REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1649

Make the shell be the first boot option by default,
So it can boot into UEFI Internal Shell directly,
when run the emulator if user don't change boot order.

Signed-off-by: Zhiguang Liu <zhiguang....@intel.com>

Cc: Jordan Justen <jordan.l.jus...@intel.com>
Cc: Andrew Fish <af...@apple.com>
Cc: Ray Ni <ray...@intel.com>
---
 EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 31 
++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c 
b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
index 2a97e385be..459ac5c4b5 100644
--- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
@@ -388,6 +388,34 @@ PlatformBootManagerChangeDevicePath (
     }
   }
 }
+/**
+  Returns the priority number.
+
+  @param BootOption
+**/
+UINTN
+BootOptionPriority (
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+  )
+{
+  //
+  // Make sure Shell is first
+  //
+  if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {
+    return 0;
+  }
+  return 100;
+}
+
+INTN
+EFIAPI
+CompareBootOption (
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Left,
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Right
+  )
+{
+  return BootOptionPriority (Left) - BootOptionPriority (Right);
+}
 
 /**
   Do the platform specific action after the console is connected.
@@ -432,9 +460,10 @@ PlatformBootManagerAfterConsole (
   default:
     PlatformBdsDiagnostics (IGNORE, TRUE);
     PlatformBootManagerChangeDevicePath(&FirstBoot);
-    PlatformBdsRegisterStaticBootOptions ();
     PlatformBdsConnectSequence ();
     EfiBootManagerRefreshAllBootOption ();
+    PlatformBdsRegisterStaticBootOptions ();
+    if(FirstBoot)EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, 
(SORT_COMPARE) CompareBootOption);
     break;
   }
 }
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39735): https://edk2.groups.io/g/devel/message/39735
Mute This Topic: https://groups.io/mt/31380242/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to