]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
Nt32Pkg: Make Shell as the first boot option
[mirror_edk2.git] / Nt32Pkg / Library / PlatformBootManagerLib / PlatformBootManager.c
index e2c3a4e5f4bb0a98cd13c400c4d7ee11215a61e8..4b23eb1602ef3138be07eaa3850f84a349d54c4c 100644 (file)
@@ -114,6 +114,35 @@ PlatformBootManagerBeforeConsole (
   }\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
@@ -156,6 +185,11 @@ PlatformBootManagerAfterConsole (
   EfiBootManagerGetBootManagerMenu (&BootOption);\r
   EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
 \r
+  //\r
+  // Make Shell as the first boot option\r
+  //\r
+  EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption);\r
+\r
   PlatformBootManagerDiagnostics (QUICK, TRUE);\r
   \r
   PrintXY (10, 10, &White, &Black, L"F2    to enter Boot Manager Menu.                                            ");\r