]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/GenericBdsLib/BdsMisc.c
Fix the doxygen comment.
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / BdsMisc.c
CommitLineData
897f0eee 1/** @file\r
2 Misc BDS library 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#include "InternalBdsLib.h"\r
16\r
17\r
18#define MAX_STRING_LEN 200\r
19\r
11ef23f9 20BOOLEAN mFeaturerSwitch = TRUE;\r
ec8cd35c 21BOOLEAN mResetRequired = FALSE;\r
897f0eee 22\r
23extern UINT16 gPlatformBootTimeOutDefault;\r
24\r
25\r
26/**\r
27 Return the default value for system Timeout variable.\r
28\r
29 @return Timeout value.\r
30\r
31**/\r
32UINT16\r
33EFIAPI\r
34BdsLibGetTimeout (\r
35 VOID\r
36 )\r
37{\r
38 UINT16 Timeout;\r
39 UINTN Size;\r
40 EFI_STATUS Status;\r
41\r
42 //\r
43 // Return Timeout variable or 0xffff if no valid\r
44 // Timeout variable exists.\r
45 //\r
46 Size = sizeof (UINT16);\r
47 Status = gRT->GetVariable (L"Timeout", &gEfiGlobalVariableGuid, NULL, &Size, &Timeout);\r
0ef93eb7 48 if (EFI_ERROR (Status)) {\r
49 //\r
50 // According to UEFI 2.0 spec, it should treat the Timeout value as 0xffff\r
51 // (default value PcdPlatformBootTimeOutDefault) when L"Timeout" variable is not present.\r
52 // To make the current EFI Automatic-Test activity possible, platform can choose other value\r
53 // for automatic boot when the variable is not present.\r
54 //\r
55 Timeout = PcdGet16 (PcdPlatformBootTimeOutDefault);\r
897f0eee 56 }\r
897f0eee 57\r
897f0eee 58 return Timeout;\r
59}\r
60\r
897f0eee 61/**\r
62 The function will go through the driver optoin link list, load and start\r
63 every driver the driver optoin device path point to.\r
64\r
65 @param BdsDriverLists The header of the current driver option link list\r
66\r
67**/\r
68VOID\r
69EFIAPI\r
70BdsLibLoadDrivers (\r
71 IN LIST_ENTRY *BdsDriverLists\r
72 )\r
73{\r
74 EFI_STATUS Status;\r
75 LIST_ENTRY *Link;\r
76 BDS_COMMON_OPTION *Option;\r
77 EFI_HANDLE ImageHandle;\r
78 EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
79 UINTN ExitDataSize;\r
80 CHAR16 *ExitData;\r
81 BOOLEAN ReconnectAll;\r
82\r
83 ReconnectAll = FALSE;\r
84\r
85 //\r
86 // Process the driver option\r
87 //\r
88 for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) {\r
89 Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
ec8cd35c 90 \r
897f0eee 91 //\r
92 // If a load option is not marked as LOAD_OPTION_ACTIVE,\r
93 // the boot manager will not automatically load the option.\r
94 //\r
95 if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) {\r
96 continue;\r
97 }\r
ec8cd35c 98 \r
897f0eee 99 //\r
100 // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
101 // then all of the EFI drivers in the system will be disconnected and\r
102 // reconnected after the last driver load option is processed.\r
103 //\r
104 if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) {\r
105 ReconnectAll = TRUE;\r
106 }\r
ec8cd35c 107 \r
897f0eee 108 //\r
109 // Make sure the driver path is connected.\r
110 //\r
111 BdsLibConnectDevicePath (Option->DevicePath);\r
112\r
113 //\r
114 // Load and start the image that Driver#### describes\r
115 //\r
116 Status = gBS->LoadImage (\r
117 FALSE,\r
118 mBdsImageHandle,\r
119 Option->DevicePath,\r
120 NULL,\r
121 0,\r
122 &ImageHandle\r
123 );\r
124\r
125 if (!EFI_ERROR (Status)) {\r
126 gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);\r
127\r
128 //\r
129 // Verify whether this image is a driver, if not,\r
130 // exit it and continue to parse next load option\r
131 //\r
132 if (ImageInfo->ImageCodeType != EfiBootServicesCode && ImageInfo->ImageCodeType != EfiRuntimeServicesCode) {\r
133 gBS->Exit (ImageHandle, EFI_INVALID_PARAMETER, 0, NULL);\r
134 continue;\r
135 }\r
136\r
137 if (Option->LoadOptionsSize != 0) {\r
138 ImageInfo->LoadOptionsSize = Option->LoadOptionsSize;\r
139 ImageInfo->LoadOptions = Option->LoadOptions;\r
140 }\r
141 //\r
142 // Before calling the image, enable the Watchdog Timer for\r
143 // the 5 Minute period\r
144 //\r
145 gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
146\r
147 Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
148 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Driver Return Status = %r\n", Status));\r
149\r
150 //\r
151 // Clear the Watchdog Timer after the image returns\r
152 //\r
153 gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
154 }\r
155 }\r
ec8cd35c 156 \r
897f0eee 157 //\r
158 // Process the LOAD_OPTION_FORCE_RECONNECT driver option\r
159 //\r
160 if (ReconnectAll) {\r
161 BdsLibDisconnectAllEfi ();\r
162 BdsLibConnectAll ();\r
163 }\r
164\r
165}\r
166\r
897f0eee 167/**\r
11ef23f9 168 Get the Option Number that does not used.\r
169 Try to locate the specific option variable one by one untile find a free number.\r
897f0eee 170\r
171 @param VariableName Indicate if the boot#### or driver#### option\r
172\r
173 @return The Minimal Free Option Number\r
174\r
175**/\r
176UINT16\r
177BdsLibGetFreeOptionNumber (\r
178 IN CHAR16 *VariableName\r
179 )\r
180{\r
897f0eee 181 UINTN Index;\r
182 CHAR16 StrTemp[10];\r
183 UINT16 *OptionBuffer;\r
184 UINTN OptionSize;\r
185\r
186 //\r
187 // Try to find the minimum free number from 0, 1, 2, 3....\r
188 //\r
189 Index = 0;\r
190 do {\r
191 if (*VariableName == 'B') {\r
192 UnicodeSPrint (StrTemp, sizeof (StrTemp), L"Boot%04x", Index);\r
193 } else {\r
194 UnicodeSPrint (StrTemp, sizeof (StrTemp), L"Driver%04x", Index);\r
195 }\r
196 //\r
197 // try if the option number is used\r
198 //\r
199 OptionBuffer = BdsLibGetVariableAndSize (\r
ec8cd35c 200 StrTemp,\r
201 &gEfiGlobalVariableGuid,\r
202 &OptionSize\r
203 );\r
897f0eee 204 if (OptionBuffer == NULL) {\r
205 break;\r
206 }\r
ec8cd35c 207 Index ++;\r
208 } while (TRUE);\r
897f0eee 209\r
ec8cd35c 210 return ((UINT16) Index);\r
897f0eee 211}\r
212\r
213\r
214/**\r
215 This function will register the new boot#### or driver#### option base on\r
216 the VariableName. The new registered boot#### or driver#### will be linked\r
217 to BdsOptionList and also update to the VariableName. After the boot#### or\r
218 driver#### updated, the BootOrder or DriverOrder will also be updated.\r
219\r
220 @param BdsOptionList The header of the boot#### or driver#### link list\r
221 @param DevicePath The device path which the boot#### or driver####\r
222 option present\r
223 @param String The description of the boot#### or driver####\r
224 @param VariableName Indicate if the boot#### or driver#### option\r
225\r
226 @retval EFI_SUCCESS The boot#### or driver#### have been success\r
227 registered\r
228 @retval EFI_STATUS Return the status of gRT->SetVariable ().\r
229\r
230**/\r
231EFI_STATUS\r
232EFIAPI\r
233BdsLibRegisterNewOption (\r
234 IN LIST_ENTRY *BdsOptionList,\r
235 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
236 IN CHAR16 *String,\r
237 IN CHAR16 *VariableName\r
238 )\r
239{\r
240 EFI_STATUS Status;\r
241 UINTN Index;\r
242 UINT16 RegisterOptionNumber;\r
243 UINT16 *TempOptionPtr;\r
244 UINTN TempOptionSize;\r
245 UINT16 *OptionOrderPtr;\r
246 VOID *OptionPtr;\r
247 UINTN OptionSize;\r
248 UINT8 *TempPtr;\r
249 EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath;\r
250 CHAR16 *Description;\r
251 CHAR16 OptionName[10];\r
252 BOOLEAN UpdateDescription;\r
253 UINT16 BootOrderEntry;\r
254 UINTN OrderItemNum;\r
255\r
256\r
257 OptionPtr = NULL;\r
258 OptionSize = 0;\r
259 TempPtr = NULL;\r
260 OptionDevicePath = NULL;\r
261 Description = NULL;\r
262 OptionOrderPtr = NULL;\r
263 UpdateDescription = FALSE;\r
ec8cd35c 264 Status = EFI_SUCCESS;\r
897f0eee 265 ZeroMem (OptionName, sizeof (OptionName));\r
266\r
267 TempOptionSize = 0;\r
268 TempOptionPtr = BdsLibGetVariableAndSize (\r
269 VariableName,\r
270 &gEfiGlobalVariableGuid,\r
271 &TempOptionSize\r
272 );\r
273\r
274 //\r
275 // Compare with current option variable\r
276 //\r
277 for (Index = 0; Index < TempOptionSize / sizeof (UINT16); Index++) {\r
278\r
279 if (*VariableName == 'B') {\r
280 UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", TempOptionPtr[Index]);\r
281 } else {\r
282 UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", TempOptionPtr[Index]);\r
283 }\r
284\r
285 OptionPtr = BdsLibGetVariableAndSize (\r
286 OptionName,\r
287 &gEfiGlobalVariableGuid,\r
288 &OptionSize\r
289 );\r
290 if (OptionPtr == NULL) {\r
291 continue;\r
292 }\r
ec8cd35c 293 TempPtr = OptionPtr;\r
294 TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
295 Description = (CHAR16 *) TempPtr;\r
296 TempPtr += StrSize ((CHAR16 *) TempPtr);\r
297 OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
897f0eee 298\r
299 //\r
300 // Notes: the description may will change base on the GetStringToken\r
301 //\r
302 if (CompareMem (OptionDevicePath, DevicePath, GetDevicePathSize (OptionDevicePath)) == 0) {\r
303 if (CompareMem (Description, String, StrSize (Description)) == 0) { \r
304 //\r
305 // Got the option, so just return\r
306 //\r
676df92c 307 FreePool (OptionPtr);\r
c473cc17 308 if (TempOptionPtr != NULL) {\r
309 FreePool (TempOptionPtr);\r
310 }\r
897f0eee 311 return EFI_SUCCESS;\r
312 } else {\r
313 //\r
314 // Option description changed, need update.\r
315 //\r
316 UpdateDescription = TRUE;\r
676df92c 317 FreePool (OptionPtr);\r
897f0eee 318 break;\r
319 }\r
320 }\r
321\r
676df92c 322 FreePool (OptionPtr);\r
897f0eee 323 }\r
324\r
325 OptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (String);\r
ec8cd35c 326 OptionSize += GetDevicePathSize (DevicePath);\r
897f0eee 327 OptionPtr = AllocateZeroPool (OptionSize);\r
676df92c 328 ASSERT (OptionPtr != NULL);\r
329 \r
897f0eee 330 TempPtr = OptionPtr;\r
331 *(UINT32 *) TempPtr = LOAD_OPTION_ACTIVE;\r
ec8cd35c 332 TempPtr += sizeof (UINT32);\r
897f0eee 333 *(UINT16 *) TempPtr = (UINT16) GetDevicePathSize (DevicePath);\r
ec8cd35c 334 TempPtr += sizeof (UINT16);\r
897f0eee 335 CopyMem (TempPtr, String, StrSize (String));\r
ec8cd35c 336 TempPtr += StrSize (String);\r
897f0eee 337 CopyMem (TempPtr, DevicePath, GetDevicePathSize (DevicePath));\r
338\r
339 if (UpdateDescription) {\r
340 //\r
341 // The number in option#### to be updated\r
342 //\r
343 RegisterOptionNumber = TempOptionPtr[Index];\r
344 } else {\r
345 //\r
346 // The new option#### number\r
347 //\r
348 RegisterOptionNumber = BdsLibGetFreeOptionNumber(VariableName);\r
349 }\r
350\r
351 if (*VariableName == 'B') {\r
352 UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", RegisterOptionNumber);\r
353 } else {\r
354 UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", RegisterOptionNumber);\r
355 }\r
356\r
357 Status = gRT->SetVariable (\r
358 OptionName,\r
359 &gEfiGlobalVariableGuid,\r
360 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
361 OptionSize,\r
362 OptionPtr\r
363 );\r
364 //\r
365 // Return if only need to update a changed description or fail to set option.\r
366 //\r
367 if (EFI_ERROR (Status) || UpdateDescription) {\r
676df92c 368 FreePool (OptionPtr);\r
c473cc17 369 if (TempOptionPtr != NULL) {\r
370 FreePool (TempOptionPtr);\r
371 }\r
897f0eee 372 return Status;\r
373 }\r
374\r
676df92c 375 FreePool (OptionPtr);\r
897f0eee 376\r
377 //\r
378 // Update the option order variable\r
379 //\r
380\r
381 //\r
382 // If no option order\r
383 //\r
384 if (TempOptionSize == 0) {\r
385 BootOrderEntry = 0;\r
386 Status = gRT->SetVariable (\r
387 VariableName,\r
388 &gEfiGlobalVariableGuid,\r
389 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
390 sizeof (UINT16),\r
391 &BootOrderEntry\r
392 );\r
c473cc17 393 if (TempOptionPtr != NULL) {\r
394 FreePool (TempOptionPtr);\r
395 }\r
ec8cd35c 396 return Status;\r
897f0eee 397 }\r
398\r
399 //\r
400 // Append the new option number to the original option order\r
401 //\r
402 OrderItemNum = (TempOptionSize / sizeof (UINT16)) + 1 ;\r
403 OptionOrderPtr = AllocateZeroPool ( OrderItemNum * sizeof (UINT16));\r
676df92c 404 ASSERT (OptionOrderPtr!= NULL);\r
405 \r
897f0eee 406 CopyMem (OptionOrderPtr, TempOptionPtr, (OrderItemNum - 1) * sizeof (UINT16));\r
407\r
408 OptionOrderPtr[Index] = RegisterOptionNumber;\r
409\r
410 Status = gRT->SetVariable (\r
411 VariableName,\r
412 &gEfiGlobalVariableGuid,\r
413 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
414 OrderItemNum * sizeof (UINT16),\r
415 OptionOrderPtr\r
416 );\r
676df92c 417 FreePool (TempOptionPtr);\r
418 FreePool (OptionOrderPtr);\r
897f0eee 419\r
ec8cd35c 420 return Status;\r
897f0eee 421}\r
422\r
423\r
424/**\r
425 Build the boot#### or driver#### option from the VariableName, the\r
11ef23f9 426 build boot#### or driver#### will also be linked to BdsCommonOptionList.\r
897f0eee 427\r
428 @param BdsCommonOptionList The header of the boot#### or driver#### option\r
429 link list\r
430 @param VariableName EFI Variable name indicate if it is boot#### or\r
431 driver####\r
432\r
433 @retval BDS_COMMON_OPTION Get the option just been created\r
434 @retval NULL Failed to get the new option\r
435\r
436**/\r
437BDS_COMMON_OPTION *\r
438EFIAPI\r
439BdsLibVariableToOption (\r
440 IN OUT LIST_ENTRY *BdsCommonOptionList,\r
441 IN CHAR16 *VariableName\r
442 )\r
443{\r
444 UINT32 Attribute;\r
445 UINT16 FilePathSize;\r
446 UINT8 *Variable;\r
447 UINT8 *TempPtr;\r
448 UINTN VariableSize;\r
449 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
450 BDS_COMMON_OPTION *Option;\r
451 VOID *LoadOptions;\r
452 UINT32 LoadOptionsSize;\r
453 CHAR16 *Description;\r
454 UINT8 NumOff;\r
455 //\r
456 // Read the variable. We will never free this data.\r
457 //\r
458 Variable = BdsLibGetVariableAndSize (\r
459 VariableName,\r
460 &gEfiGlobalVariableGuid,\r
461 &VariableSize\r
462 );\r
463 if (Variable == NULL) {\r
464 return NULL;\r
465 }\r
466 //\r
467 // Notes: careful defined the variable of Boot#### or\r
468 // Driver####, consider use some macro to abstract the code\r
469 //\r
470 //\r
471 // Get the option attribute\r
472 //\r
ec8cd35c 473 TempPtr = Variable;\r
474 Attribute = *(UINT32 *) Variable;\r
475 TempPtr += sizeof (UINT32);\r
897f0eee 476\r
477 //\r
478 // Get the option's device path size\r
479 //\r
ec8cd35c 480 FilePathSize = *(UINT16 *) TempPtr;\r
481 TempPtr += sizeof (UINT16);\r
897f0eee 482\r
483 //\r
484 // Get the option's description string\r
485 //\r
486 Description = (CHAR16 *) TempPtr;\r
487\r
488 //\r
489 // Get the option's description string size\r
490 //\r
ec8cd35c 491 TempPtr += StrSize ((CHAR16 *) TempPtr);\r
897f0eee 492\r
493 //\r
494 // Get the option's device path\r
495 //\r
ec8cd35c 496 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
497 TempPtr += FilePathSize;\r
897f0eee 498\r
499 LoadOptions = TempPtr;\r
500 LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));\r
501\r
502 //\r
503 // The Console variables may have multiple device paths, so make\r
504 // an Entry for each one.\r
505 //\r
506 Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
507 if (Option == NULL) {\r
508 return NULL;\r
509 }\r
510\r
511 Option->Signature = BDS_LOAD_OPTION_SIGNATURE;\r
512 Option->DevicePath = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
513 CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
514 Option->Attribute = Attribute;\r
515 Option->Description = AllocateZeroPool (StrSize (Description));\r
516 CopyMem (Option->Description, Description, StrSize (Description));\r
517 Option->LoadOptions = AllocateZeroPool (LoadOptionsSize);\r
518 CopyMem (Option->LoadOptions, LoadOptions, LoadOptionsSize);\r
519 Option->LoadOptionsSize = LoadOptionsSize;\r
520\r
521 //\r
522 // Get the value from VariableName Unicode string\r
523 // since the ISO standard assumes ASCII equivalent abbreviations, we can be safe in converting this\r
524 // Unicode stream to ASCII without any loss in meaning.\r
525 //\r
526 if (*VariableName == 'B') {\r
527 NumOff = sizeof (L"Boot")/sizeof(CHAR16) -1 ;\r
528 Option->BootCurrent = (UINT16) ((VariableName[NumOff] -'0') * 0x1000);\r
529 Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+1]-'0') * 0x100));\r
530 Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+2]-'0') * 0x10));\r
531 Option->BootCurrent = (UINT16) (Option->BootCurrent + ((VariableName[NumOff+3]-'0')));\r
532 }\r
533 //\r
534 // Insert active entry to BdsDeviceList\r
535 //\r
536 if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {\r
537 InsertTailList (BdsCommonOptionList, &Option->Link);\r
676df92c 538 FreePool (Variable);\r
897f0eee 539 return Option;\r
540 }\r
541\r
676df92c 542 FreePool (Variable);\r
543 FreePool (Option);\r
897f0eee 544 return NULL;\r
545\r
546}\r
547\r
897f0eee 548/**\r
549 Process BootOrder, or DriverOrder variables, by calling\r
550 BdsLibVariableToOption () for each UINT16 in the variables.\r
551\r
552 @param BdsCommonOptionList The header of the option list base on variable\r
553 VariableName\r
554 @param VariableName EFI Variable name indicate the BootOrder or\r
555 DriverOrder\r
556\r
557 @retval EFI_SUCCESS Success create the boot option or driver option\r
558 list\r
559 @retval EFI_OUT_OF_RESOURCES Failed to get the boot option or driver option list\r
560\r
561**/\r
562EFI_STATUS\r
563EFIAPI\r
564BdsLibBuildOptionFromVar (\r
565 IN LIST_ENTRY *BdsCommonOptionList,\r
566 IN CHAR16 *VariableName\r
567 )\r
568{\r
569 UINT16 *OptionOrder;\r
570 UINTN OptionOrderSize;\r
571 UINTN Index;\r
572 BDS_COMMON_OPTION *Option;\r
573 CHAR16 OptionName[20];\r
574\r
575 //\r
576 // Zero Buffer in order to get all BOOT#### variables\r
577 //\r
578 ZeroMem (OptionName, sizeof (OptionName));\r
579\r
580 //\r
581 // Read the BootOrder, or DriverOrder variable.\r
582 //\r
583 OptionOrder = BdsLibGetVariableAndSize (\r
584 VariableName,\r
585 &gEfiGlobalVariableGuid,\r
586 &OptionOrderSize\r
587 );\r
588 if (OptionOrder == NULL) {\r
589 return EFI_OUT_OF_RESOURCES;\r
590 }\r
591\r
592 for (Index = 0; Index < OptionOrderSize / sizeof (UINT16); Index++) {\r
593 if (*VariableName == 'B') {\r
594 UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", OptionOrder[Index]);\r
595 } else {\r
596 UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", OptionOrder[Index]);\r
597 }\r
598\r
599 Option = BdsLibVariableToOption (BdsCommonOptionList, OptionName);\r
600 Option->BootCurrent = OptionOrder[Index];\r
601\r
602 }\r
603\r
676df92c 604 FreePool (OptionOrder);\r
897f0eee 605\r
606 return EFI_SUCCESS;\r
607}\r
608\r
897f0eee 609/**\r
610 Get boot mode by looking up configuration table and parsing HOB list\r
611\r
612 @param BootMode Boot mode from PEI handoff HOB.\r
613\r
614 @retval EFI_SUCCESS Successfully get boot mode\r
615\r
616**/\r
617EFI_STATUS\r
618EFIAPI\r
619BdsLibGetBootMode (\r
620 OUT EFI_BOOT_MODE *BootMode\r
621 )\r
622{\r
623 *BootMode = GetBootModeHob ();\r
624\r
625 return EFI_SUCCESS;\r
626}\r
627\r
897f0eee 628/**\r
629 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
630 buffer, and the size of the buffer. If failure return NULL.\r
631\r
632 @param Name String part of EFI variable name\r
633 @param VendorGuid GUID part of EFI variable name\r
634 @param VariableSize Returns the size of the EFI variable that was read\r
635\r
636 @return Dynamically allocated memory that contains a copy of the EFI variable.\r
637 @return Caller is responsible freeing the buffer.\r
638 @retval NULL Variable was not read\r
639\r
640**/\r
641VOID *\r
642EFIAPI\r
643BdsLibGetVariableAndSize (\r
644 IN CHAR16 *Name,\r
645 IN EFI_GUID *VendorGuid,\r
646 OUT UINTN *VariableSize\r
647 )\r
648{\r
649 EFI_STATUS Status;\r
650 UINTN BufferSize;\r
651 VOID *Buffer;\r
652\r
653 Buffer = NULL;\r
654\r
655 //\r
656 // Pass in a zero size buffer to find the required buffer size.\r
657 //\r
658 BufferSize = 0;\r
659 Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
660 if (Status == EFI_BUFFER_TOO_SMALL) {\r
661 //\r
662 // Allocate the buffer to return\r
663 //\r
664 Buffer = AllocateZeroPool (BufferSize);\r
665 if (Buffer == NULL) {\r
666 return NULL;\r
667 }\r
668 //\r
669 // Read variable into the allocated buffer.\r
670 //\r
671 Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
672 if (EFI_ERROR (Status)) {\r
673 BufferSize = 0;\r
674 }\r
675 }\r
676\r
677 *VariableSize = BufferSize;\r
678 return Buffer;\r
679}\r
680\r
897f0eee 681/**\r
682 Delete the instance in Multi which matches partly with Single instance\r
683\r
684 @param Multi A pointer to a multi-instance device path data\r
685 structure.\r
686 @param Single A pointer to a single-instance device path data\r
687 structure.\r
688\r
689 @return This function will remove the device path instances in Multi which partly\r
690 match with the Single, and return the result device path. If there is no\r
691 remaining device path as a result, this function will return NULL.\r
692\r
693**/\r
694EFI_DEVICE_PATH_PROTOCOL *\r
695EFIAPI\r
696BdsLibDelPartMatchInstance (\r
697 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
698 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
699 )\r
700{\r
701 EFI_DEVICE_PATH_PROTOCOL *Instance;\r
702 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
703 EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;\r
704 UINTN InstanceSize;\r
705 UINTN SingleDpSize;\r
706 UINTN Size;\r
707\r
708 NewDevicePath = NULL;\r
709 TempNewDevicePath = NULL;\r
710\r
711 if (Multi == NULL || Single == NULL) {\r
712 return Multi;\r
713 }\r
714\r
715 Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);\r
716 SingleDpSize = GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;\r
717 InstanceSize -= END_DEVICE_PATH_LENGTH;\r
718\r
719 while (Instance != NULL) {\r
720\r
721 Size = (SingleDpSize < InstanceSize) ? SingleDpSize : InstanceSize;\r
722\r
723 if ((CompareMem (Instance, Single, Size) != 0)) {\r
724 //\r
725 // Append the device path instance which does not match with Single\r
726 //\r
727 TempNewDevicePath = NewDevicePath;\r
728 NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);\r
676df92c 729 if (TempNewDevicePath != NULL) {\r
730 FreePool(TempNewDevicePath);\r
731 }\r
897f0eee 732 }\r
676df92c 733 FreePool(Instance);\r
897f0eee 734 Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);\r
735 InstanceSize -= END_DEVICE_PATH_LENGTH;\r
736 }\r
737\r
738 return NewDevicePath;\r
739}\r
740\r
897f0eee 741/**\r
742 Function compares a device path data structure to that of all the nodes of a\r
743 second device path instance.\r
744\r
745 @param Multi A pointer to a multi-instance device path data\r
746 structure.\r
747 @param Single A pointer to a single-instance device path data\r
748 structure.\r
749\r
750 @retval TRUE If the Single is contained within Multi\r
751 @retval FALSE The Single is not match within Multi\r
752\r
753**/\r
754BOOLEAN\r
755EFIAPI\r
756BdsLibMatchDevicePaths (\r
757 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
758 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
759 )\r
760{\r
761 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
762 EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
763 UINTN Size;\r
764\r
11ef23f9 765 if (Multi != NULL || Single != NULL) {\r
897f0eee 766 return FALSE;\r
767 }\r
768\r
769 DevicePath = Multi;\r
770 DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
771\r
772 //\r
773 // Search for the match of 'Single' in 'Multi'\r
774 //\r
775 while (DevicePathInst != NULL) {\r
776 //\r
777 // If the single device path is found in multiple device paths,\r
778 // return success\r
779 //\r
780 if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
676df92c 781 FreePool (DevicePathInst);\r
897f0eee 782 return TRUE;\r
783 }\r
784\r
676df92c 785 FreePool (DevicePathInst);\r
897f0eee 786 DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
787 }\r
788\r
789 return FALSE;\r
790}\r
791\r
897f0eee 792/**\r
793 This function prints a series of strings.\r
794\r
795 @param ConOut Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL\r
796 @param ... A variable argument list containing series of\r
797 strings, the last string must be NULL.\r
798\r
799 @retval EFI_SUCCESS Success print out the string using ConOut.\r
800 @retval EFI_STATUS Return the status of the ConOut->OutputString ().\r
801\r
802**/\r
803EFI_STATUS\r
804EFIAPI\r
805BdsLibOutputStrings (\r
806 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,\r
807 ...\r
808 )\r
809{\r
11ef23f9 810 VA_LIST Args;\r
897f0eee 811 EFI_STATUS Status;\r
812 CHAR16 *String;\r
813\r
814 Status = EFI_SUCCESS;\r
11ef23f9 815 VA_START (Args, ConOut);\r
897f0eee 816\r
817 while (!EFI_ERROR (Status)) {\r
818 //\r
819 // If String is NULL, then it's the end of the list\r
820 //\r
11ef23f9 821 String = VA_ARG (Args, CHAR16 *);\r
822 if (String != NULL) {\r
897f0eee 823 break;\r
824 }\r
825\r
826 Status = ConOut->OutputString (ConOut, String);\r
827\r
828 if (EFI_ERROR (Status)) {\r
829 break;\r
830 }\r
831 }\r
832\r
833 return Status;\r
834}\r
835\r
836//\r
837// Following are BDS Lib functions which contain all the code about setup browser reset reminder feature.\r
838// Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser if\r
839// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.\r
840//\r
841\r
842\r
843/**\r
844 Enable the setup browser reset reminder feature.\r
845 This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
846\r
847**/\r
848VOID\r
849EFIAPI\r
850EnableResetReminderFeature (\r
851 VOID\r
852 )\r
853{\r
854 mFeaturerSwitch = TRUE;\r
855}\r
856\r
857\r
858/**\r
859 Disable the setup browser reset reminder feature.\r
860 This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
861\r
862**/\r
863VOID\r
864EFIAPI\r
865DisableResetReminderFeature (\r
866 VOID\r
867 )\r
868{\r
869 mFeaturerSwitch = FALSE;\r
870}\r
871\r
872\r
873/**\r
874 Record the info that a reset is required.\r
875 A module boolean variable is used to record whether a reset is required.\r
876\r
877**/\r
878VOID\r
879EFIAPI\r
880EnableResetRequired (\r
881 VOID\r
882 )\r
883{\r
884 mResetRequired = TRUE;\r
885}\r
886\r
887\r
888/**\r
889 Record the info that no reset is required.\r
890 A module boolean variable is used to record whether a reset is required.\r
891\r
892**/\r
893VOID\r
894EFIAPI\r
895DisableResetRequired (\r
896 VOID\r
897 )\r
898{\r
899 mResetRequired = FALSE;\r
900}\r
901\r
902\r
903/**\r
904 Check whether platform policy enable the reset reminder feature. The default is enabled.\r
905\r
906**/\r
907BOOLEAN\r
908EFIAPI\r
909IsResetReminderFeatureEnable (\r
910 VOID\r
911 )\r
912{\r
913 return mFeaturerSwitch;\r
914}\r
915\r
916\r
917/**\r
918 Check if user changed any option setting which needs a system reset to be effective.\r
919\r
920**/\r
921BOOLEAN\r
922EFIAPI\r
923IsResetRequired (\r
924 VOID\r
925 )\r
926{\r
927 return mResetRequired;\r
928}\r
929\r
930\r
931/**\r
932 Check whether a reset is needed, and finish the reset reminder feature.\r
933 If a reset is needed, Popup a menu to notice user, and finish the feature\r
934 according to the user selection.\r
935\r
936**/\r
937VOID\r
938EFIAPI\r
939SetupResetReminder (\r
940 VOID\r
941 )\r
942{\r
943 EFI_INPUT_KEY Key;\r
944 CHAR16 *StringBuffer1;\r
945 CHAR16 *StringBuffer2;\r
946\r
947\r
948 //\r
949 //check any reset required change is applied? if yes, reset system\r
950 //\r
951 if (IsResetReminderFeatureEnable ()) {\r
952 if (IsResetRequired ()) {\r
953\r
954 StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
955 ASSERT (StringBuffer1 != NULL);\r
956 StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
957 ASSERT (StringBuffer2 != NULL);\r
958 StrCpy (StringBuffer1, L"Configuration changed. Reset to apply it Now ? ");\r
959 StrCpy (StringBuffer2, L"Enter (YES) / Esc (NO)");\r
960 //\r
961 // Popup a menu to notice user\r
962 //\r
963 do {\r
964 IfrLibCreatePopUp (2, &Key, StringBuffer1, StringBuffer2);\r
965 } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
966\r
676df92c 967 FreePool (StringBuffer1);\r
968 FreePool (StringBuffer2);\r
897f0eee 969 //\r
970 // If the user hits the YES Response key, reset\r
971 //\r
972 if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {\r
973 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
974 }\r
975 gST->ConOut->ClearScreen (gST->ConOut);\r
976 }\r
977 }\r
978}\r
979\r
897f0eee 980/**\r
11ef23f9 981 Get the headers (dos, image, optional header) from an image.\r
897f0eee 982\r
983 @param Device SimpleFileSystem device handle\r
984 @param FileName File name for the image\r
985 @param DosHeader Pointer to dos header\r
11ef23f9 986 @param Hdr Pointer to optional header\r
897f0eee 987\r
988 @retval EFI_SUCCESS Successfully get the machine type.\r
989 @retval EFI_NOT_FOUND The file is not found.\r
990 @retval EFI_LOAD_ERROR File is not a valid image file.\r
991\r
992**/\r
993EFI_STATUS\r
994EFIAPI\r
995BdsLibGetImageHeader (\r
996 IN EFI_HANDLE Device,\r
997 IN CHAR16 *FileName,\r
998 OUT EFI_IMAGE_DOS_HEADER *DosHeader,\r
999 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
1000 )\r
1001{\r
1002 EFI_STATUS Status;\r
1003 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
1004 EFI_FILE_HANDLE Root;\r
1005 EFI_FILE_HANDLE ThisFile;\r
1006 UINTN BufferSize;\r
1007 UINT64 FileSize;\r
1008 EFI_FILE_INFO *Info;\r
1009\r
1010 Root = NULL;\r
1011 ThisFile = NULL;\r
1012 //\r
1013 // Handle the file system interface to the device\r
1014 //\r
1015 Status = gBS->HandleProtocol (\r
1016 Device,\r
1017 &gEfiSimpleFileSystemProtocolGuid,\r
1018 (VOID *) &Volume\r
1019 );\r
1020 if (EFI_ERROR (Status)) {\r
1021 goto Done;\r
1022 }\r
1023\r
1024 Status = Volume->OpenVolume (\r
1025 Volume,\r
1026 &Root\r
1027 );\r
1028 if (EFI_ERROR (Status)) {\r
676df92c 1029 Root = NULL;\r
897f0eee 1030 goto Done;\r
1031 }\r
1032\r
1033 Status = Root->Open (Root, &ThisFile, FileName, EFI_FILE_MODE_READ, 0);\r
1034 if (EFI_ERROR (Status)) {\r
1035 goto Done;\r
1036 }\r
1037\r
1038 //\r
1039 // Get file size\r
1040 //\r
1041 BufferSize = SIZE_OF_EFI_FILE_INFO + 200;\r
1042 do {\r
1043 Info = NULL;\r
1044 Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, (VOID **) &Info);\r
1045 if (EFI_ERROR (Status)) {\r
1046 goto Done;\r
1047 }\r
1048 Status = ThisFile->GetInfo (\r
1049 ThisFile,\r
1050 &gEfiFileInfoGuid,\r
1051 &BufferSize,\r
1052 Info\r
1053 );\r
1054 if (!EFI_ERROR (Status)) {\r
1055 break;\r
1056 }\r
1057 if (Status != EFI_BUFFER_TOO_SMALL) {\r
676df92c 1058 FreePool (Info);\r
897f0eee 1059 goto Done;\r
1060 }\r
676df92c 1061 FreePool (Info);\r
897f0eee 1062 } while (TRUE);\r
1063\r
1064 FileSize = Info->FileSize;\r
676df92c 1065 FreePool (Info);\r
897f0eee 1066\r
1067 //\r
1068 // Read dos header\r
1069 //\r
1070 BufferSize = sizeof (EFI_IMAGE_DOS_HEADER);\r
1071 Status = ThisFile->Read (ThisFile, &BufferSize, DosHeader);\r
1072 if (EFI_ERROR (Status) ||\r
1073 BufferSize < sizeof (EFI_IMAGE_DOS_HEADER) ||\r
1074 FileSize <= DosHeader->e_lfanew ||\r
1075 DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
1076 Status = EFI_LOAD_ERROR;\r
1077 goto Done;\r
1078 }\r
1079\r
1080 //\r
1081 // Move to PE signature\r
1082 //\r
1083 Status = ThisFile->SetPosition (ThisFile, DosHeader->e_lfanew);\r
1084 if (EFI_ERROR (Status)) {\r
1085 Status = EFI_LOAD_ERROR;\r
1086 goto Done;\r
1087 }\r
1088\r
1089 //\r
1090 // Read and check PE signature\r
1091 //\r
1092 BufferSize = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);\r
1093 Status = ThisFile->Read (ThisFile, &BufferSize, Hdr.Pe32);\r
1094 if (EFI_ERROR (Status) ||\r
1095 BufferSize < sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION) ||\r
1096 Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
1097 Status = EFI_LOAD_ERROR;\r
1098 goto Done;\r
1099 }\r
1100\r
1101 //\r
1102 // Check PE32 or PE32+ magic\r
1103 //\r
1104 if (Hdr.Pe32->OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC &&\r
1105 Hdr.Pe32->OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
1106 Status = EFI_LOAD_ERROR;\r
1107 goto Done;\r
1108 }\r
1109\r
1110 Done:\r
1111 if (ThisFile != NULL) {\r
1112 ThisFile->Close (ThisFile);\r
1113 }\r
1114 if (Root != NULL) {\r
1115 Root->Close (Root);\r
1116 }\r
1117 return Status;\r
1118}\r
1119\r
11ef23f9 1120/**\r
897f0eee 1121\r
1122 This routine is a notification function for legayc boot or exit boot\r
1123 service event. It will adjust the memory information for different\r
11ef23f9 1124 memory type and save them into the variables for next boot.\r
897f0eee 1125\r
897f0eee 1126\r
11ef23f9 1127 @param Event The event that triggered this notification function.\r
1128 @param Context Pointer to the notification functions context.\r
897f0eee 1129\r
11ef23f9 1130**/\r
1131VOID\r
1132EFIAPI\r
1133BdsSetMemoryTypeInformationVariable (\r
1134 EFI_EVENT Event,\r
1135 VOID *Context\r
1136 )\r
897f0eee 1137{\r
1138 EFI_STATUS Status;\r
1139 EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation;\r
1140 EFI_MEMORY_TYPE_INFORMATION *CurrentMemoryTypeInformation;\r
1141 UINTN VariableSize;\r
1142 BOOLEAN UpdateRequired;\r
1143 UINTN Index;\r
1144 UINTN Index1;\r
1145 UINT32 Previous;\r
1146 UINT32 Current;\r
1147 UINT32 Next;\r
1148 EFI_HOB_GUID_TYPE *GuidHob;\r
1149\r
1150 UpdateRequired = FALSE;\r
1151\r
1152 //\r
1153 // Retrieve the current memory usage statistics. If they are not found, then\r
1154 // no adjustments can be made to the Memory Type Information variable.\r
1155 //\r
1156 Status = EfiGetSystemConfigurationTable (\r
1157 &gEfiMemoryTypeInformationGuid,\r
1158 (VOID **) &CurrentMemoryTypeInformation\r
1159 );\r
1160 if (EFI_ERROR (Status)) {\r
1161 return;\r
1162 }\r
1163\r
1164 //\r
1165 // Get the Memory Type Information settings from Hob if they exist,\r
1166 // PEI is responsible for getting them from variable and build a Hob to save them.\r
1167 // If the previous Memory Type Information is not available, then set defaults\r
1168 //\r
1169 GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);\r
1170 if (GuidHob == NULL) {\r
1171 //\r
1172 // If Platform has not built Memory Type Info into the Hob, just return.\r
1173 //\r
1174 return;\r
1175 }\r
1176 PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);\r
1177 VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
1178\r
1179 //\r
1180 // Use a heuristic to adjust the Memory Type Information for the next boot\r
1181 //\r
1182 for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {\r
1183\r
1184 Current = 0;\r
1185 for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {\r
1186 if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {\r
1187 Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;\r
1188 break;\r
1189 }\r
1190 }\r
1191\r
1192 if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {\r
1193 continue;\r
1194 }\r
1195\r
1196 Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;\r
1197\r
1198 //\r
1199 // Write next varible to 125% * current and Inconsistent Memory Reserved across bootings may lead to S4 fail\r
1200 //\r
1201 if (Current > Previous) {\r
1202 Next = Current + (Current >> 2);\r
1203 } else {\r
1204 Next = Previous;\r
1205 }\r
1206 if (Next > 0 && Next < 4) {\r
1207 Next = 4;\r
1208 }\r
1209\r
1210 if (Next != Previous) {\r
1211 PreviousMemoryTypeInformation[Index].NumberOfPages = Next;\r
1212 UpdateRequired = TRUE;\r
1213 }\r
1214\r
1215 }\r
1216\r
1217 //\r
1218 // If any changes were made to the Memory Type Information settings, then set the new variable value\r
1219 //\r
1220 if (UpdateRequired) {\r
1221 Status = gRT->SetVariable (\r
1222 EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
1223 &gEfiMemoryTypeInformationGuid,\r
1224 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
1225 VariableSize,\r
1226 PreviousMemoryTypeInformation\r
1227 );\r
1228 }\r
1229\r
1230 return;\r
1231}\r
1232\r
897f0eee 1233/**\r
1234 This routine register a function to adjust the different type memory page number just before booting\r
11ef23f9 1235 and save the updated info into the variable for next boot to use.\r
897f0eee 1236\r
1237**/\r
1238VOID\r
1239EFIAPI\r
1240BdsLibSaveMemoryTypeInformation (\r
1241 VOID\r
1242 )\r
1243{\r
1244 EFI_STATUS Status;\r
1245 EFI_EVENT ReadyToBootEvent;\r
1246\r
1247 Status = EfiCreateEventReadyToBootEx (\r
1248 TPL_CALLBACK,\r
1249 BdsSetMemoryTypeInformationVariable,\r
1250 NULL,\r
1251 &ReadyToBootEvent\r
1252 );\r
1253 if (EFI_ERROR (Status)) {\r
1254 DEBUG ((DEBUG_ERROR,"Bds Set Memory Type Informationa Variable Fails\n"));\r
1255 }\r
1256\r
1257}\r
1258\r
1259\r