public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH edk2-platforms 0/5] RPi: Drop EmbeddedPkg reset runtime
@ 2024-07-25 10:43 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
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 UTC (permalink / raw)
  To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Jeremy Linton

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.

Build tested only.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>

Ard Biesheuvel (5):
  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                                             |   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         |   4 +-
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |   6 +
 Platform/RaspberryPi/Library/ResetLib/ResetLib.inf                             |  45 ------
 Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c           |  63 +++++---
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c               |  77 ++++++++++
 Platform/RaspberryPi/Library/ResetLib/ResetLib.c                               | 151 --------------------
 11 files changed, 138 insertions(+), 225 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 (#120094): https://edk2.groups.io/g/devel/message/120094
Mute This Topic: https://groups.io/mt/107628958/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH edk2-platforms 1/5] Platform/RaspberryPi/VarBlockServiceDxe: Refactor DumpVars event handler
  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 ` Ard Biesheuvel via groups.io
  2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification Ard Biesheuvel via groups.io
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 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>
---
 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 4071a3fca468..6bd026a7b763 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -159,10 +159,8 @@ DoDump (
 
 STATIC
 VOID
-EFIAPI
 DumpVars (
-  IN EFI_EVENT Event,
-  IN VOID *Context
+  VOID
   )
 {
   EFI_STATUS Status;
@@ -200,6 +198,16 @@ DumpVars (
   mFvInstance->Dirty = FALSE;
 }
 
+STATIC
+VOID
+EFIAPI
+DumpVarsOnEvent (
+  IN EFI_EVENT Event,
+  IN VOID *Context
+  )
+{
+  DumpVars ();
+}
 
 VOID
 ReadyToBootHandler (
@@ -214,7 +222,7 @@ ReadyToBootHandler (
   Status = gBS->CreateEvent (
                   EVT_NOTIFY_SIGNAL,
                   TPL_CALLBACK,
-                  DumpVars,
+                  DumpVarsOnEvent,
                   NULL,
                   &ImageInstallEvent
                 );
@@ -227,7 +235,7 @@ ReadyToBootHandler (
                 );
   ASSERT_EFI_ERROR (Status);
 
-  DumpVars (NULL, NULL);
+  DumpVars ();
   Status = gBS->CloseEvent (Event);
   ASSERT_EFI_ERROR (Status);
 }
@@ -245,7 +253,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 (#120095): https://edk2.groups.io/g/devel/message/120095
Mute This Topic: https://groups.io/mt/107628959/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] 12+ messages in thread

* [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification
  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
  2024-07-25 10:43 ` [edk2-devel] [PATCH edk2-platforms 3/5] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook Ard Biesheuvel via groups.io
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 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>
---
 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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [edk2-devel] [PATCH edk2-platforms 3/5] Platform/RaspberryPi/PlatformBootManagerLib: Reimplement reset hook
  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 ` [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification Ard Biesheuvel via groups.io
@ 2024-07-25 10:43 ` 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
  4 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 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>
---
 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 (#120097): https://edk2.groups.io/g/devel/message/120097
Mute This Topic: https://groups.io/mt/107628961/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] 12+ messages in thread

* [edk2-devel] [PATCH edk2-platforms 4/5] Platform/RaspberryPi: Switch to generic reset runtime
  2024-07-25 10:43 [edk2-devel] [PATCH edk2-platforms 0/5] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
                   ` (2 preceding siblings ...)
  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 ` 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
  4 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 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>
---
 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 5977f1e0a310..0447c5628ea7 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
@@ -624,7 +624,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 5cbc636ca7b1..49c0d8049ff1 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
@@ -646,7 +646,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 43a2b06022c8..6456153fd3ab 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -86,4 +86,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 3aa2ec76cae7..81dfb95e323c 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -291,6 +291,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 (#120098): https://edk2.groups.io/g/devel/message/120098
Mute This Topic: https://groups.io/mt/107628962/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] 12+ messages in thread

* [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  2024-07-25 10:43 [edk2-devel] [PATCH edk2-platforms 0/5] RPi: Drop EmbeddedPkg reset runtime Ard Biesheuvel via groups.io
                   ` (3 preceding siblings ...)
  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 ` Ard Biesheuvel via groups.io
  2024-07-25 11:38   ` Leif Lindholm
  4 siblings, 1 reply; 12+ messages in thread
From: Ard Biesheuvel via groups.io @ 2024-07-25 10:43 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>
---
 Platform/RaspberryPi/RaspberryPi.dec                                   |   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 --------------------
 5 files changed, 209 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/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index 6456153fd3ab..53391466a77b 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -52,7 +52,6 @@ [LibraryClasses]
 
 [Guids]
   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 81dfb95e323c..04414b142c7e 100644
--- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
@@ -262,20 +262,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 (#120099): https://edk2.groups.io/g/devel/message/120099
Mute This Topic: https://groups.io/mt/107628963/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] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  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 20:21     ` Jeremy Linton
  0 siblings, 2 replies; 12+ messages in thread
From: Leif Lindholm @ 2024-07-25 11:38 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: devel, Ard Biesheuvel, Jeremy Linton

On Thu, Jul 25, 2024 at 12:43:30 +0200, Ard Biesheuvel wrote:
> 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>
> ---
>  Platform/RaspberryPi/RaspberryPi.dec                                   |   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 --------------------
>  5 files changed, 209 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}}

*loud sigh at looking those "GUIDs"*
But that's not this set's fault.

For the series:
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Thanks!

/
    Leif

>  [PcdsFixedAtBuild.common]
> diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
> index 6456153fd3ab..53391466a77b 100644
> --- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
> +++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
> @@ -52,7 +52,6 @@ [LibraryClasses]
>  
>  [Guids]
>    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 81dfb95e323c..04414b142c7e 100644
> --- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
> +++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
> @@ -262,20 +262,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 (#120037): https://edk2.groups.io/g/devel/message/120037
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  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
  1 sibling, 1 reply; 12+ messages in thread
From: Alexander D @ 2024-07-25 12:12 UTC (permalink / raw)
  To: Leif Lindholm, devel

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

Shouldn't there be an alternative to gRaspberryPiEventResetGuid for the FVB driver? If you make changes to the var store then reset, pretty sure they'll be getting lost, right?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120039): https://edk2.groups.io/g/devel/message/120039
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 1723 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  2024-07-25 12:12     ` Alexander D
@ 2024-07-25 12:13       ` Ard Biesheuvel
  0 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2024-07-25 12:13 UTC (permalink / raw)
  To: devel, aenv067; +Cc: Leif Lindholm

On Thu, 25 Jul 2024 at 14:12, Alexander D <aenv067@gmail.com> wrote:
>
> Shouldn't there be an alternative to gRaspberryPiEventResetGuid for the FVB driver? If you make changes to the var store then reset, pretty sure they'll be getting lost, right?

Indeed. This is handled in a preceding patch.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120040): https://edk2.groups.io/g/devel/message/120040
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  2024-07-25 11:38   ` Leif Lindholm
  2024-07-25 12:12     ` Alexander D
@ 2024-07-25 20:21     ` Jeremy Linton
  2024-07-25 21:23       ` Ard Biesheuvel
  1 sibling, 1 reply; 12+ messages in thread
From: Jeremy Linton @ 2024-07-25 20:21 UTC (permalink / raw)
  To: Leif Lindholm, Ard Biesheuvel; +Cc: devel, Ard Biesheuvel

Hi,

On 7/25/24 06:38, Leif Lindholm wrote:
> On Thu, Jul 25, 2024 at 12:43:30 +0200, Ard Biesheuvel wrote:
>> 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>
>> ---
>>   Platform/RaspberryPi/RaspberryPi.dec                                   |   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 --------------------
>>   5 files changed, 209 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}}
> 
> *loud sigh at looking those "GUIDs"*
> But that's not this set's fault.

