MdeModulePkg:Create Boot Maintenance Manager Library

Split the boot maintenance manager library from UiApp in MdeModulePkg/Application
and put the library in MdeModulePkg/Library.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18923 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Dandan Bi 2015-11-23 09:34:55 +00:00 committed by dandanbi
parent 32465d9ae7
commit 4af04335ac
12 changed files with 8468 additions and 0 deletions

View File

@ -0,0 +1,89 @@
/** @file
Utility routines used by boot maintenance modules.
Copyright (c) 2004 - 2015, 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
http://opensource.org/licenses/bsd-license.php
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 "BootMaintenanceManager.h"
/**
Function deletes the variable specified by VarName and VarGuid.
@param VarName A Null-terminated Unicode string that is
the name of the vendor's variable.
@param VarGuid A unique identifier for the vendor.
@retval EFI_SUCCESS The variable was found and removed
@retval EFI_UNSUPPORTED The variable store was inaccessible
@retval EFI_NOT_FOUND The variable was not found
**/
EFI_STATUS
EfiLibDeleteVariable (
IN CHAR16 *VarName,
IN EFI_GUID *VarGuid
)
{
return gRT->SetVariable (
VarName,
VarGuid,
0,
0,
NULL
);
}
/**
Function is used to determine the number of device path instances
that exist in a device path.
@param DevicePath A pointer to a device path data structure.
@return This function counts and returns the number of device path instances
in DevicePath.
**/
UINTN
EfiDevicePathInstanceCount (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
UINTN Count;
UINTN Size;
Count = 0;
while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) {
Count += 1;
}
return Count;
}
/**
Get a string from the Data Hub record based on
a device path.
@param DevPath The device Path.
@return A string located from the Data Hub records based on
the device path.
@retval NULL If failed to get the String from Data Hub.
**/
UINT16 *
EfiLibStrFromDatahub (
IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
return NULL;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,440 @@
///** @file
// Boot Maintenance Utility Formset
//
// Copyright (c) 2004 - 2015, 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
// http://opensource.org/licenses/bsd-license.php
//
// 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 "FormGuid.h"
formset
guid = BOOT_MAINT_FORMSET_GUID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE),
help = STRING_TOKEN(STR_BOOT_MAINT_MANAGER_HELP),
classguid = gEfiIfrFrontPageGuid,
varstore BMM_FAKE_NV_DATA,
varid = VARSTORE_ID_BOOT_MAINT,
name = BmmData,
guid = BOOT_MAINT_FORMSET_GUID;
form formid = FORM_MAIN_ID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE);
goto FORM_BOOT_SETUP_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_SETUP_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_SETUP_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_DRIVER_SETUP_ID,
prompt = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE),
help = STRING_TOKEN(STR_FORM_DRIVER_SETUP_HELP),
flags = INTERACTIVE,
key = FORM_DRIVER_SETUP_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_CON_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE),
help = STRING_TOKEN(STR_FORM_CON_MAIN_HELP),
flags = INTERACTIVE,
key = FORM_CON_MAIN_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_BOOT_FROM_FILE),
help = STRING_TOKEN(STR_BOOT_FROM_FILE_HELP),
flags = INTERACTIVE,
key = KEY_VALUE_BOOT_FROM_FILE;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
// label FORM_MAIN_ID;
goto FORM_BOOT_NEXT_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_NEXT_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_NEXT_ID;
goto FORM_TIME_OUT_ID,
prompt = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE),
help = STRING_TOKEN(STR_FORM_TIME_OUT_HELP),
flags = INTERACTIVE,
key = FORM_TIME_OUT_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
text
help = STRING_TOKEN(STR_RESET),
text = STRING_TOKEN(STR_RESET),
flags = INTERACTIVE,
key = FORM_RESET;
label LABEL_BMM_PLATFORM_INFORMATION;
//
// This is where we will dynamically add a Action type op-code to show
// the platform information.
//
//
// This is where we will dynamically add a Action type op-code to show
// the advanced menu.
//
//
// This is where we will dynamically add a Action type op-code to show
// the intel test menu.
//
label LABEL_END;
endform;
form formid = FORM_BOOT_SETUP_ID,
title = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_BOOT_SETUP_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_ADD_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_ADD_ID;
goto FORM_BOOT_DEL_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_DEL_ID;
goto FORM_BOOT_CHG_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_CHG_ID;
endform;
form formid = FORM_DRIVER_SETUP_ID,
title = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//help = STRING_TOKEN(STR_FORM_GOTO_MAIN),
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_DRV_ADD_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE),
help = STRING_TOKEN(STR_FORM_DRV_ADD_HELP),
flags = INTERACTIVE,
key = FORM_DRV_ADD_ID;
goto FORM_DRV_DEL_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE),
help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),
flags = INTERACTIVE,
key = FORM_DRV_DEL_ID;
goto FORM_DRV_CHG_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),
help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),
flags = INTERACTIVE,
key = FORM_DRV_CHG_ID;
endform;
form formid = FORM_BOOT_ADD_ID,
title = STRING_TOKEN(STR_FORM_BOOT_ADD_DESC_TITLE);
label FORM_BOOT_ADD_ID;
label LABEL_END;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
string varid = BmmData.BootDescriptionData,
questionid = KEY_VALUE_BOOT_DESCRIPTION,
prompt = STRING_TOKEN(STR_LOAD_OPTION_DESC),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
minsize = 6,
maxsize = 75,
endstring;
string varid = BmmData.BootOptionalData,
questionid = KEY_VALUE_BOOT_OPTION,
prompt = STRING_TOKEN(STR_OPTIONAL_DATA),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
minsize = 0,
maxsize = 120,
endstring;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
text
help = STRING_TOKEN(STR_SAVE_AND_EXIT),
text = STRING_TOKEN(STR_SAVE_AND_EXIT),
flags = INTERACTIVE,
key = KEY_VALUE_SAVE_AND_EXIT_BOOT;
text
help = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
text = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
flags = INTERACTIVE,
key = KEY_VALUE_NO_SAVE_AND_EXIT_BOOT;
endform;
form formid = FORM_BOOT_DEL_ID,
title = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE);
label FORM_BOOT_DEL_ID;
label LABEL_END;
endform;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_BOOT_NEXT_ID,
title = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE);
label FORM_BOOT_NEXT_ID;
label LABEL_END;
endform;
form formid = FORM_TIME_OUT_ID,
title = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE);
label FORM_TIME_OUT_ID;
label LABEL_END;
endform;
form formid = FORM_MEMORY_CHECK_ID,
title = STRING_TOKEN(STR_FORM_MEMORY_CHECK_TITLE);
label FORM_MEMORY_CHECK_ID;
label LABEL_END;
endform;
form formid = FORM_UEFI_OPTIMIZED_BOOT_ID,
title = STRING_TOKEN(STR_FORM_UEFI_OPTIMIZED_BOOT_TITLE);
label FORM_UEFI_OPTIMIZED_BOOT_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_DRIVER_SETUP_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),
help = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),
flags = INTERACTIVE,
key = FORM_DRV_ADD_FILE_ID;
endform;
form formid = FORM_DRV_ADD_FILE_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);
label FORM_DRV_ADD_FILE_ID;
label LABEL_END;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
string varid = BmmData.DriverDescriptionData,
questionid = KEY_VALUE_DRIVER_DESCRIPTION,
prompt = STRING_TOKEN(STR_LOAD_OPTION_DESC),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
minsize = 6,
maxsize = 75,
endstring;
string varid = BmmData.DriverOptionalData,
questionid = KEY_VALUE_DRIVER_OPTION,
prompt = STRING_TOKEN(STR_OPTIONAL_DATA),
help = STRING_TOKEN(STR_NULL_STRING),
flags = INTERACTIVE,
minsize = 0,
maxsize = 120,
endstring;
checkbox varid = BmmData.ForceReconnect,
prompt = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),
help = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),
flags = CHECKBOX_DEFAULT,
key = 0,
endcheckbox;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
text
help = STRING_TOKEN(STR_SAVE_AND_EXIT),
text = STRING_TOKEN(STR_SAVE_AND_EXIT),
flags = INTERACTIVE,
key = KEY_VALUE_SAVE_AND_EXIT_DRIVER; //BUGBUB: allow duplicate key in one formset???
text
help = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
text = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),
flags = INTERACTIVE,
key = KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER;
endform;
form formid = FORM_DRV_DEL_ID,
title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE);
label FORM_DRV_DEL_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_CHG_ID,
title = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE);
label FORM_DRV_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_CON_MAIN_ID,
title = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_CON_IN_ID,
prompt = STRING_TOKEN(STR_FORM_CON_IN_TITLE),
help = STRING_TOKEN(STR_FORM_CON_IN_HELP),
flags = INTERACTIVE,
key = FORM_CON_IN_ID;
goto FORM_CON_OUT_ID,
prompt = STRING_TOKEN(STR_FORM_CON_OUT_TITLE),
help = STRING_TOKEN(STR_FORM_CON_OUT_HELP),
flags = INTERACTIVE,
key = FORM_CON_OUT_ID;
goto FORM_CON_ERR_ID,
prompt = STRING_TOKEN(STR_FORM_STD_ERR_TITLE),
help = STRING_TOKEN(STR_FORM_STD_ERR_HELP),
flags = INTERACTIVE,
key = FORM_CON_ERR_ID;
goto FORM_CON_MODE_ID,
prompt = STRING_TOKEN(STR_FORM_MODE_TITLE),
help = STRING_TOKEN(STR_FORM_MODE_HELP),
flags = INTERACTIVE,
key = FORM_CON_MODE_ID;
goto FORM_CON_COM_ID,
prompt = STRING_TOKEN(STR_FORM_COM_TITLE),
help = STRING_TOKEN(STR_FORM_COM_HELP),
flags = INTERACTIVE,
key = FORM_CON_COM_ID;
endform;
form formid = FORM_CON_MODE_ID,
title = STRING_TOKEN(STR_FORM_MODE_TITLE);
label FORM_CON_MODE_ID;
label LABEL_END;
endform;
form formid = FORM_CON_COM_ID,
title = STRING_TOKEN(STR_FORM_COM_TITLE);
label FORM_CON_COM_ID;
label LABEL_END;
endform;
form formid = FORM_CON_COM_SETUP_ID,
title = STRING_TOKEN(STR_CON_COM_SETUP);
label FORM_CON_COM_SETUP_ID;
label LABEL_END;
endform;
form formid = FORM_FILE_SEEK_ID,
title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);
label FORM_FILE_SEEK_ID;
label LABEL_END;
endform;
form formid = FORM_FILE_NEW_SEEK_ID,
title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);
label FORM_FILE_NEW_SEEK_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_HANDLE_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_HANDLE_TITLE);
label FORM_DRV_ADD_HANDLE_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_HANDLE_DESC_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);
label FORM_DRV_ADD_HANDLE_DESC_ID;
label LABEL_END;
endform;
form formid = FORM_CON_IN_ID,
title = STRING_TOKEN(STR_FORM_CON_IN_TITLE);
label FORM_CON_IN_ID;
label LABEL_END;
endform;
form formid = FORM_CON_OUT_ID,
title = STRING_TOKEN(STR_FORM_CON_OUT_TITLE);
label FORM_CON_OUT_ID;
label LABEL_END;
endform;
form formid = FORM_CON_ERR_ID,
title = STRING_TOKEN(STR_FORM_STD_ERR_TITLE);
label FORM_CON_ERR_ID;
label LABEL_END;
endform;
endformset;

