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