2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2008, 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
;
68 // These are the VFR compiler generated data representing our VFR data.
74 // Below are the number of options in Baudrate, Databits,
75 // Parity and Stopbits selection for serial ports.
77 #define BM_COM_ATTR_BUADRATE 19
78 #define BM_COM_ATTR_DATABITS 4
79 #define BM_COM_ATTR_PARITY 5
80 #define BM_COM_ATTR_STOPBITS 3
83 // Callback function helper
85 #define BMM_CALLBACK_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'b', 'c', 'k')
86 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
88 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
91 // Enumeration type definition
93 typedef UINT8 BBS_TYPE
;
128 } TYPE_OF_UPATE_MANNER
;
132 BOOT_FROM_FILE_STATE
,
133 ADD_BOOT_OPTION_STATE
,
134 ADD_DRIVER_OPTION_STATE
,
136 } FILE_EXPLORER_STATE
;
142 } FILE_EXPLORER_DISPLAY_CONTEXT
;
145 // All of the signatures that will be used in list structure
147 #define BM_MENU_OPTION_SIGNATURE EFI_SIGNATURE_32 ('m', 'e', 'n', 'u')
148 #define BM_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'a', 'd')
149 #define BM_CONSOLE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('c', 'n', 's', 'l')
150 #define BM_FILE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('f', 'i', 'l', 'e')
151 #define BM_HANDLE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('h', 'n', 'd', 'l')
152 #define BM_TERMINAL_OPTION_SIGNATURE EFI_SIGNATURE_32 ('t', 'r', 'm', 'l')
153 #define BM_MENU_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('e', 'n', 't', 'r')
155 #define BM_LOAD_CONTEXT_SELECT 0x0
156 #define BM_CONSOLE_CONTEXT_SELECT 0x1
157 #define BM_FILE_CONTEXT_SELECT 0x2
158 #define BM_HANDLE_CONTEXT_SELECT 0x3
159 #define BM_TERMINAL_CONTEXT_SELECT 0x5
161 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
162 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
163 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
164 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
167 // Buffer size for update data
169 #define UPDATE_DATA_SIZE 0x100000
172 // Namespace of callback keys used in display and file system navigation
174 #define MAX_BBS_OFFSET 0xE000
175 #define NET_OPTION_OFFSET 0xD800
176 #define BEV_OPTION_OFFSET 0xD000
177 #define FD_OPTION_OFFSET 0xC000
178 #define HD_OPTION_OFFSET 0xB000
179 #define CD_OPTION_OFFSET 0xA000
180 #define FILE_OPTION_OFFSET 0x8000
181 #define FILE_OPTION_MASK 0x7FFF
182 #define HANDLE_OPTION_OFFSET 0x7000
183 #define CONSOLE_OPTION_OFFSET 0x6000
184 #define TERMINAL_OPTION_OFFSET 0x5000
185 #define CONFIG_OPTION_OFFSET 0x1200
186 #define KEY_VALUE_OFFSET 0x1100
187 #define FORM_ID_OFFSET 0x1000
190 // VarOffset that will be used to create question
191 // all these values are computed from the structure
194 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
197 // Question Id of Zero is invalid, so add an offset to it
199 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
201 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
202 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
203 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
204 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
205 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
206 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
207 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
208 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
209 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
210 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
211 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
212 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
213 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
214 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
215 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
216 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
217 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
218 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
219 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
220 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
221 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
222 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
223 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
224 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
225 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionToBeDeleted)
226 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
227 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
228 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
229 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
230 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
231 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
232 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
233 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
234 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
235 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
236 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
237 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
238 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
240 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
241 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
242 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
243 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
244 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
245 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
246 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
247 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
248 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
249 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
250 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
251 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
252 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
253 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
254 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
255 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
256 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
257 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
258 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
259 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
260 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
261 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
262 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
263 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
264 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)
265 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
266 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
267 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
268 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
269 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
270 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
271 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
272 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
273 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
274 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
275 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
276 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
277 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
279 #define STRING_DEPOSITORY_NUMBER 8
282 /// Serial Ports attributes, first one is the value for
283 /// return from callback function, stringtoken is used to
284 /// display the value properly
295 // Length = sizeof (UINT16) + SIZEOF (Data)
299 } BM_LEGACY_DEV_ORDER_CONTEXT
;
318 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
319 } BM_TERMINAL_CONTEXT
;
323 BOOLEAN LoadOptionModified
;
328 BOOLEAN ForceReconnect
;
329 UINTN OptionalDataSize
;
331 UINTN LoadOptionSize
;
335 UINT16 FilePathListLength
;
337 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
348 } BM_LEGACY_DEVICE_CONTEXT
;
356 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
357 } BM_CONSOLE_CONTEXT
;
366 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
367 EFI_FILE_HANDLE FHandle
;
369 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*Info
;
373 BOOLEAN IsRemovableMedia
;
375 BOOLEAN IsBootLegacy
;
380 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
393 UINT16
*DisplayString
;
395 EFI_STRING_ID DisplayStringToken
;
396 EFI_STRING_ID HelpStringToken
;
397 UINTN ContextSelection
;
398 VOID
*VariableContext
;
403 // Shared callback data.
407 BM_MENU_ENTRY
*MenuEntry
;
408 BM_HANDLE_CONTEXT
*HandleContext
;
409 BM_FILE_CONTEXT
*FileContext
;
410 BM_LOAD_CONTEXT
*LoadContext
;
411 BM_TERMINAL_CONTEXT
*TerminalContext
;
412 UINTN CurrentTerminal
;
416 // BMM main formset callback data.
418 EFI_HII_HANDLE BmmHiiHandle
;
419 EFI_HANDLE BmmDriverHandle
;
420 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
421 EFI_FORM_ID BmmCurrentPageId
;
422 EFI_FORM_ID BmmPreviousPageId
;
423 BOOLEAN BmmAskSaveOrNot
;
424 BMM_FAKE_NV_DATA BmmFakeNvData
;
425 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
428 // File explorer formset callback data.
430 EFI_HII_HANDLE FeHiiHandle
;
431 EFI_HANDLE FeDriverHandle
;
432 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
433 FILE_EXPLORER_STATE FeCurrentState
;
434 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
435 FILE_EXPLORER_NV_DATA FeFakeNvData
;
438 typedef struct _STRING_LIST_NODE
{
439 EFI_STRING_ID StringToken
;
440 struct _STRING_LIST_NODE
*Next
;
443 typedef struct _STRING_DEPOSITORY
{
444 UINTN TotalNodeNumber
;
445 STRING_LIST_NODE
*CurrentNode
;
446 STRING_LIST_NODE
*ListHead
;
452 // For initializing File System menu
456 This function build the FsOptionMenu list which records all
457 available file system in the system. They includes all instances
458 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
459 and all type of legacy boot device.
461 @param CallbackData BMM context data
463 @retval EFI_SUCCESS Success find the file system
464 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
468 BOpt_FindFileSystem (
469 IN BMM_CALLBACK_DATA
*CallbackData
474 Find files under current directory
475 All files and sub-directories in current directory
476 will be stored in DirectoryMenu for future use.
478 @param CallbackData The BMM context data.
479 @param MenuEntry The Menu Entry.
481 @retval EFI_SUCCESS Get files from current dir successfully.
482 @return Other value if can't get files from current dir.
487 IN BMM_CALLBACK_DATA
*CallbackData
,
488 IN BM_MENU_ENTRY
*MenuEntry
494 Find drivers that will be added as Driver#### variables from handles
495 in current system environment
496 All valid handles in the system except those consume SimpleFs, LoadFile
497 are stored in DriverMenu for future use.
499 @retval EFI_SUCCESS The function complets successfully.
500 @return Other value if failed to build the DriverMenu.
511 Build the BootOptionMenu according to BootOrder Variable.
512 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
514 @param CallbackData The BMM context data.
516 @return The number of the Var Boot####.
520 BOpt_GetBootOptions (
521 IN BMM_CALLBACK_DATA
*CallbackData
526 Build up all DriverOptionMenu
528 @param CallbackData The BMM context data.
530 @return EFI_SUCESS The functin completes successfully.
531 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
536 BOpt_GetDriverOptions (
537 IN BMM_CALLBACK_DATA
*CallbackData
542 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
546 @retval EFI_SUCCESS The function complete successfully.
547 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
551 BOpt_GetLegacyOptions (
556 Free out resouce allocated from Legacy Boot Options.
564 BOpt_FreeLegacyOptions (
569 Free resources allocated in Allocate Rountine.
571 @param FreeMenu Menu to be freed
578 BM_MENU_OPTION
*FreeMenu
584 Append file name to existing file name.
586 @param Str1 The existing file name
587 @param Str2 The file name to be appended
589 @return Allocate a new string to hold the appended result.
590 Caller is responsible to free the returned string.
594 BOpt_AppendFileName (
601 Check whether current FileName point to a valid
604 @param FileName File need to be checked.
606 @retval TRUE Is Efi Image
607 @retval FALSE Not a valid Efi Image
611 BOpt_IsEfiImageName (
617 Check whether current FileName point to a valid Efi Application
619 @param Dir Pointer to current Directory
620 @param FileName Pointer to current File name.
622 @retval TRUE Is a valid Efi Application
623 @retval FALSE not a valid Efi Application
628 IN EFI_FILE_HANDLE Dir
,
634 Get the Option Number that has not been allocated for use.
636 @return The available Option Number.
640 BOpt_GetBootOptionNumber (
646 Get the Option Number that is not in use.
648 @return The unused Option Number.
652 BOpt_GetDriverOptionNumber (
657 Create a menu entry give a Menu type.
659 @param MenuType The Menu type to be created.
662 @retval NULL If failed to create the menu.
667 BOpt_CreateMenuEntry (
672 Free up all resource allocated for a BM_MENU_ENTRY.
674 @param MenuEntry A pointer to BM_MENU_ENTRY.
678 BOpt_DestroyMenuEntry (
679 BM_MENU_ENTRY
*MenuEntry
683 Get the Menu Entry from the list in Menu Entry List.
685 If MenuNumber is great or equal to the number of Menu
686 Entry in the list, then ASSERT.
688 @param MenuOption The Menu Entry List to read the menu entry.
689 @param MenuNumber The index of Menu Entry.
691 @return The Menu Entry.
696 BM_MENU_OPTION
*MenuOption
,
701 // Locate all serial io devices for console
704 Build a list containing all serial devices.
707 @retval EFI_SUCCESS The function complete successfully.
708 @retval EFI_UNSUPPORTED No serial ports present.
717 // Initializing Console menu
720 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
725 @retval EFI_SUCCESS The function always complete successfully.
734 // Get current mode information
737 Get mode number according to column and row
740 @param CallbackData The BMM context data.
747 IN BMM_CALLBACK_DATA
*CallbackData
751 // Cleaning up console menu
754 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
757 EDES_TODO: Add parameter description
759 @retval EFI_SUCCESS The function always complete successfully.
767 Update the device path that describing a terminal device
768 based on the new BaudRate, Data Bits, parity and Stop Bits
777 ChangeVariableDevicePath (
778 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
783 Update the multi-instance device path of Terminal Device based on
784 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
785 device path in the Terminal Device in TerminalMenu is also updated.
787 @param DevicePath The multi-instance device path.
788 @param ChangeTerminal TRUE, then device path in the Terminal Device
789 in TerminalMenu is also updated; FALSE, no update.
791 @return EFI_SUCCESS The function completes successfully.
795 ChangeTerminalDevicePath (
796 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
797 IN BOOLEAN ChangeTerminal
800 // Variable operation by menu selection
803 This function create a currently loaded Boot Option from
804 the BMM. It then appends this Boot Option to the end of
805 the "BootOrder" list. It also append this Boot Opotion to the end
808 @param CallbackData The BMM context data.
809 @param NvRamMap The file explorer formset internal state.
811 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
812 @retval EFI_SUCCESS If function completes successfully.
816 Var_UpdateBootOption (
817 IN BMM_CALLBACK_DATA
*CallbackData
,
818 IN FILE_EXPLORER_NV_DATA
*NvRamMap
822 Delete Boot Option that represent a Deleted state in BootOptionMenu.
823 After deleting this boot option, call Var_ChangeBootOrder to
824 make sure BootOrder is in valid state.
827 EDES_TODO: Add parameter description
829 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
830 BM_LOAD_CONTEXT marked for deletion is deleted
831 @return Others If failed to update the "BootOrder" variable after deletion.
840 After any operation on Boot####, there will be a discrepancy in BootOrder.
841 Since some are missing but in BootOrder, while some are present but are
842 not reflected by BootOrder. Then a function rebuild BootOrder from
843 scratch by content from BootOptionMenu is needed.
848 @retval EFI_SUCCESS The boot order is updated successfully.
849 @return EFI_STATUS other than EFI_SUCCESS if failed to
850 Set the "BootOrder" EFI Variable.
854 Var_ChangeBootOrder (
859 This function create a currently loaded Drive Option from
860 the BMM. It then appends this Driver Option to the end of
861 the "DriverOrder" list. It append this Driver Opotion to the end
864 @param CallbackData The BMM context data.
865 @param HiiHandle The HII handle associated with the BMM formset.
866 @param DescriptionData The description of this driver option.
867 @param OptionalData The optional load option.
868 @param ForceReconnect EDES_TODO: Add parameter description
870 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
871 @retval EFI_SUCCESS If function completes successfully.
875 Var_UpdateDriverOption (
876 IN BMM_CALLBACK_DATA
*CallbackData
,
877 IN EFI_HII_HANDLE HiiHandle
,
878 IN UINT16
*DescriptionData
,
879 IN UINT16
*OptionalData
,
880 IN UINT8 ForceReconnect
884 Delete Load Option that represent a Deleted state in BootOptionMenu.
885 After deleting this Driver option, call Var_ChangeDriverOrder to
886 make sure DriverOrder is in valid state.
891 @retval EFI_SUCCESS Load Option is successfully updated.
892 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
897 Var_DelDriverOption (
902 After any operation on Driver####, there will be a discrepancy in
903 DriverOrder. Since some are missing but in DriverOrder, while some
904 are present but are not reflected by DriverOrder. Then a function
905 rebuild DriverOrder from scratch by content from DriverOptionMenu is
911 @retval EFI_SUCCESS The driver order is updated successfully.
912 @return EFI_STATUS other than EFI_SUCCESS if failed to
913 Set the "DriverOrder" EFI Variable.
917 Var_ChangeDriverOrder (
922 This function delete and build multi-instance device path ConIn
928 @retval EFI_SUCCESS The function complete successfully.
929 @return The EFI variable can be saved. See gRT->SetVariable
930 for detail return information.
933 Var_UpdateConsoleInpOption (
938 This function delete and build multi-instance device path ConOut
944 @retval EFI_SUCCESS The function complete successfully.
945 @return The EFI variable can be saved. See gRT->SetVariable
946 for detail return information.
949 Var_UpdateConsoleOutOption (
954 This function delete and build multi-instance device path ErrOut
960 @retval EFI_SUCCESS The function complete successfully.
961 @return The EFI variable can be saved. See gRT->SetVariable
962 for detail return information.
965 Var_UpdateErrorOutOption (
970 Update the device path of "ConOut", "ConIn" and "ErrOut"
971 based on the new BaudRate, Data Bits, parity and Stop Bits
980 Var_UpdateAllConsoleOption (
985 This function update the "BootNext" EFI Variable. If there is
986 no "BootNex" specified in BMM, this EFI Variable is deleted.
987 It also update the BMM context data specified the "BootNext"
990 @param CallbackData The BMM context data.
992 @retval EFI_SUCCESS The function complete successfully.
993 @return The EFI variable can be saved. See gRT->SetVariable
994 for detail return information.
999 IN BMM_CALLBACK_DATA
*CallbackData
1003 This function update the "BootOrder" EFI Variable based on
1004 BMM Formset's NV map. It then refresh BootOptionMenu
1005 with the new "BootOrder" list.
1007 @param CallbackData The BMM context data.
1009 @retval EFI_SUCCESS The function complete successfully.
1010 @retval EFI_SUCCESS Not enough memory to complete the function.
1011 @return The EFI variable can be saved. See gRT->SetVariable
1012 for detail return information.
1016 Var_UpdateBootOrder (
1017 IN BMM_CALLBACK_DATA
*CallbackData
1021 This function update the "DriverOrder" EFI Variable based on
1022 BMM Formset's NV map. It then refresh DriverOptionMenu
1023 with the new "DriverOrder" list.
1025 @param CallbackData The BMM context data.
1027 @retval EFI_SUCCESS The function complete successfully.
1028 @retval EFI_SUCCESS Not enough memory to complete the function.
1029 @return The EFI variable can be saved. See gRT->SetVariable
1030 for detail return information.
1034 Var_UpdateDriverOrder (
1035 IN BMM_CALLBACK_DATA
*CallbackData
1039 Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable
1040 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
1043 @param CallbackData The context data for BMM.
1045 @return EFI_SUCCESS The function completed successfully.
1046 @retval EFI_NOT_FOUND If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can be found.
1050 Var_UpdateBBSOption (
1051 IN BMM_CALLBACK_DATA
*CallbackData
1055 Update the Text Mode of Console.
1057 @param CallbackData The context data for BMM.
1059 @retval EFI_SUCCSS If the Text Mode of Console is updated.
1060 @return Other value if the Text Mode of Console is not updated.
1065 IN BMM_CALLBACK_DATA
*CallbackData
1069 // Following are page create and refresh functions
1072 Refresh the global UpdateData structure.
1085 Clean up the dynamic opcode at label and form specified by
1088 @param LabelId It is both the Form ID and Label ID for
1090 @param CallbackData The BMM context data.
1098 IN BMM_CALLBACK_DATA
*CallbackData
1102 Create a lit of boot option from global BootOptionMenu. It
1103 allow user to delete the boot option.
1105 @param CallbackData The BMM context data.
1112 IN BMM_CALLBACK_DATA
*CallbackData
1116 Create a lit of driver option from global DriverMenu.
1118 @param CallbackData The BMM context data.
1124 UpdateDrvAddHandlePage (
1125 IN BMM_CALLBACK_DATA
*CallbackData
1129 Create a lit of driver option from global DriverOptionMenu. It
1130 allow user to delete the driver option.
1133 @param CallbackData The BMM context data.
1140 IN BMM_CALLBACK_DATA
*CallbackData
1144 Prepare the page to allow user to add description for
1147 @param CallbackData The BMM context data.
1153 UpdateDriverAddHandleDescPage (
1154 IN BMM_CALLBACK_DATA
*CallbackData
1158 Dispatch the correct update page function to call based on
1161 @param UpdatePageId The form ID.
1162 @param CallbackData The BMM context data.
1169 IN UINT16 UpdatePageId
,
1170 IN BMM_CALLBACK_DATA
*CallbackData
1174 Create the dynamic page to allow user to set
1175 the "BootNext" vaule.
1177 @param CallbackData The BMM context data.
1183 UpdateBootNextPage (
1184 IN BMM_CALLBACK_DATA
*CallbackData
1188 Create the dynamic page to allow user to set
1189 the "TimeOut" vaule.
1191 @param CallbackData The BMM context data.
1198 IN BMM_CALLBACK_DATA
*CallbackData
1202 Create the dynamic page which allows user to
1203 set the property such as Baud Rate, Data Bits,
1204 Parity, Stop Bits, Terminal Type.
1206 @param CallbackData The BMM context data.
1212 UpdateTerminalPage (
1213 IN BMM_CALLBACK_DATA
*CallbackData
1217 Refresh the text mode page
1220 @param CallbackData The BMM context data.
1227 IN BMM_CALLBACK_DATA
*CallbackData
1231 Create a list of Goto Opcode for all terminal devices logged
1232 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1234 @param CallbackData The BMM context data.
1241 IN BMM_CALLBACK_DATA
*CallbackData
1245 Create a dynamic page so that Legacy Device boot order
1246 can be set for specified device type.
1248 @param UpdatePageId The form ID. It also spefies the legacy device type.
1249 @param CallbackData The BMM context data.
1255 UpdateSetLegacyDeviceOrderPage (
1256 IN UINT16 UpdatePageId
,
1257 IN BMM_CALLBACK_DATA
*CallbackData
1263 Function opens and returns a file handle to the root directory of a volume.
1266 @param DeviceHandle - A handle for a device
1268 @return A valid file handle or NULL is returned
1273 IN EFI_HANDLE DeviceHandle
1278 Function gets the file system information from an open file descriptor,
1279 and stores it in a buffer allocated from pool.
1282 @param FHand The file handle.
1284 @return A pointer to a buffer with file information.
1285 @retval NULL is returned if failed to get Vaolume Label Info.
1288 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*
1289 EfiLibFileSystemVolumeLabelInfo (
1290 IN EFI_FILE_HANDLE FHand
1295 Function gets the file information from an open file descriptor, and stores it
1296 in a buffer allocated from pool.
1298 @param FHand File Handle.
1300 @return A pointer to a buffer with file information or NULL is returned
1305 IN EFI_FILE_HANDLE FHand
1309 This function converts an input device structure to a Unicode string.
1311 @param DevPath A pointer to the device path structure.
1313 @return A new allocated Unicode string that represents the device path.
1318 EFI_DEVICE_PATH_PROTOCOL
*DevPath
1323 Find the first instance of this Protocol
1324 in the system and return it's interface.
1327 @param ProtocolGuid Provides the protocol to search for
1328 @param Interface On return, a pointer to the first interface
1329 that matches ProtocolGuid
1331 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1332 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1336 EfiLibLocateProtocol (
1337 IN EFI_GUID
*ProtocolGuid
,
1338 OUT VOID
**Interface
1342 Adjusts the size of a previously allocated buffer.
1345 @param OldPool - A pointer to the buffer whose size is being adjusted.
1346 @param OldSize - The size of the current buffer.
1347 @param NewSize - The size of the new buffer.
1349 @return The newly allocated buffer.
1350 @retval NULL Allocation failed.
1361 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
1362 buffer, and the size of the buffer. If failure return NULL.
1364 @param Name String part of EFI variable name
1365 @param VendorGuid GUID part of EFI variable name
1366 @param VarSize Returns the size of the EFI variable that was read
1368 @return Dynamically allocated memory that contains a copy of the EFI variable.
1369 @return Caller is responsible freeing the buffer.
1370 @retval NULL Variable was not read
1374 BdsLibGetVariableAndSize (
1376 IN EFI_GUID
*VendorGuid
,
1381 Function deletes the variable specified by VarName and VarGuid.
1384 @param VarName - A Null-terminated Unicode string that is
1385 the name of the vendor's variable.
1387 @param VarGuid - A unique identifier for the vendor.
1389 @retval EFI_SUCCESS The variable was found and removed
1390 @retval EFI_UNSUPPORTED The variable store was inaccessible
1391 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1392 @retval EFI_NOT_FOUND The variable was not found
1396 EfiLibDeleteVariable (
1398 IN EFI_GUID
*VarGuid
1404 @param Src The source.
1406 @return A new string which is duplicated copy of the source.
1407 @retval NULL If there is not enough memory.
1416 Function is used to determine the number of device path instances
1417 that exist in a device path.
1420 @param DevicePath A pointer to a device path data structure.
1422 @return This function counts and returns the number of device path instances
1427 EfiDevicePathInstanceCount (
1428 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1432 Create string tokens for a menu from its help strings and display strings
1435 @param CallbackData The BMM context data.
1436 @param HiiHandle Hii Handle of the package to be updated.
1437 @param MenuOption The Menu whose string tokens need to be created
1439 @retval EFI_SUCCESS string tokens created successfully
1440 @retval others contain some errors
1444 CreateMenuStringToken (
1445 IN BMM_CALLBACK_DATA
*CallbackData
,
1446 IN EFI_HII_HANDLE HiiHandle
,
1447 IN BM_MENU_OPTION
*MenuOption
1451 Get a string from the Data Hub record based on
1454 @param DevPath The device Path.
1456 @return A string located from the Data Hub records based on
1458 @retval NULL If failed to get the String from Data Hub.
1462 EfiLibStrFromDatahub (
1463 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1467 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1468 specified by DeviceType.
1470 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1472 @param OptionIndex Returns the index number (#### in Boot####).
1473 @param OptionSize Return the size of the Boot### variable.
1479 GetLegacyBootOptionVar (
1480 IN UINTN DeviceType
,
1481 OUT UINTN
*OptionIndex
,
1482 OUT UINTN
*OptionSize
1486 Initialize the Boot Maintenance Utitliy.
1488 @retval EFI_SUCCESS utility ended successfully.
1489 @retval others contain some errors.
1498 Start boot maintenance manager
1503 @retval EFI_SUCCESS If BMM is invoked successfully.
1504 @return Other value if BMM return unsuccessfully.
1513 Intialize all the string depositories.
1517 InitializeStringDepository (
1522 Fetch a usable string node from the string depository and return the string token.
1525 @param CallbackData EDES_TODO: Add parameter description
1526 @param StringDepository - Pointer of the string depository.
1528 @retval EFI_STRING_ID String token.
1532 GetStringTokenFromDepository (
1533 IN BMM_CALLBACK_DATA
*CallbackData
,
1534 IN STRING_DEPOSITORY
*StringDepository
1538 Reclaim string depositories by moving the current node pointer to list head..
1541 ReclaimStringDepository (
1546 Release resource for all the string depositories.
1550 CleanUpStringDepository (
1555 Function handling request to apply changes for BMM pages.
1558 @param Private - Pointer to callback data buffer.
1559 @param CurrentFakeNVMap - Pointer to buffer holding data of various values used by BMM
1560 @param FormId - ID of the form which has sent the request to apply change.
1562 @retval EFI_SUCCESS Change successfully applied.
1563 @retval Other Error occurs while trying to apply changes.
1567 ApplyChangeHandler (
1568 IN BMM_CALLBACK_DATA
*Private
,
1569 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1570 IN EFI_FORM_ID FormId
1574 Discard all changes done to the BMM pages such as Boot Order change,
1575 Driver order change.
1577 @param Private The BMM context data.
1578 @param CurrentFakeNVMap The current Fack NV Map.
1582 DiscardChangeHandler (
1583 IN BMM_CALLBACK_DATA
*Private
,
1584 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1588 Dispatch the display to the next page based on NewPageId.
1590 @param Private The BMM context data.
1591 @param NewPageId The original page ID.
1596 BMM_CALLBACK_DATA
*Private
,
1601 Boot a file selected by user at File Expoloer of BMM.
1603 @param FileContext The file context data, which contains the device path
1604 of the file to be boot from.
1606 @retval EFI_SUCCESS The function completed successfull.
1607 @return Other value if the boot from the file fails.
1612 IN BM_FILE_CONTEXT
*FileContext
1616 Update the file explower page with the refershed file system.
1619 @param CallbackData BMM context data
1620 @param KeyValue Key value to identify the type of data to expect.
1622 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1623 @retval FALSE Indicate that there is no need to exit file explorer.
1627 UpdateFileExplorer (
1628 IN BMM_CALLBACK_DATA
*CallbackData
,
1633 This function processes the results of changes in configuration.
1634 When user select a interactive opcode, this callback will be triggered.
1635 Based on the Question(QuestionId) that triggers the callback, the corresponding
1636 actions is performed. It handles:
1638 1) the addition of boot option.
1639 2) the addition of driver option.
1640 3) exit from file browser
1641 4) update of file content if a dir is selected.
1642 5) boot the file if a file is selected in "boot from file"
1645 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1646 @param Action Specifies the type of action taken by the browser.
1647 @param QuestionId A unique value which is sent to the original exporting driver
1648 so that it can identify the type of data to expect.
1649 @param Type The type of value for the question.
1650 @param Value A pointer to the data being sent to the original exporting driver.
1651 @param ActionRequest On return, points to the action requested by the callback function.
1653 @retval EFI_SUCCESS The callback successfully handled the action.
1654 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1655 @retval EFI_DEVICE_ERROR The variable could not be saved.
1656 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1661 FileExplorerCallback (
1662 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1663 IN EFI_BROWSER_ACTION Action
,
1664 IN EFI_QUESTION_ID QuestionId
,
1666 IN EFI_IFR_TYPE_VALUE
*Value
,
1667 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1671 Dispatch BMM formset and FileExplorer formset.
1674 @param CallbackData The BMM context data.
1676 @retval EFI_SUCCESS If function complete successfully.
1677 @return Other value if the Setup Browser process BMM's pages and
1678 return unsuccessfully.
1683 IN BMM_CALLBACK_DATA
*CallbackData
1687 Function returns the value of the specified variable.
1689 @param Name A Null-terminated Unicode string that is
1690 the name of the vendor's variable.
1691 @param VendorGuid A unique identifier for the vendor.
1693 @return The payload of the variable.
1694 @retval NULL If the variable can't be read.
1700 IN EFI_GUID
*VendorGuid
1704 // Global variable in this program (defined in data.c)
1706 extern BM_MENU_OPTION BootOptionMenu
;
1707 extern BM_MENU_OPTION DriverOptionMenu
;
1708 extern BM_MENU_OPTION FsOptionMenu
;
1709 extern BM_MENU_OPTION ConsoleInpMenu
;
1710 extern BM_MENU_OPTION ConsoleOutMenu
;
1711 extern BM_MENU_OPTION ConsoleErrMenu
;
1712 extern BM_MENU_OPTION DirectoryMenu
;
1713 extern BM_MENU_OPTION DriverMenu
;
1714 extern BM_MENU_OPTION TerminalMenu
;
1715 extern BM_MENU_OPTION LegacyFDMenu
;
1716 extern BM_MENU_OPTION LegacyHDMenu
;
1717 extern BM_MENU_OPTION LegacyCDMenu
;
1718 extern BM_MENU_OPTION LegacyNETMenu
;
1719 extern BM_MENU_OPTION LegacyBEVMenu
;
1720 extern UINT16 TerminalType
[];
1721 extern COM_ATTR BaudRateList
[19];
1722 extern COM_ATTR DataBitsList
[4];
1723 extern COM_ATTR ParityList
[5];
1724 extern COM_ATTR StopBitsList
[3];
1725 extern EFI_GUID TerminalTypeGuid
[4];
1726 extern EFI_HII_UPDATE_DATA gUpdateData
;
1727 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1728 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1729 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1730 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1731 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1732 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1733 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1734 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1735 extern EFI_GUID EfiLegacyDevOrderGuid
;