From a5c3c546ea912177eb3ce3f82662718a3204d16f Mon Sep 17 00:00:00 2001 From: gikidy Date: Thu, 14 Jan 2010 04:42:45 +0000 Subject: [PATCH] Fix Boot Option appear twice while add a new boot option in some specific steps. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9738 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/BdsDxe/BootMaint/BootMaint.h | 18 ++- .../Universal/BdsDxe/BootMaint/BootOption.c | 150 +++++++----------- 2 files changed, 70 insertions(+), 98 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h index 42449fb90d..b74b28616a 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.h @@ -591,6 +591,20 @@ BOpt_IsEfiApp ( Get the Option Number that has not been allocated for use. + @param Type The type of Option. + + @return The available Option Number. + +**/ +UINT16 +BOpt_GetOptionNumber ( + CHAR16 *Type + ); + +/** + + Get the Option Number for Boot#### that does not used. + @return The available Option Number. **/ @@ -601,9 +615,9 @@ BOpt_GetBootOptionNumber ( /** - Get the Option Number that is not in use. +Get the Option Number for Driver#### that does not used. - @return The unused Option Number. +@return The unused Option Number. **/ UINT16 diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c index 73d36088a5..3d902e1eb3 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootOption.c @@ -1407,136 +1407,94 @@ BOpt_FindDrivers ( Get the Option Number that has not been allocated for use. + @param Type The type of Option. + @return The available Option Number. **/ UINT16 -BOpt_GetBootOptionNumber ( - VOID +BOpt_GetOptionNumber ( + CHAR16 *Type ) { - BM_MENU_ENTRY *NewMenuEntry; - UINT16 *BootOrderList; - UINTN BootOrderListSize; - UINT16 Number; + UINT16 *OrderList; + UINTN OrderListSize; UINTN Index; - UINTN Index2; - BOOLEAN Found; - CHAR16 StrTemp[100]; + CHAR16 StrTemp[20]; UINT16 *OptionBuffer; + UINT16 OptionNumber; UINTN OptionSize; - BootOrderListSize = 0; - BootOrderList = NULL; + OrderListSize = 0; + OrderList = NULL; + OptionNumber = 0; - BootOrderList = BdsLibGetVariableAndSize ( - L"BootOrder", - &gEfiGlobalVariableGuid, - &BootOrderListSize - ); - if (BootOrderList != NULL) { - // - // already have Boot#### - // - // AlreadyBootNumbers = BootOrderListSize / sizeof(UINT16); - // - for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) { - Found = TRUE; - for (Index2 = 0; Index2 < BootOptionMenu.MenuNumber; Index2++) { - NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index2); - if (Index == NewMenuEntry->OptionNumber) { - Found = FALSE; - break; - } - } + UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type); - if (Found) { - UnicodeSPrint (StrTemp, 100, L"Boot%04x", Index); - DEBUG((DEBUG_ERROR,"INdex= %s\n", StrTemp)); - OptionBuffer = BdsLibGetVariableAndSize ( + OrderList = BdsLibGetVariableAndSize ( StrTemp, &gEfiGlobalVariableGuid, - &OptionSize + &OrderListSize ); - if (NULL == OptionBuffer) { - break; - } + for (OptionNumber = 0; ; OptionNumber++) { + for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) { + if (OptionNumber == OrderList[Index]) { + break; } } - // - // end for Index - // - Number = (UINT16) Index; - } else { - // - // No Boot#### - // - Number = 0; + + if (Index < OrderListSize / sizeof (UINT16)) { + // + // The OptionNumber occurs in the OrderList, continue to use next one + // + continue; + } + UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN) OptionNumber); + DEBUG((EFI_D_ERROR,"Option = %s\n", StrTemp)); + OptionBuffer = BdsLibGetVariableAndSize ( + StrTemp, + &gEfiGlobalVariableGuid, + &OptionSize + ); + if (NULL == OptionBuffer) { + // + // The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it + // + break; + } } - return Number; + return OptionNumber; } /** - Get the Option Number that is not in use. + Get the Option Number for Boot#### that does not used. - @return The unused Option Number. + @return The available Option Number. **/ UINT16 -BOpt_GetDriverOptionNumber ( +BOpt_GetBootOptionNumber ( VOID ) { - BM_MENU_ENTRY *NewMenuEntry; - UINT16 *DriverOrderList; - UINTN DriverOrderListSize; - UINT16 Number; - UINTN Index; - UINTN Index2; - BOOLEAN Found; + return BOpt_GetOptionNumber (L"Boot"); +} - DriverOrderListSize = 0; - DriverOrderList = NULL; +/** - DriverOrderList = BdsLibGetVariableAndSize ( - L"DriverOrder", - &gEfiGlobalVariableGuid, - &DriverOrderListSize - ); - if (DriverOrderList != NULL) { - // - // already have Driver#### - // - // AlreadyDriverNumbers = DriverOrderListSize / sizeof(UINT16); - // - for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) { - Found = TRUE; - for (Index2 = 0; Index2 < DriverOptionMenu.MenuNumber; Index2++) { - NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index2); - if (Index == NewMenuEntry->OptionNumber) { - Found = FALSE; - break; - } - } + Get the Option Number for Driver#### that does not used. - if (Found) { - break; - } - } - // - // end for Index - // - Number = (UINT16) Index; - } else { - // - // No Driver#### - // - Number = 0; - } + @return The unused Option Number. - return Number; +**/ +UINT16 +BOpt_GetDriverOptionNumber ( + VOID + ) +{ + return BOpt_GetOptionNumber (L"Driver"); } /** -- 2.39.2