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