2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2018, 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 (
554 Get the Option Number that has not been allocated for use.
556 @param Type The type of Option.
558 @return The available Option Number.
562 BOpt_GetOptionNumber (
568 Get the Option Number for Boot#### that does not used.
570 @return The available Option Number.
574 BOpt_GetBootOptionNumber (
580 Get the Option Number for Driver#### that does not used.
582 @return The unused Option Number.
586 BOpt_GetDriverOptionNumber (
591 Create a menu entry give a Menu type.
593 @param MenuType The Menu type to be created.
596 @retval NULL If failed to create the menu.
601 BOpt_CreateMenuEntry (
606 Free up all resource allocated for a BM_MENU_ENTRY.
608 @param MenuEntry A pointer to BM_MENU_ENTRY.
612 BOpt_DestroyMenuEntry (
613 BM_MENU_ENTRY
*MenuEntry
617 Get the Menu Entry from the list in Menu Entry List.
619 If MenuNumber is great or equal to the number of Menu
620 Entry in the list, then ASSERT.
622 @param MenuOption The Menu Entry List to read the menu entry.
623 @param MenuNumber The index of Menu Entry.
625 @return The Menu Entry.
630 BM_MENU_OPTION
*MenuOption
,
635 // Locate all serial io devices for console
638 Build a list containing all serial devices.
640 @retval EFI_SUCCESS The function complete successfully.
641 @retval EFI_UNSUPPORTED No serial ports present.
650 // Initializing Console menu
653 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
655 @retval EFI_SUCCESS The function always complete successfully.
664 // Get current mode information
667 Get mode number according to column and row
669 @param CallbackData The BMM context data.
673 IN BMM_CALLBACK_DATA
*CallbackData
677 // Cleaning up console menu
680 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
682 @retval EFI_SUCCESS The function always complete successfully.
691 Update the multi-instance device path of Terminal Device based on
692 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
693 device path in the Terminal Device in TerminalMenu is also updated.
695 @param DevicePath The multi-instance device path.
696 @param ChangeTerminal TRUE, then device path in the Terminal Device
697 in TerminalMenu is also updated; FALSE, no update.
699 @return EFI_SUCCESS The function completes successfully.
703 ChangeTerminalDevicePath (
704 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
705 IN BOOLEAN ChangeTerminal
709 // Variable operation by menu selection
712 This function create a currently loaded Boot Option from
713 the BMM. It then appends this Boot Option to the end of
714 the "BootOrder" list. It also append this Boot Opotion to the end
717 @param CallbackData The BMM context data.
718 @param NvRamMap The file explorer formset internal state.
720 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
721 @retval EFI_SUCCESS If function completes successfully.
725 Var_UpdateBootOption (
726 IN BMM_CALLBACK_DATA
*CallbackData
,
727 IN FILE_EXPLORER_NV_DATA
*NvRamMap
731 Delete Boot Option that represent a Deleted state in BootOptionMenu.
732 After deleting this boot option, call Var_ChangeBootOrder to
733 make sure BootOrder is in valid state.
735 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
736 BM_LOAD_CONTEXT marked for deletion is deleted
737 @return Others If failed to update the "BootOrder" variable after deletion.
746 After any operation on Boot####, there will be a discrepancy in BootOrder.
747 Since some are missing but in BootOrder, while some are present but are
748 not reflected by BootOrder. Then a function rebuild BootOrder from
749 scratch by content from BootOptionMenu is needed.
751 @retval EFI_SUCCESS The boot order is updated successfully.
752 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
756 Var_ChangeBootOrder (
761 This function create a currently loaded Drive Option from
762 the BMM. It then appends this Driver Option to the end of
763 the "DriverOrder" list. It append this Driver Opotion to the end
766 @param CallbackData The BMM context data.
767 @param HiiHandle The HII handle associated with the BMM formset.
768 @param DescriptionData The description of this driver option.
769 @param OptionalData The optional load option.
770 @param ForceReconnect If to force reconnect.
772 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
773 @retval EFI_SUCCESS If function completes successfully.
777 Var_UpdateDriverOption (
778 IN BMM_CALLBACK_DATA
*CallbackData
,
779 IN EFI_HII_HANDLE HiiHandle
,
780 IN UINT16
*DescriptionData
,
781 IN UINT16
*OptionalData
,
782 IN UINT8 ForceReconnect
786 Delete Load Option that represent a Deleted state in BootOptionMenu.
787 After deleting this Driver option, call Var_ChangeDriverOrder to
788 make sure DriverOrder is in valid state.
790 @retval EFI_SUCCESS Load Option is successfully updated.
791 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
796 Var_DelDriverOption (
801 After any operation on Driver####, there will be a discrepancy in
802 DriverOrder. Since some are missing but in DriverOrder, while some
803 are present but are not reflected by DriverOrder. Then a function
804 rebuild DriverOrder from scratch by content from DriverOptionMenu is
807 @retval EFI_SUCCESS The driver order is updated successfully.
808 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
812 Var_ChangeDriverOrder (
817 This function delete and build multi-instance device path ConIn
820 @retval EFI_SUCCESS The function complete successfully.
821 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
824 Var_UpdateConsoleInpOption (
829 This function delete and build multi-instance device path ConOut console device.
831 @retval EFI_SUCCESS The function complete successfully.
832 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
835 Var_UpdateConsoleOutOption (
840 This function delete and build multi-instance device path ErrOut console device.
842 @retval EFI_SUCCESS The function complete successfully.
843 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
846 Var_UpdateErrorOutOption (
852 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
853 this EFI Variable is deleted.
854 It also update the BMM context data specified the "BootNext" value.
856 @param CallbackData The BMM context data.
858 @retval EFI_SUCCESS The function complete successfully.
859 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
864 IN BMM_CALLBACK_DATA
*CallbackData
868 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
869 BootOptionMenu with the new "BootOrder" list.
871 @param CallbackData The BMM context data.
873 @retval EFI_SUCCESS The function complete successfully.
874 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
875 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
879 Var_UpdateBootOrder (
880 IN BMM_CALLBACK_DATA
*CallbackData
884 This function update the "DriverOrder" EFI Variable based on
885 BMM Formset's NV map. It then refresh DriverOptionMenu
886 with the new "DriverOrder" list.
888 @param CallbackData The BMM context data.
890 @retval EFI_SUCCESS The function complete successfully.
891 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
892 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
896 Var_UpdateDriverOrder (
897 IN BMM_CALLBACK_DATA
*CallbackData
901 Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable
902 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
905 @param CallbackData The context data for BMM.
906 @param FormId The form id.
908 @return EFI_SUCCESS The function completed successfully.
909 @retval EFI_NOT_FOUND If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.
913 Var_UpdateBBSOption (
914 IN BMM_CALLBACK_DATA
*CallbackData
,
915 IN EFI_FORM_ID FormId
919 Update the Text Mode of Console.
921 @param CallbackData The context data for BMM.
923 @retval EFI_SUCCSS If the Text Mode of Console is updated.
924 @return Other value if the Text Mode of Console is not updated.
929 IN BMM_CALLBACK_DATA
*CallbackData
933 // Following are page create and refresh functions
936 Refresh the global UpdateData structure.
945 Clean up the dynamic opcode at label and form specified by
948 @param LabelId It is both the Form ID and Label ID for
950 @param CallbackData The BMM context data.
956 IN BMM_CALLBACK_DATA
*CallbackData
960 Create a lit of boot option from global BootOptionMenu. It
961 allow user to delete the boot option.
963 @param CallbackData The BMM context data.
968 IN BMM_CALLBACK_DATA
*CallbackData
972 Create a lit of driver option from global DriverMenu.
974 @param CallbackData The BMM context data.
977 UpdateDrvAddHandlePage (
978 IN BMM_CALLBACK_DATA
*CallbackData
982 Create a lit of driver option from global DriverOptionMenu. It
983 allow user to delete the driver option.
985 @param CallbackData The BMM context data.
989 IN BMM_CALLBACK_DATA
*CallbackData
993 Prepare the page to allow user to add description for a Driver Option.
995 @param CallbackData The BMM context data.
998 UpdateDriverAddHandleDescPage (
999 IN BMM_CALLBACK_DATA
*CallbackData
1003 Dispatch the correct update page function to call based on the UpdatePageId.
1005 @param UpdatePageId The form ID.
1006 @param CallbackData The BMM context data.
1010 IN UINT16 UpdatePageId
,
1011 IN BMM_CALLBACK_DATA
*CallbackData
1015 Create the dynamic page to allow user to set the "BootNext" vaule.
1017 @param CallbackData The BMM context data.
1020 UpdateBootNextPage (
1021 IN BMM_CALLBACK_DATA
*CallbackData
1025 Create the dynamic page to allow user to set the "TimeOut" vaule.
1027 @param CallbackData The BMM context data.
1031 IN BMM_CALLBACK_DATA
*CallbackData
1035 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1036 Parity, Stop Bits, Terminal Type.
1038 @param CallbackData The BMM context data.
1041 UpdateTerminalPage (
1042 IN BMM_CALLBACK_DATA
*CallbackData
1046 Refresh the text mode page
1048 @param CallbackData The BMM context data.
1052 IN BMM_CALLBACK_DATA
*CallbackData
1056 Create a list of Goto Opcode for all terminal devices logged
1057 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1059 @param CallbackData The BMM context data.
1063 IN BMM_CALLBACK_DATA
*CallbackData
1067 Create a dynamic page so that Legacy Device boot order
1068 can be set for specified device type.
1070 @param UpdatePageId The form ID. It also spefies the legacy device type.
1071 @param CallbackData The BMM context data.
1074 UpdateSetLegacyDeviceOrderPage (
1075 IN UINT16 UpdatePageId
,
1076 IN BMM_CALLBACK_DATA
*CallbackData
1081 Function opens and returns a file handle to the root directory of a volume.
1083 @param DeviceHandle A handle for a device
1084 @return A valid file handle or NULL is returned
1088 IN EFI_HANDLE DeviceHandle
1092 Function gets the file system information from an open file descriptor,
1093 and stores it in a buffer allocated from pool.
1095 @param FHand The file handle.
1097 @return A pointer to a buffer with file information.
1098 NULL is returned if failed to get Vaolume Label Info.
1100 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1101 EfiLibFileSystemVolumeLabelInfo (
1102 IN EFI_FILE_HANDLE FHand
1107 Function gets the file information from an open file descriptor, and stores it
1108 in a buffer allocated from pool.
1110 @param FHand File Handle.
1112 @return A pointer to a buffer with file information or NULL is returned
1117 IN EFI_FILE_HANDLE FHand
1122 Function deletes the variable specified by VarName and VarGuid.
1125 @param VarName A Null-terminated Unicode string that is
1126 the name of the vendor's variable.
1128 @param VarGuid A unique identifier for the vendor.
1130 @retval EFI_SUCCESS The variable was found and removed
1131 @retval EFI_UNSUPPORTED The variable store was inaccessible
1132 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1133 @retval EFI_NOT_FOUND The variable was not found
1137 EfiLibDeleteVariable (
1139 IN EFI_GUID
*VarGuid
1145 @param Src The source.
1147 @return A new string which is duplicated copy of the source.
1148 @retval NULL If there is not enough memory.
1157 Function is used to determine the number of device path instances
1158 that exist in a device path.
1161 @param DevicePath A pointer to a device path data structure.
1163 @return This function counts and returns the number of device path instances
1168 EfiDevicePathInstanceCount (
1169 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1173 Create string tokens for a menu from its help strings and display strings
1176 @param CallbackData The BMM context data.
1177 @param HiiHandle Hii Handle of the package to be updated.
1178 @param MenuOption The Menu whose string tokens need to be created
1180 @retval EFI_SUCCESS string tokens created successfully
1181 @retval others contain some errors
1185 CreateMenuStringToken (
1186 IN BMM_CALLBACK_DATA
*CallbackData
,
1187 IN EFI_HII_HANDLE HiiHandle
,
1188 IN BM_MENU_OPTION
*MenuOption
1192 Get a string from the Data Hub record based on
1195 @param DevPath The device Path.
1197 @return A string located from the Data Hub records based on
1199 @retval NULL If failed to get the String from Data Hub.
1203 EfiLibStrFromDatahub (
1204 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1208 Initialize the Boot Maintenance Utitliy.
1210 @retval EFI_SUCCESS utility ended successfully.
1211 @retval others contain some errors.
1220 Start boot maintenance manager
1222 @retval EFI_SUCCESS If BMM is invoked successfully.
1223 @return Other value if BMM return unsuccessfully.
1232 Intialize all the string depositories.
1236 InitializeStringDepository (
1241 Fetch a usable string node from the string depository and return the string token.
1244 @param CallbackData The BMM context data.
1245 @param StringDepository Pointer of the string depository.
1247 @retval EFI_STRING_ID String token.
1251 GetStringTokenFromDepository (
1252 IN BMM_CALLBACK_DATA
*CallbackData
,
1253 IN STRING_DEPOSITORY
*StringDepository
1257 Reclaim string depositories by moving the current node pointer to list head..
1260 ReclaimStringDepository (
1265 Release resource for all the string depositories.
1269 CleanUpStringDepository (
1274 Function handling request to apply changes for BMM pages.
1276 @param Private Pointer to callback data buffer.
1277 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1278 @param FormId ID of the form which has sent the request to apply change.
1280 @retval EFI_SUCCESS Change successfully applied.
1281 @retval Other Error occurs while trying to apply changes.
1285 ApplyChangeHandler (
1286 IN BMM_CALLBACK_DATA
*Private
,
1287 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1288 IN EFI_FORM_ID FormId
1292 Discard all changes done to the BMM pages such as Boot Order change,
1293 Driver order change.
1295 @param Private The BMM context data.
1296 @param CurrentFakeNVMap The current Fack NV Map.
1300 DiscardChangeHandler (
1301 IN BMM_CALLBACK_DATA
*Private
,
1302 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1306 Dispatch the display to the next page based on NewPageId.
1308 @param Private The BMM context data.
1309 @param NewPageId The original page ID.
1314 BMM_CALLBACK_DATA
*Private
,
1319 Boot a file selected by user at File Expoloer of BMM.
1321 @param FileContext The file context data, which contains the device path
1322 of the file to be boot from.
1324 @retval EFI_SUCCESS The function completed successfull.
1325 @return Other value if the boot from the file fails.
1330 IN BM_FILE_CONTEXT
*FileContext
1334 Update the file explower page with the refershed file system.
1337 @param CallbackData BMM context data
1338 @param KeyValue Key value to identify the type of data to expect.
1340 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1341 @retval FALSE Indicate that there is no need to exit file explorer.
1345 UpdateFileExplorer (
1346 IN BMM_CALLBACK_DATA
*CallbackData
,
1351 This function processes the results of changes in configuration.
1352 When user select a interactive opcode, this callback will be triggered.
1353 Based on the Question(QuestionId) that triggers the callback, the corresponding
1354 actions is performed. It handles:
1356 1) the addition of boot option.
1357 2) the addition of driver option.
1358 3) exit from file browser
1359 4) update of file content if a dir is selected.
1360 5) boot the file if a file is selected in "boot from file"
1363 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1364 @param Action Specifies the type of action taken by the browser.
1365 @param QuestionId A unique value which is sent to the original exporting driver
1366 so that it can identify the type of data to expect.
1367 @param Type The type of value for the question.
1368 @param Value A pointer to the data being sent to the original exporting driver.
1369 @param ActionRequest On return, points to the action requested by the callback function.
1371 @retval EFI_SUCCESS The callback successfully handled the action.
1372 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1373 @retval EFI_DEVICE_ERROR The variable could not be saved.
1374 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1379 FileExplorerCallback (
1380 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1381 IN EFI_BROWSER_ACTION Action
,
1382 IN EFI_QUESTION_ID QuestionId
,
1384 IN EFI_IFR_TYPE_VALUE
*Value
,
1385 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1389 This function applies changes in a driver's configuration.
1390 Input is a Configuration, which has the routing data for this
1391 driver followed by name / value configuration pairs. The driver
1392 must apply those pairs to its configurable storage. If the
1393 driver's configuration is stored in a linear block of data
1394 and the driver's name / value pairs are in <BlockConfig>
1395 format, it may use the ConfigToBlock helper function (above) to
1396 simplify the job. Currently not implemented.
1398 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1399 @param[in] Configuration A null-terminated Unicode string in
1400 <ConfigString> format.
1401 @param[out] Progress A pointer to a string filled in with the
1402 offset of the most recent '&' before the
1403 first failing name / value pair (or the
1404 beginn ing of the string if the failure
1405 is in the first name / value pair) or
1406 the terminating NULL if all was
1409 @retval EFI_SUCCESS The results have been distributed or are
1410 awaiting distribution.
1411 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1412 parts of the results that must be
1413 stored awaiting possible future
1415 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1416 Results parameter would result
1417 in this type of error.
1418 @retval EFI_NOT_FOUND Target for the specified routing data
1423 FileExplorerRouteConfig (
1424 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1425 IN CONST EFI_STRING Configuration
,
1426 OUT EFI_STRING
*Progress
1430 Dispatch BMM formset and FileExplorer formset.
1433 @param CallbackData The BMM context data.
1435 @retval EFI_SUCCESS If function complete successfully.
1436 @return Other value if the Setup Browser process BMM's pages and
1437 return unsuccessfully.
1442 IN BMM_CALLBACK_DATA
*CallbackData
1446 Function returns the value of the specified variable.
1448 @param Name A Null-terminated Unicode string that is
1449 the name of the vendor's variable.
1450 @param VendorGuid A unique identifier for the vendor.
1452 @return The payload of the variable.
1453 @retval NULL If the variable can't be read.
1459 IN EFI_GUID
*VendorGuid
1463 Get option number according to Boot#### and BootOrder variable.
1464 The value is saved as #### + 1.
1466 @param CallbackData The BMM context data.
1470 IN BMM_CALLBACK_DATA
*CallbackData
1474 Get driver option order from globalc DriverOptionMenu.
1476 @param CallbackData The BMM context data.
1481 IN BMM_CALLBACK_DATA
*CallbackData
1485 Intall BootMaint and FileExplorer HiiPackages.
1494 Remvoe the intalled BootMaint and FileExplorer HiiPackages.
1503 According to LegacyDevOrder variable to get legacy FD\HD\CD\NET\BEV
1506 @param CallbackData The BMM context data.
1509 GetLegacyDeviceOrder (
1510 IN BMM_CALLBACK_DATA
*CallbackData
1515 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1516 in BMM_FAKE_NV_DATA structure.
1518 @param CallbackData The BMM context data.
1523 IN BMM_CALLBACK_DATA
*CallbackData
1528 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1529 in BMM_FAKE_NV_DATA structure.
1531 @param CallbackData The BMM context data.
1535 GetConsoleOutCheck (
1536 IN BMM_CALLBACK_DATA
*CallbackData
1541 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1542 in BMM_FAKE_NV_DATA structure.
1544 @param CallbackData The BMM context data.
1548 GetConsoleErrCheck (
1549 IN BMM_CALLBACK_DATA
*CallbackData
1554 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1555 to BMM_FAKE_NV_DATA structure.
1557 @param CallbackData The BMM context data.
1561 GetTerminalAttribute (
1562 IN BMM_CALLBACK_DATA
*CallbackData
1567 Find the first instance of this Protocol
1568 in the system and return it's interface.
1571 @param ProtocolGuid Provides the protocol to search for
1572 @param Interface On return, a pointer to the first interface
1573 that matches ProtocolGuid
1575 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1576 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1580 EfiLibLocateProtocol (
1581 IN EFI_GUID
*ProtocolGuid
,
1582 OUT VOID
**Interface
1586 // Global variable in this program (defined in data.c)
1588 extern BM_MENU_OPTION BootOptionMenu
;
1589 extern BM_MENU_OPTION DriverOptionMenu
;
1590 extern BM_MENU_OPTION FsOptionMenu
;
1591 extern BM_MENU_OPTION ConsoleInpMenu
;
1592 extern BM_MENU_OPTION ConsoleOutMenu
;
1593 extern BM_MENU_OPTION ConsoleErrMenu
;
1594 extern BM_MENU_OPTION DirectoryMenu
;
1595 extern BM_MENU_OPTION DriverMenu
;
1596 extern BM_MENU_OPTION TerminalMenu
;
1597 extern BM_MENU_OPTION LegacyFDMenu
;
1598 extern BM_MENU_OPTION LegacyHDMenu
;
1599 extern BM_MENU_OPTION LegacyCDMenu
;
1600 extern BM_MENU_OPTION LegacyNETMenu
;
1601 extern BM_MENU_OPTION LegacyBEVMenu
;
1602 extern UINT16 TerminalType
[];
1603 extern COM_ATTR BaudRateList
[19];
1604 extern COM_ATTR DataBitsList
[4];
1605 extern COM_ATTR ParityList
[5];
1606 extern COM_ATTR StopBitsList
[3];
1607 extern EFI_GUID TerminalTypeGuid
[4];
1608 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1609 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1610 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1611 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1612 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1613 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1614 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1615 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1616 extern UINT16 mFlowControlType
[2];
1617 extern UINT32 mFlowControlValue
[2];
1619 // Shared IFR form update data
1621 extern VOID
*mStartOpCodeHandle
;
1622 extern VOID
*mEndOpCodeHandle
;
1623 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1624 extern EFI_IFR_GUID_LABEL
*mEndLabel
;