]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
EmulatorPkg: Make the shell be the first boot option
[mirror_edk2.git] / EmulatorPkg / Library / PlatformBmLib / PlatformBm.c
index 4e3297c984aa0f909b006a390dcc2db986823013..03f6157ae856ce7921555cdda741cf1089f60980 100644 (file)
@@ -2,13 +2,7 @@
 \r
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -338,6 +332,35 @@ PlatformBdsRegisterStaticBootOptions (
   PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");\r
 }\r
 \r
+/**\r
+  Returns the priority number.\r
+\r
+  @param BootOption\r
+**/\r
+UINTN\r
+BootOptionPriority (\r
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption\r
+  )\r
+{\r
+  //\r
+  // Make sure Shell is first\r
+  //\r
+  if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {\r
+    return 0;\r
+  }\r
+  return 100;\r
+}\r
+\r
+INTN\r
+EFIAPI\r
+CompareBootOption (\r
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Left,\r
+  CONST EFI_BOOT_MANAGER_LOAD_OPTION  *Right\r
+  )\r
+{\r
+  return BootOptionPriority (Left) - BootOptionPriority (Right);\r
+}\r
+\r
 /**\r
   Do the platform specific action after the console is connected.\r
 \r
@@ -383,6 +406,7 @@ PlatformBootManagerAfterConsole (
     PlatformBdsRegisterStaticBootOptions ();\r
     PlatformBdsConnectSequence ();\r
     EfiBootManagerRefreshAllBootOption ();\r
+    EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);\r
     break;\r
   }\r
 }\r