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