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 BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
183 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
184 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
185 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
186 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
187 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
188 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
189 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
190 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
191 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
193 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
194 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
195 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
196 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
197 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
198 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
199 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
200 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
201 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
202 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
203 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
204 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
205 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
206 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
207 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
208 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
209 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
210 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
211 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
212 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
213 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
214 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
215 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
216 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
217 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
218 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
219 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
220 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
221 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
222 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
223 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
224 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
225 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
227 #define STRING_DEPOSITORY_NUMBER 8
230 /// Serial Ports attributes, first one is the value for
231 /// return from callback function, stringtoken is used to
232 /// display the value properly
255 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
256 } BM_TERMINAL_CONTEXT
;
260 BOOLEAN LoadOptionModified
;
265 BOOLEAN ForceReconnect
;
266 UINTN OptionalDataSize
;
268 UINTN LoadOptionSize
;
272 UINT16 FilePathListLength
;
274 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
286 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
287 } BM_CONSOLE_CONTEXT
;
296 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
297 EFI_FILE_HANDLE FHandle
;
299 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
303 BOOLEAN IsRemovableMedia
;
305 BOOLEAN IsBootLegacy
;
310 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
323 UINT16
*DisplayString
;
325 EFI_STRING_ID DisplayStringToken
;
326 EFI_STRING_ID HelpStringToken
;
327 UINTN ContextSelection
;
328 VOID
*VariableContext
;
333 // Shared callback data.
337 BM_MENU_ENTRY
*MenuEntry
;
338 BM_HANDLE_CONTEXT
*HandleContext
;
339 BM_FILE_CONTEXT
*FileContext
;
340 BM_LOAD_CONTEXT
*LoadContext
;
341 BM_TERMINAL_CONTEXT
*TerminalContext
;
342 UINTN CurrentTerminal
;
346 // BMM main formset callback data.
348 EFI_HII_HANDLE BmmHiiHandle
;
349 EFI_HANDLE BmmDriverHandle
;
350 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
351 EFI_FORM_ID BmmCurrentPageId
;
352 EFI_FORM_ID BmmPreviousPageId
;
353 BOOLEAN BmmAskSaveOrNot
;
354 BMM_FAKE_NV_DATA BmmFakeNvData
;
355 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
358 // File explorer formset callback data.
360 EFI_HII_HANDLE FeHiiHandle
;
361 EFI_HANDLE FeDriverHandle
;
362 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
363 FILE_EXPLORER_STATE FeCurrentState
;
364 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
365 FILE_EXPLORER_NV_DATA FeFakeNvData
;
368 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
370 struct _STRING_LIST_NODE
{
371 EFI_STRING_ID StringToken
;
372 STRING_LIST_NODE
*Next
;
375 typedef struct _STRING_DEPOSITORY
{
376 UINTN TotalNodeNumber
;
377 STRING_LIST_NODE
*CurrentNode
;
378 STRING_LIST_NODE
*ListHead
;
384 // For initializing File System menu
388 This function build the FsOptionMenu list which records all
389 available file system in the system. They includes all instances
390 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
391 and all type of legacy boot device.
393 @param CallbackData BMM context data
395 @retval EFI_SUCCESS Success find the file system
396 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
400 BOpt_FindFileSystem (
401 IN BMM_CALLBACK_DATA
*CallbackData
405 Find files under current directory
406 All files and sub-directories in current directory
407 will be stored in DirectoryMenu for future use.
409 @param CallbackData The BMM context data.
410 @param MenuEntry The Menu Entry.
412 @retval EFI_SUCCESS Get files from current dir successfully.
413 @return Other value if can't get files from current dir.
418 IN BMM_CALLBACK_DATA
*CallbackData
,
419 IN BM_MENU_ENTRY
*MenuEntry
424 Find drivers that will be added as Driver#### variables from handles
425 in current system environment
426 All valid handles in the system except those consume SimpleFs, LoadFile
427 are stored in DriverMenu for future use.
429 @retval EFI_SUCCESS The function complets successfully.
430 @return Other value if failed to build the DriverMenu.
440 Build the BootOptionMenu according to BootOrder Variable.
441 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
443 @param CallbackData The BMM context data.
445 @return The number of the Var Boot####.
449 BOpt_GetBootOptions (
450 IN BMM_CALLBACK_DATA
*CallbackData
455 Build up all DriverOptionMenu
457 @param CallbackData The BMM context data.
459 @return EFI_SUCESS The functin completes successfully.
460 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
465 BOpt_GetDriverOptions (
466 IN BMM_CALLBACK_DATA
*CallbackData
470 Free resources allocated in Allocate Rountine.
472 @param FreeMenu Menu to be freed
477 BM_MENU_OPTION
*FreeMenu
483 Append file name to existing file name.
485 @param Str1 The existing file name
486 @param Str2 The file name to be appended
488 @return Allocate a new string to hold the appended result.
489 Caller is responsible to free the returned string.
493 BOpt_AppendFileName (
500 Check whether current FileName point to a valid
503 @param FileName File need to be checked.
505 @retval TRUE Is Efi Image
506 @retval FALSE Not a valid Efi Image
510 BOpt_IsEfiImageName (
516 Check whether current FileName point to a valid Efi Application
518 @param Dir Pointer to current Directory
519 @param FileName Pointer to current File name.
521 @retval TRUE Is a valid Efi Application
522 @retval FALSE not a valid Efi Application
527 IN EFI_FILE_HANDLE Dir
,
533 Get the Option Number that has not been allocated for use.
535 @param Type The type of Option.
537 @return The available Option Number.
541 BOpt_GetOptionNumber (
547 Get the Option Number for Boot#### that does not used.
549 @return The available Option Number.
553 BOpt_GetBootOptionNumber (
559 Get the Option Number for Driver#### that does not used.
561 @return The unused Option Number.
565 BOpt_GetDriverOptionNumber (
570 Create a menu entry give a Menu type.
572 @param MenuType The Menu type to be created.
575 @retval NULL If failed to create the menu.
580 BOpt_CreateMenuEntry (
585 Free up all resource allocated for a BM_MENU_ENTRY.
587 @param MenuEntry A pointer to BM_MENU_ENTRY.
591 BOpt_DestroyMenuEntry (
592 BM_MENU_ENTRY
*MenuEntry
596 Get the Menu Entry from the list in Menu Entry List.
598 If MenuNumber is great or equal to the number of Menu
599 Entry in the list, then ASSERT.
601 @param MenuOption The Menu Entry List to read the menu entry.
602 @param MenuNumber The index of Menu Entry.
604 @return The Menu Entry.
609 BM_MENU_OPTION
*MenuOption
,
614 Get option number according to Boot#### and BootOrder variable.
615 The value is saved as #### + 1.
617 @param CallbackData The BMM context data.
621 IN BMM_CALLBACK_DATA
*CallbackData
625 Get driver option order from globalc DriverOptionMenu.
627 @param CallbackData The BMM context data.
632 IN BMM_CALLBACK_DATA
*CallbackData
636 // Locate all serial io devices for console
639 Build a list containing all serial devices.
641 @retval EFI_SUCCESS The function complete successfully.
642 @retval EFI_UNSUPPORTED No serial ports present.
651 // Initializing Console menu
654 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
656 @retval EFI_SUCCESS The function always complete successfully.
665 // Get current mode information
668 Get mode number according to column and row
670 @param CallbackData The BMM context data.
674 IN BMM_CALLBACK_DATA
*CallbackData
678 // Cleaning up console menu
681 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
683 @retval EFI_SUCCESS The function always complete successfully.
691 Update the device path that describing a terminal device
692 based on the new BaudRate, Data Bits, parity and Stop Bits
695 @param DevicePath The devicepath protocol instance wanted to be updated.
699 ChangeVariableDevicePath (
700 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
704 Update the multi-instance device path of Terminal Device based on
705 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
706 device path in the Terminal Device in TerminalMenu is also updated.
708 @param DevicePath The multi-instance device path.
709 @param ChangeTerminal TRUE, then device path in the Terminal Device
710 in TerminalMenu is also updated; FALSE, no update.
712 @return EFI_SUCCESS The function completes successfully.
716 ChangeTerminalDevicePath (
717 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
718 IN BOOLEAN ChangeTerminal
722 // Variable operation by menu selection
725 This function create a currently loaded Boot Option from
726 the BMM. It then appends this Boot Option to the end of
727 the "BootOrder" list. It also append this Boot Opotion to the end
730 @param CallbackData The BMM context data.
731 @param NvRamMap The file explorer formset internal state.
733 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
734 @retval EFI_SUCCESS If function completes successfully.
738 Var_UpdateBootOption (
739 IN BMM_CALLBACK_DATA
*CallbackData
,
740 IN FILE_EXPLORER_NV_DATA
*NvRamMap
744 Delete Boot Option that represent a Deleted state in BootOptionMenu.
745 After deleting this boot option, call Var_ChangeBootOrder to
746 make sure BootOrder is in valid state.
748 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
749 BM_LOAD_CONTEXT marked for deletion is deleted
750 @return Others If failed to update the "BootOrder" variable after deletion.
759 After any operation on Boot####, there will be a discrepancy in BootOrder.
760 Since some are missing but in BootOrder, while some are present but are
761 not reflected by BootOrder. Then a function rebuild BootOrder from
762 scratch by content from BootOptionMenu is needed.
764 @retval EFI_SUCCESS The boot order is updated successfully.
765 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
769 Var_ChangeBootOrder (
774 This function create a currently loaded Drive Option from
775 the BMM. It then appends this Driver Option to the end of
776 the "DriverOrder" list. It append this Driver Opotion to the end
779 @param CallbackData The BMM context data.
780 @param HiiHandle The HII handle associated with the BMM formset.
781 @param DescriptionData The description of this driver option.
782 @param OptionalData The optional load option.
783 @param ForceReconnect If to force reconnect.
785 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
786 @retval EFI_SUCCESS If function completes successfully.
790 Var_UpdateDriverOption (
791 IN BMM_CALLBACK_DATA
*CallbackData
,
792 IN EFI_HII_HANDLE HiiHandle
,
793 IN UINT16
*DescriptionData
,
794 IN UINT16
*OptionalData
,
795 IN UINT8 ForceReconnect
799 Delete Load Option that represent a Deleted state in BootOptionMenu.
800 After deleting this Driver option, call Var_ChangeDriverOrder to
801 make sure DriverOrder is in valid state.
803 @retval EFI_SUCCESS Load Option is successfully updated.
804 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
809 Var_DelDriverOption (
814 After any operation on Driver####, there will be a discrepancy in
815 DriverOrder. Since some are missing but in DriverOrder, while some
816 are present but are not reflected by DriverOrder. Then a function
817 rebuild DriverOrder from scratch by content from DriverOptionMenu is
820 @retval EFI_SUCCESS The driver order is updated successfully.
821 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
825 Var_ChangeDriverOrder (
830 This function delete and build multi-instance device path ConIn
833 @retval EFI_SUCCESS The function complete successfully.
834 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
837 Var_UpdateConsoleInpOption (
842 This function delete and build multi-instance device path ConOut console device.
844 @retval EFI_SUCCESS The function complete successfully.
845 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
848 Var_UpdateConsoleOutOption (
853 This function delete and build multi-instance device path ErrOut console device.
855 @retval EFI_SUCCESS The function complete successfully.
856 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
859 Var_UpdateErrorOutOption (
864 This function delete and build Out of Band console device.
866 @param MenuIndex Menu index which user select in the terminal menu list.
868 @retval EFI_SUCCESS The function complete successfully.
869 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
872 Var_UpdateOutOfBandOption (
877 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
878 parity and stop Bits set.
882 Var_UpdateAllConsoleOption (
887 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
888 this EFI Variable is deleted.
889 It also update the BMM context data specified the "BootNext" value.
891 @param CallbackData The BMM context data.
893 @retval EFI_SUCCESS The function complete successfully.
894 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
899 IN BMM_CALLBACK_DATA
*CallbackData
903 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
904 BootOptionMenu with the new "BootOrder" list.
906 @param CallbackData The BMM context data.
908 @retval EFI_SUCCESS The function complete successfully.
909 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
910 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
914 Var_UpdateBootOrder (
915 IN BMM_CALLBACK_DATA
*CallbackData
919 This function update the "DriverOrder" EFI Variable based on
920 BMM Formset's NV map. It then refresh DriverOptionMenu
921 with the new "DriverOrder" list.
923 @param CallbackData The BMM context data.
925 @retval EFI_SUCCESS The function complete successfully.
926 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
927 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
931 Var_UpdateDriverOrder (
932 IN BMM_CALLBACK_DATA
*CallbackData
936 Update the Text Mode of Console.
938 @param CallbackData The context data for BMM.
940 @retval EFI_SUCCSS If the Text Mode of Console is updated.
941 @return Other value if the Text Mode of Console is not updated.
946 IN BMM_CALLBACK_DATA
*CallbackData
950 // Following are page create and refresh functions
953 Refresh the global UpdateData structure.
962 Clean up the dynamic opcode at label and form specified by
965 @param LabelId It is both the Form ID and Label ID for
967 @param CallbackData The BMM context data.
973 IN BMM_CALLBACK_DATA
*CallbackData
977 Create a lit of boot option from global BootOptionMenu. It
978 allow user to delete the boot option.
980 @param CallbackData The BMM context data.
985 IN BMM_CALLBACK_DATA
*CallbackData
989 Create a lit of driver option from global DriverMenu.
991 @param CallbackData The BMM context data.
994 UpdateDrvAddHandlePage (
995 IN BMM_CALLBACK_DATA
*CallbackData
999 Create a lit of driver option from global DriverOptionMenu. It
1000 allow user to delete the driver option.
1002 @param CallbackData The BMM context data.
1006 IN BMM_CALLBACK_DATA
*CallbackData
1010 Prepare the page to allow user to add description for a Driver Option.
1012 @param CallbackData The BMM context data.
1015 UpdateDriverAddHandleDescPage (
1016 IN BMM_CALLBACK_DATA
*CallbackData
1020 Dispatch the correct update page function to call based on the UpdatePageId.
1022 @param UpdatePageId The form ID.
1023 @param CallbackData The BMM context data.
1027 IN UINT16 UpdatePageId
,
1028 IN BMM_CALLBACK_DATA
*CallbackData
1032 Create the dynamic page to allow user to set the "BootNext" vaule.
1034 @param CallbackData The BMM context data.
1037 UpdateBootNextPage (
1038 IN BMM_CALLBACK_DATA
*CallbackData
1042 Create the dynamic page to allow user to set the "TimeOut" vaule.
1044 @param CallbackData The BMM context data.
1048 IN BMM_CALLBACK_DATA
*CallbackData
1052 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1053 Parity, Stop Bits, Terminal Type.
1055 @param CallbackData The BMM context data.
1058 UpdateTerminalPage (
1059 IN BMM_CALLBACK_DATA
*CallbackData
1063 Refresh the text mode page
1065 @param CallbackData The BMM context data.
1069 IN BMM_CALLBACK_DATA
*CallbackData
1073 Create a list of Goto Opcode for all terminal devices logged
1074 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1076 @param CallbackData The BMM context data.
1080 IN BMM_CALLBACK_DATA
*CallbackData
1084 Function opens and returns a file handle to the root directory of a volume.
1086 @param DeviceHandle A handle for a device
1087 @return A valid file handle or NULL is returned
1091 IN EFI_HANDLE DeviceHandle
1095 Function gets the file system information from an open file descriptor,
1096 and stores it in a buffer allocated from pool.
1098 @param FHand The file handle.
1100 @return A pointer to a buffer with file information.
1101 NULL is returned if failed to get Vaolume Label Info.
1103 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1104 EfiLibFileSystemVolumeLabelInfo (
1105 IN EFI_FILE_HANDLE FHand
1110 Function gets the file information from an open file descriptor, and stores it
1111 in a buffer allocated from pool.
1113 @param FHand File Handle.
1115 @return A pointer to a buffer with file information or NULL is returned
1120 IN EFI_FILE_HANDLE FHand
1124 Find the first instance of this Protocol in the system and return it's interface.
1126 @param ProtocolGuid Provides the protocol to search for
1127 @param Interface On return, a pointer to the first interface
1128 that matches ProtocolGuid
1130 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1131 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1135 EfiLibLocateProtocol (
1136 IN EFI_GUID
*ProtocolGuid
,
1137 OUT VOID
**Interface
1141 Adjusts the size of a previously allocated buffer.
1143 @param OldPool A pointer to the buffer whose size is being adjusted.
1144 @param OldSize The size of the current buffer.
1145 @param NewSize The size of the new buffer.
1147 @return The newly allocated buffer. if NULL, allocation failed.
1158 Function deletes the variable specified by VarName and VarGuid.
1161 @param VarName A Null-terminated Unicode string that is
1162 the name of the vendor's variable.
1164 @param VarGuid A unique identifier for the vendor.
1166 @retval EFI_SUCCESS The variable was found and removed
1167 @retval EFI_UNSUPPORTED The variable store was inaccessible
1168 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1169 @retval EFI_NOT_FOUND The variable was not found
1173 EfiLibDeleteVariable (
1175 IN EFI_GUID
*VarGuid
1181 @param Src The source.
1183 @return A new string which is duplicated copy of the source.
1184 @retval NULL If there is not enough memory.
1193 Function is used to determine the number of device path instances
1194 that exist in a device path.
1197 @param DevicePath A pointer to a device path data structure.
1199 @return This function counts and returns the number of device path instances
1204 EfiDevicePathInstanceCount (
1205 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1209 Create string tokens for a menu from its help strings and display strings
1212 @param CallbackData The BMM context data.
1213 @param HiiHandle Hii Handle of the package to be updated.
1214 @param MenuOption The Menu whose string tokens need to be created
1216 @retval EFI_SUCCESS string tokens created successfully
1217 @retval others contain some errors
1221 CreateMenuStringToken (
1222 IN BMM_CALLBACK_DATA
*CallbackData
,
1223 IN EFI_HII_HANDLE HiiHandle
,
1224 IN BM_MENU_OPTION
*MenuOption
1228 Get a string from the Data Hub record based on
1231 @param DevPath The device Path.
1233 @return A string located from the Data Hub records based on
1235 @retval NULL If failed to get the String from Data Hub.
1239 EfiLibStrFromDatahub (
1240 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1244 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1245 specified by DeviceType.
1247 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1249 @param OptionIndex Returns the index number (#### in Boot####).
1250 @param OptionSize Return the size of the Boot### variable.
1254 GetLegacyBootOptionVar (
1255 IN UINTN DeviceType
,
1256 OUT UINTN
*OptionIndex
,
1257 OUT UINTN
*OptionSize
1261 Initialize the Boot Maintenance Utitliy.
1271 Intialize all the string depositories.
1275 InitializeStringDepository (
1280 Fetch a usable string node from the string depository and return the string token.
1283 @param CallbackData The BMM context data.
1284 @param StringDepository Pointer of the string depository.
1286 @retval EFI_STRING_ID String token.
1290 GetStringTokenFromDepository (
1291 IN BMM_CALLBACK_DATA
*CallbackData
,
1292 IN STRING_DEPOSITORY
*StringDepository
1296 Reclaim string depositories by moving the current node pointer to list head..
1299 ReclaimStringDepository (
1304 Release resource for all the string depositories.
1308 CleanUpStringDepository (
1313 Function handling request to apply changes for BMM pages.
1315 @param Private Pointer to callback data buffer.
1316 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1317 @param FormId ID of the form which has sent the request to apply change.
1319 @retval EFI_SUCCESS Change successfully applied.
1320 @retval Other Error occurs while trying to apply changes.
1324 ApplyChangeHandler (
1325 IN BMM_CALLBACK_DATA
*Private
,
1326 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1327 IN EFI_FORM_ID FormId
1331 Discard all changes done to the BMM pages such as Boot Order change,
1332 Driver order change.
1334 @param Private The BMM context data.
1335 @param CurrentFakeNVMap The current Fack NV Map.
1339 DiscardChangeHandler (
1340 IN BMM_CALLBACK_DATA
*Private
,
1341 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1345 Dispatch the display to the next page based on NewPageId.
1347 @param Private The BMM context data.
1348 @param NewPageId The original page ID.
1353 BMM_CALLBACK_DATA
*Private
,
1358 Boot a file selected by user at File Expoloer of BMM.
1360 @param FileContext The file context data, which contains the device path
1361 of the file to be boot from.
1363 @retval EFI_SUCCESS The function completed successfull.
1364 @return Other value if the boot from the file fails.
1369 IN BM_FILE_CONTEXT
*FileContext
1373 Update the file explower page with the refershed file system.
1376 @param CallbackData BMM context data
1377 @param KeyValue Key value to identify the type of data to expect.
1379 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1380 @retval FALSE Indicate that there is no need to exit file explorer.
1384 UpdateFileExplorer (
1385 IN BMM_CALLBACK_DATA
*CallbackData
,
1390 This function processes the results of changes in configuration.
1391 When user select a interactive opcode, this callback will be triggered.
1392 Based on the Question(QuestionId) that triggers the callback, the corresponding
1393 actions is performed. It handles:
1395 1) the addition of boot option.
1396 2) the addition of driver option.
1397 3) exit from file browser
1398 4) update of file content if a dir is selected.
1399 5) boot the file if a file is selected in "boot from file"
1402 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1403 @param Action Specifies the type of action taken by the browser.
1404 @param QuestionId A unique value which is sent to the original exporting driver
1405 so that it can identify the type of data to expect.
1406 @param Type The type of value for the question.
1407 @param Value A pointer to the data being sent to the original exporting driver.
1408 @param ActionRequest On return, points to the action requested by the callback function.
1410 @retval EFI_SUCCESS The callback successfully handled the action.
1411 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1412 @retval EFI_DEVICE_ERROR The variable could not be saved.
1413 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1418 FileExplorerCallback (
1419 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1420 IN EFI_BROWSER_ACTION Action
,
1421 IN EFI_QUESTION_ID QuestionId
,
1423 IN EFI_IFR_TYPE_VALUE
*Value
,
1424 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1428 Remove the installed BootMaint and FileExplorer HiiPackages.
1437 Install BootMaint and FileExplorer HiiPackages.
1441 InitBootMaintenance(
1446 // Global variable in this program (defined in data.c)
1448 extern BM_MENU_OPTION BootOptionMenu
;
1449 extern BM_MENU_OPTION DriverOptionMenu
;
1450 extern BM_MENU_OPTION FsOptionMenu
;
1451 extern BM_MENU_OPTION ConsoleInpMenu
;
1452 extern BM_MENU_OPTION ConsoleOutMenu
;
1453 extern BM_MENU_OPTION ConsoleErrMenu
;
1454 extern BM_MENU_OPTION DirectoryMenu
;
1455 extern BM_MENU_OPTION DriverMenu
;
1456 extern BM_MENU_OPTION TerminalMenu
;
1457 extern UINT16 TerminalType
[5];
1458 extern COM_ATTR BaudRateList
[19];
1459 extern COM_ATTR DataBitsList
[4];
1460 extern COM_ATTR ParityList
[5];
1461 extern COM_ATTR StopBitsList
[3];
1462 extern EFI_GUID TerminalTypeGuid
[5];
1463 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1464 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1465 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1466 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1467 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1468 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1469 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1470 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1473 // Shared IFR form update data
1475 extern VOID
*mStartOpCodeHandle
;
1476 extern VOID
*mEndOpCodeHandle
;
1477 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1478 extern EFI_IFR_GUID_LABEL
*mEndLabel
;