From 6e06139f17bb0807c214dc674325710572bb8bf5 Mon Sep 17 00:00:00 2001 From: Nickle Wang Date: Thu, 2 Nov 2023 16:50:02 +0800 Subject: [PATCH] RedfishClientPkg: introduce Redfish override protocol Call Redfish override protocol to notify platform that the Redfish changes system settings and about to perform system reboot. Platform firmware can do platform specific operation before system rebooted. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishFeatureCoreDxe.c | 25 +++++++++++++++++-- .../RedfishFeatureCoreDxe.h | 1 + .../RedfishFeatureCoreDxe.inf | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c index d9aa6e1a8..e2ae125f6 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c @@ -242,11 +242,14 @@ RedfishFeatureDriverStartup ( IN VOID *Context ) { + EFI_STATUS Status; REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext; UINT16 RebootTimeout; + EDKII_REDFISH_OVERRIDE_PROTOCOL *RedfishOverride; - StartupContext = (REDFISH_FEATURE_STARTUP_CONTEXT *)Context; - RebootTimeout = PcdGet16 (PcdRedfishSystemRebootTimeout); + RedfishOverride = NULL; + StartupContext = (REDFISH_FEATURE_STARTUP_CONTEXT *)Context; + RebootTimeout = PcdGet16 (PcdRedfishSystemRebootTimeout); // // Invoke EDK2 Redfish feature driver callback to start up // the Redfish operations. @@ -290,6 +293,24 @@ RedfishFeatureDriverStartup ( if (PcdGetBool (PcdRedfishSystemRebootRequired)) { Print (L"System configuration is changed from RESTful interface. Reboot system in %d seconds...\n", RebootTimeout); gBS->Stall (RebootTimeout * 1000000U); + + // + // Call override protocol to notify platform that Redfish is processed + // and about to reboot system. + // + Status = gBS->LocateProtocol ( + &gEdkiiRedfishOverrideProtocolGuid, + NULL, + (VOID **)&RedfishOverride + ); + if (!EFI_ERROR (Status)) { + Status = RedfishOverride->NotifyPhase (RedfishOverride, EdkiiRedfishPhaseBeforeReboot); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: abort the reboot because NotifyPhase() returns failure: %r\n", __func__, Status)); + return; + } + } + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); CpuDeadLoop (); } diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h index a94c7930c..93139af25 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h @@ -12,6 +12,7 @@ #define EDKII_REDFISH_FEATURE_CORE_DXE_H_ #include +#include #include #include diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf index c67525eed..320eddc96 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf @@ -47,6 +47,7 @@ [Protocols] gEdkIIRedfishFeatureProtocolGuid ## BY_START + gEdkiiRedfishOverrideProtocolGuid ## CONSUMED [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid