]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Library / BootMaintenanceManagerUiLib / BootMaintenanceManager.h
1 /** @file
2 Header file for boot maintenance module.
3
4 Copyright (c) 2004 - 2018, 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
9
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.
12
13 **/
14
15 #ifndef _BOOT_MAINT_H_
16 #define _BOOT_MAINT_H_
17
18 #include "FormGuid.h"
19
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>
25
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>
31 #include <Protocol/FormBrowserEx2.h>
32
33 #include <Library/PrintLib.h>
34 #include <Library/DebugLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/UefiRuntimeServicesTableLib.h>
40 #include <Library/DevicePathLib.h>
41 #include <Library/HiiLib.h>
42 #include <Library/UefiHiiServicesLib.h>
43 #include <Library/UefiBootManagerLib.h>
44 #include <Library/FileExplorerLib.h>
45 #include "BootMaintenanceManagerCustomizedUi.h"
46
47 #pragma pack(1)
48
49 ///
50 /// HII specific Vendor Device Path definition.
51 ///
52 typedef struct {
53 VENDOR_DEVICE_PATH VendorDevicePath;
54 EFI_DEVICE_PATH_PROTOCOL End;
55 } HII_VENDOR_DEVICE_PATH;
56 #pragma pack()
57
58 //
59 // Constants which are variable names used to access variables
60 //
61
62 #define VAR_CON_OUT_MODE L"ConOutMode"
63
64 //
65 // Variable created with this flag will be "Efi:...."
66 //
67 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
68
69 extern EFI_GUID mBootMaintGuid;
70 extern CHAR16 mBootMaintStorageName[];
71 //
72 // These are the VFR compiler generated data representing our VFR data.
73 //
74 extern UINT8 BootMaintenanceManagerBin[];
75
76 //
77 // Below are the number of options in Baudrate, Databits,
78 // Parity and Stopbits selection for serial ports.
79 //
80 #define BM_COM_ATTR_BUADRATE 19
81 #define BM_COM_ATTR_DATABITS 4
82 #define BM_COM_ATTR_PARITY 5
83 #define BM_COM_ATTR_STOPBITS 3
84
85 //
86 // Callback function helper
87 //
88 #define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
89 #define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
90
91 //
92 // Enumeration type definition
93 //
94 typedef UINT8 BBS_TYPE;
95
96 typedef enum _TYPE_OF_TERMINAL {
97 TerminalTypePcAnsi = 0,
98 TerminalTypeVt100,
99 TerminalTypeVt100Plus,
100 TerminalTypeVtUtf8,
101 TerminalTypeTtyTerm
102 } TYPE_OF_TERMINAL;
103
104 //
105 // All of the signatures that will be used in list structure
106 //
107 #define BM_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
108 #define BM_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('l', 'o', 'a', 'd')
109 #define BM_CONSOLE_OPTION_SIGNATURE SIGNATURE_32 ('c', 'n', 's', 'l')
110 #define BM_FILE_OPTION_SIGNATURE SIGNATURE_32 ('f', 'i', 'l', 'e')
111 #define BM_HANDLE_OPTION_SIGNATURE SIGNATURE_32 ('h', 'n', 'd', 'l')
112 #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
113 #define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
114
115 #define BM_LOAD_CONTEXT_SELECT 0x0
116 #define BM_CONSOLE_CONTEXT_SELECT 0x1
117 #define BM_FILE_CONTEXT_SELECT 0x2
118 #define BM_HANDLE_CONTEXT_SELECT 0x3
119 #define BM_TERMINAL_CONTEXT_SELECT 0x5
120
121 #define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
122 #define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
123 #define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
124
125 //
126 // Buffer size for update data
127 //
128 #define UPDATE_DATA_SIZE 0x100000
129
130 //
131 // Namespace of callback keys used in display and file system navigation
132 //
133 #define MAX_BBS_OFFSET 0xE000
134 #define NET_OPTION_OFFSET 0xD800
135 #define BEV_OPTION_OFFSET 0xD000
136 #define FD_OPTION_OFFSET 0xC000
137 #define HD_OPTION_OFFSET 0xB000
138 #define CD_OPTION_OFFSET 0xA000
139 #define FILE_OPTION_OFFSET 0x8000
140 #define FILE_OPTION_MASK 0x7FFF
141 #define HANDLE_OPTION_OFFSET 0x7000
142 #define CONSOLE_OPTION_OFFSET 0x6000
143 #define TERMINAL_OPTION_OFFSET 0x5000
144 #define CONFIG_OPTION_OFFSET 0x1200
145 #define KEY_VALUE_OFFSET 0x1100
146 #define FORM_ID_OFFSET 0x1000
147
148 //
149 // VarOffset that will be used to create question
150 // all these values are computed from the structure
151 // defined below
152 //
153 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
154
155 //
156 // Question Id of Zero is invalid, so add an offset to it
157 //
158 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
159
160 #define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
161 #define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
162 #define COM1_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM1BaudRate)
163 #define COM1_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM1DataRate)
164 #define COM1_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM1StopBits)
165 #define COM1_PARITY_VAR_OFFSET VAR_OFFSET (COM1Parity)
166 #define COM1_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
167 #define COM2_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COM2BaudRate)
168 #define COM2_DATA_RATE_VAR_OFFSET VAR_OFFSET (COM2DataRate)
169 #define COM2_STOP_BITS_VAR_OFFSET VAR_OFFSET (COM2StopBits)
170 #define COM2_PARITY_VAR_OFFSET VAR_OFFSET (COM2Parity)
171 #define COM2_TERMINAL_VAR_OFFSET VAR_OFFSET (COM2TerminalType)
172 #define DRV_ADD_HANDLE_DESC_VAR_OFFSET VAR_OFFSET (DriverAddHandleDesc)
173 #define DRV_ADD_ACTIVE_VAR_OFFSET VAR_OFFSET (DriverAddActive)
174 #define DRV_ADD_RECON_VAR_OFFSET VAR_OFFSET (DriverAddForceReconnect)
175 #define CON_IN_COM1_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM1)
176 #define CON_IN_COM2_VAR_OFFSET VAR_OFFSET (ConsoleInputCOM2)
177 #define CON_OUT_COM1_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM1)
178 #define CON_OUT_COM2_VAR_OFFSET VAR_OFFSET (ConsoleOutputCOM2)
179 #define CON_ERR_COM1_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM1)
180 #define CON_ERR_COM2_VAR_OFFSET VAR_OFFSET (ConsoleErrorCOM2)
181 #define CON_MODE_VAR_OFFSET VAR_OFFSET (ConsoleOutMode)
182 #define CON_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleCheck)
183 #define CON_IN_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleInCheck)
184 #define CON_OUT_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleOutCheck)
185 #define CON_ERR_DEVICE_VAR_OFFSET VAR_OFFSET (ConsoleErrCheck)
186 #define BOOT_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (BootOptionOrder)
187 #define DRIVER_OPTION_ORDER_VAR_OFFSET VAR_OFFSET (DriverOptionOrder)
188 #define BOOT_OPTION_DEL_VAR_OFFSET VAR_OFFSET (BootOptionDel)
189 #define DRIVER_OPTION_DEL_VAR_OFFSET VAR_OFFSET (DriverOptionDel)
190 #define DRIVER_ADD_OPTION_VAR_OFFSET VAR_OFFSET (DriverAddHandleOptionalData)
191 #define COM_BAUD_RATE_VAR_OFFSET VAR_OFFSET (COMBaudRate)
192 #define COM_DATA_RATE_VAR_OFFSET VAR_OFFSET (COMDataRate)
193 #define COM_STOP_BITS_VAR_OFFSET VAR_OFFSET (COMStopBits)
194 #define COM_PARITY_VAR_OFFSET VAR_OFFSET (COMParity)
195 #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
196 #define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
197
198 #define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
199 #define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
200 #define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
201 #define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
202 #define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
203 #define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
204 #define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
205 #define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
206 #define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
207 #define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
208 #define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
209 #define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
210 #define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
211 #define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
212 #define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
213 #define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
214 #define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
215 #define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
216 #define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
217 #define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
218 #define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
219 #define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
220 #define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
221 #define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
222 #define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
223 #define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
224 #define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
225 #define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
226 #define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
227 #define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
228 #define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
229 #define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
230 #define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
231 #define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
232 #define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
233 #define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
234 #define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
235
236 #define STRING_DEPOSITORY_NUMBER 8
237
238 #define NONE_BOOTNEXT_VALUE (0xFFFF + 1)
239
240 ///
241 /// Serial Ports attributes, first one is the value for
242 /// return from callback function, stringtoken is used to
243 /// display the value properly
244 ///
245 typedef struct {
246 UINTN Value;
247 UINT16 StringToken;
248 } COM_ATTR;
249
250 typedef struct {
251 UINT64 BaudRate;
252 UINT8 DataBits;
253 UINT8 Parity;
254 UINT8 StopBits;
255
256 UINT8 BaudRateIndex;
257 UINT8 DataBitsIndex;
258 UINT8 ParityIndex;
259 UINT8 StopBitsIndex;
260
261 UINT8 FlowControl;
262
263 UINT8 IsConIn;
264 UINT8 IsConOut;
265 UINT8 IsStdErr;
266 UINT8 TerminalType;
267
268 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
269 } BM_TERMINAL_CONTEXT;
270
271 typedef struct {
272 BOOLEAN IsBootNext;
273 BOOLEAN Deleted;
274
275 BOOLEAN IsLegacy;
276
277 UINT32 Attributes;
278 UINT16 FilePathListLength;
279 UINT16 *Description;
280 EFI_DEVICE_PATH_PROTOCOL *FilePathList;
281 UINT8 *OptionalData;
282 } BM_LOAD_CONTEXT;
283
284 typedef struct {
285
286 BOOLEAN IsActive;
287
288 BOOLEAN IsTerminal;
289
290 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
291 } BM_CONSOLE_CONTEXT;
292
293 typedef struct {
294 UINTN Column;
295 UINTN Row;
296 } CONSOLE_OUT_MODE;
297
298 typedef struct {
299 EFI_HANDLE Handle;
300 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
301 EFI_FILE_HANDLE FHandle;
302 UINT16 *FileName;
303 EFI_FILE_SYSTEM_VOLUME_LABEL *Info;
304
305 BOOLEAN IsRoot;
306 BOOLEAN IsDir;
307 BOOLEAN IsRemovableMedia;
308 BOOLEAN IsLoadFile;
309 BOOLEAN IsBootLegacy;
310 } BM_FILE_CONTEXT;
311
312 typedef struct {
313 EFI_HANDLE Handle;
314 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
315 } BM_HANDLE_CONTEXT;
316
317 typedef struct {
318 UINTN Signature;
319 LIST_ENTRY Head;
320 UINTN MenuNumber;
321 } BM_MENU_OPTION;
322
323 typedef struct {
324 UINTN Signature;
325 LIST_ENTRY Link;
326 UINTN OptionNumber;
327 UINT16 *DisplayString;
328 UINT16 *HelpString;
329 EFI_STRING_ID DisplayStringToken;
330 EFI_STRING_ID HelpStringToken;
331 UINTN ContextSelection;
332 VOID *VariableContext;
333 } BM_MENU_ENTRY;
334
335 typedef struct {
336
337 UINTN Signature;
338
339 EFI_HII_HANDLE BmmHiiHandle;
340 EFI_HANDLE BmmDriverHandle;
341 ///
342 /// Boot Maintenance Manager Produced protocols
343 ///
344 EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess;
345 EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
346
347 BM_MENU_ENTRY *MenuEntry;
348 BM_HANDLE_CONTEXT *HandleContext;
349 BM_FILE_CONTEXT *FileContext;
350 BM_LOAD_CONTEXT *LoadContext;
351 BM_TERMINAL_CONTEXT *TerminalContext;
352 UINTN CurrentTerminal;
353 BBS_TYPE BbsType;
354
355 //
356 // BMM main formset callback data.
357 //
358
359 EFI_FORM_ID BmmCurrentPageId;
360 EFI_FORM_ID BmmPreviousPageId;
361 BOOLEAN BmmAskSaveOrNot;
362 BMM_FAKE_NV_DATA BmmFakeNvData;
363 BMM_FAKE_NV_DATA BmmOldFakeNVData;
364
365 } BMM_CALLBACK_DATA;
366
367 /**
368
369 Find drivers that will be added as Driver#### variables from handles
370 in current system environment
371 All valid handles in the system except those consume SimpleFs, LoadFile
372 are stored in DriverMenu for future use.
373
374 @retval EFI_SUCCESS The function complets successfully.
375 @return Other value if failed to build the DriverMenu.
376
377 **/
378 EFI_STATUS
379 BOpt_FindDrivers (
380 VOID
381 );
382
383 /**
384
385 Build the BootOptionMenu according to BootOrder Variable.
386 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
387
388 @param CallbackData The BMM context data.
389
390 @return The number of the Var Boot####.
391
392 **/
393 EFI_STATUS
394 BOpt_GetBootOptions (
395 IN BMM_CALLBACK_DATA *CallbackData
396 );
397
398 /**
399
400 Build up all DriverOptionMenu
401
402 @param CallbackData The BMM context data.
403
404 @return EFI_SUCESS The functin completes successfully.
405 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
406
407
408 **/
409 EFI_STATUS
410 BOpt_GetDriverOptions (
411 IN BMM_CALLBACK_DATA *CallbackData
412 );
413
414 /**
415 Free resources allocated in Allocate Rountine.
416
417 @param FreeMenu Menu to be freed
418
419 **/
420 VOID
421 BOpt_FreeMenu (
422 BM_MENU_OPTION *FreeMenu
423 );
424
425 /**
426
427 Get the Option Number that has not been allocated for use.
428
429 @param Type The type of Option.
430
431 @return The available Option Number.
432
433 **/
434 UINT16
435 BOpt_GetOptionNumber (
436 CHAR16 *Type
437 );
438
439 /**
440
441 Get the Option Number for Boot#### that does not used.
442
443 @return The available Option Number.
444
445 **/
446 UINT16
447 BOpt_GetBootOptionNumber (
448 VOID
449 );
450
451 /**
452
453 Get the Option Number for Driver#### that does not used.
454
455 @return The unused Option Number.
456
457 **/
458 UINT16
459 BOpt_GetDriverOptionNumber (
460 VOID
461 );
462
463 /**
464 Create a menu entry give a Menu type.
465
466 @param MenuType The Menu type to be created.
467
468
469 @retval NULL If failed to create the menu.
470 @return The menu.
471
472 **/
473 BM_MENU_ENTRY *
474 BOpt_CreateMenuEntry (
475 UINTN MenuType
476 );
477
478 /**
479 Free up all resource allocated for a BM_MENU_ENTRY.
480
481 @param MenuEntry A pointer to BM_MENU_ENTRY.
482
483 **/
484 VOID
485 BOpt_DestroyMenuEntry (
486 BM_MENU_ENTRY *MenuEntry
487 );
488
489 /**
490 Get the Menu Entry from the list in Menu Entry List.
491
492 If MenuNumber is great or equal to the number of Menu
493 Entry in the list, then ASSERT.
494
495 @param MenuOption The Menu Entry List to read the menu entry.
496 @param MenuNumber The index of Menu Entry.
497
498 @return The Menu Entry.
499
500 **/
501 BM_MENU_ENTRY *
502 BOpt_GetMenuEntry (
503 BM_MENU_OPTION *MenuOption,
504 UINTN MenuNumber
505 );
506
507 /**
508 Get option number according to Boot#### and BootOrder variable.
509 The value is saved as #### + 1.
510
511 @param CallbackData The BMM context data.
512 **/
513 VOID
514 GetBootOrder (
515 IN BMM_CALLBACK_DATA *CallbackData
516 );
517
518 /**
519 Get driver option order from globalc DriverOptionMenu.
520
521 @param CallbackData The BMM context data.
522
523 **/
524 VOID
525 GetDriverOrder (
526 IN BMM_CALLBACK_DATA *CallbackData
527 );
528
529 //
530 // Locate all serial io devices for console
531 //
532 /**
533 Build a list containing all serial devices.
534
535 @retval EFI_SUCCESS The function complete successfully.
536 @retval EFI_UNSUPPORTED No serial ports present.
537
538 **/
539 EFI_STATUS
540 LocateSerialIo (
541 VOID
542 );
543
544 //
545 // Initializing Console menu
546 //
547 /**
548 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
549
550 @retval EFI_SUCCESS The function always complete successfully.
551
552 **/
553 EFI_STATUS
554 GetAllConsoles(
555 VOID
556 );
557
558 //
559 // Get current mode information
560 //
561 /**
562 Get mode number according to column and row
563
564 @param CallbackData The BMM context data.
565 **/
566 VOID
567 GetConsoleOutMode (
568 IN BMM_CALLBACK_DATA *CallbackData
569 );
570
571 //
572 // Cleaning up console menu
573 //
574 /**
575 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
576
577 @retval EFI_SUCCESS The function always complete successfully.
578 **/
579 EFI_STATUS
580 FreeAllConsoles (
581 VOID
582 );
583
584 /**
585 Update the device path that describing a terminal device
586 based on the new BaudRate, Data Bits, parity and Stop Bits
587 set.
588
589 @param DevicePath The devicepath protocol instance wanted to be updated.
590
591 **/
592 VOID
593 ChangeVariableDevicePath (
594 IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath
595 );
596
597 /**
598 Update the multi-instance device path of Terminal Device based on
599 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
600 device path in the Terminal Device in TerminalMenu is also updated.
601
602 @param DevicePath The multi-instance device path.
603 @param ChangeTerminal TRUE, then device path in the Terminal Device
604 in TerminalMenu is also updated; FALSE, no update.
605
606 @return EFI_SUCCESS The function completes successfully.
607
608 **/
609 EFI_STATUS
610 ChangeTerminalDevicePath (
611 IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath,
612 IN BOOLEAN ChangeTerminal
613 );
614
615 //
616 // Variable operation by menu selection
617 //
618 /**
619 This function create a currently loaded Boot Option from
620 the BMM. It then appends this Boot Option to the end of
621 the "BootOrder" list. It also append this Boot Opotion to the end
622 of BootOptionMenu.
623
624 @param CallbackData The BMM context data.
625
626 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
627 @retval EFI_SUCCESS If function completes successfully.
628
629 **/
630 EFI_STATUS
631 Var_UpdateBootOption (
632 IN BMM_CALLBACK_DATA *CallbackData
633 );
634
635 /**
636 Delete Boot Option that represent a Deleted state in BootOptionMenu.
637
638 @retval EFI_SUCCESS If all boot load option EFI Variables corresponding to
639 BM_LOAD_CONTEXT marked for deletion is deleted
640 @return Others If failed to update the "BootOrder" variable after deletion.
641
642 **/
643 EFI_STATUS
644 Var_DelBootOption (
645 VOID
646 );
647
648 /**
649 This function create a currently loaded Drive Option from
650 the BMM. It then appends this Driver Option to the end of
651 the "DriverOrder" list. It append this Driver Opotion to the end
652 of DriverOptionMenu.
653
654 @param CallbackData The BMM context data.
655 @param HiiHandle The HII handle associated with the BMM formset.
656 @param DescriptionData The description of this driver option.
657 @param OptionalData The optional load option.
658 @param ForceReconnect If to force reconnect.
659
660 @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.
661 @retval EFI_SUCCESS If function completes successfully.
662
663 **/
664 EFI_STATUS
665 Var_UpdateDriverOption (
666 IN BMM_CALLBACK_DATA *CallbackData,
667 IN EFI_HII_HANDLE HiiHandle,
668 IN UINT16 *DescriptionData,
669 IN UINT16 *OptionalData,
670 IN UINT8 ForceReconnect
671 );
672
673 /**
674 Delete Load Option that represent a Deleted state in DriverOptionMenu.
675
676 @retval EFI_SUCCESS Load Option is successfully updated.
677 @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI
678 Variable.
679
680 **/
681 EFI_STATUS
682 Var_DelDriverOption (
683 VOID
684 );
685
686 /**
687 This function delete and build multi-instance device path ConIn
688 console device.
689
690 @retval EFI_SUCCESS The function complete successfully.
691 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
692 **/
693 EFI_STATUS
694 Var_UpdateConsoleInpOption (
695 VOID
696 );
697
698 /**
699 This function delete and build multi-instance device path ConOut console device.
700
701 @retval EFI_SUCCESS The function complete successfully.
702 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
703 **/
704 EFI_STATUS
705 Var_UpdateConsoleOutOption (
706 VOID
707 );
708
709 /**
710 This function delete and build multi-instance device path ErrOut console device.
711
712 @retval EFI_SUCCESS The function complete successfully.
713 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
714 **/
715 EFI_STATUS
716 Var_UpdateErrorOutOption (
717 VOID
718 );
719
720 /**
721 This function delete and build Out of Band console device.
722
723 @param MenuIndex Menu index which user select in the terminal menu list.
724
725 @retval EFI_SUCCESS The function complete successfully.
726 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
727 **/
728 EFI_STATUS
729 Var_UpdateOutOfBandOption (
730 IN UINT16 MenuIndex
731 );
732
733 /**
734 This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,
735 this EFI Variable is deleted.
736 It also update the BMM context data specified the "BootNext" value.
737
738 @param CallbackData The BMM context data.
739
740 @retval EFI_SUCCESS The function complete successfully.
741 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
742
743 **/
744 EFI_STATUS
745 Var_UpdateBootNext (
746 IN BMM_CALLBACK_DATA *CallbackData
747 );
748
749 /**
750 This function update the "BootOrder" EFI Variable based on BMM Formset's NV map. It then refresh
751 BootOptionMenu with the new "BootOrder" list.
752
753 @param CallbackData The BMM context data.
754
755 @retval EFI_SUCCESS The function complete successfully.
756 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
757 @return not The EFI variable can not be saved. See gRT->SetVariable for detail return information.
758
759 **/
760 EFI_STATUS
761 Var_UpdateBootOrder (
762 IN BMM_CALLBACK_DATA *CallbackData
763 );
764
765 /**
766 This function update the "DriverOrder" EFI Variable based on
767 BMM Formset's NV map. It then refresh DriverOptionMenu
768 with the new "DriverOrder" list.
769
770 @param CallbackData The BMM context data.
771
772 @retval EFI_SUCCESS The function complete successfully.
773 @retval EFI_OUT_OF_RESOURCES Not enough memory to complete the function.
774 @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.
775
776 **/
777 EFI_STATUS
778 Var_UpdateDriverOrder (
779 IN BMM_CALLBACK_DATA *CallbackData
780 );
781
782 /**
783 Update the Text Mode of Console.
784
785 @param CallbackData The context data for BMM.
786
787 @retval EFI_SUCCSS If the Text Mode of Console is updated.
788 @return Other value if the Text Mode of Console is not updated.
789
790 **/
791 EFI_STATUS
792 Var_UpdateConMode (
793 IN BMM_CALLBACK_DATA *CallbackData
794 );
795
796 //
797 // Following are page create and refresh functions
798 //
799 /**
800 Create the global UpdateData structure.
801
802 **/
803 VOID
804 CreateUpdateData (
805 VOID
806 );
807
808 /**
809 Refresh the global UpdateData structure.
810
811 **/
812 VOID
813 RefreshUpdateData (
814 VOID
815 );
816
817 /**
818 Clean up the dynamic opcode at label and form specified by
819 both LabelId.
820
821 @param LabelId It is both the Form ID and Label ID for
822 opcode deletion.
823 @param CallbackData The BMM context data.
824
825 **/
826 VOID
827 CleanUpPage (
828 IN UINT16 LabelId,
829 IN BMM_CALLBACK_DATA *CallbackData
830 );
831
832 /**
833 Create a lit of boot option from global BootOptionMenu. It
834 allow user to delete the boot option.
835
836 @param CallbackData The BMM context data.
837
838 **/
839 VOID
840 UpdateBootDelPage (
841 IN BMM_CALLBACK_DATA *CallbackData
842 );
843
844 /**
845 Create a lit of driver option from global DriverMenu.
846
847 @param CallbackData The BMM context data.
848 **/
849 VOID
850 UpdateDrvAddHandlePage (
851 IN BMM_CALLBACK_DATA *CallbackData
852 );
853
854 /**
855 Create a lit of driver option from global DriverOptionMenu. It
856 allow user to delete the driver option.
857
858 @param CallbackData The BMM context data.
859 **/
860 VOID
861 UpdateDrvDelPage (
862 IN BMM_CALLBACK_DATA *CallbackData
863 );
864
865 /**
866 Prepare the page to allow user to add description for a Driver Option.
867
868 @param CallbackData The BMM context data.
869 **/
870 VOID
871 UpdateDriverAddHandleDescPage (
872 IN BMM_CALLBACK_DATA *CallbackData
873 );
874
875 /**
876 Dispatch the correct update page function to call based on the UpdatePageId.
877
878 @param UpdatePageId The form ID.
879 @param CallbackData The BMM context data.
880 **/
881 VOID
882 UpdatePageBody (
883 IN UINT16 UpdatePageId,
884 IN BMM_CALLBACK_DATA *CallbackData
885 );
886
887 /**
888 Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
889 Parity, Stop Bits, Terminal Type.
890
891 @param CallbackData The BMM context data.
892 **/
893 VOID
894 UpdateTerminalPage (
895 IN BMM_CALLBACK_DATA *CallbackData
896 );
897
898 /**
899 Refresh the text mode page
900
901 @param CallbackData The BMM context data.
902 **/
903 VOID
904 UpdateConModePage (
905 IN BMM_CALLBACK_DATA *CallbackData
906 );
907
908 /**
909 Create a list of Goto Opcode for all terminal devices logged
910 by TerminaMenu. This list will be inserted to form FORM_CON_COM_SETUP_ID.
911
912 @param CallbackData The BMM context data.
913 **/
914 VOID
915 UpdateConCOMPage (
916 IN BMM_CALLBACK_DATA *CallbackData
917 );
918
919 /**
920 Update add boot/driver option page.
921
922 @param CallbackData The BMM context data.
923 @param FormId The form ID to be updated.
924 @param DevicePath Device path.
925
926 **/
927 VOID
928 UpdateOptionPage(
929 IN BMM_CALLBACK_DATA *CallbackData,
930 IN EFI_FORM_ID FormId,
931 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
932 );
933
934 /**
935 Function deletes the variable specified by VarName and VarGuid.
936
937
938 @param VarName A Null-terminated Unicode string that is
939 the name of the vendor's variable.
940
941 @param VarGuid A unique identifier for the vendor.
942
943 @retval EFI_SUCCESS The variable was found and removed
944 @retval EFI_UNSUPPORTED The variable store was inaccessible
945 @retval EFI_OUT_OF_RESOURCES The temporary buffer was not available
946 @retval EFI_NOT_FOUND The variable was not found
947
948 **/
949 EFI_STATUS
950 EfiLibDeleteVariable (
951 IN CHAR16 *VarName,
952 IN EFI_GUID *VarGuid
953 );
954
955 /**
956 Function is used to determine the number of device path instances
957 that exist in a device path.
958
959
960 @param DevicePath A pointer to a device path data structure.
961
962 @return This function counts and returns the number of device path instances
963 in DevicePath.
964
965 **/
966 UINTN
967 EfiDevicePathInstanceCount (
968 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
969 );
970
971 /**
972 Get a string from the Data Hub record based on
973 a device path.
974
975 @param DevPath The device Path.
976
977 @return A string located from the Data Hub records based on
978 the device path.
979 @retval NULL If failed to get the String from Data Hub.
980
981 **/
982 UINT16 *
983 EfiLibStrFromDatahub (
984 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
985 );
986
987 /**
988 Get the index number (#### in Boot####) for the boot option pointed to a BBS legacy device type
989 specified by DeviceType.
990
991 @param DeviceType The legacy device type. It can be floppy, network, harddisk, cdrom,
992 etc.
993 @param OptionIndex Returns the index number (#### in Boot####).
994 @param OptionSize Return the size of the Boot### variable.
995
996 **/
997 VOID *
998 GetLegacyBootOptionVar (
999 IN UINTN DeviceType,
1000 OUT UINTN *OptionIndex,
1001 OUT UINTN *OptionSize
1002 );
1003
1004 /**
1005 Discard all changes done to the BMM pages such as Boot Order change,
1006 Driver order change.
1007
1008 @param Private The BMM context data.
1009 @param CurrentFakeNVMap The current Fack NV Map.
1010
1011 **/
1012 VOID
1013 DiscardChangeHandler (
1014 IN BMM_CALLBACK_DATA *Private,
1015 IN BMM_FAKE_NV_DATA *CurrentFakeNVMap
1016 );
1017
1018
1019 /**
1020 This function is to clean some useless data before submit changes.
1021
1022 @param Private The BMM context data.
1023
1024 **/
1025 VOID
1026 CleanUselessBeforeSubmit (
1027 IN BMM_CALLBACK_DATA *Private
1028 );
1029
1030 /**
1031 Dispatch the display to the next page based on NewPageId.
1032
1033 @param Private The BMM context data.
1034 @param NewPageId The original page ID.
1035
1036 **/
1037 VOID
1038 UpdatePageId (
1039 BMM_CALLBACK_DATA *Private,
1040 UINT16 NewPageId
1041 );
1042
1043 /**
1044 Remove the installed BootMaint and FileExplorer HiiPackages.
1045
1046 **/
1047 VOID
1048 FreeBMPackage(
1049 VOID
1050 );
1051
1052 /**
1053 Install BootMaint and FileExplorer HiiPackages.
1054
1055 **/
1056 VOID
1057 InitBootMaintenance(
1058 VOID
1059 );
1060
1061 /**
1062
1063 Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]
1064 in BMM_FAKE_NV_DATA structure.
1065
1066 @param CallbackData The BMM context data.
1067
1068 **/
1069 VOID
1070 GetConsoleInCheck (
1071 IN BMM_CALLBACK_DATA *CallbackData
1072 );
1073
1074 /**
1075
1076 Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]
1077 in BMM_FAKE_NV_DATA structure.
1078
1079 @param CallbackData The BMM context data.
1080
1081 **/
1082 VOID
1083 GetConsoleOutCheck (
1084 IN BMM_CALLBACK_DATA *CallbackData
1085 );
1086
1087 /**
1088
1089 Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]
1090 in BMM_FAKE_NV_DATA structure.
1091
1092 @param CallbackData The BMM context data.
1093
1094 **/
1095 VOID
1096 GetConsoleErrCheck (
1097 IN BMM_CALLBACK_DATA *CallbackData
1098 );
1099
1100 /**
1101
1102 Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)
1103 to BMM_FAKE_NV_DATA structure.
1104
1105 @param CallbackData The BMM context data.
1106
1107 **/
1108 VOID
1109 GetTerminalAttribute (
1110 IN BMM_CALLBACK_DATA *CallbackData
1111 );
1112
1113 /**
1114 This function will change video resolution and text mode
1115 according to defined setup mode or defined boot mode
1116
1117 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.
1118
1119 @retval EFI_SUCCESS Mode is changed successfully.
1120 @retval Others Mode failed to be changed.
1121
1122 **/
1123 EFI_STATUS
1124 BmmSetConsoleMode (
1125 BOOLEAN IsSetupMode
1126 );
1127
1128
1129 /**
1130 This function converts an input device structure to a Unicode string.
1131
1132 @param DevPath A pointer to the device path structure.
1133
1134 @return A new allocated Unicode string that represents the device path.
1135
1136 **/
1137 CHAR16 *
1138 UiDevicePathToStr (
1139 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
1140 );
1141
1142 /**
1143 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
1144 The caller is responsible for freeing the allocated buffer using FreePool().
1145
1146 @param DevicePath Device path.
1147
1148 @return A new allocated string that represents the file name.
1149
1150 **/
1151 CHAR16 *
1152 ExtractFileNameFromDevicePath (
1153 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
1154 );
1155
1156 /**
1157 This function allows a caller to extract the current configuration for one
1158 or more named elements from the target driver.
1159
1160 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1161 @param Request A null-terminated Unicode string in <ConfigRequest> format.
1162 @param Progress On return, points to a character in the Request string.
1163 Points to the string's null terminator if request was successful.
1164 Points to the most recent '&' before the first failing name/value
1165 pair (or the beginning of the string if the failure is in the
1166 first name/value pair) if the request was not successful.
1167 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
1168 has all values filled in for the names in the Request string.
1169 String to be allocated by the called function.
1170
1171 @retval EFI_SUCCESS The Results is filled with the requested values.
1172 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
1173 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
1174 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
1175
1176 **/
1177 EFI_STATUS
1178 EFIAPI
1179 BootMaintExtractConfig (
1180 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
1181 IN CONST EFI_STRING Request,
1182 OUT EFI_STRING *Progress,
1183 OUT EFI_STRING *Results
1184 );
1185
1186 /**
1187 This function applies changes in a driver's configuration.
1188 Input is a Configuration, which has the routing data for this
1189 driver followed by name / value configuration pairs. The driver
1190 must apply those pairs to its configurable storage. If the
1191 driver's configuration is stored in a linear block of data
1192 and the driver's name / value pairs are in <BlockConfig>
1193 format, it may use the ConfigToBlock helper function (above) to
1194 simplify the job. Currently not implemented.
1195
1196 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1197 @param[in] Configuration A null-terminated Unicode string in
1198 <ConfigString> format.
1199 @param[out] Progress A pointer to a string filled in with the
1200 offset of the most recent '&' before the
1201 first failing name / value pair (or the
1202 beginn ing of the string if the failure
1203 is in the first name / value pair) or
1204 the terminating NULL if all was
1205 successful.
1206
1207 @retval EFI_SUCCESS The results have been distributed or are
1208 awaiting distribution.
1209 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1210 parts of the results that must be
1211 stored awaiting possible future
1212 protocols.
1213 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1214 Results parameter would result
1215 in this type of error.
1216 @retval EFI_NOT_FOUND Target for the specified routing data
1217 was not found.
1218 **/
1219 EFI_STATUS
1220 EFIAPI
1221 BootMaintRouteConfig (
1222 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
1223 IN CONST EFI_STRING Configuration,
1224 OUT EFI_STRING *Progress
1225 );
1226
1227 /**
1228 This function processes the results of changes in configuration.
1229
1230
1231 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1232 @param Action Specifies the type of action taken by the browser.
1233 @param QuestionId A unique value which is sent to the original exporting driver
1234 so that it can identify the type of data to expect.
1235 @param Type The type of value for the question.
1236 @param Value A pointer to the data being sent to the original exporting driver.
1237 @param ActionRequest On return, points to the action requested by the callback function.
1238
1239 @retval EFI_SUCCESS The callback successfully handled the action.
1240 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
1241 @retval EFI_DEVICE_ERROR The variable could not be saved.
1242 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
1243 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
1244 **/
1245 EFI_STATUS
1246 EFIAPI
1247 BootMaintCallback (
1248 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
1249 IN EFI_BROWSER_ACTION Action,
1250 IN EFI_QUESTION_ID QuestionId,
1251 IN UINT8 Type,
1252 IN EFI_IFR_TYPE_VALUE *Value,
1253 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
1254 );
1255
1256 /**
1257 Create boot option base on the input file path info.
1258
1259 @param FilePath Point to the file path.
1260
1261 @retval TRUE Exit caller function.
1262 @retval FALSE Not exit caller function.
1263
1264 **/
1265 BOOLEAN
1266 EFIAPI
1267 CreateBootOptionFromFile (
1268 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
1269 );
1270
1271 /**
1272 Create driver option base on the input file path info.
1273
1274 @param FilePath Point to the file path.
1275
1276 @retval TRUE Exit caller function.
1277 @retval FALSE Not exit caller function.
1278 **/
1279 BOOLEAN
1280 EFIAPI
1281 CreateDriverOptionFromFile (
1282 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
1283 );
1284
1285 /**
1286 Boot the file specified by the input file path info.
1287
1288 @param FilePath Point to the file path.
1289
1290 @retval TRUE Exit caller function.
1291 @retval FALSE Not exit caller function.
1292
1293 **/
1294 BOOLEAN
1295 EFIAPI
1296 BootFromFile (
1297 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
1298 );
1299
1300 //
1301 // Global variable in this program (defined in data.c)
1302 //
1303 extern BM_MENU_OPTION BootOptionMenu;
1304 extern BM_MENU_OPTION DriverOptionMenu;
1305 extern BM_MENU_OPTION ConsoleInpMenu;
1306 extern BM_MENU_OPTION ConsoleOutMenu;
1307 extern BM_MENU_OPTION ConsoleErrMenu;
1308 extern BM_MENU_OPTION DriverMenu;
1309 extern BM_MENU_OPTION TerminalMenu;
1310 extern UINT16 TerminalType[5];
1311 extern COM_ATTR BaudRateList[19];
1312 extern COM_ATTR DataBitsList[4];
1313 extern COM_ATTR ParityList[5];
1314 extern COM_ATTR StopBitsList[3];
1315 extern EFI_GUID TerminalTypeGuid[5];
1316 extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath[];
1317 extern UINT16 mFlowControlType[2];
1318 extern UINT32 mFlowControlValue[2];
1319
1320 //
1321 // Shared IFR form update data
1322 //
1323 extern VOID *mStartOpCodeHandle;
1324 extern VOID *mEndOpCodeHandle;
1325 extern EFI_IFR_GUID_LABEL *mStartLabel;
1326 extern EFI_IFR_GUID_LABEL *mEndLabel;
1327 extern BMM_CALLBACK_DATA gBootMaintenancePrivate;
1328 extern BMM_CALLBACK_DATA *mBmmCallbackInfo;
1329
1330 #endif