]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix Boot Option appear twice while add a new boot option in some specific steps.
authorgikidy <gikidy@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jan 2010 04:42:45 +0000 (04:42 +0000)
committergikidy <gikidy@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jan 2010 04:42:45 +0000 (04:42 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9738 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c

index 42449fb90d245ca57f405e21e3c7743b49e8fd66..b74b28616a6263ce4441758f54aee9a43ec5459b 100644 (file)
@@ -591,6 +591,20 @@ BOpt_IsEfiApp (
 \r
   Get the Option Number that has not been allocated for use.\r
 \r
+  @param Type  The type of Option.\r
+\r
+  @return The available Option Number.\r
+\r
+**/\r
+UINT16\r
+BOpt_GetOptionNumber (\r
+  CHAR16        *Type\r
+  );\r
+\r
+/**\r
+\r
+  Get the Option Number for Boot#### that does not used.\r
+\r
   @return The available Option Number.\r
 \r
 **/\r
@@ -601,9 +615,9 @@ BOpt_GetBootOptionNumber (
 \r
 /**\r
 \r
-  Get the Option Number that is not in use.\r
+Get the Option Number for Driver#### that does not used.\r
 \r
-  @return The unused Option Number.\r
+@return The unused Option Number.\r
 \r
 **/\r
 UINT16\r
index 73d36088a5e5f82ae216542582a2e8985125e9c8..3d902e1eb356673e1db7be92f17f934531c741a1 100644 (file)
@@ -1407,136 +1407,94 @@ BOpt_FindDrivers (
 \r
   Get the Option Number that has not been allocated for use.\r
 \r
+  @param Type  The type of Option.\r
+\r
   @return The available Option Number.\r
 \r
 **/\r
 UINT16\r
-BOpt_GetBootOptionNumber (\r
-  VOID\r
+BOpt_GetOptionNumber (\r
+  CHAR16        *Type\r
   )\r
 {\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        *BootOrderList;\r
-  UINTN         BootOrderListSize;\r
-  UINT16        Number;\r
+  UINT16        *OrderList;\r
+  UINTN         OrderListSize;\r
   UINTN         Index;\r
-  UINTN         Index2;\r
-  BOOLEAN       Found;\r
-  CHAR16        StrTemp[100];\r
+  CHAR16        StrTemp[20];\r
   UINT16        *OptionBuffer;\r
+  UINT16        OptionNumber;\r
   UINTN         OptionSize;\r
 \r
-  BootOrderListSize = 0;\r
-  BootOrderList     = NULL;\r
+  OrderListSize = 0;\r
+  OrderList     = NULL;\r
+  OptionNumber  = 0;\r
 \r
-  BootOrderList = BdsLibGetVariableAndSize (\r
-                    L"BootOrder",\r
-                    &gEfiGlobalVariableGuid,\r
-                    &BootOrderListSize\r
-                    );\r
-  if (BootOrderList != NULL) {\r
-    //\r
-    // already have Boot####\r
-    //\r
-    // AlreadyBootNumbers = BootOrderListSize / sizeof(UINT16);\r
-    //\r
-    for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
-      Found = TRUE;\r
-      for (Index2 = 0; Index2 < BootOptionMenu.MenuNumber; Index2++) {\r
-        NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index2);\r
-        if (Index == NewMenuEntry->OptionNumber) {\r
-          Found = FALSE;\r
-          break;\r
-        }\r
-      }\r
+  UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type);\r
 \r
-      if (Found) {\r
-        UnicodeSPrint (StrTemp, 100, L"Boot%04x", Index);\r
-        DEBUG((DEBUG_ERROR,"INdex= %s\n", StrTemp));\r
-        OptionBuffer = BdsLibGetVariableAndSize (\r
+  OrderList = BdsLibGetVariableAndSize (\r
                           StrTemp,\r
                           &gEfiGlobalVariableGuid,\r
-                          &OptionSize\r
+                          &OrderListSize\r
                           );\r
-        if (NULL == OptionBuffer) {\r
-          break;\r
-        }\r
+  for (OptionNumber = 0; ; OptionNumber++) {\r
+    for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {\r
+      if (OptionNumber == OrderList[Index]) {\r
+        break;\r
       }\r
     }\r
-    //\r
-    // end for Index\r
-    //\r
-    Number = (UINT16) Index;\r
-  } else {\r
-    //\r
-    // No Boot####\r
-    //\r
-    Number = 0;\r
+\r
+    if (Index < OrderListSize / sizeof (UINT16)) {\r
+      //\r
+      // The OptionNumber occurs in the OrderList, continue to use next one\r
+      //\r
+      continue;\r
+    }\r
+    UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN) OptionNumber);\r
+    DEBUG((EFI_D_ERROR,"Option = %s\n", StrTemp));\r
+    OptionBuffer = BdsLibGetVariableAndSize (\r
+                       StrTemp,\r
+                       &gEfiGlobalVariableGuid,\r
+                       &OptionSize\r
+                       );\r
+    if (NULL == OptionBuffer) {\r
+      //\r
+      // The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it\r
+      //\r
+      break;\r
+    }\r
   }\r
 \r
-  return Number;\r
+  return OptionNumber;\r
 }\r
 \r
 /**\r
 \r
-  Get the Option Number that is not in use.\r
+  Get the Option Number for Boot#### that does not used.\r
 \r
-  @return The unused Option Number.\r
+  @return The available Option Number.\r
 \r
 **/\r
 UINT16\r
-BOpt_GetDriverOptionNumber (\r
+BOpt_GetBootOptionNumber (\r
   VOID\r
   )\r
 {\r
-  BM_MENU_ENTRY *NewMenuEntry;\r
-  UINT16        *DriverOrderList;\r
-  UINTN         DriverOrderListSize;\r
-  UINT16        Number;\r
-  UINTN         Index;\r
-  UINTN         Index2;\r
-  BOOLEAN       Found;\r
+  return BOpt_GetOptionNumber (L"Boot");\r
+}\r
 \r
-  DriverOrderListSize = 0;\r
-  DriverOrderList     = NULL;\r
+/**\r
 \r
-  DriverOrderList = BdsLibGetVariableAndSize (\r
-                      L"DriverOrder",\r
-                      &gEfiGlobalVariableGuid,\r
-                      &DriverOrderListSize\r
-                      );\r
-  if (DriverOrderList != NULL) {\r
-    //\r
-    // already have Driver####\r
-    //\r
-    // AlreadyDriverNumbers = DriverOrderListSize / sizeof(UINT16);\r
-    //\r
-    for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {\r
-      Found = TRUE;\r
-      for (Index2 = 0; Index2 < DriverOptionMenu.MenuNumber; Index2++) {\r
-        NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index2);\r
-        if (Index == NewMenuEntry->OptionNumber) {\r
-          Found = FALSE;\r
-          break;\r
-        }\r
-      }\r
+  Get the Option Number for Driver#### that does not used.\r
 \r
-      if (Found) {\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // end for Index\r
-    //\r
-    Number = (UINT16) Index;\r
-  } else {\r
-    //\r
-    // No Driver####\r
-    //\r
-    Number = 0;\r
-  }\r
+  @return The unused Option Number.\r
 \r
-  return Number;\r
+**/\r
+UINT16\r
+BOpt_GetDriverOptionNumber (\r
+  VOID\r
+  )\r
+{\r
+  return BOpt_GetOptionNumber (L"Driver");\r
 }\r
 \r
 /**\r