Page 1 of 1

GRUB

Posted: Sun Oct 01, 2006 1:26 pm
by joke
Hi all,

i want to get my kernel loaded by grub. its real mode kernel and flat binary (.bin) when i tried to load it using a pre-installed image it told me that the format was not recognisable. so my questions
1) do i have to switch to elf/a.out to use grub? if yes how can i compile to these binary formats? Don't forget that im programming a real mode kernel and i write the hole code in assembly.
2)Where can i find some reliable info on how to install grub on a floppy or at least find some good pre-installed images?

Thank you

Re: GRUB

Posted: Sun Oct 01, 2006 8:27 pm
by rexlunae
joke wrote:Hi all,

i want to get my kernel loaded by grub. its real mode kernel and flat binary (.bin) when i tried to load it using a pre-installed image it told me that the format was not recognisable. so my questions
1) do i have to switch to elf/a.out to use grub? if yes how can i compile to these binary formats? Don't forget that im programming a real mode kernel and i write the hole code in assembly.
2)Where can i find some reliable info on how to install grub on a floppy or at least find some good pre-installed images?

Thank you
For a real mode kernel, I don't think it makes much sense to use GRUB. GRUB starts kernels in protected mode, to avoid the need for each kernel to do the switch itself. In order to use GRUB, you'd have to switch back to real mode after it loads your kernel. The only alternative is to use the "chainloader" feature, which basically does what the bios does.

For more info on GRUB, try the documentation here.

Posted: Sun Oct 01, 2006 11:32 pm
by prajwal
It is not necessary that ur kernel should be in ELF/a.out format...
Even if your kernel is a flat bin, to boot from Grub, u need a aout kludge...
e.i, a Multiboot header... iat the begining of ur flat binary kernel (something like withn 1 KB / x KB of your flat binary). if u do "info grub" u'll get full explanation...

Try upgrading to "Protected" mode to enjoy "Freedom" :)

Posted: Wed Oct 04, 2006 8:31 am
by joke
i wrote a simple asm prog to test if i can go out of pmode back to real mode.

i added
MODULEALIGN equ 1<<0
MEMINFO equ 1<<1
FLAGS equ MODULEALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
and
AOUT_KLUDGE equ 1<<16

but GRUB still says Unrecognized format
help!

Posted: Wed Oct 04, 2006 10:59 am
by jvff
IIRC, equ doesn't save values on the output. You need (after the equ) something like:

Code: Select all

header:
dd MAGIC
dd FLAGS
...
etc (following the format and sequence of the header)

Also, make sure to make the endianess compatible, for example a double-word 0xAABBCCDD is stored as the sequence of bytes: DD CC BB AA.

Somebody please correct me if I'm wrong. Hope this helps,

JVFF

Posted: Wed Oct 04, 2006 8:31 pm
by rexlunae
Another problem you may encounter if you insist on using GRUB to load a real mode kernel is the fact that (last I knew) GRUB cannot load kernels below the 1MB address mark, which means that you will need to start the kernel above 1MB, then move it, before disabling real mode.

But, as I said before, I still don't think it makes sense to use GRUB to load a real mode kernel. It really isn't intended for it.