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
;
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
;
129 } TYPE_OF_UPATE_MANNER
;
133 BOOT_FROM_FILE_STATE
,
134 ADD_BOOT_OPTION_STATE
,
135 ADD_DRIVER_OPTION_STATE
,
137 } FILE_EXPLORER_STATE
;
143 } FILE_EXPLORER_DISPLAY_CONTEXT
;
146 // All of the signatures that will be used in list structure
148 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
149 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
150 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
151 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
152 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
153 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
154 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
156 #define BM_LOAD_CONTEXT_SELECT 0x0
157 #define BM_CONSOLE_CONTEXT_SELECT 0x1
158 #define BM_FILE_CONTEXT_SELECT 0x2
159 #define BM_HANDLE_CONTEXT_SELECT 0x3
160 #define BM_TERMINAL_CONTEXT_SELECT 0x5
162 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
163 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
164 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
165 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
168 // Buffer size for update data
170 #define UPDATE_DATA_SIZE 0x100000
173 // Namespace of callback keys used in display and file system navigation
175 #define MAX_BBS_OFFSET 0xE000
176 #define NET_OPTION_OFFSET 0xD800
177 #define BEV_OPTION_OFFSET 0xD000
178 #define FD_OPTION_OFFSET 0xC000
179 #define HD_OPTION_OFFSET 0xB000
180 #define CD_OPTION_OFFSET 0xA000
181 #define FILE_OPTION_OFFSET 0x8000
182 #define FILE_OPTION_MASK 0x7FFF
183 #define HANDLE_OPTION_OFFSET 0x7000
184 #define CONSOLE_OPTION_OFFSET 0x6000
185 #define TERMINAL_OPTION_OFFSET 0x5000
186 #define CONFIG_OPTION_OFFSET 0x1200
187 #define KEY_VALUE_OFFSET 0x1100
188 #define FORM_ID_OFFSET 0x1000
191 // VarOffset that will be used to create question
192 // all these values are computed from the structure
195 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
198 // Question Id of Zero is invalid, so add an offset to it
200 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
202 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
203 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
204 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
205 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
206 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
207 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
208 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
209 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
210 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
211 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
212 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
213 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
214 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
215 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
216 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
217 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
218 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
219 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
220 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
221 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
222 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
223 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
224 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
225 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
226 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionToBeDeleted)
227 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
228 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
229 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
230 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
231 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
232 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
233 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
234 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
235 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
236 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
237 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
238 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
239 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
241 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
242 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
243 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
244 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
245 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
246 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
247 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
248 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
249 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
250 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
251 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
252 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
253 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
254 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
255 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
256 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
257 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
258 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
259 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
260 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
261 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
262 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
263 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
264 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
265 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)
266 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
267 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
268 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
269 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
270 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
271 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
272 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
273 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
274 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
275 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
276 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
277 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
278 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
280 #define STRING_DEPOSITORY_NUMBER 8
283 /// Serial Ports attributes, first one is the value for
284 /// return from callback function, stringtoken is used to
285 /// display the value properly
296 /// Length = sizeof (UINT16) + SIZEOF (Data)
300 } BM_LEGACY_DEV_ORDER_CONTEXT
;
319 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
320 } BM_TERMINAL_CONTEXT
;
324 BOOLEAN LoadOptionModified
;
329 BOOLEAN ForceReconnect
;
330 UINTN OptionalDataSize
;
332 UINTN LoadOptionSize
;
336 UINT16 FilePathListLength
;
338 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
349 } BM_LEGACY_DEVICE_CONTEXT
;
357 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
358 } BM_CONSOLE_CONTEXT
;
367 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
368 EFI_FILE_HANDLE FHandle
;
370 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
374 BOOLEAN IsRemovableMedia
;
376 BOOLEAN IsBootLegacy
;
381 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
394 UINT16
*DisplayString
;
396 EFI_STRING_ID DisplayStringToken
;
397 EFI_STRING_ID HelpStringToken
;
398 UINTN ContextSelection
;
399 VOID
*VariableContext
;
404 // Shared callback data.
408 BM_MENU_ENTRY
*MenuEntry
;
409 BM_HANDLE_CONTEXT
*HandleContext
;
410 BM_FILE_CONTEXT
*FileContext
;
411 BM_LOAD_CONTEXT
*LoadContext
;
412 BM_TERMINAL_CONTEXT
*TerminalContext
;
413 UINTN CurrentTerminal
;
417 // BMM main formset callback data.
419 EFI_HII_HANDLE BmmHiiHandle
;
420 EFI_HANDLE BmmDriverHandle
;
421 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
422 EFI_FORM_ID BmmCurrentPageId
;
423 EFI_FORM_ID BmmPreviousPageId
;
424 BOOLEAN BmmAskSaveOrNot
;
425 BMM_FAKE_NV_DATA BmmFakeNvData
;
426 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
429 // File explorer formset callback data.
431 EFI_HII_HANDLE FeHiiHandle
;
432 EFI_HANDLE FeDriverHandle
;
433 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
434 FILE_EXPLORER_STATE FeCurrentState
;
435 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
436 FILE_EXPLORER_NV_DATA FeFakeNvData
;
439 typedef struct _STRING_LIST_NODE
{
440 EFI_STRING_ID StringToken
;
441 struct _STRING_LIST_NODE
*Next
;
444 typedef struct _STRING_DEPOSITORY
{
445 UINTN TotalNodeNumber
;
446 STRING_LIST_NODE
*CurrentNode
;
447 STRING_LIST_NODE
*ListHead
;
453 // For initializing File System menu
457 This function build the FsOptionMenu list which records all
458 available file system in the system. They includes all instances
459 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
460 and all type of legacy boot device.
462 @param CallbackData BMM context data
464 @retval EFI_SUCCESS Success find the file system
465 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
469 BOpt_FindFileSystem (
470 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
493 Find drivers that will be added as Driver#### variables from handles
494 in current system environment
495 All valid handles in the system except those consume SimpleFs, LoadFile
496 are stored in DriverMenu for future use.
498 @retval EFI_SUCCESS The function complets successfully.
499 @return Other value if failed to build the DriverMenu.
509 Build the BootOptionMenu according to BootOrder Variable.
510 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
512 @param CallbackData The BMM context data.
514 @return The number of the Var Boot####.
518 BOpt_GetBootOptions (
519 IN BMM_CALLBACK_DATA
*CallbackData
524 Build up all DriverOptionMenu
526 @param CallbackData The BMM context data.
528 @return EFI_SUCESS The functin completes successfully.
529 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
534 BOpt_GetDriverOptions (
535 IN BMM_CALLBACK_DATA
*CallbackData
540 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
542 @retval EFI_SUCCESS The function complete successfully.
543 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
547 BOpt_GetLegacyOptions (
552 Free out resouce allocated from Legacy Boot Options.
556 BOpt_FreeLegacyOptions (
561 Free resources allocated in Allocate Rountine.
563 @param FreeMenu Menu to be freed
568 BM_MENU_OPTION
*FreeMenu
574 Append file name to existing file name.
576 @param Str1 The existing file name
577 @param Str2 The file name to be appended
579 @return Allocate a new string to hold the appended result.
580 Caller is responsible to free the returned string.
584 BOpt_AppendFileName (
591 Check whether current FileName point to a valid
594 @param FileName File need to be checked.
596 @retval TRUE Is Efi Image
597 @retval FALSE Not a valid Efi Image
601 BOpt_IsEfiImageName (
607 Check whether current FileName point to a valid Efi Application
609 @param Dir Pointer to current Directory
610 @param FileName Pointer to current File name.
612 @retval TRUE Is a valid Efi Application
613 @retval FALSE not a valid Efi Application
618 IN EFI_FILE_HANDLE Dir
,
624 Get the Option Number that has not been allocated for use.
626 @return The available Option Number.
630 BOpt_GetBootOptionNumber (
636 Get the Option Number that is not in use.
638 @return The unused Option Number.
642 BOpt_GetDriverOptionNumber (
647 Create a menu entry give a Menu type.
649 @param MenuType The Menu type to be created.
652 @retval NULL If failed to create the menu.
657 BOpt_CreateMenuEntry (
662 Free up all resource allocated for a BM_MENU_ENTRY.
664 @param MenuEntry A pointer to BM_MENU_ENTRY.
668 BOpt_DestroyMenuEntry (
669 BM_MENU_ENTRY
*MenuEntry
673 Get the Menu Entry from the list in Menu Entry List.
675 If MenuNumber is great or equal to the number of Menu
676 Entry in the list, then ASSERT.
678 @param MenuOption The Menu Entry List to read the menu entry.
679 @param MenuNumber The index of Menu Entry.
681 @return The Menu Entry.
686 BM_MENU_OPTION
*MenuOption
,
691 // Locate all serial io devices for console
694 Build a list containing all serial devices.
696 @retval EFI_SUCCESS The function complete successfully.
697 @retval EFI_UNSUPPORTED No serial ports present.
706 // Initializing Console menu
709 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
711 @retval EFI_SUCCESS The function always complete successfully.
720 // Get current mode information
723 Get mode number according to column and row
725 @param CallbackData The BMM context data.
729 IN BMM_CALLBACK_DATA
*CallbackData
733 // Cleaning up console menu
736 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
738 @retval EFI_SUCCESS The function always complete successfully.
746 Update the device path that describing a terminal device
747 based on the new BaudRate, Data Bits, parity and Stop Bits
750 @param DevicePath The devicepath protocol instance wanted to be updated.
754 ChangeVariableDevicePath (
755 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
759 Update the multi-instance device path of Terminal Device based on
760 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
761 device path in the Terminal Device in TerminalMenu is also updated.
763 @param DevicePath The multi-instance device path.
764 @param ChangeTerminal TRUE, then device path in the Terminal Device
765 in TerminalMenu is also updated; FALSE, no update.
767 @return EFI_SUCCESS The function completes successfully.
771 ChangeTerminalDevicePath (
772 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
773 IN BOOLEAN ChangeTerminal
777 // Variable operation by menu selection
780 This function create a currently loaded Boot Option from
781 the BMM. It then appends this Boot Option to the end of
782 the "BootOrder" list. It also append this Boot Opotion to the end
785 @param CallbackData The BMM context data.
786 @param NvRamMap The file explorer formset internal state.
788 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
789 @retval EFI_SUCCESS If function completes successfully.
793 Var_UpdateBootOption (
794 IN BMM_CALLBACK_DATA
*CallbackData
,
795 IN FILE_EXPLORER_NV_DATA
*NvRamMap
799 Delete Boot Option that represent a Deleted state in BootOptionMenu.
800 After deleting this boot option, call Var_ChangeBootOrder to
801 make sure BootOrder is in valid state.
803 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
804 BM_LOAD_CONTEXT marked for deletion is deleted
805 @return Others If failed to update the "BootOrder" variable after deletion.
814 After any operation on Boot####, there will be a discrepancy in BootOrder.
815 Since some are missing but in BootOrder, while some are present but are
816 not reflected by BootOrder. Then a function rebuild BootOrder from
817 scratch by content from BootOptionMenu is needed.
819 @retval EFI_SUCCESS The boot order is updated successfully.
820 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
824 Var_ChangeBootOrder (
829 This function create a currently loaded Drive Option from
830 the BMM. It then appends this Driver Option to the end of
831 the "DriverOrder" list. It append this Driver Opotion to the end
834 @param CallbackData The BMM context data.
835 @param HiiHandle The HII handle associated with the BMM formset.
836 @param DescriptionData The description of this driver option.
837 @param OptionalData The optional load option.
838 @param ForceReconnect If to force reconnect.
840 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
841 @retval EFI_SUCCESS If function completes successfully.
845 Var_UpdateDriverOption (
846 IN BMM_CALLBACK_DATA
*CallbackData
,
847 IN EFI_HII_HANDLE HiiHandle
,
848 IN UINT16
*DescriptionData
,
849 IN UINT16
*OptionalData
,
850 IN UINT8 ForceReconnect
854 Delete Load Option that represent a Deleted state in BootOptionMenu.
855 After deleting this Driver option, call Var_ChangeDriverOrder to
856 make sure DriverOrder is in valid state.
858 @retval EFI_SUCCESS Load Option is successfully updated.
859 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
864 Var_DelDriverOption (
869 After any operation on Driver####, there will be a discrepancy in
870 DriverOrder. Since some are missing but in DriverOrder, while some
871 are present but are not reflected by DriverOrder. Then a function
872 rebuild DriverOrder from scratch by content from DriverOptionMenu is
875 @retval EFI_SUCCESS The driver order is updated successfully.
876 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
880 Var_ChangeDriverOrder (
885 This function delete and build multi-instance device path ConIn
888 @retval EFI_SUCCESS The function complete successfully.
889 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
892 Var_UpdateConsoleInpOption (
897 This function delete and build multi-instance device path ConOut console device.
899 @retval EFI_SUCCESS The function complete successfully.
900 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
903 Var_UpdateConsoleOutOption (
908 This function delete and build multi-instance device path ErrOut console device.
910 @retval EFI_SUCCESS The function complete successfully.
911 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
914 Var_UpdateErrorOutOption (
919 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
920 parity and stop Bits set.
924 Var_UpdateAllConsoleOption (
929 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
930 this EFI Variable is deleted.
931 It also update the BMM context data specified the "BootNext" value.
933 @param CallbackData The BMM context data.
935 @retval EFI_SUCCESS The function complete successfully.
936 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
941 IN BMM_CALLBACK_DATA
*CallbackData
945 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
946 BootOptionMenu with the new "BootOrder" list.
948 @param CallbackData The BMM context data.
950 @retval EFI_SUCCESS The function complete successfully.
951 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
952 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
956 Var_UpdateBootOrder (
957 IN BMM_CALLBACK_DATA
*CallbackData
961 This function update the "DriverOrder" EFI Variable based on
962 BMM Formset's NV map. It then refresh DriverOptionMenu
963 with the new "DriverOrder" list.
965 @param CallbackData The BMM context data.
967 @retval EFI_SUCCESS The function complete successfully.
968 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
969 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
973 Var_UpdateDriverOrder (
974 IN BMM_CALLBACK_DATA
*CallbackData
978 Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable
979 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
982 @param CallbackData The context data for BMM.
984 @return EFI_SUCCESS The function completed successfully.
985 @retval EFI_NOT_FOUND If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can not be found.
989 Var_UpdateBBSOption (
990 IN BMM_CALLBACK_DATA
*CallbackData
994 Update the Text Mode of Console.
996 @param CallbackData The context data for BMM.
998 @retval EFI_SUCCSS If the Text Mode of Console is updated.
999 @return Other value if the Text Mode of Console is not updated.
1004 IN BMM_CALLBACK_DATA
*CallbackData
1008 // Following are page create and refresh functions
1011 Refresh the global UpdateData structure.
1020 Clean up the dynamic opcode at label and form specified by
1023 @param LabelId It is both the Form ID and Label ID for
1025 @param CallbackData The BMM context data.
1031 IN BMM_CALLBACK_DATA
*CallbackData
1035 Create a lit of boot option from global BootOptionMenu. It
1036 allow user to delete the boot option.
1038 @param CallbackData The BMM context data.
1043 IN BMM_CALLBACK_DATA
*CallbackData
1047 Create a lit of driver option from global DriverMenu.
1049 @param CallbackData The BMM context data.
1052 UpdateDrvAddHandlePage (
1053 IN BMM_CALLBACK_DATA
*CallbackData
1057 Create a lit of driver option from global DriverOptionMenu. It
1058 allow user to delete the driver option.
1060 @param CallbackData The BMM context data.
1064 IN BMM_CALLBACK_DATA
*CallbackData
1068 Prepare the page to allow user to add description for a Driver Option.
1070 @param CallbackData The BMM context data.
1073 UpdateDriverAddHandleDescPage (
1074 IN BMM_CALLBACK_DATA
*CallbackData
1078 Dispatch the correct update page function to call based on the UpdatePageId.
1080 @param UpdatePageId The form ID.
1081 @param CallbackData The BMM context data.
1085 IN UINT16 UpdatePageId
,
1086 IN BMM_CALLBACK_DATA
*CallbackData
1090 Create the dynamic page to allow user to set the "BootNext" vaule.
1092 @param CallbackData The BMM context data.
1095 UpdateBootNextPage (
1096 IN BMM_CALLBACK_DATA
*CallbackData
1100 Create the dynamic page to allow user to set the "TimeOut" vaule.
1102 @param CallbackData The BMM context data.
1106 IN BMM_CALLBACK_DATA
*CallbackData
1110 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1111 Parity, Stop Bits, Terminal Type.
1113 @param CallbackData The BMM context data.
1116 UpdateTerminalPage (
1117 IN BMM_CALLBACK_DATA
*CallbackData
1121 Refresh the text mode page
1123 @param CallbackData The BMM context data.
1127 IN BMM_CALLBACK_DATA
*CallbackData
1131 Create a list of Goto Opcode for all terminal devices logged
1132 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1134 @param CallbackData The BMM context data.
1138 IN BMM_CALLBACK_DATA
*CallbackData
1142 Create a dynamic page so that Legacy Device boot order
1143 can be set for specified device type.
1145 @param UpdatePageId The form ID. It also spefies the legacy device type.
1146 @param CallbackData The BMM context data.
1149 UpdateSetLegacyDeviceOrderPage (
1150 IN UINT16 UpdatePageId
,
1151 IN BMM_CALLBACK_DATA
*CallbackData
1156 Function opens and returns a file handle to the root directory of a volume.
1158 @param DeviceHandle A handle for a device
1159 @return A valid file handle or NULL is returned
1163 IN EFI_HANDLE DeviceHandle
1167 Function gets the file system information from an open file descriptor,
1168 and stores it in a buffer allocated from pool.
1170 @param FHand The file handle.
1172 @return A pointer to a buffer with file information.
1173 NULL is returned if failed to get Vaolume Label Info.
1175 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1176 EfiLibFileSystemVolumeLabelInfo (
1177 IN EFI_FILE_HANDLE FHand
1182 Function gets the file information from an open file descriptor, and stores it
1183 in a buffer allocated from pool.
1185 @param FHand File Handle.
1187 @return A pointer to a buffer with file information or NULL is returned
1192 IN EFI_FILE_HANDLE FHand
1196 Find the first instance of this Protocol in the system and return it's interface.
1198 @param ProtocolGuid Provides the protocol to search for
1199 @param Interface On return, a pointer to the first interface
1200 that matches ProtocolGuid
1202 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1203 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1207 EfiLibLocateProtocol (
1208 IN EFI_GUID
*ProtocolGuid
,
1209 OUT VOID
**Interface
1213 Adjusts the size of a previously allocated buffer.
1215 @param OldPool A pointer to the buffer whose size is being adjusted.
1216 @param OldSize The size of the current buffer.
1217 @param NewSize The size of the new buffer.
1219 @return The newly allocated buffer. if NULL, allocation failed.
1230 Function deletes the variable specified by VarName and VarGuid.
1233 @param VarName A Null-terminated Unicode string that is
1234 the name of the vendor's variable.
1236 @param VarGuid A unique identifier for the vendor.
1238 @retval EFI_SUCCESS The variable was found and removed
1239 @retval EFI_UNSUPPORTED The variable store was inaccessible
1240 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1241 @retval EFI_NOT_FOUND The variable was not found
1245 EfiLibDeleteVariable (
1247 IN EFI_GUID
*VarGuid
1253 @param Src The source.
1255 @return A new string which is duplicated copy of the source.
1256 @retval NULL If there is not enough memory.
1265 Function is used to determine the number of device path instances
1266 that exist in a device path.
1269 @param DevicePath A pointer to a device path data structure.
1271 @return This function counts and returns the number of device path instances
1276 EfiDevicePathInstanceCount (
1277 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1281 Create string tokens for a menu from its help strings and display strings
1284 @param CallbackData The BMM context data.
1285 @param HiiHandle Hii Handle of the package to be updated.
1286 @param MenuOption The Menu whose string tokens need to be created
1288 @retval EFI_SUCCESS string tokens created successfully
1289 @retval others contain some errors
1293 CreateMenuStringToken (
1294 IN BMM_CALLBACK_DATA
*CallbackData
,
1295 IN EFI_HII_HANDLE HiiHandle
,
1296 IN BM_MENU_OPTION
*MenuOption
1300 Get a string from the Data Hub record based on
1303 @param DevPath The device Path.
1305 @return A string located from the Data Hub records based on
1307 @retval NULL If failed to get the String from Data Hub.
1311 EfiLibStrFromDatahub (
1312 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1316 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1317 specified by DeviceType.
1319 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1321 @param OptionIndex Returns the index number (#### in Boot####).
1322 @param OptionSize Return the size of the Boot### variable.
1326 GetLegacyBootOptionVar (
1327 IN UINTN DeviceType
,
1328 OUT UINTN
*OptionIndex
,
1329 OUT UINTN
*OptionSize
1333 Initialize the Boot Maintenance Utitliy.
1335 @retval EFI_SUCCESS utility ended successfully.
1336 @retval others contain some errors.
1345 Start boot maintenance manager
1347 @retval EFI_SUCCESS If BMM is invoked successfully.
1348 @return Other value if BMM return unsuccessfully.
1357 Intialize all the string depositories.
1361 InitializeStringDepository (
1366 Fetch a usable string node from the string depository and return the string token.
1369 @param CallbackData The BMM context data.
1370 @param StringDepository Pointer of the string depository.
1372 @retval EFI_STRING_ID String token.
1376 GetStringTokenFromDepository (
1377 IN BMM_CALLBACK_DATA
*CallbackData
,
1378 IN STRING_DEPOSITORY
*StringDepository
1382 Reclaim string depositories by moving the current node pointer to list head..
1385 ReclaimStringDepository (
1390 Release resource for all the string depositories.
1394 CleanUpStringDepository (
1399 Function handling request to apply changes for BMM pages.
1401 @param Private Pointer to callback data buffer.
1402 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1403 @param FormId ID of the form which has sent the request to apply change.
1405 @retval EFI_SUCCESS Change successfully applied.
1406 @retval Other Error occurs while trying to apply changes.
1410 ApplyChangeHandler (
1411 IN BMM_CALLBACK_DATA
*Private
,
1412 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1413 IN EFI_FORM_ID FormId
1417 Discard all changes done to the BMM pages such as Boot Order change,
1418 Driver order change.
1420 @param Private The BMM context data.
1421 @param CurrentFakeNVMap The current Fack NV Map.
1425 DiscardChangeHandler (
1426 IN BMM_CALLBACK_DATA
*Private
,
1427 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1431 Dispatch the display to the next page based on NewPageId.
1433 @param Private The BMM context data.
1434 @param NewPageId The original page ID.
1439 BMM_CALLBACK_DATA
*Private
,
1444 Boot a file selected by user at File Expoloer of BMM.
1446 @param FileContext The file context data, which contains the device path
1447 of the file to be boot from.
1449 @retval EFI_SUCCESS The function completed successfull.
1450 @return Other value if the boot from the file fails.
1455 IN BM_FILE_CONTEXT
*FileContext
1459 Update the file explower page with the refershed file system.
1462 @param CallbackData BMM context data
1463 @param KeyValue Key value to identify the type of data to expect.
1465 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1466 @retval FALSE Indicate that there is no need to exit file explorer.
1470 UpdateFileExplorer (
1471 IN BMM_CALLBACK_DATA
*CallbackData
,
1476 This function processes the results of changes in configuration.
1477 When user select a interactive opcode, this callback will be triggered.
1478 Based on the Question(QuestionId) that triggers the callback, the corresponding
1479 actions is performed. It handles:
1481 1) the addition of boot option.
1482 2) the addition of driver option.
1483 3) exit from file browser
1484 4) update of file content if a dir is selected.
1485 5) boot the file if a file is selected in "boot from file"
1488 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1489 @param Action Specifies the type of action taken by the browser.
1490 @param QuestionId A unique value which is sent to the original exporting driver
1491 so that it can identify the type of data to expect.
1492 @param Type The type of value for the question.
1493 @param Value A pointer to the data being sent to the original exporting driver.
1494 @param ActionRequest On return, points to the action requested by the callback function.
1496 @retval EFI_SUCCESS The callback successfully handled the action.
1497 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1498 @retval EFI_DEVICE_ERROR The variable could not be saved.
1499 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1504 FileExplorerCallback (
1505 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1506 IN EFI_BROWSER_ACTION Action
,
1507 IN EFI_QUESTION_ID QuestionId
,
1509 IN EFI_IFR_TYPE_VALUE
*Value
,
1510 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1514 Dispatch BMM formset and FileExplorer formset.
1517 @param CallbackData The BMM context data.
1519 @retval EFI_SUCCESS If function complete successfully.
1520 @return Other value if the Setup Browser process BMM's pages and
1521 return unsuccessfully.
1526 IN BMM_CALLBACK_DATA
*CallbackData
1530 Function returns the value of the specified variable.
1532 @param Name A Null-terminated Unicode string that is
1533 the name of the vendor's variable.
1534 @param VendorGuid A unique identifier for the vendor.
1536 @return The payload of the variable.
1537 @retval NULL If the variable can't be read.
1543 IN EFI_GUID
*VendorGuid
1547 // Global variable in this program (defined in data.c)
1549 extern BM_MENU_OPTION BootOptionMenu
;
1550 extern BM_MENU_OPTION DriverOptionMenu
;
1551 extern BM_MENU_OPTION FsOptionMenu
;
1552 extern BM_MENU_OPTION ConsoleInpMenu
;
1553 extern BM_MENU_OPTION ConsoleOutMenu
;
1554 extern BM_MENU_OPTION ConsoleErrMenu
;
1555 extern BM_MENU_OPTION DirectoryMenu
;
1556 extern BM_MENU_OPTION DriverMenu
;
1557 extern BM_MENU_OPTION TerminalMenu
;
1558 extern BM_MENU_OPTION LegacyFDMenu
;
1559 extern BM_MENU_OPTION LegacyHDMenu
;
1560 extern BM_MENU_OPTION LegacyCDMenu
;
1561 extern BM_MENU_OPTION LegacyNETMenu
;
1562 extern BM_MENU_OPTION LegacyBEVMenu
;
1563 extern UINT16 TerminalType
[];
1564 extern COM_ATTR BaudRateList
[19];
1565 extern COM_ATTR DataBitsList
[4];
1566 extern COM_ATTR ParityList
[5];
1567 extern COM_ATTR StopBitsList
[3];
1568 extern EFI_GUID TerminalTypeGuid
[4];
1569 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1570 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1571 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1572 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1573 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1574 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1575 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1576 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1577 extern EFI_GUID EfiLegacyDevOrderGuid
;
1580 // Shared IFR form update data
1582 extern VOID
*mStartOpCodeHandle
;
1583 extern VOID
*mEndOpCodeHandle
;
1584 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1585 extern EFI_IFR_GUID_LABEL
*mEndLabel
;