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