HEL: Add heap module; locate GOP handle
This commit is contained in:
parent
406f17c1db
commit
dd57a31d38
19
src/hel/heap.d
Normal file
19
src/hel/heap.d
Normal file
@ -0,0 +1,19 @@
|
||||
private __gshared align(4096) ubyte[512 * 1024] g_heap;
|
||||
private __gshared size_t g_heap_index;
|
||||
|
||||
ubyte * heap_base()
|
||||
{
|
||||
return &g_heap[g_heap_index];
|
||||
}
|
||||
|
||||
size_t heap_free()
|
||||
{
|
||||
return g_heap.sizeof - g_heap_index;
|
||||
}
|
||||
|
||||
ubyte * heap_consume(size_t size)
|
||||
{
|
||||
ubyte * rv = &g_heap[g_heap_index];
|
||||
g_heap_index += (size + 4095u) & 0xFFFFFFFFFFFFF000u;
|
||||
return rv;
|
||||
}
|
@ -1,8 +1,19 @@
|
||||
import uefi;
|
||||
import output;
|
||||
import heap;
|
||||
|
||||
__gshared EFI_SYSTEM_TABLE * g_st;
|
||||
|
||||
private void wait_key()
|
||||
{
|
||||
writeln("Press any key...");
|
||||
g_st.ConIn.Reset(g_st.ConIn, FALSE);
|
||||
EFI_INPUT_KEY key;
|
||||
while (g_st.ConIn.ReadKeyStroke(g_st.ConIn, &key) == EFI_NOT_READY)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
|
||||
{
|
||||
g_st = st;
|
||||
@ -11,13 +22,21 @@ extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
|
||||
|
||||
writeln("HOS EFI loader");
|
||||
writeln("Firmware vendor: '%S', version: 0x%x", st.FirmwareVendor, st.FirmwareVendor);
|
||||
writeln("Press any key...");
|
||||
|
||||
st.ConIn.Reset(st.ConIn, FALSE);
|
||||
EFI_INPUT_KEY key;
|
||||
while (st.ConIn.ReadKeyStroke(st.ConIn, &key) == EFI_NOT_READY)
|
||||
UINTN buffer_size = heap_free();
|
||||
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_HANDLE * handles = cast(EFI_HANDLE *)heap_base();
|
||||
EFI_STATUS status = st.BootServices.LocateHandle(ByProtocol,
|
||||
&gop_guid, null, &buffer_size, handles);
|
||||
if (status != EFI_SUCCESS)
|
||||
{
|
||||
writeln("LocateHandle: error %u", status);
|
||||
wait_key();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
EFI_HANDLE gop_handle = handles[0];
|
||||
|
||||
wait_key();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user