Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>

Thanks for the cleanup, Samer. This debug feature was a gross hack that was additionally incompatible with boot loaders changing GOP settings. It was definitely time to see it go.

A

From: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Sent: Thursday, June 11, 2020 11:27 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Leif Lindholm <leif@nuviainc.com>; Ard Biesheuvel <ard.biesheuvel@arm.com>; Pete Batard <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>
Subject: [edk2-platform][PATCH v1 1/1] Platforms/RaspberryPi: Remove DebugShowUEFIExit
 
The "Verbose ExitBootServices" feature was originally added to the RPi
as part of early OS enablement to show that the OS boot loader did
actually call ExitBootServices (back when OS boot used to crash shortly
after that). This is no longer needed, and should be removed as part of
cleaning the RPi PlatformBootManager to be more in-line with the ArmPkg
version.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
---
 Platform/RaspberryPi/RaspberryPi.dec                                           |  1 -
 Platform/RaspberryPi/RPi3/RPi3.dsc                                             |  1 -
 Platform/RaspberryPi/RPi4/RPi4.dsc                                             |  1 -
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf                           |  1 -
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  1 -
 Platform/RaspberryPi/Include/ConfigVars.h                                      |  8 ---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr                        | 13 -----
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c                             |  8 ---
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c               | 53 --------------------
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni                        |  5 --
 10 files changed, 92 deletions(-)

diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
index 5b4021232cba..c71177a2f762 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -60,7 +60,6 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000012
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
   gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x00000016
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|0x3F|UINT8|0x00000017
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 059d16a912ab..4b1a1e763fa9 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -469,7 +469,6 @@ [PcdsDynamicHii.common.DEFAULT]
   #
 
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|gConfigDxeFormSetGuid|0x0|0
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|L"DebugShowUEFIExit"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Display-related.
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index e055f13cdb47..c481c3534263 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -480,7 +480,6 @@ [PcdsDynamicHii.common.DEFAULT]
   #
 
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|gConfigDxeFormSetGuid|0x0|0
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|L"DebugShowUEFIExit"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Display-related.
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index 5a9819b54df2..cdce35bc74c8 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -84,7 +84,6 @@ [Pcd]
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
   gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index eb44daa4b7b7..88f6f8fe09ba 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -62,7 +62,6 @@ [FixedPcd]
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
   gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
 
 [Guids]
diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h
index cefddbafcd8f..fde24cab84af 100644
--- a/Platform/RaspberryPi/Include/ConfigVars.h
+++ b/Platform/RaspberryPi/Include/ConfigVars.h
@@ -43,14 +43,6 @@ typedef struct {
    UINT32 Enable;
 } DEBUG_ENABLE_JTAG_VARSTORE_DATA;
 
-typedef struct {
-  /*
-   * 0 - Don't show UEFI exit message.
-   * 1 - Show UEFI exit message.
-   */
-   UINT32 Show;
-} DEBUG_SHOW_UEFI_EXIT_VARSTORE_DATA;
-
 typedef struct {
 #define CHIPSET_CPU_CLOCK_LOW     0
 #define CHIPSET_CPU_CLOCK_DEFAULT 1
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
index 72cc90ae0bec..b0b20fd6fb37 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -84,11 +84,6 @@ formset
       name  = DebugEnableJTAG,
       guid  = CONFIGDXE_FORM_SET_GUID;
 
-    efivarstore DEBUG_SHOW_UEFI_EXIT_VARSTORE_DATA,
-      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
-      name  = DebugShowUEFIExit,
-      guid  = CONFIGDXE_FORM_SET_GUID;
-
     efivarstore DISPLAY_ENABLE_SCALED_VMODES_VARSTORE_DATA,
       attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
       name  = DisplayEnableScaledVModes,
@@ -294,13 +289,5 @@ formset
             option text = STRING_TOKEN(STR_DEBUG_JTAG_ENABLE), value = 1, flags = 0;
             option text = STRING_TOKEN(STR_DEBUG_JTAG_DISABLE), value = 0, flags = DEFAULT;
         endoneof;
-
-        oneof varid = DebugShowUEFIExit.Show,
-            prompt      = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_PROMPT),
-            help        = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_HELP),
-            flags       = NUMERIC_SIZE_4 | INTERACTIVE,
-            option text = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_NO), value = 0, flags = DEFAULT;
-            option text = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_YES), value = 1, flags = 0;
-        endoneof;
     endform;
 endformset;
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 52e37ba68ffd..81586fd90571 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -294,14 +294,6 @@ SetupVariables (
     PcdSet32 (PcdDebugEnableJTAG, PcdGet32 (PcdDebugEnableJTAG));
   }
 
