]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Include / Library / GenericBdsLib.h
1 /** @file
2 Generic BDS library defines general interfaces for a BDS driver, including:
3 1) BDS boot policy interface.
4 2) BDS boot device connect interface.
5 3) BDS Misc interfaces for mainting boot variable, ouput string.
6
7 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #ifndef _GENERIC_BDS_LIB_H_
13 #define _GENERIC_BDS_LIB_H_
14
15 #include <Protocol/UserManager.h>
16
17 ///
18 /// Constants which are variable names used to access variables.
19 ///
20 #define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"
21
22 ///
23 /// Data structures and defines.
24 ///
25 #define FRONT_PAGE_QUESTION_ID 0x0000
26 #define FRONT_PAGE_DATA_WIDTH 0x01
27
28 ///
29 /// ConnectType
30 ///
31 #define CONSOLE_OUT 0x00000001
32 #define STD_ERROR 0x00000002
33 #define CONSOLE_IN 0x00000004
34 #define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
35
36 ///
37 /// Load Option Attributes
38 ///
39 #define LOAD_OPTION_ACTIVE 0x00000001
40 #define LOAD_OPTION_FORCE_RECONNECT 0x00000002
41
42 #define LOAD_OPTION_HIDDEN 0x00000008
43 #define LOAD_OPTION_CATEGORY 0x00001F00
44
45 #define LOAD_OPTION_CATEGORY_BOOT 0x00000000
46 #define LOAD_OPTION_CATEGORY_APP 0x00000100
47
48 #define EFI_BOOT_OPTION_SUPPORT_KEY 0x00000001
49 #define EFI_BOOT_OPTION_SUPPORT_APP 0x00000002
50
51 #define IS_LOAD_OPTION_TYPE(_c, _Mask) (BOOLEAN) (((_c) & (_Mask)) != 0)
52
53 ///
54 /// Define the maximum characters that will be accepted.
55 ///
56 #define MAX_CHAR 480
57 #define MAX_CHAR_SIZE (MAX_CHAR * 2)
58
59 ///
60 /// Define maximum characters for boot option variable "BootXXXX".
61 ///
62 #define BOOT_OPTION_MAX_CHAR 10
63
64 //
65 // This data structure is the part of BDS_CONNECT_ENTRY
66 //
67 #define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')
68
69 typedef struct {
70
71 UINTN Signature;
72 LIST_ENTRY Link;
73
74 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
75
76 CHAR16 *OptionName;
77 UINTN OptionNumber;
78 UINT16 BootCurrent;
79 UINT32 Attribute;
80 CHAR16 *Description;
81 VOID *LoadOptions;
82 UINT32 LoadOptionsSize;
83 CHAR16 *StatusString;
84
85 } BDS_COMMON_OPTION;
86
87 typedef struct {
88 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
89 UINTN ConnectType;
90 } BDS_CONSOLE_CONNECT_ENTRY;
91
92 //
93 // Bds boot related lib functions
94 //
95 /**
96 Boot from the UEFI spec defined "BootNext" variable.
97
98 **/
99 VOID
100 EFIAPI
101 BdsLibBootNext (
102 VOID
103 );
104
105 /**
106 Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.
107
108 @param Option The boot option to be processed.
109 @param DevicePath The device path describing where to load the
110 boot image or the legcy BBS device path to boot
111 the legacy OS.
112 @param ExitDataSize The size of exit data.
113 @param ExitData Data returned when Boot image failed.
114
115 @retval EFI_SUCCESS Boot from the input boot option succeeded.
116 @retval EFI_NOT_FOUND The Device Path is not found in the system.
117
118 **/
119 EFI_STATUS
120 EFIAPI
121 BdsLibBootViaBootOption (
122 IN BDS_COMMON_OPTION * Option,
123 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
124 OUT UINTN *ExitDataSize,
125 OUT CHAR16 **ExitData OPTIONAL
126 );
127
128
129 /**
130 This function will enumerate all possible boot devices in the system, and
131 automatically create boot options for Network, Shell, Removable BlockIo,
132 and Non-BlockIo Simplefile devices.
133
134 BDS separates EFI boot options into six types:
135 1. Network - The boot option points to the SimpleNetworkProtocol device.
136 Bds will try to automatically create this type of boot option during enumeration.
137 2. Shell - The boot option points to internal flash shell.
138 Bds will try to automatically create this type of boot option during enumeration.
139 3. Removable BlockIo - The boot option points to a removable media
140 device, such as a USB flash drive or DVD drive.
141 These devices should contain a *removable* blockIo
142 protocol in their device handle.
143 Bds will try to automatically create this type boot option
144 when enumerate.
145 4. Fixed BlockIo - The boot option points to a Fixed blockIo device,
146 such as a hard disk.
147 These devices should contain a *fixed* blockIo
148 protocol in their device handle.
149 BDS will skip fixed blockIo devices, and not
150 automatically create boot option for them. But BDS
151 will help to delete those fixed blockIo boot options,
152 whose description rules conflict with other auto-created
153 boot options.
154 5. Non-BlockIo Simplefile - The boot option points to a device whose handle
155 has SimpleFileSystem Protocol, but has no blockio
156 protocol. These devices do not offer blockIo
157 protocol, but BDS still can get the
158 \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem
159 Protocol.
160 6. File - The boot option points to a file. These boot options are usually
161 created by the user, either manually or with an OS loader. BDS will not delete or modify
162 these boot options.
163
164 This function will enumerate all possible boot devices in the system, and
165 automatically create boot options for Network, Shell, Removable BlockIo,
166 and Non-BlockIo Simplefile devices.
167 It will execute once every boot.
168
169 @param BdsBootOptionList The header of the linked list that indexed all
170 current boot options.
171
172 @retval EFI_SUCCESS Finished all the boot device enumerations and
173 created the boot option based on the boot device.
174
175 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create
176 the boot option list.
177 **/
178 EFI_STATUS
179 EFIAPI
180 BdsLibEnumerateAllBootOption (
181 IN OUT LIST_ENTRY *BdsBootOptionList
182 );
183
184 /**
185 Build the boot option with the handle parsed in.
186
187 @param Handle The handle representing the device path for which
188 to create a boot option.
189 @param BdsBootOptionList The header of the link list that indexed all
190 current boot options.
191 @param String The description of the boot option.
192
193 **/
194 VOID
195 EFIAPI
196 BdsLibBuildOptionFromHandle (
197 IN EFI_HANDLE Handle,
198 IN LIST_ENTRY *BdsBootOptionList,
199 IN CHAR16 *String
200 );
201
202
203 /**
204 Build the on flash shell boot option with the handle parsed in.
205
206 @param Handle The handle which present the device path to create
207 the on flash shell boot option.
208 @param BdsBootOptionList The header of the link list that indexed all
209 current boot options.
210
211 **/
212 VOID
213 EFIAPI
214 BdsLibBuildOptionFromShell (
215 IN EFI_HANDLE Handle,
216 IN OUT LIST_ENTRY *BdsBootOptionList
217 );
218
219 //
220 // Bds misc lib functions
221 //
222 /**
223 Get boot mode by looking up the configuration table and parsing the HOB list.
224
225 @param BootMode The boot mode from PEI handoff HOB.
226
227 @retval EFI_SUCCESS Successfully got boot mode.
228
229 **/
230 EFI_STATUS
231 EFIAPI
232 BdsLibGetBootMode (
233 OUT EFI_BOOT_MODE *BootMode
234 );
235
236
237 /**
238 The function will go through the driver option link list, and then load and start
239 every driver to which the driver option device path points.
240
241 @param BdsDriverLists The header of the current driver option link list.
242
243 **/
244 VOID
245 EFIAPI
246 BdsLibLoadDrivers (
247 IN LIST_ENTRY *BdsDriverLists
248 );
249
250
251 /**
252 This function processes BootOrder or DriverOrder variables, by calling
253
254 BdsLibVariableToOption () for each UINT16 in the variables.
255
256 @param BdsCommonOptionList The header of the option list base on the variable
257 VariableName.
258 @param VariableName An EFI Variable name indicate the BootOrder or
259 DriverOrder.
260
261 @retval EFI_SUCCESS Successfully created the boot option or driver option
262 list.
263 @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or the driver option list.
264 **/
265 EFI_STATUS
266 EFIAPI
267 BdsLibBuildOptionFromVar (
268 IN LIST_ENTRY *BdsCommonOptionList,
269 IN CHAR16 *VariableName
270 );
271
272 /**
273 This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated
274 buffer and the size of the buffer. If it fails, return NULL.
275
276 @param Name The string part of the EFI variable name.
277 @param VendorGuid The GUID part of the EFI variable name.
278 @param VariableSize Returns the size of the EFI variable that was read.
279
280 @return Dynamically allocated memory that contains a copy
281 of the EFI variable. The caller is responsible for
282 freeing the buffer.
283 @retval NULL The variable was not read.
284
285 **/
286 VOID *
287 EFIAPI
288 BdsLibGetVariableAndSize (
289 IN CHAR16 *Name,
290 IN EFI_GUID *VendorGuid,
291 OUT UINTN *VariableSize
292 );
293
294
295 /**
296 This function prints a series of strings.
297
298 @param ConOut A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
299 @param ... A variable argument list containing a series of
300 strings, the last string must be NULL.
301
302 @retval EFI_SUCCESS Successfully printed out the string using ConOut.
303 @retval EFI_STATUS Return the status of the ConOut->OutputString ().
304
305 **/
306 EFI_STATUS
307 EFIAPI
308 BdsLibOutputStrings (
309 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,
310 ...
311 );
312
313 /**
314 Build the boot#### or driver#### option from the VariableName. The
315 build boot#### or driver#### will also be linked to BdsCommonOptionList.
316
317 @param BdsCommonOptionList The header of the boot#### or driver#### option
318 link list.
319 @param VariableName EFI Variable name, indicates if it is boot#### or
320 driver####.
321
322 @retval BDS_COMMON_OPTION The option that was created.
323 @retval NULL Failed to get the new option.
324
325 **/
326 BDS_COMMON_OPTION *
327 EFIAPI
328 BdsLibVariableToOption (
329 IN OUT LIST_ENTRY *BdsCommonOptionList,
330 IN CHAR16 *VariableName
331 );
332
333 /**
334 This function registers the new boot#### or driver#### option based on
335 the VariableName. The new registered boot#### or driver#### will be linked
336 to BdsOptionList and also update to the VariableName. After the boot#### or
337 driver#### updated, the BootOrder or DriverOrder will also be updated.
338
339 @param BdsOptionList The header of the boot#### or driver#### link list.
340 @param DevicePath The device path that the boot#### or driver####
341 option present.
342 @param String The description of the boot#### or driver####.
343 @param VariableName Indicate if the boot#### or driver#### option.
344
345 @retval EFI_SUCCESS The boot#### or driver#### have been successfully
346 registered.
347 @retval EFI_STATUS Return the status of gRT->SetVariable ().
348
349 **/
350 EFI_STATUS
351 EFIAPI
352 BdsLibRegisterNewOption (
353 IN LIST_ENTRY *BdsOptionList,
354 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
355 IN CHAR16 *String,
356 IN CHAR16 *VariableName
357 );
358
359 //
360 // Bds connect and disconnect driver lib funcions
361 //
362 /**
363 This function connects all system drivers with the corresponding controllers.
364
365 **/
366 VOID
367 EFIAPI
368 BdsLibConnectAllDriversToAllControllers (
369 VOID
370 );
371
372 /**
373 This function connects all system drivers to controllers.
374
375 **/
376 VOID
377 EFIAPI
378 BdsLibConnectAll (
379 VOID
380 );
381
382 /**
383 This function will create all handles associate with every device
384 path node. If the handle associate with one device path node can not
385 be created successfully, then still give chance to do the dispatch,
386 which load the missing drivers if possible.
387
388 @param DevicePathToConnect The device path to be connected. Can be
389 a multi-instance device path.
390
391 @retval EFI_SUCCESS All handles associates with every device path node
392 were created.
393 @retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles.
394 @retval EFI_NOT_FOUND At least one handle could not be created.
395
396 **/
397 EFI_STATUS
398 EFIAPI
399 BdsLibConnectDevicePath (
400 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
401 );
402
403 /**
404 This function will connect all current system handles recursively.
405 gBS->ConnectController() service is invoked for each handle exist in system handler buffer.
406 If the handle is bus type handler, all childrens also will be connected recursively by gBS->ConnectController().
407
408 @retval EFI_SUCCESS All handles and child handles have been
409 connected.
410 @retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
411 **/
412 EFI_STATUS
413 EFIAPI
414 BdsLibConnectAllEfi (
415 VOID
416 );
417
418 /**
419 This function will disconnect all current system handles.
420 gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
421 If handle is a bus type handle, all childrens also are disconnected recursively by gBS->DisconnectController().
422
423 @retval EFI_SUCCESS All handles have been disconnected.
424 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().
425
426 **/
427 EFI_STATUS
428 EFIAPI
429 BdsLibDisconnectAllEfi (
430 VOID
431 );
432
433 //
434 // Bds console related lib functions
435 //
436 /**
437 This function will search every simpletxt device in the current system,
438 and make every simpletxt device a potential console device.
439
440 **/
441 VOID
442 EFIAPI
443 BdsLibConnectAllConsoles (
444 VOID
445 );
446
447
448 /**
449 This function will connect console device based on the console
450 device variable ConIn, ConOut and ErrOut.
451
452 @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have
453 been connected.
454 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
455
456 **/
457 EFI_STATUS
458 EFIAPI
459 BdsLibConnectAllDefaultConsoles (
460 VOID
461 );
462
463
464 /**
465 This function will connect console device except ConIn base on the console
466 device variable ConOut and ErrOut.
467
468 @retval EFI_SUCCESS At least one of the ConOut device have
469 been connected success.
470 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
471
472 **/
473 EFI_STATUS
474 EFIAPI
475 BdsLibConnectAllDefaultConsolesWithOutConIn (
476 VOID
477 );
478
479
480 /**
481 This function updates the console variable based on ConVarName. It can
482 add or remove one specific console device path from the variable
483
484 @param ConVarName The console-related variable name: ConIn, ConOut,
485 ErrOut.
486 @param CustomizedConDevicePath The console device path to be added to
487 the console variable ConVarName. Cannot be multi-instance.
488 @param ExclusiveDevicePath The console device path to be removed
489 from the console variable ConVarName. Cannot be multi-instance.
490
491 @retval EFI_UNSUPPORTED The added device path is the same as a removed one.
492 @retval EFI_SUCCESS Successfully added or removed the device path from the
493 console variable.
494
495 **/
496 EFI_STATUS
497 EFIAPI
498 BdsLibUpdateConsoleVariable (
499 IN CHAR16 *ConVarName,
500 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
501 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
502 );
503
504 /**
505 Connect the console device base on the variable ConVarName, if
506 device path of the ConVarName is multi-instance device path and
507 anyone of the instances is connected success, then this function
508 will return success.
509 If the handle associate with one device path node can not
510 be created successfully, then still give chance to do the dispatch,
511 which load the missing drivers if possible.
512
513 @param ConVarName Console related variable name, ConIn, ConOut,
514 ErrOut.
515
516 @retval EFI_NOT_FOUND There is not any console devices connected
517 success
518 @retval EFI_SUCCESS Success connect any one instance of the console
519 device path base on the variable ConVarName.
520
521 **/
522 EFI_STATUS
523 EFIAPI
524 BdsLibConnectConsoleVariable (
525 IN CHAR16 *ConVarName
526 );
527
528 //
529 // Bds device path related lib functions
530 //
531 /**
532 Delete the instance in Multi that overlaps with Single.
533
534 @param Multi A pointer to a multi-instance device path data
535 structure.
536 @param Single A pointer to a single-instance device path data
537 structure.
538
539 @return This function removes the device path instances in Multi that overlap
540 Single, and returns the resulting device path. If there is no
541 remaining device path as a result, this function will return NULL.
542
543 **/
544 EFI_DEVICE_PATH_PROTOCOL *
545 EFIAPI
546 BdsLibDelPartMatchInstance (
547 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
548 IN EFI_DEVICE_PATH_PROTOCOL *Single
549 );
550
551 /**
552 This function compares a device path data structure to that of all the nodes of a
553 second device path instance.
554
555 @param Multi A pointer to a multi-instance device path data
556 structure.
557 @param Single A pointer to a single-instance device path data
558 structure.
559
560 @retval TRUE If the Single device path is contained within a
561 Multi device path.
562 @retval FALSE The Single device path is not contained within a
563 Multi device path.
564
565 **/
566 BOOLEAN
567 EFIAPI
568 BdsLibMatchDevicePaths (
569 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
570 IN EFI_DEVICE_PATH_PROTOCOL *Single
571 );
572
573 /**
574 This function converts an input device structure to a Unicode string.
575
576 @param DevPath A pointer to the device path structure.
577
578 @return A newly allocated Unicode string that represents the device path.
579
580 **/
581 CHAR16 *
582 EFIAPI
583 DevicePathToStr (
584 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
585 );
586
587 //
588 // Internal definitions
589 //
590 typedef struct {
591 CHAR16 *Str;
592 UINTN Len;
593 UINTN Maxlen;
594 } POOL_PRINT;
595
596 typedef
597 VOID
598 (*DEV_PATH_FUNCTION) (
599 IN OUT POOL_PRINT *Str,
600 IN VOID *DevPath
601 );
602
603 typedef struct {
604 UINT8 Type;
605 UINT8 SubType;
606 DEV_PATH_FUNCTION Function;
607 } DEVICE_PATH_STRING_TABLE;
608
609 typedef struct {
610 EFI_DEVICE_PATH_PROTOCOL Header;
611 EFI_GUID Guid;
612 UINT8 VendorDefinedData[1];
613 } VENDOR_DEVICE_PATH_WITH_DATA;
614
615 typedef struct {
616 EFI_DEVICE_PATH_PROTOCOL Header;
617 UINT16 NetworkProtocol;
618 UINT16 LoginOption;
619 UINT64 Lun;
620 UINT16 TargetPortalGroupTag;
621 CHAR16 TargetName[1];
622 } ISCSI_DEVICE_PATH_WITH_NAME;
623
624 //
625 // BBS support macros and functions
626 //
627
628 #if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)
629 #define REFRESH_LEGACY_BOOT_OPTIONS \
630 BdsDeleteAllInvalidLegacyBootOptions ();\
631 BdsAddNonExistingLegacyBootOptions (); \
632 BdsUpdateLegacyDevOrder ()
633 #else
634 #define REFRESH_LEGACY_BOOT_OPTIONS
635 #endif
636
637 /**
638 Delete all the invalid legacy boot options.
639
640 @retval EFI_SUCCESS All invalid legacy boot options are deleted.
641 @retval EFI_OUT_OF_RESOURCES Failed to allocate necessary memory.
642 @retval EFI_NOT_FOUND Failed to retrieve variable of boot order.
643
644 **/
645 EFI_STATUS
646 EFIAPI
647 BdsDeleteAllInvalidLegacyBootOptions (
648 VOID
649 );
650
651 /**
652 Add the legacy boot options from BBS table if they do not exist.
653
654 @retval EFI_SUCCESS The boot options were added successfully,
655 or they are already in boot options.
656 @retval EFI_NOT_FOUND No legacy boot options is found.
657 @retval EFI_OUT_OF_RESOURCE No enough memory.
658 @return Other value LegacyBoot options are not added.
659 **/
660 EFI_STATUS
661 EFIAPI
662 BdsAddNonExistingLegacyBootOptions (
663 VOID
664 );
665
666 /**
667 Add the legacy boot devices from BBS table into
668 the legacy device boot order.
669
670 @retval EFI_SUCCESS The boot devices were added successfully.
671 @retval EFI_NOT_FOUND The legacy boot devices are not found.
672 @retval EFI_OUT_OF_RESOURCES Memory or storage is not enough.
673 @retval EFI_DEVICE_ERROR Failed to add the legacy device boot order into EFI variable
674 because of a hardware error.
675 **/
676 EFI_STATUS
677 EFIAPI
678 BdsUpdateLegacyDevOrder (
679 VOID
680 );
681
682 /**
683 Refresh the boot priority for BBS entries based on boot option entry and boot order.
684
685 @param Entry The boot option is to be checked for a refreshed BBS table.
686
687 @retval EFI_SUCCESS The boot priority for BBS entries refreshed successfully.
688 @retval EFI_NOT_FOUND BBS entries can't be found.
689 @retval EFI_OUT_OF_RESOURCES Failed to get the legacy device boot order.
690 **/
691 EFI_STATUS
692 EFIAPI
693 BdsRefreshBbsTableForBoot (
694 IN BDS_COMMON_OPTION *Entry
695 );
696
697 /**
698 Delete the Boot Option from EFI Variable. The Boot Order Arrray
699 is also updated.
700
701 @param OptionNumber The number of Boot options wanting to be deleted.
702 @param BootOrder The Boot Order array.
703 @param BootOrderSize The size of the Boot Order Array.
704
705 @retval EFI_SUCCESS The Boot Option Variable was found and removed.
706 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible.
707 @retval EFI_NOT_FOUND The Boot Option Variable was not found.
708 **/
709 EFI_STATUS
710 EFIAPI
711 BdsDeleteBootOption (
712 IN UINTN OptionNumber,
713 IN OUT UINT16 *BootOrder,
714 IN OUT UINTN *BootOrderSize
715 );
716
717 //
718 //The interface functions related to the Setup Browser Reset Reminder feature
719 //
720 /**
721 Enable the setup browser reset reminder feature.
722 This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.
723
724 **/
725 VOID
726 EFIAPI
727 EnableResetReminderFeature (
728 VOID
729 );
730
731 /**
732 Disable the setup browser reset reminder feature.
733 This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it.
734
735 **/
736 VOID
737 EFIAPI
738 DisableResetReminderFeature (
739 VOID
740 );
741
742 /**
743 Record the info that a reset is required.
744 A module boolean variable is used to record whether a reset is required.
745
746 **/
747 VOID
748 EFIAPI
749 EnableResetRequired (
750 VOID
751 );
752
753
754 /**
755 Record the info that no reset is required.
756 A module boolean variable is used to record whether a reset is required.
757
758 **/
759 VOID
760 EFIAPI
761 DisableResetRequired (
762 VOID
763 );
764
765 /**
766 Check whether platform policy enables the reset reminder feature. The default is enabled.
767
768 **/
769 BOOLEAN
770 EFIAPI
771 IsResetReminderFeatureEnable (
772 VOID
773 );
774
775 /**
776 Check if the user changed any option setting that needs a system reset to be effective.
777
778 **/
779 BOOLEAN
780 EFIAPI
781 IsResetRequired (
782 VOID
783 );
784
785 /**
786 Check whether a reset is needed, and finish the reset reminder feature.
787 If a reset is needed, pop up a menu to notice user, and finish the feature
788 according to the user selection.
789
790 **/
791 VOID
792 EFIAPI
793 SetupResetReminder (
794 VOID
795 );
796
797
798 ///
799 /// Define the boot type with which to classify the boot option type.
800 /// Different boot option types could have different boot behaviors.
801 /// Use their device path node (Type + SubType) as the type value.
802 /// The boot type here can be added according to requirements.
803 ///
804
805 ///
806 /// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values.
807 ///
808 #define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201
809 ///
810 /// Message boot type
811 /// If a device path of boot option only points to a message node, the boot option is a message boot type.
812 ///
813 #define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01
814 #define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02
815 #define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05
816 #define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18
817 #define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11
818 #define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF
819
820 ///
821 /// Media boot type
822 /// If a device path of boot option contains a media node, the boot option is media boot type.
823 ///
824 #define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01
825 #define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02
826 ///
827 /// BBS boot type
828 /// If a device path of boot option contains a BBS node, the boot option is BBS boot type.
829 ///
830 #define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01
831
832 #define BDS_EFI_UNSUPPORT 0xFFFF
833
834 /**
835 Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path.
836
837 @param BlockIoDevicePath Multi device path instances to check.
838 @param HardDriveDevicePath A device path starting with a hard drive media
839 device path.
840
841 @retval TRUE There is a matched device path instance.
842 @retval FALSE There is no matched device path instance.
843
844 **/
845 BOOLEAN
846 EFIAPI
847 MatchPartitionDevicePathNode (
848 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
849 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
850 );
851
852
853 /**
854 Expand a device path that starts with a hard drive media device path node to be a
855 full device path that includes the full hardware path to the device. This function enables the device to boot.
856 To avoid requiring a connect on every boot, the front match is saved in a variable (the part point
857 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).
858 All successful history device paths
859 that point to the front part of the partition node will be saved.
860
861 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard
862 drive media device path.
863 @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path
864 cannot be found.
865
866 **/
867 EFI_DEVICE_PATH_PROTOCOL *
868 EFIAPI
869 BdsExpandPartitionPartialDevicePathToFull (
870 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
871 );
872
873 /**
874 Return the bootable media handle.
875 First, check whether the device is connected.
876 Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.
877 Third, detect the the default boot file in the Media, and return the removable Media handle.
878
879 @param DevicePath The Device Path to a bootable device.
880
881 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.
882
883 **/
884 EFI_HANDLE
885 EFIAPI
886 BdsLibGetBootableHandle (
887 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
888 );
889
890
891 /**
892 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
893 is ready to boot now.
894
895 @param DevPath The Device path in a boot option.
896 @param CheckMedia If true, check whether the device is ready to boot now.
897
898 @retval TRUE The Device path is valid.
899 @retval FALSE The Device path is invalid.
900
901 **/
902 BOOLEAN
903 EFIAPI
904 BdsLibIsValidEFIBootOptDevicePath (
905 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
906 IN BOOLEAN CheckMedia
907 );
908
909 /**
910 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
911 is ready to boot now.
912 If Description is not NULL and the device path points to a fixed BlockIo
913 device, this function checks whether the description conflicts with other auto-created
914 boot options.
915
916 @param DevPath The Device path in a boot option.
917 @param CheckMedia If true, checks if the device is ready to boot now.
918 @param Description The description of a boot option.
919
920 @retval TRUE The Device path is valid.
921 @retval FALSE The Device path is invalid.
922
923 **/
924 BOOLEAN
925 EFIAPI
926 BdsLibIsValidEFIBootOptDevicePathExt (
927 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
928 IN BOOLEAN CheckMedia,
929 IN CHAR16 *Description
930 );
931
932 /**
933 For a bootable Device path, return its boot type.
934
935 @param DevicePath The bootable device Path to check.
936
937 @retval BDS_EFI_MEDIA_HD_BOOT The given device path contains MEDIA_DEVICE_PATH type device path node,
938 whose subtype is MEDIA_HARDDRIVE_DP.
939 @retval BDS_EFI_MEDIA_CDROM_BOOT If given device path contains MEDIA_DEVICE_PATH type device path node,
940 whose subtype is MEDIA_CDROM_DP.
941 @retval BDS_EFI_ACPI_FLOPPY_BOOT A given device path contains ACPI_DEVICE_PATH type device path node,
942 whose HID is floppy device.
943 @retval BDS_EFI_MESSAGE_ATAPI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,
944 and its last device path node's subtype is MSG_ATAPI_DP.
945 @retval BDS_EFI_MESSAGE_SCSI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,
946 and its last device path node's subtype is MSG_SCSI_DP.
947 @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,
948 and its last device path node's subtype is MSG_USB_DP.
949 @retval BDS_EFI_MESSAGE_MISC_BOOT The device path does not contain any media device path node, and
950 its last device path node points to a message device path node.
951 @retval BDS_LEGACY_BBS_BOOT A given device path contains BBS_DEVICE_PATH type device path node.
952 @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path does not point to a media and message device.
953
954 **/
955 UINT32
956 EFIAPI
957 BdsGetBootTypeFromDevicePath (
958 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
959 );
960
961
962 /**
963 This routine registers a function to adjust the different types of memory page numbers
964 just before booting, and saves the updated info into the variable for the next boot to use.
965
966 **/
967 VOID
968 EFIAPI
969 BdsLibSaveMemoryTypeInformation (
970 VOID
971 );
972
973 /**
974 Identify a user and, if authenticated, returns the current user profile handle.
975
976 @param[out] User Points to the user profile handle.
977
978 @retval EFI_SUCCESS The user is successfully identified, or user identification
979 is not supported.
980 @retval EFI_ACCESS_DENIED The user was not successfully identified.
981
982 **/
983 EFI_STATUS
984 EFIAPI
985 BdsLibUserIdentify (
986 OUT EFI_USER_PROFILE_HANDLE *User
987 );
988
989 /**
990 This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,
991 it tries to return the valid device path.
992 FV address maybe changes for memory layout adjust from time to time, use this function
993 could promise the Fv file device path is right.
994
995 @param DevicePath On input, the Fv file device path to check. On
996 output, the updated valid Fv file device path
997 @param FileGuid the Fv file GUID.
998
999 @retval EFI_INVALID_PARAMETER The input DevicePath or FileGuid is invalid.
1000 @retval EFI_UNSUPPORTED The input DevicePath does not contain an Fv file
1001 GUID at all.
1002 @retval EFI_ALREADY_STARTED The input DevicePath has pointed to the Fv file and is
1003 valid.
1004 @retval EFI_SUCCESS Successfully updated the invalid DevicePath
1005 and returned the updated device path in DevicePath.
1006
1007 **/
1008 EFI_STATUS
1009 EFIAPI
1010 BdsLibUpdateFvFileDevicePath (
1011 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
1012 IN EFI_GUID *FileGuid
1013 );
1014
1015
1016 /**
1017 Connect the specific USB device that matches the RemainingDevicePath,
1018 and whose bus is determined by Host Controller (Uhci or Ehci).
1019
1020 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
1021 (0xFF).
1022 @param RemainingDevicePath A short-form device path that starts with the first
1023 element being a USB WWID or a USB Class device
1024 path.
1025
1026 @retval EFI_SUCCESS The specific Usb device is connected successfully.
1027 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF)
1028 or RemainingDevicePath is not the USB class device path.
1029 @retval EFI_NOT_FOUND The device specified by device path is not found.
1030
1031 **/
1032 EFI_STATUS
1033 EFIAPI
1034 BdsLibConnectUsbDevByShortFormDP(
1035 IN UINT8 HostControllerPI,
1036 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
1037 );
1038
1039
1040 //
1041 // The implementation of this function is provided by Platform code.
1042 //
1043 /**
1044 Convert Vendor device path to a device name.
1045
1046 @param Str The buffer storing device name.
1047 @param DevPath The pointer to vendor device path.
1048
1049 **/
1050 VOID
1051 DevPathVendor (
1052 IN OUT POOL_PRINT *Str,
1053 IN VOID *DevPath
1054 );
1055
1056 /**
1057 Concatenates a formatted unicode string to an allocated pool.
1058 The caller must free the resulting buffer.
1059
1060 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
1061 @param Fmt The format string.
1062 @param ... The data will be printed.
1063
1064 @return Allocated buffer with the formatted string printed in it.
1065 The caller must free the allocated buffer.
1066 The buffer allocation is not packed.
1067
1068 **/
1069 CHAR16 *
1070 EFIAPI
1071 CatPrint (
1072 IN OUT POOL_PRINT *Str,
1073 IN CHAR16 *Fmt,
1074 ...
1075 );
1076
1077 /**
1078 Use SystemTable ConOut to stop video based Simple Text Out consoles from going
1079 to the video device. Put up LogoFile on every video device that is a console.
1080
1081 @param[in] LogoFile The file name of logo to display on the center of the screen.
1082
1083 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
1084 @retval EFI_UNSUPPORTED Logo not found.
1085
1086 **/
1087 EFI_STATUS
1088 EFIAPI
1089 EnableQuietBoot (
1090 IN EFI_GUID *LogoFile
1091 );
1092
1093
1094 /**
1095 Use SystemTable ConOut to turn on video based Simple Text Out consoles. The
1096 Simple Text Out screens will now be synced up with all non-video output devices.
1097
1098 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
1099
1100 **/
1101 EFI_STATUS
1102 EFIAPI
1103 DisableQuietBoot (
1104 VOID
1105 );
1106
1107 #endif
1108