]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Add BdsLibUserIdentify API in GenericBdsLib
[mirror_edk2.git] / IntelFrameworkModulePkg / Include / Library / GenericBdsLib.h
1 /** @file
2 Generic BDS library defines general interfaces for 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. <BR>
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. 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 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 created
180 the boot option based on the boot device
181
182 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create 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 to create
194 boot option
195 @param BdsBootOptionList The header of the link list which 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 on flash shell boot option
214 @param BdsBootOptionList The header of the link list which 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 configuration table and parsing HOB list
230
231 @param BootMode Boot mode from PEI handoff HOB.
232
233 @retval EFI_SUCCESS Successfully get 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 variable
263 VariableName
264 @param VariableName EFI Variable name indicate the BootOrder or
265 DriverOrder
266
267 @retval EFI_SUCCESS Success create the boot option or driver option
268 list
269 @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or 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 failure, return NULL.
281
282 @param Name String part of EFI variable name
283 @param VendorGuid GUID part of 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 of the EFI variable
287 Caller is responsible freeing the buffer.
288 @retval NULL Variable was not read
289
290 **/
291 VOID *
292 EFIAPI
293 BdsLibGetVariableAndSize (
294 IN CHAR16 *Name,
295 IN EFI_GUID *VendorGuid,
296 OUT UINTN *VariableSize
297 );
298
299
300 /**
301 This function prints a series of strings.
302
303 @param ConOut Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
304 @param ... A variable argument list containing series of
305 strings, the last string must be NULL.
306
307 @retval EFI_SUCCESS Success print out the string using ConOut.
308 @retval EFI_STATUS Return the status of the ConOut->OutputString ().
309
310 **/
311 EFI_STATUS
312 EFIAPI
313 BdsLibOutputStrings (
314 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,
315 ...
316 );
317
318 /**
319 Build the boot#### or driver#### option from the VariableName. The
320 build boot#### or driver#### will also be linked to BdsCommonOptionList.
321
322 @param BdsCommonOptionList The header of the boot#### or driver#### option
323 link list
324 @param VariableName EFI Variable name, indicates if it is boot#### or
325 driver####
326
327 @retval BDS_COMMON_OPTION The option that was created
328 @retval NULL Failed to get the new option
329
330 **/
331 BDS_COMMON_OPTION *
332 EFIAPI
333 BdsLibVariableToOption (
334 IN OUT LIST_ENTRY *BdsCommonOptionList,
335 IN CHAR16 *VariableName
336 );
337
338 /**
339 This function registers the new boot#### or driver#### option based on
340 the VariableName. The new registered boot#### or driver#### will be linked
341 to BdsOptionList and also update to the VariableName. After the boot#### or
342 driver#### updated, the BootOrder or DriverOrder will also be updated.
343
344 @param BdsOptionList The header of the boot#### or driver#### link list
345 @param DevicePath The device path which the boot#### or driver####
346 option present
347 @param String The description of the boot#### or driver####
348 @param VariableName Indicate if the boot#### or driver#### option
349
350 @retval EFI_SUCCESS The boot#### or driver#### have been success
351 registered
352 @retval EFI_STATUS Return the status of gRT->SetVariable ().
353
354 **/
355 EFI_STATUS
356 EFIAPI
357 BdsLibRegisterNewOption (
358 IN LIST_ENTRY *BdsOptionList,
359 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
360 IN CHAR16 *String,
361 IN CHAR16 *VariableName
362 );
363
364 //
365 // Bds connect and disconnect driver lib funcions
366 //
367 /**
368 This function connects all system drivers with the corresponding controllers.
369
370 **/
371 VOID
372 EFIAPI
373 BdsLibConnectAllDriversToAllControllers (
374 VOID
375 );
376
377 /**
378 This function connects all system drivers to controllers.
379
380 **/
381 VOID
382 EFIAPI
383 BdsLibConnectAll (
384 VOID
385 );
386
387 /**
388 This function creates all handles associated with the given device
389 path node. If the handle associated with one device path node can not
390 be created, then it tries to execute the dispatch to load the missing drivers.
391
392 @param DevicePathToConnect The device path to be connected. Can be
393 a multi-instance device path
394
395 @retval EFI_SUCCESS All handles associates with every device path node
396 were created
397 @retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles
398 @retval EFI_NOT_FOUND At least one handle could not be created
399
400 **/
401 EFI_STATUS
402 EFIAPI
403 BdsLibConnectDevicePath (
404 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
405 );
406
407 /**
408 This function will connect all current system handles recursively. gBS->ConnectController() service is invoked for each handle exist in system handler buffer. If the handle is bus type handler, all childrens also will be connected recursively by gBS->ConnectController().
409 @retval EFI_SUCCESS All handles and child handles have been connected @retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
410 **/
411 EFI_STATUS
412 EFIAPI
413 BdsLibConnectAllEfi (
414 VOID
415 );
416
417 /**
418 This function will disconnect all current system handles. gBS->DisconnectController() is invoked for each handle exists in system handle buffer. If handle is a bus type handle, all childrens also are disconnected recursively by gBS->DisconnectController().
419 @retval EFI_SUCCESS All handles have been disconnected
420 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().
421
422 **/
423 EFI_STATUS
424 EFIAPI
425 BdsLibDisconnectAllEfi (
426 VOID
427 );
428
429 //
430 // Bds console related lib functions
431 //
432 /**
433 This function will search every simpletxt device in the current system,
434 and make every simpletxt device a potential console device.
435
436 **/
437 VOID
438 EFIAPI
439 BdsLibConnectAllConsoles (
440 VOID
441 );
442
443
444 /**
445 This function will connect console device based on the console
446 device variable ConIn, ConOut and ErrOut.
447
448 @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have
449 been connected.
450 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
451
452 **/
453 EFI_STATUS
454 EFIAPI
455 BdsLibConnectAllDefaultConsoles (
456 VOID
457 );
458
459 /**
460 This function updates the console variable based on ConVarName. It can
461 add or remove one specific console device path from the variable
462
463 @param ConVarName Console-related variable name: ConIn, ConOut,
464 ErrOut.
465 @param CustomizedConDevicePath The console device path to be added to
466 the console variable ConVarName. Can not be multi-instance.
467 @param ExclusiveDevicePath The console device path to be removed
468 from the console variable ConVarName. Can not be multi-instance.
469
470 @retval EFI_UNSUPPORTED The added device path is the same as a removed one.
471 @retval EFI_SUCCESS Successfully added or removed the device path from the
472 console variable.
473
474 **/
475 EFI_STATUS
476 EFIAPI
477 BdsLibUpdateConsoleVariable (
478 IN CHAR16 *ConVarName,
479 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
480 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
481 );
482
483 /**
484 Connect the console device base on the variable ConVarName. If
485 ConVarName is a multi-instance device path, and at least one
486 instance connects successfully, then this function
487 will return success.
488
489 @param ConVarName Console related variable name, ConIn, ConOut,
490 ErrOut.
491
492 @retval EFI_NOT_FOUND No console devices were connected successfully
493 @retval EFI_SUCCESS Connected at least one instance of the console
494 device path based on the variable ConVarName.
495
496 **/
497 EFI_STATUS
498 EFIAPI
499 BdsLibConnectConsoleVariable (
500 IN CHAR16 *ConVarName
501 );
502
503 //
504 // Bds device path related lib functions
505 //
506 /**
507 Delete the instance in Multi that overlaps with Single
508
509 @param Multi A pointer to a multi-instance device path data
510 structure.
511 @param Single A pointer to a single-instance device path data
512 structure.
513
514 @return This function removes the device path instances in Multi that overlap
515 Single, and returns the resulting device path. If there is no
516 remaining device path as a result, this function will return NULL.
517
518 **/
519 EFI_DEVICE_PATH_PROTOCOL *
520 EFIAPI
521 BdsLibDelPartMatchInstance (
522 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
523 IN EFI_DEVICE_PATH_PROTOCOL *Single
524 );
525
526 /**
527 Function compares a device path data structure to that of all the nodes of a
528 second device path instance.
529
530 @param Multi A pointer to a multi-instance device path data
531 structure.
532 @param Single A pointer to a single-instance device path data
533 structure.
534
535 @retval TRUE If the Single device path is contained within Multi device path.
536 @retval FALSE The Single device path is not contained within Multi device path.
537
538 **/
539 BOOLEAN
540 EFIAPI
541 BdsLibMatchDevicePaths (
542 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
543 IN EFI_DEVICE_PATH_PROTOCOL *Single
544 );
545
546 /**
547 This function converts an input device structure to a Unicode string.
548
549 @param DevPath A pointer to the device path structure.
550
551 @return A new allocated Unicode string that represents the device path.
552
553 **/
554 CHAR16 *
555 EFIAPI
556 DevicePathToStr (
557 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
558 );
559
560
561 //
562 // Internal definitions
563 //
564 typedef struct {
565 CHAR16 *Str;
566 UINTN Len;
567 UINTN Maxlen;
568 } POOL_PRINT;
569
570 typedef
571 VOID
572 (*DEV_PATH_FUNCTION) (
573 IN OUT POOL_PRINT *Str,
574 IN VOID *DevPath
575 );
576
577 typedef struct {
578 UINT8 Type;
579 UINT8 SubType;
580 DEV_PATH_FUNCTION Function;
581 } DEVICE_PATH_STRING_TABLE;
582
583 extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;
584
585 typedef struct {
586 EFI_DEVICE_PATH_PROTOCOL Header;
587 EFI_GUID Guid;
588 UINT8 VendorDefinedData[1];
589 } VENDOR_DEVICE_PATH_WITH_DATA;
590
591
592 extern EFI_GUID mEfiDevicePathMessagingSASGuid;
593
594 typedef struct {
595 EFI_DEVICE_PATH_PROTOCOL Header;
596 UINT16 NetworkProtocol;
597 UINT16 LoginOption;
598 UINT64 Lun;
599 UINT16 TargetPortalGroupTag;
600 CHAR16 TargetName[1];
601 } ISCSI_DEVICE_PATH_WITH_NAME;
602
603
604 //
605 // Notes: EFI 64 shadow all option rom
606 //
607 #if defined (MDE_CPU_IPF)
608 #define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();
609 #else
610 #define EFI64_SHADOW_ALL_LEGACY_ROM()
611 #endif
612
613 /**
614 Shadow all Legacy OptionRom.
615
616 **/
617 VOID
618 EFIAPI
619 ShadowAllOptionRom (
620 VOID
621 );
622
623 //
624 // BBS support macros and functions
625 //
626
627 #if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)
628 #define REFRESH_LEGACY_BOOT_OPTIONS \
629 BdsDeleteAllInvalidLegacyBootOptions ();\
630 BdsAddNonExistingLegacyBootOptions (); \
631 BdsUpdateLegacyDevOrder ()
632 #else
633 #define REFRESH_LEGACY_BOOT_OPTIONS
634 #endif
635
636 /**
637 Delete all the invalid legacy boot options.
638
639 @retval EFI_SUCCESS All invalide legacy boot options are deleted.
640 @retval EFI_OUT_OF_RESOURCES Fail to allocate necessary memory.
641 @retval EFI_NOT_FOUND Fail to retrieve variable of boot order.
642
643 **/
644 EFI_STATUS
645 EFIAPI
646 BdsDeleteAllInvalidLegacyBootOptions (
647 VOID
648 );
649
650 /**
651 Add the legacy boot options from BBS table if they do not exist.
652
653 @retval EFI_SUCCESS The boot options are added successfully
654 or they are already in boot options.
655 @retval EFI_NOT_FOUND No legacy boot options is found.
656 @retval EFI_OUT_OF_RESOURCE No enough memory.
657 @return Other value LegacyBoot options are not added.
658 **/
659 EFI_STATUS
660 EFIAPI
661 BdsAddNonExistingLegacyBootOptions (
662 VOID
663 );
664
665 /**
666 Add the legacy boot devices from BBS table into
667 the legacy device boot order.
668
669 @retval EFI_SUCCESS The boot devices are added successfully.
670 @retval EFI_NOT_FOUND The legacy boot devices are not found.
671 @retval EFI_OUT_OF_RESOURCES Memmory or storage is not enough.
672 @retval EFI_DEVICE_ERROR Fail to add the legacy device boot order into EFI variable
673 because of hardware error.
674 **/
675 EFI_STATUS
676 EFIAPI
677 BdsUpdateLegacyDevOrder (
678 VOID
679 );
680
681 /**
682 Refresh the boot priority for BBS entries based on boot option entry and boot order.
683
684 @param Entry The boot option is to be checked for refresh BBS table.
685
686 @retval EFI_SUCCESS The boot priority for BBS entries is refreshed successfully.
687 @retval EFI_NOT_FOUND BBS entries can't be found.
688 @retval EFI_OUT_OF_RESOURCES Failed to get the legacy device boot order.
689 **/
690 EFI_STATUS
691 EFIAPI
692 BdsRefreshBbsTableForBoot (
693 IN BDS_COMMON_OPTION *Entry
694 );
695
696 /**
697 Delete the Boot Option from EFI Variable. The Boot Order Arrray
698 is also updated.
699
700 @param OptionNumber The number of Boot option want to be deleted.
701 @param BootOrder The Boot Order array.
702 @param BootOrderSize The size of the Boot Order Array.
703
704 @retval EFI_SUCCESS The Boot Option Variable was found and removed
705 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible
706 @retval EFI_NOT_FOUND The Boot Option Variable was not found
707 **/
708 EFI_STATUS
709 EFIAPI
710 BdsDeleteBootOption (
711 IN UINTN OptionNumber,
712 IN OUT UINT16 *BootOrder,
713 IN OUT UINTN *BootOrderSize
714 );
715
716 //
717 //The interface functions related to the Setup Browser Reset Reminder feature
718 //
719 /**
720 Enable the setup browser reset reminder feature.
721 This routine is used in platform tip. If the platform policy needs the feature, use the routine to enable it.
722
723 **/
724 VOID
725 EFIAPI
726 EnableResetReminderFeature (
727 VOID
728 );
729
730 /**
731 Disable the setup browser reset reminder feature.
732 This routine is used in platform tip. If the platform policy does not want the feature, use the routine to disable it.
733
734 **/
735 VOID
736 EFIAPI
737 DisableResetReminderFeature (
738 VOID
739 );
740
741 /**
742 Record the info that a reset is required.
743 A module boolean variable is used to record whether a reset is required.
744
745 **/
746 VOID
747 EFIAPI
748 EnableResetRequired (
749 VOID
750 );
751
752
753 /**
754 Record the info that no reset is required.
755 A module boolean variable is used to record whether a reset is required.
756
757 **/
758 VOID
759 EFIAPI
760 DisableResetRequired (
761 VOID
762 );
763
764 /**
765 Check whether platform policy enables the reset reminder feature. The default is enabled.
766
767 **/
768 BOOLEAN
769 EFIAPI
770 IsResetReminderFeatureEnable (
771 VOID
772 );
773
774 /**
775 Check if the user changed any option setting that needs a system reset to be effective.
776
777 **/
778 BOOLEAN
779 EFIAPI
780 IsResetRequired (
781 VOID
782 );
783
784 /**
785 Check whether a reset is needed, and finish the reset reminder feature.
786 If a reset is needed, pop up a menu to notice user, and finish the feature
787 according to the user selection.
788
789 **/
790 VOID
791 EFIAPI
792 SetupResetReminder (
793 VOID
794 );
795
796
797 ///
798 /// Define the boot type which to classify the boot option type
799 /// Different boot option type could have different boot behavior
800 /// Use their device path node (Type + SubType) as type value
801 /// The boot type here can be added according to requirement
802 ///
803
804 ///
805 /// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value
806 ///
807 #define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201
808 ///
809 /// Message boot type
810 /// If a device path of boot option only point to a message node, the boot option is message boot type
811 ///
812 #define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01
813 #define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02
814 #define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05
815 #define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18
816 #define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11
817 #define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF
818
819 ///
820 /// Media boot type
821 /// If a device path of boot option contain a media node, the boot option is media boot type
822 ///
823 #define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01
824 #define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02
825 ///
826 /// BBS boot type
827 /// If a device path of boot option contain a BBS node, the boot option is BBS boot type
828 ///
829 #define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01
830
831 #define BDS_EFI_UNSUPPORT 0xFFFF
832
833 /**
834 Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path
835
836 @param BlockIoDevicePath Multi device path instances to check
837 @param HardDriveDevicePath A device path starting with a hard drive media
838 device path.
839
840 @retval TRUE There is a matched device path instance.
841 @retval FALSE There is no matched device path instance.
842
843 **/
844 BOOLEAN
845 EFIAPI
846 MatchPartitionDevicePathNode (
847 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
848 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
849 );
850
851
852 /**
853 Expand a device path that starts with a hard drive media device path node to be a
854 full device path that includes the full hardware path to the device. This function enables the device to boot.
855 To avoid requiring a connect on every boot, the front match is saved in a variable (the part point
856 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).
857 All successful history device paths
858 that point to the front part of the partition node will be saved.
859
860 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard
861 drive media device path.
862 @return A Pointer to the full device path or NULL if a valid Hard Drive devic path
863 cannot be found.
864
865 **/
866 EFI_DEVICE_PATH_PROTOCOL *
867 EFIAPI
868 BdsExpandPartitionPartialDevicePathToFull (
869 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
870 );
871
872 /**
873 Return the bootable media handle.
874 First, check whether the device is connected.
875 Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.
876 Third, detect the the default boot file in the Media, and return the removable Media handle.
877
878 @param DevicePath Device Path to a bootable device
879
880 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.
881
882 **/
883 EFI_HANDLE
884 EFIAPI
885 BdsLibGetBootableHandle (
886 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
887 );
888
889
890 /**
891 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
892 is ready to boot now.
893
894 @param DevPath the Device path in a boot option
895 @param CheckMedia if true, check whether the device is ready to boot now.
896
897 @retval TRUE the Device path is valid
898 @retval FALSE the Device path is invalid
899
900 **/
901 BOOLEAN
902 EFIAPI
903 BdsLibIsValidEFIBootOptDevicePath (
904 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
905 IN BOOLEAN CheckMedia
906 );
907
908 /**
909 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
910 is ready to boot now.
911 If Description is not NULL and the device path points to a fixed BlockIo
912 device, this function checks whether the description conflicts with other auto-created
913 boot options.
914
915 @param DevPath the Device path in a boot option
916 @param CheckMedia if true, checks if the device is ready to boot now.
917 @param Description the description of a boot option
918
919 @retval TRUE the Device path is valid
920 @retval FALSE the Device path is invalid
921
922 **/
923 BOOLEAN
924 EFIAPI
925 BdsLibIsValidEFIBootOptDevicePathExt (
926 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
927 IN BOOLEAN CheckMedia,
928 IN CHAR16 *Description
929 );
930
931 /**
932 For a bootable Device path, return its boot type.
933
934 @param DevicePath The bootable device Path to check
935
936 @retval BDS_EFI_MEDIA_HD_BOOT If 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,
937 **/
938 UINT32
939 EFIAPI
940 BdsGetBootTypeFromDevicePath (
941 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
942 );
943
944
945 /**
946 This routine registers a function to adjust the different types of memory page numbers
947 just before booting, and saves the updated info into the variable for the next boot to use.
948
949 **/
950 VOID
951 EFIAPI
952 BdsLibSaveMemoryTypeInformation (
953 VOID
954 );
955
956 /**
957 Identify a user and, if authenticated, returns the current user profile handle.
958
959 @param[out] User Point to user profile handle.
960
961 @retval EFI_SUCCESS User is successfully identified, or user identification
962 is not supported.
963 @retval EFI_ACCESS_DENIED User is not successfully identified
964
965 **/
966 EFI_STATUS
967 EFIAPI
968 BdsLibUserIdentify (
969 OUT EFI_USER_PROFILE_HANDLE *User
970 );
971
972 /**
973 This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,
974 it tries to return the valid device path.
975 FV address maybe changes for memory layout adjust from time to time, use this funciton
976 could promise the Fv file device path is right.
977
978 @param DevicePath on input, the Fv file device path to check. On
979 output, the updated valid Fv file device path
980 @param FileGuid the Fv file GUID
981
982 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid
983 @retval EFI_UNSUPPORTED the input DevicePath does not contain an Fv file
984 GUID at all
985 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to the Fv file and is
986 valid
987 @retval EFI_SUCCESS successfully updated the invalid DevicePath
988 and returned the updated device path in DevicePath
989
990 **/
991 EFI_STATUS
992 EFIAPI
993 BdsLibUpdateFvFileDevicePath (
994 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
995 IN EFI_GUID *FileGuid
996 );
997
998
999 /**
1000 Connect the specific USB device that matches the RemainingDevicePath,
1001 and whose bus is determined by Host Controller (Uhci or Ehci)
1002
1003 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
1004 (0xFF)
1005 @param RemainingDevicePath a short-form device path that starts with the first
1006 element being a USB WWID or a USB Class device
1007 path
1008
1009 @retval EFI_SUCCESS The specific Usb device is connected successfully.
1010 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF)
1011 or RemainingDevicePath is not the USB class device path.
1012 @retval EFI_NOT_FOUND The device specified by device path is not found.
1013
1014 **/
1015 EFI_STATUS
1016 EFIAPI
1017 BdsLibConnectUsbDevByShortFormDP(
1018 IN UINT8 HostControllerPI,
1019 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
1020 );
1021
1022
1023 //
1024 // The implementation of this function is provided by Platform code.
1025 //
1026 /**
1027 Convert Vendor device path to a device name.
1028
1029 @param Str The buffer storing device name
1030 @param DevPath Pointer to vendor device path
1031
1032 **/
1033 VOID
1034 DevPathVendor (
1035 IN OUT POOL_PRINT *Str,
1036 IN VOID *DevPath
1037 );
1038
1039 /**
1040 Concatenates a formatted unicode string to allocated pool.
1041 The caller must free the resulting buffer.
1042
1043 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
1044 @param Fmt The format string
1045 @param ... The data will be printed.
1046
1047 @return Allocated buffer with the formatted string printed in it.
1048 The caller must free the allocated buffer.
1049 The buffer allocation is not packed.
1050
1051 **/
1052 CHAR16 *
1053 EFIAPI
1054 CatPrint (
1055 IN OUT POOL_PRINT *Str,
1056 IN CHAR16 *Fmt,
1057 ...
1058 );
1059
1060 /**
1061 Use SystemTable ConOut to stop video based Simple Text Out consoles from going
1062 to the video device. Put up LogoFile on every video device that is a console.
1063
1064 @param[in] LogoFile File name of logo to display on the center of the screen.
1065
1066 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
1067 @retval EFI_UNSUPPORTED Logo not found
1068
1069 **/
1070 EFI_STATUS
1071 EFIAPI
1072 EnableQuietBoot (
1073 IN EFI_GUID *LogoFile
1074 );
1075
1076
1077 /**
1078 Use SystemTable ConOut to turn on video based Simple Text Out consoles. The
1079 Simple Text Out screens will now be synced up with all non video output devices
1080
1081 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
1082
1083 **/
1084 EFI_STATUS
1085 EFIAPI
1086 DisableQuietBoot (
1087 VOID
1088 );
1089
1090 #endif
1091