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