Skip to content

Commit

Permalink
RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot.
Browse files Browse the repository at this point in the history
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.
To follow platform policy, platform can reject system reboot by
returning error status and Redfish feature core driver will abort system
reboot.

Signed-off-by: Nickle Wang <[email protected]>
Cc: Abner Chang <[email protected]>
Cc: Igor Kulchytskyy <[email protected]>
Cc: Nick Ramirez <[email protected]>
Reviewed-by: Abner Chang <[email protected]>
  • Loading branch information
nicklela committed Nov 6, 2023
1 parent 39d49cd commit 508365c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
25 changes: 23 additions & 2 deletions RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define EDKII_REDFISH_FEATURE_CORE_DXE_H_

#include <Protocol/EdkIIRedfishFeature.h>
#include <Protocol/EdkIIRedfishOverrideProtocol.h>

#include <Base.h>
#include <Library/BaseLib.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

[Protocols]
gEdkIIRedfishFeatureProtocolGuid ## BY_START
gEdkiiRedfishOverrideProtocolGuid ## CONSUMED

[Pcd]
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid
Expand Down

0 comments on commit 508365c

Please sign in to comment.