[edk2-devel] [PATCH V2 4/4] MdeModulePkg/CapsuleRuntimeDxe: Implement RuntimeServicesSupported
Gao, Zhichao
zhichao.gao at intel.com
Fri Jul 19 08:09:21 UTC 2019
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1907
Control the capsule services supported at runtime base on
the variable L"RuntimeServicesSupported".
It would update a global variable mRuntimeServicesSupported
at ExitBootServices event.
Cc: Jian J Wang <jian.j.wang at intel.com>
Cc: Hao A Wu <hao.a.wu at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Star Zeng <star.zeng at intel.com>
Cc: Liming gao <liming.gao at intel.com>
Cc: Sean Brogan <sean.brogan at microsoft.com>
Cc: Michael Turner <Michael.Turner at microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew at microsoft.com>
Cc: Laszlo Ersek <lersek at redhat.com>
Signed-off-by: Zhichao Gao <zhichao.gao at intel.com>
---
.../CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf | 2 +
.../CapsuleRuntimeDxe/CapsuleService.c | 68 +++++++++++++++++++
2 files changed, 70 insertions(+)
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
index 9da450722b..15d498863a 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
@@ -72,6 +72,8 @@
## SOMETIMES_PRODUCES ## Variable:L"CapsuleLongModeBuffer" # The long mode buffer used by IA32 Capsule PEIM to call X64 CapsuleCoalesce code to handle >4GB capsule blocks
gEfiCapsuleVendorGuid
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID # FMP capsule GUID
+ gEfiGlobalVariableGuid ## CONSUMES ## Variable L"RuntimeServicesSupported"
+ gEfiEventExitBootServicesGuid ## CONSUMES
[Protocols]
gEfiCapsuleArchProtocolGuid ## PRODUCES
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
index 77b8f00062..e4e700764b 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
@@ -24,6 +24,13 @@ UINTN mTimes = 0;
UINT32 mMaxSizePopulateCapsule = 0;
UINT32 mMaxSizeNonPopulateCapsule = 0;
+//
+// Runtime Services Supported Flag
+// Initialize it to 0x3FFF to indicate it is all supported before runtime
+//
+static UINT16 mRuntimeServicesSupported = 0x3FFF;
+
+
/**
Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended
consumption, the firmware may process the capsule immediately. If the payload should persist
@@ -71,6 +78,10 @@ UpdateCapsule (
CHAR16 CapsuleVarName[30];
CHAR16 *TempVarName;
+ if (!(mRuntimeServicesSupported | EFI_RT_SUPPORTED_UPDATE_CAPSULE)) {
+ return EFI_UNSUPPORTED;
+ }
+
//
// Check if platform support Capsule In RAM or not.
// Platform could choose to drop CapsulePei/CapsuleX64 and do not support Capsule In RAM.
@@ -259,6 +270,10 @@ QueryCapsuleCapabilities (
EFI_CAPSULE_HEADER *CapsuleHeader;
BOOLEAN NeedReset;
+ if (!(mRuntimeServicesSupported | EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES)) {
+ return EFI_UNSUPPORTED;
+ }
+
//
// Capsule Count can't be less than one.
//
@@ -343,6 +358,48 @@ QueryCapsuleCapabilities (
return EFI_SUCCESS;
}
+/**
+ ExitBootServices Event to update the mRuntimeServicesSupported to
+ affect the runtime services.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+**/
+static
+VOID
+EFIAPI
+UpdateRuntimeServicesSupported (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ UINT16 RuntimeServicesSupported;
+ UINT32 Attributes;
+ UINTN DataSize;
+
+ Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
+ DataSize = sizeof (UINT16);
+ Status = gRT->GetVariable (
+ L"RuntimeServicesSupported",
+ &gEfiGlobalVariableGuid,
+ &Attributes,
+ &DataSize,
+ &RuntimeServicesSupported
+ );
+
+ if (!EFI_ERROR (Status)) {
+ mRuntimeServicesSupported = RuntimeServicesSupported;
+ } else if (Status == EFI_NOT_FOUND) {
+ mRuntimeServicesSupported = 0x3FFF;
+ } else {
+ //
+ // Should never arrive here.
+ //
+ ASSERT_EFI_ERROR (Status);
+ }
+}
+
/**
@@ -362,6 +419,7 @@ CapsuleServiceInitialize (
)
{
EFI_STATUS Status;
+ EFI_EVENT Event;
mMaxSizePopulateCapsule = PcdGet32(PcdMaxSizePopulateCapsule);
mMaxSizeNonPopulateCapsule = PcdGet32(PcdMaxSizeNonPopulateCapsule);
@@ -381,6 +439,16 @@ CapsuleServiceInitialize (
gRT->UpdateCapsule = UpdateCapsule;
gRT->QueryCapsuleCapabilities = QueryCapsuleCapabilities;
+ Status = gBS->CreateEventEx(
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ UpdateRuntimeServicesSupported,
+ NULL,
+ &gEfiEventExitBootServicesGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
//
// Install the Capsule Architectural Protocol on a new handle
// to signify the capsule runtime services are ready.
--
2.21.0.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#44032): https://edk2.groups.io/g/devel/message/44032
Mute This Topic: https://groups.io/mt/32524672/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list