X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMaint%2FBootMaint.c;h=d3215a3c866a5a892127bcb292b3614db27e3e4b;hp=3f5bbc40c2138de67df62d7ec125b97b21ded0d1;hb=847240774030f9da79140a9d515a64ec817eb6eb;hpb=6ba0bc7c4ec0aa1df5ca5c5ac788ad6516eaa2ee diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c index 3f5bbc40c2..d3215a3c86 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c @@ -1,8 +1,8 @@ /** @file The functions for Boot Maintainence Main menu. -Copyright (c) 2004 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2004 - 2011, 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 http://opensource.org/licenses/bsd-license.php @@ -38,10 +38,7 @@ HII_VENDOR_DEVICE_PATH mBmmHiiVendorDevicePath = { (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) } }, - // - // {165A028F-0BB2-4b5f-8747-77592E3F6499} - // - { 0x165a028f, 0xbb2, 0x4b5f, { 0x87, 0x47, 0x77, 0x59, 0x2e, 0x3f, 0x64, 0x99 } } + BOOT_MAINT_FORMSET_GUID }, { END_DEVICE_PATH_TYPE, @@ -63,10 +60,7 @@ HII_VENDOR_DEVICE_PATH mFeHiiVendorDevicePath = { (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) } }, - // - // {91DB4238-B0C8-472e-BBCF-F3A6541010F4} - // - { 0x91db4238, 0xb0c8, 0x472e, { 0xbb, 0xcf, 0xf3, 0xa6, 0x54, 0x10, 0x10, 0xf4 } } + FILE_EXPLORE_FORMSET_GUID }, { END_DEVICE_PATH_TYPE, @@ -78,11 +72,7 @@ HII_VENDOR_DEVICE_PATH mFeHiiVendorDevicePath = { } }; -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 +118,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 +174,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, &gBootMaintFormSetGuid, 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 (&gBootMaintFormSetGuid, 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,347 +286,341 @@ BootMaintCallback ( UINT8 *NewLegacyDev; UINT8 *DisMap; EFI_FORM_ID FormId; - UINTN BufferSize; - if ((Value == NULL) || (ActionRequest == NULL)) { - return EFI_INVALID_PARAMETER; + if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) { + // + // All other action return unsupported. + // + return EFI_UNSUPPORTED; } - - OldValue = 0; - NewValue = 0; - Number = 0; - OldLegacyDev = NULL; - NewLegacyDev = NULL; - NewValuePos = 0; - DisMap = NULL; - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; - - Private = BMM_CALLBACK_DATA_FROM_THIS (This); - UpdatePageId (Private, QuestionId); - + + Status = EFI_SUCCESS; + OldValue = 0; + NewValue = 0; + Number = 0; + OldLegacyDev = NULL; + NewLegacyDev = NULL; + NewValuePos = 0; + DisMap = NULL; + + Private = BMM_CALLBACK_DATA_FROM_THIS (This); // // 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; - } - - // - // need to be subtituded. - // - // Update Select FD/HD/CD/NET/BEV Order Form - // - if (FORM_SET_FD_ORDER_ID == Private->BmmPreviousPageId || - FORM_SET_HD_ORDER_ID == Private->BmmPreviousPageId || - FORM_SET_CD_ORDER_ID == Private->BmmPreviousPageId || - FORM_SET_NET_ORDER_ID == Private->BmmPreviousPageId || - FORM_SET_BEV_ORDER_ID == Private->BmmPreviousPageId || - ((FORM_BOOT_SETUP_ID == Private->BmmPreviousPageId) && - (QuestionId >= LEGACY_FD_QUESTION_ID) && - (QuestionId < (LEGACY_BEV_QUESTION_ID + 100)) ) - ) { - - DisMap = Private->BmmOldFakeNVData.DisableMap; - - FormId = Private->BmmPreviousPageId; - if (FormId == FORM_BOOT_SETUP_ID) { - FormId = Private->BmmCurrentPageId; + HiiGetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap); + if (Action == EFI_BROWSER_ACTION_CHANGING) { + if (Value == NULL) { + return EFI_INVALID_PARAMETER; } + + UpdatePageId (Private, QuestionId); - switch (FormId) { - case FORM_SET_FD_ORDER_ID: - Number = (UINT16) LegacyFDMenu.MenuNumber; - OldLegacyDev = Private->BmmOldFakeNVData.LegacyFD; - NewLegacyDev = CurrentFakeNVMap->LegacyFD; - break; + // + // need to be subtituded. + // + // Update Select FD/HD/CD/NET/BEV Order Form + // + if (FORM_SET_FD_ORDER_ID == Private->BmmPreviousPageId || + FORM_SET_HD_ORDER_ID == Private->BmmPreviousPageId || + FORM_SET_CD_ORDER_ID == Private->BmmPreviousPageId || + FORM_SET_NET_ORDER_ID == Private->BmmPreviousPageId || + FORM_SET_BEV_ORDER_ID == Private->BmmPreviousPageId || + ((FORM_BOOT_SETUP_ID == Private->BmmPreviousPageId) && + (QuestionId >= LEGACY_FD_QUESTION_ID) && + (QuestionId < (LEGACY_BEV_QUESTION_ID + 100)) ) + ) { + + DisMap = Private->BmmOldFakeNVData.DisableMap; + + FormId = Private->BmmPreviousPageId; + if (FormId == FORM_BOOT_SETUP_ID) { + FormId = Private->BmmCurrentPageId; + } - case FORM_SET_HD_ORDER_ID: - Number = (UINT16) LegacyHDMenu.MenuNumber; - OldLegacyDev = Private->BmmOldFakeNVData.LegacyHD; - NewLegacyDev = CurrentFakeNVMap->LegacyHD; - break; + switch (FormId) { + case FORM_SET_FD_ORDER_ID: + Number = (UINT16) LegacyFDMenu.MenuNumber; + OldLegacyDev = Private->BmmOldFakeNVData.LegacyFD; + NewLegacyDev = CurrentFakeNVMap->LegacyFD; + break; - case FORM_SET_CD_ORDER_ID: - Number = (UINT16) LegacyCDMenu.MenuNumber; - OldLegacyDev = Private->BmmOldFakeNVData.LegacyCD; - NewLegacyDev = CurrentFakeNVMap->LegacyCD; - break; + case FORM_SET_HD_ORDER_ID: + Number = (UINT16) LegacyHDMenu.MenuNumber; + OldLegacyDev = Private->BmmOldFakeNVData.LegacyHD; + NewLegacyDev = CurrentFakeNVMap->LegacyHD; + break; - case FORM_SET_NET_ORDER_ID: - Number = (UINT16) LegacyNETMenu.MenuNumber; - OldLegacyDev = Private->BmmOldFakeNVData.LegacyNET; - NewLegacyDev = CurrentFakeNVMap->LegacyNET; - break; + case FORM_SET_CD_ORDER_ID: + Number = (UINT16) LegacyCDMenu.MenuNumber; + OldLegacyDev = Private->BmmOldFakeNVData.LegacyCD; + NewLegacyDev = CurrentFakeNVMap->LegacyCD; + break; - case FORM_SET_BEV_ORDER_ID: - Number = (UINT16) LegacyBEVMenu.MenuNumber; - OldLegacyDev = Private->BmmOldFakeNVData.LegacyBEV; - NewLegacyDev = CurrentFakeNVMap->LegacyBEV; - break; + case FORM_SET_NET_ORDER_ID: + Number = (UINT16) LegacyNETMenu.MenuNumber; + OldLegacyDev = Private->BmmOldFakeNVData.LegacyNET; + NewLegacyDev = CurrentFakeNVMap->LegacyNET; + break; - default: - break; - } - // - // First, find the different position - // if there is change, it should be only one - // - for (Index = 0; Index < Number; Index++) { - if (OldLegacyDev[Index] != NewLegacyDev[Index]) { - OldValue = OldLegacyDev[Index]; - NewValue = NewLegacyDev[Index]; + case FORM_SET_BEV_ORDER_ID: + Number = (UINT16) LegacyBEVMenu.MenuNumber; + OldLegacyDev = Private->BmmOldFakeNVData.LegacyBEV; + NewLegacyDev = CurrentFakeNVMap->LegacyBEV; break; - } - } - if (Index != Number) { + default: + break; + } // - // there is change, now process + // First, find the different position + // if there is change, it should be only one // - if (0xFF == NewValue) { + for (Index = 0; Index < Number; Index++) { + if (OldLegacyDev[Index] != NewLegacyDev[Index]) { + OldValue = OldLegacyDev[Index]; + NewValue = NewLegacyDev[Index]; + break; + } + } + + if (Index != Number) { // - // This item will be disable - // Just move the items behind this forward to overlap it + // there is change, now process // - Pos = OldValue / 8; - Bit = 7 - (OldValue % 8); - DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit)); - for (Index2 = Index; Index2 < Number - 1; Index2++) { - NewLegacyDev[Index2] = NewLegacyDev[Index2 + 1]; - } + if (0xFF == NewValue) { + // + // This item will be disable + // Just move the items behind this forward to overlap it + // + Pos = OldValue / 8; + Bit = 7 - (OldValue % 8); + DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit)); + for (Index2 = Index; Index2 < Number - 1; Index2++) { + NewLegacyDev[Index2] = NewLegacyDev[Index2 + 1]; + } - NewLegacyDev[Index2] = 0xFF; - } else { - for (Index2 = 0; Index2 < Number; Index2++) { - if (Index2 == Index) { - continue; + NewLegacyDev[Index2] = 0xFF; + } else { + for (Index2 = 0; Index2 < Number; Index2++) { + if (Index2 == Index) { + continue; + } + + if (OldLegacyDev[Index2] == NewValue) { + // + // If NewValue is in OldLegacyDev array + // remember its old position + // + NewValuePos = Index2; + break; + } } - if (OldLegacyDev[Index2] == NewValue) { + if (Index2 != Number) { // - // If NewValue is in OldLegacyDev array - // remember its old position + // We will change current item to an existing item + // (It's hard to describe here, please read code, it's like a cycle-moving) // - NewValuePos = Index2; - break; - } - } - - if (Index2 != Number) { - // - // We will change current item to an existing item - // (It's hard to describe here, please read code, it's like a cycle-moving) - // - for (Index2 = NewValuePos; Index2 != Index;) { - if (NewValuePos < Index) { - NewLegacyDev[Index2] = OldLegacyDev[Index2 + 1]; - Index2++; - } else { - NewLegacyDev[Index2] = OldLegacyDev[Index2 - 1]; - Index2--; + for (Index2 = NewValuePos; Index2 != Index;) { + if (NewValuePos < Index) { + NewLegacyDev[Index2] = OldLegacyDev[Index2 + 1]; + Index2++; + } else { + NewLegacyDev[Index2] = OldLegacyDev[Index2 - 1]; + Index2--; + } } - } - } else { - // - // If NewValue is not in OldlegacyDev array, we are changing to a disabled item - // so we should modify DisMap to reflect the change - // - Pos = NewValue / 8; - Bit = 7 - (NewValue % 8); - DisMap[Pos] = (UINT8) (DisMap[Pos] & (~ (UINT8) (1 << Bit))); - if (0xFF != OldValue) { + } else { // - // Because NewValue is a item that was disabled before - // so after changing the OldValue should be disabled - // actually we are doing a swap of enable-disable states of two items + // If NewValue is not in OldlegacyDev array, we are changing to a disabled item + // so we should modify DisMap to reflect the change // - Pos = OldValue / 8; - Bit = 7 - (OldValue % 8); - DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit)); + Pos = NewValue / 8; + Bit = 7 - (NewValue % 8); + DisMap[Pos] = (UINT8) (DisMap[Pos] & (~ (UINT8) (1 << Bit))); + if (0xFF != OldValue) { + // + // Because NewValue is a item that was disabled before + // so after changing the OldValue should be disabled + // actually we are doing a swap of enable-disable states of two items + // + Pos = OldValue / 8; + Bit = 7 - (OldValue % 8); + DisMap[Pos] = (UINT8) (DisMap[Pos] | (UINT8) (1 << Bit)); + } } } - } - // - // To prevent DISABLE appears in the middle of the list - // we should perform a re-ordering - // - Index = 0; - while (Index < Number) { - if (0xFF != NewLegacyDev[Index]) { - Index++; - continue; - } - - Index2 = Index; - Index2++; - while (Index2 < Number) { - if (0xFF != NewLegacyDev[Index2]) { - break; + // + // To prevent DISABLE appears in the middle of the list + // we should perform a re-ordering + // + Index = 0; + while (Index < Number) { + if (0xFF != NewLegacyDev[Index]) { + Index++; + continue; } + Index2 = Index; Index2++; - } + while (Index2 < Number) { + if (0xFF != NewLegacyDev[Index2]) { + break; + } + + Index2++; + } + + if (Index2 < Number) { + NewLegacyDev[Index] = NewLegacyDev[Index2]; + NewLegacyDev[Index2] = 0xFF; + } - if (Index2 < Number) { - NewLegacyDev[Index] = NewLegacyDev[Index2]; - NewLegacyDev[Index2] = 0xFF; + Index++; } - Index++; + CopyMem ( + OldLegacyDev, + NewLegacyDev, + Number + ); } - - CopyMem ( - OldLegacyDev, - NewLegacyDev, - Number - ); } - } - - if (QuestionId < FILE_OPTION_OFFSET) { - if (QuestionId < CONFIG_OPTION_OFFSET) { - switch (QuestionId) { - case KEY_VALUE_BOOT_FROM_FILE: - Private->FeCurrentState = BOOT_FROM_FILE_STATE; - - // - // Exit Bmm main formset to send File Explorer formset. - // - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - break; - - case FORM_BOOT_ADD_ID: - Private->FeCurrentState = ADD_BOOT_OPTION_STATE; - - // - // Exit Bmm main formset to send File Explorer formset. - // - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - break; - - case FORM_DRV_ADD_FILE_ID: - Private->FeCurrentState = ADD_DRIVER_OPTION_STATE; - - // - // Exit Bmm main formset to send File Explorer formset. - // - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - break; - case FORM_DRV_ADD_HANDLE_ID: - CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private); - UpdateDrvAddHandlePage (Private); - break; - - case FORM_BOOT_DEL_ID: - CleanUpPage (FORM_BOOT_DEL_ID, Private); - UpdateBootDelPage (Private); - break; - - case FORM_BOOT_CHG_ID: - case FORM_DRV_CHG_ID: - UpdatePageBody (QuestionId, Private); - break; - - case FORM_DRV_DEL_ID: - CleanUpPage (FORM_DRV_DEL_ID, Private); - UpdateDrvDelPage (Private); - break; - - case FORM_BOOT_NEXT_ID: - CleanUpPage (FORM_BOOT_NEXT_ID, Private); - UpdateBootNextPage (Private); - break; - - case FORM_TIME_OUT_ID: - CleanUpPage (FORM_TIME_OUT_ID, Private); - UpdateTimeOutPage (Private); - break; - - case FORM_RESET: - gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); - return EFI_UNSUPPORTED; + if (QuestionId < FILE_OPTION_OFFSET) { + if (QuestionId < CONFIG_OPTION_OFFSET) { + switch (QuestionId) { + case KEY_VALUE_BOOT_FROM_FILE: + Private->FeCurrentState = FileExplorerStateBootFromFile; + break; + + case FORM_BOOT_ADD_ID: + Private->FeCurrentState = FileExplorerStateAddBootOption; + break; + + case FORM_DRV_ADD_FILE_ID: + Private->FeCurrentState = FileExplorerStateAddDriverOptionState; + break; + + case FORM_DRV_ADD_HANDLE_ID: + CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private); + UpdateDrvAddHandlePage (Private); + break; + + case FORM_BOOT_DEL_ID: + CleanUpPage (FORM_BOOT_DEL_ID, Private); + UpdateBootDelPage (Private); + break; + + case FORM_BOOT_CHG_ID: + case FORM_DRV_CHG_ID: + UpdatePageBody (QuestionId, Private); + break; + + case FORM_DRV_DEL_ID: + CleanUpPage (FORM_DRV_DEL_ID, Private); + UpdateDrvDelPage (Private); + break; + + case FORM_BOOT_NEXT_ID: + CleanUpPage (FORM_BOOT_NEXT_ID, Private); + UpdateBootNextPage (Private); + break; + + case FORM_TIME_OUT_ID: + CleanUpPage (FORM_TIME_OUT_ID, Private); + UpdateTimeOutPage (Private); + break; + + case FORM_CON_IN_ID: + case FORM_CON_OUT_ID: + case FORM_CON_ERR_ID: + UpdatePageBody (QuestionId, Private); + break; + + case FORM_CON_MODE_ID: + CleanUpPage (FORM_CON_MODE_ID, Private); + UpdateConModePage (Private); + break; + + case FORM_CON_COM_ID: + CleanUpPage (FORM_CON_COM_ID, Private); + UpdateConCOMPage (Private); + break; + + case FORM_SET_FD_ORDER_ID: + case FORM_SET_HD_ORDER_ID: + case FORM_SET_CD_ORDER_ID: + case FORM_SET_NET_ORDER_ID: + case FORM_SET_BEV_ORDER_ID: + CleanUpPage (QuestionId, Private); + UpdateSetLegacyDeviceOrderPage (QuestionId, Private); + break; + + default: + break; + } + } else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) { + Index2 = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET); + Private->CurrentTerminal = Index2; - case FORM_CON_IN_ID: - case FORM_CON_OUT_ID: - case FORM_CON_ERR_ID: - UpdatePageBody (QuestionId, Private); - break; + CleanUpPage (FORM_CON_COM_SETUP_ID, Private); + UpdateTerminalPage (Private); - case FORM_CON_MODE_ID: - CleanUpPage (FORM_CON_MODE_ID, Private); - UpdateConModePage (Private); - break; + } else if (QuestionId >= HANDLE_OPTION_OFFSET) { + Index2 = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET); - case FORM_CON_COM_ID: - CleanUpPage (FORM_CON_COM_ID, Private); - UpdateConCOMPage (Private); - break; + NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index2); + ASSERT (NewMenuEntry != NULL); + Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext; - case FORM_SET_FD_ORDER_ID: - case FORM_SET_HD_ORDER_ID: - case FORM_SET_CD_ORDER_ID: - case FORM_SET_NET_ORDER_ID: - case FORM_SET_BEV_ORDER_ID: - CleanUpPage (QuestionId, Private); - UpdateSetLegacyDeviceOrderPage (QuestionId, Private); - break; + CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private); - case KEY_VALUE_SAVE_AND_EXIT: - case KEY_VALUE_NO_SAVE_AND_EXIT: + Private->MenuEntry = NewMenuEntry; + Private->LoadContext->FilePathList = Private->HandleContext->DevicePath; - if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) { - Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId); - if (EFI_ERROR (Status)) { - return Status; - } - } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) { - DiscardChangeHandler (Private, CurrentFakeNVMap); + UpdateDriverAddHandleDescPage (Private); + } + } + } else if (Action == EFI_BROWSER_ACTION_CHANGED) { + if ((Value == NULL) || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (QuestionId) { + case KEY_VALUE_SAVE_AND_EXIT: + case KEY_VALUE_NO_SAVE_AND_EXIT: + if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) { + Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId); + if (EFI_ERROR (Status)) { + return Status; } - - // - // Tell browser not to ask for confirmation of changes, - // since we have already applied or discarded. - // - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - break; - - default: - break; + } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) { + DiscardChangeHandler (Private, CurrentFakeNVMap); } - } else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) { - Index2 = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET); - Private->CurrentTerminal = Index2; - - CleanUpPage (FORM_CON_COM_SETUP_ID, Private); - UpdateTerminalPage (Private); - - } else if (QuestionId >= HANDLE_OPTION_OFFSET) { - Index2 = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET); - - NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index2); - ASSERT (NewMenuEntry != NULL); - Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext; - CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private); + // + // Tell browser not to ask for confirmation of changes, + // since we have already applied or discarded. + // + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; + break; - Private->MenuEntry = NewMenuEntry; - Private->LoadContext->FilePathList = Private->HandleContext->DevicePath; + case FORM_RESET: + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + return EFI_UNSUPPORTED; - UpdateDriverAddHandleDescPage (Private); + default: + break; } } // // Pass changed uncommitted data back to Form Browser // - BufferSize = sizeof (BMM_FAKE_NV_DATA); - Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) CurrentFakeNVMap, NULL); - - return Status; + HiiSetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL); + return EFI_SUCCESS; } /** @@ -629,22 +660,24 @@ 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->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])))); + Index ++) { NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index); NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; - NewLoadContext->Deleted = CurrentFakeNVMap->BootOptionDel[Index]; + NewLoadContext->Deleted = CurrentFakeNVMap->OptionDel[Index]; } Var_DelBootOption (); 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->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])))); + Index++) { NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index); NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; - NewLoadContext->Deleted = CurrentFakeNVMap->DriverOptionDel[Index]; + NewLoadContext->Deleted = CurrentFakeNVMap->OptionDel[Index]; } Var_DelDriverOption (); @@ -692,9 +725,10 @@ ApplyChangeHandler ( ASSERT (CurrentFakeNVMap->COMParity < (sizeof (ParityList) / sizeof (ParityList[0]))); NewTerminalContext->Parity = (UINT8) ParityList[CurrentFakeNVMap->COMParity].Value; NewTerminalContext->TerminalType = CurrentFakeNVMap->COMTerminalType; + NewTerminalContext->FlowControl = CurrentFakeNVMap->COMFlowControl; ChangeTerminalDevicePath ( - NewTerminalContext->DevicePath, + &(NewTerminalContext->DevicePath), FALSE ); @@ -704,16 +738,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 +756,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 +774,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]; } @@ -797,20 +834,20 @@ DiscardChangeHandler ( switch (Private->BmmPreviousPageId) { case FORM_BOOT_CHG_ID: case FORM_DRV_CHG_ID: - CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, 100); + CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, sizeof (CurrentFakeNVMap->OptionOrder)); break; case FORM_BOOT_DEL_ID: - ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (CurrentFakeNVMap->BootOptionDel[0]))); + ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0]))); for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) { - CurrentFakeNVMap->BootOptionDel[Index] = 0x00; + CurrentFakeNVMap->OptionDel[Index] = FALSE; } break; case FORM_DRV_DEL_ID: - ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (CurrentFakeNVMap->DriverOptionDel[0]))); + ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0]))); for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) { - CurrentFakeNVMap->DriverOptionDel[Index] = 0x00; + CurrentFakeNVMap->OptionDel[Index] = FALSE; } break; @@ -848,7 +885,6 @@ InitializeBM ( ) { EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; BMM_CALLBACK_DATA *BmmCallbackInfo; EFI_STATUS Status; UINT8 *Ptr; @@ -895,8 +931,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 +965,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 ( + &gBootMaintFormSetGuid, + 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 ( + &gFileExploreFormSetGuid, + 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 +1039,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, + &gBootMaintFormSetGuid, FORM_BOOT_SETUP_ID, - FORM_BOOT_LEGACY_DEVICE_ID, - FALSE, - &gUpdateData + mStartOpCodeHandle, // Label FORM_BOOT_LEGACY_DEVICE_ID + mEndOpCodeHandle // LABEL_END ); } @@ -1057,17 +1107,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 +1197,7 @@ FreeAllMenu ( } /** - Intialize all the string depositories. + Initialize all the string depositories. **/ VOID @@ -1192,7 +1247,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 +1382,7 @@ FormSetDispatcher ( gFormBrowser2, &CallbackData->BmmHiiHandle, 1, - NULL, + &gBootMaintFormSetGuid, 0, NULL, &ActionRequest @@ -1341,7 +1396,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 +1404,7 @@ FormSetDispatcher ( gFormBrowser2, &CallbackData->FeHiiHandle, 1, - NULL, + &gFileExploreFormSetGuid, 0, NULL, &ActionRequest @@ -1358,8 +1413,8 @@ FormSetDispatcher ( EnableResetRequired (); } - CallbackData->FeCurrentState = INACTIVE_STATE; - CallbackData->FeDisplayContext = UNKNOWN_CONTEXT; + CallbackData->FeCurrentState = FileExplorerStateInActive; + CallbackData->FeDisplayContext = FileExplorerDisplayUnknown; ReclaimStringDepository (); } else { break; @@ -1378,9 +1433,9 @@ 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