diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-11-29 16:16:20 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-11-29 16:16:20 +0000 |
commit | bb4ff02e5b27f33fb8c96e625da169cd9d509804 (patch) | |
tree | d938c53f8331cda2b7b012786acd8445d59e2ab5 /sys/arch | |
parent | 706955dfc23c9779e358250d9c862fee1eec1446 (diff) |
Pass the EFI memory map to the kernel.
ok deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/include/biosvar.h | 9 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efiboot.c | 64 |
3 files changed, 50 insertions, 27 deletions
diff --git a/sys/arch/amd64/include/biosvar.h b/sys/arch/amd64/include/biosvar.h index a78af133764..893fbc23caf 100644 --- a/sys/arch/amd64/include/biosvar.h +++ b/sys/arch/amd64/include/biosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosvar.h,v 1.26 2019/08/04 14:28:58 kettenis Exp $ */ +/* $OpenBSD: biosvar.h,v 1.27 2019/11/29 16:16:19 kettenis Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -204,6 +204,13 @@ typedef struct _bios_efiinfo { uint32_t fb_green_mask; uint32_t fb_blue_mask; uint32_t fb_reserved_mask; + uint32_t flags; +#define BEI_64BIT 0x00000001 /* 64-bit EFI implementation */ + uint32_t mmap_desc_ver; + uint32_t mmap_desc_size; + uint32_t mmap_size; + uint64_t mmap_start; + uint64_t system_table; } __packed bios_efiinfo_t; #define BOOTARG_UCODE 12 diff --git a/sys/arch/amd64/stand/efiboot/conf.c b/sys/arch/amd64/stand/efiboot/conf.c index 3da9127caf0..ddd5d1538c2 100644 --- a/sys/arch/amd64/stand/efiboot/conf.c +++ b/sys/arch/amd64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.24 2019/10/29 02:55:51 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.25 2019/11/29 16:16:19 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -39,7 +39,7 @@ #include "efidev.h" #include "efipxe.h" -const char version[] = "3.47"; +const char version[] = "3.48"; #ifdef EFI_DEBUG int debug = 0; diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c b/sys/arch/amd64/stand/efiboot/efiboot.c index 83ede4f7ebe..73ce1606c61 100644 --- a/sys/arch/amd64/stand/efiboot/efiboot.c +++ b/sys/arch/amd64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.33 2019/03/15 06:53:37 jsg Exp $ */ +/* $OpenBSD: efiboot.c,v 1.34 2019/11/29 16:16:19 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -282,6 +282,7 @@ efi_device_path_ncmp(EFI_DEVICE_PATH *dpa, EFI_DEVICE_PATH *dpb, int deptn) * Memory ***********************************************************************/ bios_memmap_t bios_memmap[64]; +bios_efiinfo_t bios_efiinfo; static void efi_heap_init(void) @@ -338,6 +339,9 @@ efi_memprobe_internal(void) cnvmem = extmem = 0; bios_memmap[0].type = BIOS_MAP_END; + if (bios_efiinfo.mmap_start != 0) + free((void *)bios_efiinfo.mmap_start, bios_efiinfo.mmap_size); + siz = 0; status = EFI_CALL(BS->GetMemoryMap, &siz, NULL, &mapkey, &mmsiz, &mmver); @@ -403,7 +407,11 @@ efi_memprobe_internal(void) bm->addr / 1024 == extmem + 1024) extmem += bm->size / 1024; } - free(mm0, siz); + + bios_efiinfo.mmap_desc_ver = mmver; + bios_efiinfo.mmap_desc_size = mmsiz; + bios_efiinfo.mmap_size = siz; + bios_efiinfo.mmap_start = (uintptr_t)mm0; } /*********************************************************************** @@ -820,22 +828,21 @@ efi_makebootargs(void) EFI_STATUS status; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *gopi; - bios_efiinfo_t ei; + bios_efiinfo_t *ei = &bios_efiinfo; int curmode; UINTN sz, gopsiz, bestsiz = 0; - memset(&ei, 0, sizeof(ei)); /* * ACPI, BIOS configuration table */ for (i = 0; i < ST->NumberOfTableEntries; i++) { if (efi_guidcmp(&acpi_guid, &ST->ConfigurationTable[i].VendorGuid) == 0) - ei.config_acpi = (intptr_t) + ei->config_acpi = (uintptr_t) ST->ConfigurationTable[i].VendorTable; else if (efi_guidcmp(&smbios_guid, &ST->ConfigurationTable[i].VendorGuid) == 0) - ei.config_smbios = (intptr_t) + ei->config_smbios = (uintptr_t) ST->ConfigurationTable[i].VendorTable; } @@ -868,35 +875,44 @@ efi_makebootargs(void) gopi = gop->Mode->Info; switch (gopi->PixelFormat) { case PixelBlueGreenRedReserved8BitPerColor: - ei.fb_red_mask = 0x00ff0000; - ei.fb_green_mask = 0x0000ff00; - ei.fb_blue_mask = 0x000000ff; - ei.fb_reserved_mask = 0xff000000; + ei->fb_red_mask = 0x00ff0000; + ei->fb_green_mask = 0x0000ff00; + ei->fb_blue_mask = 0x000000ff; + ei->fb_reserved_mask = 0xff000000; break; case PixelRedGreenBlueReserved8BitPerColor: - ei.fb_red_mask = 0x000000ff; - ei.fb_green_mask = 0x0000ff00; - ei.fb_blue_mask = 0x00ff0000; - ei.fb_reserved_mask = 0xff000000; + ei->fb_red_mask = 0x000000ff; + ei->fb_green_mask = 0x0000ff00; + ei->fb_blue_mask = 0x00ff0000; + ei->fb_reserved_mask = 0xff000000; break; case PixelBitMask: - ei.fb_red_mask = gopi->PixelInformation.RedMask; - ei.fb_green_mask = gopi->PixelInformation.GreenMask; - ei.fb_blue_mask = gopi->PixelInformation.BlueMask; - ei.fb_reserved_mask = + ei->fb_red_mask = gopi->PixelInformation.RedMask; + ei->fb_green_mask = gopi->PixelInformation.GreenMask; + ei->fb_blue_mask = gopi->PixelInformation.BlueMask; + ei->fb_reserved_mask = gopi->PixelInformation.ReservedMask; break; default: break; } - ei.fb_addr = gop->Mode->FrameBufferBase; - ei.fb_size = gop->Mode->FrameBufferSize; - ei.fb_height = gopi->VerticalResolution; - ei.fb_width = gopi->HorizontalResolution; - ei.fb_pixpsl = gopi->PixelsPerScanLine; + ei->fb_addr = gop->Mode->FrameBufferBase; + ei->fb_size = gop->Mode->FrameBufferSize; + ei->fb_height = gopi->VerticalResolution; + ei->fb_width = gopi->HorizontalResolution; + ei->fb_pixpsl = gopi->PixelsPerScanLine; } - addbootarg(BOOTARG_EFIINFO, sizeof(ei), &ei); + /* + * EFI system table + */ + ei->system_table = (uintptr_t)ST; + +#ifdef __amd64__ + ei->flags |= BEI_64BIT; +#endif + + addbootarg(BOOTARG_EFIINFO, sizeof(bios_efiinfo), &bios_efiinfo); } void |