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