public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
To: Ruiyu Ni <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Jie Lin <jie.lin@intel.com>,
	"Wang, Sunny (HPS SW)" <sunnywang@hpe.com>,
	"Haskell, Darrell" <darrell.haskell@hpe.com>,
	"Shifflett, Joseph" <joseph.shifflett@hpe.com>
Subject: Re: [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery####
Date: Wed, 16 Nov 2016 09:08:06 +0000	[thread overview]
Message-ID: <CS1PR84MB02956FABAC535E44B0614219A8BE0@CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20161115100425.299856-4-ruiyu.ni@intel.com>

Hi Ray,
This patch looks good to me. 
Reviewed-by: Sunny Wang <sunnywang@hpe.com>

Just a suggestion. If we can add the code block below into BmGetFreeOptionNumber(), I think it would be better.

+  LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, 
+ LoadOptionTypePlatformRecovery);  if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) {
+    for (Index = 0; Index < LoadOptionCount; Index++) {
+      //
+      // The PlatformRecovery#### options are sorted by OptionNumber.
+      // Find the the smallest unused number as the new OptionNumber.
+      //
+      if (LoadOptions[Index].OptionNumber != Index) {
+        break;
+      }
+    }
+    LoadOption.OptionNumber = Index;
+    Status = EfiBootManagerLoadOptionToVariable (&LoadOption);
+    ASSERT_EFI_ERROR (Status);
+  }

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Tuesday, November 15, 2016 6:04 PM
To: edk2-devel@lists.01.org
Cc: Jie Lin <jie.lin@intel.com>
Subject: [edk2] [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery####

Current implementation always creates PlatformRecovery0000 pointing to \EFI\BOOT\BOOT$(ARCH).efi but it may overwrite PlatformRecovery#### created before (maybe by a DXE driver).

The patch only uses the smallest unused option number for the \EFI\BOOT\BOOT$(ARCH).efi PlatformRecovery#### to avoid overwriting already-created PlatformRecovery####.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jie Lin <jie.lin@intel.com>
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index 48e5351..56034f5 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -834,7 +834,7 @@ BdsEntry (
   FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
   Status = EfiBootManagerInitializeLoadOption (
              &LoadOption,
-             0,
+             LoadOptionNumberUnassigned,
              LoadOptionTypePlatformRecovery,
              LOAD_OPTION_ACTIVE,
              L"Default PlatformRecovery", @@ -843,9 +843,24 @@ BdsEntry (
              0
              );
   ASSERT_EFI_ERROR (Status);
-  EfiBootManagerLoadOptionToVariable (&LoadOption);
+  LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, 
+ LoadOptionTypePlatformRecovery);  if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) {
+    for (Index = 0; Index < LoadOptionCount; Index++) {
+      //
+      // The PlatformRecovery#### options are sorted by OptionNumber.
+      // Find the the smallest unused number as the new OptionNumber.
+      //
+      if (LoadOptions[Index].OptionNumber != Index) {
+        break;
+      }
+    }
+    LoadOption.OptionNumber = Index;
+    Status = EfiBootManagerLoadOptionToVariable (&LoadOption);
+    ASSERT_EFI_ERROR (Status);
+  }
   EfiBootManagerFreeLoadOption (&LoadOption);
   FreePool (FilePath);
+  EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);
 
   //
   // Report Status Code to indicate connecting drivers will happen
--
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2016-11-16  9:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 10:04 [PATCH 0/3] Fix 2 bugs relating to PlatformRecovery Ruiyu Ni
2016-11-15 10:04 ` [PATCH 1/3] MdeModulePkg/UefiBootManagerLib: Refine the debug message Ruiyu Ni
2016-11-16  9:03   ` Wang, Sunny (HPS SW)
2016-11-15 10:04 ` [PATCH 2/3] MdeModulePkg/BdsDxe: Fix bug to run non-first PlatformRecovery#### Ruiyu Ni
2016-11-16  9:05   ` Wang, Sunny (HPS SW)
2016-11-15 10:04 ` [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery#### Ruiyu Ni
2016-11-16  9:08   ` Wang, Sunny (HPS SW) [this message]
2016-11-16 10:16     ` Ni, Ruiyu

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=CS1PR84MB02956FABAC535E44B0614219A8BE0@CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM \
    --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