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