diff --git a/sdk/xtdk/bltypes.h b/sdk/xtdk/bltypes.h index e667d28..7611706 100644 --- a/sdk/xtdk/bltypes.h +++ b/sdk/xtdk/bltypes.h @@ -76,6 +76,7 @@ typedef EFI_STATUS (*PBL_FRAMEBUFFER_GET_DISPLAY_INFORMATION)(OUT PXTBL_FRAMEBUF typedef EFI_STATUS (*PBL_FRAMEBUFFER_INITIALIZE)(); typedef EFI_STATUS (*PBL_FREE_PAGES)(IN UINT64 Size, IN EFI_PHYSICAL_ADDRESS Memory); typedef EFI_STATUS (*PBL_FREE_POOL)(IN PVOID Memory); +typedef VOID (*PBL_GET_MAPPINGS_COUNT)(IN PXTBL_PAGE_MAPPING PageMap, OUT PULONG NumberOfMappings); typedef EFI_STATUS (*PBL_GET_MEMORY_MAP)(OUT PEFI_MEMORY_MAP MemoryMap); typedef PLIST_ENTRY (*PBL_GET_MODULES_LIST)(); typedef INT_PTR (*PBL_GET_SECURE_BOOT_STATUS)(); @@ -308,6 +309,7 @@ typedef struct _XTBL_LOADER_PROTOCOL PBL_COPY_MEMORY CopyMemory; PBL_FREE_PAGES FreePages; PBL_FREE_POOL FreePool; + PBL_GET_MAPPINGS_COUNT GetMappingsCount; PBL_GET_MEMORY_MAP GetMemoryMap; PBL_INITIALIZE_PAGE_MAP InitializePageMap; PBL_MAP_EFI_MEMORY MapEfiMemory; diff --git a/xtldr/includes/xtldr.h b/xtldr/includes/xtldr.h index 5e3315a..93c4b98 100644 --- a/xtldr/includes/xtldr.h +++ b/xtldr/includes/xtldr.h @@ -135,6 +135,11 @@ EFI_STATUS BlGetEfiPath(IN PWCHAR SystemPath, OUT PWCHAR *EfiPath); +XTCDECL +VOID +BlGetMappingsCount(IN PXTBL_PAGE_MAPPING PageMap, + OUT PULONG NumberOfMappings); + XTCDECL EFI_STATUS BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap); diff --git a/xtldr/memory.c b/xtldr/memory.c index dc90a9c..8d62773 100644 --- a/xtldr/memory.c +++ b/xtldr/memory.c @@ -91,6 +91,28 @@ BlFreeMemoryPool(IN PVOID Memory) return EfiSystemTable->BootServices->FreePool(Memory); } +/** + * Returns the number of mappings in the page mapping structure. + * + * @param PageMap + * Supplies a pointer to the page mapping structure. + * + * @param NumberOfMappings + * Supplies a pointer to memory area where the number of mappings is returned. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +BlGetMappingsCount(IN PXTBL_PAGE_MAPPING PageMap, + OUT PULONG NumberOfMappings) +{ + /* Return number of mappings */ + *NumberOfMappings = PageMap->MapSize; +} + /** * Returns the memory descriptors which define a memory map of all the physical memory ranges reserved by the UEFI. * diff --git a/xtldr/protocol.c b/xtldr/protocol.c index 02610fd..425675d 100644 --- a/xtldr/protocol.c +++ b/xtldr/protocol.c @@ -630,6 +630,7 @@ BlpInstallXtLoaderProtocol() BlpLdrProtocol.Memory.CopyMemory = RtlCopyMemory; BlpLdrProtocol.Memory.FreePages = BlFreeMemoryPages; BlpLdrProtocol.Memory.FreePool = BlFreeMemoryPool; + BlpLdrProtocol.Memory.GetMappingsCount = BlGetMappingsCount; BlpLdrProtocol.Memory.GetMemoryMap = BlGetMemoryMap; BlpLdrProtocol.Memory.InitializePageMap = BlInitializePageMap; BlpLdrProtocol.Memory.MapEfiMemory = BlMapEfiMemory;