according to DataHubSubclass spec, all fields of data record should be naturally...
[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
0977c9b2 418 This function will connect all current system handles recursively. \r
419 \r
420 gBS->ConnectController() service is invoked for each handle exist in system handler buffer.\r
421 If the handle is bus type handler, all childrens also will be connected recursively\r
422 by gBS->ConnectController().\r
ddac74d1 423\r
0977c9b2 424 @retval EFI_SUCCESS All handles and it's child handle have been connected\r
425 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().\r
ddac74d1 426\r
427**/\r
428EFI_STATUS\r
429EFIAPI\r
430BdsLibConnectAllEfi (\r
431 VOID\r
432 );\r
433\r
ddac74d1 434/**\r
0977c9b2 435 This function will disconnect all current system handles. \r
436 \r
437 gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
438 If handle is a bus type handle, all childrens also are disconnected recursively by\r
439 gBS->DisconnectController().\r
ddac74d1 440\r
441 @retval EFI_SUCCESS All handles have been disconnected\r
0977c9b2 442 @retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().\r
ddac74d1 443\r
444**/\r
445EFI_STATUS\r
446EFIAPI\r
447BdsLibDisconnectAllEfi (\r
448 VOID\r
449 );\r
450\r
451//\r
452// Bds console related lib functions\r
453//\r
454/**\r
455 This function will search every simpletxt devive in current system,\r
456 and make every simpletxt device as pertantial console device.\r
457\r
458**/\r
459VOID\r
460EFIAPI\r
461BdsLibConnectAllConsoles (\r
462 VOID\r
463 );\r
464\r
465\r
466/**\r
467 This function will connect console device base on the console\r
468 device variable ConIn, ConOut and ErrOut.\r
469\r
470 @retval EFI_SUCCESS At least one of the ConIn and ConOut device have\r
471 been connected success.\r
472 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().\r
473\r
474**/\r
475EFI_STATUS\r
476EFIAPI\r
477BdsLibConnectAllDefaultConsoles (\r
478 VOID\r
479 );\r
480\r
481/**\r
482 This function update console variable based on ConVarName, it can\r
483 add or remove one specific console device path from the variable\r
484\r
485 @param ConVarName Console related variable name, ConIn, ConOut,\r
486 ErrOut.\r
487 @param CustomizedConDevicePath The console device path which will be added to\r
488 the console variable ConVarName, this parameter\r
489 can not be multi-instance.\r
490 @param ExclusiveDevicePath The console device path which will be removed\r
491 from the console variable ConVarName, this\r
492 parameter can not be multi-instance.\r
493\r
494 @retval EFI_UNSUPPORTED The added device path is same to the removed one.\r
495 @retval EFI_SUCCESS Success add or remove the device path from the\r
496 console variable.\r
497\r
498**/\r
499EFI_STATUS\r
500EFIAPI\r
501BdsLibUpdateConsoleVariable (\r
502 IN CHAR16 *ConVarName,\r
503 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,\r
504 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath\r
505 );\r
506\r
507/**\r
508 Connect the console device base on the variable ConVarName, if\r
509 device path of the ConVarName is multi-instance device path, if\r
510 anyone of the instances is connected success, then this function\r
511 will return success.\r
512\r
513 @param ConVarName Console related variable name, ConIn, ConOut,\r
514 ErrOut.\r
515\r
516 @retval EFI_NOT_FOUND There is not any console devices connected\r
517 success\r
518 @retval EFI_SUCCESS Success connect any one instance of the console\r
519 device path base on the variable ConVarName.\r
520\r
521**/\r
522EFI_STATUS\r
523EFIAPI\r
524BdsLibConnectConsoleVariable (\r
525 IN CHAR16 *ConVarName\r
526 );\r
527\r
528//\r
529// Bds device path related lib functions\r
530//\r
531/**\r
532 Delete the instance in Multi which matches partly with Single instance\r
533\r
534 @param Multi A pointer to a multi-instance device path data\r
535 structure.\r
536 @param Single A pointer to a single-instance device path data\r
537 structure.\r
538\r
539 @return This function will remove the device path instances in Multi which partly\r
540 match with the Single, and return the result device path. If there is no\r
541 remaining device path as a result, this function will return NULL.\r
542\r
543**/\r
544EFI_DEVICE_PATH_PROTOCOL *\r
545EFIAPI\r
546BdsLibDelPartMatchInstance (\r
547 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
548 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
549 );\r
550\r
551/**\r
552 Function compares a device path data structure to that of all the nodes of a\r
553 second device path instance.\r
554\r
555 @param Multi A pointer to a multi-instance device path data\r
556 structure.\r
557 @param Single A pointer to a single-instance device path data\r
558 structure.\r
559\r
560 @retval TRUE If the Single device path is contained within Multi device path.\r
561 @retval FALSE The Single device path is not match within Multi device path.\r
562\r
563**/\r
564BOOLEAN\r
565EFIAPI\r
566BdsLibMatchDevicePaths (\r
567 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
568 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
569 );\r
570\r
571/**\r
572 This function converts an input device structure to a Unicode string.\r
573\r
574 @param DevPath A pointer to the device path structure.\r
575\r
576 @return A new allocated Unicode string that represents the device path.\r
577\r
578**/\r
579CHAR16 *\r
580EFIAPI\r
581DevicePathToStr (\r
582 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
583 );\r
584\r
585\r
586//\r
587// Internal definitions\r
588//\r
589typedef struct {\r
b4b6c8de
LG
590 CHAR16 *Str;\r
591 UINTN Len;\r
592 UINTN Maxlen;\r
ddac74d1 593} POOL_PRINT;\r
594\r
595typedef struct {\r
596 UINT8 Type;\r
597 UINT8 SubType;\r
598 VOID (*Function) (POOL_PRINT *, VOID *);\r
599} DEVICE_PATH_STRING_TABLE;\r
600\r
601extern EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;\r
602\r
603typedef struct {\r
604 EFI_DEVICE_PATH_PROTOCOL Header;\r
605 EFI_GUID Guid;\r
606 UINT8 VendorDefinedData[1];\r
607} VENDOR_DEVICE_PATH_WITH_DATA;\r
608\r
609\r
610extern EFI_GUID mEfiDevicePathMessagingSASGuid;\r
611\r
612typedef struct {\r
613 EFI_DEVICE_PATH_PROTOCOL Header;\r
614 UINT16 NetworkProtocol;\r
615 UINT16 LoginOption;\r
616 UINT64 Lun;\r
617 UINT16 TargetPortalGroupTag;\r
201e4066 618 CHAR16 TargetName[1];\r
ddac74d1 619} ISCSI_DEVICE_PATH_WITH_NAME;\r
620\r
621\r
622//\r
623// Notes: EFI 64 shadow all option rom\r
624//\r
625#if defined (MDE_CPU_IPF)\r
626#define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();\r
627#else\r
628#define EFI64_SHADOW_ALL_LEGACY_ROM()\r
629#endif\r
630\r
631/**\r
632 Shadow all Legacy OptionRom. \r
633\r
634**/\r
635VOID\r
636EFIAPI\r
637ShadowAllOptionRom (\r
638 VOID\r
639 );\r
640\r
641//\r
642// BBS support macros and functions\r
643//\r
644\r
645#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)\r
646#define REFRESH_LEGACY_BOOT_OPTIONS \\r
647 BdsDeleteAllInvalidLegacyBootOptions ();\\r
648 BdsAddNonExistingLegacyBootOptions (); \\r
649 BdsUpdateLegacyDevOrder ()\r
650#else\r
651#define REFRESH_LEGACY_BOOT_OPTIONS\r
652#endif\r
653\r
654/**\r
655 Delete all the invalid legacy boot options.\r
656\r
657 @retval EFI_SUCCESS All invalide legacy boot options are deleted.\r
658 @retval EFI_OUT_OF_RESOURCES Fail to allocate necessary memory.\r
659 @retval EFI_NOT_FOUND Fail to retrive variable of boot order.\r
660\r
661**/\r
662EFI_STATUS\r
663EFIAPI\r
664BdsDeleteAllInvalidLegacyBootOptions (\r
665 VOID\r
666 );\r
667\r
668/**\r
669\r
670 Add the legacy boot options from BBS table if they do not exist.\r
671\r
672 @retval EFI_SUCCESS The boot options are added successfully \r
673 or they are already in boot options.\r
674\r
675**/\r
676EFI_STATUS\r
677EFIAPI\r
678BdsAddNonExistingLegacyBootOptions (\r
679 VOID\r
680 );\r
681\r
682/**\r
683\r
684 Add the legacy boot devices from BBS table into \r
685 the legacy device boot order.\r
686\r
687 @retval EFI_SUCCESS The boot devices are added successfully.\r
688\r
689**/\r
690EFI_STATUS\r
691EFIAPI\r
692BdsUpdateLegacyDevOrder (\r
693 VOID\r
694 );\r
695\r
696/**\r
697\r
698 Set the boot priority for BBS entries based on boot option entry and boot order.\r
699\r
700 @param Entry The boot option is to be checked for refresh BBS table.\r
701 \r
702 @retval EFI_SUCCESS The boot priority for BBS entries is refreshed successfully.\r
703\r
704**/\r
705EFI_STATUS\r
706EFIAPI\r
707BdsRefreshBbsTableForBoot (\r
708 IN BDS_COMMON_OPTION *Entry\r
709 );\r
710\r
711/**\r
712\r
713 Delete boot option specified by OptionNumber and adjust the boot order.\r
714\r
715 @param OptionNumber The boot option to be deleted.\r
716 @param BootOrder Boot order list to be adjusted by remove this boot option.\r
717 @param BootOrderSize The size of Boot order list will be modified.\r
718 \r
719 @retval EFI_SUCCESS The boot option is deleted successfully.\r
720\r
721**/\r
722EFI_STATUS\r
723EFIAPI\r
724BdsDeleteBootOption (\r
725 IN UINTN OptionNumber,\r
726 IN OUT UINT16 *BootOrder,\r
727 IN OUT UINTN *BootOrderSize\r
728 );\r
729\r
730//\r
731//The interface functions relate with Setup Browser Reset Reminder feature\r
732//\r
733/**\r
734 Enable the setup browser reset reminder feature.\r
735 This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
736\r
737**/\r
738VOID\r
739EFIAPI\r
740EnableResetReminderFeature (\r
741 VOID\r
742 );\r
743\r
744/**\r
745 Disable the setup browser reset reminder feature.\r
746 This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
747\r
748**/\r
749VOID\r
750EFIAPI\r
751DisableResetReminderFeature (\r
752 VOID\r
753 );\r
754\r
755/**\r
756 Record the info that a reset is required.\r
757 A module boolean variable is used to record whether a reset is required.\r
758\r
759**/\r
760VOID\r
761EFIAPI\r
762EnableResetRequired (\r
763 VOID\r
764 );\r
765\r
766\r
767/**\r
768 Record the info that no reset is required.\r
769 A module boolean variable is used to record whether a reset is required.\r
770\r
771**/\r
772VOID\r
773EFIAPI\r
774DisableResetRequired (\r
775 VOID\r
776 );\r
777\r
778/**\r
779 Check whether platform policy enable the reset reminder feature. The default is enabled.\r
780\r
781**/\r
782BOOLEAN\r
783EFIAPI\r
784IsResetReminderFeatureEnable (\r
785 VOID\r
786 );\r
787\r
788/**\r
789 Check if user changed any option setting which needs a system reset to be effective.\r
790\r
791**/\r
792BOOLEAN\r
793EFIAPI\r
794IsResetRequired (\r
795 VOID\r
796 );\r
797\r
798/**\r
799 Check whether a reset is needed, and finish the reset reminder feature.\r
800 If a reset is needed, Popup a menu to notice user, and finish the feature\r
801 according to the user selection.\r
802\r
803**/\r
804VOID\r
805EFIAPI\r
806SetupResetReminder (\r
807 VOID\r
808 );\r
809\r
3384a9bc 810\r
811//\r
812// Define the boot option default description \r
813// NOTE: This is not defined in UEFI spec.\r
814//\r
815#define DESCRIPTION_FLOPPY L"EFI Floppy"\r
816#define DESCRIPTION_FLOPPY_NUM L"EFI Floppy %d"\r
817#define DESCRIPTION_DVD L"EFI DVD/CDROM"\r
818#define DESCRIPTION_DVD_NUM L"EFI DVD/CDROM %d"\r
819#define DESCRIPTION_USB L"EFI USB Device"\r
820#define DESCRIPTION_USB_NUM L"EFI USB Device %d"\r
821#define DESCRIPTION_SCSI L"EFI SCSI Device"\r
822#define DESCRIPTION_SCSI_NUM L"EFI SCSI Device %d"\r
823#define DESCRIPTION_MISC L"EFI Misc Device"\r
824#define DESCRIPTION_MISC_NUM L"EFI Misc Device %d"\r
825#define DESCRIPTION_NETWORK L"EFI Network"\r
826#define DESCRIPTION_NETWORK_NUM L"EFI Network %d" \r
827#define DESCRIPTION_NON_BLOCK L"EFI Non-Block Boot Device"\r
828#define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d"\r
829\r
ddac74d1 830//\r
831// Define the boot type which to classify the boot option type\r
832// Different boot option type could have different boot behavior\r
833// Use their device path node (Type + SubType) as type value\r
834// The boot type here can be added according to requirement\r
835//\r
836//\r
837// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value\r
838//\r
839#define BDS_EFI_ACPI_FLOPPY_BOOT 0x0201\r
840//\r
841// Message boot type\r
842// If a device path of boot option only point to a message node, the boot option is message boot type\r
843//\r
844#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01\r
845#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02\r
846#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05\r
3384a9bc 847#define BDS_EFI_MESSAGE_SATA_BOOT 0x0318 // Type 03; Sub-Type 18\r
ddac74d1 848#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
849//\r
850// Media boot type\r
851// If a device path of boot option contain a media node, the boot option is media boot type\r
852//\r
853#define BDS_EFI_MEDIA_HD_BOOT 0x0401 // Type 04; Sub-Type 01\r
854#define BDS_EFI_MEDIA_CDROM_BOOT 0x0402 // Type 04; Sub-Type 02\r
855//\r
856// BBS boot type\r
857// If a device path of boot option contain a BBS node, the boot option is BBS boot type\r
858//\r
859#define BDS_LEGACY_BBS_BOOT 0x0501 // Type 05; Sub-Type 01\r
860\r
861#define BDS_EFI_UNSUPPORT 0xFFFF\r
862\r
863//\r
864// USB host controller Programming Interface.\r
865//\r
866#define PCI_CLASSC_PI_UHCI 0x00\r
867#define PCI_CLASSC_PI_EHCI 0x20\r
868\r
869/**\r
870 Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
871 instances, has the same partition node with HardDriveDevicePath device path\r
872\r
873 @param BlockIoDevicePath Multi device path instances which need to check\r
874 @param HardDriveDevicePath A device path which starts with a hard drive media\r
875 device path.\r
876\r
877 @retval TRUE There is a matched device path instance.\r
878 @retval FALSE There is no matched device path instance.\r
879\r
880**/\r
881BOOLEAN\r
882EFIAPI\r
883MatchPartitionDevicePathNode (\r
884 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
885 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
886 );\r
887\r
888\r
889/**\r
890 Expand a device path that starts with a hard drive media device path node to be a\r
891 full device path that includes the full hardware path to the device. We need\r
892 to do this so it can be booted. As an optimizaiton the front match (the part point\r
893 to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable\r
894 so a connect all is not required on every boot. All successful history device path\r
895 which point to partition node (the front part) will be saved.\r
896\r
897 @param HardDriveDevicePath EFI Device Path to boot, if it starts with a hard\r
898 drive media device path.\r
899 @return A Pointer to the full device path or NULL if a valid Hard Drive devic path\r
900 cannot be found.\r
901\r
902**/\r
903EFI_DEVICE_PATH_PROTOCOL *\r
904EFIAPI\r
905BdsExpandPartitionPartialDevicePathToFull (\r
906 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
907 );\r
908 \r
909/**\r
910 Return the bootable media handle.\r
911 First, check the device is connected\r
912 Second, check whether the device path point to a device which support SimpleFileSystemProtocol,\r
913 Third, detect the the default boot file in the Media, and return the removable Media handle.\r
914\r
915 @param DevicePath Device Path to a bootable device\r
916\r
917 @retval NULL The media on the DevicePath is not bootable\r
918\r
919**/\r
920EFI_HANDLE\r
921EFIAPI\r
922BdsLibGetBootableHandle (\r
923 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
924 );\r
925 \r
926\r
927/**\r
928 Check whether the Device path in a boot option point to a valide bootable device,\r
929 And if CheckMedia is true, check the device is ready to boot now.\r
930\r
931 @param DevPath the Device path in a boot option\r
932 @param CheckMedia if true, check the device is ready to boot now.\r
933\r
934 @retval TRUE the Device path is valide\r
935 @retval FALSE the Device path is invalide .\r
936\r
937**/\r
938BOOLEAN\r
939EFIAPI\r
940BdsLibIsValidEFIBootOptDevicePath (\r
941 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
942 IN BOOLEAN CheckMedia\r
943 );\r
3384a9bc 944\r
945/**\r
946 Check whether the Device path in a boot option point to a valid bootable device,\r
947 And if CheckMedia is true, check the device is ready to boot now.\r
948 If Description is not NULL and the device path point to a fixed BlockIo\r
949 device, check the description whether conflict with other auto-created\r
950 boot options.\r
951\r
952 @param DevPath the Device path in a boot option\r
953 @param CheckMedia if true, check the device is ready to boot now.\r
954 @param Description the description in a boot option\r
955\r
956 @retval TRUE the Device path is valid\r
957 @retval FALSE the Device path is invalid .\r
958\r
959**/\r
960BOOLEAN\r
961EFIAPI\r
962BdsLibIsValidEFIBootOptDevicePathExt (\r
963 IN EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
964 IN BOOLEAN CheckMedia,\r
965 IN CHAR16 *Description\r
966 );\r
967\r
ddac74d1 968/**\r
969 For a bootable Device path, return its boot type.\r
970\r
971 @param DevicePath The bootable device Path to check\r
972\r
973 @retval BDS_EFI_MEDIA_HD_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_MEDIA_CDROM_BOOT If the device path contains any media deviec path node, it is media boot type\r
976 For the floppy node, handle it as media node\r
977 @retval BDS_EFI_ACPI_FLOPPY_BOOT If the device path contains any media deviec path node, it is media boot type\r
978 For the floppy node, handle it as media node\r
979 @retval BDS_EFI_MESSAGE_ATAPI_BOOT If the device path not contains any media deviec path node, and\r
980 its last device path node point to a message device path node, it is\r
981 \r
982 @retval BDS_EFI_MESSAGE_SCSI_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_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media deviec path node, and\r
985 its last device path node point to a message device path node, it is\r
986 @retval BDS_EFI_MESSAGE_MISC_BOOT If the device path not contains any media deviec path node, and\r
987 its last device path node point to a message device path node, it is\r
988 @retval BDS_LEGACY_BBS_BOOT Legacy boot type\r
989 @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path not point to a media and message devie, \r
990\r
991**/\r
992UINT32\r
993EFIAPI\r
994BdsGetBootTypeFromDevicePath (\r
995 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
996 );\r
997\r
998\r
999/**\r
1000 This routine register a function to adjust the different type memory page number\r
1001 just before booting and save the updated info into the variable for next boot to use.\r
1002\r
1003**/\r
1004VOID\r
1005EFIAPI\r
1006BdsLibSaveMemoryTypeInformation (\r
1007 VOID\r
1008 );\r
1009 \r
1010\r
1011/**\r
1012 According to a file guild, check a Fv file device path is valid. If it is invalid,\r
1013 try to return the valid device path.\r
1014 FV address maybe changes for memory layout adjust from time to time, use this funciton\r
1015 could promise the Fv file device path is right.\r
1016\r
1017 @param DevicePath on input, the Fv file device path need to check on\r
1018 output, the updated valid Fv file device path\r
1019 @param FileGuid the Fv file guild\r
1020\r
1021 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid\r
1022 parameter\r
1023 @retval EFI_UNSUPPORTED the input DevicePath does not contain Fv file\r
1024 guild at all\r
1025 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to Fv file, it is\r
1026 valid\r
1027 @retval EFI_SUCCESS has successfully updated the invalid DevicePath,\r
1028 and return the updated device path in DevicePath\r
1029\r
1030**/\r
1031EFI_STATUS\r
1032EFIAPI\r
1033BdsLibUpdateFvFileDevicePath (\r
1034 IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,\r
1035 IN EFI_GUID *FileGuid\r
1036 );\r
1037\r
1038\r
1039/**\r
1040 Connect the specific Usb device which match the short form device path,\r
1041 and whose bus is determined by Host Controller (Uhci or Ehci)\r
1042\r
1043 @param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci\r
1044 (0xFF)\r
1045 @param RemainingDevicePath a short-form device path that starts with the first\r
1046 element being a USB WWID or a USB Class device\r
1047 path\r
1048\r
1049 @retval EFI_SUCCESS The specific Usb device is connected successfully.\r
1050 @retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF) \r
1051 or RemainingDevicePath is not the USB class device path.\r
1052 @retval EFI_NOT_FOUND The device specified by device path is not found.\r
1053\r
1054**/\r
1055EFI_STATUS\r
1056EFIAPI\r
1057BdsLibConnectUsbDevByShortFormDP(\r
1058 IN UINT8 HostControllerPI,\r
1059 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
1060 );\r
1061 \r
1062\r
1063//\r
1064// The implementation of this function is provided by Platform code.\r
1065//\r
1066/**\r
1067 Convert Vendor device path to device name.\r
1068\r
1069 @param Str The buffer store device name\r
1070 @param DevPath Pointer to vendor device path\r
1071\r
1072**/\r
1073VOID\r
ddac74d1 1074DevPathVendor (\r
1075 IN OUT POOL_PRINT *Str,\r
1076 IN VOID *DevPath\r
1077 );\r
1078\r
1079/**\r
1080 Concatenates a formatted unicode string to allocated pool.\r
1081 The caller must free the resulting buffer.\r
1082\r
1083 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
b4b6c8de 1084 @param Fmt The format string\r
ddac74d1 1085 @param ... The data will be printed.\r
1086\r
1087 @return Allocated buffer with the formatted string printed in it.\r
1088 The caller must free the allocated buffer.\r
1089 The buffer allocation is not packed.\r
1090\r
1091**/\r
1092CHAR16 *\r
1093EFIAPI\r
1094CatPrint (\r
1095 IN OUT POOL_PRINT *Str,\r
b4b6c8de 1096 IN CHAR16 *Fmt,\r
ddac74d1 1097 ...\r
1098 );\r
1099\r
1100/**\r
1101 Use Console Control to turn off UGA based Simple Text Out consoles from going\r
1102 to the UGA device. Put up LogoFile on every UGA device that is a console\r
1103\r
1104 @param[in] LogoFile File name of logo to display on the center of the screen.\r
1105\r
1106 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
1107 @retval EFI_UNSUPPORTED Logo not found\r
1108\r
1109**/\r
1110EFI_STATUS\r
1111EFIAPI\r
1112EnableQuietBoot (\r
1113 IN EFI_GUID *LogoFile\r
1114 );\r
1115\r
1116\r
1117/**\r
1118 Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
1119 Simple Text Out screens will now be synced up with all non UGA output devices\r
1120\r
1121 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
1122\r
1123**/\r
1124EFI_STATUS\r
1125EFIAPI\r
1126DisableQuietBoot (\r
1127 VOID\r
1128 );\r
1129\r
1130/**\r
1131 Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
1132 This is the ConInHandle and ConIn handle in the EFI system table. All key\r
1133 presses will be ignored until the Password is typed in. The only way to\r
1134 disable the password is to type it in to a ConIn device.\r
1135\r
1136 @param Password Password used to lock ConIn device.\r
1137\r
1138 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
1139 @retval EFI_UNSUPPORTED Password not found\r
1140\r
1141**/\r
1142EFI_STATUS\r
1143EFIAPI\r
1144LockKeyboards (\r
1145 IN CHAR16 *Password\r
1146 );\r
1147\r
1148#endif\r
1149\r