Move bootinfo into HULK header
This commit is contained in:
1 parent
cf5956dcd3
commit
d86745d91d
4 files changed
+47
-36
No files matched your search
+33
-29
@@ -14,7 +14,6 @@ import hos.memory;
|
||||
import ldc.llvmasm;
|
||||
|
||||
__gshared EFI_SYSTEM_TABLE * st;
|
||||
private __gshared BootInfo bootinfo;
|
||||
extern extern(C) __gshared ubyte _hulk_bin_start;
|
||||
extern extern(C) __gshared ubyte _hulk_bin_end;
|
||||
|
||||
@@ -23,6 +22,11 @@ private HulkHeader * hulk_header()
|
||||
return cast(HulkHeader *)&_hulk_bin_start;
|
||||
}
|
||||
|
||||
private BootInfo * bootinfo()
|
||||
{
|
||||
return &hulk_header().bootinfo;
|
||||
}
|
||||
|
||||
private ulong hulk_bin_phys()
|
||||
{
|
||||
return cast(ulong)&_hulk_bin_start;
|
||||
@@ -129,11 +133,11 @@ private bool set_graphics_mode()
|
||||
console.writeln("SetMode: Error %x\n", status);
|
||||
return false;
|
||||
}
|
||||
bootinfo.fb.buffer = cast(uint *)gop.Mode.FrameBufferBase;
|
||||
bootinfo.fb.width = gop.Mode.Info.HorizontalResolution;
|
||||
bootinfo.fb.height = gop.Mode.Info.VerticalResolution;
|
||||
bootinfo.fb.stride = gop.Mode.Info.PixelsPerScanLine;
|
||||
bootinfo.fb.format = gop.Mode.Info.PixelFormat;
|
||||
bootinfo().fb.buffer = cast(uint *)gop.Mode.FrameBufferBase;
|
||||
bootinfo().fb.width = gop.Mode.Info.HorizontalResolution;
|
||||
bootinfo().fb.height = gop.Mode.Info.VerticalResolution;
|
||||
bootinfo().fb.stride = gop.Mode.Info.PixelsPerScanLine;
|
||||
bootinfo().fb.format = gop.Mode.Info.PixelFormat;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -180,7 +184,7 @@ private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * max_ph
|
||||
bool found_stack;
|
||||
for (count = 0u; count < n_entries; count++)
|
||||
{
|
||||
if (count > bootinfo.memory_map.length)
|
||||
if (count > bootinfo().memory_map.length)
|
||||
{
|
||||
console.writeln("Memory map too large");
|
||||
for (;;) {}
|
||||
@@ -202,29 +206,29 @@ private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * max_ph
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bootinfo.memory_map[count].base = descriptor.PhysicalStart;
|
||||
bootinfo.memory_map[count].size = descriptor.NumberOfPages * 4096u;
|
||||
bootinfo.memory_map[count].type = efi_to_hulk_memory_map_type[descriptor.Type];
|
||||
bootinfo().memory_map[count].base = descriptor.PhysicalStart;
|
||||
bootinfo().memory_map[count].size = descriptor.NumberOfPages * 4096u;
|
||||
bootinfo().memory_map[count].type = efi_to_hulk_memory_map_type[descriptor.Type];
|
||||
if ((!found_bss) &&
|
||||
(descriptor.Type == EfiConventionalMemory) &&
|
||||
(bootinfo.memory_map[count].size >= hulk_bss_size()))
|
||||
(bootinfo().memory_map[count].size >= hulk_bss_size()))
|
||||
{
|
||||
*bss_phys = bootinfo.memory_map[count].base;
|
||||
bootinfo.memory_map[count].base += hulk_bss_size();
|
||||
bootinfo.memory_map[count].size -= hulk_bss_size();
|
||||
*bss_phys = bootinfo().memory_map[count].base;
|
||||
bootinfo().memory_map[count].base += hulk_bss_size();
|
||||
bootinfo().memory_map[count].size -= hulk_bss_size();
|
||||
found_bss = true;
|
||||
}
|
||||
if ((!found_stack) &&
|
||||
(descriptor.Type == EfiConventionalMemory) &&
|
||||
(bootinfo.memory_map[count].size >= hulk_stack_size()))
|
||||
(bootinfo().memory_map[count].size >= hulk_stack_size()))
|
||||
{
|
||||
*stack_phys = bootinfo.memory_map[count].base;
|
||||
bootinfo.memory_map[count].base += hulk_stack_size();
|
||||
bootinfo.memory_map[count].size -= hulk_stack_size();
|
||||
*stack_phys = bootinfo().memory_map[count].base;
|
||||
bootinfo().memory_map[count].base += hulk_stack_size();
|
||||
bootinfo().memory_map[count].size -= hulk_stack_size();
|
||||
found_stack = true;
|
||||
}
|
||||
}
|
||||
bootinfo.memory_map_count = count;
|
||||
bootinfo().memory_map_count = count;
|
||||
if ((!found_bss) && (!found_stack))
|
||||
{
|
||||
for (;;) {}
|
||||
@@ -365,17 +369,17 @@ private void build_page_tables(ulong max_physical_address, ulong bss_phys, ulong
|
||||
map2m(addr, addr, pt_base);
|
||||
}
|
||||
/* Map any memory regions that are outside physical RAM. */
|
||||
for (size_t i = 0u; i < bootinfo.memory_map_count; i++)
|
||||
for (size_t i = 0u; i < bootinfo().memory_map_count; i++)
|
||||
{
|
||||
ulong addr = bootinfo.memory_map[i].base;
|
||||
ulong addr = bootinfo().memory_map[i].base;
|
||||
if (addr >= max_physical_address)
|
||||
{
|
||||
map4kregion(addr, addr, bootinfo.memory_map[i].size, pt_base);
|
||||
map4kregion(addr, addr, bootinfo().memory_map[i].size, pt_base);
|
||||
}
|
||||
}
|
||||
/* Map graphics framebuffer. */
|
||||
ulong framebuffer_size = bootinfo.fb.height * bootinfo.fb.stride * 4u;
|
||||
ulong fb_phys = cast(ulong)bootinfo.fb.buffer;
|
||||
ulong framebuffer_size = bootinfo().fb.height * bootinfo().fb.stride * 4u;
|
||||
ulong fb_phys = cast(ulong)bootinfo().fb.buffer;
|
||||
ulong fb_virt = hulk_virt_framebuffer_address();
|
||||
map4kregion(fb_virt, fb_phys, framebuffer_size, pt_base);
|
||||
/* Map HULK regions. */
|
||||
@@ -391,8 +395,8 @@ private void jump_to_hulk()
|
||||
{
|
||||
__asm(
|
||||
"jmpq *$0",
|
||||
"r,{rdi},{rsp}",
|
||||
hulk_header().entry, &bootinfo, hulk_virt_stack_top());
|
||||
"r,{rsp}",
|
||||
hulk_header().entry, hulk_virt_stack_top());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,9 +444,9 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
|
||||
|
||||
build_page_tables(max_physical_address, bss_phys, stack_phys);
|
||||
|
||||
bootinfo.hulk_phys = hulk_bin_phys();
|
||||
bootinfo.bss_phys = bss_phys;
|
||||
bootinfo.stack_phys = stack_phys;
|
||||
bootinfo().hulk_phys = hulk_bin_phys();
|
||||
bootinfo().bss_phys = bss_phys;
|
||||
bootinfo().stack_phys = stack_phys;
|
||||
|
||||
jump_to_hulk();
|
||||
|
||||
|
||||
Reference in new issue
Block a user