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