Page 1 of 1

multiboot 2 header

Posted: Sun Sep 19, 2010 10:34 am
by lemonyii
hi,
sorry for my posting frequently, but i'm really working hard.
this is my most simple multiboot 2 header:

Code: Select all

MAGIC       equ		0xE85250D6           	; 'magic number' , version 1.6
ARCH		equ		0
HDRLEN		equ		24
CHECKSUM    equ		-(MAGIC + ARCH + HDRLEN + 8) 

align 	8
MultiBoot2Header:
dd	MAGIC
dd	ARCH
dd	HDRLEN
dd	CHECKSUM
dd	0				;tag end
dd	8
but it can't be recognized by grub2. is there any fields that must present here? i didn't see any.
there is a sample but the CHECKSUM field is not complete. chechsum is bad, what a disaster!
can anyone figure it out for me or do you have a sample?
thank you,
lemonyii

Re: multiboot 2 header

Posted: Sun Sep 19, 2010 12:34 pm
by xvedejas
The magic number for GRUB2 is 0x1BADB002...

Re: multiboot 2 header

Posted: Sun Sep 19, 2010 4:26 pm
by Owen
xvedejas wrote:The magic number for GRUB2 is 0x1BADB002...
1BADB002 is Multiboot 1.

Re: multiboot 2 header

Posted: Sun Sep 19, 2010 5:00 pm
by Hangin10
The tagged format is just for GRUB -> Kernel, so perhaps removing those two extra dwords from the end (and correcting header size & checksum) will help?

Re: multiboot 2 header

Posted: Sun Sep 19, 2010 6:48 pm
by lemonyii
Hangin10 wrote:The tagged format is just for GRUB -> Kernel, so perhaps removing those two extra dwords from the end (and correcting header size & checksum) will help?
in fact my first one is without that two dwords, and of course do not work. then i found there is a tag of TAG_END, and it seems very special, so i added them. it seems the sample in specification helps a lot, but mine is almost copied from it.
still working.
thank you,
lemonyii

Re: multiboot 2 header

Posted: Mon Sep 20, 2010 1:50 am
by gerryg400
Check this thread. The Grub2 implementation does not match the spec.

http://forum.osdev.org/viewtopic.php?f= ... 81&start=0

Re: multiboot 2 header

Posted: Mon Sep 20, 2010 2:25 am
by lemonyii
oh, thank you so much!
hell the grub2! and i hope that's the only place that grub2 do not support in the sepci. if any more, i'll consider to follow multiboot1.
trying.
thanks!
lemonyii

Re: multiboot 2 header

Posted: Thu Nov 16, 2017 11:45 am
by tongko
Hi, not sure this will help. I'm facing problem where grub 2 doesn't recognize the multiboot2 magic, but then I read it somewhere on the web and change my grub.cfg to the following:

Code: Select all

set timeout=15
set default=0

menuentry "Sin Hing 0.0.1" {
	multiboot2 /boot/shos.bin
}
Run grub-file:

Code: Select all

grub-file --is-x86-multiboot2 shos.bin
return 0, which means it is multiboot2 confirmed.

But then now I hit into error message saying "out of memory"...

Re: multiboot 2 header

Posted: Thu Nov 16, 2017 4:47 pm
by MichaelPetch
tongko wrote:But then now I hit into error message saying "out of memory"...
Did you specify an entry point?

Re: multiboot 2 header

Posted: Thu Nov 16, 2017 9:30 pm
by tongko
MichaelPetch wrote:
tongko wrote:But then now I hit into error message saying "out of memory"...
Did you specify an entry point?
Thanks for asking, I just solved this. Apparently, this is a typo mistake, I want to set my stack size to 1M, so I bring up the calculator and punch in 1024*1024*1024... :oops:

now that I've change it to 0x100000 then everything just working as intended, well, not everything, but at least, I can now dive into my C code which I'm more familiar with, compare to the ASM.

BTW, to the OP, I'm using Grub 2.02, which now the multiboot2 header are conform to the specification, I guess. I download the Grub2 source code and perform a search to find the multiboot2.h and found that it is fixed now. Hope this help.