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