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