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