Multiboot Specification
The Mutliboot Specification is a specification allowing to forward important informations from a bootloader (such as Grub) to the kernel. It also specifies how a bootloader should load a kernel.
The multiboot header
A According to the multiboot specification, an OS image must contain a Multiboot Header within the first 8192 bytes of the file and must be aligned on 4 bytes.
A Multiboot compliant bootloader must be able to load ELF binaries, such as K.
In the Multiboot Header, you should have the following fields:
magic
, au32
used to identify the header (value:0x1BADB002
)flags
, au32
field used to specify the needed features. You should need the flag asking the bootloader to align all modules on a page boundary (0x1) and the flag asking the bootloader to pass memory informations to the kernel (0x2).checksum
, au32
field whose value is-(magic + flags)
State
The state of the system when the kernel starts to be executed is the following:
EAX
contains a magic value0x2BADB002
EBX
contains the address of the Multiboot information structure- The system is in 32 bits
The multiboot information structure
The bootloader fills a structure called Multiboot infortmation structure. It
is described in multiboot.h
by multiboot_info_t
.
You should check if the flag
field advertise that the informations you need
are available.
You will find in this structure the fields mods_count
and mods_addr
.
mods_addr
contains the address of an array of informations about the loaded
modules, such as the address where it is loaded and the size of the module. This
structure is defined in multiboot.h
as module_t
. The modules to load are
specified in the grub.cfg
. For K, the first module is the rom you should load.
You will need the command line passed to your kernel. You can find its address
in the cmdline
field of your Multiboot information structure.
Ressources
k/multboot.h
contains the structures used in the Multiboot specification- Multiboot Specification