]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Committing changes to the comments, after review with engineers.
[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
d0bd68b2 112 Process the boot option according to the UEFI specification. The legacy boot option device path includes BBS_DEVICE_PATH.\r
ddac74d1 113\r
3d8bd97c 114 @param Option The boot option to be processed\r
115 @param DevicePath The device path describing where to load the\r
ddac74d1 116 boot image or the legcy BBS device path to boot\r
117 the legacy OS\r
118 @param ExitDataSize The size of exit data.\r
119 @param ExitData Data returned when Boot image failed.\r
120\r
3d8bd97c 121 @retval EFI_SUCCESS Boot from the input boot option succeeded.\r
122 @retval EFI_NOT_FOUND The Device Path is not found in the system\r
ddac74d1 123\r
124**/\r
125EFI_STATUS\r
126EFIAPI\r
127BdsLibBootViaBootOption (\r
128 IN BDS_COMMON_OPTION * Option,\r
129 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,\r
130 OUT UINTN *ExitDataSize,\r
131 OUT CHAR16 **ExitData OPTIONAL\r
132 );\r
133\r
134\r
135/**\r
3d8bd97c 136 This function will enumerate all possible boot devices in the system, and\r
137 automatically create boot options for Network, Shell, Removable BlockIo, \r
138 and Non-BlockIo Simplefile devices. \r
139 \r
140 BDS separates EFI boot options into six types:\r
8d3b5aff 141 1. Network - The boot option points to the SimpleNetworkProtocol device. \r
3d8bd97c 142 Bds will try to automatically create this type of boot option during enumeration.\r
8d3b5aff 143 2. Shell - The boot option points to internal flash shell. \r
3d8bd97c 144 Bds will try to automatically create this type of boot option during enumeration.\r
145 3. Removable BlockIo - The boot option points to a removable media\r
146 device, such as a USB flash drive or DVD drive.\r
147 These devices should contain a *removable* blockIo\r
8d3b5aff 148 protocol in their device handle.\r
149 Bds will try to automatically create this type boot option \r
150 when enumerate.\r
3d8bd97c 151 4. Fixed BlockIo - The boot option points to a Fixed blockIo device, \r
152 such as a hard disk.\r
153 These devices should contain a *fixed* blockIo\r
8d3b5aff 154 protocol in their device handle.\r
3d8bd97c 155 BDS will skip fixed blockIo devices, and not\r
8d3b5aff 156 automatically create boot option for them. But BDS \r
3d8bd97c 157 will help to delete those fixed blockIo boot options, \r
158 whose description rules conflict with other auto-created\r
8d3b5aff 159 boot options.\r
160 5. Non-BlockIo Simplefile - The boot option points to a device whose handle \r
161 has SimpleFileSystem Protocol, but has no blockio\r
162 protocol. These devices do not offer blockIo\r
163 protocol, but BDS still can get the \r
164 \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
165 Protocol.\r
166 6. File - The boot option points to a file. These boot options are usually \r
3d8bd97c 167 created by the user, either manually or with an OS loader. BDS will not delete or modify\r
8d3b5aff 168 these boot options. \r
169 \r
3d8bd97c 170 This function will enumerate all possible boot devices in the system, and\r
8d3b5aff 171 automatically create boot options for Network, Shell, Removable BlockIo, \r
172 and Non-BlockIo Simplefile devices.\r
3d8bd97c 173 It will excute once every boot.\r
8d3b5aff 174 \r
3d8bd97c 175 @param BdsBootOptionList The header of the linked list that indexed all\r
ddac74d1 176 current boot options\r
177\r
3d8bd97c 178 @retval EFI_SUCCESS Finished all the boot device enumerations and created\r
179 the boot option based on the boot device\r
ddac74d1 180\r
e83c9064 181 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create the boot option list\r
ddac74d1 182**/\r
183EFI_STATUS\r
184EFIAPI\r
185BdsLibEnumerateAllBootOption (\r
186 IN OUT LIST_ENTRY *BdsBootOptionList\r
187 );\r
188\r
189/**\r
190 Build the boot option with the handle parsed in\r
191\r
3d8bd97c 192 @param Handle The handle representing the device path for which to create\r
ddac74d1 193 boot option\r
194 @param BdsBootOptionList The header of the link list which indexed all\r
195 current boot options\r
196 @param String The description of the boot option.\r
197\r
198**/\r
199VOID\r
200EFIAPI\r
201BdsLibBuildOptionFromHandle (\r
202 IN EFI_HANDLE Handle,\r
203 IN LIST_ENTRY *BdsBootOptionList,\r
204 IN CHAR16 *String\r
205 );\r
206\r
207\r
208/**\r
209 Build the on flash shell boot option with the handle parsed in.\r
210\r
211 @param Handle The handle which present the device path to create\r
212 on flash shell boot option\r
213 @param BdsBootOptionList The header of the link list which indexed all\r
214 current boot options\r
215\r
216**/\r
217VOID\r
218EFIAPI\r
219BdsLibBuildOptionFromShell (\r
220 IN EFI_HANDLE Handle,\r
221 IN OUT LIST_ENTRY *BdsBootOptionList\r
222 );\r
223\r
224//\r
225// Bds misc lib functions\r
226//\r
ddac74d1 227/**\r
228 Get boot mode by looking up configuration table and parsing HOB list\r
229\r
230 @param BootMode Boot mode from PEI handoff HOB.\r
231\r
232 @retval EFI_SUCCESS Successfully get boot mode\r
233\r
234**/\r
235EFI_STATUS\r
236EFIAPI\r
237BdsLibGetBootMode (\r
238 OUT EFI_BOOT_MODE *BootMode\r
239 );\r
240\r
241\r
242/**\r
3d8bd97c 243 The function will go through the driver option link list, and then load and start\r
244 every driver to which the driver option device path points.\r
ddac74d1 245\r
246 @param BdsDriverLists The header of the current driver option link list\r
247\r
248**/\r
249VOID\r
250EFIAPI\r
251BdsLibLoadDrivers (\r
252 IN LIST_ENTRY *BdsDriverLists\r
253 );\r
254\r
255\r
256/**\r
d0bd68b2 257 This function processes BootOrder or DriverOrder variables, by calling\r
258\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
d0bd68b2 387 This function creates all handles associated with the given device\r
3d8bd97c 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
d0bd68b2 433 and make every simpletxt device a potential console device.\r
ddac74d1 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
d0bd68b2 674 Refresh the boot priority for BBS entries based on boot option entry and boot order.\r
ddac74d1 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
d0bd68b2 689 Delete the Boot Option from EFI Variable. The Boot Order Arrray\r
e83c9064 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 type which to classify the boot option type\r
791/// Different boot option type could have different boot behavior\r
792/// Use their device path node (Type + SubType) as type value\r
793/// The boot type here can be added according to requirement\r
794///\r
795\r
796///\r
797/// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value\r
798///\r
ddac74d1 799#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201\r
e83c9064
LG
800///\r
801/// Message boot type\r
802/// If a device path of boot option only point to a message node, the boot option is message boot type\r
803///\r
ddac74d1 804#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01\r
805#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02\r
806#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05\r
429cac9c 807#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18\r
808#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11\r
ddac74d1 809#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
429cac9c 810\r
e83c9064
LG
811///\r
812/// Media boot type\r
813/// If a device path of boot option contain a media node, the boot option is media boot type\r
814///\r
ddac74d1 815#define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01\r
816#define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02\r
e83c9064
LG
817///\r
818/// BBS boot type\r
819/// If a device path of boot option contain a BBS node, the boot option is BBS boot type\r
820///\r
ddac74d1 821#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01\r
822\r
823#define BDS_EFI_UNSUPPORT 0xFFFF\r
824\r
e83c9064
LG
825///\r
826/// USB host controller Programming Interface.\r
827///\r
ddac74d1 828#define PCI_CLASSC_PI_UHCI 0x00\r
829#define PCI_CLASSC_PI_EHCI 0x20\r
830\r
831/**\r
3d8bd97c 832 Check whether an instance in BlockIoDevicePath has the same partition node as the HardDriveDevicePath device path\r
ddac74d1 833\r
3d8bd97c 834 @param BlockIoDevicePath Multi device path instances to check\r
835 @param HardDriveDevicePath A device path starting with a hard drive media\r
ddac74d1 836 device path.\r
837\r
838 @retval TRUE There is a matched device path instance.\r
839 @retval FALSE There is no matched device path instance.\r
840\r
841**/\r
842BOOLEAN\r
843EFIAPI\r
844MatchPartitionDevicePathNode (\r
845 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
846 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
847 );\r
848\r
849\r
850/**\r
851 Expand a device path that starts with a hard drive media device path node to be a\r
d0bd68b2 852 full device path that includes the full hardware path to the device. This function enables the device to boot. \r
853 To avoid requiring a connect on every boot, the front match is saved in a variable (the part point\r
854 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ).\r
855 All successful history device paths\r
856 that point to the front part of the partition node will be saved.\r
ddac74d1 857\r
858 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard\r
859 drive media device path.\r
860 @return A Pointer to the full device path or NULL if a valid Hard Drive devic path\r
861 cannot be found.\r
862\r
863**/\r
864EFI_DEVICE_PATH_PROTOCOL *\r
865EFIAPI\r
866BdsExpandPartitionPartialDevicePathToFull (\r
867 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
868 );\r
869 \r
870/**\r
871 Return the bootable media handle.\r
3d8bd97c 872 First, check whether the device is connected.\r
873 Second, check whether the device path points to a device that supports SimpleFileSystemProtocol.\r
ddac74d1 874 Third, detect the the default boot file in the Media, and return the removable Media handle.\r
875\r
876 @param DevicePath Device Path to a bootable device\r
877\r
e83c9064 878 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
ddac74d1 879\r
880**/\r
881EFI_HANDLE\r
882EFIAPI\r
883BdsLibGetBootableHandle (\r
884 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
885 );\r
886 \r
887\r
888/**\r
3d8bd97c 889 Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
890 is ready to boot now.\r
ddac74d1 891\r
892 @param DevPath the Device path in a boot option\r
3d8bd97c 893 @param CheckMedia if true, check whether the device is ready to boot now.\r
ddac74d1 894\r
3d8bd97c 895 @retval TRUE the Device path is valid\r
896 @retval FALSE the Device path is invalid\r
ddac74d1 897\r
898**/\r
899BOOLEAN\r
900EFIAPI\r
901BdsLibIsValidEFIBootOptDevicePath (\r
902 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
903 IN BOOLEAN CheckMedia\r
904 );\r
3384a9bc 905\r
906/**\r
3d8bd97c 907 Checks whether the Device path in a boot option points to a valid bootable device, and if the device\r
908 is ready to boot now.\r
909 If Description is not NULL and the device path points to a fixed BlockIo\r
910 device, this function checks whether the description conflicts with other auto-created\r
3384a9bc 911 boot options.\r
912\r
913 @param DevPath the Device path in a boot option\r
3d8bd97c 914 @param CheckMedia if true, checks if the device is ready to boot now.\r
915 @param Description the description of a boot option\r
3384a9bc 916\r
3d8bd97c 917 @retval TRUE the Device path is valid\r
918 @retval FALSE the Device path is invalid\r
3384a9bc 919\r
920**/\r
921BOOLEAN\r
922EFIAPI\r
923BdsLibIsValidEFIBootOptDevicePathExt (\r
924 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
925 IN BOOLEAN CheckMedia,\r
926 IN CHAR16 *Description\r
927 );\r
928\r
ddac74d1 929/**\r
930 For a bootable Device path, return its boot type.\r
931\r
932 @param DevicePath The bootable device Path to check\r
933\r
3d8bd97c 934 @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 935**/\r
936UINT32\r
937EFIAPI\r
938BdsGetBootTypeFromDevicePath (\r
939 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
940 );\r
941\r
942\r
943/**\r
3d8bd97c 944 This routine registers a function to adjust the different types of memory page numbers\r
945 just before booting, and saves the updated info into the variable for the next boot to use.\r
ddac74d1 946\r
947**/\r
948VOID\r
949EFIAPI\r
950BdsLibSaveMemoryTypeInformation (\r
951 VOID\r
952 );\r
953 \r
954\r
955/**\r
3d8bd97c 956 This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
957 it tries to return the valid device path.\r
ddac74d1 958 FV address maybe changes for memory layout adjust from time to time, use this funciton\r
959 could promise the Fv file device path is right.\r
960\r
3d8bd97c 961 @param DevicePath on input, the Fv file device path to check. On\r
ddac74d1 962 output, the updated valid Fv file device path\r
3d8bd97c 963 @param FileGuid the Fv file GUID\r
ddac74d1 964\r
965 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid\r
3d8bd97c 966 @retval EFI_UNSUPPORTED the input DevicePath does not contain an Fv file\r
967 GUID at all\r
968 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to the Fv file and is\r
ddac74d1 969 valid\r
3d8bd97c 970 @retval EFI_SUCCESS successfully updated the invalid DevicePath\r
971 and returned the updated device path in DevicePath\r
ddac74d1 972\r
973**/\r
974EFI_STATUS\r
975EFIAPI\r
976BdsLibUpdateFvFileDevicePath (\r
977 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
978 IN EFI_GUID *FileGuid\r
979 );\r
980\r
981\r
982/**\r
3d8bd97c 983 Connect the specific USB device that matches the RemainingDevicePath,\r
ddac74d1 984 and whose bus is determined by Host Controller (Uhci or Ehci)\r
985\r
986 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
987 (0xFF)\r
988 @param RemainingDevicePath a short-form device path that starts with the first\r
989 element being a USB WWID or a USB Class device\r
990 path\r
991\r
992 @retval EFI_SUCCESS The specific Usb device is connected successfully.\r
993 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
994 or RemainingDevicePath is not the USB class device path.\r
995 @retval EFI_NOT_FOUND The device specified by device path is not found.\r
996\r
997**/\r
998EFI_STATUS\r
999EFIAPI\r
1000BdsLibConnectUsbDevByShortFormDP(\r
1001 IN UINT8 HostControllerPI,\r
1002 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
1003 );\r
1004 \r
1005\r
1006//\r
1007// The implementation of this function is provided by Platform code.\r
1008//\r
1009/**\r
3d8bd97c 1010 Convert Vendor device path to a device name.\r
ddac74d1 1011\r
3d8bd97c 1012 @param Str The buffer storing device name\r
ddac74d1 1013 @param DevPath Pointer to vendor device path\r
1014\r
1015**/\r
1016VOID\r
ddac74d1 1017DevPathVendor (\r
1018 IN OUT POOL_PRINT *Str,\r
1019 IN VOID *DevPath\r
1020 );\r
1021\r
1022/**\r
1023 Concatenates a formatted unicode string to allocated pool.\r
1024 The caller must free the resulting buffer.\r
1025\r
1026 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
b4b6c8de 1027 @param Fmt The format string\r
ddac74d1 1028 @param ... The data will be printed.\r
1029\r
1030 @return Allocated buffer with the formatted string printed in it.\r
1031 The caller must free the allocated buffer.\r
1032 The buffer allocation is not packed.\r
1033\r
1034**/\r
1035CHAR16 *\r
1036EFIAPI\r
1037CatPrint (\r
1038 IN OUT POOL_PRINT *Str,\r
b4b6c8de 1039 IN CHAR16 *Fmt,\r
ddac74d1 1040 ...\r
1041 );\r
1042\r
1043/**\r
24cdd14e
LG
1044 Use SystemTable ConOut to stop video based Simple Text Out consoles from going\r
1045 to the video device. Put up LogoFile on every video device that is a console.\r
ddac74d1 1046\r
1047 @param[in] LogoFile File name of logo to display on the center of the screen.\r
1048\r
1049 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
1050 @retval EFI_UNSUPPORTED Logo not found\r
1051\r
1052**/\r
1053EFI_STATUS\r
1054EFIAPI\r
1055EnableQuietBoot (\r
1056 IN EFI_GUID *LogoFile\r
1057 );\r
1058\r
1059\r
1060/**\r
24cdd14e
LG
1061 Use SystemTable ConOut to turn on video based Simple Text Out consoles. The \r
1062 Simple Text Out screens will now be synced up with all non video output devices\r
ddac74d1 1063\r
1064 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
1065\r
1066**/\r
1067EFI_STATUS\r
1068EFIAPI\r
1069DisableQuietBoot (\r
1070 VOID\r
1071 );\r
1072\r
ddac74d1 1073#endif\r
1074\r