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