]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Program SD Cards into 4-bit mode (support for this is required in the spec). This...
[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
180a5a35 7Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
49fd8a35 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
ddac74d1 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
337661bb 21#include <Protocol/UserManager.h>\r
ddac74d1 22extern EFI_HANDLE mBdsImageHandle;\r
23\r
e83c9064 24///\r
49fd8a35 25/// Constants which are variable names used to access variables.\r
e83c9064 26///\r
ddac74d1 27#define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
28\r
e83c9064 29///\r
49fd8a35 30/// Data structures and defines.\r
e83c9064 31///\r
ddac74d1 32#define FRONT_PAGE_QUESTION_ID 0x0000\r
33#define FRONT_PAGE_DATA_WIDTH 0x01\r
34\r
e83c9064
LG
35///\r
36/// ConnectType\r
37///\r
ddac74d1 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
e83c9064
LG
43///\r
44/// Load Option Attributes\r
45///\r
ddac74d1 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
e83c9064 60///\r
49fd8a35 61/// Define the maximum characters that will be accepted.\r
e83c9064 62///\r
ddac74d1 63#define MAX_CHAR 480\r
64#define MAX_CHAR_SIZE (MAX_CHAR * 2)\r
65\r
e83c9064 66///\r
49fd8a35 67/// Define maximum characters for boot option variable "BootXXXX".\r
e83c9064 68///\r
ddac74d1 69#define BOOT_OPTION_MAX_CHAR 10\r
70\r
71//\r
e83c9064 72// This data structure is the part of BDS_CONNECT_ENTRY\r
ddac74d1 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
ddac74d1 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
d0bd68b2 113 Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.\r
ddac74d1 114\r
49fd8a35 115 @param Option The boot option to be processed.\r
3d8bd97c 116 @param DevicePath The device path describing where to load the\r
ddac74d1 117 boot image or the legcy BBS device path to boot\r
49fd8a35 118 the legacy OS.\r
ddac74d1 119 @param ExitDataSize The size of exit data.\r
120 @param ExitData Data returned when Boot image failed.\r
121\r
3d8bd97c 122 @retval EFI_SUCCESS Boot from the input boot option succeeded.\r
49fd8a35 123 @retval EFI_NOT_FOUND The Device Path is not found in the system.\r
ddac74d1 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
3d8bd97c 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
8d3b5aff 142 1. Network - The boot option points to the SimpleNetworkProtocol device. \r
3d8bd97c 143 Bds will try to automatically create this type of boot option during enumeration.\r
8d3b5aff 144 2. Shell - The boot option points to internal flash shell. \r
3d8bd97c 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
8d3b5aff 149 protocol in their device handle.\r
150 Bds will try to automatically create this type boot option \r
151 when enumerate.\r
3d8bd97c 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
8d3b5aff 155 protocol in their device handle.\r
3d8bd97c 156 BDS will skip fixed blockIo devices, and not\r
8d3b5aff 157 automatically create boot option for them. But BDS \r
3d8bd97c 158 will help to delete those fixed blockIo boot options, \r
159 whose description rules conflict with other auto-created\r
8d3b5aff 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
3d8bd97c 168 created by the user, either manually or with an OS loader. BDS will not delete or modify\r
8d3b5aff 169 these boot options. \r
170 \r
3d8bd97c 171 This function will enumerate all possible boot devices in the system, and\r
8d3b5aff 172 automatically create boot options for Network, Shell, Removable BlockIo, \r
173 and Non-BlockIo Simplefile devices.\r
3d8bd97c 174 It will excute once every boot.\r
8d3b5aff 175 \r
3d8bd97c 176 @param BdsBootOptionList The header of the linked list that indexed all\r
49fd8a35 177 current boot options.\r
ddac74d1 178\r
49fd8a35 179 @retval EFI_SUCCESS Finished all the boot device enumerations and \r
180 created the boot option based on the boot device.\r
ddac74d1 181\r
49fd8a35 182 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create \r
183 the boot option list.\r
ddac74d1 184**/\r
185EFI_STATUS\r
186EFIAPI\r
187BdsLibEnumerateAllBootOption (\r
188 IN OUT LIST_ENTRY *BdsBootOptionList\r
189 );\r
190\r
191/**\r
49fd8a35 192 Build the boot option with the handle parsed in.\r
ddac74d1 193\r
49fd8a35 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
ddac74d1 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
49fd8a35 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
ddac74d1 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
ddac74d1 229/**\r
49fd8a35 230 Get boot mode by looking up the configuration table and parsing the HOB list.\r
ddac74d1 231\r
49fd8a35 232 @param BootMode The boot mode from PEI handoff HOB.\r
ddac74d1 233\r
49fd8a35 234 @retval EFI_SUCCESS Successfully got boot mode.\r
ddac74d1 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
3d8bd97c 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
ddac74d1 247\r
49fd8a35 248 @param BdsDriverLists The header of the current driver option link list.\r
ddac74d1 249\r
250**/\r
251VOID\r
252EFIAPI\r
253BdsLibLoadDrivers (\r
254 IN LIST_ENTRY *BdsDriverLists\r
255 );\r
256\r
257\r
258/**\r
d0bd68b2 259 This function processes BootOrder or DriverOrder variables, by calling\r
260\r
ddac74d1 261 BdsLibVariableToOption () for each UINT16 in the variables.\r
262\r
49fd8a35 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
24cdd14e 267\r
49fd8a35 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
24cdd14e 271**/\r
ddac74d1 272EFI_STATUS\r
273EFIAPI\r
274BdsLibBuildOptionFromVar (\r
275 IN LIST_ENTRY *BdsCommonOptionList,\r
276 IN CHAR16 *VariableName\r
277 );\r
278\r
279/**\r
3d8bd97c 280 This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated\r
49fd8a35 281 buffer and the size of the buffer. If it fails, return NULL.\r
ddac74d1 282\r
49fd8a35 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
ddac74d1 286\r
49fd8a35 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
ddac74d1 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
49fd8a35 305 @param ConOut A pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
306 @param ... A variable argument list containing a series of\r
ddac74d1 307 strings, the last string must be NULL.\r
308\r
49fd8a35 309 @retval EFI_SUCCESS Successfully printed out the string using ConOut.\r
ddac74d1 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
3d8bd97c 321 Build the boot#### or driver#### option from the VariableName. The\r
ddac74d1 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
49fd8a35 325 link list.\r
3d8bd97c 326 @param VariableName EFI Variable name, indicates if it is boot#### or\r
49fd8a35 327 driver####.\r
ddac74d1 328\r
49fd8a35 329 @retval BDS_COMMON_OPTION The option that was created.\r
330 @retval NULL Failed to get the new option.\r
ddac74d1 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
3d8bd97c 341 This function registers the new boot#### or driver#### option based on\r
ddac74d1 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
49fd8a35 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
ddac74d1 351\r
49fd8a35 352 @retval EFI_SUCCESS The boot#### or driver#### have been successfully\r
353 registered.\r
ddac74d1 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
3d8bd97c 367// Bds connect and disconnect driver lib funcions\r
ddac74d1 368//\r
369/**\r
3d8bd97c 370 This function connects all system drivers with the corresponding controllers. \r
ddac74d1 371\r
372**/\r
373VOID\r
374EFIAPI\r
375BdsLibConnectAllDriversToAllControllers (\r
376 VOID\r
377 );\r
378\r
379/**\r
3d8bd97c 380 This function connects all system drivers to controllers.\r
ddac74d1 381\r
382**/\r
383VOID\r
384EFIAPI\r
385BdsLibConnectAll (\r
386 VOID\r
387 );\r
388\r
389/**\r
d0bd68b2 390 This function creates all handles associated with the given device\r
49fd8a35 391 path node. If the handle associated with one device path node cannot\r
3d8bd97c 392 be created, then it tries to execute the dispatch to load the missing drivers. \r
ddac74d1 393\r
3d8bd97c 394 @param DevicePathToConnect The device path to be connected. Can be\r
49fd8a35 395 a multi-instance device path.\r
ddac74d1 396\r
3d8bd97c 397 @retval EFI_SUCCESS All handles associates with every device path node\r
49fd8a35 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
ddac74d1 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
49fd8a35 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
ddac74d1 417**/\r
418EFI_STATUS\r
419EFIAPI\r
420BdsLibConnectAllEfi (\r
421 VOID\r
422 );\r
423\r
ddac74d1 424/**\r
49fd8a35 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
0977c9b2 430 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().\r
ddac74d1 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
3d8bd97c 443 This function will search every simpletxt device in the current system,\r
d0bd68b2 444 and make every simpletxt device a potential console device.\r
ddac74d1 445\r
446**/\r
447VOID\r
448EFIAPI\r
449BdsLibConnectAllConsoles (\r
450 VOID\r
451 );\r
452\r
453\r
454/**\r
3d8bd97c 455 This function will connect console device based on the console\r
ddac74d1 456 device variable ConIn, ConOut and ErrOut.\r
457\r
3d8bd97c 458 @retval EFI_SUCCESS At least one of the ConIn and ConOut devices have\r
459 been connected.\r
ddac74d1 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
3d8bd97c 470 This function updates the console variable based on ConVarName. It can\r
ddac74d1 471 add or remove one specific console device path from the variable\r
472\r
49fd8a35 473 @param ConVarName The console-related variable name: ConIn, ConOut,\r
ddac74d1 474 ErrOut.\r
3d8bd97c 475 @param CustomizedConDevicePath The console device path to be added to\r
49fd8a35 476 the console variable ConVarName. Cannot be multi-instance.\r
3d8bd97c 477 @param ExclusiveDevicePath The console device path to be removed\r
49fd8a35 478 from the console variable ConVarName. Cannot be multi-instance.\r
3d8bd97c 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
ddac74d1 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
3d8bd97c 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
ddac74d1 497 will return success.\r
498\r
49fd8a35 499 @param ConVarName The console related variable name: ConIn, ConOut,\r
ddac74d1 500 ErrOut.\r
501\r
3d8bd97c 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
ddac74d1 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
49fd8a35 517 Delete the instance in Multi that overlaps with Single. \r
ddac74d1 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
3d8bd97c 524 @return This function removes the device path instances in Multi that overlap\r
49fd8a35 525 Single, and returns the resulting device path. If there is no\r
ddac74d1 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
49fd8a35 537 This function compares a device path data structure to that of all the nodes of a\r
ddac74d1 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
49fd8a35 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
ddac74d1 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
49fd8a35 563 @return A newly allocated Unicode string that represents the device path.\r
ddac74d1 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
b4b6c8de
LG
577 CHAR16 *Str;\r
578 UINTN Len;\r
579 UINTN Maxlen;\r
ddac74d1 580} POOL_PRINT;\r
581\r
8e8ae2da 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
ddac74d1 589typedef struct {\r
8e8ae2da 590 UINT8 Type;\r
591 UINT8 SubType;\r
592 DEV_PATH_FUNCTION Function;\r
ddac74d1 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
201e4066 612 CHAR16 TargetName[1];\r
ddac74d1 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
49fd8a35 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
ddac74d1 654\r
655**/\r
656EFI_STATUS\r
657EFIAPI\r
658BdsDeleteAllInvalidLegacyBootOptions (\r
659 VOID\r
660 );\r
661\r
662/**\r
ddac74d1 663 Add the legacy boot options from BBS table if they do not exist.\r
664\r
49fd8a35 665 @retval EFI_SUCCESS The boot options were added successfully, \r
e83c9064
LG
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
ddac74d1 670**/\r
671EFI_STATUS\r
672EFIAPI\r
673BdsAddNonExistingLegacyBootOptions (\r
674 VOID\r
675 );\r
676\r
677/**\r
ddac74d1 678 Add the legacy boot devices from BBS table into \r
679 the legacy device boot order.\r
680\r
49fd8a35 681 @retval EFI_SUCCESS The boot devices were added successfully.\r
e83c9064 682 @retval EFI_NOT_FOUND The legacy boot devices are not found.\r
49fd8a35 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
ddac74d1 686**/\r
687EFI_STATUS\r
688EFIAPI\r
689BdsUpdateLegacyDevOrder (\r
690 VOID\r
691 );\r
692\r
693/**\r
d0bd68b2 694 Refresh the boot priority for BBS entries based on boot option entry and boot order.\r
ddac74d1 695\r
49fd8a35 696 @param Entry The boot option is to be checked for a refreshed BBS table.\r
ddac74d1 697 \r
49fd8a35 698 @retval EFI_SUCCESS The boot priority for BBS entries refreshed successfully.\r
e83c9064
LG
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
ddac74d1 701**/\r
702EFI_STATUS\r
703EFIAPI\r
704BdsRefreshBbsTableForBoot (\r
705 IN BDS_COMMON_OPTION *Entry\r
706 );\r
707\r
708/**\r
d0bd68b2 709 Delete the Boot Option from EFI Variable. The Boot Order Arrray\r
e83c9064 710 is also updated.\r
ddac74d1 711\r
49fd8a35 712 @param OptionNumber The number of Boot options wanting to be deleted.\r
e83c9064
LG
713 @param BootOrder The Boot Order array.\r
714 @param BootOrderSize The size of the Boot Order Array.\r
ddac74d1 715\r
49fd8a35 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
ddac74d1 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
3d8bd97c 729//The interface functions related to the Setup Browser Reset Reminder feature\r
ddac74d1 730//\r
731/**\r
732 Enable the setup browser reset reminder feature.\r
49fd8a35 733 This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.\r
ddac74d1 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
49fd8a35 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
ddac74d1 745\r
746**/\r
747VOID\r
748EFIAPI\r
749DisableResetReminderFeature (\r
750 VOID\r
751 );\r
752\r
753/**\r
3d8bd97c 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
ddac74d1 756\r
757**/\r
758VOID\r
759EFIAPI\r
760EnableResetRequired (\r
761 VOID\r
762 );\r
763\r
764\r
765/**\r
3d8bd97c 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
ddac74d1 768\r
769**/\r
770VOID\r
771EFIAPI\r
772DisableResetRequired (\r
773 VOID\r
774 );\r
775\r
776/**\r
3d8bd97c 777 Check whether platform policy enables the reset reminder feature. The default is enabled.\r
ddac74d1 778\r
779**/\r
780BOOLEAN\r
781EFIAPI\r
782IsResetReminderFeatureEnable (\r
783 VOID\r
784 );\r
785\r
786/**\r
3d8bd97c 787 Check if the user changed any option setting that needs a system reset to be effective.\r
ddac74d1 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
3d8bd97c 798 If a reset is needed, pop up a menu to notice user, and finish the feature\r
ddac74d1 799 according to the user selection.\r
800\r
801**/\r
802VOID\r
803EFIAPI\r
804SetupResetReminder (\r
805 VOID\r
806 );\r
807\r
3384a9bc 808\r
e83c9064 809///\r
49fd8a35 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
e83c9064
LG
814///\r
815\r
816///\r
49fd8a35 817/// ACPI boot type. For ACPI devices, using sub-types to distinguish devices is not allowed, so hardcode their values.\r
e83c9064 818///\r
ddac74d1 819#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201\r
e83c9064
LG
820///\r
821/// Message boot type\r
49fd8a35 822/// If a device path of boot option only points to a message node, the boot option is a message boot type.\r
e83c9064 823///\r
ddac74d1 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
429cac9c 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
ddac74d1 829#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
429cac9c 830\r
e83c9064
LG
831///\r
832/// Media boot type\r
49fd8a35 833/// If a device path of boot option contains a media node, the boot option is media boot type.\r
e83c9064 834///\r
ddac74d1 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
e83c9064
LG
837///\r
838/// BBS boot type\r
49fd8a35 839/// If a device path of boot option contains a BBS node, the boot option is BBS boot type.\r
e83c9064 840///\r
ddac74d1 841#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01\r
842\r
843#define BDS_EFI_UNSUPPORT 0xFFFF\r
844\r
ddac74d1 845/**\r
49fd8a35 846 Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path.\r
ddac74d1 847\r
49fd8a35 848 @param BlockIoDevicePath Multi device path instances to check.\r
3d8bd97c 849 @param HardDriveDevicePath A device path starting with a hard drive media\r
ddac74d1 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
d0bd68b2 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
ddac74d1 871\r
872 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard\r
873 drive media device path.\r
49fd8a35 874 @return A Pointer to the full device path, or NULL if a valid Hard Drive devic path\r
ddac74d1 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
3d8bd97c 886 First, check whether the device is connected.\r
887 Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.\r
ddac74d1 888 Third, detect the the default boot file in the Media, and return the removable Media handle.\r
889\r
49fd8a35 890 @param DevicePath The Device Path to a bootable device.\r
ddac74d1 891\r
e83c9064 892 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
ddac74d1 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
3d8bd97c 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
ddac74d1 905\r
49fd8a35 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
ddac74d1 908\r
49fd8a35 909 @retval TRUE The Device path is valid.\r
910 @retval FALSE The Device path is invalid.\r
ddac74d1 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
3384a9bc 919\r
920/**\r
3d8bd97c 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
3384a9bc 925 boot options.\r
926\r
49fd8a35 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
3384a9bc 930\r
49fd8a35 931 @retval TRUE The Device path is valid.\r
932 @retval FALSE The Device path is invalid.\r
3384a9bc 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
ddac74d1 943/**\r
944 For a bootable Device path, return its boot type.\r
945\r
49fd8a35 946 @param DevicePath The bootable device Path to check.\r
ddac74d1 947\r
38dc2202 948 @retval BDS_EFI_MEDIA_HD_BOOT The given device path contains MEDIA_DEVICE_PATH type device path node,\r
949 whose subtype is MEDIA_HARDDRIVE_DP. \r
950 @retval BDS_EFI_MEDIA_CDROM_BOOT If given device path contains MEDIA_DEVICE_PATH type device path node, \r
951 whose subtype is MEDIA_CDROM_DP. \r
952 @retval BDS_EFI_ACPI_FLOPPY_BOOT A given device path contains ACPI_DEVICE_PATH type device path node, \r
953 whose HID is floppy device. \r
954 @retval BDS_EFI_MESSAGE_ATAPI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
955 and its last device path node's subtype is MSG_ATAPI_DP. \r
956 @retval BDS_EFI_MESSAGE_SCSI_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node,\r
957 and its last device path node's subtype is MSG_SCSI_DP. \r
958 @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT A given device path contains MESSAGING_DEVICE_PATH type device path node, \r
959 and its last device path node's subtype is MSG_USB_DP.\r
960 @retval BDS_EFI_MESSAGE_MISC_BOOT The device path does not contain any media device path node, and \r
961 its last device path node points to a message device path node. \r
962 @retval BDS_LEGACY_BBS_BOOT A given device path contains BBS_DEVICE_PATH type device path node. \r
963 @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path does not point to a media and message device. \r
964\r
965 **/\r
ddac74d1 966UINT32\r
967EFIAPI\r
968BdsGetBootTypeFromDevicePath (\r
969 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
970 );\r
971\r
972\r
973/**\r
3d8bd97c 974 This routine registers a function to adjust the different types of memory page numbers\r
975 just before booting, and saves the updated info into the variable for the next boot to use.\r
ddac74d1 976\r
977**/\r
978VOID\r
979EFIAPI\r
980BdsLibSaveMemoryTypeInformation (\r
981 VOID\r
982 );\r
983 \r
337661bb 984/**\r
985 Identify a user and, if authenticated, returns the current user profile handle.\r
986\r
49fd8a35 987 @param[out] User Points to the user profile handle.\r
337661bb 988 \r
49fd8a35 989 @retval EFI_SUCCESS The user is successfully identified, or user identification\r
337661bb 990 is not supported.\r
49fd8a35 991 @retval EFI_ACCESS_DENIED The user was not successfully identified.\r
337661bb 992\r
993**/\r
994EFI_STATUS\r
995EFIAPI\r
996BdsLibUserIdentify (\r
997 OUT EFI_USER_PROFILE_HANDLE *User\r
998 ); \r
ddac74d1 999\r
1000/**\r
3d8bd97c 1001 This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
1002 it tries to return the valid device path.\r
ddac74d1 1003 FV address maybe changes for memory layout adjust from time to time, use this funciton\r
1004 could promise the Fv file device path is right.\r
1005\r
49fd8a35 1006 @param DevicePath On input, the Fv file device path to check. On\r
ddac74d1 1007 output, the updated valid Fv file device path\r
49fd8a35 1008 @param FileGuid the Fv file GUID.\r
ddac74d1 1009\r
49fd8a35 1010 @retval EFI_INVALID_PARAMETER The input DevicePath or FileGuid is invalid.\r
1011 @retval EFI_UNSUPPORTED The input DevicePath does not contain an Fv file\r
1012 GUID at all.\r
1013 @retval EFI_ALREADY_STARTED The input DevicePath has pointed to the Fv file and is\r
1014 valid.\r
1015 @retval EFI_SUCCESS Successfully updated the invalid DevicePath\r
1016 and returned the updated device path in DevicePath.\r
ddac74d1 1017\r
1018**/\r
1019EFI_STATUS\r
1020EFIAPI\r
1021BdsLibUpdateFvFileDevicePath (\r
1022 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
1023 IN EFI_GUID *FileGuid\r
1024 );\r
1025\r
1026\r
1027/**\r
3d8bd97c 1028 Connect the specific USB device that matches the RemainingDevicePath,\r
49fd8a35 1029 and whose bus is determined by Host Controller (Uhci or Ehci).\r
ddac74d1 1030\r
1031 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
49fd8a35 1032 (0xFF).\r
1033 @param RemainingDevicePath A short-form device path that starts with the first\r
ddac74d1 1034 element being a USB WWID or a USB Class device\r
49fd8a35 1035 path.\r
ddac74d1 1036\r
1037 @retval EFI_SUCCESS The specific Usb device is connected successfully.\r
1038 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
1039 or RemainingDevicePath is not the USB class device path.\r
1040 @retval EFI_NOT_FOUND The device specified by device path is not found.\r
1041\r
1042**/\r
1043EFI_STATUS\r
1044EFIAPI\r
1045BdsLibConnectUsbDevByShortFormDP(\r
1046 IN UINT8 HostControllerPI,\r
1047 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
1048 );\r
1049 \r
1050\r
1051//\r
1052// The implementation of this function is provided by Platform code.\r
1053//\r
1054/**\r
3d8bd97c 1055 Convert Vendor device path to a device name.\r
ddac74d1 1056\r
49fd8a35 1057 @param Str The buffer storing device name.\r
1058 @param DevPath The pointer to vendor device path.\r
ddac74d1 1059\r
1060**/\r
1061VOID\r
ddac74d1 1062DevPathVendor (\r
1063 IN OUT POOL_PRINT *Str,\r
1064 IN VOID *DevPath\r
1065 );\r
1066\r
1067/**\r
49fd8a35 1068 Concatenates a formatted unicode string to an allocated pool.\r
ddac74d1 1069 The caller must free the resulting buffer.\r
1070\r
1071 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
49fd8a35 1072 @param Fmt The format string.\r
ddac74d1 1073 @param ... The data will be printed.\r
1074\r
1075 @return Allocated buffer with the formatted string printed in it.\r
1076 The caller must free the allocated buffer.\r
1077 The buffer allocation is not packed.\r
1078\r
1079**/\r
1080CHAR16 *\r
1081EFIAPI\r
1082CatPrint (\r
1083 IN OUT POOL_PRINT *Str,\r
b4b6c8de 1084 IN CHAR16 *Fmt,\r
ddac74d1 1085 ...\r
1086 );\r
1087\r
1088/**\r
24cdd14e
LG
1089 Use SystemTable ConOut to stop video based Simple Text Out consoles from going\r
1090 to the video device. Put up LogoFile on every video device that is a console.\r
ddac74d1 1091\r
49fd8a35 1092 @param[in] LogoFile The file name of logo to display on the center of the screen.\r
ddac74d1 1093\r
1094 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
49fd8a35 1095 @retval EFI_UNSUPPORTED Logo not found.\r
ddac74d1 1096\r
1097**/\r
1098EFI_STATUS\r
1099EFIAPI\r
1100EnableQuietBoot (\r
1101 IN EFI_GUID *LogoFile\r
1102 );\r
1103\r
1104\r
1105/**\r
24cdd14e 1106 Use SystemTable ConOut to turn on video based Simple Text Out consoles. The \r
49fd8a35 1107 Simple Text Out screens will now be synced up with all non-video output devices.\r
ddac74d1 1108\r
1109 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
1110\r
1111**/\r
1112EFI_STATUS\r
1113EFIAPI\r
1114DisableQuietBoot (\r
1115 VOID\r
1116 );\r
1117\r
ddac74d1 1118#endif\r
1119\r