Page 1 of 2

Grub and a kernel

Posted: Wed Feb 26, 2003 9:40 am
by Omegaice
Hi, i have started to use grub, i have made myself a bootable disk that comes up with the menu to chose the os to load. I try and load my kernel "kernel.sys" that has been compiled with gxx from djgpp, and it says that it is an unsuported executable format. i need some help to get this working.

Re:Grub and a kernel

Posted: Wed Feb 26, 2003 9:42 am
by Pype.Clicker
grub requires ELF, Djgpp offers COFF ... hence the problem :)

check DF's posts for an ELF version of Djgpp :)

Re:Grub and a kernel

Posted: Wed Feb 26, 2003 11:00 am
by Omegaice
ok, i have read his posts but on the thing saying how to make it compile things to elf files it says you need 4 files that are ment to be in the bin directory of the djgpp but i dont have them.

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 3:08 am
by Thunder
I have the same problem:
you need to insert the elf file definition:
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1

MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

; The Multiboot header (in NASM syntax)
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM

insert it into your code at start,and compile it,
I have tried with it but gcc shows error,but nasm compiles it but I don't know how to combine these files

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 3:13 am
by Pype.Clicker
just try an

%incbin kernel.o

in your NASM file ;)

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 3:46 am
by Omegaice
hmm, i think you missunderstood me. if you go to http://www.mega-tokyo.com/os/os-faq-elf.html#elf_files then it tells you that you need is a good installation of DJGPP, you will need sed, bison, flex, bash, etc. These files are ment to be in the bin directory of djgpp except i dont have them, where can i get a version that does.

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 4:04 am
by Pype.Clicker
omegaice : that was a response to Thunder ... i've not been testing the ELF feature of DjGpp : when i need ELF i use linux ...

... BUT i have the power of g00gle with me :)

http://membres.lycos.fr/placr/binutils-2.9-elf.zip

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 5:00 am
by Omegaice
ok, that made an elf file when i linked it but grub still says that it is an invalid or unsupported executable format

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 6:35 am
by Thunder
for me it was the same, but in GRUB totorials it was shown that this source should help but GRUB again showed that was a failure ???

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 8:17 am
by Omegaice
this would all work fine if someone would post a link to a bootloader that is written in assembler and works with c++ or c, i have been searching for 4 days now for a bootloader that works

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 8:46 am
by Pype.Clicker
GRUB works. Many people use it ... you're just using it .. wrong.
It seems that nobody that sees your thread knows how to help you, that's all ...

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 9:31 am
by distantvoices
and with your attitude you will search your whole long life after such a bootloader, Mr. Omegaice!

0. Every bootloader outta there has to be written in assembly. In 512 bytes is not that much space for blown high level language .. just place for nitty gritty!

1. The best bootloader cannot jump to any c-function or c-label, because it is not linked to this label. The bootloader just knows an ADRESS to jump to. conclusio: the bootloader cares crap about the language you use for kernel: It just cares about the adress to jump to finally.

2. At the adress the bootloader jumps to, SHALL be an assembly stub, that then jumps to the c or c++ code.

3. the assembly stub and the c or c++ kernel are linked together.

4. I miss the magic word in your request, Mr. Omegaice. Maybe you do not provide grub with it too. grub also likes to be asked politely.

stay safe

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 10:12 am
by Omegaice
Thanks for all the help, the problem was that i needed a multi boot header, i have added that and now it works

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 11:29 am
by Omegaice
ok, take that back, it now loads the kernel but it does nothing, i have a c routine to clear the screen, i call that and then i write hello on the screen, it clears the screen which is actualy grub clearing it but then it doesnt put any chars on the screen, this is in vmware by the way, then i changed it so that it just put something on the screen and it came up with an error saying tripple error- shutdown and shutsdown vmware

Re:Grub and a kernel

Posted: Thu Feb 27, 2003 2:34 pm
by Whatever5k
Well, that is most probably a bug in your code - give some more details (post some code)