]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Add definition on SmmStatusCodeProtocol to comply the SMMCIS spec to fix the bug...
[mirror_edk2.git] / IntelFrameworkModulePkg / Include / Library / GenericBdsLib.h
CommitLineData
ddac74d1 1/** @file\r
920d2c23
LG
2 Generic BDS library defines general interfaces for BDS driver including:\r
3 1) BDS boot policy interface;\r
4 2) BDS boot device connect interface;\r
5 3) BDS Misc interfaces for mainting boot variable, ouput string.\r
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
LG
59///\r
60/// Define Maxmim characters that will be accepted\r
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
115 @param Option The boot option need to be processed\r
116 @param DevicePath The device path which describe where to load the\r
117 boot image or the legcy BBS device path to boot\r
118 the legacy OS\r
119 @param ExitDataSize The size of exit data.\r
120 @param ExitData Data returned when Boot image failed.\r
121\r
122 @retval EFI_SUCCESS Boot from the input boot option successfully.\r
123 @retval EFI_NOT_FOUND If the Device Path is not found in the system\r
124\r
125**/\r
126EFI_STATUS\r
127EFIAPI\r
128BdsLibBootViaBootOption (\r
129 IN BDS_COMMON_OPTION * Option,\r
130 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,\r
131 OUT UINTN *ExitDataSize,\r
132 OUT CHAR16 **ExitData OPTIONAL\r
133 );\r
134\r
135\r
136/**\r
8d3b5aff 137 For EFI boot option, BDS separate them as six types:\r
138 1. Network - The boot option points to the SimpleNetworkProtocol device. \r
139 Bds will try to automatically create this type boot option when enumerate.\r
140 2. Shell - The boot option points to internal flash shell. \r
141 Bds will try to automatically create this type boot option when enumerate.\r
142 3. Removable BlockIo - The boot option only points to the removable media\r
143 device, like USB flash disk, DVD, Floppy etc.\r
144 These device should contain a *removable* blockIo\r
145 protocol in their device handle.\r
146 Bds will try to automatically create this type boot option \r
147 when enumerate.\r
148 4. Fixed BlockIo - The boot option only points to a Fixed blockIo device, \r
149 like HardDisk.\r
150 These device should contain a *fixed* blockIo\r
151 protocol in their device handle.\r
152 BDS will skip fixed blockIo devices, and NOT\r
153 automatically create boot option for them. But BDS \r
154 will help to delete those fixed blockIo boot option, \r
155 whose description rule conflict with other auto-created\r
156 boot options.\r
157 5. Non-BlockIo Simplefile - The boot option points to a device whose handle \r
158 has SimpleFileSystem Protocol, but has no blockio\r
159 protocol. These devices do not offer blockIo\r
160 protocol, but BDS still can get the \r
161 \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
162 Protocol.\r
163 6. File - The boot option points to a file. These boot options are usually \r
164 created by user manually or OS loader. BDS will not delete or modify\r
165 these boot options. \r
166 \r
167 This function will enumerate all possible boot device in the system, and\r
168 automatically create boot options for Network, Shell, Removable BlockIo, \r
169 and Non-BlockIo Simplefile devices.\r
170 It will only excute once of every boot.\r
171 \r
ddac74d1 172 @param BdsBootOptionList The header of the link list which indexed all\r
173 current boot options\r
174\r
175 @retval EFI_SUCCESS Finished all the boot device enumerate and create\r
176 the boot option base on that boot device\r
177\r
e83c9064 178 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create the boot option list\r
ddac74d1 179**/\r
180EFI_STATUS\r
181EFIAPI\r
182BdsLibEnumerateAllBootOption (\r
183 IN OUT LIST_ENTRY *BdsBootOptionList\r
184 );\r
185\r
186/**\r
187 Build the boot option with the handle parsed in\r
188\r
189 @param Handle The handle which present the device path to create\r
190 boot option\r
191 @param BdsBootOptionList The header of the link list which indexed all\r
192 current boot options\r
193 @param String The description of the boot option.\r
194\r
195**/\r
196VOID\r
197EFIAPI\r
198BdsLibBuildOptionFromHandle (\r
199 IN EFI_HANDLE Handle,\r
200 IN LIST_ENTRY *BdsBootOptionList,\r
201 IN CHAR16 *String\r
202 );\r
203\r
204\r
205/**\r
206 Build the on flash shell boot option with the handle parsed in.\r
207\r
208 @param Handle The handle which present the device path to create\r
209 on flash shell boot option\r
210 @param BdsBootOptionList The header of the link list which indexed all\r
211 current boot options\r
212\r
213**/\r
214VOID\r
215EFIAPI\r
216BdsLibBuildOptionFromShell (\r
217 IN EFI_HANDLE Handle,\r
218 IN OUT LIST_ENTRY *BdsBootOptionList\r
219 );\r
220\r
221//\r
222// Bds misc lib functions\r
223//\r
ddac74d1 224/**\r
225 Get boot mode by looking up configuration table and parsing HOB list\r
226\r
227 @param BootMode Boot mode from PEI handoff HOB.\r
228\r
229 @retval EFI_SUCCESS Successfully get boot mode\r
230\r
231**/\r
232EFI_STATUS\r
233EFIAPI\r
234BdsLibGetBootMode (\r
235 OUT EFI_BOOT_MODE *BootMode\r
236 );\r
237\r
238\r
239/**\r
240 The function will go through the driver optoin link list, load and start\r
241 every driver the driver optoin device path point to.\r
242\r
243 @param BdsDriverLists The header of the current driver option link list\r
244\r
245**/\r
246VOID\r
247EFIAPI\r
248BdsLibLoadDrivers (\r
249 IN LIST_ENTRY *BdsDriverLists\r
250 );\r
251\r
252\r
253/**\r
254 Process BootOrder, or DriverOrder variables, by calling\r
255 BdsLibVariableToOption () for each UINT16 in the variables.\r
256\r
e83c9064
LG
257 @param BdsCommonOptionList The header of the option list base on variable VariableName.\r
258 @param VariableName EFI Variable name indicate the BootOrder or DriverOrder.\r
ddac74d1 259\r
e83c9064
LG
260 @retval EFI_SUCCESS Success create the boot option or driver option list.\r
261 @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or driver option list.\r
ddac74d1 262**/\r
263EFI_STATUS\r
264EFIAPI\r
265BdsLibBuildOptionFromVar (\r
266 IN LIST_ENTRY *BdsCommonOptionList,\r
267 IN CHAR16 *VariableName\r
268 );\r
269\r
270/**\r
271 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
272 buffer, and the size of the buffer. If failure return NULL.\r
273\r
274 @param Name String part of EFI variable name\r
275 @param VendorGuid GUID part of EFI variable name\r
276 @param VariableSize Returns the size of the EFI variable that was read\r
277\r
278 @return Dynamically allocated memory that contains a copy of the EFI variable\r
279 Caller is responsible freeing the buffer.\r
280 @retval NULL Variable was not read\r
281\r
282**/\r
283VOID *\r
284EFIAPI\r
285BdsLibGetVariableAndSize (\r
286 IN CHAR16 *Name,\r
287 IN EFI_GUID *VendorGuid,\r
288 OUT UINTN *VariableSize\r
289 );\r
290\r
291\r
292/**\r
293 This function prints a series of strings.\r
294\r
295 @param ConOut Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL\r
296 @param ... A variable argument list containing series of\r
297 strings, the last string must be NULL.\r
298\r
299 @retval EFI_SUCCESS Success print out the string using ConOut.\r
300 @retval EFI_STATUS Return the status of the ConOut->OutputString ().\r
301\r
302**/\r
303EFI_STATUS\r
304EFIAPI\r
305BdsLibOutputStrings (\r
306 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,\r
307 ...\r
308 );\r
309\r
310/**\r
311 Build the boot#### or driver#### option from the VariableName, the\r
312 build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
313\r
314 @param BdsCommonOptionList The header of the boot#### or driver#### option\r
315 link list\r
316 @param VariableName EFI Variable name indicate if it is boot#### or\r
317 driver####\r
318\r
319 @retval BDS_COMMON_OPTION Get the option just been created\r
320 @retval NULL Failed to get the new option\r
321\r
322**/\r
323BDS_COMMON_OPTION *\r
324EFIAPI\r
325BdsLibVariableToOption (\r
326 IN OUT LIST_ENTRY *BdsCommonOptionList,\r
327 IN CHAR16 *VariableName\r
328 );\r
329\r
330/**\r
331 This function will register the new boot#### or driver#### option base on\r
332 the VariableName. The new registered boot#### or driver#### will be linked\r
333 to BdsOptionList and also update to the VariableName. After the boot#### or\r
334 driver#### updated, the BootOrder or DriverOrder will also be updated.\r
335\r
336 @param BdsOptionList The header of the boot#### or driver#### link list\r
337 @param DevicePath The device path which the boot#### or driver####\r
338 option present\r
339 @param String The description of the boot#### or driver####\r
340 @param VariableName Indicate if the boot#### or driver#### option\r
341\r
342 @retval EFI_SUCCESS The boot#### or driver#### have been success\r
343 registered\r
344 @retval EFI_STATUS Return the status of gRT->SetVariable ().\r
345\r
346**/\r
347EFI_STATUS\r
348EFIAPI\r
349BdsLibRegisterNewOption (\r
350 IN LIST_ENTRY *BdsOptionList,\r
351 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
352 IN CHAR16 *String,\r
353 IN CHAR16 *VariableName\r
354 );\r
355\r
356//\r
357// Bds connect or disconnect driver lib funcion\r
358//\r
359/**\r
360 Connects all drivers to all controllers.\r
361 This function make sure all the current system driver will manage\r
362 the correspoinding controllers if have. And at the same time, make\r
363 sure all the system controllers have driver to manage it if have.\r
364\r
365**/\r
366VOID\r
367EFIAPI\r
368BdsLibConnectAllDriversToAllControllers (\r
369 VOID\r
370 );\r
371\r
372/**\r
373 This function will connect all the system driver to controller\r
374 first, and then special connect the default console, this make\r
375 sure all the system controller available and the platform default\r
376 console connected.\r
377\r
378**/\r
379VOID\r
380EFIAPI\r
381BdsLibConnectAll (\r
382 VOID\r
383 );\r
384\r
385/**\r
386 This function will create all handles associate with every device\r
387 path node. If the handle associate with one device path node can not\r
388 be created success, then still give one chance to do the dispatch,\r
389 which load the missing drivers if possible.\r
390\r
391 @param DevicePathToConnect The device path which will be connected, it can be\r
392 a multi-instance device path\r
393\r
394 @retval EFI_SUCCESS All handles associate with every device path node\r
395 have been created\r
396 @retval EFI_OUT_OF_RESOURCES There is no resource to create new handles\r
397 @retval EFI_NOT_FOUND Create the handle associate with one device path\r
398 node failed\r
399\r
400**/\r
401EFI_STATUS\r
402EFIAPI\r
403BdsLibConnectDevicePath (\r
404 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect\r
405 );\r
406\r
407/**\r
0977c9b2 408 This function will connect all current system handles recursively. \r
409 \r
410 gBS->ConnectController() service is invoked for each handle exist in system handler buffer.\r
411 If the handle is bus type handler, all childrens also will be connected recursively\r
412 by gBS->ConnectController().\r
ddac74d1 413\r
0977c9b2 414 @retval EFI_SUCCESS All handles and it's child handle have been connected\r
415 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().\r
ddac74d1 416\r
417**/\r
418EFI_STATUS\r
419EFIAPI\r
420BdsLibConnectAllEfi (\r
421 VOID\r
422 );\r
423\r
ddac74d1 424/**\r
0977c9b2 425 This function will disconnect all current system handles. \r
426 \r
427 gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
428 If handle is a bus type handle, all childrens also are disconnected recursively by\r
429 gBS->DisconnectController().\r
ddac74d1 430\r
431 @retval EFI_SUCCESS All handles have been disconnected\r
0977c9b2 432 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().\r
ddac74d1 433\r
434**/\r
435EFI_STATUS\r
436EFIAPI\r
437BdsLibDisconnectAllEfi (\r
438 VOID\r
439 );\r
440\r
441//\r
442// Bds console related lib functions\r
443//\r
444/**\r
445 This function will search every simpletxt devive in current system,\r
446 and make every simpletxt device as pertantial console device.\r
447\r
448**/\r
449VOID\r
450EFIAPI\r
451BdsLibConnectAllConsoles (\r
452 VOID\r
453 );\r
454\r
455\r
456/**\r
457 This function will connect console device base on the console\r
458 device variable ConIn, ConOut and ErrOut.\r
459\r
460 @retval EFI_SUCCESS At least one of the ConIn and ConOut device have\r
461 been connected success.\r
462 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().\r
463\r
464**/\r
465EFI_STATUS\r
466EFIAPI\r
467BdsLibConnectAllDefaultConsoles (\r
468 VOID\r
469 );\r
470\r
471/**\r
472 This function update console variable based on ConVarName, it can\r
473 add or remove one specific console device path from the variable\r
474\r
475 @param ConVarName Console related variable name, ConIn, ConOut,\r
476 ErrOut.\r
477 @param CustomizedConDevicePath The console device path which will be added to\r
478 the console variable ConVarName, this parameter\r
479 can not be multi-instance.\r
480 @param ExclusiveDevicePath The console device path which will be removed\r
481 from the console variable ConVarName, this\r
482 parameter can not be multi-instance.\r
483\r
484 @retval EFI_UNSUPPORTED The added device path is same to the removed one.\r
485 @retval EFI_SUCCESS Success add or remove the device path from the\r
486 console variable.\r
487\r
488**/\r
489EFI_STATUS\r
490EFIAPI\r
491BdsLibUpdateConsoleVariable (\r
492 IN CHAR16 *ConVarName,\r
493 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,\r
494 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath\r
495 );\r
496\r
497/**\r
498 Connect the console device base on the variable ConVarName, if\r
499 device path of the ConVarName is multi-instance device path, if\r
500 anyone of the instances is connected success, then this function\r
501 will return success.\r
502\r
503 @param ConVarName Console related variable name, ConIn, ConOut,\r
504 ErrOut.\r
505\r
506 @retval EFI_NOT_FOUND There is not any console devices connected\r
507 success\r
508 @retval EFI_SUCCESS Success connect any one instance of the console\r
509 device path base on the variable ConVarName.\r
510\r
511**/\r
512EFI_STATUS\r
513EFIAPI\r
514BdsLibConnectConsoleVariable (\r
515 IN CHAR16 *ConVarName\r
516 );\r
517\r
518//\r
519// Bds device path related lib functions\r
520//\r
521/**\r
522 Delete the instance in Multi which matches partly with Single instance\r
523\r
524 @param Multi A pointer to a multi-instance device path data\r
525 structure.\r
526 @param Single A pointer to a single-instance device path data\r
527 structure.\r
528\r
529 @return This function will remove the device path instances in Multi which partly\r
530 match with the Single, and return the result device path. If there is no\r
531 remaining device path as a result, this function will return NULL.\r
532\r
533**/\r
534EFI_DEVICE_PATH_PROTOCOL *\r
535EFIAPI\r
536BdsLibDelPartMatchInstance (\r
537 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
538 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
539 );\r
540\r
541/**\r
542 Function compares a device path data structure to that of all the nodes of a\r
543 second device path instance.\r
544\r
545 @param Multi A pointer to a multi-instance device path data\r
546 structure.\r
547 @param Single A pointer to a single-instance device path data\r
548 structure.\r
549\r
550 @retval TRUE If the Single device path is contained within Multi device path.\r
551 @retval FALSE The Single device path is not match within Multi device path.\r
552\r
553**/\r
554BOOLEAN\r
555EFIAPI\r
556BdsLibMatchDevicePaths (\r
557 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
558 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
559 );\r
560\r
561/**\r
562 This function converts an input device structure to a Unicode string.\r
563\r
564 @param DevPath A pointer to the device path structure.\r
565\r
566 @return A new allocated Unicode string that represents the device path.\r
567\r
568**/\r
569CHAR16 *\r
570EFIAPI\r
571DevicePathToStr (\r
572 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
573 );\r
574\r
575\r
576//\r
577// Internal definitions\r
578//\r
579typedef struct {\r
b4b6c8de
LG
580 CHAR16 *Str;\r
581 UINTN Len;\r
582 UINTN Maxlen;\r
ddac74d1 583} POOL_PRINT;\r
584\r
585typedef struct {\r
586 UINT8 Type;\r
587 UINT8 SubType;\r
588 VOID (*Function) (POOL_PRINT *, VOID *);\r
589} DEVICE_PATH_STRING_TABLE;\r
590\r
591extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;\r
592\r
593typedef struct {\r
594 EFI_DEVICE_PATH_PROTOCOL Header;\r
595 EFI_GUID Guid;\r
596 UINT8 VendorDefinedData[1];\r
597} VENDOR_DEVICE_PATH_WITH_DATA;\r
598\r
599\r
600extern EFI_GUID mEfiDevicePathMessagingSASGuid;\r
601\r
602typedef struct {\r
603 EFI_DEVICE_PATH_PROTOCOL Header;\r
604 UINT16 NetworkProtocol;\r
605 UINT16 LoginOption;\r
606 UINT64 Lun;\r
607 UINT16 TargetPortalGroupTag;\r
201e4066 608 CHAR16 TargetName[1];\r
ddac74d1 609} ISCSI_DEVICE_PATH_WITH_NAME;\r
610\r
611\r
612//\r
613// Notes: EFI 64 shadow all option rom\r
614//\r
615#if defined (MDE_CPU_IPF)\r
616#define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();\r
617#else\r
618#define EFI64_SHADOW_ALL_LEGACY_ROM()\r
619#endif\r
620\r
621/**\r
622 Shadow all Legacy OptionRom. \r
623\r
624**/\r
625VOID\r
626EFIAPI\r
627ShadowAllOptionRom (\r
628 VOID\r
629 );\r
630\r
631//\r
632// BBS support macros and functions\r
633//\r
634\r
635#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)\r
636#define REFRESH_LEGACY_BOOT_OPTIONS \\r
637 BdsDeleteAllInvalidLegacyBootOptions ();\\r
638 BdsAddNonExistingLegacyBootOptions (); \\r
639 BdsUpdateLegacyDevOrder ()\r
640#else\r
641#define REFRESH_LEGACY_BOOT_OPTIONS\r
642#endif\r
643\r
644/**\r
645 Delete all the invalid legacy boot options.\r
646\r
647 @retval EFI_SUCCESS All invalide legacy boot options are deleted.\r
648 @retval EFI_OUT_OF_RESOURCES Fail to allocate necessary memory.\r
649 @retval EFI_NOT_FOUND Fail to retrive variable of boot order.\r
650\r
651**/\r
652EFI_STATUS\r
653EFIAPI\r
654BdsDeleteAllInvalidLegacyBootOptions (\r
655 VOID\r
656 );\r
657\r
658/**\r
ddac74d1 659 Add the legacy boot options from BBS table if they do not exist.\r
660\r
e83c9064
LG
661 @retval EFI_SUCCESS The boot options are added successfully \r
662 or they are already in boot options.\r
663 @retval EFI_NOT_FOUND No legacy boot options is found.\r
664 @retval EFI_OUT_OF_RESOURCE No enough memory.\r
665 @return Other value LegacyBoot options are not added.\r
ddac74d1 666**/\r
667EFI_STATUS\r
668EFIAPI\r
669BdsAddNonExistingLegacyBootOptions (\r
670 VOID\r
671 );\r
672\r
673/**\r
ddac74d1 674 Add the legacy boot devices from BBS table into \r
675 the legacy device boot order.\r
676\r
e83c9064
LG
677 @retval EFI_SUCCESS The boot devices are added successfully.\r
678 @retval EFI_NOT_FOUND The legacy boot devices are not found.\r
679 @retval EFI_OUT_OF_RESOURCES Memmory or storage is not enough.\r
680 @retval EFI_DEVICE_ERROR Fail to add the legacy device boot order into EFI variable\r
681 because of hardware error.\r
ddac74d1 682**/\r
683EFI_STATUS\r
684EFIAPI\r
685BdsUpdateLegacyDevOrder (\r
686 VOID\r
687 );\r
688\r
689/**\r
ddac74d1 690 Set the boot priority for BBS entries based on boot option entry and boot order.\r
691\r
692 @param Entry The boot option is to be checked for refresh BBS table.\r
693 \r
e83c9064
LG
694 @retval EFI_SUCCESS The boot priority for BBS entries is refreshed successfully.\r
695 @retval EFI_NOT_FOUND BBS entries can't be found.\r
696 @retval EFI_OUT_OF_RESOURCES Failed to get the legacy device boot order.\r
ddac74d1 697**/\r
698EFI_STATUS\r
699EFIAPI\r
700BdsRefreshBbsTableForBoot (\r
701 IN BDS_COMMON_OPTION *Entry\r
702 );\r
703\r
704/**\r
e83c9064
LG
705 Deletete the Boot Option from EFI Variable. The Boot Order Arrray\r
706 is also updated.\r
ddac74d1 707\r
e83c9064
LG
708 @param OptionNumber The number of Boot option want to be deleted.\r
709 @param BootOrder The Boot Order array.\r
710 @param BootOrderSize The size of the Boot Order Array.\r
ddac74d1 711\r
e83c9064
LG
712 @retval EFI_SUCCESS The Boot Option Variable was found and removed\r
713 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible\r
714 @retval EFI_NOT_FOUND The Boot Option Variable was not found\r
ddac74d1 715**/\r
716EFI_STATUS\r
717EFIAPI\r
718BdsDeleteBootOption (\r
719 IN UINTN OptionNumber,\r
720 IN OUT UINT16 *BootOrder,\r
721 IN OUT UINTN *BootOrderSize\r
722 );\r
723\r
724//\r
725//The interface functions relate with Setup Browser Reset Reminder feature\r
726//\r
727/**\r
728 Enable the setup browser reset reminder feature.\r
729 This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
730\r
731**/\r
732VOID\r
733EFIAPI\r
734EnableResetReminderFeature (\r
735 VOID\r
736 );\r
737\r
738/**\r
739 Disable the setup browser reset reminder feature.\r
740 This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
741\r
742**/\r
743VOID\r
744EFIAPI\r
745DisableResetReminderFeature (\r
746 VOID\r
747 );\r
748\r
749/**\r
750 Record the info that a reset is required.\r
751 A module boolean variable is used to record whether a reset is required.\r
752\r
753**/\r
754VOID\r
755EFIAPI\r
756EnableResetRequired (\r
757 VOID\r
758 );\r
759\r
760\r
761/**\r
762 Record the info that no reset is required.\r
763 A module boolean variable is used to record whether a reset is required.\r
764\r
765**/\r
766VOID\r
767EFIAPI\r
768DisableResetRequired (\r
769 VOID\r
770 );\r
771\r
772/**\r
773 Check whether platform policy enable the reset reminder feature. The default is enabled.\r
774\r
775**/\r
776BOOLEAN\r
777EFIAPI\r
778IsResetReminderFeatureEnable (\r
779 VOID\r
780 );\r
781\r
782/**\r
783 Check if user changed any option setting which needs a system reset to be effective.\r
784\r
785**/\r
786BOOLEAN\r
787EFIAPI\r
788IsResetRequired (\r
789 VOID\r
790 );\r
791\r
792/**\r
793 Check whether a reset is needed, and finish the reset reminder feature.\r
794 If a reset is needed, Popup a menu to notice user, and finish the feature\r
795 according to the user selection.\r
796\r
797**/\r
798VOID\r
799EFIAPI\r
800SetupResetReminder (\r
801 VOID\r
802 );\r
803\r
3384a9bc 804\r
e83c9064
LG
805///\r
806/// Define the boot option default description \r
807///\r
3384a9bc 808#define DESCRIPTION_FLOPPY L"EFI Floppy"\r
809#define DESCRIPTION_FLOPPY_NUM L"EFI Floppy %d"\r
810#define DESCRIPTION_DVD L"EFI DVD/CDROM"\r
811#define DESCRIPTION_DVD_NUM L"EFI DVD/CDROM %d"\r
812#define DESCRIPTION_USB L"EFI USB Device"\r
813#define DESCRIPTION_USB_NUM L"EFI USB Device %d"\r
814#define DESCRIPTION_SCSI L"EFI SCSI Device"\r
815#define DESCRIPTION_SCSI_NUM L"EFI SCSI Device %d"\r
816#define DESCRIPTION_MISC L"EFI Misc Device"\r
817#define DESCRIPTION_MISC_NUM L"EFI Misc Device %d"\r
818#define DESCRIPTION_NETWORK L"EFI Network"\r
819#define DESCRIPTION_NETWORK_NUM L"EFI Network %d" \r
820#define DESCRIPTION_NON_BLOCK L"EFI Non-Block Boot Device"\r
821#define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d"\r
822\r
e83c9064
LG
823///\r
824/// Define the boot type which to classify the boot option type\r
825/// Different boot option type could have different boot behavior\r
826/// Use their device path node (Type + SubType) as type value\r
827/// The boot type here can be added according to requirement\r
828///\r
829\r
830///\r
831/// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value\r
832///\r
ddac74d1 833#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201\r
e83c9064
LG
834///\r
835/// Message boot type\r
836/// If a device path of boot option only point to a message node, the boot option is message boot type\r
837///\r
ddac74d1 838#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01\r
839#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02\r
840#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05\r
3384a9bc 841#define BDS_EFI_MESSAGE_SATA_BOOT 0x0318 // Type 03; Sub-Type 18\r
ddac74d1 842#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
e83c9064
LG
843///\r
844/// Media boot type\r
845/// If a device path of boot option contain a media node, the boot option is media boot type\r
846///\r
ddac74d1 847#define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01\r
848#define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02\r
e83c9064
LG
849///\r
850/// BBS boot type\r
851/// If a device path of boot option contain a BBS node, the boot option is BBS boot type\r
852///\r
ddac74d1 853#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01\r
854\r
855#define BDS_EFI_UNSUPPORT 0xFFFF\r
856\r
e83c9064
LG
857///\r
858/// USB host controller Programming Interface.\r
859///\r
ddac74d1 860#define PCI_CLASSC_PI_UHCI 0x00\r
861#define PCI_CLASSC_PI_EHCI 0x20\r
862\r
863/**\r
864 Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
865 instances, has the same partition node with HardDriveDevicePath device path\r
866\r
867 @param BlockIoDevicePath Multi device path instances which need to check\r
868 @param HardDriveDevicePath A device path which starts with a hard drive media\r
869 device path.\r
870\r
871 @retval TRUE There is a matched device path instance.\r
872 @retval FALSE There is no matched device path instance.\r
873\r
874**/\r
875BOOLEAN\r
876EFIAPI\r
877MatchPartitionDevicePathNode (\r
878 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
879 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
880 );\r
881\r
882\r
883/**\r
884 Expand a device path that starts with a hard drive media device path node to be a\r
885 full device path that includes the full hardware path to the device. We need\r
886 to do this so it can be booted. As an optimizaiton the front match (the part point\r
887 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable\r
888 so a connect all is not required on every boot. All successful history device path\r
889 which point to partition node (the front part) will be saved.\r
890\r
891 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard\r
892 drive media device path.\r
893 @return A Pointer to the full device path or NULL if a valid Hard Drive devic path\r
894 cannot be found.\r
895\r
896**/\r
897EFI_DEVICE_PATH_PROTOCOL *\r
898EFIAPI\r
899BdsExpandPartitionPartialDevicePathToFull (\r
900 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
901 );\r
902 \r
903/**\r
904 Return the bootable media handle.\r
905 First, check the device is connected\r
906 Second, check whether the device path point to a device which support SimpleFileSystemProtocol,\r
907 Third, detect the the default boot file in the Media, and return the removable Media handle.\r
908\r
909 @param DevicePath Device Path to a bootable device\r
910\r
e83c9064 911 @return The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
ddac74d1 912\r
913**/\r
914EFI_HANDLE\r
915EFIAPI\r
916BdsLibGetBootableHandle (\r
917 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
918 );\r
919 \r
920\r
921/**\r
922 Check whether the Device path in a boot option point to a valide bootable device,\r
923 And if CheckMedia is true, check the device is ready to boot now.\r
924\r
925 @param DevPath the Device path in a boot option\r
926 @param CheckMedia if true, check the device is ready to boot now.\r
927\r
928 @retval TRUE the Device path is valide\r
929 @retval FALSE the Device path is invalide .\r
930\r
931**/\r
932BOOLEAN\r
933EFIAPI\r
934BdsLibIsValidEFIBootOptDevicePath (\r
935 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
936 IN BOOLEAN CheckMedia\r
937 );\r
3384a9bc 938\r
939/**\r
940 Check whether the Device path in a boot option point to a valid bootable device,\r
941 And if CheckMedia is true, check the device is ready to boot now.\r
942 If Description is not NULL and the device path point to a fixed BlockIo\r
943 device, check the description whether conflict with other auto-created\r
944 boot options.\r
945\r
946 @param DevPath the Device path in a boot option\r
947 @param CheckMedia if true, check the device is ready to boot now.\r
948 @param Description the description in a boot option\r
949\r
950 @retval TRUE the Device path is valid\r
951 @retval FALSE the Device path is invalid .\r
952\r
953**/\r
954BOOLEAN\r
955EFIAPI\r
956BdsLibIsValidEFIBootOptDevicePathExt (\r
957 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
958 IN BOOLEAN CheckMedia,\r
959 IN CHAR16 *Description\r
960 );\r
961\r
ddac74d1 962/**\r
963 For a bootable Device path, return its boot type.\r
964\r
965 @param DevicePath The bootable device Path to check\r
966\r
967 @retval BDS_EFI_MEDIA_HD_BOOT If the device path contains any media deviec path node, it is media boot type\r
968 For the floppy node, handle it as media node\r
969 @retval BDS_EFI_MEDIA_CDROM_BOOT If the device path contains any media deviec path node, it is media boot type\r
970 For the floppy node, handle it as media node\r
971 @retval BDS_EFI_ACPI_FLOPPY_BOOT If the device path contains any media deviec path node, it is media boot type\r
972 For the floppy node, handle it as media node\r
973 @retval BDS_EFI_MESSAGE_ATAPI_BOOT If the device path not contains any media deviec path node, and\r
974 its last device path node point to a message device path node, it is\r
975 \r
976 @retval BDS_EFI_MESSAGE_SCSI_BOOT If the device path not contains any media deviec path node, and\r
977 its last device path node point to a message device path node, it is\r
978 @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media deviec path node, and\r
979 its last device path node point to a message device path node, it is\r
980 @retval BDS_EFI_MESSAGE_MISC_BOOT If the device path not contains any media deviec path node, and\r
981 its last device path node point to a message device path node, it is\r
982 @retval BDS_LEGACY_BBS_BOOT Legacy boot type\r
983 @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path not point to a media and message devie, \r
984\r
985**/\r
986UINT32\r
987EFIAPI\r
988BdsGetBootTypeFromDevicePath (\r
989 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
990 );\r
991\r
992\r
993/**\r
994 This routine register a function to adjust the different type memory page number\r
995 just before booting and save the updated info into the variable for next boot to use.\r
996\r
997**/\r
998VOID\r
999EFIAPI\r
1000BdsLibSaveMemoryTypeInformation (\r
1001 VOID\r
1002 );\r
1003 \r
1004\r
1005/**\r
1006 According to a file guild, check a Fv file device path is valid. If it is invalid,\r
1007 try to return the valid device path.\r
1008 FV address maybe changes for memory layout adjust from time to time, use this funciton\r
1009 could promise the Fv file device path is right.\r
1010\r
1011 @param DevicePath on input, the Fv file device path need to check on\r
1012 output, the updated valid Fv file device path\r
1013 @param FileGuid the Fv file guild\r
1014\r
1015 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid\r
1016 parameter\r
1017 @retval EFI_UNSUPPORTED the input DevicePath does not contain Fv file\r
1018 guild at all\r
1019 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to Fv file, it is\r
1020 valid\r
1021 @retval EFI_SUCCESS has successfully updated the invalid DevicePath,\r
1022 and return the updated device path in DevicePath\r
1023\r
1024**/\r
1025EFI_STATUS\r
1026EFIAPI\r
1027BdsLibUpdateFvFileDevicePath (\r
1028 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
1029 IN EFI_GUID *FileGuid\r
1030 );\r
1031\r
1032\r
1033/**\r
1034 Connect the specific Usb device which match the short form device path,\r
1035 and whose bus is determined by Host Controller (Uhci or Ehci)\r
1036\r
1037 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
1038 (0xFF)\r
1039 @param RemainingDevicePath a short-form device path that starts with the first\r
1040 element being a USB WWID or a USB Class device\r
1041 path\r
1042\r
1043 @retval EFI_SUCCESS The specific Usb device is connected successfully.\r
1044 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
1045 or RemainingDevicePath is not the USB class device path.\r
1046 @retval EFI_NOT_FOUND The device specified by device path is not found.\r
1047\r
1048**/\r
1049EFI_STATUS\r
1050EFIAPI\r
1051BdsLibConnectUsbDevByShortFormDP(\r
1052 IN UINT8 HostControllerPI,\r
1053 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
1054 );\r
1055 \r
1056\r
1057//\r
1058// The implementation of this function is provided by Platform code.\r
1059//\r
1060/**\r
1061 Convert Vendor device path to device name.\r
1062\r
1063 @param Str The buffer store device name\r
1064 @param DevPath Pointer to vendor device path\r
1065\r
1066**/\r
1067VOID\r
ddac74d1 1068DevPathVendor (\r
1069 IN OUT POOL_PRINT *Str,\r
1070 IN VOID *DevPath\r
1071 );\r
1072\r
1073/**\r
1074 Concatenates a formatted unicode string to allocated pool.\r
1075 The caller must free the resulting buffer.\r
1076\r
1077 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
b4b6c8de 1078 @param Fmt The format string\r
ddac74d1 1079 @param ... The data will be printed.\r
1080\r
1081 @return Allocated buffer with the formatted string printed in it.\r
1082 The caller must free the allocated buffer.\r
1083 The buffer allocation is not packed.\r
1084\r
1085**/\r
1086CHAR16 *\r
1087EFIAPI\r
1088CatPrint (\r
1089 IN OUT POOL_PRINT *Str,\r
b4b6c8de 1090 IN CHAR16 *Fmt,\r
ddac74d1 1091 ...\r
1092 );\r
1093\r
1094/**\r
1095 Use Console Control to turn off UGA based Simple Text Out consoles from going\r
1096 to the UGA device. Put up LogoFile on every UGA device that is a console\r
1097\r
1098 @param[in] LogoFile File name of logo to display on the center of the screen.\r
1099\r
1100 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
1101 @retval EFI_UNSUPPORTED Logo not found\r
1102\r
1103**/\r
1104EFI_STATUS\r
1105EFIAPI\r
1106EnableQuietBoot (\r
1107 IN EFI_GUID *LogoFile\r
1108 );\r
1109\r
1110\r
1111/**\r
1112 Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
1113 Simple Text Out screens will now be synced up with all non UGA output devices\r
1114\r
1115 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
1116\r
1117**/\r
1118EFI_STATUS\r
1119EFIAPI\r
1120DisableQuietBoot (\r
1121 VOID\r
1122 );\r
1123\r
1124/**\r
1125 Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
1126 This is the ConInHandle and ConIn handle in the EFI system table. All key\r
1127 presses will be ignored until the Password is typed in. The only way to\r
1128 disable the password is to type it in to a ConIn device.\r
1129\r
1130 @param Password Password used to lock ConIn device.\r
1131\r
1132 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
1133 @retval EFI_UNSUPPORTED Password not found\r
1134\r
1135**/\r
1136EFI_STATUS\r
1137EFIAPI\r
1138LockKeyboards (\r
1139 IN CHAR16 *Password\r
1140 );\r
1141\r
1142#endif\r
1143\r