Jump to HULK from assembly

This commit is contained in:
Josh Holtrop 2022-03-26 00:36:23 -04:00
parent f29bd9d00c
commit f761d0a445
2 changed files with 8 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import hulk.header : HulkHeader = Header;
import hos.page_table;
import hos.cpu;
import hos.memory;
import ldc.llvmasm;
__gshared EFI_SYSTEM_TABLE * st;
private __gshared BootInfo bootinfo;
@ -376,10 +377,12 @@ private void build_page_tables(ulong max_physical_address, ulong bss_phys, ulong
/**
* Jump to HULK entry point.
*/
private void jump_to_hulk()
private void jump_to_hulk(ulong stack_end)
{
void function(BootInfo *) hulk_entry_fn = cast(void function(BootInfo *))hulk_header().entry;
hulk_entry_fn(&bootinfo);
__asm(
"jmpq *$0",
"r,{rdi},{rsp}",
hulk_header().entry, &bootinfo, stack_end);
}
/**
@ -431,7 +434,7 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
bootinfo.bss_phys = bss_phys;
bootinfo.stack_phys = stack_phys;
jump_to_hulk();
jump_to_hulk(stack_phys + hulk_stack_size());
return EFI_SUCCESS;
}

View File

@ -26,7 +26,7 @@ private __gshared Header hulk_header = {
*
* @param bootinfo Pointer to HULK boot information structure.
*/
extern(C) void hulk_start(ulong rdi, ulong rsi, ulong rdx, BootInfo * bootinfo)
void hulk_start(BootInfo * bootinfo)
{
fb.initialize(bootinfo.fb.buffer, bootinfo.fb.width, bootinfo.fb.height, bootinfo.fb.stride);
console.initialize();