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