I am testing on qemu using its '-kernel' command line. As far as I understand it, loading a protected mode kernel with a valid multiboot header should work fine, also when loading the kernel, qemu should zero out the memory where the bss section is loaded. Unfortunately, this last part doesn't seem to be happening.
If I load a grub disk, copy my kernel into it and then run it through bochs, it seems the memory is zeroed - is this a bug with qemu or a bug in my code?
Here's my initialisation code (more or less exactly like bran's kernel tut)
Code: Select all
[BITS 32]
global start
start:
mov esp, _sys_stack
jmp stublet
ALIGN 4
mboot:
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
dd mboot
dd code
dd bss
dd end
dd start
stublet:
extern kmain
call kmain
...
Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(COMMON)
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Code: Select all
int ticks;
void kmain()
{
...
char buff[0x100];
itoa(ticks, buff);
puts("ticks - ");
puts(buff);
puts("\n");
}
Any ideas?