X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMaint%2FBootMaint.c;h=f7b821f9069b7587e5411e75fdd78932909c974e;hb=e2d9bfb2bc8159c7e593ff3807737f582a757bfa;hp=98aadd6ce187cd1f3ebe407089381c084c866c04;hpb=4376a6f27300b7f710947ccf5df53f45a556d970;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c index 98aadd6ce1..f7b821f906 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c @@ -1,7 +1,7 @@ /** @file The functions for Boot Maintainence Main menu. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2010, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -82,7 +82,7 @@ EFI_GUID EfiLegacyDevOrderGuid = EFI_LEGACY_DEV_ORDER_VARIABLE_GUID; EFI_GUID mBootMaintGuid = BOOT_MAINT_FORMSET_GUID; EFI_GUID mFileExplorerGuid = FILE_EXPLORE_FORMSET_GUID; -CHAR16 mBootMaintStorageName[] = L"BmData"; +CHAR16 mBootMaintStorageName[] = L"BmmData"; CHAR16 mFileExplorerStorageName[] = L"FeData"; /** @@ -128,20 +128,22 @@ CreateMenuStringToken ( for (Index = 0; Index < MenuOption->MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index); - HiiLibNewString ( - HiiHandle, - &NewMenuEntry->DisplayStringToken, - NewMenuEntry->DisplayString - ); + NewMenuEntry->DisplayStringToken = HiiSetString ( + HiiHandle, + 0, + NewMenuEntry->DisplayString, + NULL + ); if (NULL == NewMenuEntry->HelpString) { NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken; } else { - HiiLibNewString ( - HiiHandle, - &NewMenuEntry->HelpStringToken, - NewMenuEntry->HelpString - ); + NewMenuEntry->HelpStringToken = HiiSetString ( + HiiHandle, + 0, + NewMenuEntry->HelpString, + NULL + ); } } @@ -182,25 +184,70 @@ BootMaintExtractConfig ( EFI_STATUS Status; UINTN BufferSize; BMM_CALLBACK_DATA *Private; + EFI_STRING ConfigRequestHdr; + EFI_STRING ConfigRequest; + BOOLEAN AllocatedRequest; + UINTN Size; - if (Request == NULL) { + if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } - Private = BMM_CALLBACK_DATA_FROM_THIS (This); + *Progress = Request; + if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mBootMaintGuid, mBootMaintStorageName)) { + return EFI_NOT_FOUND; + } + + ConfigRequestHdr = NULL; + ConfigRequest = NULL; + AllocatedRequest = FALSE; + Size = 0; + Private = BMM_CALLBACK_DATA_FROM_THIS (This); // // Convert buffer data to by helper function BlockToConfig() // BufferSize = sizeof (BMM_FAKE_NV_DATA); + ConfigRequest = Request; + if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { + // + // Request has no request element, construct full request string. + // Allocate and fill a buffer large enough to hold the template + // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator + // + ConfigRequestHdr = HiiConstructConfigHdr (&mBootMaintGuid, mBootMaintStorageName, Private->BmmDriverHandle); + Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (Size); + ASSERT (ConfigRequest != NULL); + AllocatedRequest = TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } + Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, - Request, + ConfigRequest, (UINT8 *) &Private->BmmFakeNvData, BufferSize, Results, Progress ); + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest = NULL; + } + // + // Set Progress string to the original request string. + // + if (Request == NULL) { + *Progress = NULL; + } else if (StrStr (Request, L"OFFSET") == NULL) { + *Progress = Request + StrLen (Request); + } + return Status; } @@ -249,8 +296,7 @@ BootMaintCallback ( UINT8 *NewLegacyDev; UINT8 *DisMap; EFI_FORM_ID FormId; - UINTN BufferSize; - + if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } @@ -271,11 +317,7 @@ BootMaintCallback ( // Retrive uncommitted data from Form Browser // CurrentFakeNVMap = &Private->BmmFakeNvData; - BufferSize = sizeof (BMM_FAKE_NV_DATA); - Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) CurrentFakeNVMap); - if (EFI_ERROR (Status)) { - return Status; - } + HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap); // // need to be subtituded. @@ -453,7 +495,7 @@ BootMaintCallback ( if (QuestionId < CONFIG_OPTION_OFFSET) { switch (QuestionId) { case KEY_VALUE_BOOT_FROM_FILE: - Private->FeCurrentState = BOOT_FROM_FILE_STATE; + Private->FeCurrentState = FileExplorerStateBootFromFile; // // Exit Bmm main formset to send File Explorer formset. @@ -462,7 +504,7 @@ BootMaintCallback ( break; case FORM_BOOT_ADD_ID: - Private->FeCurrentState = ADD_BOOT_OPTION_STATE; + Private->FeCurrentState = FileExplorerStateAddBootOption; // // Exit Bmm main formset to send File Explorer formset. @@ -471,7 +513,7 @@ BootMaintCallback ( break; case FORM_DRV_ADD_FILE_ID: - Private->FeCurrentState = ADD_DRIVER_OPTION_STATE; + Private->FeCurrentState = FileExplorerStateAddDriverOptionState; // // Exit Bmm main formset to send File Explorer formset. @@ -586,8 +628,7 @@ BootMaintCallback ( // // Pass changed uncommitted data back to Form Browser // - BufferSize = sizeof (BMM_FAKE_NV_DATA); - Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) CurrentFakeNVMap, NULL); + Status = HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL); return Status; } @@ -629,8 +670,9 @@ ApplyChangeHandler ( break; case FORM_BOOT_DEL_ID: - ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (UINT8))); - for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) { + for (Index = 0; + ((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (UINT8)))); + Index ++) { NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index); NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext->Deleted = CurrentFakeNVMap->BootOptionDel[Index]; @@ -640,8 +682,9 @@ ApplyChangeHandler ( break; case FORM_DRV_DEL_ID: - ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (UINT8))); - for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) { + for (Index = 0; + ((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (UINT8)))); + Index++) { NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index); NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext->Deleted = CurrentFakeNVMap->DriverOptionDel[Index]; @@ -704,16 +747,17 @@ ApplyChangeHandler ( break; case FORM_CON_IN_ID: - ASSERT ((ConsoleInpMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))); for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index); NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index < MAX_MENU_NUMBER); NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; } for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER); NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber]; } @@ -721,16 +765,17 @@ ApplyChangeHandler ( break; case FORM_CON_OUT_ID: - ASSERT ((ConsoleOutMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))); for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index); NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index < MAX_MENU_NUMBER); NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; } for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER); NewTerminalContext->IsConOut = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber]; } @@ -738,16 +783,17 @@ ApplyChangeHandler ( break; case FORM_CON_ERR_ID: - ASSERT ((ConsoleErrMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8))); for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index); NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index < MAX_MENU_NUMBER); NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index]; } for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) { NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index); NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; + ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER); NewTerminalContext->IsStdErr = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber]; } @@ -848,7 +894,6 @@ InitializeBM ( ) { EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; BMM_CALLBACK_DATA *BmmCallbackInfo; EFI_STATUS Status; UINT8 *Ptr; @@ -895,8 +940,8 @@ InitializeBM ( BmmCallbackInfo->FeConfigAccess.ExtractConfig = FakeExtractConfig; BmmCallbackInfo->FeConfigAccess.RouteConfig = FakeRouteConfig; BmmCallbackInfo->FeConfigAccess.Callback = FileExplorerCallback; - BmmCallbackInfo->FeCurrentState = INACTIVE_STATE; - BmmCallbackInfo->FeDisplayContext = UNKNOWN_CONTEXT; + BmmCallbackInfo->FeCurrentState = FileExplorerStateInActive; + BmmCallbackInfo->FeDisplayContext = FileExplorerDisplayUnknown; // // Install Device Path Protocol and Config Access protocol to driver handle @@ -929,43 +974,57 @@ InitializeBM ( } // - // Post our Boot Maint VFR binnary to the HII database. + // Post our Boot Maint VFR binary to the HII database. // - PackageList = HiiLibPreparePackageList (2, &mBootMaintGuid, BmBin, BdsDxeStrings); - ASSERT (PackageList != NULL); - - Status = gHiiDatabase->NewPackageList ( - gHiiDatabase, - PackageList, - BmmCallbackInfo->BmmDriverHandle, - &BmmCallbackInfo->BmmHiiHandle - ); - FreePool (PackageList); + BmmCallbackInfo->BmmHiiHandle = HiiAddPackages ( + &mBootMaintGuid, + BmmCallbackInfo->BmmDriverHandle, + BmBin, + BdsDxeStrings, + NULL + ); + ASSERT (BmmCallbackInfo->BmmHiiHandle != NULL); // // Post our File Explorer VFR binary to the HII database. // - PackageList = HiiLibPreparePackageList (2, &mFileExplorerGuid, FEBin, BdsDxeStrings); - ASSERT (PackageList != NULL); - - Status = gHiiDatabase->NewPackageList ( - gHiiDatabase, - PackageList, - BmmCallbackInfo->FeDriverHandle, - &BmmCallbackInfo->FeHiiHandle - ); - FreePool (PackageList); + BmmCallbackInfo->FeHiiHandle = HiiAddPackages ( + &mFileExplorerGuid, + BmmCallbackInfo->FeDriverHandle, + FEBin, + BdsDxeStrings, + NULL + ); + ASSERT (BmmCallbackInfo->FeHiiHandle != NULL); // - // Allocate space for creation of Buffer + // Init OpCode Handle and Allocate space for creation of Buffer // - gUpdateData.BufferSize = UPDATE_DATA_SIZE; - gUpdateData.Data = AllocateZeroPool (UPDATE_DATA_SIZE); - if (gUpdateData.Data == NULL) { + mStartOpCodeHandle = HiiAllocateOpCodeHandle (); + if (mStartOpCodeHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; } + mEndOpCodeHandle = HiiAllocateOpCodeHandle (); + if (mEndOpCodeHandle == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // + // Create Hii Extend Label OpCode as the start opcode + // + mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + + // + // Create Hii Extend Label OpCode as the end opcode + // + mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + mEndLabel->Number = LABEL_END; + InitializeStringDepository (); InitAllMenu (BmmCallbackInfo); @@ -989,63 +1048,63 @@ InitializeBM ( Status = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, (VOID **) &LegacyBios); if (!EFI_ERROR (Status)) { RefreshUpdateData (); + mStartLabel->Number = FORM_BOOT_LEGACY_DEVICE_ID; // // If LegacyBios Protocol is installed, add 3 tags about legacy boot option // in BootOption form: legacy FD/HD/CD/NET/BEV // - CreateGotoOpCode ( + HiiCreateGotoOpCode ( + mStartOpCodeHandle, FORM_SET_FD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, - FORM_SET_FD_ORDER_ID, - &gUpdateData + FORM_SET_FD_ORDER_ID ); - CreateGotoOpCode ( + HiiCreateGotoOpCode ( + mStartOpCodeHandle, FORM_SET_HD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, - FORM_SET_HD_ORDER_ID, - &gUpdateData + FORM_SET_HD_ORDER_ID ); - CreateGotoOpCode ( + HiiCreateGotoOpCode ( + mStartOpCodeHandle, FORM_SET_CD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, - FORM_SET_CD_ORDER_ID, - &gUpdateData + FORM_SET_CD_ORDER_ID ); - CreateGotoOpCode ( + HiiCreateGotoOpCode ( + mStartOpCodeHandle, FORM_SET_NET_ORDER_ID, STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, - FORM_SET_NET_ORDER_ID, - &gUpdateData + FORM_SET_NET_ORDER_ID ); - CreateGotoOpCode ( + HiiCreateGotoOpCode ( + mStartOpCodeHandle, FORM_SET_BEV_ORDER_ID, STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, - FORM_SET_BEV_ORDER_ID, - &gUpdateData + FORM_SET_BEV_ORDER_ID ); - - IfrLibUpdateForm ( + + HiiUpdateForm ( BmmCallbackInfo->BmmHiiHandle, &mBootMaintGuid, FORM_BOOT_SETUP_ID, - FORM_BOOT_LEGACY_DEVICE_ID, - FALSE, - &gUpdateData + mStartOpCodeHandle, // Label FORM_BOOT_LEGACY_DEVICE_ID + mEndOpCodeHandle // LABEL_END ); } @@ -1057,17 +1116,22 @@ InitializeBM ( // // Remove our IFR data from HII database // - gHiiDatabase->RemovePackageList (gHiiDatabase, BmmCallbackInfo->BmmHiiHandle); - gHiiDatabase->RemovePackageList (gHiiDatabase, BmmCallbackInfo->FeHiiHandle); + HiiRemovePackages (BmmCallbackInfo->BmmHiiHandle); + HiiRemovePackages (BmmCallbackInfo->FeHiiHandle); CleanUpStringDepository (); FreeAllMenu (); - FreePool (gUpdateData.Data); - gUpdateData.Data = NULL; - Exit: + if (mStartOpCodeHandle != NULL) { + HiiFreeOpCodeHandle (mStartOpCodeHandle); + } + + if (mEndOpCodeHandle != NULL) { + HiiFreeOpCodeHandle (mEndOpCodeHandle); + } + if (BmmCallbackInfo->FeDriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( BmmCallbackInfo->FeDriverHandle, @@ -1142,7 +1206,7 @@ FreeAllMenu ( } /** - Intialize all the string depositories. + Initialize all the string depositories. **/ VOID @@ -1192,7 +1256,7 @@ GetStringTokenFromDepository ( // NextListNode = AllocateZeroPool (sizeof (STRING_LIST_NODE)); ASSERT (NextListNode != NULL); - HiiLibNewString (CallbackData->BmmHiiHandle, &(NextListNode->StringToken), L" "); + NextListNode->StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, L" ", NULL); ASSERT (NextListNode->StringToken != 0); StringDepository->TotalNodeNumber++; @@ -1327,7 +1391,7 @@ FormSetDispatcher ( gFormBrowser2, &CallbackData->BmmHiiHandle, 1, - NULL, + &mBootMaintGuid, 0, NULL, &ActionRequest @@ -1341,7 +1405,7 @@ FormSetDispatcher ( // // When this Formset returns, check if we are going to explore files. // - if (INACTIVE_STATE != CallbackData->FeCurrentState) { + if (FileExplorerStateInActive != CallbackData->FeCurrentState) { UpdateFileExplorer (CallbackData, 0); ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; @@ -1349,7 +1413,7 @@ FormSetDispatcher ( gFormBrowser2, &CallbackData->FeHiiHandle, 1, - NULL, + &mFileExplorerGuid, 0, NULL, &ActionRequest @@ -1358,8 +1422,8 @@ FormSetDispatcher ( EnableResetRequired (); } - CallbackData->FeCurrentState = INACTIVE_STATE; - CallbackData->FeDisplayContext = UNKNOWN_CONTEXT; + CallbackData->FeCurrentState = FileExplorerStateInActive; + CallbackData->FeDisplayContext = FileExplorerDisplayUnknown; ReclaimStringDepository (); } else { break; @@ -1378,11 +1442,12 @@ FormSetDispatcher ( @param BootOrder The Boot Order array. @param BootOrderSize The size of the Boot Order Array. - @return Other value if the Boot Option specified by OptionNumber is not deleteed succesfully. - @retval EFI_SUCCESS If function return successfully. - + @retval EFI_SUCCESS The Boot Option Variable was found and removed + @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible + @retval EFI_NOT_FOUND The Boot Option Variable was not found **/ EFI_STATUS +EFIAPI BdsDeleteBootOption ( IN UINTN OptionNumber, IN OUT UINT16 *BootOrder,