Fix x86 payload passing
This commit is contained in:
parent
fb82dbbb77
commit
951ef07b9b
1 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
||||||
const constants = @import("constants");
|
const constants = @import("constants");
|
||||||
|
const multiboot_info = @import("multiboot.zig").multiboot_info_t;
|
||||||
|
|
||||||
/// The multiboot header
|
/// The multiboot header
|
||||||
const MultiBoot = packed struct {
|
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;
|
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 {
|
export fn _start() align(16) linksection(".text.boot") callconv(.Naked) noreturn {
|
||||||
// Set the page directory to the boot directory
|
// Set the page directory to the boot directory
|
||||||
|
@ -99,15 +101,14 @@ export fn start_higher_half() callconv(.Naked) noreturn {
|
||||||
asm volatile (
|
asm volatile (
|
||||||
\\.extern KERNEL_STACK_END
|
\\.extern KERNEL_STACK_END
|
||||||
\\mov $KERNEL_STACK_END, %%esp
|
\\mov $KERNEL_STACK_END, %%esp
|
||||||
\\xor %%ebp, %%ebp
|
\\mov %%esp, %%ebp
|
||||||
);
|
);
|
||||||
|
|
||||||
// Push the multiboot header address with virtual offset
|
// Get the multiboot header address and add the virtual offset
|
||||||
asm volatile (
|
const mb_info_addr = asm (
|
||||||
\\.extern KERNEL_ADDR_OFFSET
|
\\mov %%ebx, %[res]
|
||||||
\\add $KERNEL_ADDR_OFFSET, %%ebx
|
: [res] "=r" (-> usize)
|
||||||
\\push %%ebx
|
) + @ptrToInt(&KERNEL_ADDR_OFFSET);
|
||||||
);
|
kmain(@intToPtr(*multiboot_info, mb_info_addr));
|
||||||
kmain();
|
|
||||||
while (true) {}
|
while (true) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue