Boot Services Signature: 0x56524553544F4F42
Boot Services Revision: 0x0000000000020046
Boot Services Header Size: 0x0000000000000178
The revision is a little suspect with the 6, as I do not believe this is per the EFI specs, but could be an emulator specific variation.
Here is the code that use to get the memory:
Code: Select all
EFI_SYSTEM_TABLE *efi_system_table = (EFI_SYSTEM_TABLE *)efi64_tag->pointer;
EFI_BOOT_SERVICES *boot_services = (EFI_BOOT_SERVICES *)efi_system_table->BootServices;
inspect_boot_services(efi_system_table);
uint8_t memory_map[4096];
EFI_MEMORY_MAP_INFO mmap_info = {
.MemoryMapSize = 0,
.MapKey = 0,
.DescriptorSize = 0,
.DescriptorVersion = 0
};
size_t mmap_num = 0;
// call GetMeoryMap once. EFI will populate errorous values with correct ones.
EFI_STATUS status = boot_services->GetMemoryMap(
&mmap_info.MemoryMapSize,
(EFI_MEMORY_DESCRIPTOR *)memory_map,
&mmap_info.MapKey,
&mmap_info.DescriptorSize,
&mmap_info.DescriptorVersion);
To make maters worse, if I try to rung GetMemoryMap again, even with a fresh set of data, the CPU will crash (but that’s an issue for another day).
After much debugging, I feel it comes down to some little thing that I am doing wrong in my code, or a problem with emulation. I am using QEMU version 8.1.0 and windows 10.0.19045.5247.
Here is my code for my EFI tables which may have the issue:
Code: Select all
typedef uint64_t EFI_STATUS;
typedef struct
{
uint64_t Signature;
uint32_t Revision;
uint32_t HeaderSize;
uint32_t CRC32;
uint32_t Reserved;
} EFI_TABLE_HEADER;
typedef struct
{
// Table Header
EFI_TABLE_HEADER Hdr;
// Task Priority Services
void *RaiseTPL;
void *RestoreTPL;
// Memory Services
EFI_STATUS (*AllocatePages)
(uint32_t Type, uint32_t MemoryType, uint64_t Pages, uint64_t *Memory);
EFI_STATUS (*FreePages)
(uint64_t Memory, uint64_t Pages);
EFI_STATUS (*GetMemoryMap)
(
uint64_t *MemoryMapSize,
void *MemoryMap,
uint64_t *MapKey,
uint64_t *DescriptorSize,
uint32_t *DescriptorVersion);
EFI_STATUS (*AllocatePool)
(uint32_t PoolType, uint64_t Size, void **Buffer);
EFI_STATUS (*FreePool)
(void *Buffer);
…
} EFI_BOOT_SERVICES;