From: "Ard Biesheuvel via groups.io" <ardb+git=google.com@groups.io>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb@kernel.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Jeremy Linton <jeremy.linton@arm.com>
Subject: [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification
Date: Thu, 25 Jul 2024 12:43:27 +0200 [thread overview]
Message-ID: <20240725104332.1675625-3-ardb+git@google.com> (raw)
In-Reply-To: <20240725104332.1675625-1-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
In addition to setting up the home grown reset notification, register
with the generic EFI protocol that does the same. This event is
triggered from the reset runtime implemented in MdeModulePkg, to which
we will be switching the RPi platforms in a subsequent patch.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf | 1 +
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 35 ++++++++++++++++++--
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index c2edb25bd41d..43a2b06022c8 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -61,6 +61,7 @@ [Protocols]
gEfiBlockIoProtocolGuid
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
+ gEfiResetNotificationProtocolGuid
[FixedPcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
index 6bd026a7b763..3aa2ec76cae7 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -10,6 +10,8 @@
#include "VarBlockService.h"
+#include <Protocol/ResetNotification.h>
+
//
// Minimum delay to enact before reset, when variables are dirty (in μs).
// Needed to ensure that SSD-based USB 3.0 devices have time to flush their
@@ -209,6 +211,19 @@ DumpVarsOnEvent (
DumpVars ();
}
+STATIC
+VOID
+EFIAPI
+DumpVarsOnReset (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ )
+{
+ DumpVars ();
+}
+
VOID
ReadyToBootHandler (
IN EFI_EVENT Event,
@@ -246,9 +261,10 @@ InstallDumpVarEventHandlers (
VOID
)
{
- EFI_STATUS Status;
- EFI_EVENT ResetEvent;
- EFI_EVENT ReadyToBootEvent;
+ EFI_STATUS Status;
+ EFI_EVENT ResetEvent;
+ EFI_EVENT ReadyToBootEvent;
+ EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotify;
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
@@ -269,6 +285,19 @@ InstallDumpVarEventHandlers (
&ReadyToBootEvent
);
ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (
+ &gEfiResetNotificationProtocolGuid,
+ NULL,
+ (VOID **)&ResetNotify
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = ResetNotify->RegisterResetNotify (
+ ResetNotify,
+ DumpVarsOnReset
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
}
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120096): https://edk2.groups.io/g/devel/message/120096
Mute This Topic: https://groups.io/mt/107628960/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-07-30 15:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 10:43 [edk2-devel] [PATCH edk2-platforms 0/5] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 1/5] Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event handler Ard Biesheuvel via groups.io
2024-07-25 10:43 ` Ard Biesheuvel via groups.io [this message]
2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 3/5] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook Ard Biesheuvel via groups.io
2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 4/5] Platform/RaspberryPi: Switch to generic reset runtime Ard Biesheuvel via groups.io
2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib Ard Biesheuvel via groups.io
2024-07-25 11:38 ` Leif Lindholm
2024-07-25 12:12 ` Alexander D
2024-07-25 12:13 ` Ard Biesheuvel
2024-07-25 20:21 ` Jeremy Linton
2024-07-25 21:23 ` Ard Biesheuvel
2024-07-28 19:35 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240725104332.1675625-3-ardb+git@google.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox