2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #define _BOOT_MAINT_H_
13 #include "BBSsupport.h"
15 #include "FrontPage.h"
18 // Constants which are variable names used to access variables
20 #define VAR_CON_OUT_MODE L"ConOutMode"
25 #define STR_FLOPPY L"Floppy Drive #%02x"
26 #define STR_HARDDISK L"HardDisk Drive #%02x"
27 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
28 #define STR_NET L"NET Drive #%02x"
29 #define STR_BEV L"BEV Drive #%02x"
30 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
31 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
32 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
33 #define STR_NET_HELP L"NET Drive #%02x"
34 #define STR_BEV_HELP L"BEV Drive #%02x"
36 extern CHAR16 mFileExplorerStorageName
[];
37 extern CHAR16 mBootMaintStorageName
[];
39 // These are the VFR compiler generated data representing our VFR data.
45 // Below are the number of options in Baudrate, Databits,
46 // Parity and Stopbits selection for serial ports.
48 #define BM_COM_ATTR_BUADRATE 19
49 #define BM_COM_ATTR_DATABITS 4
50 #define BM_COM_ATTR_PARITY 5
51 #define BM_COM_ATTR_STOPBITS 3
54 // Callback function helper
56 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
57 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
59 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
62 // Enumeration type definition
64 typedef enum _TYPE_OF_TERMINAL
{
65 TerminalTypePcAnsi
= 0,
67 TerminalTypeVt100Plus
,
71 typedef enum _FILE_EXPLORER_STATE
{
72 FileExplorerStateInActive
= 0,
73 FileExplorerStateBootFromFile
,
74 FileExplorerStateAddBootOption
,
75 FileExplorerStateAddDriverOptionState
,
76 FileExplorerStateUnknown
77 } FILE_EXPLORER_STATE
;
79 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
80 FileExplorerDisplayFileSystem
,
81 FileExplorerDisplayDirectory
,
82 FileExplorerDisplayUnknown
83 } FILE_EXPLORER_DISPLAY_CONTEXT
;
86 // All of the signatures that will be used in list structure
88 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
89 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
90 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
91 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
92 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
93 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
94 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
96 #define BM_LOAD_CONTEXT_SELECT 0x0
97 #define BM_CONSOLE_CONTEXT_SELECT 0x1
98 #define BM_FILE_CONTEXT_SELECT 0x2
99 #define BM_HANDLE_CONTEXT_SELECT 0x3
100 #define BM_TERMINAL_CONTEXT_SELECT 0x5
102 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
103 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
104 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
105 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
108 // Buffer size for update data
110 #define UPDATE_DATA_SIZE 0x100000
113 // Namespace of callback keys used in display and file system navigation
115 #define MAX_BBS_OFFSET 0xE000
116 #define NET_OPTION_OFFSET 0xD800
117 #define BEV_OPTION_OFFSET 0xD000
118 #define FD_OPTION_OFFSET 0xC000
119 #define HD_OPTION_OFFSET 0xB000
120 #define CD_OPTION_OFFSET 0xA000
121 #define FILE_OPTION_GOTO_OFFSET 0xC000
122 #define FILE_OPTION_OFFSET 0x8000
123 #define FILE_OPTION_MASK 0x3FFF
124 #define HANDLE_OPTION_OFFSET 0x7000
125 #define CONSOLE_OPTION_OFFSET 0x6000
126 #define TERMINAL_OPTION_OFFSET 0x5000
127 #define CONFIG_OPTION_OFFSET 0x1200
128 #define KEY_VALUE_OFFSET 0x1100
129 #define FORM_ID_OFFSET 0x1000
132 // VarOffset that will be used to create question
133 // all these values are computed from the structure
136 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
139 // Question Id of Zero is invalid, so add an offset to it
141 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
143 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
144 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
145 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
146 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
147 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
148 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
149 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
150 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
151 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
152 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
153 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
154 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
155 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
156 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
157 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
158 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
159 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
160 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
161 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
162 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
163 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
164 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
165 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
166 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
167 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
168 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
169 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
170 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
171 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
172 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
173 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
174 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
175 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
176 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
177 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
178 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
179 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
180 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
181 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
182 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
183 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
185 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
186 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
187 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
188 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
189 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
190 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
191 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
192 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
193 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
194 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
195 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
196 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
197 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
198 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
199 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
200 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
201 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
202 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
203 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
204 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
205 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
206 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
207 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
208 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
209 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
210 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
211 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
212 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
213 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
214 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
215 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
216 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
217 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
218 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
219 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
220 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
221 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
222 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
223 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
224 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
225 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
227 #define STRING_DEPOSITORY_NUMBER 8
230 /// Serial Ports attributes, first one is the value for
231 /// return from callback function, stringtoken is used to
232 /// display the value properly
257 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
258 } BM_TERMINAL_CONTEXT
;
262 BOOLEAN LoadOptionModified
;
267 BOOLEAN ForceReconnect
;
268 UINTN OptionalDataSize
;
270 UINTN LoadOptionSize
;
274 UINT16 FilePathListLength
;
276 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
287 } BM_LEGACY_DEVICE_CONTEXT
;
295 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
296 } BM_CONSOLE_CONTEXT
;
305 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
306 EFI_FILE_HANDLE FHandle
;
308 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
312 BOOLEAN IsRemovableMedia
;
314 BOOLEAN IsBootLegacy
;
319 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
332 UINT16
*DisplayString
;
334 EFI_STRING_ID DisplayStringToken
;
335 EFI_STRING_ID HelpStringToken
;
336 UINTN ContextSelection
;
337 VOID
*VariableContext
;
342 // Shared callback data.
346 BM_MENU_ENTRY
*MenuEntry
;
347 BM_HANDLE_CONTEXT
*HandleContext
;
348 BM_FILE_CONTEXT
*FileContext
;
349 BM_LOAD_CONTEXT
*LoadContext
;
350 BM_TERMINAL_CONTEXT
*TerminalContext
;
351 UINTN CurrentTerminal
;
355 // BMM main formset callback data.
357 EFI_HII_HANDLE BmmHiiHandle
;
358 EFI_HANDLE BmmDriverHandle
;
359 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
360 EFI_FORM_ID BmmCurrentPageId
;
361 EFI_FORM_ID BmmPreviousPageId
;
362 BOOLEAN BmmAskSaveOrNot
;
363 BMM_FAKE_NV_DATA BmmFakeNvData
;
364 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
367 // File explorer formset callback data.
369 EFI_HII_HANDLE FeHiiHandle
;
370 EFI_HANDLE FeDriverHandle
;
371 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
372 FILE_EXPLORER_STATE FeCurrentState
;
373 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
374 FILE_EXPLORER_NV_DATA FeFakeNvData
;
377 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
379 struct _STRING_LIST_NODE
{
380 EFI_STRING_ID StringToken
;
381 STRING_LIST_NODE
*Next
;
384 typedef struct _STRING_DEPOSITORY
{
385 UINTN TotalNodeNumber
;
386 STRING_LIST_NODE
*CurrentNode
;
387 STRING_LIST_NODE
*ListHead
;
393 // For initializing File System menu
397 This function build the FsOptionMenu list which records all
398 available file system in the system. They includes all instances
399 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
400 and all type of legacy boot device.
402 @param CallbackData BMM context data
404 @retval EFI_SUCCESS Success find the file system
405 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
409 BOpt_FindFileSystem (
410 IN BMM_CALLBACK_DATA
*CallbackData
414 Find files under current directory
415 All files and sub-directories in current directory
416 will be stored in DirectoryMenu for future use.
418 @param CallbackData The BMM context data.
419 @param MenuEntry The Menu Entry.
421 @retval EFI_SUCCESS Get files from current dir successfully.
422 @return Other value if can't get files from current dir.
427 IN BMM_CALLBACK_DATA
*CallbackData
,
428 IN BM_MENU_ENTRY
*MenuEntry
433 Find drivers that will be added as Driver#### variables from handles
434 in current system environment
435 All valid handles in the system except those consume SimpleFs, LoadFile
436 are stored in DriverMenu for future use.
438 @retval EFI_SUCCESS The function complets successfully.
439 @return Other value if failed to build the DriverMenu.
449 Build the BootOptionMenu according to BootOrder Variable.
450 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
452 @param CallbackData The BMM context data.
454 @return The number of the Var Boot####.
458 BOpt_GetBootOptions (
459 IN BMM_CALLBACK_DATA
*CallbackData
464 Build up all DriverOptionMenu
466 @param CallbackData The BMM context data.
468 @return EFI_SUCESS The functin completes successfully.
469 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
474 BOpt_GetDriverOptions (
475 IN BMM_CALLBACK_DATA
*CallbackData
480 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
482 @retval EFI_SUCCESS The function complete successfully.
483 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
487 BOpt_GetLegacyOptions (
492 Free out resouce allocated from Legacy Boot Options.
496 BOpt_FreeLegacyOptions (
501 Free resources allocated in Allocate Rountine.
503 @param FreeMenu Menu to be freed
508 BM_MENU_OPTION
*FreeMenu
514 Append file name to existing file name.
516 @param Str1 The existing file name
517 @param Str2 The file name to be appended
519 @return Allocate a new string to hold the appended result.
520 Caller is responsible to free the returned string.
524 BOpt_AppendFileName (
531 Check whether current FileName point to a valid
534 @param FileName File need to be checked.
536 @retval TRUE Is Efi Image
537 @retval FALSE Not a valid Efi Image
541 BOpt_IsEfiImageName (
548 Get the Option Number that has not been allocated for use.
550 @param Type The type of Option.
552 @return The available Option Number.
556 BOpt_GetOptionNumber (
562 Get the Option Number for Boot#### that does not used.
564 @return The available Option Number.
568 BOpt_GetBootOptionNumber (
574 Get the Option Number for Driver#### that does not used.
576 @return The unused Option Number.
580 BOpt_GetDriverOptionNumber (
585 Create a menu entry give a Menu type.
587 @param MenuType The Menu type to be created.
590 @retval NULL If failed to create the menu.
595 BOpt_CreateMenuEntry (
600 Free up all resource allocated for a BM_MENU_ENTRY.
602 @param MenuEntry A pointer to BM_MENU_ENTRY.
606 BOpt_DestroyMenuEntry (
607 BM_MENU_ENTRY
*MenuEntry
611 Get the Menu Entry from the list in Menu Entry List.
613 If MenuNumber is great or equal to the number of Menu
614 Entry in the list, then ASSERT.
616 @param MenuOption The Menu Entry List to read the menu entry.
617 @param MenuNumber The index of Menu Entry.
619 @return The Menu Entry.
624 BM_MENU_OPTION
*MenuOption
,
629 // Locate all serial io devices for console
632 Build a list containing all serial devices.
634 @retval EFI_SUCCESS The function complete successfully.
635 @retval EFI_UNSUPPORTED No serial ports present.
644 // Initializing Console menu
647 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
649 @retval EFI_SUCCESS The function always complete successfully.
658 // Get current mode information
661 Get mode number according to column and row
663 @param CallbackData The BMM context data.
667 IN BMM_CALLBACK_DATA
*CallbackData
671 // Cleaning up console menu
674 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
676 @retval EFI_SUCCESS The function always complete successfully.
685 Update the multi-instance device path of Terminal Device based on
686 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
687 device path in the Terminal Device in TerminalMenu is also updated.
689 @param DevicePath The multi-instance device path.
690 @param ChangeTerminal TRUE, then device path in the Terminal Device
691 in TerminalMenu is also updated; FALSE, no update.
693 @return EFI_SUCCESS The function completes successfully.
697 ChangeTerminalDevicePath (
698 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
699 IN BOOLEAN ChangeTerminal
703 // Variable operation by menu selection
706 This function create a currently loaded Boot Option from
707 the BMM. It then appends this Boot Option to the end of
708 the "BootOrder" list. It also append this Boot Opotion to the end
711 @param CallbackData The BMM context data.
712 @param NvRamMap The file explorer formset internal state.
714 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
715 @retval EFI_SUCCESS If function completes successfully.
719 Var_UpdateBootOption (
720 IN BMM_CALLBACK_DATA
*CallbackData
,
721 IN FILE_EXPLORER_NV_DATA
*NvRamMap
725 Delete Boot Option that represent a Deleted state in BootOptionMenu.
726 After deleting this boot option, call Var_ChangeBootOrder to
727 make sure BootOrder is in valid state.
729 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
730 BM_LOAD_CONTEXT marked for deletion is deleted
731 @return Others If failed to update the "BootOrder" variable after deletion.
740 After any operation on Boot####, there will be a discrepancy in BootOrder.
741 Since some are missing but in BootOrder, while some are present but are
742 not reflected by BootOrder. Then a function rebuild BootOrder from
743 scratch by content from BootOptionMenu is needed.
745 @retval EFI_SUCCESS The boot order is updated successfully.
746 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
750 Var_ChangeBootOrder (
755 This function create a currently loaded Drive Option from
756 the BMM. It then appends this Driver Option to the end of
757 the "DriverOrder" list. It append this Driver Opotion to the end
760 @param CallbackData The BMM context data.
761 @param HiiHandle The HII handle associated with the BMM formset.
762 @param DescriptionData The description of this driver option.
763 @param OptionalData The optional load option.
764 @param ForceReconnect If to force reconnect.
766 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
767 @retval EFI_SUCCESS If function completes successfully.
771 Var_UpdateDriverOption (
772 IN BMM_CALLBACK_DATA
*CallbackData
,
773 IN EFI_HII_HANDLE HiiHandle
,
774 IN UINT16
*DescriptionData
,
775 IN UINT16
*OptionalData
,
776 IN UINT8 ForceReconnect
780 Delete Load Option that represent a Deleted state in BootOptionMenu.
781 After deleting this Driver option, call Var_ChangeDriverOrder to
782 make sure DriverOrder is in valid state.
784 @retval EFI_SUCCESS Load Option is successfully updated.
785 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
790 Var_DelDriverOption (
795 After any operation on Driver####, there will be a discrepancy in
796 DriverOrder. Since some are missing but in DriverOrder, while some
797 are present but are not reflected by DriverOrder. Then a function
798 rebuild DriverOrder from scratch by content from DriverOptionMenu is
801 @retval EFI_SUCCESS The driver order is updated successfully.
802 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
806 Var_ChangeDriverOrder (
811 This function delete and build multi-instance device path ConIn
814 @retval EFI_SUCCESS The function complete successfully.
815 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
818 Var_UpdateConsoleInpOption (
823 This function delete and build multi-instance device path ConOut console device.
825 @retval EFI_SUCCESS The function complete successfully.
826 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
829 Var_UpdateConsoleOutOption (
834 This function delete and build multi-instance device path ErrOut console device.
836 @retval EFI_SUCCESS The function complete successfully.
837 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
840 Var_UpdateErrorOutOption (
846 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
847 this EFI Variable is deleted.
848 It also update the BMM context data specified the "BootNext" value.
850 @param CallbackData The BMM context data.
852 @retval EFI_SUCCESS The function complete successfully.
853 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
858 IN BMM_CALLBACK_DATA
*CallbackData
862 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
863 BootOptionMenu with the new "BootOrder" list.
865 @param CallbackData The BMM context data.
867 @retval EFI_SUCCESS The function complete successfully.
868 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
869 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
873 Var_UpdateBootOrder (
874 IN BMM_CALLBACK_DATA
*CallbackData
878 This function update the "DriverOrder" EFI Variable based on
879 BMM Formset's NV map. It then refresh DriverOptionMenu
880 with the new "DriverOrder" list.
882 @param CallbackData The BMM context data.
884 @retval EFI_SUCCESS The function complete successfully.
885 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
886 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
890 Var_UpdateDriverOrder (
891 IN BMM_CALLBACK_DATA
*CallbackData
895 Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable
896 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
899 @param CallbackData The context data for BMM.
900 @param FormId The form id.
902 @return EFI_SUCCESS The function completed successfully.
903 @retval EFI_NOT_FOUND If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.
907 Var_UpdateBBSOption (
908 IN BMM_CALLBACK_DATA
*CallbackData
,
909 IN EFI_FORM_ID FormId
913 Update the Text Mode of Console.
915 @param CallbackData The context data for BMM.
917 @retval EFI_SUCCSS If the Text Mode of Console is updated.
918 @return Other value if the Text Mode of Console is not updated.
923 IN BMM_CALLBACK_DATA
*CallbackData
927 // Following are page create and refresh functions
930 Refresh the global UpdateData structure.
939 Clean up the dynamic opcode at label and form specified by
942 @param LabelId It is both the Form ID and Label ID for
944 @param CallbackData The BMM context data.
950 IN BMM_CALLBACK_DATA
*CallbackData
954 Create a lit of boot option from global BootOptionMenu. It
955 allow user to delete the boot option.
957 @param CallbackData The BMM context data.
962 IN BMM_CALLBACK_DATA
*CallbackData
966 Create a lit of driver option from global DriverMenu.
968 @param CallbackData The BMM context data.
971 UpdateDrvAddHandlePage (
972 IN BMM_CALLBACK_DATA
*CallbackData
976 Create a lit of driver option from global DriverOptionMenu. It
977 allow user to delete the driver option.
979 @param CallbackData The BMM context data.
983 IN BMM_CALLBACK_DATA
*CallbackData
987 Prepare the page to allow user to add description for a Driver Option.
989 @param CallbackData The BMM context data.
992 UpdateDriverAddHandleDescPage (
993 IN BMM_CALLBACK_DATA
*CallbackData
997 Dispatch the correct update page function to call based on the UpdatePageId.
999 @param UpdatePageId The form ID.
1000 @param CallbackData The BMM context data.
1004 IN UINT16 UpdatePageId
,
1005 IN BMM_CALLBACK_DATA
*CallbackData
1009 Create the dynamic page to allow user to set the "BootNext" vaule.
1011 @param CallbackData The BMM context data.
1014 UpdateBootNextPage (
1015 IN BMM_CALLBACK_DATA
*CallbackData
1019 Create the dynamic page to allow user to set the "TimeOut" vaule.
1021 @param CallbackData The BMM context data.
1025 IN BMM_CALLBACK_DATA
*CallbackData
1029 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1030 Parity, Stop Bits, Terminal Type.
1032 @param CallbackData The BMM context data.
1035 UpdateTerminalPage (
1036 IN BMM_CALLBACK_DATA
*CallbackData
1040 Refresh the text mode page
1042 @param CallbackData The BMM context data.
1046 IN BMM_CALLBACK_DATA
*CallbackData
1050 Create a list of Goto Opcode for all terminal devices logged
1051 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1053 @param CallbackData The BMM context data.
1057 IN BMM_CALLBACK_DATA
*CallbackData
1061 Create a dynamic page so that Legacy Device boot order
1062 can be set for specified device type.
1064 @param UpdatePageId The form ID. It also spefies the legacy device type.
1065 @param CallbackData The BMM context data.
1068 UpdateSetLegacyDeviceOrderPage (
1069 IN UINT16 UpdatePageId
,
1070 IN BMM_CALLBACK_DATA
*CallbackData
1075 Function opens and returns a file handle to the root directory of a volume.
1077 @param DeviceHandle A handle for a device
1078 @return A valid file handle or NULL is returned
1082 IN EFI_HANDLE DeviceHandle
1086 Function gets the file system information from an open file descriptor,
1087 and stores it in a buffer allocated from pool.
1089 @param FHand The file handle.
1091 @return A pointer to a buffer with file information.
1092 NULL is returned if failed to get Vaolume Label Info.
1094 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1095 EfiLibFileSystemVolumeLabelInfo (
1096 IN EFI_FILE_HANDLE FHand
1101 Function gets the file information from an open file descriptor, and stores it
1102 in a buffer allocated from pool.
1104 @param FHand File Handle.
1106 @return A pointer to a buffer with file information or NULL is returned
1111 IN EFI_FILE_HANDLE FHand
1116 Function deletes the variable specified by VarName and VarGuid.
1119 @param VarName A Null-terminated Unicode string that is
1120 the name of the vendor's variable.
1122 @param VarGuid A unique identifier for the vendor.
1124 @retval EFI_SUCCESS The variable was found and removed
1125 @retval EFI_UNSUPPORTED The variable store was inaccessible
1126 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1127 @retval EFI_NOT_FOUND The variable was not found
1131 EfiLibDeleteVariable (
1133 IN EFI_GUID
*VarGuid
1139 @param Src The source.
1141 @return A new string which is duplicated copy of the source.
1142 @retval NULL If there is not enough memory.
1151 Function is used to determine the number of device path instances
1152 that exist in a device path.
1155 @param DevicePath A pointer to a device path data structure.
1157 @return This function counts and returns the number of device path instances
1162 EfiDevicePathInstanceCount (
1163 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1167 Create string tokens for a menu from its help strings and display strings
1170 @param CallbackData The BMM context data.
1171 @param HiiHandle Hii Handle of the package to be updated.
1172 @param MenuOption The Menu whose string tokens need to be created
1174 @retval EFI_SUCCESS string tokens created successfully
1175 @retval others contain some errors
1179 CreateMenuStringToken (
1180 IN BMM_CALLBACK_DATA
*CallbackData
,
1181 IN EFI_HII_HANDLE HiiHandle
,
1182 IN BM_MENU_OPTION
*MenuOption
1186 Get a string from the Data Hub record based on
1189 @param DevPath The device Path.
1191 @return A string located from the Data Hub records based on
1193 @retval NULL If failed to get the String from Data Hub.
1197 EfiLibStrFromDatahub (
1198 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1202 Initialize the Boot Maintenance Utitliy.
1204 @retval EFI_SUCCESS utility ended successfully.
1205 @retval others contain some errors.
1214 Start boot maintenance manager
1216 @retval EFI_SUCCESS If BMM is invoked successfully.
1217 @return Other value if BMM return unsuccessfully.
1226 Intialize all the string depositories.
1230 InitializeStringDepository (
1235 Fetch a usable string node from the string depository and return the string token.
1238 @param CallbackData The BMM context data.
1239 @param StringDepository Pointer of the string depository.
1241 @retval EFI_STRING_ID String token.
1245 GetStringTokenFromDepository (
1246 IN BMM_CALLBACK_DATA
*CallbackData
,
1247 IN STRING_DEPOSITORY
*StringDepository
1251 Reclaim string depositories by moving the current node pointer to list head..
1254 ReclaimStringDepository (
1259 Release resource for all the string depositories.
1263 CleanUpStringDepository (
1268 Function handling request to apply changes for BMM pages.
1270 @param Private Pointer to callback data buffer.
1271 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1272 @param FormId ID of the form which has sent the request to apply change.
1274 @retval EFI_SUCCESS Change successfully applied.
1275 @retval Other Error occurs while trying to apply changes.
1279 ApplyChangeHandler (
1280 IN BMM_CALLBACK_DATA
*Private
,
1281 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1282 IN EFI_FORM_ID FormId
1286 Discard all changes done to the BMM pages such as Boot Order change,
1287 Driver order change.
1289 @param Private The BMM context data.
1290 @param CurrentFakeNVMap The current Fack NV Map.
1294 DiscardChangeHandler (
1295 IN BMM_CALLBACK_DATA
*Private
,
1296 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1300 Dispatch the display to the next page based on NewPageId.
1302 @param Private The BMM context data.
1303 @param NewPageId The original page ID.
1308 BMM_CALLBACK_DATA
*Private
,
1313 Boot a file selected by user at File Expoloer of BMM.
1315 @param FileContext The file context data, which contains the device path
1316 of the file to be boot from.
1318 @retval EFI_SUCCESS The function completed successfull.
1319 @return Other value if the boot from the file fails.
1324 IN BM_FILE_CONTEXT
*FileContext
1328 Update the file explower page with the refershed file system.
1331 @param CallbackData BMM context data
1332 @param KeyValue Key value to identify the type of data to expect.
1334 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1335 @retval FALSE Indicate that there is no need to exit file explorer.
1339 UpdateFileExplorer (
1340 IN BMM_CALLBACK_DATA
*CallbackData
,
1345 This function processes the results of changes in configuration.
1346 When user select a interactive opcode, this callback will be triggered.
1347 Based on the Question(QuestionId) that triggers the callback, the corresponding
1348 actions is performed. It handles:
1350 1) the addition of boot option.
1351 2) the addition of driver option.
1352 3) exit from file browser
1353 4) update of file content if a dir is selected.
1354 5) boot the file if a file is selected in "boot from file"
1357 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1358 @param Action Specifies the type of action taken by the browser.
1359 @param QuestionId A unique value which is sent to the original exporting driver
1360 so that it can identify the type of data to expect.
1361 @param Type The type of value for the question.
1362 @param Value A pointer to the data being sent to the original exporting driver.
1363 @param ActionRequest On return, points to the action requested by the callback function.
1365 @retval EFI_SUCCESS The callback successfully handled the action.
1366 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1367 @retval EFI_DEVICE_ERROR The variable could not be saved.
1368 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1373 FileExplorerCallback (
1374 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1375 IN EFI_BROWSER_ACTION Action
,
1376 IN EFI_QUESTION_ID QuestionId
,
1378 IN EFI_IFR_TYPE_VALUE
*Value
,
1379 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1383 This function applies changes in a driver's configuration.
1384 Input is a Configuration, which has the routing data for this
1385 driver followed by name / value configuration pairs. The driver
1386 must apply those pairs to its configurable storage. If the
1387 driver's configuration is stored in a linear block of data
1388 and the driver's name / value pairs are in <BlockConfig>
1389 format, it may use the ConfigToBlock helper function (above) to
1390 simplify the job. Currently not implemented.
1392 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1393 @param[in] Configuration A null-terminated Unicode string in
1394 <ConfigString> format.
1395 @param[out] Progress A pointer to a string filled in with the
1396 offset of the most recent '&' before the
1397 first failing name / value pair (or the
1398 beginn ing of the string if the failure
1399 is in the first name / value pair) or
1400 the terminating NULL if all was
1403 @retval EFI_SUCCESS The results have been distributed or are
1404 awaiting distribution.
1405 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1406 parts of the results that must be
1407 stored awaiting possible future
1409 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1410 Results parameter would result
1411 in this type of error.
1412 @retval EFI_NOT_FOUND Target for the specified routing data
1417 FileExplorerRouteConfig (
1418 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1419 IN CONST EFI_STRING Configuration
,
1420 OUT EFI_STRING
*Progress
1424 Dispatch BMM formset and FileExplorer formset.
1427 @param CallbackData The BMM context data.
1429 @retval EFI_SUCCESS If function complete successfully.
1430 @return Other value if the Setup Browser process BMM's pages and
1431 return unsuccessfully.
1436 IN BMM_CALLBACK_DATA
*CallbackData
1440 Function returns the value of the specified variable.
1442 @param Name A Null-terminated Unicode string that is
1443 the name of the vendor's variable.
1444 @param VendorGuid A unique identifier for the vendor.
1446 @return The payload of the variable.
1447 @retval NULL If the variable can't be read.
1453 IN EFI_GUID
*VendorGuid
1457 Get option number according to Boot#### and BootOrder variable.
1458 The value is saved as #### + 1.
1460 @param CallbackData The BMM context data.
1464 IN BMM_CALLBACK_DATA
*CallbackData
1468 Get driver option order from globalc DriverOptionMenu.
1470 @param CallbackData The BMM context data.
1475 IN BMM_CALLBACK_DATA
*CallbackData
1479 Intall BootMaint and FileExplorer HiiPackages.
1488 Remvoe the intalled BootMaint and FileExplorer HiiPackages.
1497 According to LegacyDevOrder variable to get legacy FD\HD\CD\NET\BEV
1500 @param CallbackData The BMM context data.
1503 GetLegacyDeviceOrder (
1504 IN BMM_CALLBACK_DATA
*CallbackData
1509 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1510 in BMM_FAKE_NV_DATA structure.
1512 @param CallbackData The BMM context data.
1517 IN BMM_CALLBACK_DATA
*CallbackData
1522 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1523 in BMM_FAKE_NV_DATA structure.
1525 @param CallbackData The BMM context data.
1529 GetConsoleOutCheck (
1530 IN BMM_CALLBACK_DATA
*CallbackData
1535 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1536 in BMM_FAKE_NV_DATA structure.
1538 @param CallbackData The BMM context data.
1542 GetConsoleErrCheck (
1543 IN BMM_CALLBACK_DATA
*CallbackData
1548 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1549 to BMM_FAKE_NV_DATA structure.
1551 @param CallbackData The BMM context data.
1555 GetTerminalAttribute (
1556 IN BMM_CALLBACK_DATA
*CallbackData
1561 Find the first instance of this Protocol
1562 in the system and return it's interface.
1565 @param ProtocolGuid Provides the protocol to search for
1566 @param Interface On return, a pointer to the first interface
1567 that matches ProtocolGuid
1569 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1570 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1574 EfiLibLocateProtocol (
1575 IN EFI_GUID
*ProtocolGuid
,
1576 OUT VOID
**Interface
1580 // Global variable in this program (defined in data.c)
1582 extern BM_MENU_OPTION BootOptionMenu
;
1583 extern BM_MENU_OPTION DriverOptionMenu
;
1584 extern BM_MENU_OPTION FsOptionMenu
;
1585 extern BM_MENU_OPTION ConsoleInpMenu
;
1586 extern BM_MENU_OPTION ConsoleOutMenu
;
1587 extern BM_MENU_OPTION ConsoleErrMenu
;
1588 extern BM_MENU_OPTION DirectoryMenu
;
1589 extern BM_MENU_OPTION DriverMenu
;
1590 extern BM_MENU_OPTION TerminalMenu
;
1591 extern BM_MENU_OPTION LegacyFDMenu
;
1592 extern BM_MENU_OPTION LegacyHDMenu
;
1593 extern BM_MENU_OPTION LegacyCDMenu
;
1594 extern BM_MENU_OPTION LegacyNETMenu
;
1595 extern BM_MENU_OPTION LegacyBEVMenu
;
1596 extern UINT16 TerminalType
[];
1597 extern COM_ATTR BaudRateList
[19];
1598 extern COM_ATTR DataBitsList
[4];
1599 extern COM_ATTR ParityList
[5];
1600 extern COM_ATTR StopBitsList
[3];
1601 extern EFI_GUID TerminalTypeGuid
[4];
1602 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1603 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1604 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1605 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1606 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1607 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1608 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1609 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1610 extern UINT16 mFlowControlType
[2];
1611 extern UINT32 mFlowControlValue
[2];
1613 // Shared IFR form update data
1615 extern VOID
*mStartOpCodeHandle
;
1616 extern VOID
*mEndOpCodeHandle
;
1617 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1618 extern EFI_IFR_GUID_LABEL
*mEndLabel
;