multiboot header doesn't work in boot file
Posted: Tue Aug 20, 2013 2:19 am
I'm trying to write a multiboot kernel compliant using the grub (legacy) specification , here is the content of my boot.s (written with the gnu as)
The boot.h file content some definition for grub:
I also set up the linker like this:
For the moment , my kernel_main simply return the value 0x01 which i'm expecting in the %eax register, however when i execute the kernel with:
and then issue the command info registers in qemu , i always find a value of 18 for %eax. So my questions are: is my boot.s file correctly defined to be grub compliant? and why the value 18 in %eax instead of 0x01?
Code: Select all
#include "boot.h"
.code32
.globl start
.type start, @function
.extern kernel_main
.type kernel_main, @function
.bss
.comm stack, STACK_SIZE
.section .mboot
.align 4
.long MBOOT_HEADER_MAGIC
.long MBOOT_HEADER_FLAGS
.long MBOOT_CHECKSUM
.text
start:
movl $(stack + STACK_SIZE) , %esp
cli
call kernel_main
sti
hlt
jmp .
Code: Select all
#ifndef _BOOT_H_
#define _BOOT_H_
#define MBOOT_PAGE_ALIGN 1<<0
#define MBOOT_MEM_INFO 1<<1
#define MBOOT_HEADER_MAGIC 0x1BADB002
#define MBOOT_HEADER_FLAGS MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO
#define MBOOT_CHECKSUM -( MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)
#define STACK_SIZE 0x4000
#endif /* _BOOT_H_ */
Code: Select all
ENTRY(start)
OUTPUT_ARCH(i386)
OUTPUT_FORMAT("elf32-i386")
SECTIONS
{
. = 1M;
.mboot ALIGN(4K) :
{
*(.mboot)
}
.text ALIGN(4K) :
{
*(.text)
*(.rodata)
}
.data ALIGN(4K) :
{
*(.data)
}
.bss ALIGN(4K) :
{
*(.bss)
}
}
Code: Select all
qemu -kernel kernel.bin -monitor stdio