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