I am trying to call the BootServices->GetMemoryMap()
function, but the function definition and the documentation does not make sense to me. The UEFI spec (v2.6) says that the definition of the function is (page: 207):
typedef EFI_STATUS(EFIAPI *EFI_GET_MEMORY_MAP)(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion);
But the parameters section says:
MemoryMap: A pointer to the buffer in which firmware places the current memory map. The map is an array of EFI_MEMORY_DESCRIPTORs.
If the memory map is an array of EFI_MEMORY_DESCRIPTOR
s and the parameter is supposed to be a pointer to a buffer, how can the parameter's type be IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap
, shouldn't it be IN OUT EFI_MEMORY_DESCRIPTOR **MemoryMap
?
The map is an array of EFI_MEMORY_DESCRIPTORs.
If the map is an array of EFI_MEMORY_DESCRIPTOR
s then the name of the array decays to a pointer to the first element in that array, i.e to the
EFI_MEMORY_DESCRIPTOR *MemoryMap
So given the function
EFI_STATUS efi_get_memorymap(IN OUT UINTN *MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, ...);
and a map of descriptors
EFI_MEMORY_DESCRIPTOR memory_map[2];
you can pass the array this way:
status = efi_get_memorymap(size, memory_map, ...);