46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
#include "efi.h"
|
|
|
|
#include "../types.h"
|
|
#include "../lnxboot.h"
|
|
|
|
#include "./memmap.h"
|
|
|
|
static bool IsPresent = false;
|
|
|
|
// XXX: This was static but something got fucked up when it was.
|
|
// investigate later
|
|
const struct EfiSystemTable* SystemTable = 0;
|
|
|
|
void EfiInitialize() {
|
|
// Get the system table
|
|
if ((BootBootParams->efi_info.EfiSystemTable | BootBootParams->efi_info.EfiSystemTableHigh) != 0) {
|
|
SystemTable = (struct EfiSystemTable*)(
|
|
(uptr)BootBootParams->efi_info.EfiSystemTable |
|
|
((uptr)BootBootParams->efi_info.EfiSystemTableHigh << 32)
|
|
);
|
|
} else goto fail;
|
|
|
|
// Load the memory map
|
|
if ((BootBootParams->efi_info.EfiMemoryMap | BootBootParams->efi_info.EfiMemoryMapHigh) != 0) {
|
|
if (BootBootParams->efi_info.EfiMemoryDescriptionSize == 0) goto fail;
|
|
|
|
EfiLoadStoredMemoryMap(
|
|
(struct EfiMemoryDescription*)(
|
|
(u64)BootBootParams->efi_info.EfiMemoryMap |
|
|
((u64)BootBootParams->efi_info.EfiMemoryMapHigh << 32)
|
|
),
|
|
BootBootParams->efi_info.EfiMemoryMapSize / BootBootParams->efi_info.EfiMemoryDescriptionSize,
|
|
BootBootParams->efi_info.EfiMemoryDescriptionSize
|
|
);
|
|
} else goto fail;
|
|
|
|
IsPresent = true;
|
|
return;
|
|
|
|
fail: IsPresent = false;
|
|
return;
|
|
}
|
|
|
|
bool EfiPresent() { return IsPresent; }
|
|
const struct EfiSystemTable* EfiGetSystemTable() { return SystemTable; }
|