2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2009, Intel Corporation. <BR>
5 All rights reserved. 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
59 // Define Maxmim characters that will be accepted
62 #define MAX_CHAR_SIZE (MAX_CHAR * 2)
64 extern EFI_GUID mBootMaintGuid
;
65 extern EFI_GUID mFileExplorerGuid
;
66 extern CHAR16 mFileExplorerStorageName
[];
67 extern CHAR16 mBootMaintStorageName
[];
69 // These are the VFR compiler generated data representing our VFR data.
75 // Below are the number of options in Baudrate, Databits,
76 // Parity and Stopbits selection for serial ports.
78 #define BM_COM_ATTR_BUADRATE 19
79 #define BM_COM_ATTR_DATABITS 4
80 #define BM_COM_ATTR_PARITY 5
81 #define BM_COM_ATTR_STOPBITS 3
84 // Callback function helper
86 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
87 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
89 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
92 // Enumeration type definition
94 typedef UINT8 BBS_TYPE
;
96 typedef enum _TYPE_OF_TERMINAL
{
97 TerminalTypePcAnsi
= 0,
99 TerminalTypeVt100Plus
,
103 typedef enum _FILE_EXPLORER_STATE
{
104 FileExplorerStateInActive
= 0,
105 FileExplorerStateBootFromFile
,
106 FileExplorerStateAddBootOption
,
107 FileExplorerStateAddDriverOptionState
,
108 FileExplorerStateUnknown
109 } FILE_EXPLORER_STATE
;
111 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
112 FileExplorerDisplayFileSystem
,
113 FileExplorerDisplayDirectory
,
114 FileExplorerDisplayUnknown
115 } FILE_EXPLORER_DISPLAY_CONTEXT
;
118 // All of the signatures that will be used in list structure
120 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
121 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
122 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
123 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
124 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
125 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
126 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
128 #define BM_LOAD_CONTEXT_SELECT 0x0
129 #define BM_CONSOLE_CONTEXT_SELECT 0x1
130 #define BM_FILE_CONTEXT_SELECT 0x2
131 #define BM_HANDLE_CONTEXT_SELECT 0x3
132 #define BM_TERMINAL_CONTEXT_SELECT 0x5
134 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
135 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
136 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
137 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
140 // Buffer size for update data
142 #define UPDATE_DATA_SIZE 0x100000
145 // Namespace of callback keys used in display and file system navigation
147 #define MAX_BBS_OFFSET 0xE000
148 #define NET_OPTION_OFFSET 0xD800
149 #define BEV_OPTION_OFFSET 0xD000
150 #define FD_OPTION_OFFSET 0xC000
151 #define HD_OPTION_OFFSET 0xB000
152 #define CD_OPTION_OFFSET 0xA000
153 #define FILE_OPTION_OFFSET 0x8000
154 #define FILE_OPTION_MASK 0x7FFF
155 #define HANDLE_OPTION_OFFSET 0x7000
156 #define CONSOLE_OPTION_OFFSET 0x6000
157 #define TERMINAL_OPTION_OFFSET 0x5000
158 #define CONFIG_OPTION_OFFSET 0x1200
159 #define KEY_VALUE_OFFSET 0x1100
160 #define FORM_ID_OFFSET 0x1000
163 // VarOffset that will be used to create question
164 // all these values are computed from the structure
167 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
170 // Question Id of Zero is invalid, so add an offset to it
172 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
174 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
175 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
176 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
177 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
178 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
179 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
180 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
181 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
182 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
183 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
184 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
185 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
186 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
187 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
188 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
189 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
190 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
191 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
192 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
193 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
194 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
195 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
196 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
197 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
198 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionToBeDeleted)
199 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
200 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
201 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
202 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
203 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
204 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
205 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
206 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
207 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
208 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
209 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
210 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
211 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
213 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
214 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
215 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
216 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
217 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
218 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
219 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
220 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
221 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
222 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
223 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
224 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
225 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
226 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
227 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
228 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
229 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
230 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
231 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
232 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
233 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
234 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
235 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
236 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
237 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)
238 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
239 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
240 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
241 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
242 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
243 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
244 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
245 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
246 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
247 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
248 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
249 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
250 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
252 #define STRING_DEPOSITORY_NUMBER 8
255 /// Serial Ports attributes, first one is the value for
256 /// return from callback function, stringtoken is used to
257 /// display the value properly
268 /// Length = sizeof (UINT16) + SIZEOF (Data)
272 } BM_LEGACY_DEV_ORDER_CONTEXT
;
291 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
292 } BM_TERMINAL_CONTEXT
;
296 BOOLEAN LoadOptionModified
;
301 BOOLEAN ForceReconnect
;
302 UINTN OptionalDataSize
;
304 UINTN LoadOptionSize
;
308 UINT16 FilePathListLength
;
310 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
321 } BM_LEGACY_DEVICE_CONTEXT
;
329 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
330 } BM_CONSOLE_CONTEXT
;
339 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
340 EFI_FILE_HANDLE FHandle
;
342 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
346 BOOLEAN IsRemovableMedia
;
348 BOOLEAN IsBootLegacy
;
353 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
366 UINT16
*DisplayString
;
368 EFI_STRING_ID DisplayStringToken
;
369 EFI_STRING_ID HelpStringToken
;
370 UINTN ContextSelection
;
371 VOID
*VariableContext
;
376 // Shared callback data.
380 BM_MENU_ENTRY
*MenuEntry
;
381 BM_HANDLE_CONTEXT
*HandleContext
;
382 BM_FILE_CONTEXT
*FileContext
;
383 BM_LOAD_CONTEXT
*LoadContext
;
384 BM_TERMINAL_CONTEXT
*TerminalContext
;
385 UINTN CurrentTerminal
;
389 // BMM main formset callback data.
391 EFI_HII_HANDLE BmmHiiHandle
;
392 EFI_HANDLE BmmDriverHandle
;
393 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
394 EFI_FORM_ID BmmCurrentPageId
;
395 EFI_FORM_ID BmmPreviousPageId
;
396 BOOLEAN BmmAskSaveOrNot
;
397 BMM_FAKE_NV_DATA BmmFakeNvData
;
398 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
401 // File explorer formset callback data.
403 EFI_HII_HANDLE FeHiiHandle
;
404 EFI_HANDLE FeDriverHandle
;
405 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
406 FILE_EXPLORER_STATE FeCurrentState
;
407 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
408 FILE_EXPLORER_NV_DATA FeFakeNvData
;
411 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
413 struct _STRING_LIST_NODE
{
414 EFI_STRING_ID StringToken
;
415 STRING_LIST_NODE
*Next
;
418 typedef struct _STRING_DEPOSITORY
{
419 UINTN TotalNodeNumber
;
420 STRING_LIST_NODE
*CurrentNode
;
421 STRING_LIST_NODE
*ListHead
;
427 // For initializing File System menu
431 This function build the FsOptionMenu list which records all
432 available file system in the system. They includes all instances
433 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
434 and all type of legacy boot device.
436 @param CallbackData BMM context data
438 @retval EFI_SUCCESS Success find the file system
439 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
443 BOpt_FindFileSystem (
444 IN BMM_CALLBACK_DATA
*CallbackData
448 Find files under current directory
449 All files and sub-directories in current directory
450 will be stored in DirectoryMenu for future use.
452 @param CallbackData The BMM context data.
453 @param MenuEntry The Menu Entry.
455 @retval EFI_SUCCESS Get files from current dir successfully.
456 @return Other value if can't get files from current dir.
461 IN BMM_CALLBACK_DATA
*CallbackData
,
462 IN BM_MENU_ENTRY
*MenuEntry
467 Find drivers that will be added as Driver#### variables from handles
468 in current system environment
469 All valid handles in the system except those consume SimpleFs, LoadFile
470 are stored in DriverMenu for future use.
472 @retval EFI_SUCCESS The function complets successfully.
473 @return Other value if failed to build the DriverMenu.
483 Build the BootOptionMenu according to BootOrder Variable.
484 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
486 @param CallbackData The BMM context data.
488 @return The number of the Var Boot####.
492 BOpt_GetBootOptions (
493 IN BMM_CALLBACK_DATA
*CallbackData
498 Build up all DriverOptionMenu
500 @param CallbackData The BMM context data.
502 @return EFI_SUCESS The functin completes successfully.
503 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
508 BOpt_GetDriverOptions (
509 IN BMM_CALLBACK_DATA
*CallbackData
514 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
516 @retval EFI_SUCCESS The function complete successfully.
517 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
521 BOpt_GetLegacyOptions (
526 Free out resouce allocated from Legacy Boot Options.
530 BOpt_FreeLegacyOptions (
535 Free resources allocated in Allocate Rountine.
537 @param FreeMenu Menu to be freed
542 BM_MENU_OPTION
*FreeMenu
548 Append file name to existing file name.
550 @param Str1 The existing file name
551 @param Str2 The file name to be appended
553 @return Allocate a new string to hold the appended result.
554 Caller is responsible to free the returned string.
558 BOpt_AppendFileName (
565 Check whether current FileName point to a valid
568 @param FileName File need to be checked.
570 @retval TRUE Is Efi Image
571 @retval FALSE Not a valid Efi Image
575 BOpt_IsEfiImageName (
581 Check whether current FileName point to a valid Efi Application
583 @param Dir Pointer to current Directory
584 @param FileName Pointer to current File name.
586 @retval TRUE Is a valid Efi Application
587 @retval FALSE not a valid Efi Application
592 IN EFI_FILE_HANDLE Dir
,
598 Get the Option Number that has not been allocated for use.
600 @return The available Option Number.
604 BOpt_GetBootOptionNumber (
610 Get the Option Number that is not in use.
612 @return The unused Option Number.
616 BOpt_GetDriverOptionNumber (
621 Create a menu entry give a Menu type.
623 @param MenuType The Menu type to be created.
626 @retval NULL If failed to create the menu.
631 BOpt_CreateMenuEntry (
636 Free up all resource allocated for a BM_MENU_ENTRY.
638 @param MenuEntry A pointer to BM_MENU_ENTRY.
642 BOpt_DestroyMenuEntry (
643 BM_MENU_ENTRY
*MenuEntry
647 Get the Menu Entry from the list in Menu Entry List.
649 If MenuNumber is great or equal to the number of Menu
650 Entry in the list, then ASSERT.
652 @param MenuOption The Menu Entry List to read the menu entry.
653 @param MenuNumber The index of Menu Entry.
655 @return The Menu Entry.
660 BM_MENU_OPTION
*MenuOption
,
665 // Locate all serial io devices for console
668 Build a list containing all serial devices.
670 @retval EFI_SUCCESS The function complete successfully.
671 @retval EFI_UNSUPPORTED No serial ports present.
680 // Initializing Console menu
683 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
685 @retval EFI_SUCCESS The function always complete successfully.
694 // Get current mode information
697 Get mode number according to column and row
699 @param CallbackData The BMM context data.
703 IN BMM_CALLBACK_DATA
*CallbackData
707 // Cleaning up console menu
710 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
712 @retval EFI_SUCCESS The function always complete successfully.
720 Update the device path that describing a terminal device
721 based on the new BaudRate, Data Bits, parity and Stop Bits
724 @param DevicePath The devicepath protocol instance wanted to be updated.
728 ChangeVariableDevicePath (
729 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
733 Update the multi-instance device path of Terminal Device based on
734 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
735 device path in the Terminal Device in TerminalMenu is also updated.
737 @param DevicePath The multi-instance device path.
738 @param ChangeTerminal TRUE, then device path in the Terminal Device
739 in TerminalMenu is also updated; FALSE, no update.
741 @return EFI_SUCCESS The function completes successfully.
745 ChangeTerminalDevicePath (
746 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
747 IN BOOLEAN ChangeTerminal
751 // Variable operation by menu selection
754 This function create a currently loaded Boot Option from
755 the BMM. It then appends this Boot Option to the end of
756 the "BootOrder" list. It also append this Boot Opotion to the end
759 @param CallbackData The BMM context data.
760 @param NvRamMap The file explorer formset internal state.
762 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
763 @retval EFI_SUCCESS If function completes successfully.
767 Var_UpdateBootOption (
768 IN BMM_CALLBACK_DATA
*CallbackData
,
769 IN FILE_EXPLORER_NV_DATA
*NvRamMap
773 Delete Boot Option that represent a Deleted state in BootOptionMenu.
774 After deleting this boot option, call Var_ChangeBootOrder to
775 make sure BootOrder is in valid state.
777 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
778 BM_LOAD_CONTEXT marked for deletion is deleted
779 @return Others If failed to update the "BootOrder" variable after deletion.
788 After any operation on Boot####, there will be a discrepancy in BootOrder.
789 Since some are missing but in BootOrder, while some are present but are
790 not reflected by BootOrder. Then a function rebuild BootOrder from
791 scratch by content from BootOptionMenu is needed.
793 @retval EFI_SUCCESS The boot order is updated successfully.
794 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
798 Var_ChangeBootOrder (
803 This function create a currently loaded Drive Option from
804 the BMM. It then appends this Driver Option to the end of
805 the "DriverOrder" list. It append this Driver Opotion to the end
808 @param CallbackData The BMM context data.
809 @param HiiHandle The HII handle associated with the BMM formset.
810 @param DescriptionData The description of this driver option.
811 @param OptionalData The optional load option.
812 @param ForceReconnect If to force reconnect.
814 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
815 @retval EFI_SUCCESS If function completes successfully.
819 Var_UpdateDriverOption (
820 IN BMM_CALLBACK_DATA
*CallbackData
,
821 IN EFI_HII_HANDLE HiiHandle
,
822 IN UINT16
*DescriptionData
,
823 IN UINT16
*OptionalData
,
824 IN UINT8 ForceReconnect
828 Delete Load Option that represent a Deleted state in BootOptionMenu.
829 After deleting this Driver option, call Var_ChangeDriverOrder to
830 make sure DriverOrder is in valid state.
832 @retval EFI_SUCCESS Load Option is successfully updated.
833 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
838 Var_DelDriverOption (
843 After any operation on Driver####, there will be a discrepancy in
844 DriverOrder. Since some are missing but in DriverOrder, while some
845 are present but are not reflected by DriverOrder. Then a function
846 rebuild DriverOrder from scratch by content from DriverOptionMenu is
849 @retval EFI_SUCCESS The driver order is updated successfully.
850 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
854 Var_ChangeDriverOrder (
859 This function delete and build multi-instance device path ConIn
862 @retval EFI_SUCCESS The function complete successfully.
863 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
866 Var_UpdateConsoleInpOption (
871 This function delete and build multi-instance device path ConOut console device.
873 @retval EFI_SUCCESS The function complete successfully.
874 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
877 Var_UpdateConsoleOutOption (
882 This function delete and build multi-instance device path ErrOut console device.
884 @retval EFI_SUCCESS The function complete successfully.
885 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
888 Var_UpdateErrorOutOption (
893 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
894 parity and stop Bits set.
898 Var_UpdateAllConsoleOption (
903 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
904 this EFI Variable is deleted.
905 It also update the BMM context data specified the "BootNext" value.
907 @param CallbackData The BMM context data.
909 @retval EFI_SUCCESS The function complete successfully.
910 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
915 IN BMM_CALLBACK_DATA
*CallbackData
919 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
920 BootOptionMenu with the new "BootOrder" list.
922 @param CallbackData The BMM context data.
924 @retval EFI_SUCCESS The function complete successfully.
925 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
926 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
930 Var_UpdateBootOrder (
931 IN BMM_CALLBACK_DATA
*CallbackData
935 This function update the "DriverOrder" EFI Variable based on
936 BMM Formset's NV map. It then refresh DriverOptionMenu
937 with the new "DriverOrder" list.
939 @param CallbackData The BMM context data.
941 @retval EFI_SUCCESS The function complete successfully.
942 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
943 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
947 Var_UpdateDriverOrder (
948 IN BMM_CALLBACK_DATA
*CallbackData
952 Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable
953 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
956 @param CallbackData The context data for BMM.
958 @return EFI_SUCCESS The function completed successfully.
959 @retval EFI_NOT_FOUND If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can not be found.
963 Var_UpdateBBSOption (
964 IN BMM_CALLBACK_DATA
*CallbackData
968 Update the Text Mode of Console.
970 @param CallbackData The context data for BMM.
972 @retval EFI_SUCCSS If the Text Mode of Console is updated.
973 @return Other value if the Text Mode of Console is not updated.
978 IN BMM_CALLBACK_DATA
*CallbackData
982 // Following are page create and refresh functions
985 Refresh the global UpdateData structure.
994 Clean up the dynamic opcode at label and form specified by
997 @param LabelId It is both the Form ID and Label ID for
999 @param CallbackData The BMM context data.
1005 IN BMM_CALLBACK_DATA
*CallbackData
1009 Create a lit of boot option from global BootOptionMenu. It
1010 allow user to delete the boot option.
1012 @param CallbackData The BMM context data.
1017 IN BMM_CALLBACK_DATA
*CallbackData
1021 Create a lit of driver option from global DriverMenu.
1023 @param CallbackData The BMM context data.
1026 UpdateDrvAddHandlePage (
1027 IN BMM_CALLBACK_DATA
*CallbackData
1031 Create a lit of driver option from global DriverOptionMenu. It
1032 allow user to delete the driver option.
1034 @param CallbackData The BMM context data.
1038 IN BMM_CALLBACK_DATA
*CallbackData
1042 Prepare the page to allow user to add description for a Driver Option.
1044 @param CallbackData The BMM context data.
1047 UpdateDriverAddHandleDescPage (
1048 IN BMM_CALLBACK_DATA
*CallbackData
1052 Dispatch the correct update page function to call based on the UpdatePageId.
1054 @param UpdatePageId The form ID.
1055 @param CallbackData The BMM context data.
1059 IN UINT16 UpdatePageId
,
1060 IN BMM_CALLBACK_DATA
*CallbackData
1064 Create the dynamic page to allow user to set the "BootNext" vaule.
1066 @param CallbackData The BMM context data.
1069 UpdateBootNextPage (
1070 IN BMM_CALLBACK_DATA
*CallbackData
1074 Create the dynamic page to allow user to set the "TimeOut" vaule.
1076 @param CallbackData The BMM context data.
1080 IN BMM_CALLBACK_DATA
*CallbackData
1084 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1085 Parity, Stop Bits, Terminal Type.
1087 @param CallbackData The BMM context data.
1090 UpdateTerminalPage (
1091 IN BMM_CALLBACK_DATA
*CallbackData
1095 Refresh the text mode page
1097 @param CallbackData The BMM context data.
1101 IN BMM_CALLBACK_DATA
*CallbackData
1105 Create a list of Goto Opcode for all terminal devices logged
1106 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1108 @param CallbackData The BMM context data.
1112 IN BMM_CALLBACK_DATA
*CallbackData
1116 Create a dynamic page so that Legacy Device boot order
1117 can be set for specified device type.
1119 @param UpdatePageId The form ID. It also spefies the legacy device type.
1120 @param CallbackData The BMM context data.
1123 UpdateSetLegacyDeviceOrderPage (
1124 IN UINT16 UpdatePageId
,
1125 IN BMM_CALLBACK_DATA
*CallbackData
1130 Function opens and returns a file handle to the root directory of a volume.
1132 @param DeviceHandle A handle for a device
1133 @return A valid file handle or NULL is returned
1137 IN EFI_HANDLE DeviceHandle
1141 Function gets the file system information from an open file descriptor,
1142 and stores it in a buffer allocated from pool.
1144 @param FHand The file handle.
1146 @return A pointer to a buffer with file information.
1147 NULL is returned if failed to get Vaolume Label Info.
1149 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1150 EfiLibFileSystemVolumeLabelInfo (
1151 IN EFI_FILE_HANDLE FHand
1156 Function gets the file information from an open file descriptor, and stores it
1157 in a buffer allocated from pool.
1159 @param FHand File Handle.
1161 @return A pointer to a buffer with file information or NULL is returned
1166 IN EFI_FILE_HANDLE FHand
1170 Find the first instance of this Protocol in the system and return it's interface.
1172 @param ProtocolGuid Provides the protocol to search for
1173 @param Interface On return, a pointer to the first interface
1174 that matches ProtocolGuid
1176 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1177 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1181 EfiLibLocateProtocol (
1182 IN EFI_GUID
*ProtocolGuid
,
1183 OUT VOID
**Interface
1187 Adjusts the size of a previously allocated buffer.
1189 @param OldPool A pointer to the buffer whose size is being adjusted.
1190 @param OldSize The size of the current buffer.
1191 @param NewSize The size of the new buffer.
1193 @return The newly allocated buffer. if NULL, allocation failed.
1204 Function deletes the variable specified by VarName and VarGuid.
1207 @param VarName A Null-terminated Unicode string that is
1208 the name of the vendor's variable.
1210 @param VarGuid A unique identifier for the vendor.
1212 @retval EFI_SUCCESS The variable was found and removed
1213 @retval EFI_UNSUPPORTED The variable store was inaccessible
1214 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1215 @retval EFI_NOT_FOUND The variable was not found
1219 EfiLibDeleteVariable (
1221 IN EFI_GUID
*VarGuid
1227 @param Src The source.
1229 @return A new string which is duplicated copy of the source.
1230 @retval NULL If there is not enough memory.
1239 Function is used to determine the number of device path instances
1240 that exist in a device path.
1243 @param DevicePath A pointer to a device path data structure.
1245 @return This function counts and returns the number of device path instances
1250 EfiDevicePathInstanceCount (
1251 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1255 Create string tokens for a menu from its help strings and display strings
1258 @param CallbackData The BMM context data.
1259 @param HiiHandle Hii Handle of the package to be updated.
1260 @param MenuOption The Menu whose string tokens need to be created
1262 @retval EFI_SUCCESS string tokens created successfully
1263 @retval others contain some errors
1267 CreateMenuStringToken (
1268 IN BMM_CALLBACK_DATA
*CallbackData
,
1269 IN EFI_HII_HANDLE HiiHandle
,
1270 IN BM_MENU_OPTION
*MenuOption
1274 Get a string from the Data Hub record based on
1277 @param DevPath The device Path.
1279 @return A string located from the Data Hub records based on
1281 @retval NULL If failed to get the String from Data Hub.
1285 EfiLibStrFromDatahub (
1286 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1290 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1291 specified by DeviceType.
1293 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1295 @param OptionIndex Returns the index number (#### in Boot####).
1296 @param OptionSize Return the size of the Boot### variable.
1300 GetLegacyBootOptionVar (
1301 IN UINTN DeviceType
,
1302 OUT UINTN
*OptionIndex
,
1303 OUT UINTN
*OptionSize
1307 Initialize the Boot Maintenance Utitliy.
1309 @retval EFI_SUCCESS utility ended successfully.
1310 @retval others contain some errors.
1319 Start boot maintenance manager
1321 @retval EFI_SUCCESS If BMM is invoked successfully.
1322 @return Other value if BMM return unsuccessfully.
1331 Intialize all the string depositories.
1335 InitializeStringDepository (
1340 Fetch a usable string node from the string depository and return the string token.
1343 @param CallbackData The BMM context data.
1344 @param StringDepository Pointer of the string depository.
1346 @retval EFI_STRING_ID String token.
1350 GetStringTokenFromDepository (
1351 IN BMM_CALLBACK_DATA
*CallbackData
,
1352 IN STRING_DEPOSITORY
*StringDepository
1356 Reclaim string depositories by moving the current node pointer to list head..
1359 ReclaimStringDepository (
1364 Release resource for all the string depositories.
1368 CleanUpStringDepository (
1373 Function handling request to apply changes for BMM pages.
1375 @param Private Pointer to callback data buffer.
1376 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1377 @param FormId ID of the form which has sent the request to apply change.
1379 @retval EFI_SUCCESS Change successfully applied.
1380 @retval Other Error occurs while trying to apply changes.
1384 ApplyChangeHandler (
1385 IN BMM_CALLBACK_DATA
*Private
,
1386 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1387 IN EFI_FORM_ID FormId
1391 Discard all changes done to the BMM pages such as Boot Order change,
1392 Driver order change.
1394 @param Private The BMM context data.
1395 @param CurrentFakeNVMap The current Fack NV Map.
1399 DiscardChangeHandler (
1400 IN BMM_CALLBACK_DATA
*Private
,
1401 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1405 Dispatch the display to the next page based on NewPageId.
1407 @param Private The BMM context data.
1408 @param NewPageId The original page ID.
1413 BMM_CALLBACK_DATA
*Private
,
1418 Boot a file selected by user at File Expoloer of BMM.
1420 @param FileContext The file context data, which contains the device path
1421 of the file to be boot from.
1423 @retval EFI_SUCCESS The function completed successfull.
1424 @return Other value if the boot from the file fails.
1429 IN BM_FILE_CONTEXT
*FileContext
1433 Update the file explower page with the refershed file system.
1436 @param CallbackData BMM context data
1437 @param KeyValue Key value to identify the type of data to expect.
1439 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1440 @retval FALSE Indicate that there is no need to exit file explorer.
1444 UpdateFileExplorer (
1445 IN BMM_CALLBACK_DATA
*CallbackData
,
1450 This function processes the results of changes in configuration.
1451 When user select a interactive opcode, this callback will be triggered.
1452 Based on the Question(QuestionId) that triggers the callback, the corresponding
1453 actions is performed. It handles:
1455 1) the addition of boot option.
1456 2) the addition of driver option.
1457 3) exit from file browser
1458 4) update of file content if a dir is selected.
1459 5) boot the file if a file is selected in "boot from file"
1462 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1463 @param Action Specifies the type of action taken by the browser.
1464 @param QuestionId A unique value which is sent to the original exporting driver
1465 so that it can identify the type of data to expect.
1466 @param Type The type of value for the question.
1467 @param Value A pointer to the data being sent to the original exporting driver.
1468 @param ActionRequest On return, points to the action requested by the callback function.
1470 @retval EFI_SUCCESS The callback successfully handled the action.
1471 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1472 @retval EFI_DEVICE_ERROR The variable could not be saved.
1473 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1478 FileExplorerCallback (
1479 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1480 IN EFI_BROWSER_ACTION Action
,
1481 IN EFI_QUESTION_ID QuestionId
,
1483 IN EFI_IFR_TYPE_VALUE
*Value
,
1484 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1488 Dispatch BMM formset and FileExplorer formset.
1491 @param CallbackData The BMM context data.
1493 @retval EFI_SUCCESS If function complete successfully.
1494 @return Other value if the Setup Browser process BMM's pages and
1495 return unsuccessfully.
1500 IN BMM_CALLBACK_DATA
*CallbackData
1504 Function returns the value of the specified variable.
1506 @param Name A Null-terminated Unicode string that is
1507 the name of the vendor's variable.
1508 @param VendorGuid A unique identifier for the vendor.
1510 @return The payload of the variable.
1511 @retval NULL If the variable can't be read.
1517 IN EFI_GUID
*VendorGuid
1521 // Global variable in this program (defined in data.c)
1523 extern BM_MENU_OPTION BootOptionMenu
;
1524 extern BM_MENU_OPTION DriverOptionMenu
;
1525 extern BM_MENU_OPTION FsOptionMenu
;
1526 extern BM_MENU_OPTION ConsoleInpMenu
;
1527 extern BM_MENU_OPTION ConsoleOutMenu
;
1528 extern BM_MENU_OPTION ConsoleErrMenu
;
1529 extern BM_MENU_OPTION DirectoryMenu
;
1530 extern BM_MENU_OPTION DriverMenu
;
1531 extern BM_MENU_OPTION TerminalMenu
;
1532 extern BM_MENU_OPTION LegacyFDMenu
;
1533 extern BM_MENU_OPTION LegacyHDMenu
;
1534 extern BM_MENU_OPTION LegacyCDMenu
;
1535 extern BM_MENU_OPTION LegacyNETMenu
;
1536 extern BM_MENU_OPTION LegacyBEVMenu
;
1537 extern UINT16 TerminalType
[];
1538 extern COM_ATTR BaudRateList
[19];
1539 extern COM_ATTR DataBitsList
[4];
1540 extern COM_ATTR ParityList
[5];
1541 extern COM_ATTR StopBitsList
[3];
1542 extern EFI_GUID TerminalTypeGuid
[4];
1543 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1544 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1545 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1546 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1547 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1548 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1549 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1550 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1551 extern EFI_GUID EfiLegacyDevOrderGuid
;
1554 // Shared IFR form update data
1556 extern VOID
*mStartOpCodeHandle
;
1557 extern VOID
*mEndOpCodeHandle
;
1558 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1559 extern EFI_IFR_GUID_LABEL
*mEndLabel
;