View File

@ -0,0 +1,100 @@
## @file
# Boot Maintenance Manager Library used by UiApp.
#
# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
# This software and associated documentation (if any) is furnished
# under a license and may only be used or copied in accordance
# with the terms of the license. Except as permitted by such
# license, no part of this software or documentation may be
# reproduced, stored in a retrieval system, or transmitted in any
# form or by any means without the express written consent of
# Intel Corporation.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BootMaintenanceManagerLib
FILE_GUID = CA9E4824-4198-4715-AA22-E2935E703A07
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = NULL|DXE_DRIVER UEFI_APPLICATION
CONSTRUCTOR = BootMaintenanceManagerLibConstructor
DESTRUCTOR = BootMaintenanceManagerLibDestructor
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
BootMaintenanceManager.h
BootMaintenanceManager.vfr
BootMaintenanceManagerStrings.uni
BootMaintenance.c
FormGuid.h
BootOption.c
ConsoleOption.c
Data.c
Variable.c
UpdatePage.c
BmLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
DevicePathLib
BaseLib
UefiRuntimeServicesTableLib
MemoryAllocationLib
UefiLib
UefiBootServicesTableLib
BaseMemoryLib
DebugLib
PrintLib
HiiLib
UefiHiiServicesLib
UefiBootManagerLib
FileExplorerLib
[Guids]
gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"BootNext" (The number of next boot option)
## SOMETIMES_PRODUCES ## Variable:L"BootXX" (Boot option variable)
## SOMETIMES_PRODUCES ## Variable:L"PlatformLang" (Platform supported languange in Rfc4646 format)
## SOMETIMES_PRODUCES ## Variable:L"Lang" (Platform supported languange in Iso639 format)
## SOMETIMES_PRODUCES ## Variable:L"KeyXX" (Hotkey option variable)
## PRODUCES ## Variable:L"HwErrRecSupport" (The level of platform supported hardware Error Record Persistence)
## SOMETIMES_PRODUCES ## Variable:L"BootOptionSupport" (The feature supported in boot option menu, value could be: EFI_BOOT_OPTION_SUPPORT_KEY, EFI_BOOT_OPTION_SUPPORT_APP
## SOMETIMES_PRODUCES (not PcdUefiVariableDefaultLangDeprecate)## Variable:L"LangCodes" (Value of PcdUefiVariableDefaultLangCodes)
## PRODUCES ## Variable:L"PlatformLangCodes" (Value of PcdUefiVariableDefaultPlatformLangCodes)
## PRODUCES ## Variable:L"Timeout" (The time out value in second of showing progress bar)
## SOMETIMES_PRODUCES ## Variable:L"BootOrder" (The boot option array)
## SOMETIMES_PRODUCES ## Variable:L"DriverOrder" (The driver order list)
## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device)
## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device)
## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device)
gEfiFileSystemVolumeLabelInfoIdGuid ## CONSUMES ## GUID (Indicate the information type is volume)
gEfiFileInfoGuid ## CONSUMES ## GUID (Indicate the information type is file)
gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode)
gEfiIfrFrontPageGuid ## CONSUMES ## GUID
gEfiIfrBootMaintenanceGuid ## CONSUMES ## GUID
[Protocols]
gEfiSimpleFileSystemProtocolGuid ## CONSUMES
gEfiLoadFileProtocolGuid ## CONSUMES
gEfiHiiConfigAccessProtocolGuid ## CONSUMES
gEfiSerialIoProtocolGuid ## CONSUMES
gEfiDevicePathToTextProtocolGuid ## CONSUMES
[FeaturePcd]
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow

