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