2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2012, 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_
19 #include "BBSsupport.h"
21 #include "FrontPage.h"
24 // Constants which are variable names used to access variables
26 #define VAR_CON_OUT_MODE L"ConOutMode"
31 #define STR_FLOPPY L"Floppy Drive #%02x"
32 #define STR_HARDDISK L"HardDisk Drive #%02x"
33 #define STR_CDROM L"ATAPI CDROM Drive #%02x"
34 #define STR_NET L"NET Drive #%02x"
35 #define STR_BEV L"BEV Drive #%02x"
36 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x"
37 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x"
38 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x"
39 #define STR_NET_HELP L"NET Drive #%02x"
40 #define STR_BEV_HELP L"BEV Drive #%02x"
42 extern CHAR16 mFileExplorerStorageName
[];
43 extern CHAR16 mBootMaintStorageName
[];
45 // These are the VFR compiler generated data representing our VFR data.
51 // Below are the number of options in Baudrate, Databits,
52 // Parity and Stopbits selection for serial ports.
54 #define BM_COM_ATTR_BUADRATE 19
55 #define BM_COM_ATTR_DATABITS 4
56 #define BM_COM_ATTR_PARITY 5
57 #define BM_COM_ATTR_STOPBITS 3
60 // Callback function helper
62 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
63 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
65 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
68 // Enumeration type definition
70 typedef enum _TYPE_OF_TERMINAL
{
71 TerminalTypePcAnsi
= 0,
73 TerminalTypeVt100Plus
,
77 typedef enum _FILE_EXPLORER_STATE
{
78 FileExplorerStateInActive
= 0,
79 FileExplorerStateBootFromFile
,
80 FileExplorerStateAddBootOption
,
81 FileExplorerStateAddDriverOptionState
,
82 FileExplorerStateUnknown
83 } FILE_EXPLORER_STATE
;
85 typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT
{
86 FileExplorerDisplayFileSystem
,
87 FileExplorerDisplayDirectory
,
88 FileExplorerDisplayUnknown
89 } FILE_EXPLORER_DISPLAY_CONTEXT
;
92 // All of the signatures that will be used in list structure
94 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
95 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
96 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
97 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
98 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
99 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
100 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
102 #define BM_LOAD_CONTEXT_SELECT 0x0
103 #define BM_CONSOLE_CONTEXT_SELECT 0x1
104 #define BM_FILE_CONTEXT_SELECT 0x2
105 #define BM_HANDLE_CONTEXT_SELECT 0x3
106 #define BM_TERMINAL_CONTEXT_SELECT 0x5
108 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
109 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
110 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
111 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
114 // Buffer size for update data
116 #define UPDATE_DATA_SIZE 0x100000
119 // Namespace of callback keys used in display and file system navigation
121 #define MAX_BBS_OFFSET 0xE000
122 #define NET_OPTION_OFFSET 0xD800
123 #define BEV_OPTION_OFFSET 0xD000
124 #define FD_OPTION_OFFSET 0xC000
125 #define HD_OPTION_OFFSET 0xB000
126 #define CD_OPTION_OFFSET 0xA000
127 #define FILE_OPTION_OFFSET 0x8000
128 #define FILE_OPTION_MASK 0x7FFF
129 #define HANDLE_OPTION_OFFSET 0x7000
130 #define CONSOLE_OPTION_OFFSET 0x6000
131 #define TERMINAL_OPTION_OFFSET 0x5000
132 #define CONFIG_OPTION_OFFSET 0x1200
133 #define KEY_VALUE_OFFSET 0x1100
134 #define FORM_ID_OFFSET 0x1000
137 // VarOffset that will be used to create question
138 // all these values are computed from the structure
141 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
144 // Question Id of Zero is invalid, so add an offset to it
146 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
148 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
149 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
150 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
151 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
152 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
153 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
154 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
155 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
156 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
157 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
158 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
159 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
160 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
161 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
162 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
163 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
164 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
165 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
166 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
167 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
168 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
169 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
170 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
171 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
172 #define OPTION_DEL_VAR_OFFSET VAR_OFFSET (OptionDel)
173 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
174 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
175 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
176 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
177 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
178 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
179 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
180 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
181 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
182 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
183 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
184 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
186 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
187 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
188 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
189 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
190 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
191 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
192 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
193 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
194 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
195 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
196 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
197 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
198 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
199 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
200 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
201 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
202 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
203 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
204 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
205 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
206 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
207 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
208 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
209 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
210 #define OPTION_DEL_QUESTION_ID QUESTION_ID (OptionDel)
211 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
212 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
213 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
214 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
215 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
216 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
217 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
218 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
219 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
220 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
221 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
222 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
224 #define STRING_DEPOSITORY_NUMBER 8
227 /// Serial Ports attributes, first one is the value for
228 /// return from callback function, stringtoken is used to
229 /// display the value properly
254 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
255 } BM_TERMINAL_CONTEXT
;
259 BOOLEAN LoadOptionModified
;
264 BOOLEAN ForceReconnect
;
265 UINTN OptionalDataSize
;
267 UINTN LoadOptionSize
;
271 UINT16 FilePathListLength
;
273 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
284 } BM_LEGACY_DEVICE_CONTEXT
;
292 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
293 } BM_CONSOLE_CONTEXT
;
302 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
303 EFI_FILE_HANDLE FHandle
;
305 EFI_FILE_SYSTEM_VOLUME_LABEL
*Info
;
309 BOOLEAN IsRemovableMedia
;
311 BOOLEAN IsBootLegacy
;
316 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
329 UINT16
*DisplayString
;
331 EFI_STRING_ID DisplayStringToken
;
332 EFI_STRING_ID HelpStringToken
;
333 UINTN ContextSelection
;
334 VOID
*VariableContext
;
339 // Shared callback data.
343 BM_MENU_ENTRY
*MenuEntry
;
344 BM_HANDLE_CONTEXT
*HandleContext
;
345 BM_FILE_CONTEXT
*FileContext
;
346 BM_LOAD_CONTEXT
*LoadContext
;
347 BM_TERMINAL_CONTEXT
*TerminalContext
;
348 UINTN CurrentTerminal
;
352 // BMM main formset callback data.
354 EFI_HII_HANDLE BmmHiiHandle
;
355 EFI_HANDLE BmmDriverHandle
;
356 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
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
;
364 // File explorer formset callback data.
366 EFI_HII_HANDLE FeHiiHandle
;
367 EFI_HANDLE FeDriverHandle
;
368 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
369 FILE_EXPLORER_STATE FeCurrentState
;
370 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
371 FILE_EXPLORER_NV_DATA FeFakeNvData
;
374 typedef struct _STRING_LIST_NODE STRING_LIST_NODE
;
376 struct _STRING_LIST_NODE
{
377 EFI_STRING_ID StringToken
;
378 STRING_LIST_NODE
*Next
;
381 typedef struct _STRING_DEPOSITORY
{
382 UINTN TotalNodeNumber
;
383 STRING_LIST_NODE
*CurrentNode
;
384 STRING_LIST_NODE
*ListHead
;
390 // For initializing File System menu
394 This function build the FsOptionMenu list which records all
395 available file system in the system. They includes all instances
396 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
397 and all type of legacy boot device.
399 @param CallbackData BMM context data
401 @retval EFI_SUCCESS Success find the file system
402 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
406 BOpt_FindFileSystem (
407 IN BMM_CALLBACK_DATA
*CallbackData
411 Find files under current directory
412 All files and sub-directories in current directory
413 will be stored in DirectoryMenu for future use.
415 @param CallbackData The BMM context data.
416 @param MenuEntry The Menu Entry.
418 @retval EFI_SUCCESS Get files from current dir successfully.
419 @return Other value if can't get files from current dir.
424 IN BMM_CALLBACK_DATA
*CallbackData
,
425 IN BM_MENU_ENTRY
*MenuEntry
430 Find drivers that will be added as Driver#### variables from handles
431 in current system environment
432 All valid handles in the system except those consume SimpleFs, LoadFile
433 are stored in DriverMenu for future use.
435 @retval EFI_SUCCESS The function complets successfully.
436 @return Other value if failed to build the DriverMenu.
446 Build the BootOptionMenu according to BootOrder Variable.
447 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
449 @param CallbackData The BMM context data.
451 @return The number of the Var Boot####.
455 BOpt_GetBootOptions (
456 IN BMM_CALLBACK_DATA
*CallbackData
461 Build up all DriverOptionMenu
463 @param CallbackData The BMM context data.
465 @return EFI_SUCESS The functin completes successfully.
466 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
471 BOpt_GetDriverOptions (
472 IN BMM_CALLBACK_DATA
*CallbackData
477 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
479 @retval EFI_SUCCESS The function complete successfully.
480 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
484 BOpt_GetLegacyOptions (
489 Free out resouce allocated from Legacy Boot Options.
493 BOpt_FreeLegacyOptions (
498 Free resources allocated in Allocate Rountine.
500 @param FreeMenu Menu to be freed
505 BM_MENU_OPTION
*FreeMenu
511 Append file name to existing file name.
513 @param Str1 The existing file name
514 @param Str2 The file name to be appended
516 @return Allocate a new string to hold the appended result.
517 Caller is responsible to free the returned string.
521 BOpt_AppendFileName (
528 Check whether current FileName point to a valid
531 @param FileName File need to be checked.
533 @retval TRUE Is Efi Image
534 @retval FALSE Not a valid Efi Image
538 BOpt_IsEfiImageName (
544 Check whether current FileName point to a valid Efi Application
546 @param Dir Pointer to current Directory
547 @param FileName Pointer to current File name.
549 @retval TRUE Is a valid Efi Application
550 @retval FALSE not a valid Efi Application
555 IN EFI_FILE_HANDLE Dir
,
561 Get the Option Number that has not been allocated for use.
563 @param Type The type of Option.
565 @return The available Option Number.
569 BOpt_GetOptionNumber (
575 Get the Option Number for Boot#### that does not used.
577 @return The available Option Number.
581 BOpt_GetBootOptionNumber (
587 Get the Option Number for Driver#### that does not used.
589 @return The unused Option Number.
593 BOpt_GetDriverOptionNumber (
598 Create a menu entry give a Menu type.
600 @param MenuType The Menu type to be created.
603 @retval NULL If failed to create the menu.
608 BOpt_CreateMenuEntry (
613 Free up all resource allocated for a BM_MENU_ENTRY.
615 @param MenuEntry A pointer to BM_MENU_ENTRY.
619 BOpt_DestroyMenuEntry (
620 BM_MENU_ENTRY
*MenuEntry
624 Get the Menu Entry from the list in Menu Entry List.
626 If MenuNumber is great or equal to the number of Menu
627 Entry in the list, then ASSERT.
629 @param MenuOption The Menu Entry List to read the menu entry.
630 @param MenuNumber The index of Menu Entry.
632 @return The Menu Entry.
637 BM_MENU_OPTION
*MenuOption
,
642 // Locate all serial io devices for console
645 Build a list containing all serial devices.
647 @retval EFI_SUCCESS The function complete successfully.
648 @retval EFI_UNSUPPORTED No serial ports present.
657 // Initializing Console menu
660 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
662 @retval EFI_SUCCESS The function always complete successfully.
671 // Get current mode information
674 Get mode number according to column and row
676 @param CallbackData The BMM context data.
680 IN BMM_CALLBACK_DATA
*CallbackData
684 // Cleaning up console menu
687 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
689 @retval EFI_SUCCESS The function always complete successfully.
697 Update the device path that describing a terminal device
698 based on the new BaudRate, Data Bits, parity and Stop Bits
701 @param DevicePath The devicepath protocol instance wanted to be updated.
705 ChangeVariableDevicePath (
706 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
710 Update the multi-instance device path of Terminal Device based on
711 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
712 device path in the Terminal Device in TerminalMenu is also updated.
714 @param DevicePath The multi-instance device path.
715 @param ChangeTerminal TRUE, then device path in the Terminal Device
716 in TerminalMenu is also updated; FALSE, no update.
718 @return EFI_SUCCESS The function completes successfully.
722 ChangeTerminalDevicePath (
723 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
724 IN BOOLEAN ChangeTerminal
728 // Variable operation by menu selection
731 This function create a currently loaded Boot Option from
732 the BMM. It then appends this Boot Option to the end of
733 the "BootOrder" list. It also append this Boot Opotion to the end
736 @param CallbackData The BMM context data.
737 @param NvRamMap The file explorer formset internal state.
739 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
740 @retval EFI_SUCCESS If function completes successfully.
744 Var_UpdateBootOption (
745 IN BMM_CALLBACK_DATA
*CallbackData
,
746 IN FILE_EXPLORER_NV_DATA
*NvRamMap
750 Delete Boot Option that represent a Deleted state in BootOptionMenu.
751 After deleting this boot option, call Var_ChangeBootOrder to
752 make sure BootOrder is in valid state.
754 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
755 BM_LOAD_CONTEXT marked for deletion is deleted
756 @return Others If failed to update the "BootOrder" variable after deletion.
765 After any operation on Boot####, there will be a discrepancy in BootOrder.
766 Since some are missing but in BootOrder, while some are present but are
767 not reflected by BootOrder. Then a function rebuild BootOrder from
768 scratch by content from BootOptionMenu is needed.
770 @retval EFI_SUCCESS The boot order is updated successfully.
771 @return other than EFI_SUCCESS if failed to change the "BootOrder" EFI Variable.
775 Var_ChangeBootOrder (
780 This function create a currently loaded Drive Option from
781 the BMM. It then appends this Driver Option to the end of
782 the "DriverOrder" list. It append this Driver Opotion to the end
785 @param CallbackData The BMM context data.
786 @param HiiHandle The HII handle associated with the BMM formset.
787 @param DescriptionData The description of this driver option.
788 @param OptionalData The optional load option.
789 @param ForceReconnect If to force reconnect.
791 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
792 @retval EFI_SUCCESS If function completes successfully.
796 Var_UpdateDriverOption (
797 IN BMM_CALLBACK_DATA
*CallbackData
,
798 IN EFI_HII_HANDLE HiiHandle
,
799 IN UINT16
*DescriptionData
,
800 IN UINT16
*OptionalData
,
801 IN UINT8 ForceReconnect
805 Delete Load Option that represent a Deleted state in BootOptionMenu.
806 After deleting this Driver option, call Var_ChangeDriverOrder to
807 make sure DriverOrder is in valid state.
809 @retval EFI_SUCCESS Load Option is successfully updated.
810 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
815 Var_DelDriverOption (
820 After any operation on Driver####, there will be a discrepancy in
821 DriverOrder. Since some are missing but in DriverOrder, while some
822 are present but are not reflected by DriverOrder. Then a function
823 rebuild DriverOrder from scratch by content from DriverOptionMenu is
826 @retval EFI_SUCCESS The driver order is updated successfully.
827 @return other than EFI_SUCCESS if failed to set the "DriverOrder" EFI Variable.
831 Var_ChangeDriverOrder (
836 This function delete and build multi-instance device path ConIn
839 @retval EFI_SUCCESS The function complete successfully.
840 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
843 Var_UpdateConsoleInpOption (
848 This function delete and build multi-instance device path ConOut console device.
850 @retval EFI_SUCCESS The function complete successfully.
851 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
854 Var_UpdateConsoleOutOption (
859 This function delete and build multi-instance device path ErrOut console device.
861 @retval EFI_SUCCESS The function complete successfully.
862 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
865 Var_UpdateErrorOutOption (
870 Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,
871 parity and stop Bits set.
875 Var_UpdateAllConsoleOption (
880 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
881 this EFI Variable is deleted.
882 It also update the BMM context data specified the "BootNext" value.
884 @param CallbackData The BMM context data.
886 @retval EFI_SUCCESS The function complete successfully.
887 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
892 IN BMM_CALLBACK_DATA
*CallbackData
896 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
897 BootOptionMenu with the new "BootOrder" list.
899 @param CallbackData The BMM context data.
901 @retval EFI_SUCCESS The function complete successfully.
902 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
903 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
907 Var_UpdateBootOrder (
908 IN BMM_CALLBACK_DATA
*CallbackData
912 This function update the "DriverOrder" EFI Variable based on
913 BMM Formset's NV map. It then refresh DriverOptionMenu
914 with the new "DriverOrder" list.
916 @param CallbackData The BMM context data.
918 @retval EFI_SUCCESS The function complete successfully.
919 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
920 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
924 Var_UpdateDriverOrder (
925 IN BMM_CALLBACK_DATA
*CallbackData
929 Update the legacy BBS boot option. VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable
930 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
933 @param CallbackData The context data for BMM.
935 @return EFI_SUCCESS The function completed successfully.
936 @retval EFI_NOT_FOUND If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can not be found.
940 Var_UpdateBBSOption (
941 IN BMM_CALLBACK_DATA
*CallbackData
945 Update the Text Mode of Console.
947 @param CallbackData The context data for BMM.
949 @retval EFI_SUCCSS If the Text Mode of Console is updated.
950 @return Other value if the Text Mode of Console is not updated.
955 IN BMM_CALLBACK_DATA
*CallbackData
959 // Following are page create and refresh functions
962 Refresh the global UpdateData structure.
971 Clean up the dynamic opcode at label and form specified by
974 @param LabelId It is both the Form ID and Label ID for
976 @param CallbackData The BMM context data.
982 IN BMM_CALLBACK_DATA
*CallbackData
986 Create a lit of boot option from global BootOptionMenu. It
987 allow user to delete the boot option.
989 @param CallbackData The BMM context data.
994 IN BMM_CALLBACK_DATA
*CallbackData
998 Create a lit of driver option from global DriverMenu.
1000 @param CallbackData The BMM context data.
1003 UpdateDrvAddHandlePage (
1004 IN BMM_CALLBACK_DATA
*CallbackData
1008 Create a lit of driver option from global DriverOptionMenu. It
1009 allow user to delete the driver option.
1011 @param CallbackData The BMM context data.
1015 IN BMM_CALLBACK_DATA
*CallbackData
1019 Prepare the page to allow user to add description for a Driver Option.
1021 @param CallbackData The BMM context data.
1024 UpdateDriverAddHandleDescPage (
1025 IN BMM_CALLBACK_DATA
*CallbackData
1029 Dispatch the correct update page function to call based on the UpdatePageId.
1031 @param UpdatePageId The form ID.
1032 @param CallbackData The BMM context data.
1036 IN UINT16 UpdatePageId
,
1037 IN BMM_CALLBACK_DATA
*CallbackData
1041 Create the dynamic page to allow user to set the "BootNext" vaule.
1043 @param CallbackData The BMM context data.
1046 UpdateBootNextPage (
1047 IN BMM_CALLBACK_DATA
*CallbackData
1051 Create the dynamic page to allow user to set the "TimeOut" vaule.
1053 @param CallbackData The BMM context data.
1057 IN BMM_CALLBACK_DATA
*CallbackData
1061 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
1062 Parity, Stop Bits, Terminal Type.
1064 @param CallbackData The BMM context data.
1067 UpdateTerminalPage (
1068 IN BMM_CALLBACK_DATA
*CallbackData
1072 Refresh the text mode page
1074 @param CallbackData The BMM context data.
1078 IN BMM_CALLBACK_DATA
*CallbackData
1082 Create a list of Goto Opcode for all terminal devices logged
1083 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1085 @param CallbackData The BMM context data.
1089 IN BMM_CALLBACK_DATA
*CallbackData
1093 Create a dynamic page so that Legacy Device boot order
1094 can be set for specified device type.
1096 @param UpdatePageId The form ID. It also spefies the legacy device type.
1097 @param CallbackData The BMM context data.
1100 UpdateSetLegacyDeviceOrderPage (
1101 IN UINT16 UpdatePageId
,
1102 IN BMM_CALLBACK_DATA
*CallbackData
1107 Function opens and returns a file handle to the root directory of a volume.
1109 @param DeviceHandle A handle for a device
1110 @return A valid file handle or NULL is returned
1114 IN EFI_HANDLE DeviceHandle
1118 Function gets the file system information from an open file descriptor,
1119 and stores it in a buffer allocated from pool.
1121 @param FHand The file handle.
1123 @return A pointer to a buffer with file information.
1124 NULL is returned if failed to get Vaolume Label Info.
1126 EFI_FILE_SYSTEM_VOLUME_LABEL
*
1127 EfiLibFileSystemVolumeLabelInfo (
1128 IN EFI_FILE_HANDLE FHand
1133 Function gets the file information from an open file descriptor, and stores it
1134 in a buffer allocated from pool.
1136 @param FHand File Handle.
1138 @return A pointer to a buffer with file information or NULL is returned
1143 IN EFI_FILE_HANDLE FHand
1147 Adjusts the size of a previously allocated buffer.
1149 @param OldPool A pointer to the buffer whose size is being adjusted.
1150 @param OldSize The size of the current buffer.
1151 @param NewSize The size of the new buffer.
1153 @return The newly allocated buffer. if NULL, allocation failed.
1164 Function deletes the variable specified by VarName and VarGuid.
1167 @param VarName A Null-terminated Unicode string that is
1168 the name of the vendor's variable.
1170 @param VarGuid A unique identifier for the vendor.
1172 @retval EFI_SUCCESS The variable was found and removed
1173 @retval EFI_UNSUPPORTED The variable store was inaccessible
1174 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1175 @retval EFI_NOT_FOUND The variable was not found
1179 EfiLibDeleteVariable (
1181 IN EFI_GUID
*VarGuid
1187 @param Src The source.
1189 @return A new string which is duplicated copy of the source.
1190 @retval NULL If there is not enough memory.
1199 Function is used to determine the number of device path instances
1200 that exist in a device path.
1203 @param DevicePath A pointer to a device path data structure.
1205 @return This function counts and returns the number of device path instances
1210 EfiDevicePathInstanceCount (
1211 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1215 Create string tokens for a menu from its help strings and display strings
1218 @param CallbackData The BMM context data.
1219 @param HiiHandle Hii Handle of the package to be updated.
1220 @param MenuOption The Menu whose string tokens need to be created
1222 @retval EFI_SUCCESS string tokens created successfully
1223 @retval others contain some errors
1227 CreateMenuStringToken (
1228 IN BMM_CALLBACK_DATA
*CallbackData
,
1229 IN EFI_HII_HANDLE HiiHandle
,
1230 IN BM_MENU_OPTION
*MenuOption
1234 Get a string from the Data Hub record based on
1237 @param DevPath The device Path.
1239 @return A string located from the Data Hub records based on
1241 @retval NULL If failed to get the String from Data Hub.
1245 EfiLibStrFromDatahub (
1246 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1250 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1251 specified by DeviceType.
1253 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1255 @param OptionIndex Returns the index number (#### in Boot####).
1256 @param OptionSize Return the size of the Boot### variable.
1260 GetLegacyBootOptionVar (
1261 IN UINTN DeviceType
,
1262 OUT UINTN
*OptionIndex
,
1263 OUT UINTN
*OptionSize
1267 Initialize the Boot Maintenance Utitliy.
1269 @retval EFI_SUCCESS utility ended successfully.
1270 @retval others contain some errors.
1279 Start boot maintenance manager
1281 @retval EFI_SUCCESS If BMM is invoked successfully.
1282 @return Other value if BMM return unsuccessfully.
1291 Intialize all the string depositories.
1295 InitializeStringDepository (
1300 Fetch a usable string node from the string depository and return the string token.
1303 @param CallbackData The BMM context data.
1304 @param StringDepository Pointer of the string depository.
1306 @retval EFI_STRING_ID String token.
1310 GetStringTokenFromDepository (
1311 IN BMM_CALLBACK_DATA
*CallbackData
,
1312 IN STRING_DEPOSITORY
*StringDepository
1316 Reclaim string depositories by moving the current node pointer to list head..
1319 ReclaimStringDepository (
1324 Release resource for all the string depositories.
1328 CleanUpStringDepository (
1333 Function handling request to apply changes for BMM pages.
1335 @param Private Pointer to callback data buffer.
1336 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
1337 @param FormId ID of the form which has sent the request to apply change.
1339 @retval EFI_SUCCESS Change successfully applied.
1340 @retval Other Error occurs while trying to apply changes.
1344 ApplyChangeHandler (
1345 IN BMM_CALLBACK_DATA
*Private
,
1346 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1347 IN EFI_FORM_ID FormId
1351 Discard all changes done to the BMM pages such as Boot Order change,
1352 Driver order change.
1354 @param Private The BMM context data.
1355 @param CurrentFakeNVMap The current Fack NV Map.
1359 DiscardChangeHandler (
1360 IN BMM_CALLBACK_DATA
*Private
,
1361 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1365 Dispatch the display to the next page based on NewPageId.
1367 @param Private The BMM context data.
1368 @param NewPageId The original page ID.
1373 BMM_CALLBACK_DATA
*Private
,
1378 Boot a file selected by user at File Expoloer of BMM.
1380 @param FileContext The file context data, which contains the device path
1381 of the file to be boot from.
1383 @retval EFI_SUCCESS The function completed successfull.
1384 @return Other value if the boot from the file fails.
1389 IN BM_FILE_CONTEXT
*FileContext
1393 Update the file explower page with the refershed file system.
1396 @param CallbackData BMM context data
1397 @param KeyValue Key value to identify the type of data to expect.
1399 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1400 @retval FALSE Indicate that there is no need to exit file explorer.
1404 UpdateFileExplorer (
1405 IN BMM_CALLBACK_DATA
*CallbackData
,
1410 This function processes the results of changes in configuration.
1411 When user select a interactive opcode, this callback will be triggered.
1412 Based on the Question(QuestionId) that triggers the callback, the corresponding
1413 actions is performed. It handles:
1415 1) the addition of boot option.
1416 2) the addition of driver option.
1417 3) exit from file browser
1418 4) update of file content if a dir is selected.
1419 5) boot the file if a file is selected in "boot from file"
1422 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1423 @param Action Specifies the type of action taken by the browser.
1424 @param QuestionId A unique value which is sent to the original exporting driver
1425 so that it can identify the type of data to expect.
1426 @param Type The type of value for the question.
1427 @param Value A pointer to the data being sent to the original exporting driver.
1428 @param ActionRequest On return, points to the action requested by the callback function.
1430 @retval EFI_SUCCESS The callback successfully handled the action.
1431 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1432 @retval EFI_DEVICE_ERROR The variable could not be saved.
1433 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1438 FileExplorerCallback (
1439 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1440 IN EFI_BROWSER_ACTION Action
,
1441 IN EFI_QUESTION_ID QuestionId
,
1443 IN EFI_IFR_TYPE_VALUE
*Value
,
1444 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1448 Dispatch BMM formset and FileExplorer formset.
1451 @param CallbackData The BMM context data.
1453 @retval EFI_SUCCESS If function complete successfully.
1454 @return Other value if the Setup Browser process BMM's pages and
1455 return unsuccessfully.
1460 IN BMM_CALLBACK_DATA
*CallbackData
1464 Function returns the value of the specified variable.
1466 @param Name A Null-terminated Unicode string that is
1467 the name of the vendor's variable.
1468 @param VendorGuid A unique identifier for the vendor.
1470 @return The payload of the variable.
1471 @retval NULL If the variable can't be read.
1477 IN EFI_GUID
*VendorGuid
1481 // Global variable in this program (defined in data.c)
1483 extern BM_MENU_OPTION BootOptionMenu
;
1484 extern BM_MENU_OPTION DriverOptionMenu
;
1485 extern BM_MENU_OPTION FsOptionMenu
;
1486 extern BM_MENU_OPTION ConsoleInpMenu
;
1487 extern BM_MENU_OPTION ConsoleOutMenu
;
1488 extern BM_MENU_OPTION ConsoleErrMenu
;
1489 extern BM_MENU_OPTION DirectoryMenu
;
1490 extern BM_MENU_OPTION DriverMenu
;
1491 extern BM_MENU_OPTION TerminalMenu
;
1492 extern BM_MENU_OPTION LegacyFDMenu
;
1493 extern BM_MENU_OPTION LegacyHDMenu
;
1494 extern BM_MENU_OPTION LegacyCDMenu
;
1495 extern BM_MENU_OPTION LegacyNETMenu
;
1496 extern BM_MENU_OPTION LegacyBEVMenu
;
1497 extern UINT16 TerminalType
[];
1498 extern COM_ATTR BaudRateList
[19];
1499 extern COM_ATTR DataBitsList
[4];
1500 extern COM_ATTR ParityList
[5];
1501 extern COM_ATTR StopBitsList
[3];
1502 extern EFI_GUID TerminalTypeGuid
[4];
1503 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1504 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1505 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1506 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1507 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1508 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1509 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1510 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1511 extern UINT16 mFlowControlType
[2];
1512 extern UINT32 mFlowControlValue
[2];
1514 // Shared IFR form update data
1516 extern VOID
*mStartOpCodeHandle
;
1517 extern VOID
*mEndOpCodeHandle
;
1518 extern EFI_IFR_GUID_LABEL
*mStartLabel
;
1519 extern EFI_IFR_GUID_LABEL
*mEndLabel
;