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