X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FLibrary%2FEdkUefiRuntimeLib%2FIpf%2FRuntimeLib.c;h=f6a19041433b1d1d3d89a54c873d3154df474b61;hp=d0f0d6012bd0d9bf9e1e826cf965bd67206506d4;hb=e8d4831b1980a9c97acb15963e9ce4eb5d5c1ba8;hpb=a5e465a79f7a3ccf00314ba7fa6be275e1fde790 diff --git a/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c b/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c index d0f0d6012b..f6a1904143 100644 --- a/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c +++ b/EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c @@ -13,28 +13,16 @@ Module Name: RuntimeLib.c -Abstract: - - Light weight lib to support Tiano drivers. - --*/ -#include #include // // Driver Lib Module Globals // +static EFI_EVENT mEfiVirtualNotifyEvent; +EFI_RUNTIME_SERVICES *mRT; -STATIC EFI_EVENT mRuntimeNotifyEvent; -STATIC EFI_EVENT mEfiVirtualNotifyEvent; - -STATIC EFI_PLABEL mPlabel; -STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService; - -EFI_RUNTIME_SERVICES *mRT = NULL; - -STATIC VOID EFIAPI RuntimeDriverExitBootServices ( @@ -59,12 +47,8 @@ Returns: --*/ { - EFI_EVENT_NOTIFY ChildNotifyEventHandler; - UINTN Index; - - for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) { - ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index]; - ChildNotifyEventHandler (Event, NULL); + if (EfiAtRuntime()) { + return; } } @@ -95,7 +79,7 @@ Returns: --*/ { - UINTN Index; + UINTN Index; EFI_EVENT_NOTIFY ChildNotifyEventHandler; for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) { @@ -103,17 +87,10 @@ Returns: ChildNotifyEventHandler (Event, NULL); } - mRT->ConvertPointer (0x0, (VOID **) &mPlabel.EntryPoint); - mRT->ConvertPointer (EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP); - - SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP); - // - // Clear out BootService globals + // Update global for Runtime Services Table // - gBS = NULL; - gST = NULL; - mRT = NULL; + EfiConvertPointer (0, (VOID **) &mRT); } EFI_STATUS @@ -142,54 +119,23 @@ Returns: --*/ { - EFI_PLABEL *Plabel; EFI_STATUS Status; mRT = SystemTable->RuntimeServices; - // - // The protocol contains a function pointer, which is an indirect procedure call. - // An indirect procedure call goes through a plabel, and pointer to a function is - // a pointer to a plabel. To implement indirect procedure calls that can work in - // both physical and virtual mode, two plabels are required (one physical and one - // 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); - - Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc; - - mPlabel.EntryPoint = Plabel->EntryPoint; - mPlabel.GP = Plabel->GP; - - SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP); - - // - // Register our ExitBootServices () notify function - // - - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, - EFI_TPL_NOTIFY, - RuntimeDriverExitBootServices, - NULL, - &mRuntimeNotifyEvent - ); - ASSERT_EFI_ERROR (Status); - // // Register SetVirtualAddressMap () notify function // - - Status = gBS->CreateEvent ( - EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, - EFI_TPL_NOTIFY, - RuntimeLibVirtualNotifyEvent, - NULL, - mEfiVirtualNotifyEvent - ); - ASSERT_EFI_ERROR (Status); + if (_gDriverSetVirtualAddressMapEvent[0] != NULL) { + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + RuntimeLibVirtualNotifyEvent, + NULL, + &mEfiVirtualNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + } return EFI_SUCCESS; } @@ -197,7 +143,8 @@ Returns: EFI_STATUS EFIAPI RuntimeDriverLibDeconstruct ( - VOID + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) /*++ @@ -220,22 +167,19 @@ Returns: { EFI_STATUS Status; - // - // Close our ExitBootServices () notify function - // - Status = gBS->CloseEvent (mRuntimeNotifyEvent); - ASSERT_EFI_ERROR (Status); - // // Close SetVirtualAddressMap () notify function // - Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); - ASSERT_EFI_ERROR (Status); + if (_gDriverSetVirtualAddressMapEvent[0] != NULL) { + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + } return EFI_SUCCESS; } BOOLEAN +EFIAPI EfiAtRuntime ( VOID ) @@ -252,15 +196,19 @@ Returns: --*/ { - EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + EFI_GUID Guid; SAL_RETURN_REGS ReturnReg; + *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO; + *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI; + ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0); return (BOOLEAN) (ReturnReg.r9 == 1); } BOOLEAN +EFIAPI EfiGoneVirtual ( VOID ) @@ -277,10 +225,14 @@ Returns: --*/ { - EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + EFI_GUID Guid; SAL_RETURN_REGS ReturnReg; + *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO; + *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI; + ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0); return (BOOLEAN) (ReturnReg.r9 == 1); } +