moving away from GRUB

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
kenneth_phough
Member
Member
Posts: 106
Joined: Sun Sep 18, 2005 11:00 pm
Location: Williamstown, MA; Worcester, MA; Yokohama, Japan
Contact:

moving away from GRUB

Post by kenneth_phough »

A member on our dev team developed a FAT12 bootstrap which will load our kernel in real mode, so I decided to merge the second boot strap with the kernel's kernel entry which was formerly designed for GRUB. So I got rid of the multiboot header and added code to enable the A20 gate and enter pmode (also loading a temporary GDT which will be modified later on) however when i compiled and linked everything and loaded it on to a floppy image and tried it on Bochs the kernel.bin was loaded but nothing happened after that. I did a little debuging and found out that every thing up to enabling the A20 gate seems to work fine but I can't check its normal operation after that.
So I decided to make a test kernel entry file that will just print helloworld on to the screen and it work..fwew!
So I decided to link that with the rest of the kenrel files nowing that what should happen is that "hello world" would be printed on screen but nothing else will happen. I was wrong...I couldn't get it to link. Found out that my link.ld script doesn't allow (I'm lost at this point so I might not make sense but..) the following in my kernel entry code:
SECTION .data
hello db 'hello world'
I am compiling the asm file as follows:
nasm -f aout kernel_ent -o kernel_ent.o
aout so I can link it.
The script links it so the output is binary and the kernel will be loaded at 1MB.
I get the following error when I link the files:
relocation truncated to fit: 16 against '.data'

what do I need to add to my script to fix this problem.

Thanks in advance :)

Yours,
Kenneth
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post by bubach »

I found this:
http://www.osdev.org/phpBB2/viewtopic.p ... +truncated

when searching for "relocation AND truncated".

HTH
User avatar
kenneth_phough
Member
Member
Posts: 106
Joined: Sun Sep 18, 2005 11:00 pm
Location: Williamstown, MA; Worcester, MA; Yokohama, Japan
Contact:

Post by kenneth_phough »

Should have searched the error msg... :oops:

Thanks a bunch! :D

But now I've encountered a new question...

What I am trying to do is create an asm file called kernel_ent.asm that will change the VGA monitor mode to 320x200 graphics then enable A20, load a temporary GDT and finally enter Pmode and doing a far jump to kmain();. However, if I have the first couple of lines in kernel_ent.asm work in a 16bit real mode but the rest in pmode do I still need to modify the linker script to work in real mode? And would that mean that once the OS is loaded in real mode and I move to pmode I would need to dynamically relocate the kernel to a higher memory?
Also the bootstrap load kernel.bin at 0x100000.

Thanks in advance,
Kenneth
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post by bubach »

I don't know much about that, but in my opinion it seems easier to assemble the 16-bit code seperatly and merge with the rest into some sort of img-file.
User avatar
kenneth_phough
Member
Member
Posts: 106
Joined: Sun Sep 18, 2005 11:00 pm
Location: Williamstown, MA; Worcester, MA; Yokohama, Japan
Contact:

Post by kenneth_phough »

your right. I agree, i think that is the best. Maybe even have the second stage loader as a seprate file and have that seek for the kernel.bin and have it load that.

Thanks :D
Kenneth
Post Reply