View File

@ -0,0 +1,984 @@
/** @file
Provide boot option support for Application "BootMaint"
Include file system navigation, system handle selection
Boot option manipulation
Copyright (c) 2004 - 2015, 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
http://opensource.org/licenses/bsd-license.php
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 "BootMaintenanceManager.h"
///
/// Define the maximum characters that will be accepted.
///
#define MAX_CHAR 480
/**
Create a menu entry by given menu type.
@param MenuType The Menu type to be created.
@retval NULL If failed to create the menu.
@return the new menu entry.
**/
BM_MENU_ENTRY *
BOpt_CreateMenuEntry (
UINTN MenuType
)
{
BM_MENU_ENTRY *MenuEntry;
UINTN ContextSize;
//
// Get context size according to menu type
//
switch (MenuType) {
case BM_LOAD_CONTEXT_SELECT:
ContextSize = sizeof (BM_LOAD_CONTEXT);
break;
case BM_FILE_CONTEXT_SELECT:
ContextSize = sizeof (BM_FILE_CONTEXT);
break;
case BM_CONSOLE_CONTEXT_SELECT:
ContextSize = sizeof (BM_CONSOLE_CONTEXT);
break;
case BM_TERMINAL_CONTEXT_SELECT:
ContextSize = sizeof (BM_TERMINAL_CONTEXT);
break;
case BM_HANDLE_CONTEXT_SELECT:
ContextSize = sizeof (BM_HANDLE_CONTEXT);
break;
default:
ContextSize = 0;
break;
}
if (ContextSize == 0) {
return NULL;
}
//
// Create new menu entry
//
MenuEntry = AllocateZeroPool (sizeof (BM_MENU_ENTRY));
if (MenuEntry == NULL) {
return NULL;
}
MenuEntry->VariableContext = AllocateZeroPool (ContextSize);
if (MenuEntry->VariableContext == NULL) {
FreePool (MenuEntry);
return NULL;
}
MenuEntry->Signature = BM_MENU_ENTRY_SIGNATURE;
MenuEntry->ContextSelection = MenuType;
return MenuEntry;
}
/**
Free up all resource allocated for a BM_MENU_ENTRY.
@param MenuEntry A pointer to BM_MENU_ENTRY.
**/
VOID
BOpt_DestroyMenuEntry (
BM_MENU_ENTRY *MenuEntry
)
{
BM_LOAD_CONTEXT *LoadContext;
BM_FILE_CONTEXT *FileContext;
BM_CONSOLE_CONTEXT *ConsoleContext;
BM_TERMINAL_CONTEXT *TerminalContext;
BM_HANDLE_CONTEXT *HandleContext;
//
// Select by the type in Menu entry for current context type
//
switch (MenuEntry->ContextSelection) {
case BM_LOAD_CONTEXT_SELECT:
LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;
FreePool (LoadContext->FilePathList);
FreePool (LoadContext->LoadOption);
if (LoadContext->OptionalData != NULL) {
FreePool (LoadContext->OptionalData);
}
FreePool (LoadContext);
break;
case BM_FILE_CONTEXT_SELECT:
FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;
if (!FileContext->IsRoot) {
FreePool (FileContext->DevicePath);
} else {
if (FileContext->FHandle != NULL) {
FileContext->FHandle->Close (FileContext->FHandle);
}
}
if (FileContext->FileName != NULL) {
FreePool (FileContext->FileName);
}
if (FileContext->Info != NULL) {
FreePool (FileContext->Info);
}
FreePool (FileContext);
break;
case BM_CONSOLE_CONTEXT_SELECT:
ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;
FreePool (ConsoleContext->DevicePath);
FreePool (ConsoleContext);
break;
case BM_TERMINAL_CONTEXT_SELECT:
TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;
FreePool (TerminalContext->DevicePath);
FreePool (TerminalContext);
break;
case BM_HANDLE_CONTEXT_SELECT:
HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;
FreePool (HandleContext);
break;
default:
break;
}
FreePool (MenuEntry->DisplayString);
if (MenuEntry->HelpString != NULL) {
FreePool (MenuEntry->HelpString);
}
FreePool (MenuEntry);
}
/**
Get the Menu Entry from the list in Menu Entry List.
If MenuNumber is great or equal to the number of Menu
Entry in the list, then ASSERT.
@param MenuOption The Menu Entry List to read the menu entry.
@param MenuNumber The index of Menu Entry.
@return The Menu Entry.
**/
BM_MENU_ENTRY *
BOpt_GetMenuEntry (
BM_MENU_OPTION *MenuOption,
UINTN MenuNumber
)
{
BM_MENU_ENTRY *NewMenuEntry;
UINTN Index;
LIST_ENTRY *List;
ASSERT (MenuNumber < MenuOption->MenuNumber);
List = MenuOption->Head.ForwardLink;
for (Index = 0; Index < MenuNumber; Index++) {
List = List->ForwardLink;
}
NewMenuEntry = CR (List, BM_MENU_ENTRY, Link, BM_MENU_ENTRY_SIGNATURE);
return NewMenuEntry;
}
/**
Free resources allocated in Allocate Rountine.
@param FreeMenu Menu to be freed
**/
VOID
BOpt_FreeMenu (
BM_MENU_OPTION *FreeMenu
)
{
BM_MENU_ENTRY *MenuEntry;
while (!IsListEmpty (&FreeMenu->Head)) {
MenuEntry = CR (
FreeMenu->Head.ForwardLink,
BM_MENU_ENTRY,
Link,
BM_MENU_ENTRY_SIGNATURE
);
RemoveEntryList (&MenuEntry->Link);
BOpt_DestroyMenuEntry (MenuEntry);
}
FreeMenu->MenuNumber = 0;
}
/**
Build the BootOptionMenu according to BootOrder Variable.
This Routine will access the Boot#### to get EFI_LOAD_OPTION.
@param CallbackData The BMM context data.
@return EFI_NOT_FOUND Fail to find "BootOrder" variable.
@return EFI_SUCESS Success build boot option menu.
**/
EFI_STATUS
BOpt_GetBootOptions (
IN BMM_CALLBACK_DATA *CallbackData
)
{
UINTN Index;
UINT16 BootString[10];
UINT8 *LoadOptionFromVar;
UINT8 *LoadOption;
UINTN BootOptionSize;
BOOLEAN BootNextFlag;
UINT16 *BootOrderList;
UINTN BootOrderListSize;
UINT16 *BootNext;
UINTN BootNextSize;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
UINT8 *LoadOptionPtr;
UINTN StringSize;
UINTN OptionalDataSize;
UINT8 *LoadOptionEnd;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN MenuCount;
UINT8 *Ptr;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
UINTN BootOptionCount;
MenuCount = 0;
BootOrderListSize = 0;
BootNextSize = 0;
BootOrderList = NULL;
BootNext = NULL;
LoadOptionFromVar = NULL;
BOpt_FreeMenu (&BootOptionMenu);
InitializeListHead (&BootOptionMenu.Head);
//
// Get the BootOrder from the Var
//
GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, &BootOrderListSize);
if (BootOrderList == NULL) {
return EFI_NOT_FOUND;
}
//
// Get the BootNext from the Var
//
GetEfiGlobalVariable2 (L"BootNext", (VOID **) &BootNext, &BootNextSize);
if (BootNext != NULL) {
if (BootNextSize != sizeof (UINT16)) {
FreePool (BootNext);
BootNext = NULL;
}
}
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {
//
// Don't display the hidden/inactive boot option
//
if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {
continue;
}
UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index]);
//
// Get all loadoptions from the VAR
//
GetEfiGlobalVariable2 (BootString, (VOID **) &LoadOptionFromVar, &BootOptionSize);
if (LoadOptionFromVar == NULL) {
continue;
}
LoadOption = AllocateZeroPool (BootOptionSize);
if (LoadOption == NULL) {
continue;
}
CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);
FreePool (LoadOptionFromVar);
if (BootNext != NULL) {
BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);
} else {
BootNextFlag = FALSE;
}
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
ASSERT (NULL != NewMenuEntry);
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
LoadOptionPtr = LoadOption;
LoadOptionEnd = LoadOption + BootOptionSize;
NewMenuEntry->OptionNumber = BootOrderList[Index];
NewLoadContext->LoadOptionModified = FALSE;
NewLoadContext->Deleted = FALSE;
NewLoadContext->IsBootNext = BootNextFlag;
//
// Is a Legacy Device?
//
Ptr = (UINT8 *) LoadOption;
//
// Attribute = *(UINT32 *)Ptr;
//
Ptr += sizeof (UINT32);
//
// FilePathSize = *(UINT16 *)Ptr;
//
Ptr += sizeof (UINT16);
//
// Description = (CHAR16 *)Ptr;
//
Ptr += StrSize ((CHAR16 *) Ptr);
//
// Now Ptr point to Device Path
//
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {
NewLoadContext->IsLegacy = TRUE;
} else {
NewLoadContext->IsLegacy = FALSE;
}
//
// LoadOption is a pointer type of UINT8
// for easy use with following LOAD_OPTION
// embedded in this struct
//
NewLoadContext->LoadOption = LoadOption;
NewLoadContext->LoadOptionSize = BootOptionSize;
NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
NewLoadContext->IsActive = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
LoadOptionPtr += sizeof (UINT32);
NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;
LoadOptionPtr += sizeof (UINT16);
StringSize = StrSize((UINT16*)LoadOptionPtr);
NewLoadContext->Description = AllocateZeroPool (StrSize((UINT16*)LoadOptionPtr));
ASSERT (NewLoadContext->Description != NULL);
StrCpyS (NewLoadContext->Description, StrSize((UINT16*)LoadOptionPtr) / sizeof (UINT16), (UINT16*)LoadOptionPtr);
ASSERT (NewLoadContext->Description != NULL);
NewMenuEntry->DisplayString = NewLoadContext->Description;
NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
LoadOptionPtr += StringSize;
NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);
ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem (
NewLoadContext->FilePathList,
(EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,
NewLoadContext->FilePathListLength
);
NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
LoadOptionPtr += NewLoadContext->FilePathListLength;
if (LoadOptionPtr < LoadOptionEnd) {
OptionalDataSize = BootOptionSize -
sizeof (UINT32) -
sizeof (UINT16) -
StringSize -
NewLoadContext->FilePathListLength;
NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
ASSERT (NewLoadContext->OptionalData != NULL);
CopyMem (
NewLoadContext->OptionalData,
LoadOptionPtr,
OptionalDataSize
);
NewLoadContext->OptionalDataSize = OptionalDataSize;
}
InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
MenuCount++;
}
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
if (BootNext != NULL) {
FreePool (BootNext);
}
if (BootOrderList != NULL) {
FreePool (BootOrderList);
}
BootOptionMenu.MenuNumber = MenuCount;
return EFI_SUCCESS;
}
/**
Find drivers that will be added as Driver#### variables from handles
in current system environment
All valid handles in the system except those consume SimpleFs, LoadFile
are stored in DriverMenu for future use.
@retval EFI_SUCCESS The function complets successfully.
@return Other value if failed to build the DriverMenu.
**/
EFI_STATUS
BOpt_FindDrivers (
VOID
)
{
UINTN NoDevicePathHandles;
EFI_HANDLE *DevicePathHandle;
UINTN Index;
EFI_STATUS Status;
BM_MENU_ENTRY *NewMenuEntry;
BM_HANDLE_CONTEXT *NewHandleContext;
EFI_HANDLE CurHandle;
UINTN OptionNumber;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
SimpleFs = NULL;
LoadFile = NULL;
InitializeListHead (&DriverMenu.Head);
//
// At first, get all handles that support Device Path
// protocol which is the basic requirement for
// Driver####
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiDevicePathProtocolGuid,
NULL,
&NoDevicePathHandles,
&DevicePathHandle
);
if (EFI_ERROR (Status)) {
return Status;
}
OptionNumber = 0;
for (Index = 0; Index < NoDevicePathHandles; Index++) {
CurHandle = DevicePathHandle[Index];
Status = gBS->HandleProtocol (
CurHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID **) &SimpleFs
);
if (Status == EFI_SUCCESS) {
continue;
}
Status = gBS->HandleProtocol (
CurHandle,
&gEfiLoadFileProtocolGuid,
(VOID **) &LoadFile
);
if (Status == EFI_SUCCESS) {
continue;
}
NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
FreePool (DevicePathHandle);
return EFI_OUT_OF_RESOURCES;
}
NewHandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;
NewHandleContext->Handle = CurHandle;
NewHandleContext->DevicePath = DevicePathFromHandle (CurHandle);
NewMenuEntry->DisplayString = UiDevicePathToStr (NewHandleContext->DevicePath);
NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle,0,NewMenuEntry->DisplayString,NULL);
NewMenuEntry->HelpString = NULL;
NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
NewMenuEntry->OptionNumber = OptionNumber;
OptionNumber++;
InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);
}
if (DevicePathHandle != NULL) {
FreePool (DevicePathHandle);
}
DriverMenu.MenuNumber = OptionNumber;
return EFI_SUCCESS;
}
/**
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
)
{
UINT16 *OrderList;
UINTN OrderListSize;
UINTN Index;
CHAR16 StrTemp[20];
UINT16 *OptionBuffer;
UINT16 OptionNumber;
UINTN OptionSize;
OrderListSize = 0;
OrderList = NULL;
OptionNumber = 0;
Index = 0;
UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type);
GetEfiGlobalVariable2 (StrTemp, (VOID **) &OrderList, &OrderListSize);
for (OptionNumber = 0; ; OptionNumber++) {
if (OrderList != NULL) {
for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {
if (OptionNumber == OrderList[Index]) {
break;
}
}
}
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));
GetEfiGlobalVariable2 (StrTemp, (VOID **) &OptionBuffer, &OptionSize);
if (NULL == OptionBuffer) {
//
// The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it
//
break;
}
}
return OptionNumber;
}
/**
Get the Option Number for Boot#### that does not used.
@return The available Option Number.
**/
UINT16
BOpt_GetBootOptionNumber (
VOID
)
{
return BOpt_GetOptionNumber (L"Boot");
}
/**
Get the Option Number for Driver#### that does not used.
@return The unused Option Number.
**/
UINT16
BOpt_GetDriverOptionNumber (
VOID
)
{
return BOpt_GetOptionNumber (L"Driver");
}
/**
Build up all DriverOptionMenu
@param CallbackData The BMM context data.
@retval EFI_SUCESS The functin completes successfully.
@retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
@retval EFI_NOT_FOUND Fail to get "DriverOrder" variable.
**/
EFI_STATUS
BOpt_GetDriverOptions (
IN BMM_CALLBACK_DATA *CallbackData
)
{
UINTN Index;
UINT16 DriverString[12];
UINT8 *LoadOptionFromVar;
UINT8 *LoadOption;
UINTN DriverOptionSize;
UINT16 *DriverOrderList;
UINTN DriverOrderListSize;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
UINT8 *LoadOptionPtr;
UINTN StringSize;
UINTN OptionalDataSize;
UINT8 *LoadOptionEnd;
DriverOrderListSize = 0;
DriverOrderList = NULL;
DriverOptionSize = 0;
LoadOptionFromVar = NULL;
BOpt_FreeMenu (&DriverOptionMenu);
InitializeListHead (&DriverOptionMenu.Head);
//
// Get the DriverOrder from the Var
//
GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, &DriverOrderListSize);
if (DriverOrderList == NULL) {
return EFI_NOT_FOUND;
}
for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {
UnicodeSPrint (
DriverString,
sizeof (DriverString),
L"Driver%04x",
DriverOrderList[Index]
);
//
// Get all loadoptions from the VAR
//
GetEfiGlobalVariable2 (DriverString, (VOID **) &LoadOptionFromVar, &DriverOptionSize);
if (LoadOptionFromVar == NULL) {
continue;
}
LoadOption = AllocateZeroPool (DriverOptionSize);
if (LoadOption == NULL) {
continue;
}
CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);
FreePool (LoadOptionFromVar);
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
return EFI_OUT_OF_RESOURCES;
}
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
LoadOptionPtr = LoadOption;
LoadOptionEnd = LoadOption + DriverOptionSize;
NewMenuEntry->OptionNumber = DriverOrderList[Index];
NewLoadContext->LoadOptionModified = FALSE;
NewLoadContext->Deleted = FALSE;
NewLoadContext->IsLegacy = FALSE;
//
// LoadOption is a pointer type of UINT8
// for easy use with following LOAD_OPTION
// embedded in this struct
//
NewLoadContext->LoadOption = LoadOption;
NewLoadContext->LoadOptionSize = DriverOptionSize;
NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
NewLoadContext->IsActive = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
LoadOptionPtr += sizeof (UINT32);
NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;
LoadOptionPtr += sizeof (UINT16);
StringSize = StrSize ((UINT16 *) LoadOptionPtr);
NewLoadContext->Description = AllocateZeroPool (StringSize);
ASSERT (NewLoadContext->Description != NULL);
CopyMem (
NewLoadContext->Description,
(UINT16 *) LoadOptionPtr,
StringSize
);
NewMenuEntry->DisplayString = NewLoadContext->Description;
NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
LoadOptionPtr += StringSize;
NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);
ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem (
NewLoadContext->FilePathList,
(EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,
NewLoadContext->FilePathListLength
);
NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
LoadOptionPtr += NewLoadContext->FilePathListLength;
if (LoadOptionPtr < LoadOptionEnd) {
OptionalDataSize = DriverOptionSize -
sizeof (UINT32) -
sizeof (UINT16) -
StringSize -
NewLoadContext->FilePathListLength;
NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
ASSERT (NewLoadContext->OptionalData != NULL);
CopyMem (
NewLoadContext->OptionalData,
LoadOptionPtr,
OptionalDataSize
);
NewLoadContext->OptionalDataSize = OptionalDataSize;
}
InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
}
if (DriverOrderList != NULL) {
FreePool (DriverOrderList);
}
DriverOptionMenu.MenuNumber = Index;
return EFI_SUCCESS;
}
/**
Get option number according to Boot#### and BootOrder variable.
The value is saved as #### + 1.
@param CallbackData The BMM context data.
**/
VOID
GetBootOrder (
IN BMM_CALLBACK_DATA *CallbackData
)
{
BMM_FAKE_NV_DATA *BmmConfig;
UINT16 Index;
UINT16 OptionOrderIndex;
UINTN DeviceType;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
ASSERT (CallbackData != NULL);
DeviceType = (UINTN) -1;
BmmConfig = &CallbackData->BmmFakeNvData;
ZeroMem (BmmConfig->BootOptionOrder, sizeof (BmmConfig->BootOptionOrder));
for (Index = 0, OptionOrderIndex = 0; ((Index < BootOptionMenu.MenuNumber) &&
(OptionOrderIndex < (sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
if (NewLoadContext->IsLegacy) {
if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {
DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;
} else {
//
// Only show one legacy boot option for the same device type
// assuming the boot options are grouped by the device type
//
continue;
}
}
BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);
}
}
/**
Get driver option order from globalc DriverOptionMenu.
@param CallbackData The BMM context data.
**/
VOID
GetDriverOrder (
IN BMM_CALLBACK_DATA *CallbackData
)
{
BMM_FAKE_NV_DATA *BmmConfig;
UINT16 Index;
UINT16 OptionOrderIndex;
UINTN DeviceType;
BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext;
ASSERT (CallbackData != NULL);
DeviceType = (UINTN) -1;
BmmConfig = &CallbackData->BmmFakeNvData;
ZeroMem (BmmConfig->DriverOptionOrder, sizeof (BmmConfig->DriverOptionOrder));
for (Index = 0, OptionOrderIndex = 0; ((Index < DriverOptionMenu.MenuNumber) &&
(OptionOrderIndex < (sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));
Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
if (NewLoadContext->IsLegacy) {
if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {
DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;
} else {
//
// Only show one legacy boot option for the same device type
// assuming the boot options are grouped by the device type
//
continue;
}
}
BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);
}
}
/**
Boot the file specified by the input file path info.
@param FilePath Point to the file path.
@retval TRUE Exit caller function.
@retval FALSE Not exit caller function.
**/
BOOLEAN
BootFromFile (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
CHAR16 *FileName;
FileName = ExtractFileNameFromDevicePath(FilePath);
EfiBootManagerInitializeLoadOption (
&BootOption,
0,
LoadOptionTypeBoot,
LOAD_OPTION_ACTIVE,
FileName,
FilePath,
NULL,
0
);
//
// Since current no boot from removable media directly is allowed */
//
gST->ConOut->ClearScreen (gST->ConOut);
BmmBdsSetConsoleMode (FALSE);
EfiBootManagerBoot (&BootOption);
BmmBdsSetConsoleMode (TRUE);
FreePool(FileName);
EfiBootManagerFreeLoadOption (&BootOption);
return FALSE;
}
/**
Display the form base on the selected file.
@param FilePath Point to the file path.
@param FormId The form need to display.
**/
BOOLEAN
ReSendForm(
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN EFI_FORM_ID FormId
)
{
gBootMaintenancePrivate.LoadContext->FilePathList = FilePath;
UpdateOptionPage(&gBootMaintenancePrivate, FormId, FilePath);
gBootMaintenancePrivate.FormBrowser2->SendForm (
gBootMaintenancePrivate.FormBrowser2,
&gBootMaintenancePrivate.BmmHiiHandle,
1,
&mBootMaintGuid,
FormId,
NULL,
NULL
);
return TRUE;
}
/**
Create boot option base on the input file path info.
@param FilePath Point to the file path.
@retval TRUE Exit caller function.
@retval FALSE Not exit caller function.
**/
BOOLEAN
CreateBootOptionFromFile (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
return ReSendForm(FilePath, FORM_BOOT_ADD_ID);
}
/**
Create driver option base on the input file path info.
@param FilePath Point to the file path.
@retval TRUE Exit caller function.
@retval FALSE Not exit caller function.
**/
BOOLEAN
CreateDriverOptionFromFile (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
return ReSendForm(FilePath, FORM_DRV_ADD_FILE_ID);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,263 @@
/** @file
Define some data used for Boot Maint
Copyright (c) 2004 - 2015, 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
http://opensource.org/licenses/bsd-license.php
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 "BootMaintenanceManager.h"
VOID *mStartOpCodeHandle = NULL;
VOID *mEndOpCodeHandle = NULL;
EFI_IFR_GUID_LABEL *mStartLabel = NULL;
EFI_IFR_GUID_LABEL *mEndLabel = NULL;
///
/// Terminal type string token storage
///
UINT16 TerminalType[] = {
STRING_TOKEN(STR_COM_TYPE_0),
STRING_TOKEN(STR_COM_TYPE_1),
STRING_TOKEN(STR_COM_TYPE_2),
STRING_TOKEN(STR_COM_TYPE_3),
STRING_TOKEN(STR_COM_TYPE_4),
};
///
/// Flow Control type string token storage
///
UINT16 mFlowControlType[2] = {
STRING_TOKEN(STR_NONE_FLOW_CONTROL),
STRING_TOKEN(STR_HARDWARE_FLOW_CONTROL)
};
UINT32 mFlowControlValue[2] = {
0,
UART_FLOW_CONTROL_HARDWARE
};
///
/// Console Input Device Selection Menu
///
BM_MENU_OPTION ConsoleInpMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Console Output Device Selection Menu
///
BM_MENU_OPTION ConsoleOutMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Error Output Device Selection Menu
///
BM_MENU_OPTION ConsoleErrMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Boot Option from variable Menu
///
BM_MENU_OPTION BootOptionMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Driver Option from variable menu
///
BM_MENU_OPTION DriverOptionMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Handles in current system selection menu
///
BM_MENU_OPTION DriverMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
BM_MENU_OPTION TerminalMenu = {
BM_MENU_OPTION_SIGNATURE,
{NULL},
0
};
///
/// Value and string token correspondency for BaudRate
///
COM_ATTR BaudRateList[19] = {
{
115200,
STRING_TOKEN(STR_COM_BAUD_RATE_0)
},
{
57600,
STRING_TOKEN(STR_COM_BAUD_RATE_1)
},
{
38400,
STRING_TOKEN(STR_COM_BAUD_RATE_2)
},
{
19200,
STRING_TOKEN(STR_COM_BAUD_RATE_3)
},
{
9600,
STRING_TOKEN(STR_COM_BAUD_RATE_4)
},
{
7200,
STRING_TOKEN(STR_COM_BAUD_RATE_5)
},
{
4800,
STRING_TOKEN(STR_COM_BAUD_RATE_6)
},
{
3600,
STRING_TOKEN(STR_COM_BAUD_RATE_7)
},
{
2400,
STRING_TOKEN(STR_COM_BAUD_RATE_8)
},
{
2000,
STRING_TOKEN(STR_COM_BAUD_RATE_9)
},
{
1800,
STRING_TOKEN(STR_COM_BAUD_RATE_10)
},
{
1200,
STRING_TOKEN(STR_COM_BAUD_RATE_11)
},
{
600,
STRING_TOKEN(STR_COM_BAUD_RATE_12)
},
{
300,
STRING_TOKEN(STR_COM_BAUD_RATE_13)
},
{
150,
STRING_TOKEN(STR_COM_BAUD_RATE_14)
},
{
134,
STRING_TOKEN(STR_COM_BAUD_RATE_15)
},
{
110,
STRING_TOKEN(STR_COM_BAUD_RATE_16)
},
{
75,
STRING_TOKEN(STR_COM_BAUD_RATE_17)
},
{
50,
STRING_TOKEN(STR_COM_BAUD_RATE_18)
}
};
///
/// Value and string token correspondency for DataBits
///
COM_ATTR DataBitsList[4] = {
{
5,
STRING_TOKEN(STR_COM_DATA_BITS_0)
},
{
6,
STRING_TOKEN(STR_COM_DATA_BITS_1)
},
{
7,
STRING_TOKEN(STR_COM_DATA_BITS_2)
},
{
8,
STRING_TOKEN(STR_COM_DATA_BITS_3)
}
};
///
/// Value and string token correspondency for Parity
///
COM_ATTR ParityList[5] = {
{
NoParity,
STRING_TOKEN(STR_COM_PAR_0)
},
{
EvenParity,
STRING_TOKEN(STR_COM_PAR_1)
},
{
OddParity,
STRING_TOKEN(STR_COM_PAR_2)
},
{
MarkParity,
STRING_TOKEN(STR_COM_PAR_3)
},
{
SpaceParity,
STRING_TOKEN(STR_COM_PAR_4)
}
};
///
/// Value and string token correspondency for Baudreate
///
COM_ATTR StopBitsList[3] = {
{
OneStopBit,
STRING_TOKEN(STR_COM_STOP_BITS_0)
},
{
OneFiveStopBits,
STRING_TOKEN(STR_COM_STOP_BITS_1)
},
{
TwoStopBits,
STRING_TOKEN(STR_COM_STOP_BITS_2)
}
};
///
/// Guid for messaging path, used in Serial port setting.
///
EFI_GUID TerminalTypeGuid[] = {
DEVICE_PATH_MESSAGING_PC_ANSI,
DEVICE_PATH_MESSAGING_VT_100,
DEVICE_PATH_MESSAGING_VT_100_PLUS,
DEVICE_PATH_MESSAGING_VT_UTF8,
EFI_TTY_TERM_GUID
};

View File

@ -0,0 +1,209 @@
/** @file
Formset guids, form id and VarStore data structure for Boot Maintenance Manager.
Copyright (c) 2004 - 2015, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _FORM_GUID_H_
#define _FORM_GUID_H_
#define BOOT_MAINT_FORMSET_GUID \
{ \
0x642237c7, 0x35d4, 0x472d, {0x83, 0x65, 0x12, 0xe0, 0xcc, 0xf2, 0x7a, 0x22} \
}
#define FORM_MAIN_ID 0x1001
#define FORM_BOOT_ADD_ID 0x1002
#define FORM_BOOT_DEL_ID 0x1003
#define FORM_BOOT_CHG_ID 0x1004
#define FORM_DRV_ADD_ID 0x1005
#define FORM_DRV_DEL_ID 0x1006
#define FORM_DRV_CHG_ID 0x1007
#define FORM_CON_MAIN_ID 0x1008
#define FORM_CON_IN_ID 0x1009
#define FORM_CON_OUT_ID 0x100A
#define FORM_CON_ERR_ID 0x100B
#define FORM_FILE_SEEK_ID 0x100C
#define FORM_FILE_NEW_SEEK_ID 0x100D
#define FORM_DRV_ADD_FILE_ID 0x100E
#define FORM_DRV_ADD_HANDLE_ID 0x100F
#define FORM_DRV_ADD_HANDLE_DESC_ID 0x1010
#define FORM_BOOT_NEXT_ID 0x1011
#define FORM_TIME_OUT_ID 0x1012
#define FORM_BOOT_SETUP_ID 0x1014
#define FORM_DRIVER_SETUP_ID 0x1015
#define FORM_BOOT_LEGACY_DEVICE_ID 0x1016
#define FORM_CON_COM_ID 0x1017
#define FORM_CON_COM_SETUP_ID 0x1018
#define FORM_BOOT_ADD_DESCRIPTION_ID 0x101F
#define FORM_DRIVER_ADD_FILE_DESCRIPTION_ID 0x1020
#define FORM_CON_MODE_ID 0x1021
#define FORM_MEMORY_CHECK_ID 0x1022
#define FORM_UEFI_OPTIMIZED_BOOT_ID 0x1023
#define FORM_BOOT_FROM_FILE_ID 0x1024
#define MAXIMUM_FORM_ID 0x10FF
#define KEY_VALUE_COM_SET_BAUD_RATE 0x1101
#define KEY_VALUE_COM_SET_DATA_BITS 0x1102
#define KEY_VALUE_COM_SET_STOP_BITS 0x1103
#define KEY_VALUE_COM_SET_PARITY 0x1104
#define KEY_VALUE_COM_SET_TERMI_TYPE 0x1105
#define KEY_VALUE_MAIN_BOOT_NEXT 0x1106
#define KEY_VALUE_BOOT_ADD_DESC_DATA 0x1107
#define KEY_VALUE_BOOT_ADD_OPT_DATA 0x1108
#define KEY_VALUE_DRIVER_ADD_DESC_DATA 0x1109
#define KEY_VALUE_DRIVER_ADD_OPT_DATA 0x110A
#define KEY_VALUE_SAVE_AND_EXIT 0x110B
#define KEY_VALUE_NO_SAVE_AND_EXIT 0x110C
#define KEY_VALUE_BOOT_FROM_FILE 0x110D
#define FORM_RESET 0x110E
#define KEY_VALUE_BOOT_DESCRIPTION 0x110F
#define KEY_VALUE_BOOT_OPTION 0x1110
#define KEY_VALUE_DRIVER_DESCRIPTION 0x1111
#define KEY_VALUE_DRIVER_OPTION 0x1112
#define KEY_VALUE_SAVE_AND_EXIT_BOOT 0x1113
#define KEY_VALUE_NO_SAVE_AND_EXIT_BOOT 0x1114
#define KEY_VALUE_SAVE_AND_EXIT_DRIVER 0x1115
#define KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER 0x1116
#define MAXIMUM_NORMAL_KEY_VALUE 0x11FF
//
// Varstore ID defined for Buffer Storage
//
#define VARSTORE_ID_BOOT_MAINT 0x1000
//
// End Label
//
#define LABEL_BMM_PLATFORM_INFORMATION 0xfffe
#define LABEL_END 0xffff
#define MAX_MENU_NUMBER 100
///
/// This is the structure that will be used to store the
/// question's current value. Use it at initialize time to
/// set default value for each question. When using at run
/// time, this map is returned by the callback function,
/// so dynamically changing the question's value will be
/// possible through this mechanism
///
typedef struct {
//
// Three questions displayed at the main page
// for Timeout, BootNext, Variables respectively
//
UINT16 BootTimeOut;
UINT16 BootNext;
//
// This is the COM1 Attributes value storage
//
UINT8 COM1BaudRate;
UINT8 COM1DataRate;
UINT8 COM1StopBits;
UINT8 COM1Parity;
UINT8 COM1TerminalType;
//
// This is the COM2 Attributes value storage
//
UINT8 COM2BaudRate;
UINT8 COM2DataRate;
UINT8 COM2StopBits;
UINT8 COM2Parity;
UINT8 COM2TerminalType;
//
// Driver Option Add Handle page storage
//
UINT16 DriverAddHandleDesc[MAX_MENU_NUMBER];
UINT16 DriverAddHandleOptionalData[MAX_MENU_NUMBER];
UINT8 DriverAddActive;
UINT8 DriverAddForceReconnect;
//
// Console Input/Output/Errorout using COM port check storage
//
UINT8 ConsoleInputCOM1;
UINT8 ConsoleInputCOM2;
UINT8 ConsoleOutputCOM1;
UINT8 ConsoleOutputCOM2;
UINT8 ConsoleErrorCOM1;
UINT8 ConsoleErrorCOM2;
//
// At most 100 input/output/errorout device for console storage
//
UINT8 ConsoleCheck[MAX_MENU_NUMBER];
//
// At most 100 input/output/errorout device for console storage
//
UINT8 ConsoleInCheck[MAX_MENU_NUMBER];
UINT8 ConsoleOutCheck[MAX_MENU_NUMBER];
UINT8 ConsoleErrCheck[MAX_MENU_NUMBER];
//
// Boot or Driver Option Order storage
// The value is the OptionNumber+1 because the order list value cannot be 0
// Use UINT32 to hold the potential value 0xFFFF+1=0x10000
//
UINT32 BootOptionOrder[MAX_MENU_NUMBER];
UINT32 DriverOptionOrder[MAX_MENU_NUMBER];
//
// Boot or Driver Option Delete storage
//
BOOLEAN BootOptionDel[MAX_MENU_NUMBER];
BOOLEAN DriverOptionDel[MAX_MENU_NUMBER];
BOOLEAN BootOptionDelMark[MAX_MENU_NUMBER];
BOOLEAN DriverOptionDelMark[MAX_MENU_NUMBER];
//
// This is the Terminal Attributes value storage
//
UINT8 COMBaudRate[MAX_MENU_NUMBER];
UINT8 COMDataRate[MAX_MENU_NUMBER];
UINT8 COMStopBits[MAX_MENU_NUMBER];
UINT8 COMParity[MAX_MENU_NUMBER];
UINT8 COMTerminalType[MAX_MENU_NUMBER];
UINT8 COMFlowControl[MAX_MENU_NUMBER];
//
// We use DisableMap array to record the enable/disable state of each boot device
// It should be taken as a bit array, from left to right there are totally 256 bits
// the most left one stands for BBS table item 0, and the most right one stands for item 256
// If the bit is 1, it means the boot device has been disabled.
//
UINT8 DisableMap[32];
//
// Console Output Text Mode
//
UINT16 ConsoleOutMode;
//
// UINT16 PadArea[10];
//
UINT16 BootDescriptionData[MAX_MENU_NUMBER];
UINT16 BootOptionalData[127];
UINT16 DriverDescriptionData[MAX_MENU_NUMBER];
UINT16 DriverOptionalData[127];
BOOLEAN BootOptionChanged;
BOOLEAN DriverOptionChanged;
UINT8 Active;
UINT8 ForceReconnect;
} BMM_FAKE_NV_DATA;
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff