Allocate framebuffer buffer1 in HELLO
This commit is contained in:
parent
71c30fa932
commit
55604468c8
@ -143,7 +143,7 @@ private bool set_graphics_mode()
|
||||
/**
|
||||
* Walk the EFI memory map and translate it to the HULK bootinfo format.
|
||||
*/
|
||||
private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * physical_address_limit, UINTN * memory_map_key)
|
||||
private void get_memory_map(ulong * physical_address_limit, UINTN * memory_map_key)
|
||||
{
|
||||
immutable static ubyte[] efi_to_hulk_memory_map_type = [
|
||||
BootInfo.MemoryRegion.Type.Reserved, // EfiReservedMemoryType
|
||||
@ -181,6 +181,8 @@ private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * physic
|
||||
size_t count;
|
||||
bool found_bss;
|
||||
bool found_stack;
|
||||
bool found_fb_buffer1;
|
||||
const(size_t) fb_size = (bootinfo().fb.stride * bootinfo().fb.height * 4u + PAGE_SIZE - 1u) & ~(PAGE_SIZE - 1u);
|
||||
for (count = 0u; count < n_entries; count++)
|
||||
{
|
||||
if (count > bootinfo().memory_map.length)
|
||||
@ -212,7 +214,7 @@ private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * physic
|
||||
(descriptor.Type == EfiConventionalMemory) &&
|
||||
(bootinfo().memory_map[count].size >= hulk_bss_size()))
|
||||
{
|
||||
*bss_phys = bootinfo().memory_map[count].base;
|
||||
bootinfo().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;
|
||||
@ -221,14 +223,23 @@ private void get_memory_map(ulong * bss_phys, ulong * stack_phys, ulong * physic
|
||||
(descriptor.Type == EfiConventionalMemory) &&
|
||||
(bootinfo().memory_map[count].size >= hulk_stack_size()))
|
||||
{
|
||||
*stack_phys = bootinfo().memory_map[count].base;
|
||||
bootinfo().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;
|
||||
}
|
||||
if ((!found_fb_buffer1) &&
|
||||
(descriptor.Type == EfiConventionalMemory) &&
|
||||
(bootinfo().memory_map[count].size >= fb_size))
|
||||
{
|
||||
bootinfo().fb_buffer1_phys = bootinfo().memory_map[count].base;
|
||||
bootinfo().memory_map[count].base += fb_size;
|
||||
bootinfo().memory_map[count].size -= fb_size;
|
||||
found_fb_buffer1 = true;
|
||||
}
|
||||
}
|
||||
bootinfo().memory_map_count = count;
|
||||
if ((!found_bss) || (!found_stack))
|
||||
if ((!found_bss) || (!found_stack) || (!found_fb_buffer1))
|
||||
{
|
||||
for (;;) {}
|
||||
}
|
||||
@ -379,7 +390,7 @@ private bool map2m(ulong source_page, ulong dest_page, PageTable * pt_base)
|
||||
*
|
||||
* @param pt_base Page table base address.
|
||||
*/
|
||||
private bool map_hulk(PageTable * pt_base, ulong bss_phys, ulong stack_phys)
|
||||
private bool map_hulk(PageTable * pt_base)
|
||||
{
|
||||
/* Map HULK bin region. */
|
||||
ulong virt = hulk_virt_base_address();
|
||||
@ -389,13 +400,13 @@ private bool map_hulk(PageTable * pt_base, ulong bss_phys, ulong stack_phys)
|
||||
}
|
||||
/* Map HULK bss region. */
|
||||
virt += hulk_bin_size();
|
||||
if (!map4kregion(virt, bss_phys, hulk_bss_size(), pt_base))
|
||||
if (!map4kregion(virt, bootinfo().bss_phys, hulk_bss_size(), pt_base))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/* Map HULK stack. */
|
||||
virt = hulk_virt_stack_top() - hulk_stack_size();
|
||||
if (!map4kregion(virt, stack_phys, hulk_stack_size(), pt_base))
|
||||
if (!map4kregion(virt, bootinfo().stack_phys, hulk_stack_size(), pt_base))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -407,7 +418,7 @@ private bool map_hulk(PageTable * pt_base, ulong bss_phys, ulong stack_phys)
|
||||
*
|
||||
* @param physical_address_limit Maximum physical address to identity map.
|
||||
*/
|
||||
private bool build_page_tables(ulong physical_address_limit, ulong bss_phys, ulong stack_phys)
|
||||
private bool build_page_tables(ulong physical_address_limit)
|
||||
{
|
||||
PageTable * pt_base = new_page_table();
|
||||
if (pt_base == null)
|
||||
@ -443,7 +454,7 @@ private bool build_page_tables(ulong physical_address_limit, ulong bss_phys, ulo
|
||||
return false;
|
||||
}
|
||||
/* Map HULK regions. */
|
||||
if (!map_hulk(pt_base, bss_phys, stack_phys))
|
||||
if (!map_hulk(pt_base))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -518,13 +529,11 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ulong bss_phys;
|
||||
ulong stack_phys;
|
||||
ulong physical_address_limit;
|
||||
UINTN memory_map_key;
|
||||
for (;;)
|
||||
{
|
||||
get_memory_map(&bss_phys, &stack_phys, &physical_address_limit, &memory_map_key);
|
||||
get_memory_map(&physical_address_limit, &memory_map_key);
|
||||
|
||||
EFI_STATUS status = st.BootServices.ExitBootServices(image_handle, memory_map_key);
|
||||
if (status == EFI_INVALID_PARAMETER)
|
||||
@ -540,14 +549,12 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (!build_page_tables(physical_address_limit, bss_phys, stack_phys))
|
||||
if (!build_page_tables(physical_address_limit))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
bootinfo().hulk_phys = hulk_bin_phys();
|
||||
bootinfo().bss_phys = bss_phys;
|
||||
bootinfo().stack_phys = stack_phys;
|
||||
|
||||
jump_to_hulk();
|
||||
|
||||
|
@ -69,6 +69,9 @@ struct BootInfo
|
||||
/* Physical address of stack while jumping to HULK. */
|
||||
ulong stack_phys;
|
||||
|
||||
/* Physical address of framebuffer buffer1. */
|
||||
ulong fb_buffer1_phys;
|
||||
|
||||
/* Physical address of ACPI XSDT table. */
|
||||
ulong acpi_xsdt_phys;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user