In theory we should be properly cleaning up all the device drivers before hitting the big reset. The partition manager will issue flush commands to attached disks as it goes down. This assures that devices running in WB mode, which correctly handle flush/sync/etc commands, are persisted to physical media before reset.
Without this, there are definitely cases where the relevant specifications don't guarantee persistence of data in their buffers in the face of reset conditions. We can't really do anything about the many devices that don't honor persistence requests, but we can start here. Signed-off-by: Jeremy Linton <jeremy.lin...@arm.com> --- Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c index a70eee485d..2bcef8d4db 100644 --- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c +++ b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c @@ -19,11 +19,51 @@ #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. @@ -53,6 +93,8 @@ LibResetSystem ( */ EfiEventGroupSignal (&gRaspberryPiEventResetGuid); + DisconnectAll (); + Delay = PcdGet32 (PcdPlatformResetDelay); if (Delay != 0) { DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n", -- 2.13.7 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82254): https://edk2.groups.io/g/devel/message/82254 Mute This Topic: https://groups.io/mt/86424965/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-