After many years far from osdev, i decided to go back and create a new kernel from scratch (64bit this time) in the free time, with no real big objective, just try to go back into the fun of low level programming... after being forced to use javascript at work for some time! (but recently i moved to python lol)
Btw here my question, i was following various tutorial on how to create a hello world 64bit kernel, like this one: https://intermezzos.github.io/book/firs ... aders.html
and i followed it, and launched my C kernel, printed lot of stuff, started to write some print functions etc.. everything works fine.
Now in my previous OS, that used multiboot1 specs, i was able to pass a data structure to the kernel containing some useful info (like the flags, mem_lower, mem_uppper, cmdline, etc) the multiboot_info_t data structure.
And as far as i know it is possible with multiboot2 too.
What i understood is that the information should be stored in ebx (this is written in the documentation), and eax should contain the magic number.
So on my new kernel i have done the exact same thing i did in the previous one, pushed content of ebx just before doing the long jump.
Code: Select all
push rbx
call kernel_start
My problem is that i haven't a clear idea of what is the data type i should expect from the bootloader, if there is any, or need to guess like here https://www.gnu.org/software/grub/manua ... rnel_002ec
Btw before entering into the kernel i switched to 32bit thant to 64bit, that means that loaded paging, and gdt. And mapped the kernel into memory. So probably this can be one of the issues. But in theory i never touch ebx (unless something else does). Or could be that once i enabled paging
My multiboot_header looks like it now:
Code: Select all
section .multiboot_header
header_start:
dd 0xe85250d6 ;magic_number
dd 0 ;Protected mode
dd header_end - header_start ;Header length
;compute checksum
dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start))
dd 0x4 ;Add memory information tag
dd 0x10 ; Size of the current tag
;end tag
dw 0 ;type
dw 0 ;flags
dd 8 ;size
header_end:
Code: Select all
ENTRY(start)
SECTIONS {
. = 1M;
.boot :
{
/* Be sure that multiboot header is at the beginning */
*(.multiboot_header)
}
.text :
{
*(.text)
}
end = .;
}
Most of the code of the boot sequence is pretty similar to the one in the link posted above (the intermezzos book).
What information i'm missing? And mainly when the ebx content should be pushed into the stack?
Thanks!