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