Fix x86 payload passing

This commit is contained in:
Sam Tebbs 2020-06-20 15:48:55 +01:00
parent fb82dbbb77
commit 951ef07b9b

View file

@ -1,4 +1,5 @@
const constants = @import("constants");
const multiboot_info = @import("multiboot.zig").multiboot_info_t;
/// The multiboot header
const MultiBoot = packed struct {
@ -63,8 +64,9 @@ export var boot_page_directory: [1024]u32 align(4096) linksection(".rodata.boot"
};
export var kernel_stack: [16 * 1024]u8 align(16) linksection(".bss.stack") = undefined;
extern var KERNEL_ADDR_OFFSET: *u32;
extern fn kmain() void;
extern fn kmain(mb_info: *multiboot_info) void;
export fn _start() align(16) linksection(".text.boot") callconv(.Naked) noreturn {
// Set the page directory to the boot directory
@ -99,15 +101,14 @@ export fn start_higher_half() callconv(.Naked) noreturn {
asm volatile (
\\.extern KERNEL_STACK_END
\\mov $KERNEL_STACK_END, %%esp
\\xor %%ebp, %%ebp
\\mov %%esp, %%ebp
);
// Push the multiboot header address with virtual offset
asm volatile (
\\.extern KERNEL_ADDR_OFFSET
\\add $KERNEL_ADDR_OFFSET, %%ebx
\\push %%ebx
);
kmain();
// Get the multiboot header address and add the virtual offset
const mb_info_addr = asm (
\\mov %%ebx, %[res]
: [res] "=r" (-> usize)
) + @ptrToInt(&KERNEL_ADDR_OFFSET);
kmain(@intToPtr(*multiboot_info, mb_info_addr));
while (true) {}
}