mirror of https://github.com/acidanthera/audk.git
Remove use of global variable at runtime in this lib
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2046 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
22613d6e71
commit
2df858f7e2
|
@ -54,6 +54,9 @@
|
||||||
<Externs>
|
<Externs>
|
||||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||||
|
<Extern>
|
||||||
|
<Constructor>DxeSalLibConstructor</Constructor>
|
||||||
|
</Extern>
|
||||||
<Extern>
|
<Extern>
|
||||||
<SetVirtualAddressMapCallBack>DxeSalVirtualNotifyEvent</SetVirtualAddressMapCallBack>
|
<SetVirtualAddressMapCallBack>DxeSalVirtualNotifyEvent</SetVirtualAddressMapCallBack>
|
||||||
</Extern>
|
</Extern>
|
||||||
|
|
|
@ -19,25 +19,21 @@ Abstract:
|
||||||
|
|
||||||
#include <Ipf/IpfDefines.h>
|
#include <Ipf/IpfDefines.h>
|
||||||
|
|
||||||
BOOLEAN mLibraryInitialized = FALSE;
|
EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService = NULL;
|
||||||
STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;
|
EFI_PLABEL mPlabel;
|
||||||
STATIC EFI_PLABEL mPlabel;
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DxeSalLibConstruct (
|
DxeSalLibInitialize (
|
||||||
// IN EFI_HANDLE ImageHandle,
|
|
||||||
// IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PLABEL *Plabel;
|
EFI_PLABEL *Plabel;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
if (mLibraryInitialized == TRUE) {
|
if (mEsalBootService != NULL) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
mLibraryInitialized = TRUE;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The protocol contains a function pointer, which is an indirect procedure call.
|
// The protocol contains a function pointer, which is an indirect procedure call.
|
||||||
|
@ -48,7 +44,10 @@ DxeSalLibConstruct (
|
||||||
// away. We cache it in a module global, so we can register the vitrual version.
|
// away. We cache it in a module global, so we can register the vitrual version.
|
||||||
//
|
//
|
||||||
Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
|
Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
|
||||||
ASSERT_EFI_ERROR (Status);
|
if (EFI_ERROR (Status)) {
|
||||||
|
mEsalBootService = NULL;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;
|
Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;
|
||||||
|
|
||||||
|
@ -56,7 +55,17 @@ DxeSalLibConstruct (
|
||||||
mPlabel.GP = Plabel->GP;
|
mPlabel.GP = Plabel->GP;
|
||||||
SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);
|
SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);
|
||||||
|
|
||||||
return Status;
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
DxeSalLibConstructor (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DxeSalLibInitialize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -115,7 +124,7 @@ Returns:
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
DxeSalLibConstruct ();
|
DxeSalLibInitialize ();
|
||||||
return mEsalBootService->AddExtendedSalProc (
|
return mEsalBootService->AddExtendedSalProc (
|
||||||
mEsalBootService,
|
mEsalBootService,
|
||||||
ClassGuid,
|
ClassGuid,
|
||||||
|
@ -224,12 +233,32 @@ Returns:
|
||||||
SAL_RETURN_REGS ReturnReg;
|
SAL_RETURN_REGS ReturnReg;
|
||||||
SAL_EXTENDED_SAL_PROC EsalProc;
|
SAL_EXTENDED_SAL_PROC EsalProc;
|
||||||
|
|
||||||
DxeSalLibConstruct ();
|
|
||||||
ReturnReg = GetEsalEntryPoint ();
|
ReturnReg = GetEsalEntryPoint ();
|
||||||
if (ReturnReg.Status != EFI_SAL_SUCCESS) {
|
if (ReturnReg.Status != EFI_SAL_SUCCESS) {
|
||||||
return ReturnReg;
|
return ReturnReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Look at the physical mode ESAL entry point to determine of the ESAL entry point has been initialized
|
||||||
|
//
|
||||||
|
if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {
|
||||||
|
//
|
||||||
|
// Both the function ponter and the GP value are zero, so attempt to initialize the ESAL Entry Point
|
||||||
|
//
|
||||||
|
DxeSalLibInitialize ();
|
||||||
|
ReturnReg = GetEsalEntryPoint ();
|
||||||
|
if (ReturnReg.Status != EFI_SAL_SUCCESS) {
|
||||||
|
return ReturnReg;
|
||||||
|
}
|
||||||
|
if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {
|
||||||
|
//
|
||||||
|
// The ESAL Entry Point could not be initialized
|
||||||
|
//
|
||||||
|
ReturnReg.Status = EFI_SAL_ERROR;
|
||||||
|
return ReturnReg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ReturnReg.r11 & PSR_IT_MASK) {
|
if (ReturnReg.r11 & PSR_IT_MASK) {
|
||||||
//
|
//
|
||||||
// Virtual mode plabel to entry point
|
// Virtual mode plabel to entry point
|
||||||
|
|
Loading…
Reference in New Issue