2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2017, 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>
44 #include "BootMaintenanceManagerCustomizedUi.h"
49 /// HII specific Vendor Device Path definition.
52 VENDOR_DEVICE_PATH VendorDevicePath
;
53 EFI_DEVICE_PATH_PROTOCOL End
;
54 } HII_VENDOR_DEVICE_PATH
;
58 // Constants which are variable names used to access variables
61 #define VAR_CON_OUT_MODE L"ConOutMode"
64 // Variable created with this flag will be "Efi:...."
66 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
68 extern EFI_GUID mBootMaintGuid
;
69 extern CHAR16 mBootMaintStorageName
[];
71 // These are the VFR compiler generated data representing our VFR data.
73 extern UINT8 BootMaintenanceManagerBin
[];
76 // Below are the number of options in Baudrate, Databits,
77 // Parity and Stopbits selection for serial ports.
79 #define BM_COM_ATTR_BUADRATE 19
80 #define BM_COM_ATTR_DATABITS 4
81 #define BM_COM_ATTR_PARITY 5
82 #define BM_COM_ATTR_STOPBITS 3
85 // Callback function helper
87 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
88 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
91 // Enumeration type definition
93 typedef UINT8 BBS_TYPE
;
95 typedef enum _TYPE_OF_TERMINAL
{
96 TerminalTypePcAnsi
= 0,
98 TerminalTypeVt100Plus
,
104 // All of the signatures that will be used in list structure
106 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
107 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
108 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
109 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
110 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
111 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
112 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
114 #define BM_LOAD_CONTEXT_SELECT 0x0
115 #define BM_CONSOLE_CONTEXT_SELECT 0x1
116 #define BM_FILE_CONTEXT_SELECT 0x2
117 #define BM_HANDLE_CONTEXT_SELECT 0x3
118 #define BM_TERMINAL_CONTEXT_SELECT 0x5
120 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
121 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
122 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
125 // Buffer size for update data
127 #define UPDATE_DATA_SIZE 0x100000
130 // Namespace of callback keys used in display and file system navigation
132 #define MAX_BBS_OFFSET 0xE000
133 #define NET_OPTION_OFFSET 0xD800
134 #define BEV_OPTION_OFFSET 0xD000
135 #define FD_OPTION_OFFSET 0xC000
136 #define HD_OPTION_OFFSET 0xB000
137 #define CD_OPTION_OFFSET 0xA000
138 #define FILE_OPTION_OFFSET 0x8000
139 #define FILE_OPTION_MASK 0x7FFF
140 #define HANDLE_OPTION_OFFSET 0x7000
141 #define CONSOLE_OPTION_OFFSET 0x6000
142 #define TERMINAL_OPTION_OFFSET 0x5000
143 #define CONFIG_OPTION_OFFSET 0x1200
144 #define KEY_VALUE_OFFSET 0x1100
145 #define FORM_ID_OFFSET 0x1000
148 // VarOffset that will be used to create question
149 // all these values are computed from the structure
152 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
155 // Question Id of Zero is invalid, so add an offset to it
157 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
159 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
160 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
161 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
162 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
163 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
164 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
165 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
166 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
167 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
168 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
169 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
170 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
171 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
172 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
173 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
174 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
175 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
176 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
177 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
178 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
179 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
180 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
181 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
182 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
183 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
184 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
185 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
186 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
187 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
188 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
189 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
190 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
191 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
192 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
193 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
194 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
195 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
197 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
198 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
199 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
200 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
201 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
202 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
203 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
204 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
205 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
206 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
207 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
208 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
209 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
210 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
211 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
212 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
213 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
214 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
215 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
216 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
217 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
218 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
219 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
220 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
221 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
222 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
223 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
224 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
225 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
226 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
227 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
228 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
229 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
230 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
231 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
232 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
233 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
235 #define STRING_DEPOSITORY_NUMBER 8
237 #define NONE_BOOTNEXT_VALUE (0xFFFF + 1)
240 /// Serial Ports attributes, first one is the value for
241 /// return from callback function, stringtoken is used to
242 /// display the value properly
267 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
268 } BM_TERMINAL_CONTEXT
;
277 UINT16 FilePathListLength
;
279 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
289 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
290 } BM_CONSOLE_CONTEXT
;
299 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
300 EFI_FILE_HANDLE FHandle
;
302 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
306 BOOLEAN IsRemovableMedia
;
308 BOOLEAN IsBootLegacy
;
313 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
326 UINT16
*DisplayString
;
328 EFI_STRING_ID DisplayStringToken
;
329 EFI_STRING_ID HelpStringToken
;
330 UINTN ContextSelection
;
331 VOID
*VariableContext
;
338 EFI_HII_HANDLE BmmHiiHandle
;
339 EFI_HANDLE BmmDriverHandle
;
341 /// Boot Maintenance Manager Produced protocols
343 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
344 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
346 BM_MENU_ENTRY
*MenuEntry
;
347 BM_HANDLE_CONTEXT
*HandleContext
;
348 BM_FILE_CONTEXT
*FileContext
;
349 BM_LOAD_CONTEXT
*LoadContext
;
350 BM_TERMINAL_CONTEXT
*TerminalContext
;
351 UINTN CurrentTerminal
;
355 // BMM main formset callback data.
358 EFI_FORM_ID BmmCurrentPageId
;
359 EFI_FORM_ID BmmPreviousPageId
;
360 BOOLEAN BmmAskSaveOrNot
;
361 BMM_FAKE_NV_DATA BmmFakeNvData
;
362 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
368 Find drivers that will be added as Driver#### variables from handles
369 in current system environment
370 All valid handles in the system except those consume SimpleFs, LoadFile
371 are stored in DriverMenu for future use.
373 @retval EFI_SUCCESS The function complets successfully.
374 @return Other value if failed to build the DriverMenu.
384 Build the BootOptionMenu according to BootOrder Variable.
385 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
387 @param CallbackData The BMM context data.
389 @return The number of the Var Boot####.
393 BOpt_GetBootOptions (
394 IN BMM_CALLBACK_DATA
*CallbackData
399 Build up all DriverOptionMenu
401 @param CallbackData The BMM context data.
403 @return EFI_SUCESS The functin completes successfully.
404 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
409 BOpt_GetDriverOptions (
410 IN BMM_CALLBACK_DATA
*CallbackData
414 Free resources allocated in Allocate Rountine.
416 @param FreeMenu Menu to be freed
421 BM_MENU_OPTION
*FreeMenu
426 Get the Option Number that has not been allocated for use.
428 @param Type The type of Option.
430 @return The available Option Number.
434 BOpt_GetOptionNumber (
440 Get the Option Number for Boot#### that does not used.
442 @return The available Option Number.
446 BOpt_GetBootOptionNumber (
452 Get the Option Number for Driver#### that does not used.
454 @return The unused Option Number.
458 BOpt_GetDriverOptionNumber (
463 Create a menu entry give a Menu type.
465 @param MenuType The Menu type to be created.
468 @retval NULL If failed to create the menu.
473 BOpt_CreateMenuEntry (
478 Free up all resource allocated for a BM_MENU_ENTRY.
480 @param MenuEntry A pointer to BM_MENU_ENTRY.
484 BOpt_DestroyMenuEntry (
485 BM_MENU_ENTRY
*MenuEntry
489 Get the Menu Entry from the list in Menu Entry List.
491 If MenuNumber is great or equal to the number of Menu
492 Entry in the list, then ASSERT.
494 @param MenuOption The Menu Entry List to read the menu entry.
495 @param MenuNumber The index of Menu Entry.
497 @return The Menu Entry.
502 BM_MENU_OPTION
*MenuOption
,
507 Get option number according to Boot#### and BootOrder variable.
508 The value is saved as #### + 1.
510 @param CallbackData The BMM context data.
514 IN BMM_CALLBACK_DATA
*CallbackData
518 Get driver option order from globalc DriverOptionMenu.
520 @param CallbackData The BMM context data.
525 IN BMM_CALLBACK_DATA
*CallbackData
529 // Locate all serial io devices for console
532 Build a list containing all serial devices.
534 @retval EFI_SUCCESS The function complete successfully.
535 @retval EFI_UNSUPPORTED No serial ports present.
544 // Initializing Console menu
547 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
549 @retval EFI_SUCCESS The function always complete successfully.
558 // Get current mode information
561 Get mode number according to column and row
563 @param CallbackData The BMM context data.
567 IN BMM_CALLBACK_DATA
*CallbackData
571 // Cleaning up console menu
574 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
576 @retval EFI_SUCCESS The function always complete successfully.
584 Update the device path that describing a terminal device
585 based on the new BaudRate, Data Bits, parity and Stop Bits
588 @param DevicePath The devicepath protocol instance wanted to be updated.
592 ChangeVariableDevicePath (
593 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
597 Update the multi-instance device path of Terminal Device based on
598 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
599 device path in the Terminal Device in TerminalMenu is also updated.
601 @param DevicePath The multi-instance device path.
602 @param ChangeTerminal TRUE, then device path in the Terminal Device
603 in TerminalMenu is also updated; FALSE, no update.
605 @return EFI_SUCCESS The function completes successfully.
609 ChangeTerminalDevicePath (
610 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
611 IN BOOLEAN ChangeTerminal
615 // Variable operation by menu selection
618 This function create a currently loaded Boot Option from
619 the BMM. It then appends this Boot Option to the end of
620 the "BootOrder" list. It also append this Boot Opotion to the end
623 @param CallbackData The BMM context data.
625 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
626 @retval EFI_SUCCESS If function completes successfully.
630 Var_UpdateBootOption (
631 IN BMM_CALLBACK_DATA
*CallbackData
635 Delete Boot Option that represent a Deleted state in BootOptionMenu.
637 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
638 BM_LOAD_CONTEXT marked for deletion is deleted
639 @return Others If failed to update the "BootOrder" variable after deletion.
648 This function create a currently loaded Drive Option from
649 the BMM. It then appends this Driver Option to the end of
650 the "DriverOrder" list. It append this Driver Opotion to the end
653 @param CallbackData The BMM context data.
654 @param HiiHandle The HII handle associated with the BMM formset.
655 @param DescriptionData The description of this driver option.
656 @param OptionalData The optional load option.
657 @param ForceReconnect If to force reconnect.
659 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
660 @retval EFI_SUCCESS If function completes successfully.
664 Var_UpdateDriverOption (
665 IN BMM_CALLBACK_DATA
*CallbackData
,
666 IN EFI_HII_HANDLE HiiHandle
,
667 IN UINT16
*DescriptionData
,
668 IN UINT16
*OptionalData
,
669 IN UINT8 ForceReconnect
673 Delete Load Option that represent a Deleted state in DriverOptionMenu.
675 @retval EFI_SUCCESS Load Option is successfully updated.
676 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
681 Var_DelDriverOption (
686 This function delete and build multi-instance device path ConIn
689 @retval EFI_SUCCESS The function complete successfully.
690 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
693 Var_UpdateConsoleInpOption (
698 This function delete and build multi-instance device path ConOut console device.
700 @retval EFI_SUCCESS The function complete successfully.
701 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
704 Var_UpdateConsoleOutOption (
709 This function delete and build multi-instance device path ErrOut console device.
711 @retval EFI_SUCCESS The function complete successfully.
712 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
715 Var_UpdateErrorOutOption (
720 This function delete and build Out of Band console device.
722 @param MenuIndex Menu index which user select in the terminal menu list.
724 @retval EFI_SUCCESS The function complete successfully.
725 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
728 Var_UpdateOutOfBandOption (
733 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
734 this EFI Variable is deleted.
735 It also update the BMM context data specified the "BootNext" value.
737 @param CallbackData The BMM context data.
739 @retval EFI_SUCCESS The function complete successfully.
740 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
745 IN BMM_CALLBACK_DATA
*CallbackData
749 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
750 BootOptionMenu with the new "BootOrder" list.
752 @param CallbackData The BMM context data.
754 @retval EFI_SUCCESS The function complete successfully.
755 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
756 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
760 Var_UpdateBootOrder (
761 IN BMM_CALLBACK_DATA
*CallbackData
765 This function update the "DriverOrder" EFI Variable based on
766 BMM Formset's NV map. It then refresh DriverOptionMenu
767 with the new "DriverOrder" list.
769 @param CallbackData The BMM context data.
771 @retval EFI_SUCCESS The function complete successfully.
772 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
773 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
777 Var_UpdateDriverOrder (
778 IN BMM_CALLBACK_DATA
*CallbackData
782 Update the Text Mode of Console.
784 @param CallbackData The context data for BMM.
786 @retval EFI_SUCCSS If the Text Mode of Console is updated.
787 @return Other value if the Text Mode of Console is not updated.
792 IN BMM_CALLBACK_DATA
*CallbackData
796 // Following are page create and refresh functions
799 Create the global UpdateData structure.
808 Refresh the global UpdateData structure.
817 Clean up the dynamic opcode at label and form specified by
820 @param LabelId It is both the Form ID and Label ID for
822 @param CallbackData The BMM context data.
828 IN BMM_CALLBACK_DATA
*CallbackData
832 Create a lit of boot option from global BootOptionMenu. It
833 allow user to delete the boot option.
835 @param CallbackData The BMM context data.
840 IN BMM_CALLBACK_DATA
*CallbackData
844 Create a lit of driver option from global DriverMenu.
846 @param CallbackData The BMM context data.
849 UpdateDrvAddHandlePage (
850 IN BMM_CALLBACK_DATA
*CallbackData
854 Create a lit of driver option from global DriverOptionMenu. It
855 allow user to delete the driver option.
857 @param CallbackData The BMM context data.
861 IN BMM_CALLBACK_DATA
*CallbackData
865 Prepare the page to allow user to add description for a Driver Option.
867 @param CallbackData The BMM context data.
870 UpdateDriverAddHandleDescPage (
871 IN BMM_CALLBACK_DATA
*CallbackData
875 Dispatch the correct update page function to call based on the UpdatePageId.
877 @param UpdatePageId The form ID.
878 @param CallbackData The BMM context data.
882 IN UINT16 UpdatePageId
,
883 IN BMM_CALLBACK_DATA
*CallbackData
887 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
888 Parity, Stop Bits, Terminal Type.
890 @param CallbackData The BMM context data.
894 IN BMM_CALLBACK_DATA
*CallbackData
898 Refresh the text mode page
900 @param CallbackData The BMM context data.
904 IN BMM_CALLBACK_DATA
*CallbackData
908 Create a list of Goto Opcode for all terminal devices logged
909 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
911 @param CallbackData The BMM context data.
915 IN BMM_CALLBACK_DATA
*CallbackData
919 Update add boot/driver option page.
921 @param CallbackData The BMM context data.
922 @param FormId The form ID to be updated.
923 @param DevicePath Device path.
928 IN BMM_CALLBACK_DATA
*CallbackData
,
929 IN EFI_FORM_ID FormId
,
930 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
934 Function deletes the variable specified by VarName and VarGuid.
937 @param VarName A Null-terminated Unicode string that is
938 the name of the vendor's variable.
940 @param VarGuid A unique identifier for the vendor.
942 @retval EFI_SUCCESS The variable was found and removed
943 @retval EFI_UNSUPPORTED The variable store was inaccessible
944 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
945 @retval EFI_NOT_FOUND The variable was not found
949 EfiLibDeleteVariable (
955 Function is used to determine the number of device path instances
956 that exist in a device path.
959 @param DevicePath A pointer to a device path data structure.
961 @return This function counts and returns the number of device path instances
966 EfiDevicePathInstanceCount (
967 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
971 Get a string from the Data Hub record based on
974 @param DevPath The device Path.
976 @return A string located from the Data Hub records based on
978 @retval NULL If failed to get the String from Data Hub.
982 EfiLibStrFromDatahub (
983 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
987 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
988 specified by DeviceType.
990 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
992 @param OptionIndex Returns the index number (#### in Boot####).
993 @param OptionSize Return the size of the Boot### variable.
997 GetLegacyBootOptionVar (
999 OUT UINTN
*OptionIndex
,
1000 OUT UINTN
*OptionSize
1004 Discard all changes done to the BMM pages such as Boot Order change,
1005 Driver order change.
1007 @param Private The BMM context data.
1008 @param CurrentFakeNVMap The current Fack NV Map.
1012 DiscardChangeHandler (
1013 IN BMM_CALLBACK_DATA
*Private
,
1014 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1019 This function is to clean some useless data before submit changes.
1021 @param Private The BMM context data.
1025 CleanUselessBeforeSubmit (
1026 IN BMM_CALLBACK_DATA
*Private
1030 Dispatch the display to the next page based on NewPageId.
1032 @param Private The BMM context data.
1033 @param NewPageId The original page ID.
1038 BMM_CALLBACK_DATA
*Private
,
1043 Remove the installed BootMaint and FileExplorer HiiPackages.
1052 Install BootMaint and FileExplorer HiiPackages.
1056 InitBootMaintenance(
1062 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1063 in BMM_FAKE_NV_DATA structure.
1065 @param CallbackData The BMM context data.
1070 IN BMM_CALLBACK_DATA
*CallbackData
1075 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1076 in BMM_FAKE_NV_DATA structure.
1078 @param CallbackData The BMM context data.
1082 GetConsoleOutCheck (
1083 IN BMM_CALLBACK_DATA
*CallbackData
1088 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1089 in BMM_FAKE_NV_DATA structure.
1091 @param CallbackData The BMM context data.
1095 GetConsoleErrCheck (
1096 IN BMM_CALLBACK_DATA
*CallbackData
1101 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1102 to BMM_FAKE_NV_DATA structure.
1104 @param CallbackData The BMM context data.
1108 GetTerminalAttribute (
1109 IN BMM_CALLBACK_DATA
*CallbackData
1113 This function will change video resolution and text mode
1114 according to defined setup mode or defined boot mode
1116 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.
1118 @retval EFI_SUCCESS Mode is changed successfully.
1119 @retval Others Mode failed to be changed.
1129 This function converts an input device structure to a Unicode string.
1131 @param DevPath A pointer to the device path structure.
1133 @return A new allocated Unicode string that represents the device path.
1138 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1142 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
1143 The caller is responsible for freeing the allocated buffer using FreePool().
1145 @param DevicePath Device path.
1147 @return A new allocated string that represents the file name.
1151 ExtractFileNameFromDevicePath (
1152 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1156 This function allows a caller to extract the current configuration for one
1157 or more named elements from the target driver.
1159 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1160 @param Request A null-terminated Unicode string in <ConfigRequest> format.
1161 @param Progress On return, points to a character in the Request string.
1162 Points to the string's null terminator if request was successful.
1163 Points to the most recent '&' before the first failing name/value
1164 pair (or the beginning of the string if the failure is in the
1165 first name/value pair) if the request was not successful.
1166 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
1167 has all values filled in for the names in the Request string.
1168 String to be allocated by the called function.
1170 @retval EFI_SUCCESS The Results is filled with the requested values.
1171 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
1172 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
1173 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
1178 BootMaintExtractConfig (
1179 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1180 IN CONST EFI_STRING Request
,
1181 OUT EFI_STRING
*Progress
,
1182 OUT EFI_STRING
*Results
1186 This function applies changes in a driver's configuration.
1187 Input is a Configuration, which has the routing data for this
1188 driver followed by name / value configuration pairs. The driver
1189 must apply those pairs to its configurable storage. If the
1190 driver's configuration is stored in a linear block of data
1191 and the driver's name / value pairs are in <BlockConfig>
1192 format, it may use the ConfigToBlock helper function (above) to
1193 simplify the job. Currently not implemented.
1195 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1196 @param[in] Configuration A null-terminated Unicode string in
1197 <ConfigString> format.
1198 @param[out] Progress A pointer to a string filled in with the
1199 offset of the most recent '&' before the
1200 first failing name / value pair (or the
1201 beginn ing of the string if the failure
1202 is in the first name / value pair) or
1203 the terminating NULL if all was
1206 @retval EFI_SUCCESS The results have been distributed or are
1207 awaiting distribution.
1208 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1209 parts of the results that must be
1210 stored awaiting possible future
1212 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1213 Results parameter would result
1214 in this type of error.
1215 @retval EFI_NOT_FOUND Target for the specified routing data
1220 BootMaintRouteConfig (
1221 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1222 IN CONST EFI_STRING Configuration
,
1223 OUT EFI_STRING
*Progress
1227 This function processes the results of changes in configuration.
1230 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1231 @param Action Specifies the type of action taken by the browser.
1232 @param QuestionId A unique value which is sent to the original exporting driver
1233 so that it can identify the type of data to expect.
1234 @param Type The type of value for the question.
1235 @param Value A pointer to the data being sent to the original exporting driver.
1236 @param ActionRequest On return, points to the action requested by the callback function.
1238 @retval EFI_SUCCESS The callback successfully handled the action.
1239 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1240 @retval EFI_DEVICE_ERROR The variable could not be saved.
1241 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1242 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
1247 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1248 IN EFI_BROWSER_ACTION Action
,
1249 IN EFI_QUESTION_ID QuestionId
,
1251 IN EFI_IFR_TYPE_VALUE
*Value
,
1252 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1256 Create boot option base on the input file path info.
1258 @param FilePath Point to the file path.
1260 @retval TRUE Exit caller function.
1261 @retval FALSE Not exit caller function.
1266 CreateBootOptionFromFile (
1267 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1271 Create driver option base on the input file path info.
1273 @param FilePath Point to the file path.
1275 @retval TRUE Exit caller function.
1276 @retval FALSE Not exit caller function.
1280 CreateDriverOptionFromFile (
1281 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1285 Boot the file specified by the input file path info.
1287 @param FilePath Point to the file path.
1289 @retval TRUE Exit caller function.
1290 @retval FALSE Not exit caller function.
1296 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1300 // Global variable in this program (defined in data.c)
1302 extern BM_MENU_OPTION BootOptionMenu
;
1303 extern BM_MENU_OPTION DriverOptionMenu
;
1304 extern BM_MENU_OPTION ConsoleInpMenu
;
1305 extern BM_MENU_OPTION ConsoleOutMenu
;
1306 extern BM_MENU_OPTION ConsoleErrMenu
;
1307 extern BM_MENU_OPTION DriverMenu
;
1308 extern BM_MENU_OPTION TerminalMenu
;
1309 extern UINT16 TerminalType
[5];
1310 extern COM_ATTR BaudRateList
[19];
1311 extern COM_ATTR DataBitsList
[4];
1312 extern COM_ATTR ParityList
[5];
1313 extern COM_ATTR StopBitsList
[3];
1314 extern EFI_GUID TerminalTypeGuid
[5];
1315 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1316 extern UINT16 mFlowControlType
[2];
1317 extern UINT32 mFlowControlValue
[2];
1320 // Shared IFR form update data
1322 extern VOID
*mStartOpCodeHandle
;
1323 extern VOID
*mEndOpCodeHandle
;
1324 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1325 extern EFI_IFR_GUID_LABEL
*mEndLabel
;
1326 extern BMM_CALLBACK_DATA gBootMaintenancePrivate
;
1327 extern BMM_CALLBACK_DATA
*mBmmCallbackInfo
;