42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include "types.h"
 | |
| 
 | |
| #define EFI_MEMORY_TYPE_CONVENTIONAL_MEMORY 7
 | |
| 
 | |
| /// EFI Memory Descriptor
 | |
| struct EfiMemoryDescription {
 | |
| 	EfiUint32  Type;
 | |
| 	EfiVoid   *PhysicalStart;
 | |
| 	EfiVoid   *VirtualStart;
 | |
| 	EfiUint64  NumberOfPages;
 | |
| 	EfiUint64  Attribute;
 | |
| };
 | |
| 
 | |
| /**
 | |
|  * Load a memory map to use for translating pointers recovered from EFI tables.
 | |
|  */
 | |
| void EfiLoadStoredMemoryMap(
 | |
| 	struct EfiMemoryDescription* StoredMemoryMap,
 | |
| 	u32                          StoredMemoryMapEntryCount,
 | |
| 	u32                          StoredMemoryMapEntrySize
 | |
| );
 | |
| 
 | |
| /// Translate a pointer to something we can use using the stored memory map.
 | |
| void* EfiTranslatePointer(void* FirmwarePointer);
 | |
| 
 | |
| struct EfiMemoryDescription* EfiGetStoredMemoryMap();
 | |
| u32 EfiGetStoredMemoryMapEntryCount();
 | |
| u32 EfiGetStoredMemoryMapEntrySize();
 | |
| 
 | |
| /**
 | |
|  * Iterate through the EFI memory map
 | |
|  *
 | |
|  * \param _Index  VAR(int) loop index
 | |
|  * \param _Output VAR(struct EfiMemoryDescription*) variable to store the current entry
 | |
|  */
 | |
| #define EFI_MEMORY_MAP_FOREACH_(_Index, _Output) \
 | |
| 	for (_Index = 0, _Output = EfiGetStoredMemoryMap(); \
 | |
| 	     _Index < EfiGetStoredMemoryMapEntryCount(); \
 | |
| 	     _Index++, _Output = (struct EfiMemoryDescription*)(((void*)_Output) + EfiGetStoredMemoryMapEntrySize()))
 |