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