]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/BdsDxe/BdsEntry.c
MdeModulePkg/UefiBootManagerLib: Refine the debug message
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BdsEntry.c
... / ...
CommitLineData
1/** @file\r
2 This module produce main entry for BDS phase - BdsEntry.\r
3 When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed\r
4 which contains interface of BdsEntry.\r
5 After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r
6 to enter BDS phase.\r
7\r
8Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
9(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
10(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
11This program and the accompanying materials\r
12are licensed and made available under the terms and conditions of the BSD License\r
13which accompanies this distribution. The full text of the license may be found at\r
14http://opensource.org/licenses/bsd-license.php\r
15\r
16THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
17WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18\r
19**/\r
20\r
21#include "Bds.h"\r
22#include "Language.h"\r
23#include "HwErrRecSupport.h"\r
24\r
25#define SET_BOOT_OPTION_SUPPORT_KEY_COUNT(a, c) { \\r
26 (a) = ((a) & ~EFI_BOOT_OPTION_SUPPORT_COUNT) | (((c) << LowBitSet32 (EFI_BOOT_OPTION_SUPPORT_COUNT)) & EFI_BOOT_OPTION_SUPPORT_COUNT); \\r
27 }\r
28\r
29///\r
30/// BDS arch protocol instance initial value.\r
31///\r
32EFI_BDS_ARCH_PROTOCOL gBds = {\r
33 BdsEntry\r
34};\r
35\r
36//\r
37// gConnectConInEvent - Event which is signaled when ConIn connection is required\r
38//\r
39EFI_EVENT gConnectConInEvent = NULL;\r
40\r
41///\r
42/// The read-only variables defined in UEFI Spec.\r
43///\r
44CHAR16 *mReadOnlyVariables[] = {\r
45 EFI_PLATFORM_LANG_CODES_VARIABLE_NAME,\r
46 EFI_LANG_CODES_VARIABLE_NAME,\r
47 EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME,\r
48 EFI_HW_ERR_REC_SUPPORT_VARIABLE_NAME,\r
49 EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME\r
50 };\r
51\r
52CHAR16 *mBdsLoadOptionName[] = {\r
53 L"Driver",\r
54 L"SysPrep",\r
55 L"Boot",\r
56 L"PlatformRecovery"\r
57};\r
58\r
59/**\r
60 Event to Connect ConIn.\r
61\r
62 @param Event Event whose notification function is being invoked.\r
63 @param Context Pointer to the notification function's context,\r
64 which is implementation-dependent.\r
65\r
66**/\r
67VOID\r
68EFIAPI\r
69BdsDxeOnConnectConInCallBack (\r
70 IN EFI_EVENT Event,\r
71 IN VOID *Context\r
72 )\r
73{\r
74 EFI_STATUS Status;\r
75\r
76 //\r
77 // When Osloader call ReadKeyStroke to signal this event\r
78 // no driver dependency is assumed existing. So use a non-dispatch version\r
79 //\r
80 Status = EfiBootManagerConnectConsoleVariable (ConIn);\r
81 if (EFI_ERROR (Status)) {\r
82 //\r
83 // Should not enter this case, if enter, the keyboard will not work.\r
84 // May need platfrom policy to connect keyboard.\r
85 //\r
86 DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));\r
87 }\r
88}\r
89/**\r
90 Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to\r
91 check whether there is remaining deferred load images.\r
92\r
93 @param[in] Event The Event that is being processed.\r
94 @param[in] Context The Event Context.\r
95\r
96**/\r
97VOID\r
98EFIAPI\r
99CheckDeferredLoadImageOnReadyToBoot (\r
100 IN EFI_EVENT Event,\r
101 IN VOID *Context\r
102 )\r
103{\r
104 EFI_STATUS Status;\r
105 EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;\r
106 UINTN HandleCount;\r
107 EFI_HANDLE *Handles;\r
108 UINTN Index;\r
109 UINTN ImageIndex;\r
110 EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;\r
111 VOID *Image;\r
112 UINTN ImageSize;\r
113 BOOLEAN BootOption;\r
114 CHAR16 *DevicePathStr;\r
115\r
116 //\r
117 // Find all the deferred image load protocols.\r
118 //\r
119 HandleCount = 0;\r
120 Handles = NULL;\r
121 Status = gBS->LocateHandleBuffer (\r
122 ByProtocol,\r
123 &gEfiDeferredImageLoadProtocolGuid,\r
124 NULL,\r
125 &HandleCount,\r
126 &Handles\r
127 );\r
128 if (EFI_ERROR (Status)) {\r
129 return;\r
130 }\r
131\r
132 for (Index = 0; Index < HandleCount; Index++) {\r
133 Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);\r
134 if (EFI_ERROR (Status)) {\r
135 continue;\r
136 }\r
137\r
138 for (ImageIndex = 0; ; ImageIndex++) {\r
139 //\r
140 // Load all the deferred images in this protocol instance.\r
141 //\r
142 Status = DeferredImage->GetImageInfo (\r
143 DeferredImage,\r
144 ImageIndex,\r
145 &ImageDevicePath,\r
146 (VOID **) &Image,\r
147 &ImageSize,\r
148 &BootOption\r
149 );\r
150 if (EFI_ERROR (Status)) {\r
151 break;\r
152 }\r
153 DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE, FALSE);\r
154 DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n", DevicePathStr));\r
155 if (DevicePathStr != NULL) {\r
156 FreePool (DevicePathStr);\r
157 }\r
158 }\r
159 }\r
160 if (Handles != NULL) {\r
161 FreePool (Handles);\r
162 }\r
163}\r
164\r
165/**\r
166\r
167 Install Boot Device Selection Protocol\r
168\r
169 @param ImageHandle The image handle.\r
170 @param SystemTable The system table.\r
171\r
172 @retval EFI_SUCEESS BDS has finished initializing.\r
173 Return the dispatcher and recall BDS.Entry\r
174 @retval Other Return status from AllocatePool() or gBS->InstallProtocolInterface\r
175\r
176**/\r
177EFI_STATUS\r
178EFIAPI\r
179BdsInitialize (\r
180 IN EFI_HANDLE ImageHandle,\r
181 IN EFI_SYSTEM_TABLE *SystemTable\r
182 )\r
183{\r
184 EFI_STATUS Status;\r
185 EFI_HANDLE Handle;\r
186 //\r
187 // Install protocol interface\r
188 //\r
189 Handle = NULL;\r
190 Status = gBS->InstallMultipleProtocolInterfaces (\r
191 &Handle,\r
192 &gEfiBdsArchProtocolGuid, &gBds,\r
193 NULL\r
194 );\r
195 ASSERT_EFI_ERROR (Status);\r
196\r
197 DEBUG_CODE (\r
198 EFI_EVENT Event;\r
199 //\r
200 // Register notify function to check deferred images on ReadyToBoot Event.\r
201 //\r
202 Status = gBS->CreateEventEx (\r
203 EVT_NOTIFY_SIGNAL,\r
204 TPL_CALLBACK,\r
205 CheckDeferredLoadImageOnReadyToBoot,\r
206 NULL,\r
207 &gEfiEventReadyToBootGuid,\r
208 &Event\r
209 );\r
210 ASSERT_EFI_ERROR (Status);\r
211 );\r
212 return Status;\r
213}\r
214\r
215/**\r
216 Function waits for a given event to fire, or for an optional timeout to expire.\r
217\r
218 @param Event The event to wait for\r
219 @param Timeout An optional timeout value in 100 ns units.\r
220\r
221 @retval EFI_SUCCESS Event fired before Timeout expired.\r
222 @retval EFI_TIME_OUT Timout expired before Event fired..\r
223\r
224**/\r
225EFI_STATUS\r
226BdsWaitForSingleEvent (\r
227 IN EFI_EVENT Event,\r
228 IN UINT64 Timeout OPTIONAL\r
229 )\r
230{\r
231 UINTN Index;\r
232 EFI_STATUS Status;\r
233 EFI_EVENT TimerEvent;\r
234 EFI_EVENT WaitList[2];\r
235\r
236 if (Timeout != 0) {\r
237 //\r
238 // Create a timer event\r
239 //\r
240 Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
241 if (!EFI_ERROR (Status)) {\r
242 //\r
243 // Set the timer event\r
244 //\r
245 gBS->SetTimer (\r
246 TimerEvent,\r
247 TimerRelative,\r
248 Timeout\r
249 );\r
250\r
251 //\r
252 // Wait for the original event or the timer\r
253 //\r
254 WaitList[0] = Event;\r
255 WaitList[1] = TimerEvent;\r
256 Status = gBS->WaitForEvent (2, WaitList, &Index);\r
257 ASSERT_EFI_ERROR (Status);\r
258 gBS->CloseEvent (TimerEvent);\r
259\r
260 //\r
261 // If the timer expired, change the return to timed out\r
262 //\r
263 if (Index == 1) {\r
264 Status = EFI_TIMEOUT;\r
265 }\r
266 }\r
267 } else {\r
268 //\r
269 // No timeout... just wait on the event\r
270 //\r
271 Status = gBS->WaitForEvent (1, &Event, &Index);\r
272 ASSERT (!EFI_ERROR (Status));\r
273 ASSERT (Index == 0);\r
274 }\r
275\r
276 return Status;\r
277}\r
278\r
279/**\r
280 The function reads user inputs.\r
281\r
282**/\r
283VOID\r
284BdsReadKeys (\r
285 VOID\r
286 )\r
287{\r
288 EFI_STATUS Status;\r
289 EFI_INPUT_KEY Key;\r
290\r
291 if (PcdGetBool (PcdConInConnectOnDemand)) {\r
292 return;\r
293 }\r
294\r
295 while (gST->ConIn != NULL) {\r
296 \r
297 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
298 \r
299 if (EFI_ERROR (Status)) {\r
300 //\r
301 // No more keys.\r
302 //\r
303 break;\r
304 }\r
305 }\r
306}\r
307\r
308/**\r
309 The function waits for the boot manager timeout expires or hotkey is pressed.\r
310\r
311 It calls PlatformBootManagerWaitCallback each second.\r
312\r
313 @param HotkeyTriggered Input hotkey event.\r
314**/\r
315VOID\r
316BdsWait (\r
317 IN EFI_EVENT HotkeyTriggered\r
318 )\r
319{\r
320 EFI_STATUS Status;\r
321 UINT16 TimeoutRemain;\r
322\r
323 DEBUG ((EFI_D_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n"));\r
324\r
325 TimeoutRemain = PcdGet16 (PcdPlatformBootTimeOut);\r
326 while (TimeoutRemain != 0) {\r
327 DEBUG ((EFI_D_INFO, "[Bds]BdsWait(%d)..Zzzz...\n", (UINTN) TimeoutRemain));\r
328 PlatformBootManagerWaitCallback (TimeoutRemain);\r
329\r
330 BdsReadKeys (); // BUGBUG: Only reading can signal HotkeyTriggered\r
331 // Can be removed after all keyboard drivers invoke callback in timer callback.\r
332\r
333 if (HotkeyTriggered != NULL) {\r
334 Status = BdsWaitForSingleEvent (HotkeyTriggered, EFI_TIMER_PERIOD_SECONDS (1));\r
335 if (!EFI_ERROR (Status)) {\r
336 break;\r
337 }\r
338 } else {\r
339 gBS->Stall (1000000);\r
340 }\r
341\r
342 //\r
343 // 0xffff means waiting forever\r
344 // BDS with no hotkey provided and 0xffff as timeout will "hang" in the loop\r
345 //\r
346 if (TimeoutRemain != 0xffff) {\r
347 TimeoutRemain--;\r
348 }\r
349 }\r
350 DEBUG ((EFI_D_INFO, "[Bds]Exit the waiting!\n"));\r
351}\r
352\r
353/**\r
354 Attempt to boot each boot option in the BootOptions array.\r
355\r
356 @param BootOptions Input boot option array.\r
357 @param BootOptionCount Input boot option count.\r
358 @param BootManagerMenu Input boot manager menu.\r
359\r
360 @retval TRUE Successfully boot one of the boot options.\r
361 @retval FALSE Failed boot any of the boot options.\r
362**/\r
363BOOLEAN\r
364BootBootOptions (\r
365 IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,\r
366 IN UINTN BootOptionCount,\r
367 IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu OPTIONAL\r
368 )\r
369{\r
370 UINTN Index;\r
371\r
372 //\r
373 // Attempt boot each boot option\r
374 //\r
375 for (Index = 0; Index < BootOptionCount; Index++) {\r
376 //\r
377 // According to EFI Specification, if a load option is not marked\r
378 // as LOAD_OPTION_ACTIVE, the boot manager will not automatically\r
379 // load the option.\r
380 //\r
381 if ((BootOptions[Index].Attributes & LOAD_OPTION_ACTIVE) == 0) {\r
382 continue;\r
383 }\r
384\r
385 //\r
386 // Boot#### load options with LOAD_OPTION_CATEGORY_APP are executables which are not\r
387 // part of the normal boot processing. Boot options with reserved category values will be\r
388 // ignored by the boot manager.\r
389 //\r
390 if ((BootOptions[Index].Attributes & LOAD_OPTION_CATEGORY) != LOAD_OPTION_CATEGORY_BOOT) {\r
391 continue;\r
392 }\r
393\r
394 //\r
395 // All the driver options should have been processed since\r
396 // now boot will be performed.\r
397 //\r
398 EfiBootManagerBoot (&BootOptions[Index]);\r
399\r
400 //\r
401 // If the boot via Boot#### returns with a status of EFI_SUCCESS, platform firmware\r
402 // supports boot manager menu, and if firmware is configured to boot in an\r
403 // interactive mode, the boot manager will stop processing the BootOrder variable and\r
404 // present a boot manager menu to the user.\r
405 //\r
406 if ((BootManagerMenu != NULL) && (BootOptions[Index].Status == EFI_SUCCESS)) {\r
407 EfiBootManagerBoot (BootManagerMenu);\r
408 break;\r
409 }\r
410 }\r
411\r
412 return (BOOLEAN) (Index < BootOptionCount);\r
413}\r
414\r
415/**\r
416 The function will load and start every Driver####, SysPrep#### or PlatformRecovery####.\r
417\r
418 @param LoadOptions Load option array.\r
419 @param LoadOptionCount Load option count.\r
420**/\r
421VOID\r
422ProcessLoadOptions (\r
423 IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions,\r
424 IN UINTN LoadOptionCount\r
425 )\r
426{\r
427 EFI_STATUS Status;\r
428 UINTN Index;\r
429 BOOLEAN ReconnectAll;\r
430 EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType;\r
431\r
432 ReconnectAll = FALSE;\r
433 LoadOptionType = LoadOptionTypeMax;\r
434\r
435 //\r
436 // Process the driver option\r
437 //\r
438 for (Index = 0; Index < LoadOptionCount; Index++) {\r
439 //\r
440 // All the load options in the array should be of the same type.\r
441 //\r
442 if (Index == 0) {\r
443 LoadOptionType = LoadOptions[Index].OptionType;\r
444 }\r
445 ASSERT (LoadOptionType == LoadOptions[Index].OptionType);\r
446\r
447 Status = EfiBootManagerProcessLoadOption (&LoadOptions[Index]);\r
448\r
449 if (!EFI_ERROR (Status)) {\r
450 if (LoadOptionType == LoadOptionTypePlatformRecovery) {\r
451 //\r
452 // Stop processing if any entry is successful\r
453 //\r
454 break;\r
455 }\r
456 if ((LoadOptions[Index].Attributes & LOAD_OPTION_FORCE_RECONNECT) != 0) {\r
457 ReconnectAll = TRUE;\r
458 }\r
459 }\r
460 }\r
461\r
462 //\r
463 // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
464 // then all of the EFI drivers in the system will be disconnected and\r
465 // reconnected after the last driver load option is processed.\r
466 //\r
467 if (ReconnectAll && LoadOptionType == LoadOptionTypeDriver) {\r
468 EfiBootManagerDisconnectAll ();\r
469 EfiBootManagerConnectAll ();\r
470 }\r
471}\r
472\r
473/**\r
474\r
475 Validate input console variable data. \r
476\r
477 If found the device path is not a valid device path, remove the variable.\r
478 \r
479 @param VariableName Input console variable name.\r
480\r
481**/\r
482VOID\r
483BdsFormalizeConsoleVariable (\r
484 IN CHAR16 *VariableName\r
485 )\r
486{\r
487 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
488 UINTN VariableSize;\r
489 EFI_STATUS Status;\r
490\r
491 GetEfiGlobalVariable2 (VariableName, (VOID **) &DevicePath, &VariableSize);\r
492 if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) { \r
493 Status = gRT->SetVariable (\r
494 VariableName,\r
495 &gEfiGlobalVariableGuid,\r
496 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
497 0,\r
498 NULL\r
499 );\r
500 //\r
501 // Deleting variable with current variable implementation shouldn't fail.\r
502 //\r
503 ASSERT_EFI_ERROR (Status);\r
504 }\r
505\r
506 if (DevicePath != NULL) {\r
507 FreePool (DevicePath);\r
508 }\r
509}\r
510\r
511/**\r
512 Formalize OsIndication related variables. \r
513 \r
514 For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps \r
515 Delete OsIndications variable if it is not NV/BS/RT UINT64.\r
516 \r
517 Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.\r
518\r
519 Create a boot option for BootManagerMenu if it hasn't been created yet\r
520\r
521**/\r
522VOID \r
523BdsFormalizeOSIndicationVariable (\r
524 VOID\r
525 )\r
526{\r
527 EFI_STATUS Status;\r
528 UINT64 OsIndicationSupport;\r
529 UINT64 OsIndication;\r
530 UINTN DataSize;\r
531 UINT32 Attributes;\r
532 EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;\r
533\r
534 //\r
535 // OS indicater support variable\r
536 //\r
537 Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);\r
538 if (Status != EFI_NOT_FOUND) {\r
539 OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;\r
540 EfiBootManagerFreeLoadOption (&BootManagerMenu);\r
541 } else {\r
542 OsIndicationSupport = EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;\r
543 }\r
544\r
545 Status = gRT->SetVariable (\r
546 EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME,\r
547 &gEfiGlobalVariableGuid,\r
548 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
549 sizeof(UINT64),\r
550 &OsIndicationSupport\r
551 );\r
552 //\r
553 // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
554 //\r
555 ASSERT_EFI_ERROR (Status);\r
556\r
557 //\r
558 // If OsIndications is invalid, remove it.\r
559 // Invalid case\r
560 // 1. Data size != UINT64\r
561 // 2. OsIndication value inconsistence\r
562 // 3. OsIndication attribute inconsistence\r
563 //\r
564 OsIndication = 0;\r
565 Attributes = 0;\r
566 DataSize = sizeof(UINT64);\r
567 Status = gRT->GetVariable (\r
568 EFI_OS_INDICATIONS_VARIABLE_NAME,\r
569 &gEfiGlobalVariableGuid,\r
570 &Attributes,\r
571 &DataSize,\r
572 &OsIndication\r
573 );\r
574 if (Status == EFI_NOT_FOUND) {\r
575 return;\r
576 }\r
577\r
578 if ((DataSize != sizeof (OsIndication)) ||\r
579 ((OsIndication & ~OsIndicationSupport) != 0) ||\r
580 (Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE))\r
581 ){\r
582\r
583 DEBUG ((EFI_D_ERROR, "[Bds] Unformalized OsIndications variable exists. Delete it\n"));\r
584 Status = gRT->SetVariable (\r
585 EFI_OS_INDICATIONS_VARIABLE_NAME,\r
586 &gEfiGlobalVariableGuid,\r
587 0,\r
588 0,\r
589 NULL\r
590 );\r
591 //\r
592 // Deleting variable with current variable implementation shouldn't fail.\r
593 //\r
594 ASSERT_EFI_ERROR(Status);\r
595 }\r
596}\r
597\r
598/**\r
599\r
600 Validate variables. \r
601\r
602**/\r
603VOID \r
604BdsFormalizeEfiGlobalVariable (\r
605 VOID\r
606 )\r
607{\r
608 //\r
609 // Validate Console variable.\r
610 //\r
611 BdsFormalizeConsoleVariable (EFI_CON_IN_VARIABLE_NAME);\r
612 BdsFormalizeConsoleVariable (EFI_CON_OUT_VARIABLE_NAME);\r
613 BdsFormalizeConsoleVariable (EFI_ERR_OUT_VARIABLE_NAME);\r
614\r
615 //\r
616 // Validate OSIndication related variable.\r
617 //\r
618 BdsFormalizeOSIndicationVariable ();\r
619}\r
620\r
621/**\r
622\r
623 Allocate a block of memory that will contain performance data to OS.\r
624\r
625**/\r
626VOID\r
627BdsAllocateMemoryForPerformanceData (\r
628 VOID\r
629 )\r
630{\r
631 EFI_STATUS Status;\r
632 EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;\r
633 EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;\r
634\r
635 AcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
636\r
637 //\r
638 // Allocate a block of memory that will contain performance data to OS.\r
639 //\r
640 Status = gBS->AllocatePages (\r
641 AllocateMaxAddress,\r
642 EfiReservedMemoryType,\r
643 EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH),\r
644 &AcpiLowMemoryBase\r
645 );\r
646 if (!EFI_ERROR (Status)) {\r
647 //\r
648 // Save the pointer to variable for use in S3 resume.\r
649 //\r
650 Status = BdsDxeSetVariableAndReportStatusCodeOnError (\r
651 L"PerfDataMemAddr",\r
652 &gPerformanceProtocolGuid,\r
653 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
654 sizeof (EFI_PHYSICAL_ADDRESS),\r
655 &AcpiLowMemoryBase\r
656 );\r
657 if (EFI_ERROR (Status)) {\r
658 DEBUG ((EFI_D_ERROR, "[Bds] PerfDataMemAddr (%08x) cannot be saved to NV storage.\n", AcpiLowMemoryBase));\r
659 }\r
660 //\r
661 // Mark L"PerfDataMemAddr" variable to read-only if the Variable Lock protocol exists\r
662 // Still lock it even the variable cannot be saved to prevent it's set by 3rd party code.\r
663 //\r
664 Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
665 if (!EFI_ERROR (Status)) {\r
666 Status = VariableLock->RequestToLock (VariableLock, L"PerfDataMemAddr", &gPerformanceProtocolGuid);\r
667 ASSERT_EFI_ERROR (Status);\r
668 }\r
669 }\r
670}\r
671\r
672/**\r
673\r
674 Service routine for BdsInstance->Entry(). Devices are connected, the\r
675 consoles are initialized, and the boot options are tried.\r
676\r
677 @param This Protocol Instance structure.\r
678\r
679**/\r
680VOID\r
681EFIAPI\r
682BdsEntry (\r
683 IN EFI_BDS_ARCH_PROTOCOL *This\r
684 )\r
685{\r
686 EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions;\r
687 UINTN LoadOptionCount;\r
688 CHAR16 *FirmwareVendor;\r
689 EFI_EVENT HotkeyTriggered;\r
690 UINT64 OsIndication;\r
691 UINTN DataSize;\r
692 EFI_STATUS Status;\r
693 UINT32 BootOptionSupport;\r
694 UINT16 BootTimeOut;\r
695 EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;\r
696 UINTN Index;\r
697 EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;\r
698 UINT16 *BootNext;\r
699 CHAR16 BootNextVariableName[sizeof ("Boot####")];\r
700 EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;\r
701 BOOLEAN BootFwUi;\r
702 BOOLEAN PlatformRecovery;\r
703 BOOLEAN BootSuccess;\r
704 EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
705 EFI_STATUS BootManagerMenuStatus;\r
706\r
707 HotkeyTriggered = NULL;\r
708 Status = EFI_SUCCESS;\r
709 BootSuccess = FALSE;\r
710\r
711 //\r
712 // Insert the performance probe\r
713 //\r
714 PERF_END (NULL, "DXE", NULL, 0);\r
715 PERF_START (NULL, "BDS", NULL, 0);\r
716 DEBUG ((EFI_D_INFO, "[Bds] Entry...\n"));\r
717\r
718 PERF_CODE (\r
719 BdsAllocateMemoryForPerformanceData ();\r
720 );\r
721\r
722 //\r
723 // Fill in FirmwareVendor and FirmwareRevision from PCDs\r
724 //\r
725 FirmwareVendor = (CHAR16 *) PcdGetPtr (PcdFirmwareVendor);\r
726 gST->FirmwareVendor = AllocateRuntimeCopyPool (StrSize (FirmwareVendor), FirmwareVendor);\r
727 ASSERT (gST->FirmwareVendor != NULL);\r
728 gST->FirmwareRevision = PcdGet32 (PcdFirmwareRevision);\r
729\r
730 //\r
731 // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
732 //\r
733 gST->Hdr.CRC32 = 0;\r
734 gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
735\r
736 //\r
737 // Validate Variable.\r
738 //\r
739 BdsFormalizeEfiGlobalVariable ();\r
740\r
741 //\r
742 // Mark the read-only variables if the Variable Lock protocol exists\r
743 //\r
744 Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
745 DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));\r
746 if (!EFI_ERROR (Status)) {\r
747 for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {\r
748 Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);\r
749 ASSERT_EFI_ERROR (Status);\r
750 }\r
751 }\r
752\r
753 InitializeHwErrRecSupport ();\r
754\r
755 //\r
756 // Initialize L"Timeout" EFI global variable.\r
757 //\r
758 BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
759 if (BootTimeOut != 0xFFFF) {\r
760 //\r
761 // If time out value equal 0xFFFF, no need set to 0xFFFF to variable area because UEFI specification\r
762 // define same behavior between no value or 0xFFFF value for L"Timeout".\r
763 //\r
764 BdsDxeSetVariableAndReportStatusCodeOnError (\r
765 EFI_TIME_OUT_VARIABLE_NAME,\r
766 &gEfiGlobalVariableGuid,\r
767 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
768 sizeof (UINT16),\r
769 &BootTimeOut\r
770 );\r
771 }\r
772\r
773 //\r
774 // Initialize L"BootOptionSupport" EFI global variable.\r
775 // Lazy-ConIn implictly disables BDS hotkey.\r
776 //\r
777 BootOptionSupport = EFI_BOOT_OPTION_SUPPORT_APP | EFI_BOOT_OPTION_SUPPORT_SYSPREP;\r
778 if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
779 BootOptionSupport |= EFI_BOOT_OPTION_SUPPORT_KEY;\r
780 SET_BOOT_OPTION_SUPPORT_KEY_COUNT (BootOptionSupport, 3);\r
781 }\r
782 Status = gRT->SetVariable (\r
783 EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME,\r
784 &gEfiGlobalVariableGuid,\r
785 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
786 sizeof (BootOptionSupport),\r
787 &BootOptionSupport\r
788 );\r
789 //\r
790 // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
791 //\r
792 ASSERT_EFI_ERROR (Status);\r
793\r
794 //\r
795 // Cache and remove the "BootNext" NV variable.\r
796 //\r
797 GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) &BootNext, &DataSize);\r
798 if (DataSize != sizeof (UINT16)) {\r
799 if (BootNext != NULL) {\r
800 FreePool (BootNext);\r
801 }\r
802 BootNext = NULL;\r
803 }\r
804 Status = gRT->SetVariable (\r
805 EFI_BOOT_NEXT_VARIABLE_NAME,\r
806 &gEfiGlobalVariableGuid,\r
807 0,\r
808 0,\r
809 NULL\r
810 );\r
811 //\r
812 // Deleting NV variable shouldn't fail unless it doesn't exist.\r
813 //\r
814 ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);\r
815\r
816 //\r
817 // Initialize the platform language variables\r
818 //\r
819 InitializeLanguage (TRUE);\r
820\r
821 //\r
822 // System firmware must include a PlatformRecovery#### variable specifying\r
823 // a short-form File Path Media Device Path containing the platform default\r
824 // file path for removable media\r
825 //\r
826 FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
827 Status = EfiBootManagerInitializeLoadOption (\r
828 &LoadOption,\r
829 0,\r
830 LoadOptionTypePlatformRecovery,\r
831 LOAD_OPTION_ACTIVE,\r
832 L"Default PlatformRecovery",\r
833 FilePath,\r
834 NULL,\r
835 0\r
836 );\r
837 ASSERT_EFI_ERROR (Status);\r
838 EfiBootManagerLoadOptionToVariable (&LoadOption);\r
839 EfiBootManagerFreeLoadOption (&LoadOption);\r
840 FreePool (FilePath);\r
841\r
842 //\r
843 // Report Status Code to indicate connecting drivers will happen\r
844 //\r
845 REPORT_STATUS_CODE (\r
846 EFI_PROGRESS_CODE,\r
847 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
848 );\r
849\r
850 //\r
851 // Do the platform init, can be customized by OEM/IBV\r
852 // Possible things that can be done in PlatformBootManagerBeforeConsole:\r
853 // > Update console variable: 1. include hot-plug devices; 2. Clear ConIn and add SOL for AMT\r
854 // > Register new Driver#### or Boot####\r
855 // > Register new Key####: e.g.: F12 \r
856 // > Signal ReadyToLock event\r
857 // > Authentication action: 1. connect Auth devices; 2. Identify auto logon user.\r
858 //\r
859 PERF_START (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0);\r
860 PlatformBootManagerBeforeConsole ();\r
861 PERF_END (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0);\r
862\r
863 //\r
864 // Initialize hotkey service\r
865 //\r
866 EfiBootManagerStartHotkeyService (&HotkeyTriggered);\r
867\r
868 //\r
869 // Execute Driver Options\r
870 //\r
871 LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypeDriver);\r
872 ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
873 EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
874\r
875 //\r
876 // Connect consoles\r
877 //\r
878 PERF_START (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0);\r
879 if (PcdGetBool (PcdConInConnectOnDemand)) {\r
880 EfiBootManagerConnectConsoleVariable (ConOut);\r
881 EfiBootManagerConnectConsoleVariable (ErrOut);\r
882\r
883 //\r
884 // Initialize ConnectConIn event\r
885 //\r
886 Status = gBS->CreateEventEx (\r
887 EVT_NOTIFY_SIGNAL,\r
888 TPL_CALLBACK,\r
889 BdsDxeOnConnectConInCallBack,\r
890 NULL,\r
891 &gConnectConInEventGuid,\r
892 &gConnectConInEvent\r
893 );\r
894 if (EFI_ERROR (Status)) {\r
895 gConnectConInEvent = NULL;\r
896 }\r
897 } else {\r
898 EfiBootManagerConnectAllDefaultConsoles ();\r
899 }\r
900 PERF_END (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0);\r
901\r
902 //\r
903 // Do the platform specific action after the console is ready\r
904 // Possible things that can be done in PlatformBootManagerAfterConsole:\r
905 // > Console post action:\r
906 // > Dynamically switch output mode from 100x31 to 80x25 for certain senarino\r
907 // > Signal console ready platform customized event\r
908 // > Run diagnostics like memory testing\r
909 // > Connect certain devices\r
910 // > Dispatch aditional option roms\r
911 // > Special boot: e.g.: USB boot, enter UI\r
912 // \r
913 PERF_START (NULL, "PlatformBootManagerAfterConsole", "BDS", 0);\r
914 PlatformBootManagerAfterConsole ();\r
915 PERF_END (NULL, "PlatformBootManagerAfterConsole", "BDS", 0);\r
916 //\r
917 // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot\r
918 //\r
919 DataSize = sizeof (UINT64);\r
920 Status = gRT->GetVariable (\r
921 EFI_OS_INDICATIONS_VARIABLE_NAME,\r
922 &gEfiGlobalVariableGuid,\r
923 NULL,\r
924 &DataSize,\r
925 &OsIndication\r
926 );\r
927 if (EFI_ERROR (Status)) {\r
928 OsIndication = 0;\r
929 }\r
930\r
931 DEBUG_CODE (\r
932 EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType;\r
933 DEBUG ((EFI_D_INFO, "[Bds]OsIndication: %016x\n", OsIndication));\r
934 DEBUG ((EFI_D_INFO, "[Bds]=============Begin Load Options Dumping ...=============\n"));\r
935 for (LoadOptionType = 0; LoadOptionType < LoadOptionTypeMax; LoadOptionType++) {\r
936 DEBUG ((\r
937 EFI_D_INFO, " %s Options:\n",\r
938 mBdsLoadOptionName[LoadOptionType]\r
939 ));\r
940 LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionType);\r
941 for (Index = 0; Index < LoadOptionCount; Index++) {\r
942 DEBUG ((\r
943 EFI_D_INFO, " %s%04x: %s \t\t 0x%04x\n",\r
944 mBdsLoadOptionName[LoadOptionType],\r
945 LoadOptions[Index].OptionNumber,\r
946 LoadOptions[Index].Description,\r
947 LoadOptions[Index].Attributes\r
948 ));\r
949 }\r
950 EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
951 }\r
952 DEBUG ((EFI_D_INFO, "[Bds]=============End Load Options Dumping=============\n"));\r
953 );\r
954\r
955 //\r
956 // BootManagerMenu doesn't contain the correct information when return status is EFI_NOT_FOUND.\r
957 //\r
958 BootManagerMenuStatus = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);\r
959\r
960 BootFwUi = (BOOLEAN) ((OsIndication & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0);\r
961 PlatformRecovery = (BOOLEAN) ((OsIndication & EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY) != 0);\r
962 //\r
963 // Clear EFI_OS_INDICATIONS_BOOT_TO_FW_UI to acknowledge OS\r
964 // \r
965 if (BootFwUi || PlatformRecovery) {\r
966 OsIndication &= ~((UINT64) (EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY));\r
967 Status = gRT->SetVariable (\r
968 EFI_OS_INDICATIONS_VARIABLE_NAME,\r
969 &gEfiGlobalVariableGuid,\r
970 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
971 sizeof(UINT64),\r
972 &OsIndication\r
973 );\r
974 //\r
975 // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
976 //\r
977 ASSERT_EFI_ERROR (Status);\r
978 }\r
979\r
980 //\r
981 // Launch Boot Manager Menu directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot\r
982 //\r
983 if (BootFwUi && (BootManagerMenuStatus != EFI_NOT_FOUND)) {\r
984 //\r
985 // Follow generic rule, Call BdsDxeOnConnectConInCallBack to connect ConIn before enter UI\r
986 //\r
987 if (PcdGetBool (PcdConInConnectOnDemand)) {\r
988 BdsDxeOnConnectConInCallBack (NULL, NULL);\r
989 }\r
990\r
991 //\r
992 // Directly enter the setup page.\r
993 //\r
994 EfiBootManagerBoot (&BootManagerMenu);\r
995 }\r
996\r
997 if (!PlatformRecovery) {\r
998 //\r
999 // Execute SysPrep####\r
1000 //\r
1001 LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypeSysPrep);\r
1002 ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
1003 EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
1004\r
1005 //\r
1006 // Execute Key####\r
1007 //\r
1008 PERF_START (NULL, "BdsWait", "BDS", 0);\r
1009 BdsWait (HotkeyTriggered);\r
1010 PERF_END (NULL, "BdsWait", "BDS", 0);\r
1011\r
1012 //\r
1013 // BdsReadKeys() can be removed after all keyboard drivers invoke callback in timer callback.\r
1014 //\r
1015 BdsReadKeys ();\r
1016\r
1017 EfiBootManagerHotkeyBoot ();\r
1018\r
1019 //\r
1020 // Boot to "BootNext"\r
1021 //\r
1022 if (BootNext != NULL) {\r
1023 UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), L"Boot%04x", *BootNext);\r
1024 Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &LoadOption);\r
1025 if (!EFI_ERROR (Status)) {\r
1026 EfiBootManagerBoot (&LoadOption);\r
1027 EfiBootManagerFreeLoadOption (&LoadOption);\r
1028 if ((LoadOption.Status == EFI_SUCCESS) && \r
1029 (BootManagerMenuStatus != EFI_NOT_FOUND) &&\r
1030 (LoadOption.OptionNumber != BootManagerMenu.OptionNumber)) {\r
1031 //\r
1032 // Boot to Boot Manager Menu upon EFI_SUCCESS\r
1033 // Exception: Do not boot again when the BootNext points to Boot Manager Menu.\r
1034 //\r
1035 EfiBootManagerBoot (&BootManagerMenu);\r
1036 }\r
1037 }\r
1038 }\r
1039\r
1040 do {\r
1041 //\r
1042 // Retry to boot if any of the boot succeeds\r
1043 //\r
1044 LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypeBoot);\r
1045 BootSuccess = BootBootOptions (LoadOptions, LoadOptionCount, (BootManagerMenuStatus != EFI_NOT_FOUND) ? &BootManagerMenu : NULL);\r
1046 EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
1047 } while (BootSuccess);\r
1048 }\r
1049\r
1050 if (BootManagerMenuStatus != EFI_NOT_FOUND) {\r
1051 EfiBootManagerFreeLoadOption (&BootManagerMenu);\r
1052 }\r
1053\r
1054 if (!BootSuccess) {\r
1055 LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
1056 ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
1057 EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
1058 }\r
1059\r
1060 DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n"));\r
1061 CpuDeadLoop ();\r
1062}\r
1063\r
1064/**\r
1065 Set the variable and report the error through status code upon failure.\r
1066\r
1067 @param VariableName A Null-terminated string that is the name of the vendor's variable.\r
1068 Each VariableName is unique for each VendorGuid. VariableName must\r
1069 contain 1 or more characters. If VariableName is an empty string,\r
1070 then EFI_INVALID_PARAMETER is returned.\r
1071 @param VendorGuid A unique identifier for the vendor.\r
1072 @param Attributes Attributes bitmask to set for the variable.\r
1073 @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, \r
1074 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or \r
1075 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero \r
1076 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is \r
1077 set, then a SetVariable() call with a DataSize of zero will not cause any change to \r
1078 the variable value (the timestamp associated with the variable may be updated however \r
1079 even if no new data value is provided,see the description of the \r
1080 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not \r
1081 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). \r
1082 @param Data The contents for the variable.\r
1083\r
1084 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r
1085 defined by the Attributes.\r
1086 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the\r
1087 DataSize exceeds the maximum allowed.\r
1088 @retval EFI_INVALID_PARAMETER VariableName is an empty string.\r
1089 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
1090 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r
1091 @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r
1092 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r
1093 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS \r
1094 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo \r
1095 does NOT pass the validation check carried out by the firmware.\r
1096\r
1097 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
1098**/\r
1099EFI_STATUS\r
1100BdsDxeSetVariableAndReportStatusCodeOnError (\r
1101 IN CHAR16 *VariableName,\r
1102 IN EFI_GUID *VendorGuid,\r
1103 IN UINT32 Attributes,\r
1104 IN UINTN DataSize,\r
1105 IN VOID *Data\r
1106 )\r
1107{\r
1108 EFI_STATUS Status;\r
1109 EDKII_SET_VARIABLE_STATUS *SetVariableStatus;\r
1110 UINTN NameSize;\r
1111\r
1112 Status = gRT->SetVariable (\r
1113 VariableName,\r
1114 VendorGuid,\r
1115 Attributes,\r
1116 DataSize,\r
1117 Data\r
1118 );\r
1119 if (EFI_ERROR (Status)) {\r
1120 NameSize = StrSize (VariableName);\r
1121 SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);\r
1122 if (SetVariableStatus != NULL) {\r
1123 CopyGuid (&SetVariableStatus->Guid, VendorGuid);\r
1124 SetVariableStatus->NameSize = NameSize;\r
1125 SetVariableStatus->DataSize = DataSize;\r
1126 SetVariableStatus->SetStatus = Status;\r
1127 SetVariableStatus->Attributes = Attributes;\r
1128 CopyMem (SetVariableStatus + 1, VariableName, NameSize);\r
1129 CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);\r
1130\r
1131 REPORT_STATUS_CODE_EX (\r
1132 EFI_ERROR_CODE,\r
1133 PcdGet32 (PcdErrorCodeSetVariable),\r
1134 0,\r
1135 NULL,\r
1136 &gEdkiiStatusCodeDataTypeVariableGuid,\r
1137 SetVariableStatus,\r
1138 sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize\r
1139 );\r
1140\r
1141 FreePool (SetVariableStatus);\r
1142 }\r
1143 }\r
1144\r
1145 return Status;\r
1146}\r