2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2009, 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_LEGACY_DEV_ORDER L"LegacyDevOrder"
28 #define VAR_CON_OUT_MODE L"ConOutMode"
31 /// Guid of a NV Variable which store the information about the
32 /// FD/HD/CD/NET/BEV order
34 #define EFI_LEGACY_DEV_ORDER_VARIABLE_GUID \
36 0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52} \
42 #define STR_FLOPPY L"Floppy Drive #%02x"
43 #define STR_HARDDISK L"HardDisk Drive #%02x"
44 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
45 #define STR_NET L"NET Drive #%02x"
46 #define STR_BEV L"BEV Drive #%02x"
47 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
48 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
49 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
50 #define STR_NET_HELP L"NET Drive #%02x"
51 #define STR_BEV_HELP L"BEV Drive #%02x"
54 // Variable created with this flag will be "Efi:...."
56 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
58 extern EFI_GUID mBootMaintGuid
;
59 extern EFI_GUID mFileExplorerGuid
;
60 extern CHAR16 mFileExplorerStorageName
[];
61 extern CHAR16 mBootMaintStorageName
[];
63 // These are the VFR compiler generated data representing our VFR data.
69 // Below are the number of options in Baudrate, Databits,
70 // Parity and Stopbits selection for serial ports.
72 #define BM_COM_ATTR_BUADRATE 19
73 #define BM_COM_ATTR_DATABITS 4
74 #define BM_COM_ATTR_PARITY 5
75 #define BM_COM_ATTR_STOPBITS 3
78 // Callback function helper
80 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
81 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
83 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
86 // Enumeration type definition
88 typedef UINT8 BBS_TYPE
;
90 typedef enum _TYPE_OF_TERMINAL
{
91 TerminalTypePcAnsi
= 0,
93 TerminalTypeVt100Plus
,
97 typedef enum _FILE_EXPLORER_STATE
{
98 FileExplorerStateInActive
= 0,
99 FileExplorerStateBootFromFile
,
100 FileExplorerStateAddBootOption
,
101 FileExplorerStateAddDriverOptionState
,
102 FileExplorerStateUnknown
103 } FILE_EXPLORER_STATE
;
105 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
106 FileExplorerDisplayFileSystem
,
107 FileExplorerDisplayDirectory
,
108 FileExplorerDisplayUnknown
109 } FILE_EXPLORER_DISPLAY_CONTEXT
;
112 // All of the signatures that will be used in list structure
114 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
115 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
116 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
117 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
118 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
119 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
120 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
122 #define BM_LOAD_CONTEXT_SELECT 0x0
123 #define BM_CONSOLE_CONTEXT_SELECT 0x1
124 #define BM_FILE_CONTEXT_SELECT 0x2
125 #define BM_HANDLE_CONTEXT_SELECT 0x3
126 #define BM_TERMINAL_CONTEXT_SELECT 0x5
128 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
129 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
130 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
131 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
134 // Buffer size for update data
136 #define UPDATE_DATA_SIZE 0x100000
139 // Namespace of callback keys used in display and file system navigation
141 #define MAX_BBS_OFFSET 0xE000
142 #define NET_OPTION_OFFSET 0xD800
143 #define BEV_OPTION_OFFSET 0xD000
144 #define FD_OPTION_OFFSET 0xC000
145 #define HD_OPTION_OFFSET 0xB000
146 #define CD_OPTION_OFFSET 0xA000
147 #define FILE_OPTION_OFFSET 0x8000
148 #define FILE_OPTION_MASK 0x7FFF
149 #define HANDLE_OPTION_OFFSET 0x7000
150 #define CONSOLE_OPTION_OFFSET 0x6000
151 #define TERMINAL_OPTION_OFFSET 0x5000
152 #define CONFIG_OPTION_OFFSET 0x1200
153 #define KEY_VALUE_OFFSET 0x1100
154 #define FORM_ID_OFFSET 0x1000
157 // VarOffset that will be used to create question
158 // all these values are computed from the structure
161 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
164 // Question Id of Zero is invalid, so add an offset to it
166 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
168 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
169 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
170 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
171 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
172 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
173 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
174 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
175 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
176 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
177 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
178 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
179 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
180 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
181 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
182 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
183 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
184 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
185 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
186 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
187 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
188 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
189 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
190 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
191 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
192 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionToBeDeleted)
193 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
194 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
195 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
196 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
197 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
198 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
199 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
200 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
201 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
202 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
203 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
204 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
205 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
207 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
208 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
209 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
210 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
211 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
212 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
213 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
214 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
215 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
216 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
217 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
218 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
219 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
220 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
221 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
222 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
223 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
224 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
225 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
226 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
227 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
228 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
229 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
230 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
231 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)
232 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
233 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
234 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
235 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
236 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
237 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
238 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
239 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
240 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
241 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
242 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
243 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
244 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
246 #define STRING_DEPOSITORY_NUMBER 8
249 /// Serial Ports attributes, first one is the value for
250 /// return from callback function, stringtoken is used to
251 /// display the value properly
262 /// Length = sizeof (UINT16) + SIZEOF (Data)
266 } BM_LEGACY_DEV_ORDER_CONTEXT
;
285 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
286 } BM_TERMINAL_CONTEXT
;
290 BOOLEAN LoadOptionModified
;
295 BOOLEAN ForceReconnect
;
296 UINTN OptionalDataSize
;
298 UINTN LoadOptionSize
;
302 UINT16 FilePathListLength
;
304 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
315 } BM_LEGACY_DEVICE_CONTEXT
;
323 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
324 } BM_CONSOLE_CONTEXT
;
333 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
334 EFI_FILE_HANDLE FHandle
;
336 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
340 BOOLEAN IsRemovableMedia
;
342 BOOLEAN IsBootLegacy
;
347 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
360 UINT16
*DisplayString
;
362 EFI_STRING_ID DisplayStringToken
;
363 EFI_STRING_ID HelpStringToken
;
364 UINTN ContextSelection
;
365 VOID
*VariableContext
;
370 // Shared callback data.
374 BM_MENU_ENTRY
*MenuEntry
;
375 BM_HANDLE_CONTEXT
*HandleContext
;
376 BM_FILE_CONTEXT
*FileContext
;
377 BM_LOAD_CONTEXT
*LoadContext
;
378 BM_TERMINAL_CONTEXT
*TerminalContext
;
379 UINTN CurrentTerminal
;
383 // BMM main formset callback data.
385 EFI_HII_HANDLE BmmHiiHandle
;
386 EFI_HANDLE BmmDriverHandle
;
387 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
388 EFI_FORM_ID BmmCurrentPageId
;
389 EFI_FORM_ID BmmPreviousPageId
;
390 BOOLEAN BmmAskSaveOrNot
;
391 BMM_FAKE_NV_DATA BmmFakeNvData
;
392 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
395 // File explorer formset callback data.
397 EFI_HII_HANDLE FeHiiHandle
;
398 EFI_HANDLE FeDriverHandle
;
399 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
400 FILE_EXPLORER_STATE FeCurrentState
;
401 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
402 FILE_EXPLORER_NV_DATA FeFakeNvData
;
405 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
407 struct _STRING_LIST_NODE
{
408 EFI_STRING_ID StringToken
;
409 STRING_LIST_NODE
*Next
;
412 typedef struct _STRING_DEPOSITORY
{
413 UINTN TotalNodeNumber
;
414 STRING_LIST_NODE
*CurrentNode
;
415 STRING_LIST_NODE
*ListHead
;
421 // For initializing File System menu
425 This function build the FsOptionMenu list which records all
426 available file system in the system. They includes all instances
427 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
428 and all type of legacy boot device.
430 @param CallbackData BMM context data
432 @retval EFI_SUCCESS Success find the file system
433 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
437 BOpt_FindFileSystem (
438 IN BMM_CALLBACK_DATA
*CallbackData
442 Find files under current directory
443 All files and sub-directories in current directory
444 will be stored in DirectoryMenu for future use.
446 @param CallbackData The BMM context data.
447 @param MenuEntry The Menu Entry.
449 @retval EFI_SUCCESS Get files from current dir successfully.
450 @return Other value if can't get files from current dir.
455 IN BMM_CALLBACK_DATA
*CallbackData
,
456 IN BM_MENU_ENTRY
*MenuEntry
461 Find drivers that will be added as Driver#### variables from handles
462 in current system environment
463 All valid handles in the system except those consume SimpleFs, LoadFile
464 are stored in DriverMenu for future use.
466 @retval EFI_SUCCESS The function complets successfully.
467 @return Other value if failed to build the DriverMenu.
477 Build the BootOptionMenu according to BootOrder Variable.
478 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
480 @param CallbackData The BMM context data.
482 @return The number of the Var Boot####.
486 BOpt_GetBootOptions (
487 IN BMM_CALLBACK_DATA
*CallbackData
492 Build up all DriverOptionMenu
494 @param CallbackData The BMM context data.
496 @return EFI_SUCESS The functin completes successfully.
497 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
502 BOpt_GetDriverOptions (
503 IN BMM_CALLBACK_DATA
*CallbackData
508 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
510 @retval EFI_SUCCESS The function complete successfully.
511 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
515 BOpt_GetLegacyOptions (
520 Free out resouce allocated from Legacy Boot Options.
524 BOpt_FreeLegacyOptions (
529 Free resources allocated in Allocate Rountine.
531 @param FreeMenu Menu to be freed
536 BM_MENU_OPTION
*FreeMenu
542 Append file name to existing file name.
544 @param Str1 The existing file name
545 @param Str2 The file name to be appended
547 @return Allocate a new string to hold the appended result.
548 Caller is responsible to free the returned string.
552 BOpt_AppendFileName (
559 Check whether current FileName point to a valid
562 @param FileName File need to be checked.
564 @retval TRUE Is Efi Image
565 @retval FALSE Not a valid Efi Image
569 BOpt_IsEfiImageName (
575 Check whether current FileName point to a valid Efi Application
577 @param Dir Pointer to current Directory
578 @param FileName Pointer to current File name.
580 @retval TRUE Is a valid Efi Application
581 @retval FALSE not a valid Efi Application
586 IN EFI_FILE_HANDLE Dir
,
592 Get the Option Number that has not been allocated for use.
594 @param Type The type of Option.
596 @return The available Option Number.
600 BOpt_GetOptionNumber (
606 Get the Option Number for Boot#### that does not used.
608 @return The available Option Number.
612 BOpt_GetBootOptionNumber (
618 Get the Option Number for Driver#### that does not used.
620 @return The unused Option Number.
624 BOpt_GetDriverOptionNumber (
629 Create a menu entry give a Menu type.
631 @param MenuType The Menu type to be created.
634 @retval NULL If failed to create the menu.
639 BOpt_CreateMenuEntry (
644 Free up all resource allocated for a BM_MENU_ENTRY.
646 @param MenuEntry A pointer to BM_MENU_ENTRY.
650 BOpt_DestroyMenuEntry (
651 BM_MENU_ENTRY
*MenuEntry
655 Get the Menu Entry from the list in Menu Entry List.
657 If MenuNumber is great or equal to the number of Menu
658 Entry in the list, then ASSERT.
660 @param MenuOption The Menu Entry List to read the menu entry.
661 @param MenuNumber The index of Menu Entry.
663 @return The Menu Entry.
668 BM_MENU_OPTION
*MenuOption
,
673 // Locate all serial io devices for console
676 Build a list containing all serial devices.
678 @retval EFI_SUCCESS The function complete successfully.
679 @retval EFI_UNSUPPORTED No serial ports present.
688 // Initializing Console menu
691 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
693 @retval EFI_SUCCESS The function always complete successfully.
702 // Get current mode information
705 Get mode number according to column and row
707 @param CallbackData The BMM context data.
711 IN BMM_CALLBACK_DATA
*CallbackData
715 // Cleaning up console menu
718 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
720 @retval EFI_SUCCESS The function always complete successfully.
728 Update the device path that describing a terminal device
729 based on the new BaudRate, Data Bits, parity and Stop Bits
732 @param DevicePath The devicepath protocol instance wanted to be updated.
736 ChangeVariableDevicePath (
737 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
741 Update the multi-instance device path of Terminal Device based on
742 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
743 device path in the Terminal Device in TerminalMenu is also updated.
745 @param DevicePath The multi-instance device path.
746 @param ChangeTerminal TRUE, then device path in the Terminal Device
747 in TerminalMenu is also updated; FALSE, no update.
749 @return EFI_SUCCESS The function completes successfully.
753 ChangeTerminalDevicePath (
754 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
755 IN BOOLEAN ChangeTerminal
759 // Variable operation by menu selection
762 This function create a currently loaded Boot Option from
763 the BMM. It then appends this Boot Option to the end of
764 the "BootOrder" list. It also append this Boot Opotion to the end
767 @param CallbackData The BMM context data.
768 @param NvRamMap The file explorer formset internal state.
770 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
771 @retval EFI_SUCCESS If function completes successfully.
775 Var_UpdateBootOption (
776 IN BMM_CALLBACK_DATA
*CallbackData
,
777 IN FILE_EXPLORER_NV_DATA
*NvRamMap
781 Delete Boot Option that represent a Deleted state in BootOptionMenu.
782 After deleting this boot option, call Var_ChangeBootOrder to
783 make sure BootOrder is in valid state.
785 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
786 BM_LOAD_CONTEXT marked for deletion is deleted
787 @return Others If failed to update the "BootOrder" variable after deletion.
796 After any operation on Boot####, there will be a discrepancy in BootOrder.
797 Since some are missing but in BootOrder, while some are present but are
798 not reflected by BootOrder. Then a function rebuild BootOrder from
799 scratch by content from BootOptionMenu is needed.
801 @retval EFI_SUCCESS The boot order is updated successfully.
802 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
806 Var_ChangeBootOrder (
811 This function create a currently loaded Drive Option from
812 the BMM. It then appends this Driver Option to the end of
813 the "DriverOrder" list. It append this Driver Opotion to the end
816 @param CallbackData The BMM context data.
817 @param HiiHandle The HII handle associated with the BMM formset.
818 @param DescriptionData The description of this driver option.
819 @param OptionalData The optional load option.
820 @param ForceReconnect If to force reconnect.
822 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
823 @retval EFI_SUCCESS If function completes successfully.
827 Var_UpdateDriverOption (
828 IN BMM_CALLBACK_DATA
*CallbackData
,
829 IN EFI_HII_HANDLE HiiHandle
,
830 IN UINT16
*DescriptionData
,
831 IN UINT16
*OptionalData
,
832 IN UINT8 ForceReconnect
836 Delete Load Option that represent a Deleted state in BootOptionMenu.
837 After deleting this Driver option, call Var_ChangeDriverOrder to
838 make sure DriverOrder is in valid state.
840 @retval EFI_SUCCESS Load Option is successfully updated.
841 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
846 Var_DelDriverOption (
851 After any operation on Driver####, there will be a discrepancy in
852 DriverOrder. Since some are missing but in DriverOrder, while some
853 are present but are not reflected by DriverOrder. Then a function
854 rebuild DriverOrder from scratch by content from DriverOptionMenu is
857 @retval EFI_SUCCESS The driver order is updated successfully.
858 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
862 Var_ChangeDriverOrder (
867 This function delete and build multi-instance device path ConIn
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_UpdateConsoleInpOption (
879 This function delete and build multi-instance device path ConOut console device.
881 @retval EFI_SUCCESS The function complete successfully.
882 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
885 Var_UpdateConsoleOutOption (
890 This function delete and build multi-instance device path ErrOut console device.
892 @retval EFI_SUCCESS The function complete successfully.
893 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
896 Var_UpdateErrorOutOption (
901 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
902 parity and stop Bits set.
906 Var_UpdateAllConsoleOption (
911 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
912 this EFI Variable is deleted.
913 It also update the BMM context data specified the "BootNext" value.
915 @param CallbackData The BMM context data.
917 @retval EFI_SUCCESS The function complete successfully.
918 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
923 IN BMM_CALLBACK_DATA
*CallbackData
927 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
928 BootOptionMenu with the new "BootOrder" list.
930 @param CallbackData The BMM context data.
932 @retval EFI_SUCCESS The function complete successfully.
933 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
934 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
938 Var_UpdateBootOrder (
939 IN BMM_CALLBACK_DATA
*CallbackData
943 This function update the "DriverOrder" EFI Variable based on
944 BMM Formset's NV map. It then refresh DriverOptionMenu
945 with the new "DriverOrder" list.
947 @param CallbackData The BMM context data.
949 @retval EFI_SUCCESS The function complete successfully.
950 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
951 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
955 Var_UpdateDriverOrder (
956 IN BMM_CALLBACK_DATA
*CallbackData
960 Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable
961 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
964 @param CallbackData The context data for BMM.
966 @return EFI_SUCCESS The function completed successfully.
967 @retval EFI_NOT_FOUND If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can not be found.
971 Var_UpdateBBSOption (
972 IN BMM_CALLBACK_DATA
*CallbackData
976 Update the Text Mode of Console.
978 @param CallbackData The context data for BMM.
980 @retval EFI_SUCCSS If the Text Mode of Console is updated.
981 @return Other value if the Text Mode of Console is not updated.
986 IN BMM_CALLBACK_DATA
*CallbackData
990 // Following are page create and refresh functions
993 Refresh the global UpdateData structure.
1002 Clean up the dynamic opcode at label and form specified by
1005 @param LabelId It is both the Form ID and Label ID for
1007 @param CallbackData The BMM context data.
1013 IN BMM_CALLBACK_DATA
*CallbackData
1017 Create a lit of boot option from global BootOptionMenu. It
1018 allow user to delete the boot option.
1020 @param CallbackData The BMM context data.
1025 IN BMM_CALLBACK_DATA
*CallbackData
1029 Create a lit of driver option from global DriverMenu.
1031 @param CallbackData The BMM context data.
1034 UpdateDrvAddHandlePage (
1035 IN BMM_CALLBACK_DATA
*CallbackData
1039 Create a lit of driver option from global DriverOptionMenu. It
1040 allow user to delete the driver option.
1042 @param CallbackData The BMM context data.
1046 IN BMM_CALLBACK_DATA
*CallbackData
1050 Prepare the page to allow user to add description for a Driver Option.
1052 @param CallbackData The BMM context data.
1055 UpdateDriverAddHandleDescPage (
1056 IN BMM_CALLBACK_DATA
*CallbackData
1060 Dispatch the correct update page function to call based on the UpdatePageId.
1062 @param UpdatePageId The form ID.
1063 @param CallbackData The BMM context data.
1067 IN UINT16 UpdatePageId
,
1068 IN BMM_CALLBACK_DATA
*CallbackData
1072 Create the dynamic page to allow user to set the "BootNext" vaule.
1074 @param CallbackData The BMM context data.
1077 UpdateBootNextPage (
1078 IN BMM_CALLBACK_DATA
*CallbackData
1082 Create the dynamic page to allow user to set the "TimeOut" vaule.
1084 @param CallbackData The BMM context data.
1088 IN BMM_CALLBACK_DATA
*CallbackData
1092 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1093 Parity, Stop Bits, Terminal Type.
1095 @param CallbackData The BMM context data.
1098 UpdateTerminalPage (
1099 IN BMM_CALLBACK_DATA
*CallbackData
1103 Refresh the text mode page
1105 @param CallbackData The BMM context data.
1109 IN BMM_CALLBACK_DATA
*CallbackData
1113 Create a list of Goto Opcode for all terminal devices logged
1114 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1116 @param CallbackData The BMM context data.
1120 IN BMM_CALLBACK_DATA
*CallbackData
1124 Create a dynamic page so that Legacy Device boot order
1125 can be set for specified device type.
1127 @param UpdatePageId The form ID. It also spefies the legacy device type.
1128 @param CallbackData The BMM context data.
1131 UpdateSetLegacyDeviceOrderPage (
1132 IN UINT16 UpdatePageId
,
1133 IN BMM_CALLBACK_DATA
*CallbackData
1138 Function opens and returns a file handle to the root directory of a volume.
1140 @param DeviceHandle A handle for a device
1141 @return A valid file handle or NULL is returned
1145 IN EFI_HANDLE DeviceHandle
1149 Function gets the file system information from an open file descriptor,
1150 and stores it in a buffer allocated from pool.
1152 @param FHand The file handle.
1154 @return A pointer to a buffer with file information.
1155 NULL is returned if failed to get Vaolume Label Info.
1157 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1158 EfiLibFileSystemVolumeLabelInfo (
1159 IN EFI_FILE_HANDLE FHand
1164 Function gets the file information from an open file descriptor, and stores it
1165 in a buffer allocated from pool.
1167 @param FHand File Handle.
1169 @return A pointer to a buffer with file information or NULL is returned
1174 IN EFI_FILE_HANDLE FHand
1178 Find the first instance of this Protocol in the system and return it's interface.
1180 @param ProtocolGuid Provides the protocol to search for
1181 @param Interface On return, a pointer to the first interface
1182 that matches ProtocolGuid
1184 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1185 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1189 EfiLibLocateProtocol (
1190 IN EFI_GUID
*ProtocolGuid
,
1191 OUT VOID
**Interface
1195 Adjusts the size of a previously allocated buffer.
1197 @param OldPool A pointer to the buffer whose size is being adjusted.
1198 @param OldSize The size of the current buffer.
1199 @param NewSize The size of the new buffer.
1201 @return The newly allocated buffer. if NULL, allocation failed.
1212 Function deletes the variable specified by VarName and VarGuid.
1215 @param VarName A Null-terminated Unicode string that is
1216 the name of the vendor's variable.
1218 @param VarGuid A unique identifier for the vendor.
1220 @retval EFI_SUCCESS The variable was found and removed
1221 @retval EFI_UNSUPPORTED The variable store was inaccessible
1222 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1223 @retval EFI_NOT_FOUND The variable was not found
1227 EfiLibDeleteVariable (
1229 IN EFI_GUID
*VarGuid
1235 @param Src The source.
1237 @return A new string which is duplicated copy of the source.
1238 @retval NULL If there is not enough memory.
1247 Function is used to determine the number of device path instances
1248 that exist in a device path.
1251 @param DevicePath A pointer to a device path data structure.
1253 @return This function counts and returns the number of device path instances
1258 EfiDevicePathInstanceCount (
1259 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1263 Create string tokens for a menu from its help strings and display strings
1266 @param CallbackData The BMM context data.
1267 @param HiiHandle Hii Handle of the package to be updated.
1268 @param MenuOption The Menu whose string tokens need to be created
1270 @retval EFI_SUCCESS string tokens created successfully
1271 @retval others contain some errors
1275 CreateMenuStringToken (
1276 IN BMM_CALLBACK_DATA
*CallbackData
,
1277 IN EFI_HII_HANDLE HiiHandle
,
1278 IN BM_MENU_OPTION
*MenuOption
1282 Get a string from the Data Hub record based on
1285 @param DevPath The device Path.
1287 @return A string located from the Data Hub records based on
1289 @retval NULL If failed to get the String from Data Hub.
1293 EfiLibStrFromDatahub (
1294 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1298 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1299 specified by DeviceType.
1301 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1303 @param OptionIndex Returns the index number (#### in Boot####).
1304 @param OptionSize Return the size of the Boot### variable.
1308 GetLegacyBootOptionVar (
1309 IN UINTN DeviceType
,
1310 OUT UINTN
*OptionIndex
,
1311 OUT UINTN
*OptionSize
1315 Initialize the Boot Maintenance Utitliy.
1317 @retval EFI_SUCCESS utility ended successfully.
1318 @retval others contain some errors.
1327 Start boot maintenance manager
1329 @retval EFI_SUCCESS If BMM is invoked successfully.
1330 @return Other value if BMM return unsuccessfully.
1339 Intialize all the string depositories.
1343 InitializeStringDepository (
1348 Fetch a usable string node from the string depository and return the string token.
1351 @param CallbackData The BMM context data.
1352 @param StringDepository Pointer of the string depository.
1354 @retval EFI_STRING_ID String token.
1358 GetStringTokenFromDepository (
1359 IN BMM_CALLBACK_DATA
*CallbackData
,
1360 IN STRING_DEPOSITORY
*StringDepository
1364 Reclaim string depositories by moving the current node pointer to list head..
1367 ReclaimStringDepository (
1372 Release resource for all the string depositories.
1376 CleanUpStringDepository (
1381 Function handling request to apply changes for BMM pages.
1383 @param Private Pointer to callback data buffer.
1384 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1385 @param FormId ID of the form which has sent the request to apply change.
1387 @retval EFI_SUCCESS Change successfully applied.
1388 @retval Other Error occurs while trying to apply changes.
1392 ApplyChangeHandler (
1393 IN BMM_CALLBACK_DATA
*Private
,
1394 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1395 IN EFI_FORM_ID FormId
1399 Discard all changes done to the BMM pages such as Boot Order change,
1400 Driver order change.
1402 @param Private The BMM context data.
1403 @param CurrentFakeNVMap The current Fack NV Map.
1407 DiscardChangeHandler (
1408 IN BMM_CALLBACK_DATA
*Private
,
1409 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1413 Dispatch the display to the next page based on NewPageId.
1415 @param Private The BMM context data.
1416 @param NewPageId The original page ID.
1421 BMM_CALLBACK_DATA
*Private
,
1426 Boot a file selected by user at File Expoloer of BMM.
1428 @param FileContext The file context data, which contains the device path
1429 of the file to be boot from.
1431 @retval EFI_SUCCESS The function completed successfull.
1432 @return Other value if the boot from the file fails.
1437 IN BM_FILE_CONTEXT
*FileContext
1441 Update the file explower page with the refershed file system.
1444 @param CallbackData BMM context data
1445 @param KeyValue Key value to identify the type of data to expect.
1447 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1448 @retval FALSE Indicate that there is no need to exit file explorer.
1452 UpdateFileExplorer (
1453 IN BMM_CALLBACK_DATA
*CallbackData
,
1458 This function processes the results of changes in configuration.
1459 When user select a interactive opcode, this callback will be triggered.
1460 Based on the Question(QuestionId) that triggers the callback, the corresponding
1461 actions is performed. It handles:
1463 1) the addition of boot option.
1464 2) the addition of driver option.
1465 3) exit from file browser
1466 4) update of file content if a dir is selected.
1467 5) boot the file if a file is selected in "boot from file"
1470 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1471 @param Action Specifies the type of action taken by the browser.
1472 @param QuestionId A unique value which is sent to the original exporting driver
1473 so that it can identify the type of data to expect.
1474 @param Type The type of value for the question.
1475 @param Value A pointer to the data being sent to the original exporting driver.
1476 @param ActionRequest On return, points to the action requested by the callback function.
1478 @retval EFI_SUCCESS The callback successfully handled the action.
1479 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1480 @retval EFI_DEVICE_ERROR The variable could not be saved.
1481 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1486 FileExplorerCallback (
1487 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1488 IN EFI_BROWSER_ACTION Action
,
1489 IN EFI_QUESTION_ID QuestionId
,
1491 IN EFI_IFR_TYPE_VALUE
*Value
,
1492 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1496 Dispatch BMM formset and FileExplorer formset.
1499 @param CallbackData The BMM context data.
1501 @retval EFI_SUCCESS If function complete successfully.
1502 @return Other value if the Setup Browser process BMM's pages and
1503 return unsuccessfully.
1508 IN BMM_CALLBACK_DATA
*CallbackData
1512 Function returns the value of the specified variable.
1514 @param Name A Null-terminated Unicode string that is
1515 the name of the vendor's variable.
1516 @param VendorGuid A unique identifier for the vendor.
1518 @return The payload of the variable.
1519 @retval NULL If the variable can't be read.
1525 IN EFI_GUID
*VendorGuid
1529 // Global variable in this program (defined in data.c)
1531 extern BM_MENU_OPTION BootOptionMenu
;
1532 extern BM_MENU_OPTION DriverOptionMenu
;
1533 extern BM_MENU_OPTION FsOptionMenu
;
1534 extern BM_MENU_OPTION ConsoleInpMenu
;
1535 extern BM_MENU_OPTION ConsoleOutMenu
;
1536 extern BM_MENU_OPTION ConsoleErrMenu
;
1537 extern BM_MENU_OPTION DirectoryMenu
;
1538 extern BM_MENU_OPTION DriverMenu
;
1539 extern BM_MENU_OPTION TerminalMenu
;
1540 extern BM_MENU_OPTION LegacyFDMenu
;
1541 extern BM_MENU_OPTION LegacyHDMenu
;
1542 extern BM_MENU_OPTION LegacyCDMenu
;
1543 extern BM_MENU_OPTION LegacyNETMenu
;
1544 extern BM_MENU_OPTION LegacyBEVMenu
;
1545 extern UINT16 TerminalType
[];
1546 extern COM_ATTR BaudRateList
[19];
1547 extern COM_ATTR DataBitsList
[4];
1548 extern COM_ATTR ParityList
[5];
1549 extern COM_ATTR StopBitsList
[3];
1550 extern EFI_GUID TerminalTypeGuid
[4];
1551 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1552 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1553 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1554 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1555 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1556 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1557 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1558 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1559 extern EFI_GUID EfiLegacyDevOrderGuid
;
1562 // Shared IFR form update data
1564 extern VOID
*mStartOpCodeHandle
;
1565 extern VOID
*mEndOpCodeHandle
;
1566 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1567 extern EFI_IFR_GUID_LABEL
*mEndLabel
;