]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot mode
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 1 Nov 2017 12:57:26 +0000 (12:57 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Sun, 5 Nov 2017 16:19:00 +0000 (16:19 +0000)
The current interdepencies between the PrePeiCore SEC module, the
platform PEIM and ArmPlatformLib is a bit awkward: due to the fact
that ArmPlatformLib is also used by SEC modules, we cannot use PEI
specific facilities in the implementation of ArmPlatformGetBootMode.
However, given that we call that library function /after/ invoking
PlatformPeiLib, there is no way for that library to set the boot mode
other than resorting to tricks like notification callbacks on arbitrary
unrelated events.

ArmPlatformLib should probably be phased out anyway, given its quirky
nature, but for now, let's fix this particular issue by deferring the
call to PlatformPeim() to after the point where we set the boot mode
by calling ArmPlatformGetBootMode ().

While we're at it, clean up the code slightly by using PeiServicesLib
instead of doing double pointer dereferencing.

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

index e4535250c245a70fe2b070d0db0002e555c7b9a8..14f301e947a8ef69e059d92751bb2c07b594933f 100644 (file)
@@ -83,21 +83,23 @@ InitializePlatformPeim (
   )\r
 {\r
   EFI_STATUS                    Status;\r
-  UINTN                         BootMode;\r
+  EFI_BOOT_MODE                 BootMode;\r
 \r
   DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));\r
 \r
+  Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   PlatformPeim ();\r
 \r
-  BootMode  = ArmPlatformGetBootMode ();\r
-  Status    = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);\r
+  Status = PeiServicesGetBootMode (&BootMode);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);\r
+  Status = PeiServicesInstallPpi (&mPpiListBootMode);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
-    Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);\r
+    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
index f466c1412ad318a6fb8c96144e6a7f2963214899..21701cdc0731bd49086121042c1ad6c09803e387 100644 (file)
@@ -43,6 +43,7 @@
   HobLib\r
   ArmPlatformLib\r
   PlatformPeiLib\r
+  PeiServicesLib\r
 \r
 [Ppis]\r
   gEfiPeiMasterBootModePpiGuid                  # PPI ALWAYS_PRODUCED\r