2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _BOOT_MAINT_H_
16 #define _BOOT_MAINT_H_
20 #include "FrontPage.h"
21 #include <Guid/TtyTerm.h>
24 // Constants which are variable names used to access variables
27 #define VAR_CON_OUT_MODE L"ConOutMode"
33 #define STR_FLOPPY L"Floppy Drive #%02x"
34 #define STR_HARDDISK L"HardDisk Drive #%02x"
35 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
36 #define STR_NET L"NET Drive #%02x"
37 #define STR_BEV L"BEV Drive #%02x"
38 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
39 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
40 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
41 #define STR_NET_HELP L"NET Drive #%02x"
42 #define STR_BEV_HELP L"BEV Drive #%02x"
45 // Variable created with this flag will be "Efi:...."
47 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
49 extern EFI_GUID mBootMaintGuid
;
50 extern EFI_GUID mFileExplorerGuid
;
51 extern CHAR16 mFileExplorerStorageName
[];
52 extern CHAR16 mBootMaintStorageName
[];
54 // These are the VFR compiler generated data representing our VFR data.
60 // Below are the number of options in Baudrate, Databits,
61 // Parity and Stopbits selection for serial ports.
63 #define BM_COM_ATTR_BUADRATE 19
64 #define BM_COM_ATTR_DATABITS 4
65 #define BM_COM_ATTR_PARITY 5
66 #define BM_COM_ATTR_STOPBITS 3
69 // Callback function helper
71 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
72 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
74 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
77 // Enumeration type definition
79 typedef UINT8 BBS_TYPE
;
81 typedef enum _TYPE_OF_TERMINAL
{
82 TerminalTypePcAnsi
= 0,
84 TerminalTypeVt100Plus
,
89 typedef enum _FILE_EXPLORER_STATE
{
90 FileExplorerStateInActive
= 0,
91 FileExplorerStateBootFromFile
,
92 FileExplorerStateAddBootOption
,
93 FileExplorerStateAddDriverOptionState
,
94 FileExplorerStateUnknown
95 } FILE_EXPLORER_STATE
;
97 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
98 FileExplorerDisplayFileSystem
,
99 FileExplorerDisplayDirectory
,
100 FileExplorerDisplayUnknown
101 } FILE_EXPLORER_DISPLAY_CONTEXT
;
104 // All of the signatures that will be used in list structure
106 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
107 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
108 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
109 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
110 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
111 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
112 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
114 #define BM_LOAD_CONTEXT_SELECT 0x0
115 #define BM_CONSOLE_CONTEXT_SELECT 0x1
116 #define BM_FILE_CONTEXT_SELECT 0x2
117 #define BM_HANDLE_CONTEXT_SELECT 0x3
118 #define BM_TERMINAL_CONTEXT_SELECT 0x5
120 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
121 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
122 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
125 // Buffer size for update data
127 #define UPDATE_DATA_SIZE 0x100000
130 // Namespace of callback keys used in display and file system navigation
132 #define MAX_BBS_OFFSET 0xE000
133 #define NET_OPTION_OFFSET 0xD800
134 #define BEV_OPTION_OFFSET 0xD000
135 #define FD_OPTION_OFFSET 0xC000
136 #define HD_OPTION_OFFSET 0xB000
137 #define CD_OPTION_OFFSET 0xA000
138 #define FILE_OPTION_OFFSET 0x8000
139 #define FILE_OPTION_MASK 0x7FFF
140 #define HANDLE_OPTION_OFFSET 0x7000
141 #define CONSOLE_OPTION_OFFSET 0x6000
142 #define TERMINAL_OPTION_OFFSET 0x5000
143 #define CONFIG_OPTION_OFFSET 0x1200
144 #define KEY_VALUE_OFFSET 0x1100
145 #define FORM_ID_OFFSET 0x1000
148 // VarOffset that will be used to create question
149 // all these values are computed from the structure
152 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
155 // Question Id of Zero is invalid, so add an offset to it
157 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
159 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
160 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
161 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
162 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
163 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
164 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
165 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
166 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
167 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
168 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
169 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
170 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
171 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
172 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
173 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
174 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
175 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
176 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
177 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
178 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
179 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
180 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
181 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
182 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
183 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
184 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
185 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
186 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
187 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
188 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
189 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
190 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
191 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
192 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
193 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
194 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
195 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
197 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
198 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
199 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
200 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
201 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
202 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
203 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
204 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
205 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
206 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
207 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
208 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
209 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
210 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
211 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
212 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
213 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
214 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
215 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
216 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
217 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
218 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
219 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
220 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
221 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
222 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
223 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
224 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
225 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
226 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
227 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
228 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
229 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
230 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
231 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
232 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
233 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
235 #define STRING_DEPOSITORY_NUMBER 8
238 /// Serial Ports attributes, first one is the value for
239 /// return from callback function, stringtoken is used to
240 /// display the value properly
265 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
266 } BM_TERMINAL_CONTEXT
;
270 BOOLEAN LoadOptionModified
;
275 BOOLEAN ForceReconnect
;
276 UINTN OptionalDataSize
;
278 UINTN LoadOptionSize
;
282 UINT16 FilePathListLength
;
284 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
296 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
297 } BM_CONSOLE_CONTEXT
;
306 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
307 EFI_FILE_HANDLE FHandle
;
309 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
313 BOOLEAN IsRemovableMedia
;
315 BOOLEAN IsBootLegacy
;
320 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
333 UINT16
*DisplayString
;
335 EFI_STRING_ID DisplayStringToken
;
336 EFI_STRING_ID HelpStringToken
;
337 UINTN ContextSelection
;
338 VOID
*VariableContext
;
343 // Shared callback data.
347 BM_MENU_ENTRY
*MenuEntry
;
348 BM_HANDLE_CONTEXT
*HandleContext
;
349 BM_FILE_CONTEXT
*FileContext
;
350 BM_LOAD_CONTEXT
*LoadContext
;
351 BM_TERMINAL_CONTEXT
*TerminalContext
;
352 UINTN CurrentTerminal
;
356 // BMM main formset callback data.
358 EFI_HII_HANDLE BmmHiiHandle
;
359 EFI_HANDLE BmmDriverHandle
;
360 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
361 EFI_FORM_ID BmmCurrentPageId
;
362 EFI_FORM_ID BmmPreviousPageId
;
363 BOOLEAN BmmAskSaveOrNot
;
364 BMM_FAKE_NV_DATA BmmFakeNvData
;
365 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
368 // File explorer formset callback data.
370 EFI_HII_HANDLE FeHiiHandle
;
371 EFI_HANDLE FeDriverHandle
;
372 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
373 FILE_EXPLORER_STATE FeCurrentState
;
374 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
375 FILE_EXPLORER_NV_DATA FeFakeNvData
;
378 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
380 struct _STRING_LIST_NODE
{
381 EFI_STRING_ID StringToken
;
382 STRING_LIST_NODE
*Next
;
385 typedef struct _STRING_DEPOSITORY
{
386 UINTN TotalNodeNumber
;
387 STRING_LIST_NODE
*CurrentNode
;
388 STRING_LIST_NODE
*ListHead
;
394 // For initializing File System menu
398 This function build the FsOptionMenu list which records all
399 available file system in the system. They includes all instances
400 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
401 and all type of legacy boot device.
403 @param CallbackData BMM context data
405 @retval EFI_SUCCESS Success find the file system
406 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
410 BOpt_FindFileSystem (
411 IN BMM_CALLBACK_DATA
*CallbackData
415 Find files under current directory
416 All files and sub-directories in current directory
417 will be stored in DirectoryMenu for future use.
419 @param CallbackData The BMM context data.
420 @param MenuEntry The Menu Entry.
422 @retval EFI_SUCCESS Get files from current dir successfully.
423 @return Other value if can't get files from current dir.
428 IN BMM_CALLBACK_DATA
*CallbackData
,
429 IN BM_MENU_ENTRY
*MenuEntry
434 Find drivers that will be added as Driver#### variables from handles
435 in current system environment
436 All valid handles in the system except those consume SimpleFs, LoadFile
437 are stored in DriverMenu for future use.
439 @retval EFI_SUCCESS The function complets successfully.
440 @return Other value if failed to build the DriverMenu.
450 Build the BootOptionMenu according to BootOrder Variable.
451 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
453 @param CallbackData The BMM context data.
455 @return The number of the Var Boot####.
459 BOpt_GetBootOptions (
460 IN BMM_CALLBACK_DATA
*CallbackData
465 Build up all DriverOptionMenu
467 @param CallbackData The BMM context data.
469 @return EFI_SUCESS The functin completes successfully.
470 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
475 BOpt_GetDriverOptions (
476 IN BMM_CALLBACK_DATA
*CallbackData
480 Free resources allocated in Allocate Rountine.
482 @param FreeMenu Menu to be freed
487 BM_MENU_OPTION
*FreeMenu
493 Append file name to existing file name.
495 @param Str1 The existing file name
496 @param Str2 The file name to be appended
498 @return Allocate a new string to hold the appended result.
499 Caller is responsible to free the returned string.
503 BOpt_AppendFileName (
510 Check whether current FileName point to a valid
513 @param FileName File need to be checked.
515 @retval TRUE Is Efi Image
516 @retval FALSE Not a valid Efi Image
520 BOpt_IsEfiImageName (
526 Check whether current FileName point to a valid Efi Application
528 @param Dir Pointer to current Directory
529 @param FileName Pointer to current File name.
531 @retval TRUE Is a valid Efi Application
532 @retval FALSE not a valid Efi Application
537 IN EFI_FILE_HANDLE Dir
,
543 Get the Option Number that has not been allocated for use.
545 @param Type The type of Option.
547 @return The available Option Number.
551 BOpt_GetOptionNumber (
557 Get the Option Number for Boot#### that does not used.
559 @return The available Option Number.
563 BOpt_GetBootOptionNumber (
569 Get the Option Number for Driver#### that does not used.
571 @return The unused Option Number.
575 BOpt_GetDriverOptionNumber (
580 Create a menu entry give a Menu type.
582 @param MenuType The Menu type to be created.
585 @retval NULL If failed to create the menu.
590 BOpt_CreateMenuEntry (
595 Free up all resource allocated for a BM_MENU_ENTRY.
597 @param MenuEntry A pointer to BM_MENU_ENTRY.
601 BOpt_DestroyMenuEntry (
602 BM_MENU_ENTRY
*MenuEntry
606 Get the Menu Entry from the list in Menu Entry List.
608 If MenuNumber is great or equal to the number of Menu
609 Entry in the list, then ASSERT.
611 @param MenuOption The Menu Entry List to read the menu entry.
612 @param MenuNumber The index of Menu Entry.
614 @return The Menu Entry.
619 BM_MENU_OPTION
*MenuOption
,
624 Get option number according to Boot#### and BootOrder variable.
625 The value is saved as #### + 1.
627 @param CallbackData The BMM context data.
631 IN BMM_CALLBACK_DATA
*CallbackData
635 Get driver option order from globalc DriverOptionMenu.
637 @param CallbackData The BMM context data.
642 IN BMM_CALLBACK_DATA
*CallbackData
646 // Locate all serial io devices for console
649 Build a list containing all serial devices.
651 @retval EFI_SUCCESS The function complete successfully.
652 @retval EFI_UNSUPPORTED No serial ports present.
661 // Initializing Console menu
664 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
666 @retval EFI_SUCCESS The function always complete successfully.
675 // Get current mode information
678 Get mode number according to column and row
680 @param CallbackData The BMM context data.
684 IN BMM_CALLBACK_DATA
*CallbackData
688 // Cleaning up console menu
691 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
693 @retval EFI_SUCCESS The function always complete successfully.
701 Update the device path that describing a terminal device
702 based on the new BaudRate, Data Bits, parity and Stop Bits
705 @param DevicePath The devicepath protocol instance wanted to be updated.
709 ChangeVariableDevicePath (
710 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
714 Update the multi-instance device path of Terminal Device based on
715 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
716 device path in the Terminal Device in TerminalMenu is also updated.
718 @param DevicePath The multi-instance device path.
719 @param ChangeTerminal TRUE, then device path in the Terminal Device
720 in TerminalMenu is also updated; FALSE, no update.
722 @return EFI_SUCCESS The function completes successfully.
726 ChangeTerminalDevicePath (
727 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
728 IN BOOLEAN ChangeTerminal
732 // Variable operation by menu selection
735 This function create a currently loaded Boot Option from
736 the BMM. It then appends this Boot Option to the end of
737 the "BootOrder" list. It also append this Boot Opotion to the end
740 @param CallbackData The BMM context data.
741 @param NvRamMap The file explorer formset internal state.
743 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
744 @retval EFI_SUCCESS If function completes successfully.
748 Var_UpdateBootOption (
749 IN BMM_CALLBACK_DATA
*CallbackData
,
750 IN FILE_EXPLORER_NV_DATA
*NvRamMap
754 Delete Boot Option that represent a Deleted state in BootOptionMenu.
755 After deleting this boot option, call Var_ChangeBootOrder to
756 make sure BootOrder is in valid state.
758 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
759 BM_LOAD_CONTEXT marked for deletion is deleted
760 @return Others If failed to update the "BootOrder" variable after deletion.
769 After any operation on Boot####, there will be a discrepancy in BootOrder.
770 Since some are missing but in BootOrder, while some are present but are
771 not reflected by BootOrder. Then a function rebuild BootOrder from
772 scratch by content from BootOptionMenu is needed.
774 @retval EFI_SUCCESS The boot order is updated successfully.
775 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
779 Var_ChangeBootOrder (
784 This function create a currently loaded Drive Option from
785 the BMM. It then appends this Driver Option to the end of
786 the "DriverOrder" list. It append this Driver Opotion to the end
789 @param CallbackData The BMM context data.
790 @param HiiHandle The HII handle associated with the BMM formset.
791 @param DescriptionData The description of this driver option.
792 @param OptionalData The optional load option.
793 @param ForceReconnect If to force reconnect.
795 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
796 @retval EFI_SUCCESS If function completes successfully.
800 Var_UpdateDriverOption (
801 IN BMM_CALLBACK_DATA
*CallbackData
,
802 IN EFI_HII_HANDLE HiiHandle
,
803 IN UINT16
*DescriptionData
,
804 IN UINT16
*OptionalData
,
805 IN UINT8 ForceReconnect
809 Delete Load Option that represent a Deleted state in BootOptionMenu.
810 After deleting this Driver option, call Var_ChangeDriverOrder to
811 make sure DriverOrder is in valid state.
813 @retval EFI_SUCCESS Load Option is successfully updated.
814 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
819 Var_DelDriverOption (
824 After any operation on Driver####, there will be a discrepancy in
825 DriverOrder. Since some are missing but in DriverOrder, while some
826 are present but are not reflected by DriverOrder. Then a function
827 rebuild DriverOrder from scratch by content from DriverOptionMenu is
830 @retval EFI_SUCCESS The driver order is updated successfully.
831 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
835 Var_ChangeDriverOrder (
840 This function delete and build multi-instance device path ConIn
843 @retval EFI_SUCCESS The function complete successfully.
844 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
847 Var_UpdateConsoleInpOption (
852 This function delete and build multi-instance device path ConOut console device.
854 @retval EFI_SUCCESS The function complete successfully.
855 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
858 Var_UpdateConsoleOutOption (
863 This function delete and build multi-instance device path ErrOut console device.
865 @retval EFI_SUCCESS The function complete successfully.
866 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
869 Var_UpdateErrorOutOption (
874 This function delete and build Out of Band console device.
876 @param MenuIndex Menu index which user select in the terminal menu list.
878 @retval EFI_SUCCESS The function complete successfully.
879 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
882 Var_UpdateOutOfBandOption (
887 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
888 parity and stop Bits set.
892 Var_UpdateAllConsoleOption (
897 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
898 this EFI Variable is deleted.
899 It also update the BMM context data specified the "BootNext" value.
901 @param CallbackData The BMM context data.
903 @retval EFI_SUCCESS The function complete successfully.
904 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
909 IN BMM_CALLBACK_DATA
*CallbackData
913 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
914 BootOptionMenu with the new "BootOrder" list.
916 @param CallbackData The BMM context data.
918 @retval EFI_SUCCESS The function complete successfully.
919 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
920 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
924 Var_UpdateBootOrder (
925 IN BMM_CALLBACK_DATA
*CallbackData
929 This function update the "DriverOrder" EFI Variable based on
930 BMM Formset's NV map. It then refresh DriverOptionMenu
931 with the new "DriverOrder" list.
933 @param CallbackData The BMM context data.
935 @retval EFI_SUCCESS The function complete successfully.
936 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
937 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
941 Var_UpdateDriverOrder (
942 IN BMM_CALLBACK_DATA
*CallbackData
946 Update the Text Mode of Console.
948 @param CallbackData The context data for BMM.
950 @retval EFI_SUCCSS If the Text Mode of Console is updated.
951 @return Other value if the Text Mode of Console is not updated.
956 IN BMM_CALLBACK_DATA
*CallbackData
960 // Following are page create and refresh functions
963 Refresh the global UpdateData structure.
972 Clean up the dynamic opcode at label and form specified by
975 @param LabelId It is both the Form ID and Label ID for
977 @param CallbackData The BMM context data.
983 IN BMM_CALLBACK_DATA
*CallbackData
987 Create a lit of boot option from global BootOptionMenu. It
988 allow user to delete the boot option.
990 @param CallbackData The BMM context data.
995 IN BMM_CALLBACK_DATA
*CallbackData
999 Create a lit of driver option from global DriverMenu.
1001 @param CallbackData The BMM context data.
1004 UpdateDrvAddHandlePage (
1005 IN BMM_CALLBACK_DATA
*CallbackData
1009 Create a lit of driver option from global DriverOptionMenu. It
1010 allow user to delete the driver option.
1012 @param CallbackData The BMM context data.
1016 IN BMM_CALLBACK_DATA
*CallbackData
1020 Prepare the page to allow user to add description for a Driver Option.
1022 @param CallbackData The BMM context data.
1025 UpdateDriverAddHandleDescPage (
1026 IN BMM_CALLBACK_DATA
*CallbackData
1030 Dispatch the correct update page function to call based on the UpdatePageId.
1032 @param UpdatePageId The form ID.
1033 @param CallbackData The BMM context data.
1037 IN UINT16 UpdatePageId
,
1038 IN BMM_CALLBACK_DATA
*CallbackData
1042 Create the dynamic page to allow user to set the "BootNext" vaule.
1044 @param CallbackData The BMM context data.
1047 UpdateBootNextPage (
1048 IN BMM_CALLBACK_DATA
*CallbackData
1052 Create the dynamic page to allow user to set the "TimeOut" vaule.
1054 @param CallbackData The BMM context data.
1058 IN BMM_CALLBACK_DATA
*CallbackData
1062 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1063 Parity, Stop Bits, Terminal Type.
1065 @param CallbackData The BMM context data.
1068 UpdateTerminalPage (
1069 IN BMM_CALLBACK_DATA
*CallbackData
1073 Refresh the text mode page
1075 @param CallbackData The BMM context data.
1079 IN BMM_CALLBACK_DATA
*CallbackData
1083 Create a list of Goto Opcode for all terminal devices logged
1084 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1086 @param CallbackData The BMM context data.
1090 IN BMM_CALLBACK_DATA
*CallbackData
1094 Function opens and returns a file handle to the root directory of a volume.
1096 @param DeviceHandle A handle for a device
1097 @return A valid file handle or NULL is returned
1101 IN EFI_HANDLE DeviceHandle
1105 Function gets the file system information from an open file descriptor,
1106 and stores it in a buffer allocated from pool.
1108 @param FHand The file handle.
1110 @return A pointer to a buffer with file information.
1111 NULL is returned if failed to get Vaolume Label Info.
1113 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1114 EfiLibFileSystemVolumeLabelInfo (
1115 IN EFI_FILE_HANDLE FHand
1120 Function gets the file information from an open file descriptor, and stores it
1121 in a buffer allocated from pool.
1123 @param FHand File Handle.
1125 @return A pointer to a buffer with file information or NULL is returned
1130 IN EFI_FILE_HANDLE FHand
1134 Find the first instance of this Protocol in the system and return it's interface.
1136 @param ProtocolGuid Provides the protocol to search for
1137 @param Interface On return, a pointer to the first interface
1138 that matches ProtocolGuid
1140 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1141 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1145 EfiLibLocateProtocol (
1146 IN EFI_GUID
*ProtocolGuid
,
1147 OUT VOID
**Interface
1151 Adjusts the size of a previously allocated buffer.
1153 @param OldPool A pointer to the buffer whose size is being adjusted.
1154 @param OldSize The size of the current buffer.
1155 @param NewSize The size of the new buffer.
1157 @return The newly allocated buffer. if NULL, allocation failed.
1168 Function deletes the variable specified by VarName and VarGuid.
1171 @param VarName A Null-terminated Unicode string that is
1172 the name of the vendor's variable.
1174 @param VarGuid A unique identifier for the vendor.
1176 @retval EFI_SUCCESS The variable was found and removed
1177 @retval EFI_UNSUPPORTED The variable store was inaccessible
1178 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1179 @retval EFI_NOT_FOUND The variable was not found
1183 EfiLibDeleteVariable (
1185 IN EFI_GUID
*VarGuid
1191 @param Src The source.
1193 @return A new string which is duplicated copy of the source.
1194 @retval NULL If there is not enough memory.
1203 Function is used to determine the number of device path instances
1204 that exist in a device path.
1207 @param DevicePath A pointer to a device path data structure.
1209 @return This function counts and returns the number of device path instances
1214 EfiDevicePathInstanceCount (
1215 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1219 Create string tokens for a menu from its help strings and display strings
1222 @param CallbackData The BMM context data.
1223 @param HiiHandle Hii Handle of the package to be updated.
1224 @param MenuOption The Menu whose string tokens need to be created
1226 @retval EFI_SUCCESS string tokens created successfully
1227 @retval others contain some errors
1231 CreateMenuStringToken (
1232 IN BMM_CALLBACK_DATA
*CallbackData
,
1233 IN EFI_HII_HANDLE HiiHandle
,
1234 IN BM_MENU_OPTION
*MenuOption
1238 Get a string from the Data Hub record based on
1241 @param DevPath The device Path.
1243 @return A string located from the Data Hub records based on
1245 @retval NULL If failed to get the String from Data Hub.
1249 EfiLibStrFromDatahub (
1250 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1254 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1255 specified by DeviceType.
1257 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1259 @param OptionIndex Returns the index number (#### in Boot####).
1260 @param OptionSize Return the size of the Boot### variable.
1264 GetLegacyBootOptionVar (
1265 IN UINTN DeviceType
,
1266 OUT UINTN
*OptionIndex
,
1267 OUT UINTN
*OptionSize
1271 Initialize the Boot Maintenance Utitliy.
1281 Intialize all the string depositories.
1285 InitializeStringDepository (
1290 Fetch a usable string node from the string depository and return the string token.
1293 @param CallbackData The BMM context data.
1294 @param StringDepository Pointer of the string depository.
1296 @retval EFI_STRING_ID String token.
1300 GetStringTokenFromDepository (
1301 IN BMM_CALLBACK_DATA
*CallbackData
,
1302 IN STRING_DEPOSITORY
*StringDepository
1306 Reclaim string depositories by moving the current node pointer to list head..
1309 ReclaimStringDepository (
1314 Release resource for all the string depositories.
1318 CleanUpStringDepository (
1323 Discard all changes done to the BMM pages such as Boot Order change,
1324 Driver order change.
1326 @param Private The BMM context data.
1327 @param CurrentFakeNVMap The current Fack NV Map.
1331 DiscardChangeHandler (
1332 IN BMM_CALLBACK_DATA
*Private
,
1333 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1337 Dispatch the display to the next page based on NewPageId.
1339 @param Private The BMM context data.
1340 @param NewPageId The original page ID.
1345 BMM_CALLBACK_DATA
*Private
,
1350 Boot a file selected by user at File Expoloer of BMM.
1352 @param FileContext The file context data, which contains the device path
1353 of the file to be boot from.
1355 @retval EFI_SUCCESS The function completed successfull.
1356 @return Other value if the boot from the file fails.
1361 IN BM_FILE_CONTEXT
*FileContext
1365 Update the file explower page with the refershed file system.
1368 @param CallbackData BMM context data
1369 @param KeyValue Key value to identify the type of data to expect.
1371 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1372 @retval FALSE Indicate that there is no need to exit file explorer.
1376 UpdateFileExplorer (
1377 IN BMM_CALLBACK_DATA
*CallbackData
,
1382 This function applies changes in a driver's configuration.
1383 Input is a Configuration, which has the routing data for this
1384 driver followed by name / value configuration pairs. The driver
1385 must apply those pairs to its configurable storage. If the
1386 driver's configuration is stored in a linear block of data
1387 and the driver's name / value pairs are in <BlockConfig>
1388 format, it may use the ConfigToBlock helper function (above) to
1389 simplify the job. Currently not implemented.
1391 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1392 @param[in] Configuration A null-terminated Unicode string in
1393 <ConfigString> format.
1394 @param[out] Progress A pointer to a string filled in with the
1395 offset of the most recent '&' before the
1396 first failing name / value pair (or the
1397 beginn ing of the string if the failure
1398 is in the first name / value pair) or
1399 the terminating NULL if all was
1402 @retval EFI_SUCCESS The results have been distributed or are
1403 awaiting distribution.
1404 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1405 parts of the results that must be
1406 stored awaiting possible future
1408 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1409 Results parameter would result
1410 in this type of error.
1411 @retval EFI_NOT_FOUND Target for the specified routing data
1416 FileExplorerRouteConfig (
1417 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1418 IN CONST EFI_STRING Configuration
,
1419 OUT EFI_STRING
*Progress
1423 This function processes the results of changes in configuration.
1424 When user select a interactive opcode, this callback will be triggered.
1425 Based on the Question(QuestionId) that triggers the callback, the corresponding
1426 actions is performed. It handles:
1428 1) the addition of boot option.
1429 2) the addition of driver option.
1430 3) exit from file browser
1431 4) update of file content if a dir is selected.
1432 5) boot the file if a file is selected in "boot from file"
1435 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1436 @param Action Specifies the type of action taken by the browser.
1437 @param QuestionId A unique value which is sent to the original exporting driver
1438 so that it can identify the type of data to expect.
1439 @param Type The type of value for the question.
1440 @param Value A pointer to the data being sent to the original exporting driver.
1441 @param ActionRequest On return, points to the action requested by the callback function.
1443 @retval EFI_SUCCESS The callback successfully handled the action.
1444 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1445 @retval EFI_DEVICE_ERROR The variable could not be saved.
1446 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1451 FileExplorerCallback (
1452 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1453 IN EFI_BROWSER_ACTION Action
,
1454 IN EFI_QUESTION_ID QuestionId
,
1456 IN EFI_IFR_TYPE_VALUE
*Value
,
1457 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1461 Remove the installed BootMaint and FileExplorer HiiPackages.
1470 Install BootMaint and FileExplorer HiiPackages.
1474 InitBootMaintenance(
1480 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1481 in BMM_FAKE_NV_DATA structure.
1483 @param CallbackData The BMM context data.
1488 IN BMM_CALLBACK_DATA
*CallbackData
1493 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1494 in BMM_FAKE_NV_DATA structure.
1496 @param CallbackData The BMM context data.
1500 GetConsoleOutCheck (
1501 IN BMM_CALLBACK_DATA
*CallbackData
1506 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1507 in BMM_FAKE_NV_DATA structure.
1509 @param CallbackData The BMM context data.
1513 GetConsoleErrCheck (
1514 IN BMM_CALLBACK_DATA
*CallbackData
1519 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1520 to BMM_FAKE_NV_DATA structure.
1522 @param CallbackData The BMM context data.
1526 GetTerminalAttribute (
1527 IN BMM_CALLBACK_DATA
*CallbackData
1531 // Global variable in this program (defined in data.c)
1533 extern BM_MENU_OPTION BootOptionMenu
;
1534 extern BM_MENU_OPTION DriverOptionMenu
;
1535 extern BM_MENU_OPTION FsOptionMenu
;
1536 extern BM_MENU_OPTION ConsoleInpMenu
;
1537 extern BM_MENU_OPTION ConsoleOutMenu
;
1538 extern BM_MENU_OPTION ConsoleErrMenu
;
1539 extern BM_MENU_OPTION DirectoryMenu
;
1540 extern BM_MENU_OPTION DriverMenu
;
1541 extern BM_MENU_OPTION TerminalMenu
;
1542 extern UINT16 TerminalType
[5];
1543 extern COM_ATTR BaudRateList
[19];
1544 extern COM_ATTR DataBitsList
[4];
1545 extern COM_ATTR ParityList
[5];
1546 extern COM_ATTR StopBitsList
[3];
1547 extern EFI_GUID TerminalTypeGuid
[5];
1548 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1549 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1550 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1551 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1552 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1553 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1554 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1555 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1556 extern UINT16 mFlowControlType
[2];
1557 extern UINT32 mFlowControlValue
[2];
1560 // Shared IFR form update data
1562 extern VOID
*mStartOpCodeHandle
;
1563 extern VOID
*mEndOpCodeHandle
;
1564 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1565 extern EFI_IFR_GUID_LABEL
*mEndLabel
;