public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, leif.lindholm@linaro.org
Cc: daniel.thompson@linaro.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 2/2] ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot mode
Date: Wed,  1 Nov 2017 13:11:45 +0000	[thread overview]
Message-ID: <20171101131145.16459-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20171101131145.16459-1-ard.biesheuvel@linaro.org>

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>
---
 ArmPlatformPkg/PlatformPei/PlatformPeim.c   | 12 +++++++-----
 ArmPlatformPkg/PlatformPei/PlatformPeim.inf |  1 +
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.c b/ArmPlatformPkg/PlatformPei/PlatformPeim.c
index e4535250c245..14f301e947a8 100644
--- a/ArmPlatformPkg/PlatformPei/PlatformPeim.c
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.c
@@ -83,21 +83,23 @@ InitializePlatformPeim (
   )
 {
   EFI_STATUS                    Status;
-  UINTN                         BootMode;
+  EFI_BOOT_MODE                 BootMode;
 
   DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));
 
+  Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());
+  ASSERT_EFI_ERROR (Status);
+
   PlatformPeim ();
 
-  BootMode  = ArmPlatformGetBootMode ();
-  Status    = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
+  Status = PeiServicesGetBootMode (&BootMode);
   ASSERT_EFI_ERROR (Status);
 
-  Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
+  Status = PeiServicesInstallPpi (&mPpiListBootMode);
   ASSERT_EFI_ERROR (Status);
 
   if (BootMode == BOOT_IN_RECOVERY_MODE) {
-    Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
+    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
     ASSERT_EFI_ERROR (Status);
   }
 
diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
index f466c1412ad3..21701cdc0731 100644
--- a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
@@ -43,6 +43,7 @@ [LibraryClasses]
   HobLib
   ArmPlatformLib
   PlatformPeiLib
+  PeiServicesLib
 
 [Ppis]
   gEfiPeiMasterBootModePpiGuid                  # PPI ALWAYS_PRODUCED
-- 
2.11.0



  parent reply	other threads:[~2017-11-01 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 13:11 [PATCH 0/2] PEI phase boot mode setting Ard Biesheuvel
2017-11-01 13:11 ` [PATCH 1/2] EmbeddedPkg: introduce GPIO PPI Ard Biesheuvel
2017-11-05  5:38   ` Leif Lindholm
2017-11-05 10:05     ` Ard Biesheuvel
2017-11-05 16:21       ` Ard Biesheuvel
2017-11-01 13:11 ` Ard Biesheuvel [this message]
2017-11-05  5:43   ` [PATCH 2/2] ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot mode Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171101131145.16459-3-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox