Grub and a kernel

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.
Omegaice

Grub and a kernel

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Grub and a kernel

Post by Pype.Clicker »

grub requires ELF, Djgpp offers COFF ... hence the problem :)

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

Re:Grub and a kernel

Post 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.
Thunder

Re:Grub and a kernel

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Grub and a kernel

Post by Pype.Clicker »

just try an

%incbin kernel.o

in your NASM file ;)
Omegaice

Re:Grub and a kernel

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Grub and a kernel

Post 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
Omegaice

Re:Grub and a kernel

Post 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
Thunder

Re:Grub and a kernel

Post 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 ???
Omegaice

Re:Grub and a kernel

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Grub and a kernel

Post 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 ...
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Grub and a kernel

Post 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
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Omegaice

Re:Grub and a kernel

Post 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
Omegaice

Re:Grub and a kernel

Post 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
Whatever5k

Re:Grub and a kernel

Post by Whatever5k »

Well, that is most probably a bug in your code - give some more details (post some code)
Post Reply