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