The first couple are DCE time/mac UUIDs with the MAC address fuzzed, no? 
Initially I assumed this coudn't be the case because I would have 
expected the timestamp (2016-06-13 21:57:59, which looks almost 
reasonable) to vary, but i'm guessing they were generated, and then 
someone didn't want their mac in the pubic so they fuzzed it a couple 
times rather than generating completely new IDs. Some of the others 
though, maybe a BE/LE UUID/GUID manual conversion (or not) problem...

Anyway, I will spin it up in a day or two on real hardware, but right 
now its all torn down in boxes because i've moved.



> 
> For the series:
> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
> Thanks!
> 
> /
>      Leif
> 
>>   [PcdsFixedAtBuild.common]
>> diff --git a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
>> index 6456153fd3ab..53391466a77b 100644
>> --- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
>> +++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
>> @@ -52,7 +52,6 @@ [LibraryClasses]
>>   
>>   [Guids]
>>     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 81dfb95e323c..04414b142c7e 100644
>> --- a/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
>> +++ b/Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
>> @@ -262,20 +262,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 (#120042): https://edk2.groups.io/g/devel/message/120042
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  2024-07-25 20:21     ` Jeremy Linton
@ 2024-07-25 21:23       ` Ard Biesheuvel
  2024-07-28 19:35         ` Ard Biesheuvel
  0 siblings, 1 reply; 12+ messages in thread
From: Ard Biesheuvel @ 2024-07-25 21:23 UTC (permalink / raw)
  To: Jeremy Linton; +Cc: Leif Lindholm, Ard Biesheuvel, devel

On Thu, 25 Jul 2024 at 22:21, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> Hi,
>
> On 7/25/24 06:38, Leif Lindholm wrote:
> > On Thu, Jul 25, 2024 at 12:43:30 +0200, Ard Biesheuvel wrote:
> >> 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>
> >> ---
> >>   Platform/RaspberryPi/RaspberryPi.dec                                   |   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 --------------------
> >>   5 files changed, 209 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}}
> >
> > *loud sigh at looking those "GUIDs"*
> > But that's not this set's fault.
>
> The first couple are DCE time/mac UUIDs with the MAC address fuzzed, no?
> Initially I assumed this coudn't be the case because I would have
> expected the timestamp (2016-06-13 21:57:59, which looks almost
> reasonable) to vary, but i'm guessing they were generated, and then
> someone didn't want their mac in the pubic so they fuzzed it a couple
> times rather than generating completely new IDs. Some of the others
> though, maybe a BE/LE UUID/GUID manual conversion (or not) problem...
>

It looks to me like "hey I need a new GUIO so I'll just grab this one
and stick some 2s or some 4s in random places"

> Anyway, I will spin it up in a day or two on real hardware, but right
> now its all torn down in boxes because i've moved.
>

Thanks. I'll do the same myself on Sunday or Monday - am travelling at
the moment.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120043): https://edk2.groups.io/g/devel/message/120043
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: Drop platform specific EfiResetSystemLib
  2024-07-25 21:23       ` Ard Biesheuvel
@ 2024-07-28 19:35         ` Ard Biesheuvel
  0 siblings, 0 replies; 12+ messages in thread
From: Ard Biesheuvel @ 2024-07-28 19:35 UTC (permalink / raw)
  To: Jeremy Linton; +Cc: Leif Lindholm, Ard Biesheuvel, devel

On Thu, 25 Jul 2024 at 23:23, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 25 Jul 2024 at 22:21, Jeremy Linton <jeremy.linton@arm.com> wrote:
> >
> > Hi,
> >
> > On 7/25/24 06:38, Leif Lindholm wrote:
> > > On Thu, Jul 25, 2024 at 12:43:30 +0200, Ard Biesheuvel wrote:
> > >> 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>
> > >> ---
> > >>   Platform/RaspberryPi/RaspberryPi.dec                                   |   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 --------------------
> > >>   5 files changed, 209 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}}
> > >
> > > *loud sigh at looking those "GUIDs"*
> > > But that's not this set's fault.
> >
> > The first couple are DCE time/mac UUIDs with the MAC address fuzzed, no?
> > Initially I assumed this coudn't be the case because I would have
> > expected the timestamp (2016-06-13 21:57:59, which looks almost
> > reasonable) to vary, but i'm guessing they were generated, and then
> > someone didn't want their mac in the pubic so they fuzzed it a couple
> > times rather than generating completely new IDs. Some of the others
> > though, maybe a BE/LE UUID/GUID manual conversion (or not) problem...
> >
>
> It looks to me like "hey I need a new GUIO so I'll just grab this one
> and stick some 2s or some 4s in random places"
>
> > Anyway, I will spin it up in a day or two on real hardware, but right
> > now its all torn down in boxes because i've moved.
> >
>
> Thanks. I'll do the same myself on Sunday or Monday - am travelling at
> the moment.

I ran into some issues with dispatch order - the added depexes prevent
the varblockservicedxe from being dispatched before the
VariableRuntimeDxe, which results in a crash.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120058): https://edk2.groups.io/g/devel/message/120058
Mute This Topic: https://groups.io/mt/107540912/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-07-30 15:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi/VarBlockServiceDxe: Register for reset notification Ard Biesheuvel via groups.io
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox