* [edk2-devel] [edk2-redfish-client][PATCH 2/2] RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot.
@ 2023-11-02 10:17 Nickle Wang via groups.io
2023-11-06 0:57 ` Chang, Abner via groups.io
0 siblings, 1 reply; 2+ messages in thread
From: Nickle Wang via groups.io @ 2023-11-02 10:17 UTC (permalink / raw)
To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez
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 <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
.../RedfishFeatureCoreDxe.inf | 1 +
.../RedfishFeatureCoreDxe.h | 1 +
.../RedfishFeatureCoreDxe.c | 25 +++++++++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
index c67525ee..320eddc9 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
@@ -47,6 +47,7 @@
[Protocols]
gEdkIIRedfishFeatureProtocolGuid ## BY_START
+ gEdkiiRedfishOverrideProtocolGuid ## CONSUMED
[Pcd]
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
index a94c7930..93139af2 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
@@ -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>
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
index d9aa6e1a..e2ae125f 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 ();
}
--
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110512): https://edk2.groups.io/g/devel/message/110512
Mute This Topic: https://groups.io/mt/102338708/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [edk2-redfish-client][PATCH 2/2] RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot.
2023-11-02 10:17 [edk2-devel] [edk2-redfish-client][PATCH 2/2] RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot Nickle Wang via groups.io
@ 2023-11-06 0:57 ` Chang, Abner via groups.io
0 siblings, 0 replies; 2+ messages in thread
From: Chang, Abner via groups.io @ 2023-11-06 0:57 UTC (permalink / raw)
To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nick Ramirez
[AMD Official Use Only - General]
Looks good, you can move EDKII_REDFISH_OVERRIDE_PROTOCOL *RedfishOverride from local variable to global variable and locate this protocol only once if there are more than one use cases of Redfish override protocol in RedfishFeatureCore in the future.
Reviewed-by: Abner Chang <abner.chang@amd.com>
> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Thursday, November 2, 2023 6:18 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>
> Subject: [edk2-redfish-client][PATCH 2/2]
> RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> 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 <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nick Ramirez <nramirez@nvidia.com>
> ---
> .../RedfishFeatureCoreDxe.inf | 1 +
> .../RedfishFeatureCoreDxe.h | 1 +
> .../RedfishFeatureCoreDxe.c | 25 +++++++++++++++++--
> 3 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git
> a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> index c67525ee..320eddc9 100644
> --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> @@ -47,6 +47,7 @@
>
> [Protocols]
> gEdkIIRedfishFeatureProtocolGuid ## BY_START
> + gEdkiiRedfishOverrideProtocolGuid ## CONSUMED
>
> [Pcd]
>
> gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEve
> ntGuid
> diff --git
> a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
> b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
> index a94c7930..93139af2 100644
> --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
> +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h
> @@ -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>
> diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
> index d9aa6e1a..e2ae125f 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 ();
> }
> --
> 2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110687): https://edk2.groups.io/g/devel/message/110687
Mute This Topic: https://groups.io/mt/102338708/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-06 0:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 10:17 [edk2-devel] [edk2-redfish-client][PATCH 2/2] RedfishClientPkg/RedfishFeatureCoreDxe: notify platform before reboot Nickle Wang via groups.io
2023-11-06 0:57 ` Chang, Abner via groups.io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox