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