]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmSmcPsciResetSystemLib: implement fallback for warm reboot
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 6 Jun 2018 12:32:42 +0000 (14:32 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 15 Jun 2018 16:18:37 +0000 (18:18 +0200)
Implement ResetSystemLib's EnterS3WithImmediateWake() routine using
a jump back to the PEI entry point with interrupts and MMU+caches
disabled. This is only possible at boot time, when we are sure that
the current CPU is the only one up and running. Also, it depends on
the platform whether the PEI code is preserved in memory (it may be
copied to DRAM rather than execute in place), so also add a feature
PCD to selectively enable this feature.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/ArmPkg.dec
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf

index debe066b6f7b3503e209431d36a2643dcbe60a99..3aa229fe2ec9a020a6084d58657f67baf1b86d27 100644 (file)
   # Define if the GICv3 controller should use the GICv2 legacy\r
   gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042\r
 \r
+  # Whether to implement warm reboot for capsule update using a jump back to the\r
+  # PEI entry point with caches and interrupts disabled.\r
+  gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot|FALSE|BOOLEAN|0x0000001F\r
+\r
 [PcdsFeatureFlag.ARM]\r
   # Whether to map normal memory as non-shareable. FALSE is the safe choice, but\r
   # TRUE may be appropriate to fix performance problems if you don't care about\r
index d6d26bce5009905f368099aa157af43b501cbbb3..10ceafd14d5de0de5465817615f7650a81ae7073 100644 (file)
 \r
 #include <PiDxe.h>\r
 \r
+#include <Library/ArmMmuLib.h>\r
+#include <Library/ArmSmcLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/ResetSystemLib.h>\r
-#include <Library/ArmSmcLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
 \r
 #include <IndustryStandard/ArmStdSmc.h>\r
 \r
@@ -89,7 +92,21 @@ EnterS3WithImmediateWake (
   VOID\r
   )\r
 {\r
-  // Not implemented\r
+  VOID (*Reset)(VOID);\r
+\r
+  if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot) &&\r
+      !EfiAtRuntime ()) {\r
+    //\r
+    // At boot time, we are the only core running, so we can implement the\r
+    // immediate wake (which is used by capsule update) by disabling the MMU\r
+    // and interrupts, and jumping to the PEI entry point.\r
+    //\r
+    Reset = (VOID (*)(VOID))(UINTN)FixedPcdGet64 (PcdFvBaseAddress);\r
+\r
+    gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+    ArmDisableMmu ();\r
+    Reset ();\r
+  }\r
 }\r
 \r
 /**\r
index 5a1ee976e5bc754e1cbabe526c531ca3d844adda..19021cd1e8b695e840bdbf8db9d06e52c9c1d0ce 100644 (file)
   MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
+  ArmMmuLib\r
   ArmSmcLib\r
   BaseLib\r
   DebugLib\r
+  UefiBootServicesTableLib\r
+  UefiRuntimeLib\r
+\r
+[FeaturePcd]\r
+  gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot\r
+\r
+[FixedPcd]\r
+  gArmTokenSpaceGuid.PcdFvBaseAddress\r