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