Move bootinfo into HULK header
This commit is contained in:
parent
cf5956dcd3
commit
d86745d91d
@ -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();
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
*/
|
||||
module hulk.header;
|
||||
|
||||
import hulk.bootinfo;
|
||||
|
||||
/**
|
||||
* Header describing the HULK image.
|
||||
*/
|
||||
@ -32,4 +34,7 @@ struct HulkHeader
|
||||
|
||||
/** Framebuffer virtual address. */
|
||||
ulong virt_fb_buffer;
|
||||
|
||||
/** HULK boot information. */
|
||||
BootInfo bootinfo;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
module hulk.hulk;
|
||||
|
||||
import hulk.header;
|
||||
import hulk.bootinfo;
|
||||
import hulk.fb;
|
||||
import hulk.console;
|
||||
import hos.memory;
|
||||
@ -27,12 +26,10 @@ private __gshared HulkHeader hulk_header = {
|
||||
|
||||
/**
|
||||
* HULK entry point.
|
||||
*
|
||||
* @param bootinfo Pointer to HULK boot information structure.
|
||||
*/
|
||||
void hulk_start(BootInfo * bootinfo)
|
||||
void hulk_start()
|
||||
{
|
||||
fb.initialize(cast(uint *)HULK_VIRTUAL_FRAMEBUFFER_ADDRESS, bootinfo.fb.width, bootinfo.fb.height, bootinfo.fb.stride);
|
||||
fb.initialize(cast(uint *)HULK_VIRTUAL_FRAMEBUFFER_ADDRESS, hulk_header.bootinfo.fb.width, hulk_header.bootinfo.fb.height, hulk_header.bootinfo.fb.stride);
|
||||
console.initialize();
|
||||
console.clear();
|
||||
klog.initialize();
|
||||
|
@ -3,17 +3,22 @@ SECTIONS
|
||||
. = 0xFFFF800000000000;
|
||||
_hulk_mem_start = .;
|
||||
|
||||
.rodata BLOCK(4K) : ALIGN(4K)
|
||||
.hulk_header BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.hulk_header)
|
||||
*(.rodata)
|
||||
}
|
||||
_hulk_header_size = . - _hulk_mem_start;
|
||||
|
||||
.text BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.text)
|
||||
}
|
||||
|
||||
.rodata BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.rodata)
|
||||
}
|
||||
|
||||
.data BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user