\r
#include <Ipf/IpfDefines.h>\r
\r
-BOOLEAN mLibraryInitialized = FALSE;\r
-STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;\r
-STATIC EFI_PLABEL mPlabel;\r
+EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService = NULL;\r
+EFI_PLABEL mPlabel;\r
\r
EFI_STATUS\r
EFIAPI\r
-DxeSalLibConstruct (\r
-// IN EFI_HANDLE ImageHandle,\r
-// IN EFI_SYSTEM_TABLE *SystemTable\r
+DxeSalLibInitialize (\r
VOID\r
)\r
{\r
EFI_PLABEL *Plabel;\r
EFI_STATUS Status;\r
\r
- if (mLibraryInitialized == TRUE) {\r
+ if (mEsalBootService != NULL) {\r
return EFI_SUCCESS;\r
}\r
- mLibraryInitialized = TRUE;\r
\r
//\r
// The protocol contains a function pointer, which is an indirect procedure call.\r
// virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r
// away. We cache it in a module global, so we can register the vitrual version.\r
//\r
- Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);\r
- ASSERT_EFI_ERROR (Status);\r
+ Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);\r
+ if (EFI_ERROR (Status)) {\r
+ mEsalBootService = NULL;\r
+ return EFI_SUCCESS;\r
+ }\r
\r
Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r
\r
mPlabel.GP = Plabel->GP;\r
SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
\r
- return Status;\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeSalLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ return DxeSalLibInitialize ();\r
}\r
\r
VOID\r
\r
--*/\r
{\r
- DxeSalLibConstruct ();\r
+ DxeSalLibInitialize ();\r
return mEsalBootService->AddExtendedSalProc (\r
mEsalBootService,\r
ClassGuid,\r
SAL_RETURN_REGS ReturnReg;\r
SAL_EXTENDED_SAL_PROC EsalProc;\r
\r
- DxeSalLibConstruct ();\r
ReturnReg = GetEsalEntryPoint ();\r
if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r
return ReturnReg;\r
}\r
\r
+ //\r
+ // Look at the physical mode ESAL entry point to determine of the ESAL entry point has been initialized\r
+ //\r
+ if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
+ //\r
+ // Both the function ponter and the GP value are zero, so attempt to initialize the ESAL Entry Point\r
+ //\r
+ DxeSalLibInitialize ();\r
+ ReturnReg = GetEsalEntryPoint ();\r
+ if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r
+ return ReturnReg;\r
+ }\r
+ if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
+ //\r
+ // The ESAL Entry Point could not be initialized\r
+ //\r
+ ReturnReg.Status = EFI_SAL_ERROR;\r
+ return ReturnReg;\r
+ }\r
+ }\r
+\r
if (ReturnReg.r11 & PSR_IT_MASK) {\r
//\r
// Virtual mode plabel to entry point\r