]> 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 191ce58cfbd11fe61cebed6eb4cb4585efb217dd..03f6157ae856ce7921555cdda741cf1089f60980 100644 (file)
@@ -332,6 +332,35 @@ PlatformBdsRegisterStaticBootOptions (
   PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");\r
 }\r
 \r
   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
 /**\r
   Do the platform specific action after the console is connected.\r
 \r
@@ -377,6 +406,7 @@ PlatformBootManagerAfterConsole (
     PlatformBdsRegisterStaticBootOptions ();\r
     PlatformBdsConnectSequence ();\r
     EfiBootManagerRefreshAllBootOption ();\r
     PlatformBdsRegisterStaticBootOptions ();\r
     PlatformBdsConnectSequence ();\r
     EfiBootManagerRefreshAllBootOption ();\r
+    EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);\r
     break;\r
   }\r
 }\r
     break;\r
   }\r
 }\r