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