]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Committing changes to the comments, to improve code documentation.
[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 - 2009, 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 extern EFI_HANDLE mBdsImageHandle;
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 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 follow the UEFI specification and
113 special treat the legacy boot option with 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 BdsLibVariableToOption () for each UINT16 in the variables.
260
261 @param BdsCommonOptionList The header of the option list base on variable VariableName. @param VariableName EFI Variable name indicate the BootOrder or DriverOrder.
262 @retval EFI_SUCCESS Successfully created the boot option or driver option list @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or driver option list**/
263 EFI_STATUS
264 EFIAPI
265 BdsLibBuildOptionFromVar (
266 IN LIST_ENTRY *BdsCommonOptionList,
267 IN CHAR16 *VariableName
268 );
269
270 /**
271 This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated
272 buffer and the size of the buffer. If failure, return NULL.
273
274 @param Name String part of EFI variable name
275 @param VendorGuid GUID part of EFI variable name
276 @param VariableSize Returns the size of the EFI variable that was read
277
278 @return Dynamically allocated memory that contains a copy of the EFI variable
279 Caller is responsible freeing the buffer.
280 @retval NULL Variable was not read
281
282 **/
283 VOID *
284 EFIAPI
285 BdsLibGetVariableAndSize (
286 IN CHAR16 *Name,
287 IN EFI_GUID *VendorGuid,
288 OUT UINTN *VariableSize
289 );
290
291
292 /**
293 This function prints a series of strings.
294
295 @param ConOut Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
296 @param ... A variable argument list containing series of
297 strings, the last string must be NULL.
298
299 @retval EFI_SUCCESS Success print out the string using ConOut.
300 @retval EFI_STATUS Return the status of the ConOut->OutputString ().
301
302 **/
303 EFI_STATUS
304 EFIAPI
305 BdsLibOutputStrings (
306 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,
307 ...
308 );
309
310 /**
311 Build the boot#### or driver#### option from the VariableName. The
312 build boot#### or driver#### will also be linked to BdsCommonOptionList.
313
314 @param BdsCommonOptionList The header of the boot#### or driver#### option
315 link list
316 @param VariableName EFI Variable name, indicates if it is boot#### or
317 driver####
318
319 @retval BDS_COMMON_OPTION The option that was created
320 @retval NULL Failed to get the new option
321
322 **/
323 BDS_COMMON_OPTION *
324 EFIAPI
325 BdsLibVariableToOption (
326 IN OUT LIST_ENTRY *BdsCommonOptionList,
327 IN CHAR16 *VariableName
328 );
329
330 /**
331 This function registers the new boot#### or driver#### option based on
332 the VariableName. The new registered boot#### or driver#### will be linked
333 to BdsOptionList and also update to the VariableName. After the boot#### or
334 driver#### updated, the BootOrder or DriverOrder will also be updated.
335
336 @param BdsOptionList The header of the boot#### or driver#### link list
337 @param DevicePath The device path which the boot#### or driver####
338 option present
339 @param String The description of the boot#### or driver####
340 @param VariableName Indicate if the boot#### or driver#### option
341
342 @retval EFI_SUCCESS The boot#### or driver#### have been success
343 registered
344 @retval EFI_STATUS Return the status of gRT->SetVariable ().
345
346 **/
347 EFI_STATUS
348 EFIAPI
349 BdsLibRegisterNewOption (
350 IN LIST_ENTRY *BdsOptionList,
351 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
352 IN CHAR16 *String,
353 IN CHAR16 *VariableName
354 );
355
356 //
357 // Bds connect and disconnect driver lib funcions
358 //
359 /**
360 This function connects all system drivers with the corresponding controllers.
361
362 **/
363 VOID
364 EFIAPI
365 BdsLibConnectAllDriversToAllControllers (
366 VOID
367 );
368
369 /**
370 This function connects all system drivers to controllers.
371
372 **/
373 VOID
374 EFIAPI
375 BdsLibConnectAll (
376 VOID
377 );
378
379 /**
380 This function creates all handles associated with every device
381 path node. If the handle associated with one device path node can not
382 be created, then it tries to execute the dispatch to load the missing drivers.
383
384 @param DevicePathToConnect The device path to be connected. Can be
385 a multi-instance device path
386
387 @retval EFI_SUCCESS All handles associates with every device path node
388 were created
389 @retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles
390 @retval EFI_NOT_FOUND At least one handle could not be created
391
392 **/
393 EFI_STATUS
394 EFIAPI
395 BdsLibConnectDevicePath (
396 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
397 );
398
399 /**
400 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().
401 @retval EFI_SUCCESS All handles and child handles have been connected @retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
402 **/
403 EFI_STATUS
404 EFIAPI
405 BdsLibConnectAllEfi (
406 VOID
407 );
408
409 /**
410 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().
411 @retval EFI_SUCCESS All handles have been disconnected
412 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().
413
414 **/
415 EFI_STATUS
416 EFIAPI
417 BdsLibDisconnectAllEfi (
418 VOID
419 );
420
421 //
422 // Bds console related lib functions
423 //
424 /**
425 This function will search every simpletxt device in the current system,
426 and make every simpletxt device as pertantial console device.
427
428 **/
429 VOID
430 EFIAPI
431 BdsLibConnectAllConsoles (
432 VOID
433 );
434
435
436 /**
437 This function will connect console device based on the console
438 device variable ConIn, ConOut and ErrOut.
439
440 @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have
441 been connected.
442 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
443
444 **/
445 EFI_STATUS
446 EFIAPI
447 BdsLibConnectAllDefaultConsoles (
448 VOID
449 );
450
451 /**
452 This function updates the console variable based on ConVarName. It can
453 add or remove one specific console device path from the variable
454
455 @param ConVarName Console-related variable name: ConIn, ConOut,
456 ErrOut.
457 @param CustomizedConDevicePath The console device path to be added to
458 the console variable ConVarName. Can not be multi-instance.
459 @param ExclusiveDevicePath The console device path to be removed
460 from the console variable ConVarName. Can not be multi-instance.
461
462 @retval EFI_UNSUPPORTED The added device path is the same as a removed one.
463 @retval EFI_SUCCESS Successfully added or removed the device path from the
464 console variable.
465
466 **/
467 EFI_STATUS
468 EFIAPI
469 BdsLibUpdateConsoleVariable (
470 IN CHAR16 *ConVarName,
471 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
472 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
473 );
474
475 /**
476 Connect the console device base on the variable ConVarName. If
477 ConVarName is a multi-instance device path, and at least one
478 instance connects successfully, then this function
479 will return success.
480
481 @param ConVarName Console related variable name, ConIn, ConOut,
482 ErrOut.
483
484 @retval EFI_NOT_FOUND No console devices were connected successfully
485 @retval EFI_SUCCESS Connected at least one instance of the console
486 device path based on the variable ConVarName.
487
488 **/
489 EFI_STATUS
490 EFIAPI
491 BdsLibConnectConsoleVariable (
492 IN CHAR16 *ConVarName
493 );
494
495 //
496 // Bds device path related lib functions
497 //
498 /**
499 Delete the instance in Multi that overlaps with Single
500
501 @param Multi A pointer to a multi-instance device path data
502 structure.
503 @param Single A pointer to a single-instance device path data
504 structure.
505
506 @return This function removes the device path instances in Multi that overlap
507 Single, and returns the resulting device path. If there is no
508 remaining device path as a result, this function will return NULL.
509
510 **/
511 EFI_DEVICE_PATH_PROTOCOL *
512 EFIAPI
513 BdsLibDelPartMatchInstance (
514 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
515 IN EFI_DEVICE_PATH_PROTOCOL *Single
516 );
517
518 /**
519 Function compares a device path data structure to that of all the nodes of a
520 second device path instance.
521
522 @param Multi A pointer to a multi-instance device path data
523 structure.
524 @param Single A pointer to a single-instance device path data
525 structure.
526
527 @retval TRUE If the Single device path is contained within Multi device path.
528 @retval FALSE The Single device path is not contained within Multi device path.
529
530 **/
531 BOOLEAN
532 EFIAPI
533 BdsLibMatchDevicePaths (
534 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
535 IN EFI_DEVICE_PATH_PROTOCOL *Single
536 );
537
538 /**
539 This function converts an input device structure to a Unicode string.
540
541 @param DevPath A pointer to the device path structure.
542
543 @return A new allocated Unicode string that represents the device path.
544
545 **/
546 CHAR16 *
547 EFIAPI
548 DevicePathToStr (
549 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
550 );
551
552
553 //
554 // Internal definitions
555 //
556 typedef struct {
557 CHAR16 *Str;
558 UINTN Len;
559 UINTN Maxlen;
560 } POOL_PRINT;
561
562 typedef struct {
563 UINT8 Type;
564 UINT8 SubType;
565 VOID (*Function) (POOL_PRINT *, VOID *);
566 } DEVICE_PATH_STRING_TABLE;
567
568 extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;
569
570 typedef struct {
571 EFI_DEVICE_PATH_PROTOCOL Header;
572 EFI_GUID Guid;
573 UINT8 VendorDefinedData[1];
574 } VENDOR_DEVICE_PATH_WITH_DATA;
575
576
577 extern EFI_GUID mEfiDevicePathMessagingSASGuid;
578
579 typedef struct {
580 EFI_DEVICE_PATH_PROTOCOL Header;
581 UINT16 NetworkProtocol;
582 UINT16 LoginOption;
583 UINT64 Lun;
584 UINT16 TargetPortalGroupTag;
585 CHAR16 TargetName[1];
586 } ISCSI_DEVICE_PATH_WITH_NAME;
587
588
589 //
590 // Notes: EFI 64 shadow all option rom
591 //
592 #if defined (MDE_CPU_IPF)
593 #define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();
594 #else
595 #define EFI64_SHADOW_ALL_LEGACY_ROM()
596 #endif
597
598 /**
599 Shadow all Legacy OptionRom.
600
601 **/
602 VOID
603 EFIAPI
604 ShadowAllOptionRom (
605 VOID
606 );
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 invalide legacy boot options are deleted.
625 @retval EFI_OUT_OF_RESOURCES Fail to allocate necessary memory.
626 @retval EFI_NOT_FOUND Fail 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 are 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 are added successfully.
655 @retval EFI_NOT_FOUND The legacy boot devices are not found.
656 @retval EFI_OUT_OF_RESOURCES Memmory or storage is not enough.
657 @retval EFI_DEVICE_ERROR Fail to add the legacy device boot order into EFI variable
658 because of hardware error.
659 **/
660 EFI_STATUS
661 EFIAPI
662 BdsUpdateLegacyDevOrder (
663 VOID
664 );
665
666 /**
667 Set 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 refresh BBS table.
670
671 @retval EFI_SUCCESS The boot priority for BBS entries is 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 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
683 is also updated.
684
685 @param OptionNumber The number of Boot option want 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 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 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 option default description
784 ///
785 #define DESCRIPTION_FLOPPY L"EFI Floppy"
786 #define DESCRIPTION_FLOPPY_NUM L"EFI Floppy %d"
787 #define DESCRIPTION_DVD L"EFI DVD/CDROM"
788 #define DESCRIPTION_DVD_NUM L"EFI DVD/CDROM %d"
789 #define DESCRIPTION_USB L"EFI USB Device"
790 #define DESCRIPTION_USB_NUM L"EFI USB Device %d"
791 #define DESCRIPTION_SCSI L"EFI SCSI Device"
792 #define DESCRIPTION_SCSI_NUM L"EFI SCSI Device %d"
793 #define DESCRIPTION_MISC L"EFI Misc Device"
794 #define DESCRIPTION_MISC_NUM L"EFI Misc Device %d"
795 #define DESCRIPTION_NETWORK L"EFI Network"
796 #define DESCRIPTION_NETWORK_NUM L"EFI Network %d"
797 #define DESCRIPTION_NON_BLOCK L"EFI Non-Block Boot Device"
798 #define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d"
799
800 ///
801 /// Define the boot type which to classify the boot option type
802 /// Different boot option type could have different boot behavior
803 /// Use their device path node (Type + SubType) as type value
804 /// The boot type here can be added according to requirement
805 ///
806
807 ///
808 /// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value
809 ///
810 #define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201
811 ///
812 /// Message boot type
813 /// If a device path of boot option only point to a message node, the boot option is message boot type
814 ///
815 #define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01
816 #define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02
817 #define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05
818 #define BDS_EFI_MESSAGE_SATA_BOOT 0x0318 // Type 03; Sub-Type 18
819 #define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF
820 ///
821 /// Media boot type
822 /// If a device path of boot option contain a media node, the boot option is media boot type
823 ///
824 #define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01
825 #define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02
826 ///
827 /// BBS boot type
828 /// If a device path of boot option contain a BBS node, the boot option is BBS boot type
829 ///
830 #define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01
831
832 #define BDS_EFI_UNSUPPORT 0xFFFF
833
834 ///
835 /// USB host controller Programming Interface.
836 ///
837 #define PCI_CLASSC_PI_UHCI 0x00
838 #define PCI_CLASSC_PI_EHCI 0x20
839
840 /**
841 Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path
842
843 @param BlockIoDevicePath Multi device path instances to check
844 @param HardDriveDevicePath A device path starting with a hard drive media
845 device path.
846
847 @retval TRUE There is a matched device path instance.
848 @retval FALSE There is no matched device path instance.
849
850 **/
851 BOOLEAN
852 EFIAPI
853 MatchPartitionDevicePathNode (
854 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
855 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
856 );
857
858
859 /**
860 Expand a device path that starts with a hard drive media device path node to be a
861 full device path that includes the full hardware path to the device. We need
862 to do this so it can be booted. As an optimizaiton the front match (the part point
863 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable
864 so a connect all is not required on every boot. All successful history device path
865 which point to partition node (the front part) will be saved.
866
867 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard
868 drive media device path.
869 @return A Pointer to the full device path or NULL if a valid Hard Drive devic path
870 cannot be found.
871
872 **/
873 EFI_DEVICE_PATH_PROTOCOL *
874 EFIAPI
875 BdsExpandPartitionPartialDevicePathToFull (
876 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
877 );
878
879 /**
880 Return the bootable media handle.
881 First, check whether the device is connected.
882 Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.
883 Third, detect the the default boot file in the Media, and return the removable Media handle.
884
885 @param DevicePath Device Path to a bootable device
886
887 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.
888
889 **/
890 EFI_HANDLE
891 EFIAPI
892 BdsLibGetBootableHandle (
893 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
894 );
895
896
897 /**
898 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
899 is ready to boot now.
900
901 @param DevPath the Device path in a boot option
902 @param CheckMedia if true, check whether the device is ready to boot now.
903
904 @retval TRUE the Device path is valid
905 @retval FALSE the Device path is invalid
906
907 **/
908 BOOLEAN
909 EFIAPI
910 BdsLibIsValidEFIBootOptDevicePath (
911 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
912 IN BOOLEAN CheckMedia
913 );
914
915 /**
916 Checks whether the Device path in a boot option points to a valid bootable device, and if the device
917 is ready to boot now.
918 If Description is not NULL and the device path points to a fixed BlockIo
919 device, this function checks whether the description conflicts with other auto-created
920 boot options.
921
922 @param DevPath the Device path in a boot option
923 @param CheckMedia if true, checks if the device is ready to boot now.
924 @param Description the description of a boot option
925
926 @retval TRUE the Device path is valid
927 @retval FALSE the Device path is invalid
928
929 **/
930 BOOLEAN
931 EFIAPI
932 BdsLibIsValidEFIBootOptDevicePathExt (
933 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,
934 IN BOOLEAN CheckMedia,
935 IN CHAR16 *Description
936 );
937
938 /**
939 For a bootable Device path, return its boot type.
940
941 @param DevicePath The bootable device Path to check
942
943 @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,
944 **/
945 UINT32
946 EFIAPI
947 BdsGetBootTypeFromDevicePath (
948 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
949 );
950
951
952 /**
953 This routine registers a function to adjust the different types of memory page numbers
954 just before booting, and saves the updated info into the variable for the next boot to use.
955
956 **/
957 VOID
958 EFIAPI
959 BdsLibSaveMemoryTypeInformation (
960 VOID
961 );
962
963
964 /**
965 This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,
966 it tries to return the valid device path.
967 FV address maybe changes for memory layout adjust from time to time, use this funciton
968 could promise the Fv file device path is right.
969
970 @param DevicePath on input, the Fv file device path to check. On
971 output, the updated valid Fv file device path
972 @param FileGuid the Fv file GUID
973
974 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid
975 @retval EFI_UNSUPPORTED the input DevicePath does not contain an Fv file
976 GUID at all
977 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to the Fv file and is
978 valid
979 @retval EFI_SUCCESS successfully updated the invalid DevicePath
980 and returned the updated device path in DevicePath
981
982 **/
983 EFI_STATUS
984 EFIAPI
985 BdsLibUpdateFvFileDevicePath (
986 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
987 IN EFI_GUID *FileGuid
988 );
989
990
991 /**
992 Connect the specific USB device that matches the RemainingDevicePath,
993 and whose bus is determined by Host Controller (Uhci or Ehci)
994
995 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
996 (0xFF)
997 @param RemainingDevicePath a short-form device path that starts with the first
998 element being a USB WWID or a USB Class device
999 path
1000
1001 @retval EFI_SUCCESS The specific Usb device is connected successfully.
1002 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF)
1003 or RemainingDevicePath is not the USB class device path.
1004 @retval EFI_NOT_FOUND The device specified by device path is not found.
1005
1006 **/
1007 EFI_STATUS
1008 EFIAPI
1009 BdsLibConnectUsbDevByShortFormDP(
1010 IN UINT8 HostControllerPI,
1011 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
1012 );
1013
1014
1015 //
1016 // The implementation of this function is provided by Platform code.
1017 //
1018 /**
1019 Convert Vendor device path to a device name.
1020
1021 @param Str The buffer storing device name
1022 @param DevPath Pointer to vendor device path
1023
1024 **/
1025 VOID
1026 DevPathVendor (
1027 IN OUT POOL_PRINT *Str,
1028 IN VOID *DevPath
1029 );
1030
1031 /**
1032 Concatenates a formatted unicode string to allocated pool.
1033 The caller must free the resulting buffer.
1034
1035 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
1036 @param Fmt The format string
1037 @param ... The data will be printed.
1038
1039 @return Allocated buffer with the formatted string printed in it.
1040 The caller must free the allocated buffer.
1041 The buffer allocation is not packed.
1042
1043 **/
1044 CHAR16 *
1045 EFIAPI
1046 CatPrint (
1047 IN OUT POOL_PRINT *Str,
1048 IN CHAR16 *Fmt,
1049 ...
1050 );
1051
1052 /**
1053 Use Console Control to stop UGA-based Simple Text Out consoles from going
1054 to the UGA device. Put up LogoFile on every UGA device that is a console.
1055
1056 @param[in] LogoFile File name of logo to display on the center of the screen.
1057
1058 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
1059 @retval EFI_UNSUPPORTED Logo not found
1060
1061 **/
1062 EFI_STATUS
1063 EFIAPI
1064 EnableQuietBoot (
1065 IN EFI_GUID *LogoFile
1066 );
1067
1068
1069 /**
1070 Use Console Control to turn on UGA based Simple Text Out consoles. The UGA
1071 Simple Text Out screens will now be synced up with all non UGA output devices
1072
1073 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
1074
1075 **/
1076 EFI_STATUS
1077 EFIAPI
1078 DisableQuietBoot (
1079 VOID
1080 );
1081
1082 /**
1083 Use Console Control Protocol to lock the Console In Spliter virtual handle.
1084 This is the ConInHandle and ConIn handle in the EFI system table. All key
1085 presses will be ignored until the Password is typed in. The only way to
1086 disable the password is to type it in to a ConIn device.
1087
1088 @param Password Password used to lock ConIn device.
1089
1090 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
1091 @retval EFI_UNSUPPORTED Password not found
1092
1093 **/
1094 EFI_STATUS
1095 EFIAPI
1096 LockKeyboards (
1097 IN CHAR16 *Password
1098 );
1099
1100 #endif
1101