Move trampoline handling code
This commit is contained in:
@@ -14,11 +14,6 @@
|
|||||||
|
|
||||||
|
|
||||||
/* XT BootLoader routines forward references */
|
/* XT BootLoader routines forward references */
|
||||||
XTCLINK
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
ArEnableExtendedPhysicalAddressing(IN ULONG_PTR PageMap);
|
|
||||||
|
|
||||||
XTCLINK
|
XTCLINK
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@@ -48,6 +48,7 @@ typedef EFI_STATUS (XTCDECL *PBL_ALLOCATE_PAGES)(IN EFI_ALLOCATE_TYPE Allocation
|
|||||||
typedef EFI_STATUS (XTCDECL *PBL_ALLOCATE_POOL)(IN UINT_PTR Size, OUT PVOID *Memory);
|
typedef EFI_STATUS (XTCDECL *PBL_ALLOCATE_POOL)(IN UINT_PTR Size, OUT PVOID *Memory);
|
||||||
typedef EFI_STATUS (XTCDECL *PBL_BOOTMENU_INITIALIZE_OS_LIST)(IN ULONG MaxNameLength, OUT PXTBL_BOOTMENU_ITEM *MenuEntries, OUT PULONG EntriesCount, OUT PULONG DefaultId);
|
typedef EFI_STATUS (XTCDECL *PBL_BOOTMENU_INITIALIZE_OS_LIST)(IN ULONG MaxNameLength, OUT PXTBL_BOOTMENU_ITEM *MenuEntries, OUT PULONG EntriesCount, OUT PULONG DefaultId);
|
||||||
typedef BOOLEAN (XTCDECL *PBL_BOOTUTIL_GET_BOOLEAN_PARAMETER)(IN PCWSTR Parameters, IN PCWSTR Needle);
|
typedef BOOLEAN (XTCDECL *PBL_BOOTUTIL_GET_BOOLEAN_PARAMETER)(IN PCWSTR Parameters, IN PCWSTR Needle);
|
||||||
|
typedef VOID (XTAPI *PBL_BOOTUTIL_GET_TRAMPOLINE_INFORMATION)(IN TRAMPOLINE_TYPE TrampolineType, OUT PVOID *TrampolineCode, OUT PULONG_PTR TrampolineSize);
|
||||||
typedef EFI_STATUS (XTCDECL *PBL_BUILD_PAGE_MAP)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR SelfMapAddress);
|
typedef EFI_STATUS (XTCDECL *PBL_BUILD_PAGE_MAP)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR SelfMapAddress);
|
||||||
typedef EFI_STATUS (XTCDECL *PBL_CLOSE_VOLUME)(IN PEFI_HANDLE VolumeHandle);
|
typedef EFI_STATUS (XTCDECL *PBL_CLOSE_VOLUME)(IN PEFI_HANDLE VolumeHandle);
|
||||||
typedef VOID (XTCDECL *PBL_CLEAR_CONSOLE_LINE)(IN ULONGLONG LineNo);
|
typedef VOID (XTCDECL *PBL_CLEAR_CONSOLE_LINE)(IN ULONGLONG LineNo);
|
||||||
@@ -388,6 +389,7 @@ typedef struct _XTBL_LOADER_PROTOCOL
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
PBL_BOOTUTIL_GET_BOOLEAN_PARAMETER GetBooleanParameter;
|
PBL_BOOTUTIL_GET_BOOLEAN_PARAMETER GetBooleanParameter;
|
||||||
|
PBL_BOOTUTIL_GET_TRAMPOLINE_INFORMATION GetTrampolineInformation;
|
||||||
} BootUtil;
|
} BootUtil;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@@ -24,6 +24,14 @@ namespace AR
|
|||||||
STATIC XTCDECL VOID WriteControlRegister(IN USHORT ControlRegister,
|
STATIC XTCDECL VOID WriteControlRegister(IN USHORT ControlRegister,
|
||||||
IN UINT_PTR Value);
|
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 */
|
/* Minimal forward references for HL classes used by XTLDR */
|
||||||
|
@@ -74,6 +74,7 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
EFI_PHYSICAL_ADDRESS TrampolineAddress;
|
EFI_PHYSICAL_ADDRESS TrampolineAddress;
|
||||||
PXT_TRAMPOLINE_ENTRY TrampolineEntry;
|
PXT_TRAMPOLINE_ENTRY TrampolineEntry;
|
||||||
ULONG_PTR TrampolineSize;
|
ULONG_PTR TrampolineSize;
|
||||||
|
PVOID TrampolineCode;
|
||||||
|
|
||||||
/* Build page map */
|
/* Build page map */
|
||||||
Status = XtLdrProtocol->Memory.BuildPageMap(PageMap, (PageMap->PageMapLevel > 4) ? MM_P5E_LA57_BASE : MM_PXE_BASE);
|
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 */
|
/* Check the configured page map level to set the LA57 state accordingly */
|
||||||
if(PageMap->PageMapLevel == 5)
|
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 */
|
/* Set the address of the trampoline code below 1MB */
|
||||||
TrampolineAddress = MM_TRAMPOLINE_ADDRESS;
|
TrampolineAddress = MM_TRAMPOLINE_ADDRESS;
|
||||||
|
|
||||||
/* Calculate the size of the trampoline code */
|
|
||||||
TrampolineSize = (ULONG_PTR)ArEnableExtendedPhysicalAddressingEnd - (ULONG_PTR)ArEnableExtendedPhysicalAddressing;
|
|
||||||
|
|
||||||
/* Allocate pages for the trampoline */
|
/* Allocate pages for the trampoline */
|
||||||
Status = XtLdrProtocol->Memory.AllocatePages(AllocateAddress, EFI_SIZE_TO_PAGES(TrampolineSize), &TrampolineAddress);
|
Status = XtLdrProtocol->Memory.AllocatePages(AllocateAddress, EFI_SIZE_TO_PAGES(TrampolineSize), &TrampolineAddress);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
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 */
|
/* Set the trampoline entry point and copy its code into the allocated buffer */
|
||||||
TrampolineEntry = (PXT_TRAMPOLINE_ENTRY)(UINT_PTR)TrampolineAddress;
|
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 */
|
/* Exit EFI Boot Services */
|
||||||
|
@@ -18,9 +18,6 @@ typedef VOID (XTAPI *PXT_ENTRY_POINT)(IN PKERNEL_INITIALIZATION_BLOCK BootParame
|
|||||||
/* XTOS trampoline entry point */
|
/* XTOS trampoline entry point */
|
||||||
typedef VOID (*PXT_TRAMPOLINE_ENTRY)(UINT64 PageMap);
|
typedef VOID (*PXT_TRAMPOLINE_ENTRY)(UINT64 PageMap);
|
||||||
|
|
||||||
/* XTOS trampoline end address to calculate trampoline size */
|
|
||||||
XTCLINK PVOID ArEnableExtendedPhysicalAddressingEnd[];
|
|
||||||
|
|
||||||
|
|
||||||
/* XTOS module for XTLDR */
|
/* XTOS module for XTLDR */
|
||||||
class Xtos
|
class Xtos
|
||||||
|
@@ -869,6 +869,7 @@ BlpInstallXtLoaderProtocol()
|
|||||||
BlpLdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu;
|
BlpLdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu;
|
||||||
BlpLdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol;
|
BlpLdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol;
|
||||||
BlpLdrProtocol.BootUtil.GetBooleanParameter = BlGetBooleanParameter;
|
BlpLdrProtocol.BootUtil.GetBooleanParameter = BlGetBooleanParameter;
|
||||||
|
BlpLdrProtocol.BootUtil.GetTrampolineInformation = AR::ProcSup::GetTrampolineInformation;
|
||||||
BlpLdrProtocol.Config.GetBooleanValue = BlGetConfigBooleanValue;
|
BlpLdrProtocol.Config.GetBooleanValue = BlGetConfigBooleanValue;
|
||||||
BlpLdrProtocol.Config.GetBootOptionValue = BlGetBootOptionValue;
|
BlpLdrProtocol.Config.GetBootOptionValue = BlGetBootOptionValue;
|
||||||
BlpLdrProtocol.Config.GetEditableOptions = BlGetEditableOptions;
|
BlpLdrProtocol.Config.GetEditableOptions = BlGetEditableOptions;
|
||||||
|
Reference in New Issue
Block a user