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"
23 // Constants which are variable names used to access variables
26 #define VAR_CON_OUT_MODE L"ConOutMode"
32 #define STR_FLOPPY L"Floppy Drive #%02x"
33 #define STR_HARDDISK L"HardDisk Drive #%02x"
34 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
35 #define STR_NET L"NET Drive #%02x"
36 #define STR_BEV L"BEV Drive #%02x"
37 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
38 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
39 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
40 #define STR_NET_HELP L"NET Drive #%02x"
41 #define STR_BEV_HELP L"BEV Drive #%02x"
44 // Variable created with this flag will be "Efi:...."
46 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
48 extern EFI_GUID mBootMaintGuid
;
49 extern EFI_GUID mFileExplorerGuid
;
50 extern CHAR16 mFileExplorerStorageName
[];
51 extern CHAR16 mBootMaintStorageName
[];
53 // These are the VFR compiler generated data representing our VFR data.
59 // Below are the number of options in Baudrate, Databits,
60 // Parity and Stopbits selection for serial ports.
62 #define BM_COM_ATTR_BUADRATE 19
63 #define BM_COM_ATTR_DATABITS 4
64 #define BM_COM_ATTR_PARITY 5
65 #define BM_COM_ATTR_STOPBITS 3
68 // Callback function helper
70 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
71 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
73 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
76 // Enumeration type definition
78 typedef UINT8 BBS_TYPE
;
80 typedef enum _TYPE_OF_TERMINAL
{
81 TerminalTypePcAnsi
= 0,
83 TerminalTypeVt100Plus
,
87 typedef enum _FILE_EXPLORER_STATE
{
88 FileExplorerStateInActive
= 0,
89 FileExplorerStateBootFromFile
,
90 FileExplorerStateAddBootOption
,
91 FileExplorerStateAddDriverOptionState
,
92 FileExplorerStateUnknown
93 } FILE_EXPLORER_STATE
;
95 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
96 FileExplorerDisplayFileSystem
,
97 FileExplorerDisplayDirectory
,
98 FileExplorerDisplayUnknown
99 } FILE_EXPLORER_DISPLAY_CONTEXT
;
102 // All of the signatures that will be used in list structure
104 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
105 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
106 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
107 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
108 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
109 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
110 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
112 #define BM_LOAD_CONTEXT_SELECT 0x0
113 #define BM_CONSOLE_CONTEXT_SELECT 0x1
114 #define BM_FILE_CONTEXT_SELECT 0x2
115 #define BM_HANDLE_CONTEXT_SELECT 0x3
116 #define BM_TERMINAL_CONTEXT_SELECT 0x5
118 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
119 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
120 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
123 // Buffer size for update data
125 #define UPDATE_DATA_SIZE 0x100000
128 // Namespace of callback keys used in display and file system navigation
130 #define MAX_BBS_OFFSET 0xE000
131 #define NET_OPTION_OFFSET 0xD800
132 #define BEV_OPTION_OFFSET 0xD000
133 #define FD_OPTION_OFFSET 0xC000
134 #define HD_OPTION_OFFSET 0xB000
135 #define CD_OPTION_OFFSET 0xA000
136 #define FILE_OPTION_OFFSET 0x8000
137 #define FILE_OPTION_MASK 0x7FFF
138 #define HANDLE_OPTION_OFFSET 0x7000
139 #define CONSOLE_OPTION_OFFSET 0x6000
140 #define TERMINAL_OPTION_OFFSET 0x5000
141 #define CONFIG_OPTION_OFFSET 0x1200
142 #define KEY_VALUE_OFFSET 0x1100
143 #define FORM_ID_OFFSET 0x1000
146 // VarOffset that will be used to create question
147 // all these values are computed from the structure
150 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
153 // Question Id of Zero is invalid, so add an offset to it
155 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
157 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
158 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
159 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
160 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
161 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
162 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
163 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
164 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
165 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
166 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
167 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
168 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
169 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
170 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
171 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
172 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
173 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
174 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
175 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
176 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
177 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
178 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
179 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
180 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
181 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
182 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
183 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
184 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
185 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
186 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
187 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
188 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
189 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
191 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
192 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
193 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
194 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
195 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
196 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
197 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
198 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
199 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
200 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
201 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
202 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
203 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
204 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
205 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
206 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
207 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
208 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
209 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
210 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
211 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
212 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
213 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
214 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
215 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
216 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
217 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
218 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
219 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
220 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
221 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
222 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
223 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
225 #define STRING_DEPOSITORY_NUMBER 8
228 /// Serial Ports attributes, first one is the value for
229 /// return from callback function, stringtoken is used to
230 /// display the value properly
253 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
254 } BM_TERMINAL_CONTEXT
;
258 BOOLEAN LoadOptionModified
;
263 BOOLEAN ForceReconnect
;
264 UINTN OptionalDataSize
;
266 UINTN LoadOptionSize
;
270 UINT16 FilePathListLength
;
272 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
284 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
285 } BM_CONSOLE_CONTEXT
;
294 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
295 EFI_FILE_HANDLE FHandle
;
297 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
301 BOOLEAN IsRemovableMedia
;
303 BOOLEAN IsBootLegacy
;
308 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
321 UINT16
*DisplayString
;
323 EFI_STRING_ID DisplayStringToken
;
324 EFI_STRING_ID HelpStringToken
;
325 UINTN ContextSelection
;
326 VOID
*VariableContext
;
331 // Shared callback data.
335 BM_MENU_ENTRY
*MenuEntry
;
336 BM_HANDLE_CONTEXT
*HandleContext
;
337 BM_FILE_CONTEXT
*FileContext
;
338 BM_LOAD_CONTEXT
*LoadContext
;
339 BM_TERMINAL_CONTEXT
*TerminalContext
;
340 UINTN CurrentTerminal
;
344 // BMM main formset callback data.
346 EFI_HII_HANDLE BmmHiiHandle
;
347 EFI_HANDLE BmmDriverHandle
;
348 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
349 EFI_FORM_ID BmmCurrentPageId
;
350 EFI_FORM_ID BmmPreviousPageId
;
351 BOOLEAN BmmAskSaveOrNot
;
352 BMM_FAKE_NV_DATA BmmFakeNvData
;
353 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
356 // File explorer formset callback data.
358 EFI_HII_HANDLE FeHiiHandle
;
359 EFI_HANDLE FeDriverHandle
;
360 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
361 FILE_EXPLORER_STATE FeCurrentState
;
362 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
363 FILE_EXPLORER_NV_DATA FeFakeNvData
;
366 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
368 struct _STRING_LIST_NODE
{
369 EFI_STRING_ID StringToken
;
370 STRING_LIST_NODE
*Next
;
373 typedef struct _STRING_DEPOSITORY
{
374 UINTN TotalNodeNumber
;
375 STRING_LIST_NODE
*CurrentNode
;
376 STRING_LIST_NODE
*ListHead
;
382 // For initializing File System menu
386 This function build the FsOptionMenu list which records all
387 available file system in the system. They includes all instances
388 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
389 and all type of legacy boot device.
391 @param CallbackData BMM context data
393 @retval EFI_SUCCESS Success find the file system
394 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
398 BOpt_FindFileSystem (
399 IN BMM_CALLBACK_DATA
*CallbackData
403 Find files under current directory
404 All files and sub-directories in current directory
405 will be stored in DirectoryMenu for future use.
407 @param CallbackData The BMM context data.
408 @param MenuEntry The Menu Entry.
410 @retval EFI_SUCCESS Get files from current dir successfully.
411 @return Other value if can't get files from current dir.
416 IN BMM_CALLBACK_DATA
*CallbackData
,
417 IN BM_MENU_ENTRY
*MenuEntry
422 Find drivers that will be added as Driver#### variables from handles
423 in current system environment
424 All valid handles in the system except those consume SimpleFs, LoadFile
425 are stored in DriverMenu for future use.
427 @retval EFI_SUCCESS The function complets successfully.
428 @return Other value if failed to build the DriverMenu.
438 Build the BootOptionMenu according to BootOrder Variable.
439 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
441 @param CallbackData The BMM context data.
443 @return The number of the Var Boot####.
447 BOpt_GetBootOptions (
448 IN BMM_CALLBACK_DATA
*CallbackData
453 Build up all DriverOptionMenu
455 @param CallbackData The BMM context data.
457 @return EFI_SUCESS The functin completes successfully.
458 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
463 BOpt_GetDriverOptions (
464 IN BMM_CALLBACK_DATA
*CallbackData
468 Free resources allocated in Allocate Rountine.
470 @param FreeMenu Menu to be freed
475 BM_MENU_OPTION
*FreeMenu
481 Append file name to existing file name.
483 @param Str1 The existing file name
484 @param Str2 The file name to be appended
486 @return Allocate a new string to hold the appended result.
487 Caller is responsible to free the returned string.
491 BOpt_AppendFileName (
498 Check whether current FileName point to a valid
501 @param FileName File need to be checked.
503 @retval TRUE Is Efi Image
504 @retval FALSE Not a valid Efi Image
508 BOpt_IsEfiImageName (
514 Check whether current FileName point to a valid Efi Application
516 @param Dir Pointer to current Directory
517 @param FileName Pointer to current File name.
519 @retval TRUE Is a valid Efi Application
520 @retval FALSE not a valid Efi Application
525 IN EFI_FILE_HANDLE Dir
,
531 Get the Option Number that has not been allocated for use.
533 @param Type The type of Option.
535 @return The available Option Number.
539 BOpt_GetOptionNumber (
545 Get the Option Number for Boot#### that does not used.
547 @return The available Option Number.
551 BOpt_GetBootOptionNumber (
557 Get the Option Number for Driver#### that does not used.
559 @return The unused Option Number.
563 BOpt_GetDriverOptionNumber (
568 Create a menu entry give a Menu type.
570 @param MenuType The Menu type to be created.
573 @retval NULL If failed to create the menu.
578 BOpt_CreateMenuEntry (
583 Free up all resource allocated for a BM_MENU_ENTRY.
585 @param MenuEntry A pointer to BM_MENU_ENTRY.
589 BOpt_DestroyMenuEntry (
590 BM_MENU_ENTRY
*MenuEntry
594 Get the Menu Entry from the list in Menu Entry List.
596 If MenuNumber is great or equal to the number of Menu
597 Entry in the list, then ASSERT.
599 @param MenuOption The Menu Entry List to read the menu entry.
600 @param MenuNumber The index of Menu Entry.
602 @return The Menu Entry.
607 BM_MENU_OPTION
*MenuOption
,
612 Get option number according to Boot#### and BootOrder variable.
613 The value is saved as #### + 1.
615 @param CallbackData The BMM context data.
619 IN BMM_CALLBACK_DATA
*CallbackData
623 Get driver option order from globalc DriverOptionMenu.
625 @param CallbackData The BMM context data.
630 IN BMM_CALLBACK_DATA
*CallbackData
634 // Locate all serial io devices for console
637 Build a list containing all serial devices.
639 @retval EFI_SUCCESS The function complete successfully.
640 @retval EFI_UNSUPPORTED No serial ports present.
649 // Initializing Console menu
652 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
654 @retval EFI_SUCCESS The function always complete successfully.
663 // Get current mode information
666 Get mode number according to column and row
668 @param CallbackData The BMM context data.
672 IN BMM_CALLBACK_DATA
*CallbackData
676 // Cleaning up console menu
679 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
681 @retval EFI_SUCCESS The function always complete successfully.
689 Update the device path that describing a terminal device
690 based on the new BaudRate, Data Bits, parity and Stop Bits
693 @param DevicePath The devicepath protocol instance wanted to be updated.
697 ChangeVariableDevicePath (
698 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
702 Update the multi-instance device path of Terminal Device based on
703 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
704 device path in the Terminal Device in TerminalMenu is also updated.
706 @param DevicePath The multi-instance device path.
707 @param ChangeTerminal TRUE, then device path in the Terminal Device
708 in TerminalMenu is also updated; FALSE, no update.
710 @return EFI_SUCCESS The function completes successfully.
714 ChangeTerminalDevicePath (
715 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
716 IN BOOLEAN ChangeTerminal
720 // Variable operation by menu selection
723 This function create a currently loaded Boot Option from
724 the BMM. It then appends this Boot Option to the end of
725 the "BootOrder" list. It also append this Boot Opotion to the end
728 @param CallbackData The BMM context data.
729 @param NvRamMap The file explorer formset internal state.
731 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
732 @retval EFI_SUCCESS If function completes successfully.
736 Var_UpdateBootOption (
737 IN BMM_CALLBACK_DATA
*CallbackData
,
738 IN FILE_EXPLORER_NV_DATA
*NvRamMap
742 Delete Boot Option that represent a Deleted state in BootOptionMenu.
743 After deleting this boot option, call Var_ChangeBootOrder to
744 make sure BootOrder is in valid state.
746 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
747 BM_LOAD_CONTEXT marked for deletion is deleted
748 @return Others If failed to update the "BootOrder" variable after deletion.
757 After any operation on Boot####, there will be a discrepancy in BootOrder.
758 Since some are missing but in BootOrder, while some are present but are
759 not reflected by BootOrder. Then a function rebuild BootOrder from
760 scratch by content from BootOptionMenu is needed.
762 @retval EFI_SUCCESS The boot order is updated successfully.
763 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
767 Var_ChangeBootOrder (
772 This function create a currently loaded Drive Option from
773 the BMM. It then appends this Driver Option to the end of
774 the "DriverOrder" list. It append this Driver Opotion to the end
777 @param CallbackData The BMM context data.
778 @param HiiHandle The HII handle associated with the BMM formset.
779 @param DescriptionData The description of this driver option.
780 @param OptionalData The optional load option.
781 @param ForceReconnect If to force reconnect.
783 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
784 @retval EFI_SUCCESS If function completes successfully.
788 Var_UpdateDriverOption (
789 IN BMM_CALLBACK_DATA
*CallbackData
,
790 IN EFI_HII_HANDLE HiiHandle
,
791 IN UINT16
*DescriptionData
,
792 IN UINT16
*OptionalData
,
793 IN UINT8 ForceReconnect
797 Delete Load Option that represent a Deleted state in BootOptionMenu.
798 After deleting this Driver option, call Var_ChangeDriverOrder to
799 make sure DriverOrder is in valid state.
801 @retval EFI_SUCCESS Load Option is successfully updated.
802 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
807 Var_DelDriverOption (
812 After any operation on Driver####, there will be a discrepancy in
813 DriverOrder. Since some are missing but in DriverOrder, while some
814 are present but are not reflected by DriverOrder. Then a function
815 rebuild DriverOrder from scratch by content from DriverOptionMenu is
818 @retval EFI_SUCCESS The driver order is updated successfully.
819 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
823 Var_ChangeDriverOrder (
828 This function delete and build multi-instance device path ConIn
831 @retval EFI_SUCCESS The function complete successfully.
832 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
835 Var_UpdateConsoleInpOption (
840 This function delete and build multi-instance device path ConOut console device.
842 @retval EFI_SUCCESS The function complete successfully.
843 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
846 Var_UpdateConsoleOutOption (
851 This function delete and build multi-instance device path ErrOut console device.
853 @retval EFI_SUCCESS The function complete successfully.
854 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
857 Var_UpdateErrorOutOption (
862 This function delete and build Out of Band console device.
864 @param MenuIndex Menu index which user select in the terminal menu list.
866 @retval EFI_SUCCESS The function complete successfully.
867 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
870 Var_UpdateOutOfBandOption (
875 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
876 parity and stop Bits set.
880 Var_UpdateAllConsoleOption (
885 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
886 this EFI Variable is deleted.
887 It also update the BMM context data specified the "BootNext" value.
889 @param CallbackData The BMM context data.
891 @retval EFI_SUCCESS The function complete successfully.
892 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
897 IN BMM_CALLBACK_DATA
*CallbackData
901 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
902 BootOptionMenu with the new "BootOrder" list.
904 @param CallbackData The BMM context data.
906 @retval EFI_SUCCESS The function complete successfully.
907 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
908 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
912 Var_UpdateBootOrder (
913 IN BMM_CALLBACK_DATA
*CallbackData
917 This function update the "DriverOrder" EFI Variable based on
918 BMM Formset's NV map. It then refresh DriverOptionMenu
919 with the new "DriverOrder" list.
921 @param CallbackData The BMM context data.
923 @retval EFI_SUCCESS The function complete successfully.
924 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
925 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
929 Var_UpdateDriverOrder (
930 IN BMM_CALLBACK_DATA
*CallbackData
934 Update the Text Mode of Console.
936 @param CallbackData The context data for BMM.
938 @retval EFI_SUCCSS If the Text Mode of Console is updated.
939 @return Other value if the Text Mode of Console is not updated.
944 IN BMM_CALLBACK_DATA
*CallbackData
948 // Following are page create and refresh functions
951 Refresh the global UpdateData structure.
960 Clean up the dynamic opcode at label and form specified by
963 @param LabelId It is both the Form ID and Label ID for
965 @param CallbackData The BMM context data.
971 IN BMM_CALLBACK_DATA
*CallbackData
975 Create a lit of boot option from global BootOptionMenu. It
976 allow user to delete the boot option.
978 @param CallbackData The BMM context data.
983 IN BMM_CALLBACK_DATA
*CallbackData
987 Create a lit of driver option from global DriverMenu.
989 @param CallbackData The BMM context data.
992 UpdateDrvAddHandlePage (
993 IN BMM_CALLBACK_DATA
*CallbackData
997 Create a lit of driver option from global DriverOptionMenu. It
998 allow user to delete the driver option.
1000 @param CallbackData The BMM context data.
1004 IN BMM_CALLBACK_DATA
*CallbackData
1008 Prepare the page to allow user to add description for a Driver Option.
1010 @param CallbackData The BMM context data.
1013 UpdateDriverAddHandleDescPage (
1014 IN BMM_CALLBACK_DATA
*CallbackData
1018 Dispatch the correct update page function to call based on the UpdatePageId.
1020 @param UpdatePageId The form ID.
1021 @param CallbackData The BMM context data.
1025 IN UINT16 UpdatePageId
,
1026 IN BMM_CALLBACK_DATA
*CallbackData
1030 Create the dynamic page to allow user to set the "BootNext" vaule.
1032 @param CallbackData The BMM context data.
1035 UpdateBootNextPage (
1036 IN BMM_CALLBACK_DATA
*CallbackData
1040 Create the dynamic page to allow user to set the "TimeOut" vaule.
1042 @param CallbackData The BMM context data.
1046 IN BMM_CALLBACK_DATA
*CallbackData
1050 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1051 Parity, Stop Bits, Terminal Type.
1053 @param CallbackData The BMM context data.
1056 UpdateTerminalPage (
1057 IN BMM_CALLBACK_DATA
*CallbackData
1061 Refresh the text mode page
1063 @param CallbackData The BMM context data.
1067 IN BMM_CALLBACK_DATA
*CallbackData
1071 Create a list of Goto Opcode for all terminal devices logged
1072 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1074 @param CallbackData The BMM context data.
1078 IN BMM_CALLBACK_DATA
*CallbackData
1082 Function opens and returns a file handle to the root directory of a volume.
1084 @param DeviceHandle A handle for a device
1085 @return A valid file handle or NULL is returned
1089 IN EFI_HANDLE DeviceHandle
1093 Function gets the file system information from an open file descriptor,
1094 and stores it in a buffer allocated from pool.
1096 @param FHand The file handle.
1098 @return A pointer to a buffer with file information.
1099 NULL is returned if failed to get Vaolume Label Info.
1101 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1102 EfiLibFileSystemVolumeLabelInfo (
1103 IN EFI_FILE_HANDLE FHand
1108 Function gets the file information from an open file descriptor, and stores it
1109 in a buffer allocated from pool.
1111 @param FHand File Handle.
1113 @return A pointer to a buffer with file information or NULL is returned
1118 IN EFI_FILE_HANDLE FHand
1122 Find the first instance of this Protocol in the system and return it's interface.
1124 @param ProtocolGuid Provides the protocol to search for
1125 @param Interface On return, a pointer to the first interface
1126 that matches ProtocolGuid
1128 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1129 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1133 EfiLibLocateProtocol (
1134 IN EFI_GUID
*ProtocolGuid
,
1135 OUT VOID
**Interface
1139 Adjusts the size of a previously allocated buffer.
1141 @param OldPool A pointer to the buffer whose size is being adjusted.
1142 @param OldSize The size of the current buffer.
1143 @param NewSize The size of the new buffer.
1145 @return The newly allocated buffer. if NULL, allocation failed.
1156 Function deletes the variable specified by VarName and VarGuid.
1159 @param VarName A Null-terminated Unicode string that is
1160 the name of the vendor's variable.
1162 @param VarGuid A unique identifier for the vendor.
1164 @retval EFI_SUCCESS The variable was found and removed
1165 @retval EFI_UNSUPPORTED The variable store was inaccessible
1166 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1167 @retval EFI_NOT_FOUND The variable was not found
1171 EfiLibDeleteVariable (
1173 IN EFI_GUID
*VarGuid
1179 @param Src The source.
1181 @return A new string which is duplicated copy of the source.
1182 @retval NULL If there is not enough memory.
1191 Function is used to determine the number of device path instances
1192 that exist in a device path.
1195 @param DevicePath A pointer to a device path data structure.
1197 @return This function counts and returns the number of device path instances
1202 EfiDevicePathInstanceCount (
1203 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1207 Create string tokens for a menu from its help strings and display strings
1210 @param CallbackData The BMM context data.
1211 @param HiiHandle Hii Handle of the package to be updated.
1212 @param MenuOption The Menu whose string tokens need to be created
1214 @retval EFI_SUCCESS string tokens created successfully
1215 @retval others contain some errors
1219 CreateMenuStringToken (
1220 IN BMM_CALLBACK_DATA
*CallbackData
,
1221 IN EFI_HII_HANDLE HiiHandle
,
1222 IN BM_MENU_OPTION
*MenuOption
1226 Get a string from the Data Hub record based on
1229 @param DevPath The device Path.
1231 @return A string located from the Data Hub records based on
1233 @retval NULL If failed to get the String from Data Hub.
1237 EfiLibStrFromDatahub (
1238 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1242 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1243 specified by DeviceType.
1245 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1247 @param OptionIndex Returns the index number (#### in Boot####).
1248 @param OptionSize Return the size of the Boot### variable.
1252 GetLegacyBootOptionVar (
1253 IN UINTN DeviceType
,
1254 OUT UINTN
*OptionIndex
,
1255 OUT UINTN
*OptionSize
1259 Initialize the Boot Maintenance Utitliy.
1269 Intialize all the string depositories.
1273 InitializeStringDepository (
1278 Fetch a usable string node from the string depository and return the string token.
1281 @param CallbackData The BMM context data.
1282 @param StringDepository Pointer of the string depository.
1284 @retval EFI_STRING_ID String token.
1288 GetStringTokenFromDepository (
1289 IN BMM_CALLBACK_DATA
*CallbackData
,
1290 IN STRING_DEPOSITORY
*StringDepository
1294 Reclaim string depositories by moving the current node pointer to list head..
1297 ReclaimStringDepository (
1302 Release resource for all the string depositories.
1306 CleanUpStringDepository (
1311 Function handling request to apply changes for BMM pages.
1313 @param Private Pointer to callback data buffer.
1314 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1315 @param FormId ID of the form which has sent the request to apply change.
1317 @retval EFI_SUCCESS Change successfully applied.
1318 @retval Other Error occurs while trying to apply changes.
1322 ApplyChangeHandler (
1323 IN BMM_CALLBACK_DATA
*Private
,
1324 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1325 IN EFI_FORM_ID FormId
1329 Discard all changes done to the BMM pages such as Boot Order change,
1330 Driver order change.
1332 @param Private The BMM context data.
1333 @param CurrentFakeNVMap The current Fack NV Map.
1337 DiscardChangeHandler (
1338 IN BMM_CALLBACK_DATA
*Private
,
1339 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1343 Dispatch the display to the next page based on NewPageId.
1345 @param Private The BMM context data.
1346 @param NewPageId The original page ID.
1351 BMM_CALLBACK_DATA
*Private
,
1356 Boot a file selected by user at File Expoloer of BMM.
1358 @param FileContext The file context data, which contains the device path
1359 of the file to be boot from.
1361 @retval EFI_SUCCESS The function completed successfull.
1362 @return Other value if the boot from the file fails.
1367 IN BM_FILE_CONTEXT
*FileContext
1371 Update the file explower page with the refershed file system.
1374 @param CallbackData BMM context data
1375 @param KeyValue Key value to identify the type of data to expect.
1377 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1378 @retval FALSE Indicate that there is no need to exit file explorer.
1382 UpdateFileExplorer (
1383 IN BMM_CALLBACK_DATA
*CallbackData
,
1388 This function processes the results of changes in configuration.
1389 When user select a interactive opcode, this callback will be triggered.
1390 Based on the Question(QuestionId) that triggers the callback, the corresponding
1391 actions is performed. It handles:
1393 1) the addition of boot option.
1394 2) the addition of driver option.
1395 3) exit from file browser
1396 4) update of file content if a dir is selected.
1397 5) boot the file if a file is selected in "boot from file"
1400 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1401 @param Action Specifies the type of action taken by the browser.
1402 @param QuestionId A unique value which is sent to the original exporting driver
1403 so that it can identify the type of data to expect.
1404 @param Type The type of value for the question.
1405 @param Value A pointer to the data being sent to the original exporting driver.
1406 @param ActionRequest On return, points to the action requested by the callback function.
1408 @retval EFI_SUCCESS The callback successfully handled the action.
1409 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1410 @retval EFI_DEVICE_ERROR The variable could not be saved.
1411 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1416 FileExplorerCallback (
1417 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1418 IN EFI_BROWSER_ACTION Action
,
1419 IN EFI_QUESTION_ID QuestionId
,
1421 IN EFI_IFR_TYPE_VALUE
*Value
,
1422 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1426 Remove the installed BootMaint and FileExplorer HiiPackages.
1435 Install BootMaint and FileExplorer HiiPackages.
1439 InitBootMaintenance(
1444 // Global variable in this program (defined in data.c)
1446 extern BM_MENU_OPTION BootOptionMenu
;
1447 extern BM_MENU_OPTION DriverOptionMenu
;
1448 extern BM_MENU_OPTION FsOptionMenu
;
1449 extern BM_MENU_OPTION ConsoleInpMenu
;
1450 extern BM_MENU_OPTION ConsoleOutMenu
;
1451 extern BM_MENU_OPTION ConsoleErrMenu
;
1452 extern BM_MENU_OPTION DirectoryMenu
;
1453 extern BM_MENU_OPTION DriverMenu
;
1454 extern BM_MENU_OPTION TerminalMenu
;
1455 extern UINT16 TerminalType
[];
1456 extern COM_ATTR BaudRateList
[19];
1457 extern COM_ATTR DataBitsList
[4];
1458 extern COM_ATTR ParityList
[5];
1459 extern COM_ATTR StopBitsList
[3];
1460 extern EFI_GUID TerminalTypeGuid
[4];
1461 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1462 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1463 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1464 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1465 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1466 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1467 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1468 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1471 // Shared IFR form update data
1473 extern VOID
*mStartOpCodeHandle
;
1474 extern VOID
*mEndOpCodeHandle
;
1475 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1476 extern EFI_IFR_GUID_LABEL
*mEndLabel
;