UEFI 的 BootServices->GetMemoryMap() 的令人困惑的文档
Confusing documentation for UEFI's BootServices->GetMemoryMap()
我正在尝试调用 BootServices->GetMemoryMap()
函数,但函数定义和文档对我来说没有意义。 UEFI 规范 (v2.6) 说函数的定义是 (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);
但是参数部分说:
MemoryMap: A pointer to the buffer in which firmware places the current
memory map. The map is an array of
EFI_MEMORY_DESCRIPTORs.
如果内存映射是EFI_MEMORY_DESCRIPTOR
的数组,参数应该是一个指向缓冲区的指针,参数的类型怎么会是IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap
,不应该是IN OUT EFI_MEMORY_DESCRIPTOR **MemoryMap
?
The map is an array of EFI_MEMORY_DESCRIPTORs.
如果映射是 EFI_MEMORY_DESCRIPTOR
的数组,则数组的名称会衰减为指向该数组中第一个元素的指针,即
EFI_MEMORY_DESCRIPTOR *MemoryMap
所以给定函数
EFI_STATUS efi_get_memorymap(IN OUT UINTN *MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, ...);
和描述符映射
EFI_MEMORY_DESCRIPTOR memory_map[2];
你可以这样传递数组:
status = efi_get_memorymap(size, memory_map, ...);
我正在尝试调用 BootServices->GetMemoryMap()
函数,但函数定义和文档对我来说没有意义。 UEFI 规范 (v2.6) 说函数的定义是 (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);
但是参数部分说:
MemoryMap: A pointer to the buffer in which firmware places the current memory map. The map is an array of EFI_MEMORY_DESCRIPTORs.
如果内存映射是EFI_MEMORY_DESCRIPTOR
的数组,参数应该是一个指向缓冲区的指针,参数的类型怎么会是IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap
,不应该是IN OUT EFI_MEMORY_DESCRIPTOR **MemoryMap
?
The map is an array of EFI_MEMORY_DESCRIPTORs.
如果映射是 EFI_MEMORY_DESCRIPTOR
的数组,则数组的名称会衰减为指向该数组中第一个元素的指针,即
EFI_MEMORY_DESCRIPTOR *MemoryMap
所以给定函数
EFI_STATUS efi_get_memorymap(IN OUT UINTN *MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, ...);
和描述符映射
EFI_MEMORY_DESCRIPTOR memory_map[2];
你可以这样传递数组:
status = efi_get_memorymap(size, memory_map, ...);