summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Library
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-02 19:09:56 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-02 19:09:56 +0000
commit2df858f7e2d231dd5968a25d32d8a6093e3d9f01 (patch)
treea8e3df1ad3ef83be950889e522718a0e0743f3da /EdkModulePkg/Library
parent22613d6e71f1e577591e9c542de67064abdc21fa (diff)
downloadedk2-platforms-2df858f7e2d231dd5968a25d32d8a6093e3d9f01.tar.xz
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
Diffstat (limited to 'EdkModulePkg/Library')
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa3
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c55
2 files changed, 45 insertions, 13 deletions
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa
index a7a6214a30..10c3f8cb4f 100644
--- a/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa
+++ b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa
@@ -55,6 +55,9 @@
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
+ <Constructor>DxeSalLibConstructor</Constructor>
+ </Extern>
+ <Extern>
<SetVirtualAddressMapCallBack>DxeSalVirtualNotifyEvent</SetVirtualAddressMapCallBack>
</Extern>
</Externs>
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c
index 706dda2873..9eb909dcd3 100644
--- a/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c
+++ b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c
@@ -19,25 +19,21 @@ Abstract:
#include <Ipf/IpfDefines.h>
-BOOLEAN mLibraryInitialized = FALSE;
-STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;
-STATIC EFI_PLABEL mPlabel;
+EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService = NULL;
+EFI_PLABEL mPlabel;
EFI_STATUS
EFIAPI
-DxeSalLibConstruct (
-// IN EFI_HANDLE ImageHandle,
-// IN EFI_SYSTEM_TABLE *SystemTable
+DxeSalLibInitialize (
VOID
)
{
EFI_PLABEL *Plabel;
EFI_STATUS Status;
- if (mLibraryInitialized == TRUE) {
+ if (mEsalBootService != NULL) {
return EFI_SUCCESS;
}
- mLibraryInitialized = TRUE;
//
// The protocol contains a function pointer, which is an indirect procedure call.
@@ -47,8 +43,11 @@ DxeSalLibConstruct (
// virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it
// away. We cache it in a module global, so we can register the vitrual version.
//
- Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
- ASSERT_EFI_ERROR (Status);
+ Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
+ if (EFI_ERROR (Status)) {
+ mEsalBootService = NULL;
+ return EFI_SUCCESS;
+ }
Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;
@@ -56,7 +55,17 @@ DxeSalLibConstruct (
mPlabel.GP = Plabel->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
@@ -115,7 +124,7 @@ Returns:
--*/
{
- DxeSalLibConstruct ();
+ DxeSalLibInitialize ();
return mEsalBootService->AddExtendedSalProc (
mEsalBootService,
ClassGuid,
@@ -224,12 +233,32 @@ Returns:
SAL_RETURN_REGS ReturnReg;
SAL_EXTENDED_SAL_PROC EsalProc;
- DxeSalLibConstruct ();
ReturnReg = GetEsalEntryPoint ();
if (ReturnReg.Status != EFI_SAL_SUCCESS) {
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) {
//
// Virtual mode plabel to entry point