2 Header file for boot maintenance module.
4 Copyright (c) 2004 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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.
19 #include "BBSsupport.h"
21 #include "FrontPage.h"
24 // Constants which are variable names used to access variables
26 #define VarLegacyDevOrder L"LegacyDevOrder"
28 #define VarConOutMode L"ConOutMode"
31 // Guid of a NV Variable which store the information about the
32 // FD/HD/CD/NET/BEV order
34 #define EFI_LEGACY_DEV_ORDER_VARIABLE_GUID \
36 0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52} \
42 #define StrFloppy L"Floppy Drive #%02x"
43 #define StrHardDisk L"HardDisk Drive #%02x"
44 #define StrCDROM L"ATAPI CDROM Drive #%02x"
45 #define StrNET L"NET Drive #%02x"
46 #define StrBEV L"BEV Drive #%02x"
47 #define StrFloppyHelp L"Select Floppy Drive #%02x"
48 #define StrHardDiskHelp L"Select HardDisk Drive #%02x"
49 #define StrCDROMHelp L"Select ATAPI CDROM Drive #%02x"
50 #define StrNETHelp L"NET Drive #%02x"
51 #define StrBEVHelp L"BEV Drive #%02x"
54 // Variable created with this flag will be "Efi:...."
56 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
59 // Define Maxmim characters that will be accepted
62 #define MAX_CHAR_SIZE (MAX_CHAR * 2)
65 // Check to see if current build support option active feature of
68 #ifndef LOAD_OPTION_ACTIVE
69 #define LOAD_OPTION_ACTIVE 0x00000001
73 // Check to see if current build support force reconnect feature of
76 #ifndef LOAD_OPTION_FORCE_RECONNECT
77 #define LOAD_OPTION_FORCE_RECONNECT 0x00000002
80 extern EFI_GUID mBootMaintGuid
;
81 extern EFI_GUID mFileExplorerGuid
;
84 // These are the VFR compiler generated data representing our VFR data.
90 // Below are the number of options in Baudrate, Databits,
91 // Parity and Stopbits selection for serial ports.
93 #define BM_COM_ATTR_BUADRATE 19
94 #define BM_COM_ATTR_DATABITS 4
95 #define BM_COM_ATTR_PARITY 5
96 #define BM_COM_ATTR_STOPBITS 3
99 // Callback function helper
101 #define BMM_CALLBACK_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'b', 'c', 'k')
102 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
104 #define FE_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, FeConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
107 // Enumeration type definition
109 typedef UINT8 BBS_TYPE
;
144 } TYPE_OF_UPATE_MANNER
;
148 BOOT_FROM_FILE_STATE
,
149 ADD_BOOT_OPTION_STATE
,
150 ADD_DRIVER_OPTION_STATE
,
152 } FILE_EXPLORER_STATE
;
158 } FILE_EXPLORER_DISPLAY_CONTEXT
;
161 // All of the signatures that will be used in list structure
163 #define BM_MENU_OPTION_SIGNATURE EFI_SIGNATURE_32 ('m', 'e', 'n', 'u')
164 #define BM_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'a', 'd')
165 #define BM_CONSOLE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('c', 'n', 's', 'l')
166 #define BM_FILE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('f', 'i', 'l', 'e')
167 #define BM_HANDLE_OPTION_SIGNATURE EFI_SIGNATURE_32 ('h', 'n', 'd', 'l')
168 #define BM_TERMINAL_OPTION_SIGNATURE EFI_SIGNATURE_32 ('t', 'r', 'm', 'l')
169 #define BM_MENU_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('e', 'n', 't', 'r')
171 #define BM_LOAD_CONTEXT_SELECT 0x0
172 #define BM_CONSOLE_CONTEXT_SELECT 0x1
173 #define BM_FILE_CONTEXT_SELECT 0x2
174 #define BM_HANDLE_CONTEXT_SELECT 0x3
175 #define BM_TERMINAL_CONTEXT_SELECT 0x5
177 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
178 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
179 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
180 #define BM_LEGACY_DEV_CONTEXT_SELECT 0x9
183 // Buffer size for update data
185 #define UPDATE_DATA_SIZE 0x100000
188 // Namespace of callback keys used in display and file system navigation
190 #define MAX_BBS_OFFSET 0xE000
191 #define NET_OPTION_OFFSET 0xD800
192 #define BEV_OPTION_OFFSET 0xD000
193 #define FD_OPTION_OFFSET 0xC000
194 #define HD_OPTION_OFFSET 0xB000
195 #define CD_OPTION_OFFSET 0xA000
196 #define FILE_OPTION_OFFSET 0x8000
197 #define FILE_OPTION_MASK 0x7FFF
198 #define HANDLE_OPTION_OFFSET 0x7000
199 #define CONSOLE_OPTION_OFFSET 0x6000
200 #define TERMINAL_OPTION_OFFSET 0x5000
201 #define CONFIG_OPTION_OFFSET 0x1200
202 #define KEY_VALUE_OFFSET 0x1100
203 #define FORM_ID_OFFSET 0x1000
206 // VarOffset that will be used to create question
207 // all these values are computed from the structure
210 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
213 // Question Id of Zero is invalid, so add an offset to it
215 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
217 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
218 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
219 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
220 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
221 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
222 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
223 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
224 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
225 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
226 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
227 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
228 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
229 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
230 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
231 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
232 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
233 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
234 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
235 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
236 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
237 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
238 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
239 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
240 #define OPTION_ORDER_VAR_OFFSET VAR_OFFSET (OptionOrder)
241 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionToBeDeleted)
242 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
243 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
244 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
245 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
246 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
247 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
248 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
249 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
250 #define LEGACY_FD_VAR_OFFSET VAR_OFFSET (LegacyFD)
251 #define LEGACY_HD_VAR_OFFSET VAR_OFFSET (LegacyHD)
252 #define LEGACY_CD_VAR_OFFSET VAR_OFFSET (LegacyCD)
253 #define LEGACY_NET_VAR_OFFSET VAR_OFFSET (LegacyNET)
254 #define LEGACY_BEV_VAR_OFFSET VAR_OFFSET (LegacyBEV)
256 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
257 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
258 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
259 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
260 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
261 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
262 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
263 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
264 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
265 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
266 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
267 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
268 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
269 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
270 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
271 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
272 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
273 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
274 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
275 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
276 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
277 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
278 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
279 #define OPTION_ORDER_QUESTION_ID QUESTION_ID (OptionOrder)
280 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)
281 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
282 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
283 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
284 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
285 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
286 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
287 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
288 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
289 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
290 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
291 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
292 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
293 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
295 #define STRING_DEPOSITORY_NUMBER 8
300 // Serial Ports attributes, first one is the value for
301 // return from callback function, stringtoken is used to
302 // display the value properly
313 // Length = sizeof (UINT16) + SIZEOF (Data)
317 } BM_LEGACY_DEV_ORDER_CONTEXT
;
336 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
337 } BM_TERMINAL_CONTEXT
;
341 BOOLEAN LoadOptionModified
;
346 BOOLEAN ForceReconnect
;
347 UINTN OptionalDataSize
;
349 UINTN LoadOptionSize
;
353 UINT16 FilePathListLength
;
355 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
366 } BM_LEGACY_DEVICE_CONTEXT
;
374 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
375 } BM_CONSOLE_CONTEXT
;
384 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
385 EFI_FILE_HANDLE FHandle
;
387 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*Info
;
391 BOOLEAN IsRemovableMedia
;
393 BOOLEAN IsBootLegacy
;
398 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
411 UINT16
*DisplayString
;
413 EFI_STRING_ID DisplayStringToken
;
414 EFI_STRING_ID HelpStringToken
;
415 UINTN ContextSelection
;
416 VOID
*VariableContext
;
421 // Shared callback data.
425 BM_MENU_ENTRY
*MenuEntry
;
426 BM_HANDLE_CONTEXT
*HandleContext
;
427 BM_FILE_CONTEXT
*FileContext
;
428 BM_LOAD_CONTEXT
*LoadContext
;
429 BM_TERMINAL_CONTEXT
*TerminalContext
;
430 UINTN CurrentTerminal
;
434 // BMM main formset callback data.
436 EFI_HII_HANDLE BmmHiiHandle
;
437 EFI_HANDLE BmmDriverHandle
;
438 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess
;
439 EFI_FORM_ID BmmCurrentPageId
;
440 EFI_FORM_ID BmmPreviousPageId
;
441 BOOLEAN BmmAskSaveOrNot
;
442 BMM_FAKE_NV_DATA BmmFakeNvData
;
443 BMM_FAKE_NV_DATA BmmOldFakeNVData
;
446 // File explorer formset callback data.
448 EFI_HII_HANDLE FeHiiHandle
;
449 EFI_HANDLE FeDriverHandle
;
450 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess
;
451 FILE_EXPLORER_STATE FeCurrentState
;
452 FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext
;
453 FILE_EXPLORER_NV_DATA FeFakeNvData
;
456 typedef struct _STRING_LIST_NODE
{
457 EFI_STRING_ID StringToken
;
458 struct _STRING_LIST_NODE
*Next
;
461 typedef struct _STRING_DEPOSITORY
{
462 UINTN TotalNodeNumber
;
463 STRING_LIST_NODE
*CurrentNode
;
464 STRING_LIST_NODE
*ListHead
;
470 // For initializing File System menu
474 This function build the FsOptionMenu list which records all
475 available file system in the system. They includes all instances
476 of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
477 and all type of legacy boot device.
479 @param CallbackData BMM context data
481 @retval EFI_SUCCESS Success find the file system
482 @retval EFI_OUT_OF_RESOURCES Can not create menu entry
486 BOpt_FindFileSystem (
487 IN BMM_CALLBACK_DATA
*CallbackData
492 Find files under current directory
493 All files and sub-directories in current directory
494 will be stored in DirectoryMenu for future use.
496 @param FileOption Pointer for Dir to explore.
498 @retval TRUE Get files from current dir successfully.
499 @retval FALSE Can't get files from current dir.
504 IN BMM_CALLBACK_DATA
*CallbackData
,
505 IN BM_MENU_ENTRY
*MenuEntry
511 Find drivers that will be added as Driver#### variables from handles
512 in current system environment
513 All valid handles in the system except those consume SimpleFs, LoadFile
514 are stored in DriverMenu for future use.
518 @retval EFI_SUCCESS The function complets successfully.
519 @return Other value if failed to build the DriverMenu.
530 Build the BootOptionMenu according to BootOrder Variable.
531 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
535 @return The number of the Var Boot####.
539 BOpt_GetBootOptions (
540 IN BMM_CALLBACK_DATA
*CallbackData
545 Build up all DriverOptionMenu
547 @param CallbackData The BMM context data.
549 @return EFI_SUCESS The functin completes successfully.
550 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
555 BOpt_GetDriverOptions (
556 IN BMM_CALLBACK_DATA
*CallbackData
561 Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().
565 @retval EFI_SUCCESS The function complete successfully.
566 @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.
570 BOpt_GetLegacyOptions (
575 Free out resouce allocated from Legacy Boot Options.
583 BOpt_FreeLegacyOptions (
588 Free resources allocated in Allocate Rountine
590 @param FreeMenu Menu to be freed
597 BM_MENU_OPTION
*FreeMenu
603 Append file name to existing file name.
605 @param Str1 The existing file name
606 @param Str2 The file name to be appended
608 @return Allocate a new string to hold the appended result.
609 Caller is responsible to free the returned string.
613 BOpt_AppendFileName (
620 Check whether current FileName point to a valid
623 @param FileName File need to be checked.
625 @retval TRUE Is Efi Image
626 @retval FALSE Not a valid Efi Image
630 BOpt_IsEfiImageName (
636 Check whether current FileName point to a valid Efi Application
638 @param Dir Pointer to current Directory
639 @param FileName Pointer to current File name.
641 @retval TRUE Is a valid Efi Application
642 @retval FALSE not a valid Efi Application
647 IN EFI_FILE_HANDLE Dir
,
653 Get the Option Number that has not been allocated for use.
657 @return The available Option Number.
661 BOpt_GetBootOptionNumber (
667 Get the Option Number that is not in use.
671 @return The unused Option Number.
675 BOpt_GetDriverOptionNumber (
680 Create a menu entry give a Menu type.
682 @param MenuType The Menu type to be created.
685 @retval NULL If failed to create the menu.
690 BOpt_CreateMenuEntry (
695 Free up all resource allocated for a BM_MENU_ENTRY.
697 @param MenuEntry A pointer to BM_MENU_ENTRY.
703 BOpt_DestroyMenuEntry (
704 BM_MENU_ENTRY
*MenuEntry
708 Get the Menu Entry from the list in Menu Entry List.
710 If MenuNumber is great or equal to the number of Menu
711 Entry in the list, then ASSERT.
713 @param MenuOption The Menu Entry List to read the menu entry.
714 @param MenuNumber The index of Menu Entry.
716 @return The Menu Entry.
721 BM_MENU_OPTION
*MenuOption
,
726 // Locate all serial io devices for console
729 Build a list containing all serial devices
732 @param VOID EDES_TODO: Add parameter description
734 @return EDES_TODO: Add description for return value
743 // Initializing Console menu
746 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
751 @retval EFI_SUCCESS The function always complete successfully.
760 // Get current mode information
763 Get mode number according to column and row
766 @param CallbackData The BMM context data.
773 IN BMM_CALLBACK_DATA
*CallbackData
777 // Cleaning up console menu
780 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
783 @param VOID EDES_TODO: Add parameter description
785 @retval EFI_SUCCESS The function always complete successfully.
793 Update the device path that describing a terminal device
794 based on the new BaudRate, Data Bits, parity and Stop Bits
803 ChangeVariableDevicePath (
804 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
808 Update the multi-instance device path of Terminal Device based on
809 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
810 device path in the Terminal Device in TerminalMenu is also updated.
812 @param DevicePath The multi-instance device path.
813 @param ChangeTerminal TRUE, then device path in the Terminal Device
814 in TerminalMenu is also updated; FALSE, no update.
816 @return EFI_SUCCESS The function completes successfully.
820 ChangeTerminalDevicePath (
821 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
822 BOOLEAN ChangeTerminal
825 // Variable operation by menu selection
828 This function create a currently loaded Boot Option from
829 the BMM. It then appends this Boot Option to the end of
830 the "BootOrder" list. It also append this Boot Opotion to the end
833 @param CallbackData The BMM context data.
834 @param NvRamMap The file explorer formset internal state.
836 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
837 @retval EFI_SUCCESS If function completes successfully.
841 Var_UpdateBootOption (
842 IN BMM_CALLBACK_DATA
*CallbackData
,
843 IN FILE_EXPLORER_NV_DATA
*NvRamMap
847 Delete Boot Option that represent a Deleted state in BootOptionMenu.
848 After deleting this boot option, call Var_ChangeBootOrder to
849 make sure BootOrder is in valid state.
852 @param VOID EDES_TODO: Add parameter description
854 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
855 BM_LOAD_CONTEXT marked for deletion is deleted
856 @return Others If failed to update the "BootOrder" variable after deletion.
865 After any operation on Boot####, there will be a discrepancy in BootOrder.
866 Since some are missing but in BootOrder, while some are present but are
867 not reflected by BootOrder. Then a function rebuild BootOrder from
868 scratch by content from BootOptionMenu is needed.
873 @retval EFI_SUCCESS The boot order is updated successfully.
874 @return EFI_STATUS other than EFI_SUCCESS if failed to
875 Set the "BootOrder" EFI Variable.
879 Var_ChangeBootOrder (
884 This function create a currently loaded Drive Option from
885 the BMM. It then appends this Driver Option to the end of
886 the "DriverOrder" list. It append this Driver Opotion to the end
889 @param CallbackData The BMM context data.
890 @param HiiHandle The HII handle associated with the BMM formset.
891 @param DescriptionData The description of this driver option.
892 @param OptionalData The optional load option.
893 @param ForceReconnect EDES_TODO: Add parameter description
895 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
896 @retval EFI_SUCCESS If function completes successfully.
900 Var_UpdateDriverOption (
901 IN BMM_CALLBACK_DATA
*CallbackData
,
902 IN EFI_HII_HANDLE HiiHandle
,
903 IN UINT16
*DescriptionData
,
904 IN UINT16
*OptionalData
,
905 IN UINT8 ForceReconnect
909 Delete Load Option that represent a Deleted state in BootOptionMenu.
910 After deleting this Driver option, call Var_ChangeDriverOrder to
911 make sure DriverOrder is in valid state.
916 @retval EFI_SUCCESS Load Option is successfully updated.
917 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
922 Var_DelDriverOption (
927 After any operation on Driver####, there will be a discrepancy in
928 DriverOrder. Since some are missing but in DriverOrder, while some
929 are present but are not reflected by DriverOrder. Then a function
930 rebuild DriverOrder from scratch by content from DriverOptionMenu is
936 @retval EFI_SUCCESS The driver order is updated successfully.
937 @return EFI_STATUS other than EFI_SUCCESS if failed to
938 Set the "DriverOrder" EFI Variable.
942 Var_ChangeDriverOrder (
947 This function delete and build multi-instance device path ConIn
953 @retval EFI_SUCCESS The function complete successfully.
954 @return The EFI variable can be saved. See gRT->SetVariable
955 for detail return information.
958 Var_UpdateConsoleInpOption (
963 This function delete and build multi-instance device path ConOut
969 @retval EFI_SUCCESS The function complete successfully.
970 @return The EFI variable can be saved. See gRT->SetVariable
971 for detail return information.
974 Var_UpdateConsoleOutOption (
979 This function delete and build multi-instance device path ErrOut
985 @retval EFI_SUCCESS The function complete successfully.
986 @return The EFI variable can be saved. See gRT->SetVariable
987 for detail return information.
990 Var_UpdateErrorOutOption (
995 Update the device path of "ConOut", "ConIn" and "ErrOut"
996 based on the new BaudRate, Data Bits, parity and Stop Bits
1005 Var_UpdateAllConsoleOption (
1010 This function update the "BootNext" EFI Variable. If there is
1011 no "BootNex" specified in BMM, this EFI Variable is deleted.
1012 It also update the BMM context data specified the "BootNext"
1015 @param CallbackData The BMM context data.
1017 @retval EFI_SUCCESS The function complete successfully.
1018 @return The EFI variable can be saved. See gRT->SetVariable
1019 for detail return information.
1023 Var_UpdateBootNext (
1024 IN BMM_CALLBACK_DATA
*CallbackData
1028 This function update the "BootOrder" EFI Variable based on
1029 BMM Formset's NV map. It then refresh BootOptionMenu
1030 with the new "BootOrder" list.
1032 @param CallbackData The BMM context data.
1034 @retval EFI_SUCCESS The function complete successfully.
1035 @retval EFI_SUCCESS Not enough memory to complete the function.
1036 @return The EFI variable can be saved. See gRT->SetVariable
1037 for detail return information.
1041 Var_UpdateBootOrder (
1042 IN BMM_CALLBACK_DATA
*CallbackData
1046 This function update the "DriverOrder" EFI Variable based on
1047 BMM Formset's NV map. It then refresh DriverOptionMenu
1048 with the new "DriverOrder" list.
1050 @param CallbackData The BMM context data.
1052 @retval EFI_SUCCESS The function complete successfully.
1053 @retval EFI_SUCCESS Not enough memory to complete the function.
1054 @return The EFI variable can be saved. See gRT->SetVariable
1055 for detail return information.
1059 Var_UpdateDriverOrder (
1060 IN BMM_CALLBACK_DATA
*CallbackData
1064 Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable
1065 is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid
1068 @param CallbackData The context data for BMM.
1070 @return EFI_SUCCESS The function completed successfully.
1071 @retval EFI_NOT_FOUND If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can be found.
1075 Var_UpdateBBSOption (
1076 IN BMM_CALLBACK_DATA
*CallbackData
1080 Update the Text Mode of Console.
1082 @param CallbackData The context data for BMM.
1084 @retval EFI_SUCCSS If the Text Mode of Console is updated.
1085 @return Other value if the Text Mode of Console is not updated.
1090 IN BMM_CALLBACK_DATA
*CallbackData
1094 // Following are page create and refresh functions
1097 Refresh the global UpdateData structure.
1110 Clean up the dynamic opcode at label and form specified by
1113 @param LabelId It is both the Form ID and Label ID for
1115 @param CallbackData The BMM context data.
1123 IN BMM_CALLBACK_DATA
*CallbackData
1127 Create a lit of boot option from global BootOptionMenu. It
1128 allow user to delete the boot option.
1130 @param CallbackData The BMM context data.
1137 IN BMM_CALLBACK_DATA
*CallbackData
1141 Create a lit of driver option from global DriverMenu.
1143 @param CallbackData The BMM context data.
1149 UpdateDrvAddHandlePage (
1150 IN BMM_CALLBACK_DATA
*CallbackData
1154 Create a lit of driver option from global DriverOptionMenu. It
1155 allow user to delete the driver option.
1158 @param CallbackData The BMM context data.
1165 IN BMM_CALLBACK_DATA
*CallbackData
1169 Prepare the page to allow user to add description for
1172 @param CallbackData The BMM context data.
1178 UpdateDriverAddHandleDescPage (
1179 IN BMM_CALLBACK_DATA
*CallbackData
1183 Dispatch the correct update page function to call based on
1186 @param UpdatePageId The form ID.
1187 @param CallbackData The BMM context data.
1194 IN UINT16 UpdatePageId
,
1195 IN BMM_CALLBACK_DATA
*CallbackData
1199 Create the dynamic page to allow user to set
1200 the "BootNext" vaule.
1202 @param CallbackData The BMM context data.
1208 UpdateBootNextPage (
1209 IN BMM_CALLBACK_DATA
*CallbackData
1213 Create the dynamic page to allow user to set
1214 the "TimeOut" vaule.
1216 @param CallbackData The BMM context data.
1223 IN BMM_CALLBACK_DATA
*CallbackData
1227 Create the dynamic page which allows user to
1228 set the property such as Baud Rate, Data Bits,
1229 Parity, Stop Bits, Terminal Type.
1231 @param CallbackData The BMM context data.
1237 UpdateTerminalPage (
1238 IN BMM_CALLBACK_DATA
*CallbackData
1242 Refresh the text mode page
1245 @param CallbackData The BMM context data.
1252 IN BMM_CALLBACK_DATA
*CallbackData
1256 Create a list of Goto Opcode for all terminal devices logged
1257 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
1259 @param CallbackData The BMM context data.
1266 IN BMM_CALLBACK_DATA
*CallbackData
1270 Create a dynamic page so that Legacy Device boot order
1271 can be set for specified device type.
1273 @param UpdatePageId The form ID. It also spefies the legacy device type.
1274 @param CallbackData The BMM context data.
1280 UpdateSetLegacyDeviceOrderPage (
1281 IN UINT16 UpdatePageId
,
1282 IN BMM_CALLBACK_DATA
*CallbackData
1288 Function opens and returns a file handle to the root directory of a volume.
1291 @param DeviceHandle - A handle for a device
1293 @return A valid file handle or NULL is returned
1298 IN EFI_HANDLE DeviceHandle
1303 Function gets the file system information from an open file descriptor,
1304 and stores it in a buffer allocated from pool.
1307 @param FHand The file handle.
1309 @return A pointer to a buffer with file information.
1310 @retval NULL is returned if failed to get Vaolume Label Info.
1313 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*
1314 EfiLibFileSystemVolumeLabelInfo (
1315 IN EFI_FILE_HANDLE FHand
1320 Function gets the file information from an open file descriptor, and stores it
1321 in a buffer allocated from pool.
1323 @param FHand File Handle.
1325 @return A pointer to a buffer with file information or NULL is returned
1330 IN EFI_FILE_HANDLE FHand
1335 change a Unicode string t ASCII string
1338 @param UStr Unicode string
1339 Lenght - most possible length of AStr
1340 @param Length The length of UStr.
1341 @param AStr ASCII string to pass out
1343 @return Actual length
1354 This function converts an input device structure to a Unicode string.
1356 @param DevPath A pointer to the device path structure.
1358 @return A new allocated Unicode string that represents the device path.
1363 EFI_DEVICE_PATH_PROTOCOL
*DevPath
1368 Find the first instance of this Protocol
1369 in the system and return it's interface
1372 @param ProtocolGuid Provides the protocol to search for
1373 @param Interface On return, a pointer to the first interface
1374 that matches ProtocolGuid
1376 @retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
1377 @retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
1381 EfiLibLocateProtocol (
1382 IN EFI_GUID
*ProtocolGuid
,
1383 OUT VOID
**Interface
1387 Adjusts the size of a previously allocated buffer.
1390 @param OldPool - A pointer to the buffer whose size is being adjusted.
1391 @param OldSize - The size of the current buffer.
1392 @param NewSize - The size of the new buffer.
1394 @return The newly allocated buffer.
1395 @retval NULL Allocation failed.
1406 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
1407 buffer, and the size of the buffer. If failure return NULL.
1409 @param Name String part of EFI variable name
1410 @param VendorGuid GUID part of EFI variable name
1411 @param VariableSize Returns the size of the EFI variable that was read
1413 @return Dynamically allocated memory that contains a copy of the EFI variable.
1414 @return Caller is responsible freeing the buffer.
1415 @retval NULL Variable was not read
1419 BdsLibGetVariableAndSize (
1421 IN EFI_GUID
*VendorGuid
,
1426 Function deletes the variable specified by VarName and VarGuid.
1429 @param VarName - A Null-terminated Unicode string that is
1430 the name of the vendor's variable.
1432 @param VendorGuid - A unique identifier for the vendor.
1434 @retval EFI_SUCCESS The variable was found and removed
1435 @retval EFI_UNSUPPORTED The variable store was inaccessible
1436 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
1437 @retval EFI_NOT_FOUND The variable was not found
1441 EfiLibDeleteVariable (
1443 IN EFI_GUID
*VarGuid
1449 @param Src The source.
1451 @return A new string which is duplicated copy of the source.
1452 @retval NULL If there is not enough memory.
1461 Function is used to determine the number of device path instances
1462 that exist in a device path.
1465 @param DevicePath A pointer to a device path data structure.
1467 @return This function counts and returns the number of device path instances
1472 EfiDevicePathInstanceCount (
1473 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1477 Create string tokens for a menu from its help strings and display strings
1480 @param CallbackData The BMM context data.
1481 @param HiiHandle Hii Handle of the package to be updated.
1482 @param MenuOption The Menu whose string tokens need to be created
1484 @retval EFI_SUCCESS string tokens created successfully
1485 @retval others contain some errors
1489 CreateMenuStringToken (
1490 IN BMM_CALLBACK_DATA
*CallbackData
,
1491 IN EFI_HII_HANDLE HiiHandle
,
1492 IN BM_MENU_OPTION
*MenuOption
1496 Get a string from the Data Hub record based on
1499 @param DevPath The device Path.
1501 @return A string located from the Data Hub records based on
1503 @retval NULL If failed to get the String from Data Hub.
1507 EfiLibStrFromDatahub (
1508 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1512 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
1513 specified by DeviceType.
1515 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
1517 @param OptionIndex Returns the index number (#### in Boot####).
1518 @param OptionSize Return the size of the Boot### variable.
1524 GetLegacyBootOptionVar (
1525 IN UINTN DeviceType
,
1526 OUT UINTN
*OptionIndex
,
1527 OUT UINTN
*OptionSize
1531 Initialize the Boot Maintenance Utitliy
1534 @param VOID EDES_TODO: Add parameter description
1536 @retval EFI_SUCCESS utility ended successfully
1537 @retval others contain some errors
1546 Start boot maintenance manager
1551 @retval EFI_SUCCESS If BMM is invoked successfully.
1552 @return Other value if BMM return unsuccessfully.
1561 Intialize all the string depositories.
1570 InitializeStringDepository (
1575 Fetch a usable string node from the string depository and return the string token.
1578 @param CallbackData EDES_TODO: Add parameter description
1579 @param StringDepository - Pointer of the string depository.
1581 @retval EFI_STRING_ID String token.
1585 GetStringTokenFromDepository (
1586 IN BMM_CALLBACK_DATA
*CallbackData
,
1587 IN STRING_DEPOSITORY
*StringDepository
1591 Reclaim string depositories by moving the current node pointer to list head..
1600 ReclaimStringDepository (
1605 Release resource for all the string depositories.
1614 CleanUpStringDepository (
1619 Function handling request to apply changes for BMM pages.
1622 @param Private - Pointer to callback data buffer.
1623 @param CurrentFakeNVMap - Pointer to buffer holding data of various values used by BMM
1624 @param FormId - ID of the form which has sent the request to apply change.
1626 @retval EFI_SUCCESS Change successfully applied.
1627 @retval Other Error occurs while trying to apply changes.
1631 ApplyChangeHandler (
1632 IN BMM_CALLBACK_DATA
*Private
,
1633 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
1634 IN EFI_FORM_ID FormId
1638 Discard all changes done to the BMM pages such as Boot Order change,
1639 Driver order change.
1641 @param Private The BMM context data.
1642 @param CurrentFakeNVMap The current Fack NV Map.
1648 DiscardChangeHandler (
1649 IN BMM_CALLBACK_DATA
*Private
,
1650 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1654 Dispatch the display to the next page based on NewPageId.
1656 @param Private The BMM context data.
1657 @param NewPageId The original page ID.
1664 BMM_CALLBACK_DATA
*Private
,
1669 Boot a file selected by user at File Expoloer of BMM.
1671 @param FileContext The file context data, which contains the device path
1672 of the file to be boot from.
1674 @retval EFI_SUCCESS The function completed successfull.
1675 @retun Other value if the boot from the file fails.
1680 IN BM_FILE_CONTEXT
*FileContext
1684 Update the file explower page with the refershed file system.
1687 @param CallbackData BMM context data
1688 @param KeyValue Key value to identify the type of data to expect.
1690 @retval TRUE Inform the caller to create a callback packet to exit file explorer.
1691 @retval FALSE Indicate that there is no need to exit file explorer.
1695 UpdateFileExplorer (
1696 IN BMM_CALLBACK_DATA
*CallbackData
,
1701 This function processes the results of changes in configuration.
1702 When user select a interactive opcode, this callback will be triggered.
1703 Based on the Question(QuestionId) that triggers the callback, the corresponding
1704 actions is performed. It handles:
1706 1) the addition of boot option.
1707 2) the addition of driver option.
1708 3) exit from file browser
1709 4) update of file content if a dir is selected.
1710 5) boot the file if a file is selected in "boot from file"
1713 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1714 @param Action Specifies the type of action taken by the browser.
1715 @param QuestionId A unique value which is sent to the original exporting driver
1716 so that it can identify the type of data to expect.
1717 @param Type The type of value for the question.
1718 @param Value A pointer to the data being sent to the original exporting driver.
1719 @param ActionRequest On return, points to the action requested by the callback function.
1721 @retval EFI_SUCCESS The callback successfully handled the action.
1722 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1723 @retval EFI_DEVICE_ERROR The variable could not be saved.
1724 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1729 FileExplorerCallback (
1730 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1731 IN EFI_BROWSER_ACTION Action
,
1732 IN EFI_QUESTION_ID QuestionId
,
1734 IN EFI_IFR_TYPE_VALUE
*Value
,
1735 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1739 Dispatch BMM formset and FileExplorer formset.
1742 @param CallbackData The BMM context data.
1744 @retval EFI_SUCCESS If function complete successfully.
1745 @retturn Other value if the Setup Browser process BMM's pages and
1746 return unsuccessfully.
1751 IN BMM_CALLBACK_DATA
*CallbackData
1755 Function returns the value of the specified variable.
1758 @param Name A Null-terminated Unicode string that is
1759 the name of the vendor's variable.
1760 @param VendorGuid A unique identifier for the vendor.
1762 @return The payload of the variable.
1763 @retval NULL If the variable can't be read.
1769 IN EFI_GUID
*VendorGuid
1773 // Global variable in this program (defined in data.c)
1775 extern BM_MENU_OPTION BootOptionMenu
;
1776 extern BM_MENU_OPTION DriverOptionMenu
;
1777 extern BM_MENU_OPTION FsOptionMenu
;
1778 extern BM_MENU_OPTION ConsoleInpMenu
;
1779 extern BM_MENU_OPTION ConsoleOutMenu
;
1780 extern BM_MENU_OPTION ConsoleErrMenu
;
1781 extern BM_MENU_OPTION DirectoryMenu
;
1782 extern BM_MENU_OPTION DriverMenu
;
1783 extern BM_MENU_OPTION TerminalMenu
;
1784 extern BM_MENU_OPTION LegacyFDMenu
;
1785 extern BM_MENU_OPTION LegacyHDMenu
;
1786 extern BM_MENU_OPTION LegacyCDMenu
;
1787 extern BM_MENU_OPTION LegacyNETMenu
;
1788 extern BM_MENU_OPTION LegacyBEVMenu
;
1789 extern UINT16 TerminalType
[];
1790 extern COM_ATTR BaudRateList
[19];
1791 extern COM_ATTR DataBitsList
[4];
1792 extern COM_ATTR ParityList
[5];
1793 extern COM_ATTR StopBitsList
[3];
1794 extern EFI_GUID TerminalTypeGuid
[4];
1795 extern EFI_HII_UPDATE_DATA gUpdateData
;
1796 extern STRING_DEPOSITORY
*FileOptionStrDepository
;
1797 extern STRING_DEPOSITORY
*ConsoleOptionStrDepository
;
1798 extern STRING_DEPOSITORY
*BootOptionStrDepository
;
1799 extern STRING_DEPOSITORY
*BootOptionHelpStrDepository
;
1800 extern STRING_DEPOSITORY
*DriverOptionStrDepository
;
1801 extern STRING_DEPOSITORY
*DriverOptionHelpStrDepository
;
1802 extern STRING_DEPOSITORY
*TerminalStrDepository
;
1803 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[];
1804 extern EFI_GUID EfiLegacyDevOrderGuid
;