Move trampoline handling code
This commit is contained in:
@@ -24,6 +24,14 @@ namespace AR
|
||||
STATIC XTCDECL VOID WriteControlRegister(IN USHORT ControlRegister,
|
||||
IN UINT_PTR Value);
|
||||
};
|
||||
|
||||
class ProcSup
|
||||
{
|
||||
public:
|
||||
STATIC XTAPI VOID GetTrampolineInformation(IN TRAMPOLINE_TYPE TrampolineType,
|
||||
OUT PVOID *TrampolineCode,
|
||||
OUT PULONG_PTR TrampolineSize);
|
||||
};
|
||||
}
|
||||
|
||||
/* Minimal forward references for HL classes used by XTLDR */
|
||||
|
@@ -74,6 +74,7 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
|
||||
EFI_PHYSICAL_ADDRESS TrampolineAddress;
|
||||
PXT_TRAMPOLINE_ENTRY TrampolineEntry;
|
||||
ULONG_PTR TrampolineSize;
|
||||
PVOID TrampolineCode;
|
||||
|
||||
/* Build page map */
|
||||
Status = XtLdrProtocol->Memory.BuildPageMap(PageMap, (PageMap->PageMapLevel > 4) ? MM_P5E_LA57_BASE : MM_PXE_BASE);
|
||||
@@ -96,12 +97,18 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
|
||||
/* Check the configured page map level to set the LA57 state accordingly */
|
||||
if(PageMap->PageMapLevel == 5)
|
||||
{
|
||||
/* Get the trampoline code information */
|
||||
XtLdrProtocol->BootUtil.GetTrampolineInformation(TrampolineEnableXpa, &TrampolineCode, &TrampolineSize);
|
||||
if(TrampolineCode == NULLPTR || TrampolineSize == 0)
|
||||
{
|
||||
/* Failed to get trampoline information */
|
||||
XtLdrProtocol->Debug.Print(L"Failed to get trampoline information\n");
|
||||
return STATUS_EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Set the address of the trampoline code below 1MB */
|
||||
TrampolineAddress = MM_TRAMPOLINE_ADDRESS;
|
||||
|
||||
/* Calculate the size of the trampoline code */
|
||||
TrampolineSize = (ULONG_PTR)ArEnableExtendedPhysicalAddressingEnd - (ULONG_PTR)ArEnableExtendedPhysicalAddressing;
|
||||
|
||||
/* Allocate pages for the trampoline */
|
||||
Status = XtLdrProtocol->Memory.AllocatePages(AllocateAddress, EFI_SIZE_TO_PAGES(TrampolineSize), &TrampolineAddress);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
@@ -113,7 +120,7 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
|
||||
|
||||
/* Set the trampoline entry point and copy its code into the allocated buffer */
|
||||
TrampolineEntry = (PXT_TRAMPOLINE_ENTRY)(UINT_PTR)TrampolineAddress;
|
||||
XtLdrProtocol->Memory.CopyMemory((PVOID)TrampolineEntry, (PVOID)ArEnableExtendedPhysicalAddressing, TrampolineSize);
|
||||
XtLdrProtocol->Memory.CopyMemory((PVOID)TrampolineEntry, TrampolineCode, TrampolineSize);
|
||||
}
|
||||
|
||||
/* Exit EFI Boot Services */
|
||||
|
@@ -18,9 +18,6 @@ typedef VOID (XTAPI *PXT_ENTRY_POINT)(IN PKERNEL_INITIALIZATION_BLOCK BootParame
|
||||
/* XTOS trampoline entry point */
|
||||
typedef VOID (*PXT_TRAMPOLINE_ENTRY)(UINT64 PageMap);
|
||||
|
||||
/* XTOS trampoline end address to calculate trampoline size */
|
||||
XTCLINK PVOID ArEnableExtendedPhysicalAddressingEnd[];
|
||||
|
||||
|
||||
/* XTOS module for XTLDR */
|
||||
class Xtos
|
||||
|
@@ -869,6 +869,7 @@ BlpInstallXtLoaderProtocol()
|
||||
BlpLdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu;
|
||||
BlpLdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol;
|
||||
BlpLdrProtocol.BootUtil.GetBooleanParameter = BlGetBooleanParameter;
|
||||
BlpLdrProtocol.BootUtil.GetTrampolineInformation = AR::ProcSup::GetTrampolineInformation;
|
||||
BlpLdrProtocol.Config.GetBooleanValue = BlGetConfigBooleanValue;
|
||||
BlpLdrProtocol.Config.GetBootOptionValue = BlGetBootOptionValue;
|
||||
BlpLdrProtocol.Config.GetEditableOptions = BlGetEditableOptions;
|
||||
|
Reference in New Issue
Block a user