mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-02 21:26:59 +03:00
linux: Pass additional EFI info to kernel
This commit is contained in:
parent
8475f98f08
commit
f2b172be71
@ -14,6 +14,8 @@ EFI_SYSTEM_TABLE *gST;
|
||||
EFI_BOOT_SERVICES *gBS;
|
||||
EFI_RUNTIME_SERVICES *gRT;
|
||||
EFI_HANDLE efi_image_handle;
|
||||
EFI_MEMORY_DESCRIPTOR *efi_mmap = NULL;
|
||||
UINTN efi_mmap_size = 0, efi_desc_size = 0, efi_desc_ver = 0;
|
||||
#endif
|
||||
|
||||
bool parse_resolution(int *width, int *height, int *bpp, const char *buf) {
|
||||
|
@ -15,6 +15,8 @@ extern EFI_SYSTEM_TABLE *gST;
|
||||
extern EFI_BOOT_SERVICES *gBS;
|
||||
extern EFI_RUNTIME_SERVICES *gRT;
|
||||
extern EFI_HANDLE efi_image_handle;
|
||||
extern EFI_MEMORY_DESCRIPTOR *efi_mmap;
|
||||
extern UINTN efi_mmap_size, efi_desc_size, efi_desc_ver;
|
||||
|
||||
extern bool efi_boot_services_exited;
|
||||
bool efi_exit_boot_services(void);
|
||||
|
@ -228,26 +228,24 @@ void init_memmap(void) {
|
||||
EFI_STATUS status;
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR tmp_mmap[1];
|
||||
UINTN mmap_size = sizeof(tmp_mmap);
|
||||
UINTN mmap_key = 0, desc_size = 0, desc_ver = 0;
|
||||
efi_mmap_size = sizeof(tmp_mmap);
|
||||
UINTN mmap_key = 0;
|
||||
|
||||
status = uefi_call_wrapper(gBS->GetMemoryMap, 5,
|
||||
&mmap_size, tmp_mmap, &mmap_key, &desc_size, &desc_ver);
|
||||
&efi_mmap_size, tmp_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
|
||||
|
||||
EFI_MEMORY_DESCRIPTOR *efi_mmap;
|
||||
|
||||
mmap_size += 4096;
|
||||
efi_mmap_size += 4096;
|
||||
|
||||
status = uefi_call_wrapper(gBS->AllocatePool, 3,
|
||||
EfiLoaderData, mmap_size, &efi_mmap);
|
||||
EfiLoaderData, efi_mmap_size, &efi_mmap);
|
||||
|
||||
status = uefi_call_wrapper(gBS->GetMemoryMap, 5,
|
||||
&mmap_size, efi_mmap, &mmap_key, &desc_size, &desc_ver);
|
||||
&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
|
||||
|
||||
size_t entry_count = mmap_size / desc_size;
|
||||
size_t entry_count = efi_mmap_size / efi_desc_size;
|
||||
|
||||
for (size_t i = 0; i < entry_count; i++) {
|
||||
EFI_MEMORY_DESCRIPTOR *entry = (void *)efi_mmap + i * desc_size;
|
||||
EFI_MEMORY_DESCRIPTOR *entry = (void *)efi_mmap + i * efi_desc_size;
|
||||
|
||||
uint32_t our_type;
|
||||
switch (entry->Type) {
|
||||
|
@ -530,9 +530,18 @@ void linux_load(char *config, char *cmdline) {
|
||||
boot_params->acpi_rsdp_addr = (uintptr_t)acpi_get_rsdp();
|
||||
|
||||
///////////////////////////////////////
|
||||
// Jettison UEFI
|
||||
// UEFI
|
||||
///////////////////////////////////////
|
||||
#if defined (uefi)
|
||||
memcpy(&boot_params->efi_info.efi_loader_signature, "EL64", 4);
|
||||
boot_params->efi_info.efi_systab = (uint32_t)(uintptr_t)gST;
|
||||
boot_params->efi_info.efi_systab_hi = (uint32_t)((uintptr_t)gST >> 32);
|
||||
boot_params->efi_info.efi_memmap = (uint32_t)(uintptr_t)efi_mmap;
|
||||
boot_params->efi_info.efi_memmap_hi = (uint32_t)((uintptr_t)efi_mmap >> 32);
|
||||
boot_params->efi_info.efi_memmap_size = efi_mmap_size;
|
||||
boot_params->efi_info.efi_memdesc_size = efi_desc_size;
|
||||
boot_params->efi_info.efi_memdesc_version = efi_desc_ver;
|
||||
|
||||
efi_exit_boot_services();
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user