/** @file
The functions for Boot Maintainence Main menu.
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "BootMaint.h"
#include "FormGuid.h"
#include "Bds.h"
#include "FrontPage.h"
{
{
0
}
}
};
{
{
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
}
},
},
{
{
}
}
};
{
{
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
}
},
},
{
{
}
}
};
/**
Init all memu.
@param CallbackData The BMM context data.
**/
);
/**
Free up all Menu Option list.
**/
);
/**
Create string tokens for a menu from its help strings and display strings
@param CallbackData The BMM context data.
@param HiiHandle Hii Handle of the package to be updated.
@param MenuOption The Menu whose string tokens need to be created
@retval EFI_SUCCESS String tokens created successfully
@retval others contain some errors
**/
)
{
0,
);
} else {
0,
);
}
}
return EFI_SUCCESS;
}
/**
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Request A null-terminated Unicode string in <ConfigRequest> format.
@param Progress On return, points to a character in the Request string.
Points to the string's null terminator if request was successful.
pair (or the beginning of the string if the failure is in the
@param Results A null-terminated Unicode string in <ConfigAltResp> format which
has all values filled in for the names in the Request string.
String to be allocated by the called function.
@retval EFI_SUCCESS The Results is filled with the requested values.
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
@retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gBootMaintFormSetGuid, mBootMaintStorageName)) {
return EFI_NOT_FOUND;
}
Size = 0;
//
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
//
BufferSize = sizeof (BMM_FAKE_NV_DATA);
//
// Request has no request element, construct full request string.
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (&gBootMaintFormSetGuid, mBootMaintStorageName, Private->BmmDriverHandle);
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
}
);
//
// Free the allocated config request string.
//
if (AllocatedRequest) {
}
//
// Set Progress string to the original request string.
//
}
return Status;
}
/**
This function processes the results of changes in configuration.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser.
@param QuestionId A unique value which is sent to the original exporting driver
so that it can identify the type of data to expect.
@param Type The type of value for the question.
@param Value A pointer to the data being sent to the original exporting driver.
@param ActionRequest On return, points to the action requested by the callback function.
@retval EFI_SUCCESS The callback successfully handled the action.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be saved.
@retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
@retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
**/
)
{
//
// All other action return unsupported.
//
return EFI_UNSUPPORTED;
}
OldValue = 0;
NewValue = 0;
Number = 0;
OldLegacyDev = NULL;
NewLegacyDev = NULL;
NewValuePos = 0;
//
// Retrive uncommitted data from Form Browser
//
HiiGetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
return EFI_INVALID_PARAMETER;
}
//
// need to be subtituded.
//
//
if ((QuestionId >= LEGACY_FD_QUESTION_ID) && (QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER)) {
} else if (QuestionId >= LEGACY_HD_QUESTION_ID && QuestionId < LEGACY_HD_QUESTION_ID + MAX_MENU_NUMBER) {
} else if (QuestionId >= LEGACY_CD_QUESTION_ID && QuestionId < LEGACY_CD_QUESTION_ID + MAX_MENU_NUMBER) {
} else if (QuestionId >= LEGACY_NET_QUESTION_ID && QuestionId < LEGACY_NET_QUESTION_ID + MAX_MENU_NUMBER) {
} else if (QuestionId >= LEGACY_BEV_QUESTION_ID && QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER) {
}
//
// First, find the different position
// if there is change, it should be only one
//
break;
}
}
//
// there is change, now process
//
if (0xFF == NewValue) {
//
// This item will be disable
// Just move the items behind this forward to overlap it
//
}
} else {
continue;
}
//
// If NewValue is in OldLegacyDev array
// remember its old position
//
break;
}
}
//
// We will change current item to an existing item
// (It's hard to describe here, please read code, it's like a cycle-moving)
//
if (NewValuePos < Index) {
Index2++;
} else {
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
//
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
//
}
}
}
//
// To prevent DISABLE appears in the middle of the list
// we should perform a re-ordering
//
Index = 0;
Index++;
continue;
}
Index2++;
break;
}
Index2++;
}
}
Index++;
}
CopyMem (
);
//
// Return correct question value.
//
}
}
if (QuestionId < FILE_OPTION_OFFSET) {
if (QuestionId < CONFIG_OPTION_OFFSET) {
switch (QuestionId) {
case KEY_VALUE_BOOT_FROM_FILE:
break;
case FORM_BOOT_ADD_ID:
break;
case FORM_DRV_ADD_FILE_ID:
break;
case FORM_DRV_ADD_HANDLE_ID:
break;
case FORM_BOOT_DEL_ID:
break;
case FORM_BOOT_CHG_ID:
case FORM_DRV_CHG_ID:
break;
case FORM_DRV_DEL_ID:
break;
case FORM_BOOT_NEXT_ID:
break;
case FORM_TIME_OUT_ID:
break;
case FORM_CON_IN_ID:
case FORM_CON_OUT_ID:
case FORM_CON_ERR_ID:
break;
case FORM_CON_MODE_ID:
break;
case FORM_CON_COM_ID:
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:
break;
default:
break;
}
} else if (QuestionId >= HANDLE_OPTION_OFFSET) {
}
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
return EFI_INVALID_PARAMETER;
}
switch (QuestionId) {
case KEY_VALUE_SAVE_AND_EXIT:
if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
return Status;
}
} else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
}
//
// Tell browser not to ask for confirmation of changes,
// since we have already applied or discarded.
//
break;
case FORM_RESET:
return EFI_UNSUPPORTED;
default:
break;
}
}
//
// Pass changed uncommitted data back to Form Browser
//
HiiSetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);
return EFI_SUCCESS;
}
/**
Function handling request to apply changes for BMM pages.
@param Private Pointer to callback data buffer.
@param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
@param FormId ID of the form which has sent the request to apply change.
@retval EFI_SUCCESS Change successfully applied.
@retval Other Error occurs while trying to apply changes.
**/
)
{
switch (FormId) {
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:
break;
case FORM_BOOT_DEL_ID:
for (Index = 0;
((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0]))));
Index ++) {
}
break;
case FORM_DRV_DEL_ID:
for (Index = 0;
((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0]))));
Index++) {
}
break;
case FORM_BOOT_CHG_ID:
break;
case FORM_DRV_CHG_ID:
break;
case FORM_TIME_OUT_ID:
break;
case FORM_BOOT_NEXT_ID:
break;
case FORM_CON_MODE_ID:
break;
case FORM_CON_COM_SETUP_ID:
);
break;
case FORM_CON_IN_ID:
}
}
break;
case FORM_CON_OUT_ID:
}
}
break;
case FORM_CON_ERR_ID:
}
}
break;
);
goto Error;
}
break;
default:
break;
}
return Status;
}
/**
Discard all changes done to the BMM pages such as Boot Order change,
Driver order change.
@param Private The BMM context data.
@param CurrentFakeNVMap The current Fack NV Map.
**/
)
{
switch (Private->BmmPreviousPageId) {
case FORM_BOOT_CHG_ID:
case FORM_DRV_CHG_ID:
CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, sizeof (CurrentFakeNVMap->OptionOrder));
break;
case FORM_BOOT_DEL_ID:
ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])));
}
break;
case FORM_DRV_DEL_ID:
ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])));
}
break;
case FORM_BOOT_NEXT_ID:
break;
case FORM_TIME_OUT_ID:
break;
case FORM_DRV_ADD_FILE_ID:
case FORM_DRV_ADD_HANDLE_ID:
break;
default:
break;
}
}
/**
Initialize the Boot Maintenance Utitliy.
@retval EFI_SUCCESS utility ended successfully
@retval others contain some errors
**/
)
{
//
// Create CallbackData structures for Driver Callback
//
if (BmmCallbackInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Create LoadOption in BmmCallbackInfo for Driver Callback
//
Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY));
return EFI_OUT_OF_RESOURCES;
}
//
// Initialize Bmm callback data.
//
Ptr += sizeof (BM_LOAD_CONTEXT);
Ptr += sizeof (BM_FILE_CONTEXT);
Ptr += sizeof (BM_HANDLE_CONTEXT);
//
// Install Device Path Protocol and Config Access protocol to driver handle
//
);
goto Exit;
}
//
// Install Device Path Protocol and Config Access protocol to driver handle
//
);
goto Exit;
}
//
// Post our Boot Maint VFR binary to the HII database.
//
);
//
// Post our File Explorer VFR binary to the HII database.
//
);
//
// Init OpCode Handle and Allocate space for creation of Buffer
//
if (mStartOpCodeHandle == NULL) {
goto Exit;
}
if (mEndOpCodeHandle == NULL) {
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));
//
// Create Hii Extend Label OpCode as the end opcode
//
mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
if (TerminalMenu.MenuNumber > 0) {
}
//
// If LegacyBios Protocol is installed, add 3 tags about legacy boot option
//
);
);
);
);
);
mStartOpCodeHandle, // Label FORM_BOOT_LEGACY_DEVICE_ID
mEndOpCodeHandle // LABEL_END
);
}
//
// Dispatch BMM main formset and File Explorer formset.
//
//
// Remove our IFR data from HII database
//
FreeAllMenu ();
Exit:
if (mStartOpCodeHandle != NULL) {
}
if (mEndOpCodeHandle != NULL) {
}
);
}
);
}
return Status;
}
/**
Initialized all Menu Option List.
@param CallbackData The BMM context data.
**/
)
{
BOpt_FindDrivers ();
LocateSerialIo ();
GetAllConsoles ();
}
/**
Free up all Menu Option list.
**/
)
{
FreeAllConsoles ();
}
/**
Initialize all the string depositories.
**/
)
{
}
/**
Fetch a usable string node from the string depository and return the string token.
@param CallbackData The BMM context data.
@param StringDepository The string repository.
@retval EFI_STRING_ID String token.
**/
)
{
//
// Fetch one reclaimed node from the list.
//
} else {
//
// If there is no usable node in the list, update the list.
//
if (NULL == CurrentListNode) {
} else {
}
}
}
/**
Reclaim string depositories by moving the current node pointer to list head..
**/
)
{
}
}
/**
Release resource for all the string depositories.
**/
)
{
//
// Release string list nodes.
//
}
}
//
// Release string depository.
//
}
/**
Start boot maintenance manager
@retval EFI_SUCCESS If BMM is invoked successfully.
@return Other value if BMM return unsuccessfully.
**/
)
{
//
// Connect all prior to entering the platform setup menu.
//
if (!gConnectAllHappened) {
}
//
// Have chance to enumerate boot device
//
//
// Init the BMM
//
Status = InitializeBM ();
return Status;
}
/**
Dispatch BMM formset and FileExplorer formset.
@param CallbackData The BMM context data.
@retval EFI_SUCCESS If function complete successfully.
@return Other value if the Setup Browser process BMM's pages and
return unsuccessfully.
**/
)
{
while (TRUE) {
1,
0,
NULL,
);
}
//
// When this Formset returns, check if we are going to explore files.
//
1,
0,
NULL,
);
}
} else {
break;
}
}
return Status;
}
/**
Deletete the Boot Option from EFI Variable. The Boot Order Arrray
is also updated.
@param OptionNumber The number of Boot option want to be deleted.
@param BootOrder The Boot Order array.
@param BootOrderSize The size of the Boot Order Array.
@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
**/
)
{
Index2Del = 0;
//
// adjust boot order array
//
break;
}
}
}
}
*BootOrderSize -= sizeof (UINT16);
}
return Status;
}