* [edk2-devel] [PATCH edk2-platforms v2 1/8] Platform/RaspberryPi: Mark RAM regions as write/execute protectable
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 2/8] Platform/RaspberryPi: Fix line endings in DSCs Ard Biesheuvel via groups.io
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
Mark RAM ranges as write/execute protectable in the GCD memory map. This
is needed to avoid issues with NonCoherentDmaLib in EmbeddedPkg, which
will fail if it does not manage to set the EFI_MEMORY_XP attribute on
the allocated DMA buffers.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
index 7ba1cc5602d2..cf9eca2ffe9a 100644
--- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
+++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
@@ -51,6 +51,8 @@ AddBasicMemoryRegion (
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTABLE |
+ EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE |
EFI_RESOURCE_ATTRIBUTE_TESTED,
Desc->PhysicalBase,
Desc->Length
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120101): https://edk2.groups.io/g/devel/message/120101
Mute This Topic: https://groups.io/mt/107628975/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 2/8] Platform/RaspberryPi: Fix line endings in DSCs
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 1/8] Platform/RaspberryPi: Mark RAM regions as write/execute protectable Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 3/8] Platform/RaspberryPi: Use depex based dispatch order for varstore Ard Biesheuvel via groups.io
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
Get rid of spurious LF-only line endings.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
Platform/RaspberryPi/RPi3/RPi3.dsc | 2 +-
Platform/RaspberryPi/RPi4/RPi4.dsc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index f5361ab95ec4..5977f1e0a310 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -90,7 +90,7 @@ [LibraryClasses.common]
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
- ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf
+ ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 4e91eb9aea96..5cbc636ca7b1 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -88,7 +88,7 @@ [LibraryClasses.common]
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
- ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf
+ ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120102): https://edk2.groups.io/g/devel/message/120102
Mute This Topic: https://groups.io/mt/107628976/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 3/8] Platform/RaspberryPi: Use depex based dispatch order for varstore
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 1/8] Platform/RaspberryPi: Mark RAM regions as write/execute protectable Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 2/8] Platform/RaspberryPi: Fix line endings in DSCs Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 4/8] Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event handler Ard Biesheuvel via groups.io
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
The VarBlockServiceDxe driver needs to be dispatched before the common
VariableRuntimeDxe, but we are currently relying on FDF order and lack
of transitive dependencies for this, which is fragile, and will break
once we move to the generic reset runtime.
So use the existing helper library for this, which can be plugged into
the generic variable drivers, and force them to depex on a GUID that can
be installed as a NULL protocol in VarBlockServiceDxe.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
Platform/RaspberryPi/RPi3/RPi3.dsc | 6 +++++-
Platform/RaspberryPi/RPi4/RPi4.dsc | 6 +++++-
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf | 2 ++
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 2 ++
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 5977f1e0a310..c399d65aa0b5 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -607,9 +607,13 @@ [Components.common]
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {
+ <LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ }
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
}
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 5cbc636ca7b1..f01875173601 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -627,9 +627,13 @@ [Components.common]
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {
+ <LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ }
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
}
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index c2edb25bd41d..9cf5e8b0d01f 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -34,6 +34,7 @@ [Sources]
[Packages]
ArmPkg/ArmPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Platform/RaspberryPi/RaspberryPi.dec
@@ -51,6 +52,7 @@ [LibraryClasses]
UefiRuntimeLib
[Guids]
+ gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL
gEfiEventVirtualAddressChangeGuid
gRaspberryPiEventResetGuid
gEfiEventReadyToBootGuid
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
index 4071a3fca468..d7be37f67af3 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -51,6 +51,8 @@ InstallProtocolInterfaces (
&FvbDevice->FwVolBlockInstance,
&gEfiDevicePathProtocolGuid,
FvbDevice->DevicePath,
+ &gEdkiiNvVarStoreFormattedGuid,
+ NULL,
NULL
);
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 (#120103): https://edk2.groups.io/g/devel/message/120103
Mute This Topic: https://groups.io/mt/107628977/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 4/8] Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event handler
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (2 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 3/8] Platform/RaspberryPi: Use depex based dispatch order for varstore Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 5/8] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification Ard Biesheuvel via groups.io
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
The DumpVars() routine is called directly and via an event notification
callback, and the latter therefore defines the function's prototype,
even though the arguments are unused.
We will introduce another callback into this logic, but via a reset
notifier, which has yet another prototype. So to keep things tidy, drop
the formal parameters from DumpVars() and invoke it via a helper
function that discards the arguments when called as a event notification
callback. We will do the same for the reset notification once that
functionality gets added.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
index d7be37f67af3..006d4ded15e9 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -161,10 +161,8 @@ DoDump (
STATIC
VOID
-EFIAPI
DumpVars (
- IN EFI_EVENT Event,
- IN VOID *Context
+ VOID
)
{
EFI_STATUS Status;
@@ -202,6 +200,16 @@ DumpVars (
mFvInstance->Dirty = FALSE;
}
+STATIC
+VOID
+EFIAPI
+DumpVarsOnEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DumpVars ();
+}
VOID
ReadyToBootHandler (
@@ -216,7 +224,7 @@ ReadyToBootHandler (
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
- DumpVars,
+ DumpVarsOnEvent,
NULL,
&ImageInstallEvent
);
@@ -229,7 +237,7 @@ ReadyToBootHandler (
);
ASSERT_EFI_ERROR (Status);
- DumpVars (NULL, NULL);
+ DumpVars ();
Status = gBS->CloseEvent (Event);
ASSERT_EFI_ERROR (Status);
}
@@ -247,7 +255,7 @@ InstallDumpVarEventHandlers (
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
- DumpVars,
+ DumpVarsOnEvent,
NULL,
&gRaspberryPiEventResetGuid,
&ResetEvent
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120104): https://edk2.groups.io/g/devel/message/120104
Mute This Topic: https://groups.io/mt/107628978/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 5/8] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (3 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 4/8] Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event handler Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 6/8] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook Ard Biesheuvel via groups.io
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
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>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
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 9cf5e8b0d01f..f1ecc47c7f5d 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -63,6 +63,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 006d4ded15e9..b18121155c01 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
@@ -211,6 +213,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,
@@ -248,9 +263,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,
@@ -271,6 +287,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 (#120105): https://edk2.groups.io/g/devel/message/120105
Mute This Topic: https://groups.io/mt/107628979/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 6/8] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (4 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 5/8] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 7/8] Platform/RaspberryPi: Switch to generic reset runtime Ard Biesheuvel via groups.io
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
Duplicate the logic that is triggered on a system reset into the
platform boot manager driver, and hook it up to the EDK2 platform
specific reset notification driver. This is supported by generic EDK2
code in MdeModulePkg, allowing us to retire the platform-specific
EfiResetSystemLib implementation in a subsequent patch. This is needed
because this library class and its only user ResetRuntimeDxe in
EmbeddedPkg are deprecated and are going to be removed.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 3 +
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 76 ++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 5e55eff7bcf9..9c6bbb9dd102 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -46,6 +46,7 @@ [LibraryClasses]
MemoryAllocationLib
PcdLib
PrintLib
+ TimerLib
UefiBootManagerLib
UefiBootServicesTableLib
UefiLib
@@ -63,6 +64,7 @@ [FixedPcd]
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
+ gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay
gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
[Guids]
@@ -78,6 +80,7 @@ [Guids]
gEfiBootManagerPolicyConnectAllGuid
[Protocols]
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid
gEfiBootManagerPolicyProtocolGuid
gEfiDevicePathProtocolGuid
gEfiGraphicsOutputProtocolGuid
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index 1a0fcbf8f908..976e86043790 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -17,6 +17,7 @@
#include <Library/DevicePathLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
+#include <Library/TimerLib.h>
#include <Library/UefiBootManagerLib.h>
#include <Library/UefiLib.h>
#include <Library/PrintLib.h>
@@ -25,6 +26,7 @@
#include <Protocol/EsrtManagement.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/LoadedImage.h>
+#include <Protocol/PlatformSpecificResetHandler.h>
#include <Guid/BootDiscoveryPolicy.h>
#include <Guid/EventGroup.h>
#include <Guid/TtyTerm.h>
@@ -527,6 +529,66 @@ SerialConPrint (
}
}
+/**
+ Disconnect everything.
+ Modified from the UEFI 2.3 spec (May 2009 version)
+
+**/
+STATIC
+VOID
+DisconnectAll (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleIndex;
+
+ /*
+ * Retrieve the list of all handles from the handle database
+ */
+ Status = gBS->LocateHandleBuffer (
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
+ gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL);
+ }
+
+ gBS->FreePool(HandleBuffer);
+}
+
+
+STATIC
+VOID
+EFIAPI
+OnResetNotify (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
+ )
+{
+ UINT32 Delay;
+
+ DisconnectAll ();
+
+ Delay = PcdGet32 (PcdPlatformResetDelay);
+ if (Delay != 0) {
+ DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
+ Delay / 1000000, (Delay % 1000000) / 100000));
+ MicroSecondDelay (Delay);
+ }
+}
+
//
// BDS Platform Functions
//
@@ -549,6 +611,7 @@ PlatformBootManagerBeforeConsole (
{
EFI_STATUS Status;
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
+ EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL *ResetNotify;
if (GetBootModeHob () == BOOT_ON_FLASH_UPDATE) {
DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
@@ -582,6 +645,19 @@ PlatformBootManagerBeforeConsole (
EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
+ Status = gBS->LocateProtocol (
+ &gEdkiiPlatformSpecificResetHandlerProtocolGuid,
+ NULL,
+ (VOID **)&ResetNotify
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = ResetNotify->RegisterResetNotify (
+ ResetNotify,
+ OnResetNotify
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
//
// Signal EndOfDxe PI Event
//
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120106): https://edk2.groups.io/g/devel/message/120106
Mute This Topic: https://groups.io/mt/107628980/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 7/8] Platform/RaspberryPi: Switch to generic reset runtime
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (5 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 6/8] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 8/8] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib Ard Biesheuvel via groups.io
2024-07-30 12:40 ` [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Leif Lindholm
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
Drop the reference to the special reset runtime DXE driver in
EmbeddedPkg, and move to the one in MdeModulePkg shared between all
architectures. This version implements reset notifications, allowing us
to retire the home grown version of that functionality in a subsequent
patch.
Add depexes to the components that rely on the reset notification
protocols to ensure that they are not dispatched before those protocols
are made available by the reset runtime DXE driver.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
Platform/RaspberryPi/RPi3/RPi3.dsc | 6 +++---
Platform/RaspberryPi/RPi4/RPi4.dsc | 6 +++---
Platform/RaspberryPi/RPi3/RPi3.fdf | 2 +-
Platform/RaspberryPi/RPi4/RPi4.fdf | 2 +-
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf | 2 +-
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 3 +++
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 1 +
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 1 +
8 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index c399d65aa0b5..5b6b2782f297 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -226,8 +226,8 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+ ArmMonitorLib|ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
+ ResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
!if $(SECURE_BOOT_ENABLE) == TRUE
@@ -628,7 +628,7 @@ [Components.common]
!endif
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
<LibraryClasses>
RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index f01875173601..58b3d6643382 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -234,8 +234,8 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+ ArmMonitorLib|ArmPkg/Library/ArmMonitorLib/ArmMonitorLib.inf
+ ResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
!if $(SECURE_BOOT_ENABLE) == TRUE
@@ -650,7 +650,7 @@ [Components.common]
!endif
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
<LibraryClasses>
RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf b/Platform/RaspberryPi/RPi3/RPi3.fdf
index 3c569f57740b..090c4a621e90 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -198,7 +198,7 @@ [FV.FvMain]
INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
!endif
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
- INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+ INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4/RPi4.fdf
index 816927761513..080e1638c1c5 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.fdf
+++ b/Platform/RaspberryPi/RPi4/RPi4.fdf
@@ -194,7 +194,7 @@ [FV.FvMain]
INF SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf
!endif
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
- INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
+ INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index f1ecc47c7f5d..665cd7dd062d 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -88,4 +88,4 @@ [Pcd]
[FeaturePcd]
[Depex]
- TRUE
+ gEfiResetNotificationProtocolGuid
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 9c6bbb9dd102..9e26828ba84b 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -89,3 +89,6 @@ [Protocols]
gEfiSimpleFileSystemProtocolGuid
gEsrtManagementProtocolGuid
gEfiUsb2HcProtocolGuid
+
+[Depex]
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
index b18121155c01..26d4b41f94b0 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -293,6 +293,7 @@ InstallDumpVarEventHandlers (
NULL,
(VOID **)&ResetNotify
);
+ ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
Status = ResetNotify->RegisterResetNotify (
ResetNotify,
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index 976e86043790..e5c348cc731b 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -650,6 +650,7 @@ PlatformBootManagerBeforeConsole (
NULL,
(VOID **)&ResetNotify
);
+ ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
Status = ResetNotify->RegisterResetNotify (
ResetNotify,
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120107): https://edk2.groups.io/g/devel/message/120107
Mute This Topic: https://groups.io/mt/107628981/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] 11+ messages in thread
* [edk2-devel] [PATCH edk2-platforms v2 8/8] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (6 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 7/8] Platform/RaspberryPi: Switch to generic reset runtime Ard Biesheuvel via groups.io
@ 2024-07-28 20:44 ` Ard Biesheuvel via groups.io
2024-07-30 12:40 ` [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Leif Lindholm
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-28 20:44 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton
From: Ard Biesheuvel <ardb@kernel.org>
Drop the now unused EfiResetSystemLib implementation, which has been
superseded by the generic one from EDK2.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
Platform/RaspberryPi/RaspberryPi.dec | 1 -
Platform/RaspberryPi/RPi3/RPi3.dsc | 1 -
Platform/RaspberryPi/RPi4/RPi4.dsc | 1 -
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf | 1 -
Platform/RaspberryPi/Library/ResetLib/ResetLib.inf | 45 ------
Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 11 --
Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 151 --------------------
7 files changed, 211 deletions(-)
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
index 6bd16a5ae9fd..a5fa1fb00c48 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -24,7 +24,6 @@ [Protocols]
[Guids]
gRaspberryPiTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
- gRaspberryPiEventResetGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB4, 0xB4, 0xE4, 0xD4, 0xB4}}
gConfigDxeFormSetGuid = {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
[PcdsFixedAtBuild.common]
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 5b6b2782f297..f8cb82f9e2e6 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -125,7 +125,6 @@ [LibraryClasses.common]
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
# Dual serial port library
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 58b3d6643382..113d08bc8448 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -125,7 +125,6 @@ [LibraryClasses.common]
TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
# Dual serial port library
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index 665cd7dd062d..d15671af7260 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -54,7 +54,6 @@ [LibraryClasses]
[Guids]
gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL
gEfiEventVirtualAddressChangeGuid
- gRaspberryPiEventResetGuid
gEfiEventReadyToBootGuid
[Protocols]
diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf b/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
deleted file mode 100644
index 9bdb94a52ebf..000000000000
--- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-#/** @file
-#
-# Reset System lib using PSCI hypervisor or secure monitor calls.
-# Signals the gRaspberryPiEventResetGuid event group on reset.
-#
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2014, Linaro Ltd. All rights reserved.
-# Copyright (c) 2014, ARM Ltd. All rights reserved.
-# Copyright (c) 2008, Apple Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = ResetLib
- FILE_GUID = B9F59B69-A105-41C7-8F5A-2C60DD7FD7AB
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
-
-[Sources]
- ResetLib.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Platform/RaspberryPi/RaspberryPi.dec
-
-[LibraryClasses]
- DebugLib
- BaseLib
- ArmSmcLib
- PcdLib
- TimerLib
- UefiLib
- UefiRuntimeLib
-
-[Guids]
- gRaspberryPiEventResetGuid
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay ## CONSUMES
diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
index 26d4b41f94b0..bc8ab2270423 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -264,20 +264,9 @@ InstallDumpVarEventHandlers (
)
{
EFI_STATUS Status;
- EFI_EVENT ResetEvent;
EFI_EVENT ReadyToBootEvent;
EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotify;
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DumpVarsOnEvent,
- NULL,
- &gRaspberryPiEventResetGuid,
- &ResetEvent
- );
- ASSERT_EFI_ERROR (Status);
-
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
deleted file mode 100644
index 2bcef8d4db2b..000000000000
--- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/** @file
- *
- * Support ResetSystem Runtime call using PSCI calls.
- * Signals the gRaspberryPiEventResetGuid event group on reset.
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2014, Linaro Ltd. All rights reserved.
- * Copyright (c) 2013-2015, ARM Ltd. All rights reserved.
- * Copyright (c) 2008-2009, Apple Inc. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/TimerLib.h>
-#include <Library/EfiResetSystemLib.h>
-#include <Library/ArmSmcLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeLib.h>
-
-#include <IndustryStandard/ArmStdSmc.h>
-
-
-/**
- Disconnect everything.
- Modified from the UEFI 2.3 spec (May 2009 version)
-
-**/
-STATIC
-VOID
-DisconnectAll (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleIndex;
-
- /*
- * Retrieve the list of all handles from the handle database
- */
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return;
- }
-
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL);
- }
-
- gBS->FreePool(HandleBuffer);
-}
-
-
-/**
- Resets the entire platform.
-
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
- EfiResetShutdown the data buffer starts with a Null-terminated
- Unicode string, optionally followed by additional binary data.
-
-**/
-EFI_STATUS
-EFIAPI
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
-{
- ARM_SMC_ARGS ArmSmcArgs;
- UINT32 Delay;
-
- if (!EfiAtRuntime ()) {
- /*
- * Only if still in UEFI.
- */
- EfiEventGroupSignal (&gRaspberryPiEventResetGuid);
-
- DisconnectAll ();
-
- Delay = PcdGet32 (PcdPlatformResetDelay);
- if (Delay != 0) {
- DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
- Delay / 1000000, (Delay % 1000000) / 100000));
- MicroSecondDelay (Delay);
- }
- }
- DEBUG ((DEBUG_INFO, "Platform %a.\n",
- (ResetType == EfiResetShutdown) ? "shutdown" : "reset"));
-
- switch (ResetType) {
- case EfiResetPlatformSpecific:
- // Map the platform specific reset as reboot
- case EfiResetWarm:
- // Map a warm reset into a cold reset
- case EfiResetCold:
- // Send a PSCI 0.2 SYSTEM_RESET command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
- break;
- case EfiResetShutdown:
- // Send a PSCI 0.2 SYSTEM_OFF command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
- break;
- default:
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
- }
-
- ArmCallSmc (&ArmSmcArgs);
-
- // We should never be here
- DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
- CpuDeadLoop ();
- return EFI_UNSUPPORTED;
-}
-
-/**
- Initialize any infrastructure required for LibResetSystem () to function.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
--
2.46.0.rc1.232.g9752f9e123-goog
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120108): https://edk2.groups.io/g/devel/message/120108
Mute This Topic: https://groups.io/mt/107628982/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] 11+ messages in thread
* Re: [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime
2024-07-28 20:44 [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
` (7 preceding siblings ...)
2024-07-28 20:44 ` [edk2-devel] [PATCH edk2-platforms v2 8/8] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib Ard Biesheuvel via groups.io
@ 2024-07-30 12:40 ` Leif Lindholm
2024-07-30 15:43 ` Ard Biesheuvel
8 siblings, 1 reply; 11+ messages in thread
From: Leif Lindholm @ 2024-07-30 12:40 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: devel, Ard Biesheuvel, Jeremy Linton
On Sun, Jul 28, 2024 at 22:44:27 +0200, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> The EmbeddedPkg runtime DXE is being retired in favour of the generic
> one in MdeModulePkg which is actually being maintained.
>
> RPi uses this driver and the associated EfiResetSystemLib, of which it
> has an implementation with value-add for reset notification. So this
> logic needs to be moved elsewhere and hooked up to the generic protocols
> that implement the same.
>
> Changes since v1:
> - boot tested
> - add patch to fix pre-existing issue that causes a crash when DmaLib
> attempts to set EFI_MEMORY_XP on allocated buffers
> - add a patch to force the correct dispatch order for the varstore
> related drivers
> - fix line endings
For the added commits:
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Jeremy Linton <jeremy.linton@arm.com>
>
> Ard Biesheuvel (8):
> Platform/RaspberryPi: Mark RAM regions as write/execute protectable
> Platform/RaspberryPi: Fix line endings in DSCs
> Platform/RaspberryPi: Use depex based dispatch order for varstore
> Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event
> handler
> Platform/RaspberryPi/VarBlockServiceDxe: Register for reset
> notification
> Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook
> Platform/RaspberryPi: Switch to generic reset runtime
> Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
>
> Platform/RaspberryPi/RaspberryPi.dec | 1 -
> Platform/RaspberryPi/RPi3/RPi3.dsc | 15 +-
> Platform/RaspberryPi/RPi4/RPi4.dsc | 15 +-
> Platform/RaspberryPi/RPi3/RPi3.fdf | 2 +-
> Platform/RaspberryPi/RPi4/RPi4.fdf | 2 +-
> Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf | 6 +-
> Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 6 +
> Platform/RaspberryPi/Library/ResetLib/ResetLib.inf | 45 ------
> Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c | 65 ++++++---
> Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c | 2 +
> Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 77 ++++++++++
> Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 151 --------------------
> 12 files changed, 156 insertions(+), 231 deletions(-)
> delete mode 100644 Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
> delete mode 100644 Platform/RaspberryPi/Library/ResetLib/ResetLib.c
>
> --
> 2.46.0.rc1.232.g9752f9e123-goog
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120075): https://edk2.groups.io/g/devel/message/120075
Mute This Topic: https://groups.io/mt/107626473/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime
2024-07-30 12:40 ` [edk2-devel] [PATCH edk2-platforms v2 0/8] RPi: Drop EmbeddedPkg reset runtime Leif Lindholm
@ 2024-07-30 15:43 ` Ard Biesheuvel
0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2024-07-30 15:43 UTC (permalink / raw)
To: devel, quic_llindhol; +Cc: Ard Biesheuvel, Jeremy Linton
On Tue, 30 Jul 2024 at 14:40, Leif Lindholm <quic_llindhol@quicinc.com> wrote:
>
> On Sun, Jul 28, 2024 at 22:44:27 +0200, Ard Biesheuvel wrote:
> > From: Ard Biesheuvel <ardb@kernel.org>
> >
> > The EmbeddedPkg runtime DXE is being retired in favour of the generic
> > one in MdeModulePkg which is actually being maintained.
> >
> > RPi uses this driver and the associated EfiResetSystemLib, of which it
> > has an implementation with value-add for reset notification. So this
> > logic needs to be moved elsewhere and hooked up to the generic protocols
> > that implement the same.
> >
> > Changes since v1:
> > - boot tested
> > - add patch to fix pre-existing issue that causes a crash when DmaLib
> > attempts to set EFI_MEMORY_XP on allocated buffers
> > - add a patch to force the correct dispatch order for the varstore
> > related drivers
> > - fix line endings
>
> For the added commits:
> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
>
Thanks
Merged as 6254b3246aef..8975c5d45ea9
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120121): https://edk2.groups.io/g/devel/message/120121
Mute This Topic: https://groups.io/mt/107626473/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 11+ messages in thread