-  Size = sizeof (UINT32);
-  Status = gRT->GetVariable (L"DebugShowUEFIExit",
-                  &gConfigDxeFormSetGuid,
-                  NULL, &Size, &Var32);
-  if (EFI_ERROR (Status)) {
-    PcdSet32 (PcdDebugShowUEFIExit, PcdGet32 (PcdDebugShowUEFIExit));
-  }
-
   Size = sizeof (UINT8);
   Status = gRT->GetVariable (L"DisplayEnableScaledVModes",
                   &gConfigDxeFormSetGuid,
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index d347c733855d..cb74d65b7f91 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -524,46 +524,6 @@ SerialConPrint (
   }
 }
 
-STATIC
-VOID
-EFIAPI
-ExitBootServicesHandler (
-  IN EFI_EVENT  Event,
-  IN VOID       *Context
-  )
-{
-  EFI_STATUS Status;
-  //
-  // Long enough to occlude the string printed
-  // in PlatformBootManagerWaitCallback.
-  //
-  STATIC CHAR16 *OsBootStr = L"Exiting UEFI and booting EL2 OS kernel!\r\n";
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Green;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Yellow;
-
-  if (!PcdGet32 (PcdDebugShowUEFIExit)) {
-    return;
-  }
-
-  Green.Raw = 0x00007F00;
-  Black.Raw = 0x00000000;
-  Yellow.Raw = 0x00FFFF00;
-
-  Status = BootLogoUpdateProgress (Yellow.Pixel,
-             Black.Pixel,
-             OsBootStr,
-             Green.Pixel,
-             100, 0);
-  if (Status == EFI_SUCCESS) {
-    SerialConPrint (OsBootStr);
-  } else {
-    Print (L"\n");
-    Print (OsBootStr);
-    Print (L"\n");
-  }
-}
-
 //
 // BDS Platform Functions
 //
@@ -585,21 +545,8 @@ PlatformBootManagerBeforeConsole (
   )
 {
   EFI_STATUS Status;
-  EFI_EVENT ExitBSEvent;
   ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
 
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
-                  TPL_NOTIFY,
-                  ExitBootServicesHandler,
-                  NULL,
-                  &gEfiEventExitBootServicesGuid,
-                  &ExitBSEvent
-                );
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "%a: failed to register ExitBootServices handler\n", __FUNCTION__));
-  }
-
   if (GetBootModeHob () == BOOT_ON_FLASH_UPDATE) {
     DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
     Status = ProcessCapsules ();
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
index 7195e497f986..636de2184f09 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -118,8 +118,3 @@
 #string STR_DEBUG_JTAG_HELP         #language en-US "Signals (nTRST, TDI, TMS, TCK, RTCK, TDO) -> Header pins (15, 7, 13, 22, 16, 18)"
 #string STR_DEBUG_JTAG_ENABLE       #language en-US "Enable JTAG via GPIO"
 #string STR_DEBUG_JTAG_DISABLE      #language en-US "Disable JTAG"
-
-#string STR_DEBUG_EXIT_SHOW_PROMPT  #language en-US "Verbose ExitBootServices"
-#string STR_DEBUG_EXIT_SHOW_HELP    #language en-US "Show message when UEFI hands off to OS"
-#string STR_DEBUG_EXIT_SHOW_NO      #language en-US "Do nothing"
-#string STR_DEBUG_EXIT_SHOW_YES     #language en-US "Show farewell message"
--
2.17.1