Update memory mapping related structures
This commit is contained in:
parent
d27a4cde4b
commit
0c691a40e3
@ -169,6 +169,16 @@ typedef struct _XTBL_KNOWN_BOOT_PROTOCOL
|
|||||||
EFI_GUID Guid;
|
EFI_GUID Guid;
|
||||||
} XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL;
|
} XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL;
|
||||||
|
|
||||||
|
/* Boot Loader memory mapping information */
|
||||||
|
typedef struct _XTBL_MEMORY_MAPPING
|
||||||
|
{
|
||||||
|
LIST_ENTRY ListEntry;
|
||||||
|
PVOID VirtualAddress;
|
||||||
|
PVOID PhysicalAddress;
|
||||||
|
ULONGLONG NumberOfPages;
|
||||||
|
LOADER_MEMORY_TYPE MemoryType;
|
||||||
|
} XTBL_MEMORY_MAPPING, *PXTBL_MEMORY_MAPPING;
|
||||||
|
|
||||||
/* XTLDR Module dependencies data */
|
/* XTLDR Module dependencies data */
|
||||||
typedef struct _XTBL_MODULE_DEPS
|
typedef struct _XTBL_MODULE_DEPS
|
||||||
{
|
{
|
||||||
|
@ -115,10 +115,9 @@ typedef struct _LOADER_INFORMATION_BLOCK
|
|||||||
typedef struct _LOADER_MEMORY_MAPPING
|
typedef struct _LOADER_MEMORY_MAPPING
|
||||||
{
|
{
|
||||||
LIST_ENTRY ListEntry;
|
LIST_ENTRY ListEntry;
|
||||||
PVOID VirtualAddress;
|
|
||||||
PVOID PhysicalAddress;
|
|
||||||
ULONGLONG NumberOfPages;
|
|
||||||
LOADER_MEMORY_TYPE MemoryType;
|
LOADER_MEMORY_TYPE MemoryType;
|
||||||
|
ULONG BasePage;
|
||||||
|
ULONG PageCount;
|
||||||
} LOADER_MEMORY_MAPPING, *PLOADER_MEMORY_MAPPING;
|
} LOADER_MEMORY_MAPPING, *PLOADER_MEMORY_MAPPING;
|
||||||
|
|
||||||
/* Loader provided information needed by the kernel to initialize */
|
/* Loader provided information needed by the kernel to initialize */
|
||||||
|
@ -281,6 +281,7 @@ typedef struct _XTBL_FRAMEBUFFER_INFORMATION XTBL_FRAMEBUFFER_INFORMATION, *PXTB
|
|||||||
typedef struct _XTBL_FRAMEBUFFER_PROTOCOL XTBL_FRAMEBUFFER_PROTOCOL, *PXTBL_FRAMEBUFFER_PROTOCOL;
|
typedef struct _XTBL_FRAMEBUFFER_PROTOCOL XTBL_FRAMEBUFFER_PROTOCOL, *PXTBL_FRAMEBUFFER_PROTOCOL;
|
||||||
typedef struct _XTBL_KNOWN_BOOT_PROTOCOL XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL;
|
typedef struct _XTBL_KNOWN_BOOT_PROTOCOL XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL;
|
||||||
typedef struct _XTBL_LOADER_PROTOCOL XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL;
|
typedef struct _XTBL_LOADER_PROTOCOL XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL;
|
||||||
|
typedef struct _XTBL_MEMORY_MAPPING XTBL_MEMORY_MAPPING, *PXTBL_MEMORY_MAPPING;
|
||||||
typedef struct _XTBL_MODULE_DEPS XTBL_MODULE_DEPS, *PXTBL_MODULE_DEPS;
|
typedef struct _XTBL_MODULE_DEPS XTBL_MODULE_DEPS, *PXTBL_MODULE_DEPS;
|
||||||
typedef struct _XTBL_MODULE_INFO XTBL_MODULE_INFO, *PXTBL_MODULE_INFO;
|
typedef struct _XTBL_MODULE_INFO XTBL_MODULE_INFO, *PXTBL_MODULE_INFO;
|
||||||
typedef struct _XTBL_PAGE_MAPPING XTBL_PAGE_MAPPING, *PXTBL_PAGE_MAPPING;
|
typedef struct _XTBL_PAGE_MAPPING XTBL_PAGE_MAPPING, *PXTBL_PAGE_MAPPING;
|
||||||
|
@ -24,7 +24,7 @@ EFI_STATUS
|
|||||||
BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap)
|
BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListEntry, ModulesList, ModulesListEntry;
|
PLIST_ENTRY ListEntry, ModulesList, ModulesListEntry;
|
||||||
PLOADER_MEMORY_MAPPING Mapping;
|
PXTBL_MEMORY_MAPPING Mapping;
|
||||||
PXTBL_MODULE_INFO ModuleInfo;
|
PXTBL_MODULE_INFO ModuleInfo;
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -96,7 +96,7 @@ BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
while(ListEntry != &PageMap->MemoryMap)
|
while(ListEntry != &PageMap->MemoryMap)
|
||||||
{
|
{
|
||||||
/* Take mapping from the list */
|
/* Take mapping from the list */
|
||||||
Mapping = CONTAIN_RECORD(ListEntry, LOADER_MEMORY_MAPPING, ListEntry);
|
Mapping = CONTAIN_RECORD(ListEntry, XTBL_MEMORY_MAPPING, ListEntry);
|
||||||
|
|
||||||
/* Check if virtual address is set */
|
/* Check if virtual address is set */
|
||||||
if(Mapping->VirtualAddress)
|
if(Mapping->VirtualAddress)
|
||||||
|
@ -194,7 +194,7 @@ PVOID
|
|||||||
BlGetVirtualAddress(IN PXTBL_PAGE_MAPPING PageMap,
|
BlGetVirtualAddress(IN PXTBL_PAGE_MAPPING PageMap,
|
||||||
IN PVOID PhysicalAddress)
|
IN PVOID PhysicalAddress)
|
||||||
{
|
{
|
||||||
PLOADER_MEMORY_MAPPING Mapping;
|
PXTBL_MEMORY_MAPPING Mapping;
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY ListEntry;
|
||||||
|
|
||||||
/* Iterate over memory mappings in order to find descriptor containing a physical address */
|
/* Iterate over memory mappings in order to find descriptor containing a physical address */
|
||||||
@ -202,7 +202,7 @@ BlGetVirtualAddress(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
while(ListEntry != &PageMap->MemoryMap)
|
while(ListEntry != &PageMap->MemoryMap)
|
||||||
{
|
{
|
||||||
/* Get mapping from linked list */
|
/* Get mapping from linked list */
|
||||||
Mapping = CONTAIN_RECORD(ListEntry, LOADER_MEMORY_MAPPING, ListEntry);
|
Mapping = CONTAIN_RECORD(ListEntry, XTBL_MEMORY_MAPPING, ListEntry);
|
||||||
|
|
||||||
/* Make sure any virtual address is set */
|
/* Make sure any virtual address is set */
|
||||||
if(Mapping->VirtualAddress)
|
if(Mapping->VirtualAddress)
|
||||||
@ -379,14 +379,14 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
|||||||
IN ULONGLONG NumberOfPages,
|
IN ULONGLONG NumberOfPages,
|
||||||
IN LOADER_MEMORY_TYPE MemoryType)
|
IN LOADER_MEMORY_TYPE MemoryType)
|
||||||
{
|
{
|
||||||
PLOADER_MEMORY_MAPPING Mapping1, Mapping2, Mapping3;
|
PXTBL_MEMORY_MAPPING Mapping1, Mapping2, Mapping3;
|
||||||
PVOID PhysicalAddressEnd, PhysicalAddress2End;
|
PVOID PhysicalAddressEnd, PhysicalAddress2End;
|
||||||
PLIST_ENTRY ListEntry, MappingListEntry;
|
PLIST_ENTRY ListEntry, MappingListEntry;
|
||||||
SIZE_T NumberOfMappedPages;
|
SIZE_T NumberOfMappedPages;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
/* Allocate memory for new mapping */
|
/* Allocate memory for new mapping */
|
||||||
Status = BlAllocateMemoryPool(sizeof(LOADER_MEMORY_MAPPING), (PVOID *)&Mapping1);
|
Status = BlAllocateMemoryPool(sizeof(XTBL_MEMORY_MAPPING), (PVOID *)&Mapping1);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Memory allocation failure */
|
/* Memory allocation failure */
|
||||||
@ -407,7 +407,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
|||||||
while(ListEntry != &PageMap->MemoryMap)
|
while(ListEntry != &PageMap->MemoryMap)
|
||||||
{
|
{
|
||||||
/* Take a mapping from the list and calculate its end of physical address */
|
/* Take a mapping from the list and calculate its end of physical address */
|
||||||
Mapping2 = CONTAIN_RECORD(ListEntry, LOADER_MEMORY_MAPPING, ListEntry);
|
Mapping2 = CONTAIN_RECORD(ListEntry, XTBL_MEMORY_MAPPING, ListEntry);
|
||||||
PhysicalAddress2End = (PUCHAR)Mapping2->PhysicalAddress + (Mapping2->NumberOfPages * EFI_PAGE_SIZE) - 1 ;
|
PhysicalAddress2End = (PUCHAR)Mapping2->PhysicalAddress + (Mapping2->NumberOfPages * EFI_PAGE_SIZE) - 1 ;
|
||||||
|
|
||||||
/* Check if new mapping is a subset of an existing mapping */
|
/* Check if new mapping is a subset of an existing mapping */
|
||||||
@ -436,7 +436,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
|||||||
if(NumberOfMappedPages > 0)
|
if(NumberOfMappedPages > 0)
|
||||||
{
|
{
|
||||||
/* Pages associated to the mapping, allocate memory for it */
|
/* Pages associated to the mapping, allocate memory for it */
|
||||||
Status = BlAllocateMemoryPool(sizeof(LOADER_MEMORY_MAPPING), (PVOID*)&Mapping3);
|
Status = BlAllocateMemoryPool(sizeof(XTBL_MEMORY_MAPPING), (PVOID*)&Mapping3);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Memory allocation failure */
|
/* Memory allocation failure */
|
||||||
@ -472,7 +472,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
|||||||
if(NumberOfMappedPages > 0)
|
if(NumberOfMappedPages > 0)
|
||||||
{
|
{
|
||||||
/* Pages associated to the mapping, allocate memory for it */
|
/* Pages associated to the mapping, allocate memory for it */
|
||||||
Status = BlAllocateMemoryPool(sizeof(LOADER_MEMORY_MAPPING), (PVOID*)&Mapping3);
|
Status = BlAllocateMemoryPool(sizeof(XTBL_MEMORY_MAPPING), (PVOID*)&Mapping3);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Memory allocation failure */
|
/* Memory allocation failure */
|
||||||
|
Loading…
Reference in New Issue
Block a user