2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _BOOT_MAINT_H_
16 #define _BOOT_MAINT_H_
19 #include "BBSsupport.h"
21 #include "FrontPage.h"
24 // Constants which are variable names used to access variables
26 #define VAR_CON_OUT_MODE L"ConOutMode"
31 #define STR_FLOPPY L"Floppy Drive #%02x"
32 #define STR_HARDDISK L"HardDisk Drive #%02x"
33 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
34 #define STR_NET L"NET Drive #%02x"
35 #define STR_BEV L"BEV Drive #%02x"
36 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
37 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
38 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
39 #define STR_NET_HELP L"NET Drive #%02x"
40 #define STR_BEV_HELP L"BEV Drive #%02x"
42 extern CHAR16 mFileExplorerStorageName
[];
43 extern CHAR16 mBootMaintStorageName
[];
45 // These are the VFR compiler generated data representing our VFR data.
51 // Below are the number of options in Baudrate, Databits,
52 // Parity and Stopbits selection for serial ports.
54 #define BM_COM_ATTR_BUADRATE 19
55 #define BM_COM_ATTR_DATABITS 4
56 #define BM_COM_ATTR_PARITY 5
57 #define BM_COM_ATTR_STOPBITS 3
60 // Callback function helper
62 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
63 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
65 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
68 // Enumeration type definition
70 typedef enum _TYPE_OF_TERMINAL
{
71 TerminalTypePcAnsi
= 0,
73 TerminalTypeVt100Plus
,
77 typedef enum _FILE_EXPLORER_STATE
{
78 FileExplorerStateInActive
= 0,
79 FileExplorerStateBootFromFile
,
80 FileExplorerStateAddBootOption
,
81 FileExplorerStateAddDriverOptionState
,
82 FileExplorerStateUnknown
83 } FILE_EXPLORER_STATE
;
85 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
86 FileExplorerDisplayFileSystem
,
87 FileExplorerDisplayDirectory
,
88 FileExplorerDisplayUnknown
89 } FILE_EXPLORER_DISPLAY_CONTEXT
;
92 // All of the signatures that will be used in list structure
94 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
95 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
96 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
97 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
98 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
99 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
100 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
102 #define BM_LOAD_CONTEXT_SELECT 0x0
103 #define BM_CONSOLE_CONTEXT_SELECT 0x1
104 #define BM_FILE_CONTEXT_SELECT 0x2
105 #define BM_HANDLE_CONTEXT_SELECT 0x3
106 #define BM_TERMINAL_CONTEXT_SELECT 0x5
108 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
109 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
110 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
111 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
114 // Buffer size for update data
116 #define UPDATE_DATA_SIZE 0x100000
119 // Namespace of callback keys used in display and file system navigation
121 #define MAX_BBS_OFFSET 0xE000
122 #define NET_OPTION_OFFSET 0xD800
123 #define BEV_OPTION_OFFSET 0xD000
124 #define FD_OPTION_OFFSET 0xC000
125 #define HD_OPTION_OFFSET 0xB000
126 #define CD_OPTION_OFFSET 0xA000
127 #define FILE_OPTION_GOTO_OFFSET 0xC000
128 #define FILE_OPTION_OFFSET 0x8000
129 #define FILE_OPTION_MASK 0x3FFF
130 #define HANDLE_OPTION_OFFSET 0x7000
131 #define CONSOLE_OPTION_OFFSET 0x6000
132 #define TERMINAL_OPTION_OFFSET 0x5000
133 #define CONFIG_OPTION_OFFSET 0x1200
134 #define KEY_VALUE_OFFSET 0x1100
135 #define FORM_ID_OFFSET 0x1000
138 // VarOffset that will be used to create question
139 // all these values are computed from the structure
142 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
145 // Question Id of Zero is invalid, so add an offset to it
147 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
149 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
150 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
151 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
152 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
153 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
154 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
155 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
156 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
157 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
158 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
159 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
160 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
161 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
162 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
163 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
164 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
165 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
166 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
167 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
168 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
169 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
170 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
171 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
172 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
173 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
174 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
175 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
176 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
177 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
178 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
179 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
180 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
181 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
182 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
183 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
184 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
185 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
186 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
187 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
188 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
189 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
191 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
192 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
193 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
194 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
195 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
196 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
197 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
198 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
199 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
200 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
201 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
202 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
203 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
204 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
205 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
206 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
207 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
208 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
209 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
210 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
211 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
212 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
213 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
214 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
215 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
216 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
217 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
218 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
219 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
220 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
221 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
222 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
223 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
224 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
225 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
226 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
227 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
228 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
229 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
230 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
231 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
233 #define STRING_DEPOSITORY_NUMBER 8
236 /// Serial Ports attributes, first one is the value for
237 /// return from callback function, stringtoken is used to
238 /// display the value properly
263 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
264 } BM_TERMINAL_CONTEXT
;
268 BOOLEAN LoadOptionModified
;
273 BOOLEAN ForceReconnect
;
274 UINTN OptionalDataSize
;
276 UINTN LoadOptionSize
;
280 UINT16 FilePathListLength
;
282 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
293 } BM_LEGACY_DEVICE_CONTEXT
;
301 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
302 } BM_CONSOLE_CONTEXT
;
311 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
312 EFI_FILE_HANDLE FHandle
;
314 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
318 BOOLEAN IsRemovableMedia
;
320 BOOLEAN IsBootLegacy
;
325 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
338 UINT16
*DisplayString
;
340 EFI_STRING_ID DisplayStringToken
;
341 EFI_STRING_ID HelpStringToken
;
342 UINTN ContextSelection
;
343 VOID
*VariableContext
;
348 // Shared callback data.
352 BM_MENU_ENTRY
*MenuEntry
;
353 BM_HANDLE_CONTEXT
*HandleContext
;
354 BM_FILE_CONTEXT
*FileContext
;
355 BM_LOAD_CONTEXT
*LoadContext
;
356 BM_TERMINAL_CONTEXT
*TerminalContext
;
357 UINTN CurrentTerminal
;
361 // BMM main formset callback data.
363 EFI_HII_HANDLE BmmHiiHandle
;
364 EFI_HANDLE BmmDriverHandle
;
365 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
366 EFI_FORM_ID BmmCurrentPageId
;
367 EFI_FORM_ID BmmPreviousPageId
;
368 BOOLEAN BmmAskSaveOrNot
;
369 BMM_FAKE_NV_DATA BmmFakeNvData
;
370 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
373 // File explorer formset callback data.
375 EFI_HII_HANDLE FeHiiHandle
;
376 EFI_HANDLE FeDriverHandle
;
377 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
378 FILE_EXPLORER_STATE FeCurrentState
;
379 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
380 FILE_EXPLORER_NV_DATA FeFakeNvData
;
383 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
385 struct _STRING_LIST_NODE
{
386 EFI_STRING_ID StringToken
;
387 STRING_LIST_NODE
*Next
;
390 typedef struct _STRING_DEPOSITORY
{
391 UINTN TotalNodeNumber
;
392 STRING_LIST_NODE
*CurrentNode
;
393 STRING_LIST_NODE
*ListHead
;
399 // For initializing File System menu
403 This function build the FsOptionMenu list which records all
404 available file system in the system. They includes all instances
405 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
406 and all type of legacy boot device.
408 @param CallbackData BMM context data
410 @retval EFI_SUCCESS Success find the file system
411 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
415 BOpt_FindFileSystem (
416 IN BMM_CALLBACK_DATA
*CallbackData
420 Find files under current directory
421 All files and sub-directories in current directory
422 will be stored in DirectoryMenu for future use.
424 @param CallbackData The BMM context data.
425 @param MenuEntry The Menu Entry.
427 @retval EFI_SUCCESS Get files from current dir successfully.
428 @return Other value if can't get files from current dir.
433 IN BMM_CALLBACK_DATA
*CallbackData
,
434 IN BM_MENU_ENTRY
*MenuEntry
439 Find drivers that will be added as Driver#### variables from handles
440 in current system environment
441 All valid handles in the system except those consume SimpleFs, LoadFile
442 are stored in DriverMenu for future use.
444 @retval EFI_SUCCESS The function complets successfully.
445 @return Other value if failed to build the DriverMenu.
455 Build the BootOptionMenu according to BootOrder Variable.
456 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
458 @param CallbackData The BMM context data.
460 @return The number of the Var Boot####.
464 BOpt_GetBootOptions (
465 IN BMM_CALLBACK_DATA
*CallbackData
470 Build up all DriverOptionMenu
472 @param CallbackData The BMM context data.
474 @return EFI_SUCESS The functin completes successfully.
475 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
480 BOpt_GetDriverOptions (
481 IN BMM_CALLBACK_DATA
*CallbackData
486 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
488 @retval EFI_SUCCESS The function complete successfully.
489 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
493 BOpt_GetLegacyOptions (
498 Free out resouce allocated from Legacy Boot Options.
502 BOpt_FreeLegacyOptions (
507 Free resources allocated in Allocate Rountine.
509 @param FreeMenu Menu to be freed
514 BM_MENU_OPTION
*FreeMenu
520 Append file name to existing file name.
522 @param Str1 The existing file name
523 @param Str2 The file name to be appended
525 @return Allocate a new string to hold the appended result.
526 Caller is responsible to free the returned string.
530 BOpt_AppendFileName (
537 Check whether current FileName point to a valid
540 @param FileName File need to be checked.
542 @retval TRUE Is Efi Image
543 @retval FALSE Not a valid Efi Image
547 BOpt_IsEfiImageName (
553 Check whether current FileName point to a valid Efi Application
555 @param Dir Pointer to current Directory
556 @param FileName Pointer to current File name.
558 @retval TRUE Is a valid Efi Application
559 @retval FALSE not a valid Efi Application
564 IN EFI_FILE_HANDLE Dir
,
570 Get the Option Number that has not been allocated for use.
572 @param Type The type of Option.
574 @return The available Option Number.
578 BOpt_GetOptionNumber (
584 Get the Option Number for Boot#### that does not used.
586 @return The available Option Number.
590 BOpt_GetBootOptionNumber (
596 Get the Option Number for Driver#### that does not used.
598 @return The unused Option Number.
602 BOpt_GetDriverOptionNumber (
607 Create a menu entry give a Menu type.
609 @param MenuType The Menu type to be created.
612 @retval NULL If failed to create the menu.
617 BOpt_CreateMenuEntry (
622 Free up all resource allocated for a BM_MENU_ENTRY.
624 @param MenuEntry A pointer to BM_MENU_ENTRY.
628 BOpt_DestroyMenuEntry (
629 BM_MENU_ENTRY
*MenuEntry
633 Get the Menu Entry from the list in Menu Entry List.
635 If MenuNumber is great or equal to the number of Menu
636 Entry in the list, then ASSERT.
638 @param MenuOption The Menu Entry List to read the menu entry.
639 @param MenuNumber The index of Menu Entry.
641 @return The Menu Entry.
646 BM_MENU_OPTION
*MenuOption
,
651 // Locate all serial io devices for console
654 Build a list containing all serial devices.
656 @retval EFI_SUCCESS The function complete successfully.
657 @retval EFI_UNSUPPORTED No serial ports present.
666 // Initializing Console menu
669 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
671 @retval EFI_SUCCESS The function always complete successfully.
680 // Get current mode information
683 Get mode number according to column and row
685 @param CallbackData The BMM context data.
689 IN BMM_CALLBACK_DATA
*CallbackData
693 // Cleaning up console menu
696 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
698 @retval EFI_SUCCESS The function always complete successfully.
706 Update the device path that describing a terminal device
707 based on the new BaudRate, Data Bits, parity and Stop Bits
710 @param DevicePath The devicepath protocol instance wanted to be updated.
714 ChangeVariableDevicePath (
715 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
719 Update the multi-instance device path of Terminal Device based on
720 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
721 device path in the Terminal Device in TerminalMenu is also updated.
723 @param DevicePath The multi-instance device path.
724 @param ChangeTerminal TRUE, then device path in the Terminal Device
725 in TerminalMenu is also updated; FALSE, no update.
727 @return EFI_SUCCESS The function completes successfully.
731 ChangeTerminalDevicePath (
732 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
733 IN BOOLEAN ChangeTerminal
737 // Variable operation by menu selection
740 This function create a currently loaded Boot Option from
741 the BMM. It then appends this Boot Option to the end of
742 the "BootOrder" list. It also append this Boot Opotion to the end
745 @param CallbackData The BMM context data.
746 @param NvRamMap The file explorer formset internal state.
748 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
749 @retval EFI_SUCCESS If function completes successfully.
753 Var_UpdateBootOption (
754 IN BMM_CALLBACK_DATA
*CallbackData
,
755 IN FILE_EXPLORER_NV_DATA
*NvRamMap
759 Delete Boot Option that represent a Deleted state in BootOptionMenu.
760 After deleting this boot option, call Var_ChangeBootOrder to
761 make sure BootOrder is in valid state.
763 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
764 BM_LOAD_CONTEXT marked for deletion is deleted
765 @return Others If failed to update the "BootOrder" variable after deletion.
774 After any operation on Boot####, there will be a discrepancy in BootOrder.
775 Since some are missing but in BootOrder, while some are present but are
776 not reflected by BootOrder. Then a function rebuild BootOrder from
777 scratch by content from BootOptionMenu is needed.
779 @retval EFI_SUCCESS The boot order is updated successfully.
780 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
784 Var_ChangeBootOrder (
789 This function create a currently loaded Drive Option from
790 the BMM. It then appends this Driver Option to the end of
791 the "DriverOrder" list. It append this Driver Opotion to the end
794 @param CallbackData The BMM context data.
795 @param HiiHandle The HII handle associated with the BMM formset.
796 @param DescriptionData The description of this driver option.
797 @param OptionalData The optional load option.
798 @param ForceReconnect If to force reconnect.
800 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
801 @retval EFI_SUCCESS If function completes successfully.
805 Var_UpdateDriverOption (
806 IN BMM_CALLBACK_DATA
*CallbackData
,
807 IN EFI_HII_HANDLE HiiHandle
,
808 IN UINT16
*DescriptionData
,
809 IN UINT16
*OptionalData
,
810 IN UINT8 ForceReconnect
814 Delete Load Option that represent a Deleted state in BootOptionMenu.
815 After deleting this Driver option, call Var_ChangeDriverOrder to
816 make sure DriverOrder is in valid state.
818 @retval EFI_SUCCESS Load Option is successfully updated.
819 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
824 Var_DelDriverOption (
829 After any operation on Driver####, there will be a discrepancy in
830 DriverOrder. Since some are missing but in DriverOrder, while some
831 are present but are not reflected by DriverOrder. Then a function
832 rebuild DriverOrder from scratch by content from DriverOptionMenu is
835 @retval EFI_SUCCESS The driver order is updated successfully.
836 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
840 Var_ChangeDriverOrder (
845 This function delete and build multi-instance device path ConIn
848 @retval EFI_SUCCESS The function complete successfully.
849 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
852 Var_UpdateConsoleInpOption (
857 This function delete and build multi-instance device path ConOut console device.
859 @retval EFI_SUCCESS The function complete successfully.
860 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
863 Var_UpdateConsoleOutOption (
868 This function delete and build multi-instance device path ErrOut console device.
870 @retval EFI_SUCCESS The function complete successfully.
871 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
874 Var_UpdateErrorOutOption (
879 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
880 parity and stop Bits set.
884 Var_UpdateAllConsoleOption (
889 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
890 this EFI Variable is deleted.
891 It also update the BMM context data specified the "BootNext" value.
893 @param CallbackData The BMM context data.
895 @retval EFI_SUCCESS The function complete successfully.
896 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
901 IN BMM_CALLBACK_DATA
*CallbackData
905 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
906 BootOptionMenu with the new "BootOrder" list.
908 @param CallbackData The BMM context data.
910 @retval EFI_SUCCESS The function complete successfully.
911 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
912 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
916 Var_UpdateBootOrder (
917 IN BMM_CALLBACK_DATA
*CallbackData
921 This function update the "DriverOrder" EFI Variable based on
922 BMM Formset's NV map. It then refresh DriverOptionMenu
923 with the new "DriverOrder" list.
925 @param CallbackData The BMM context data.
927 @retval EFI_SUCCESS The function complete successfully.
928 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
929 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
933 Var_UpdateDriverOrder (
934 IN BMM_CALLBACK_DATA
*CallbackData
938 Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable
939 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
942 @param CallbackData The context data for BMM.
944 @return EFI_SUCCESS The function completed successfully.
945 @retval EFI_NOT_FOUND If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.
949 Var_UpdateBBSOption (
950 IN BMM_CALLBACK_DATA
*CallbackData
,
951 IN EFI_FORM_ID FormId
955 Update the Text Mode of Console.
957 @param CallbackData The context data for BMM.
959 @retval EFI_SUCCSS If the Text Mode of Console is updated.
960 @return Other value if the Text Mode of Console is not updated.
965 IN BMM_CALLBACK_DATA
*CallbackData
969 // Following are page create and refresh functions
972 Refresh the global UpdateData structure.
981 Clean up the dynamic opcode at label and form specified by
984 @param LabelId It is both the Form ID and Label ID for
986 @param CallbackData The BMM context data.
992 IN BMM_CALLBACK_DATA
*CallbackData
996 Create a lit of boot option from global BootOptionMenu. It
997 allow user to delete the boot option.
999 @param CallbackData The BMM context data.
1004 IN BMM_CALLBACK_DATA
*CallbackData
1008 Create a lit of driver option from global DriverMenu.
1010 @param CallbackData The BMM context data.
1013 UpdateDrvAddHandlePage (
1014 IN BMM_CALLBACK_DATA
*CallbackData
1018 Create a lit of driver option from global DriverOptionMenu. It
1019 allow user to delete the driver option.
1021 @param CallbackData The BMM context data.
1025 IN BMM_CALLBACK_DATA
*CallbackData
1029 Prepare the page to allow user to add description for a Driver Option.
1031 @param CallbackData The BMM context data.
1034 UpdateDriverAddHandleDescPage (
1035 IN BMM_CALLBACK_DATA
*CallbackData
1039 Dispatch the correct update page function to call based on the UpdatePageId.
1041 @param UpdatePageId The form ID.
1042 @param CallbackData The BMM context data.
1046 IN UINT16 UpdatePageId
,
1047 IN BMM_CALLBACK_DATA
*CallbackData
1051 Create the dynamic page to allow user to set the "BootNext" vaule.
1053 @param CallbackData The BMM context data.
1056 UpdateBootNextPage (
1057 IN BMM_CALLBACK_DATA
*CallbackData
1061 Create the dynamic page to allow user to set the "TimeOut" vaule.
1063 @param CallbackData The BMM context data.
1067 IN BMM_CALLBACK_DATA
*CallbackData
1071 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1072 Parity, Stop Bits, Terminal Type.
1074 @param CallbackData The BMM context data.
1077 UpdateTerminalPage (
1078 IN BMM_CALLBACK_DATA
*CallbackData
1082 Refresh the text mode page
1084 @param CallbackData The BMM context data.
1088 IN BMM_CALLBACK_DATA
*CallbackData
1092 Create a list of Goto Opcode for all terminal devices logged
1093 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1095 @param CallbackData The BMM context data.
1099 IN BMM_CALLBACK_DATA
*CallbackData
1103 Create a dynamic page so that Legacy Device boot order
1104 can be set for specified device type.
1106 @param UpdatePageId The form ID. It also spefies the legacy device type.
1107 @param CallbackData The BMM context data.
1110 UpdateSetLegacyDeviceOrderPage (
1111 IN UINT16 UpdatePageId
,
1112 IN BMM_CALLBACK_DATA
*CallbackData
1117 Function opens and returns a file handle to the root directory of a volume.
1119 @param DeviceHandle A handle for a device
1120 @return A valid file handle or NULL is returned
1124 IN EFI_HANDLE DeviceHandle
1128 Function gets the file system information from an open file descriptor,
1129 and stores it in a buffer allocated from pool.
1131 @param FHand The file handle.
1133 @return A pointer to a buffer with file information.
1134 NULL is returned if failed to get Vaolume Label Info.
1136 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1137 EfiLibFileSystemVolumeLabelInfo (
1138 IN EFI_FILE_HANDLE FHand
1143 Function gets the file information from an open file descriptor, and stores it
1144 in a buffer allocated from pool.
1146 @param FHand File Handle.
1148 @return A pointer to a buffer with file information or NULL is returned
1153 IN EFI_FILE_HANDLE FHand
1157 Adjusts the size of a previously allocated buffer.
1159 @param OldPool A pointer to the buffer whose size is being adjusted.
1160 @param OldSize The size of the current buffer.
1161 @param NewSize The size of the new buffer.
1163 @return The newly allocated buffer. if NULL, allocation failed.
1174 Function deletes the variable specified by VarName and VarGuid.
1177 @param VarName A Null-terminated Unicode string that is
1178 the name of the vendor's variable.
1180 @param VarGuid A unique identifier for the vendor.
1182 @retval EFI_SUCCESS The variable was found and removed
1183 @retval EFI_UNSUPPORTED The variable store was inaccessible
1184 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1185 @retval EFI_NOT_FOUND The variable was not found
1189 EfiLibDeleteVariable (
1191 IN EFI_GUID
*VarGuid
1197 @param Src The source.
1199 @return A new string which is duplicated copy of the source.
1200 @retval NULL If there is not enough memory.
1209 Function is used to determine the number of device path instances
1210 that exist in a device path.
1213 @param DevicePath A pointer to a device path data structure.
1215 @return This function counts and returns the number of device path instances
1220 EfiDevicePathInstanceCount (
1221 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1225 Create string tokens for a menu from its help strings and display strings
1228 @param CallbackData The BMM context data.
1229 @param HiiHandle Hii Handle of the package to be updated.
1230 @param MenuOption The Menu whose string tokens need to be created
1232 @retval EFI_SUCCESS string tokens created successfully
1233 @retval others contain some errors
1237 CreateMenuStringToken (
1238 IN BMM_CALLBACK_DATA
*CallbackData
,
1239 IN EFI_HII_HANDLE HiiHandle
,
1240 IN BM_MENU_OPTION
*MenuOption
1244 Get a string from the Data Hub record based on
1247 @param DevPath The device Path.
1249 @return A string located from the Data Hub records based on
1251 @retval NULL If failed to get the String from Data Hub.
1255 EfiLibStrFromDatahub (
1256 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1260 Initialize the Boot Maintenance Utitliy.
1262 @retval EFI_SUCCESS utility ended successfully.
1263 @retval others contain some errors.
1272 Start boot maintenance manager
1274 @retval EFI_SUCCESS If BMM is invoked successfully.
1275 @return Other value if BMM return unsuccessfully.
1284 Intialize all the string depositories.
1288 InitializeStringDepository (
1293 Fetch a usable string node from the string depository and return the string token.
1296 @param CallbackData The BMM context data.
1297 @param StringDepository Pointer of the string depository.
1299 @retval EFI_STRING_ID String token.
1303 GetStringTokenFromDepository (
1304 IN BMM_CALLBACK_DATA
*CallbackData
,
1305 IN STRING_DEPOSITORY
*StringDepository
1309 Reclaim string depositories by moving the current node pointer to list head..
1312 ReclaimStringDepository (
1317 Release resource for all the string depositories.
1321 CleanUpStringDepository (
1326 Function handling request to apply changes for BMM pages.
1328 @param Private Pointer to callback data buffer.
1329 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1330 @param FormId ID of the form which has sent the request to apply change.
1332 @retval EFI_SUCCESS Change successfully applied.
1333 @retval Other Error occurs while trying to apply changes.
1337 ApplyChangeHandler (
1338 IN BMM_CALLBACK_DATA
*Private
,
1339 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1340 IN EFI_FORM_ID FormId
1344 Discard all changes done to the BMM pages such as Boot Order change,
1345 Driver order change.
1347 @param Private The BMM context data.
1348 @param CurrentFakeNVMap The current Fack NV Map.
1352 DiscardChangeHandler (
1353 IN BMM_CALLBACK_DATA
*Private
,
1354 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1358 Dispatch the display to the next page based on NewPageId.
1360 @param Private The BMM context data.
1361 @param NewPageId The original page ID.
1366 BMM_CALLBACK_DATA
*Private
,
1371 Boot a file selected by user at File Expoloer of BMM.
1373 @param FileContext The file context data, which contains the device path
1374 of the file to be boot from.
1376 @retval EFI_SUCCESS The function completed successfull.
1377 @return Other value if the boot from the file fails.
1382 IN BM_FILE_CONTEXT
*FileContext
1386 Update the file explower page with the refershed file system.
1389 @param CallbackData BMM context data
1390 @param KeyValue Key value to identify the type of data to expect.
1392 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1393 @retval FALSE Indicate that there is no need to exit file explorer.
1397 UpdateFileExplorer (
1398 IN BMM_CALLBACK_DATA
*CallbackData
,
1403 This function processes the results of changes in configuration.
1404 When user select a interactive opcode, this callback will be triggered.
1405 Based on the Question(QuestionId) that triggers the callback, the corresponding
1406 actions is performed. It handles:
1408 1) the addition of boot option.
1409 2) the addition of driver option.
1410 3) exit from file browser
1411 4) update of file content if a dir is selected.
1412 5) boot the file if a file is selected in "boot from file"
1415 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1416 @param Action Specifies the type of action taken by the browser.
1417 @param QuestionId A unique value which is sent to the original exporting driver
1418 so that it can identify the type of data to expect.
1419 @param Type The type of value for the question.
1420 @param Value A pointer to the data being sent to the original exporting driver.
1421 @param ActionRequest On return, points to the action requested by the callback function.
1423 @retval EFI_SUCCESS The callback successfully handled the action.
1424 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1425 @retval EFI_DEVICE_ERROR The variable could not be saved.
1426 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1431 FileExplorerCallback (
1432 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1433 IN EFI_BROWSER_ACTION Action
,
1434 IN EFI_QUESTION_ID QuestionId
,
1436 IN EFI_IFR_TYPE_VALUE
*Value
,
1437 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1441 This function applies changes in a driver's configuration.
1442 Input is a Configuration, which has the routing data for this
1443 driver followed by name / value configuration pairs. The driver
1444 must apply those pairs to its configurable storage. If the
1445 driver's configuration is stored in a linear block of data
1446 and the driver's name / value pairs are in <BlockConfig>
1447 format, it may use the ConfigToBlock helper function (above) to
1448 simplify the job. Currently not implemented.
1450 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1451 @param[in] Configuration A null-terminated Unicode string in
1452 <ConfigString> format.
1453 @param[out] Progress A pointer to a string filled in with the
1454 offset of the most recent '&' before the
1455 first failing name / value pair (or the
1456 beginn ing of the string if the failure
1457 is in the first name / value pair) or
1458 the terminating NULL if all was
1461 @retval EFI_SUCCESS The results have been distributed or are
1462 awaiting distribution.
1463 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1464 parts of the results that must be
1465 stored awaiting possible future
1467 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1468 Results parameter would result
1469 in this type of error.
1470 @retval EFI_NOT_FOUND Target for the specified routing data
1475 FileExplorerRouteConfig (
1476 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1477 IN CONST EFI_STRING Configuration
,
1478 OUT EFI_STRING
*Progress
1482 Dispatch BMM formset and FileExplorer formset.
1485 @param CallbackData The BMM context data.
1487 @retval EFI_SUCCESS If function complete successfully.
1488 @return Other value if the Setup Browser process BMM's pages and
1489 return unsuccessfully.
1494 IN BMM_CALLBACK_DATA
*CallbackData
1498 Function returns the value of the specified variable.
1500 @param Name A Null-terminated Unicode string that is
1501 the name of the vendor's variable.
1502 @param VendorGuid A unique identifier for the vendor.
1504 @return The payload of the variable.
1505 @retval NULL If the variable can't be read.
1511 IN EFI_GUID
*VendorGuid
1515 Get option number according to Boot#### and BootOrder variable.
1516 The value is saved as #### + 1.
1518 @param CallbackData The BMM context data.
1522 IN BMM_CALLBACK_DATA
*CallbackData
1526 Get driver option order from globalc DriverOptionMenu.
1528 @param CallbackData The BMM context data.
1533 IN BMM_CALLBACK_DATA
*CallbackData
1537 Intall BootMaint and FileExplorer HiiPackages.
1546 Remvoe the intalled BootMaint and FileExplorer HiiPackages.
1555 According to LegacyDevOrder variable to get legacy FD\HD\CD\NET\BEV
1558 @param CallbackData The BMM context data.
1561 GetLegacyDeviceOrder (
1562 IN BMM_CALLBACK_DATA
*CallbackData
1567 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1568 in BMM_FAKE_NV_DATA structure.
1570 @param CallbackData The BMM context data.
1575 IN BMM_CALLBACK_DATA
*CallbackData
1580 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1581 in BMM_FAKE_NV_DATA structure.
1583 @param CallbackData The BMM context data.
1587 GetConsoleOutCheck (
1588 IN BMM_CALLBACK_DATA
*CallbackData
1593 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1594 in BMM_FAKE_NV_DATA structure.
1596 @param CallbackData The BMM context data.
1600 GetConsoleErrCheck (
1601 IN BMM_CALLBACK_DATA
*CallbackData
1606 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1607 to BMM_FAKE_NV_DATA structure.
1609 @param CallbackData The BMM context data.
1613 GetTerminalAttribute (
1614 IN BMM_CALLBACK_DATA
*CallbackData
1619 Find the first instance of this Protocol
1620 in the system and return it's interface.
1623 @param ProtocolGuid Provides the protocol to search for
1624 @param Interface On return, a pointer to the first interface
1625 that matches ProtocolGuid
1627 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1628 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1632 EfiLibLocateProtocol (
1633 IN EFI_GUID
*ProtocolGuid
,
1634 OUT VOID
**Interface
1638 // Global variable in this program (defined in data.c)
1640 extern BM_MENU_OPTION BootOptionMenu
;
1641 extern BM_MENU_OPTION DriverOptionMenu
;
1642 extern BM_MENU_OPTION FsOptionMenu
;
1643 extern BM_MENU_OPTION ConsoleInpMenu
;
1644 extern BM_MENU_OPTION ConsoleOutMenu
;
1645 extern BM_MENU_OPTION ConsoleErrMenu
;
1646 extern BM_MENU_OPTION DirectoryMenu
;
1647 extern BM_MENU_OPTION DriverMenu
;
1648 extern BM_MENU_OPTION TerminalMenu
;
1649 extern BM_MENU_OPTION LegacyFDMenu
;
1650 extern BM_MENU_OPTION LegacyHDMenu
;
1651 extern BM_MENU_OPTION LegacyCDMenu
;
1652 extern BM_MENU_OPTION LegacyNETMenu
;
1653 extern BM_MENU_OPTION LegacyBEVMenu
;
1654 extern UINT16 TerminalType
[];
1655 extern COM_ATTR BaudRateList
[19];
1656 extern COM_ATTR DataBitsList
[4];
1657 extern COM_ATTR ParityList
[5];
1658 extern COM_ATTR StopBitsList
[3];
1659 extern EFI_GUID TerminalTypeGuid
[4];
1660 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1661 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1662 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1663 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1664 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1665 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1666 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1667 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1668 extern UINT16 mFlowControlType
[2];
1669 extern UINT32 mFlowControlValue
[2];
1671 // Shared IFR form update data
1673 extern VOID
*mStartOpCodeHandle
;
1674 extern VOID
*mEndOpCodeHandle
;
1675 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1676 extern EFI_IFR_GUID_LABEL
*mEndLabel
;