2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2016, 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 <Guid/TtyTerm.h>
21 #include <Guid/MdeModuleHii.h>
22 #include <Guid/FileSystemVolumeLabelInfo.h>
23 #include <Guid/GlobalVariable.h>
24 #include <Guid/HiiBootMaintenanceFormset.h>
26 #include <Protocol/LoadFile.h>
27 #include <Protocol/HiiConfigAccess.h>
28 #include <Protocol/SimpleFileSystem.h>
29 #include <Protocol/SerialIo.h>
30 #include <Protocol/DevicePathToText.h>
32 #include <Library/PrintLib.h>
33 #include <Library/DebugLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/UefiRuntimeServicesTableLib.h>
39 #include <Library/DevicePathLib.h>
40 #include <Library/HiiLib.h>
41 #include <Library/UefiHiiServicesLib.h>
42 #include <Library/UefiBootManagerLib.h>
43 #include <Library/FileExplorerLib.h>
48 /// HII specific Vendor Device Path definition.
51 VENDOR_DEVICE_PATH VendorDevicePath
;
52 EFI_DEVICE_PATH_PROTOCOL End
;
53 } HII_VENDOR_DEVICE_PATH
;
57 // Constants which are variable names used to access variables
60 #define VAR_CON_OUT_MODE L"ConOutMode"
63 // Variable created with this flag will be "Efi:...."
65 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
67 extern EFI_GUID mBootMaintGuid
;
68 extern CHAR16 mBootMaintStorageName
[];
70 // These are the VFR compiler generated data representing our VFR data.
72 extern UINT8 BootMaintenanceManagerBin
[];
75 // Below are the number of options in Baudrate, Databits,
76 // Parity and Stopbits selection for serial ports.
78 #define BM_COM_ATTR_BUADRATE 19
79 #define BM_COM_ATTR_DATABITS 4
80 #define BM_COM_ATTR_PARITY 5
81 #define BM_COM_ATTR_STOPBITS 3
84 // Callback function helper
86 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
87 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
90 // Enumeration type definition
92 typedef UINT8 BBS_TYPE
;
94 typedef enum _TYPE_OF_TERMINAL
{
95 TerminalTypePcAnsi
= 0,
97 TerminalTypeVt100Plus
,
103 // All of the signatures that will be used in list structure
105 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
106 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
107 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
108 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
109 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
110 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
111 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
113 #define BM_LOAD_CONTEXT_SELECT 0x0
114 #define BM_CONSOLE_CONTEXT_SELECT 0x1
115 #define BM_FILE_CONTEXT_SELECT 0x2
116 #define BM_HANDLE_CONTEXT_SELECT 0x3
117 #define BM_TERMINAL_CONTEXT_SELECT 0x5
119 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
120 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
121 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
124 // Buffer size for update data
126 #define UPDATE_DATA_SIZE 0x100000
129 // Namespace of callback keys used in display and file system navigation
131 #define MAX_BBS_OFFSET 0xE000
132 #define NET_OPTION_OFFSET 0xD800
133 #define BEV_OPTION_OFFSET 0xD000
134 #define FD_OPTION_OFFSET 0xC000
135 #define HD_OPTION_OFFSET 0xB000
136 #define CD_OPTION_OFFSET 0xA000
137 #define FILE_OPTION_OFFSET 0x8000
138 #define FILE_OPTION_MASK 0x7FFF
139 #define HANDLE_OPTION_OFFSET 0x7000
140 #define CONSOLE_OPTION_OFFSET 0x6000
141 #define TERMINAL_OPTION_OFFSET 0x5000
142 #define CONFIG_OPTION_OFFSET 0x1200
143 #define KEY_VALUE_OFFSET 0x1100
144 #define FORM_ID_OFFSET 0x1000
147 // VarOffset that will be used to create question
148 // all these values are computed from the structure
151 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
154 // Question Id of Zero is invalid, so add an offset to it
156 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
158 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
159 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
160 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
161 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
162 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
163 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
164 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
165 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
166 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
167 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
168 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
169 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
170 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
171 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
172 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
173 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
174 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
175 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
176 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
177 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
178 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
179 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
180 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
181 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
182 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
183 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
184 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
185 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
186 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
187 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
188 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
189 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
190 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
191 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
192 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
193 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
194 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
196 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
197 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
198 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
199 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
200 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
201 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
202 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
203 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
204 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
205 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
206 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
207 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
208 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
209 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
210 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
211 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
212 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
213 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
214 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
215 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
216 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
217 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
218 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
219 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
220 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
221 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
222 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
223 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
224 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
225 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
226 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
227 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
228 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
229 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
230 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
231 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
232 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
234 #define STRING_DEPOSITORY_NUMBER 8
236 #define NONE_BOOTNEXT_VALUE (0xFFFF + 1)
239 /// Serial Ports attributes, first one is the value for
240 /// return from callback function, stringtoken is used to
241 /// display the value properly
266 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
267 } BM_TERMINAL_CONTEXT
;
276 UINT16 FilePathListLength
;
278 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
288 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
289 } BM_CONSOLE_CONTEXT
;
298 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
299 EFI_FILE_HANDLE FHandle
;
301 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
305 BOOLEAN IsRemovableMedia
;
307 BOOLEAN IsBootLegacy
;
312 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
325 UINT16
*DisplayString
;
327 EFI_STRING_ID DisplayStringToken
;
328 EFI_STRING_ID HelpStringToken
;
329 UINTN ContextSelection
;
330 VOID
*VariableContext
;
337 EFI_HII_HANDLE BmmHiiHandle
;
338 EFI_HANDLE BmmDriverHandle
;
340 /// Boot Maintenance Manager Produced protocols
342 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
343 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
345 BM_MENU_ENTRY
*MenuEntry
;
346 BM_HANDLE_CONTEXT
*HandleContext
;
347 BM_FILE_CONTEXT
*FileContext
;
348 BM_LOAD_CONTEXT
*LoadContext
;
349 BM_TERMINAL_CONTEXT
*TerminalContext
;
350 UINTN CurrentTerminal
;
354 // BMM main formset callback data.
357 EFI_FORM_ID BmmCurrentPageId
;
358 EFI_FORM_ID BmmPreviousPageId
;
359 BOOLEAN BmmAskSaveOrNot
;
360 BMM_FAKE_NV_DATA BmmFakeNvData
;
361 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
367 Find drivers that will be added as Driver#### variables from handles
368 in current system environment
369 All valid handles in the system except those consume SimpleFs, LoadFile
370 are stored in DriverMenu for future use.
372 @retval EFI_SUCCESS The function complets successfully.
373 @return Other value if failed to build the DriverMenu.
383 Build the BootOptionMenu according to BootOrder Variable.
384 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
386 @param CallbackData The BMM context data.
388 @return The number of the Var Boot####.
392 BOpt_GetBootOptions (
393 IN BMM_CALLBACK_DATA
*CallbackData
398 Build up all DriverOptionMenu
400 @param CallbackData The BMM context data.
402 @return EFI_SUCESS The functin completes successfully.
403 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
408 BOpt_GetDriverOptions (
409 IN BMM_CALLBACK_DATA
*CallbackData
413 Free resources allocated in Allocate Rountine.
415 @param FreeMenu Menu to be freed
420 BM_MENU_OPTION
*FreeMenu
425 Get the Option Number that has not been allocated for use.
427 @param Type The type of Option.
429 @return The available Option Number.
433 BOpt_GetOptionNumber (
439 Get the Option Number for Boot#### that does not used.
441 @return The available Option Number.
445 BOpt_GetBootOptionNumber (
451 Get the Option Number for Driver#### that does not used.
453 @return The unused Option Number.
457 BOpt_GetDriverOptionNumber (
462 Create a menu entry give a Menu type.
464 @param MenuType The Menu type to be created.
467 @retval NULL If failed to create the menu.
472 BOpt_CreateMenuEntry (
477 Free up all resource allocated for a BM_MENU_ENTRY.
479 @param MenuEntry A pointer to BM_MENU_ENTRY.
483 BOpt_DestroyMenuEntry (
484 BM_MENU_ENTRY
*MenuEntry
488 Get the Menu Entry from the list in Menu Entry List.
490 If MenuNumber is great or equal to the number of Menu
491 Entry in the list, then ASSERT.
493 @param MenuOption The Menu Entry List to read the menu entry.
494 @param MenuNumber The index of Menu Entry.
496 @return The Menu Entry.
501 BM_MENU_OPTION
*MenuOption
,
506 Get option number according to Boot#### and BootOrder variable.
507 The value is saved as #### + 1.
509 @param CallbackData The BMM context data.
513 IN BMM_CALLBACK_DATA
*CallbackData
517 Get driver option order from globalc DriverOptionMenu.
519 @param CallbackData The BMM context data.
524 IN BMM_CALLBACK_DATA
*CallbackData
528 // Locate all serial io devices for console
531 Build a list containing all serial devices.
533 @retval EFI_SUCCESS The function complete successfully.
534 @retval EFI_UNSUPPORTED No serial ports present.
543 // Initializing Console menu
546 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
548 @retval EFI_SUCCESS The function always complete successfully.
557 // Get current mode information
560 Get mode number according to column and row
562 @param CallbackData The BMM context data.
566 IN BMM_CALLBACK_DATA
*CallbackData
570 // Cleaning up console menu
573 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
575 @retval EFI_SUCCESS The function always complete successfully.
583 Update the device path that describing a terminal device
584 based on the new BaudRate, Data Bits, parity and Stop Bits
587 @param DevicePath The devicepath protocol instance wanted to be updated.
591 ChangeVariableDevicePath (
592 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
596 Update the multi-instance device path of Terminal Device based on
597 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
598 device path in the Terminal Device in TerminalMenu is also updated.
600 @param DevicePath The multi-instance device path.
601 @param ChangeTerminal TRUE, then device path in the Terminal Device
602 in TerminalMenu is also updated; FALSE, no update.
604 @return EFI_SUCCESS The function completes successfully.
608 ChangeTerminalDevicePath (
609 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
610 IN BOOLEAN ChangeTerminal
614 // Variable operation by menu selection
617 This function create a currently loaded Boot Option from
618 the BMM. It then appends this Boot Option to the end of
619 the "BootOrder" list. It also append this Boot Opotion to the end
622 @param CallbackData The BMM context data.
624 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
625 @retval EFI_SUCCESS If function completes successfully.
629 Var_UpdateBootOption (
630 IN BMM_CALLBACK_DATA
*CallbackData
634 Delete Boot Option that represent a Deleted state in BootOptionMenu.
635 After deleting this boot option, call Var_ChangeBootOrder to
636 make sure BootOrder is in valid state.
638 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
639 BM_LOAD_CONTEXT marked for deletion is deleted
640 @return Others If failed to update the "BootOrder" variable after deletion.
649 After any operation on Boot####, there will be a discrepancy in BootOrder.
650 Since some are missing but in BootOrder, while some are present but are
651 not reflected by BootOrder. Then a function rebuild BootOrder from
652 scratch by content from BootOptionMenu is needed.
654 @retval EFI_SUCCESS The boot order is updated successfully.
655 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
659 Var_ChangeBootOrder (
664 This function create a currently loaded Drive Option from
665 the BMM. It then appends this Driver Option to the end of
666 the "DriverOrder" list. It append this Driver Opotion to the end
669 @param CallbackData The BMM context data.
670 @param HiiHandle The HII handle associated with the BMM formset.
671 @param DescriptionData The description of this driver option.
672 @param OptionalData The optional load option.
673 @param ForceReconnect If to force reconnect.
675 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
676 @retval EFI_SUCCESS If function completes successfully.
680 Var_UpdateDriverOption (
681 IN BMM_CALLBACK_DATA
*CallbackData
,
682 IN EFI_HII_HANDLE HiiHandle
,
683 IN UINT16
*DescriptionData
,
684 IN UINT16
*OptionalData
,
685 IN UINT8 ForceReconnect
689 Delete Load Option that represent a Deleted state in BootOptionMenu.
690 After deleting this Driver option, call Var_ChangeDriverOrder to
691 make sure DriverOrder is in valid state.
693 @retval EFI_SUCCESS Load Option is successfully updated.
694 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
699 Var_DelDriverOption (
704 After any operation on Driver####, there will be a discrepancy in
705 DriverOrder. Since some are missing but in DriverOrder, while some
706 are present but are not reflected by DriverOrder. Then a function
707 rebuild DriverOrder from scratch by content from DriverOptionMenu is
710 @retval EFI_SUCCESS The driver order is updated successfully.
711 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
715 Var_ChangeDriverOrder (
720 This function delete and build multi-instance device path ConIn
723 @retval EFI_SUCCESS The function complete successfully.
724 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
727 Var_UpdateConsoleInpOption (
732 This function delete and build multi-instance device path ConOut console device.
734 @retval EFI_SUCCESS The function complete successfully.
735 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
738 Var_UpdateConsoleOutOption (
743 This function delete and build multi-instance device path ErrOut console device.
745 @retval EFI_SUCCESS The function complete successfully.
746 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
749 Var_UpdateErrorOutOption (
754 This function delete and build Out of Band console device.
756 @param MenuIndex Menu index which user select in the terminal menu list.
758 @retval EFI_SUCCESS The function complete successfully.
759 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
762 Var_UpdateOutOfBandOption (
767 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
768 this EFI Variable is deleted.
769 It also update the BMM context data specified the "BootNext" value.
771 @param CallbackData The BMM context data.
773 @retval EFI_SUCCESS The function complete successfully.
774 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
779 IN BMM_CALLBACK_DATA
*CallbackData
783 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
784 BootOptionMenu with the new "BootOrder" list.
786 @param CallbackData The BMM context data.
788 @retval EFI_SUCCESS The function complete successfully.
789 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
790 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
794 Var_UpdateBootOrder (
795 IN BMM_CALLBACK_DATA
*CallbackData
799 This function update the "DriverOrder" EFI Variable based on
800 BMM Formset's NV map. It then refresh DriverOptionMenu
801 with the new "DriverOrder" list.
803 @param CallbackData The BMM context data.
805 @retval EFI_SUCCESS The function complete successfully.
806 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
807 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
811 Var_UpdateDriverOrder (
812 IN BMM_CALLBACK_DATA
*CallbackData
816 Update the Text Mode of Console.
818 @param CallbackData The context data for BMM.
820 @retval EFI_SUCCSS If the Text Mode of Console is updated.
821 @return Other value if the Text Mode of Console is not updated.
826 IN BMM_CALLBACK_DATA
*CallbackData
830 // Following are page create and refresh functions
833 Create the global UpdateData structure.
842 Refresh the global UpdateData structure.
851 Clean up the dynamic opcode at label and form specified by
854 @param LabelId It is both the Form ID and Label ID for
856 @param CallbackData The BMM context data.
862 IN BMM_CALLBACK_DATA
*CallbackData
866 Create a lit of boot option from global BootOptionMenu. It
867 allow user to delete the boot option.
869 @param CallbackData The BMM context data.
874 IN BMM_CALLBACK_DATA
*CallbackData
878 Create a lit of driver option from global DriverMenu.
880 @param CallbackData The BMM context data.
883 UpdateDrvAddHandlePage (
884 IN BMM_CALLBACK_DATA
*CallbackData
888 Create a lit of driver option from global DriverOptionMenu. It
889 allow user to delete the driver option.
891 @param CallbackData The BMM context data.
895 IN BMM_CALLBACK_DATA
*CallbackData
899 Prepare the page to allow user to add description for a Driver Option.
901 @param CallbackData The BMM context data.
904 UpdateDriverAddHandleDescPage (
905 IN BMM_CALLBACK_DATA
*CallbackData
909 Dispatch the correct update page function to call based on the UpdatePageId.
911 @param UpdatePageId The form ID.
912 @param CallbackData The BMM context data.
916 IN UINT16 UpdatePageId
,
917 IN BMM_CALLBACK_DATA
*CallbackData
921 Create the dynamic page to allow user to set the "BootNext" vaule.
923 @param CallbackData The BMM context data.
927 IN BMM_CALLBACK_DATA
*CallbackData
931 Create the dynamic page to allow user to set the "TimeOut" vaule.
933 @param CallbackData The BMM context data.
937 IN BMM_CALLBACK_DATA
*CallbackData
941 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
942 Parity, Stop Bits, Terminal Type.
944 @param CallbackData The BMM context data.
948 IN BMM_CALLBACK_DATA
*CallbackData
952 Refresh the text mode page
954 @param CallbackData The BMM context data.
958 IN BMM_CALLBACK_DATA
*CallbackData
962 Create a list of Goto Opcode for all terminal devices logged
963 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
965 @param CallbackData The BMM context data.
969 IN BMM_CALLBACK_DATA
*CallbackData
973 Update add boot/driver option page.
975 @param CallbackData The BMM context data.
976 @param FormId The form ID to be updated.
977 @param DevicePath Device path.
982 IN BMM_CALLBACK_DATA
*CallbackData
,
983 IN EFI_FORM_ID FormId
,
984 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
988 Function deletes the variable specified by VarName and VarGuid.
991 @param VarName A Null-terminated Unicode string that is
992 the name of the vendor's variable.
994 @param VarGuid A unique identifier for the vendor.
996 @retval EFI_SUCCESS The variable was found and removed
997 @retval EFI_UNSUPPORTED The variable store was inaccessible
998 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
999 @retval EFI_NOT_FOUND The variable was not found
1003 EfiLibDeleteVariable (
1005 IN EFI_GUID
*VarGuid
1009 Function is used to determine the number of device path instances
1010 that exist in a device path.
1013 @param DevicePath A pointer to a device path data structure.
1015 @return This function counts and returns the number of device path instances
1020 EfiDevicePathInstanceCount (
1021 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1025 Get a string from the Data Hub record based on
1028 @param DevPath The device Path.
1030 @return A string located from the Data Hub records based on
1032 @retval NULL If failed to get the String from Data Hub.
1036 EfiLibStrFromDatahub (
1037 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1041 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1042 specified by DeviceType.
1044 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1046 @param OptionIndex Returns the index number (#### in Boot####).
1047 @param OptionSize Return the size of the Boot### variable.
1051 GetLegacyBootOptionVar (
1052 IN UINTN DeviceType
,
1053 OUT UINTN
*OptionIndex
,
1054 OUT UINTN
*OptionSize
1058 Discard all changes done to the BMM pages such as Boot Order change,
1059 Driver order change.
1061 @param Private The BMM context data.
1062 @param CurrentFakeNVMap The current Fack NV Map.
1066 DiscardChangeHandler (
1067 IN BMM_CALLBACK_DATA
*Private
,
1068 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1072 Dispatch the display to the next page based on NewPageId.
1074 @param Private The BMM context data.
1075 @param NewPageId The original page ID.
1080 BMM_CALLBACK_DATA
*Private
,
1085 Remove the installed BootMaint and FileExplorer HiiPackages.
1094 Install BootMaint and FileExplorer HiiPackages.
1098 InitBootMaintenance(
1104 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1105 in BMM_FAKE_NV_DATA structure.
1107 @param CallbackData The BMM context data.
1112 IN BMM_CALLBACK_DATA
*CallbackData
1117 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1118 in BMM_FAKE_NV_DATA structure.
1120 @param CallbackData The BMM context data.
1124 GetConsoleOutCheck (
1125 IN BMM_CALLBACK_DATA
*CallbackData
1130 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1131 in BMM_FAKE_NV_DATA structure.
1133 @param CallbackData The BMM context data.
1137 GetConsoleErrCheck (
1138 IN BMM_CALLBACK_DATA
*CallbackData
1143 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1144 to BMM_FAKE_NV_DATA structure.
1146 @param CallbackData The BMM context data.
1150 GetTerminalAttribute (
1151 IN BMM_CALLBACK_DATA
*CallbackData
1155 This function will change video resolution and text mode
1156 according to defined setup mode or defined boot mode
1158 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.
1160 @retval EFI_SUCCESS Mode is changed successfully.
1161 @retval Others Mode failed to be changed.
1166 BmmBdsSetConsoleMode (
1172 This function converts an input device structure to a Unicode string.
1174 @param DevPath A pointer to the device path structure.
1176 @return A new allocated Unicode string that represents the device path.
1181 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1185 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
1186 The caller is responsible for freeing the allocated buffer using FreePool().
1188 @param DevicePath Device path.
1190 @return A new allocated string that represents the file name.
1194 ExtractFileNameFromDevicePath (
1195 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1199 This function allows a caller to extract the current configuration for one
1200 or more named elements from the target driver.
1202 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1203 @param Request A null-terminated Unicode string in <ConfigRequest> format.
1204 @param Progress On return, points to a character in the Request string.
1205 Points to the string's null terminator if request was successful.
1206 Points to the most recent '&' before the first failing name/value
1207 pair (or the beginning of the string if the failure is in the
1208 first name/value pair) if the request was not successful.
1209 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
1210 has all values filled in for the names in the Request string.
1211 String to be allocated by the called function.
1213 @retval EFI_SUCCESS The Results is filled with the requested values.
1214 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
1215 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
1216 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
1221 BootMaintExtractConfig (
1222 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1223 IN CONST EFI_STRING Request
,
1224 OUT EFI_STRING
*Progress
,
1225 OUT EFI_STRING
*Results
1229 This function applies changes in a driver's configuration.
1230 Input is a Configuration, which has the routing data for this
1231 driver followed by name / value configuration pairs. The driver
1232 must apply those pairs to its configurable storage. If the
1233 driver's configuration is stored in a linear block of data
1234 and the driver's name / value pairs are in <BlockConfig>
1235 format, it may use the ConfigToBlock helper function (above) to
1236 simplify the job. Currently not implemented.
1238 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1239 @param[in] Configuration A null-terminated Unicode string in
1240 <ConfigString> format.
1241 @param[out] Progress A pointer to a string filled in with the
1242 offset of the most recent '&' before the
1243 first failing name / value pair (or the
1244 beginn ing of the string if the failure
1245 is in the first name / value pair) or
1246 the terminating NULL if all was
1249 @retval EFI_SUCCESS The results have been distributed or are
1250 awaiting distribution.
1251 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1252 parts of the results that must be
1253 stored awaiting possible future
1255 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1256 Results parameter would result
1257 in this type of error.
1258 @retval EFI_NOT_FOUND Target for the specified routing data
1263 BootMaintRouteConfig (
1264 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1265 IN CONST EFI_STRING Configuration
,
1266 OUT EFI_STRING
*Progress
1270 This function processes the results of changes in configuration.
1273 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1274 @param Action Specifies the type of action taken by the browser.
1275 @param QuestionId A unique value which is sent to the original exporting driver
1276 so that it can identify the type of data to expect.
1277 @param Type The type of value for the question.
1278 @param Value A pointer to the data being sent to the original exporting driver.
1279 @param ActionRequest On return, points to the action requested by the callback function.
1281 @retval EFI_SUCCESS The callback successfully handled the action.
1282 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1283 @retval EFI_DEVICE_ERROR The variable could not be saved.
1284 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1285 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
1290 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1291 IN EFI_BROWSER_ACTION Action
,
1292 IN EFI_QUESTION_ID QuestionId
,
1294 IN EFI_IFR_TYPE_VALUE
*Value
,
1295 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1299 Create boot option base on the input file path info.
1301 @param FilePath Point to the file path.
1303 @retval TRUE Exit caller function.
1304 @retval FALSE Not exit caller function.
1308 CreateBootOptionFromFile (
1309 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1313 Create driver option base on the input file path info.
1315 @param FilePath Point to the file path.
1317 @retval TRUE Exit caller function.
1318 @retval FALSE Not exit caller function.
1321 CreateDriverOptionFromFile (
1322 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1326 Boot the file specified by the input file path info.
1328 @param FilePath Point to the file path.
1330 @retval TRUE Exit caller function.
1331 @retval FALSE Not exit caller function.
1336 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1340 // Global variable in this program (defined in data.c)
1342 extern BM_MENU_OPTION BootOptionMenu
;
1343 extern BM_MENU_OPTION DriverOptionMenu
;
1344 extern BM_MENU_OPTION ConsoleInpMenu
;
1345 extern BM_MENU_OPTION ConsoleOutMenu
;
1346 extern BM_MENU_OPTION ConsoleErrMenu
;
1347 extern BM_MENU_OPTION DriverMenu
;
1348 extern BM_MENU_OPTION TerminalMenu
;
1349 extern UINT16 TerminalType
[5];
1350 extern COM_ATTR BaudRateList
[19];
1351 extern COM_ATTR DataBitsList
[4];
1352 extern COM_ATTR ParityList
[5];
1353 extern COM_ATTR StopBitsList
[3];
1354 extern EFI_GUID TerminalTypeGuid
[5];
1355 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1356 extern UINT16 mFlowControlType
[2];
1357 extern UINT32 mFlowControlValue
[2];
1360 // Shared IFR form update data
1362 extern VOID
*mStartOpCodeHandle
;
1363 extern VOID
*mEndOpCodeHandle
;
1364 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1365 extern EFI_IFR_GUID_LABEL
*mEndLabel
;
1366 extern BMM_CALLBACK_DATA gBootMaintenancePrivate
;
1367 extern BMM_CALLBACK_DATA
*mBmmCallbackInfo
;