Allow to specify virtual address during EFI memory mapping only
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 44s
Builds / ExectOS (i686) (push) Successful in 29s

This commit is contained in:
Rafal Kupiec 2024-01-19 23:16:45 +01:00
parent 88321b5f4d
commit c24745d233
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 10 additions and 26 deletions

View File

@ -77,7 +77,7 @@ typedef EFI_STATUS (*PBL_FREE_POOL)(IN PVOID Memory);
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)();
typedef VOID (*PBL_INITIALIZE_PAGE_MAP)(OUT PXTBL_PAGE_MAPPING PageMap, IN PVOID *MemoryMapAddress, IN SHORT PageMapLevel, IN PAGE_SIZE PageSize);
typedef VOID (*PBL_INITIALIZE_PAGE_MAP)(OUT PXTBL_PAGE_MAPPING PageMap, IN SHORT PageMapLevel, IN PAGE_SIZE PageSize);
typedef EFI_STATUS (*PBL_INSTALL_XT_PROTOCOL)(IN PVOID Interface, IN PEFI_GUID Guid);
typedef EFI_STATUS (*PBL_INVOKE_BOOT_PROTOCOL)(IN PLIST_ENTRY OptionsList);
typedef EFI_STATUS (*PBL_LOCATE_PROTOCOL_HANDLES)(OUT PEFI_HANDLE *Handles, OUT PUINT_PTR Count, IN PEFI_GUID ProtocolGuid);
@ -185,7 +185,6 @@ typedef struct _XTBL_PAGE_MAPPING
{
LIST_ENTRY MemoryMap;
PVOID PtePointer;
PVOID MemoryMapAddress;
SHORT PageMapLevel;
PAGE_SIZE PageSize;
} XTBL_PAGE_MAPPING, *PXTBL_PAGE_MAPPING;

View File

@ -157,7 +157,6 @@ BlInitializeConsole();
XTCDECL
VOID
BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
IN PVOID *MemoryMapAddress,
IN SHORT PageMapLevel,
IN PAGE_SIZE PageSize);

View File

@ -160,9 +160,6 @@ BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap)
* @param PageMap
* Supplies a pointer to the page mapping structure.
*
* @param MemoryMapAddress
* Supplies an address of the mapped virtual memory area.
*
* @param PageMapLevel
* Specifies a number of of paging structures levels.
*
@ -176,7 +173,6 @@ BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap)
XTCDECL
VOID
BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
IN PVOID *MemoryMapAddress,
IN SHORT PageMapLevel,
IN PAGE_SIZE PageSize)
{
@ -184,7 +180,6 @@ BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
RtlInitializeListHead(&PageMap->MemoryMap);
/* Set page map size/level and memory map address */
PageMap->MemoryMapAddress = &MemoryMapAddress;
PageMap->PageMapLevel = PageMapLevel;
PageMap->PageSize = PageSize;
}
@ -195,9 +190,8 @@ BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
* @param PageMap
* Supplies a pointer to the page mapping structure.
*
* @param DesiredVirtualAddress
* Supplies a desired virtual address, where EFI memory will be mapped.
* If not specified, memory map address will be used.
* @param MemoryMapAddress
* Supplies a virtual address, where EFI memory will be mapped.
*
* @return This routine returns a status code.
*
@ -206,7 +200,7 @@ BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
XTCDECL
EFI_STATUS
BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
IN OUT PVOID *DesiredVirtualAddress)
IN OUT PVOID *MemoryMapAddress)
{
PEFI_MEMORY_DESCRIPTOR Descriptor;
LOADER_MEMORY_TYPE MemoryType;
@ -216,17 +210,8 @@ BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
EFI_STATUS Status;
SIZE_T Index;
/* Set initial virtual address */
if(*DesiredVirtualAddress != NULL)
{
/* Set virtual address as specified in argument */
VirtualAddress = *DesiredVirtualAddress;
}
else
{
/* Otherwise, set virtual address as specified in page map */
VirtualAddress = PageMap->MemoryMapAddress;
}
/* Set virtual address as specified in argument */
VirtualAddress = *MemoryMapAddress;
/* Allocate and zero-fill buffer for EFI memory map */
BlAllocateMemoryPool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap);
@ -288,7 +273,8 @@ BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
}
}
/* Return success */
/* Store next valid virtual address and return success */
*MemoryMapAddress = VirtualAddress;
return STATUS_EFI_SUCCESS;
}

View File

@ -191,9 +191,9 @@ XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
VirtualAddress = (PVOID)(KSEG0_BASE + KSEG0_KERNEL_BASE);
/* Initialize virtual memory mappings */
XtLdrProtocol->Memory.InitializePageMap(&PageMap, &VirtualMemoryArea, 3, Size4K);
XtLdrProtocol->Memory.InitializePageMap(&PageMap, 3, Size4K);
Status = XtLdrProtocol->Memory.MapEfiMemory(&PageMap, NULL);
Status = XtLdrProtocol->Memory.MapEfiMemory(&PageMap, &VirtualMemoryArea);
if(Status != STATUS_EFI_SUCCESS)
{
return Status;