]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
MdeModulePkg/BmpSupportLib: Check PixelHeight/PixelWidth against 0
[mirror_edk2.git] / MdeModulePkg / Library / DxeCapsuleLibFmp / DxeCapsuleProcessLib.c
... / ...
CommitLineData
1/** @file\r
2 DXE capsule process.\r
3\r
4 Caution: This module requires additional review when modified.\r
5 This module will have external input - capsule image.\r
6 This external input must be validated carefully to avoid security issue like\r
7 buffer overflow, integer overflow.\r
8\r
9 ProcessCapsules(), ProcessTheseCapsules() will receive untrusted\r
10 input and do basic validation.\r
11\r
12 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
13 This program and the accompanying materials\r
14 are licensed and made available under the terms and conditions of the BSD License\r
15 which accompanies this distribution. The full text of the license may be found at\r
16 http://opensource.org/licenses/bsd-license.php\r
17\r
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
20\r
21**/\r
22\r
23#include <PiDxe.h>\r
24#include <Protocol/EsrtManagement.h>\r
25#include <Protocol/FirmwareManagementProgress.h>\r
26\r
27#include <Library/BaseLib.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/BaseMemoryLib.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/UefiRuntimeServicesTableLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/PcdLib.h>\r
35#include <Library/HobLib.h>\r
36#include <Library/ReportStatusCodeLib.h>\r
37#include <Library/CapsuleLib.h>\r
38#include <Library/DisplayUpdateProgressLib.h>\r
39\r
40#include <IndustryStandard/WindowsUxCapsule.h>\r
41\r
42extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;\r
43\r
44/**\r
45 Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.\r
46\r
47 @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER\r
48\r
49 @retval TRUE It is a system FMP.\r
50 @retval FALSE It is a device FMP.\r
51**/\r
52BOOLEAN\r
53IsFmpCapsule (\r
54 IN EFI_CAPSULE_HEADER *CapsuleHeader\r
55 );\r
56\r
57/**\r
58 Validate Fmp capsules layout.\r
59\r
60 Caution: This function may receive untrusted input.\r
61\r
62 This function assumes the caller validated the capsule by using\r
63 IsValidCapsuleHeader(), so that all fields in EFI_CAPSULE_HEADER are correct.\r
64 The capsule buffer size is CapsuleHeader->CapsuleImageSize.\r
65\r
66 This function validates the fields in EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER\r
67 and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.\r
68\r
69 This function need support nested FMP capsule.\r
70\r
71 @param[in] CapsuleHeader Points to a capsule header.\r
72 @param[out] EmbeddedDriverCount The EmbeddedDriverCount in the FMP capsule.\r
73\r
74 @retval EFI_SUCESS Input capsule is a correct FMP capsule.\r
75 @retval EFI_INVALID_PARAMETER Input capsule is not a correct FMP capsule.\r
76**/\r
77EFI_STATUS\r
78ValidateFmpCapsule (\r
79 IN EFI_CAPSULE_HEADER *CapsuleHeader,\r
80 OUT UINT16 *EmbeddedDriverCount OPTIONAL\r
81 );\r
82\r
83/**\r
84 Validate if it is valid capsule header\r
85\r
86 This function assumes the caller provided correct CapsuleHeader pointer\r
87 and CapsuleSize.\r
88\r
89 This function validates the fields in EFI_CAPSULE_HEADER.\r
90\r
91 @param[in] CapsuleHeader Points to a capsule header.\r
92 @param[in] CapsuleSize Size of the whole capsule image.\r
93\r
94**/\r
95BOOLEAN\r
96IsValidCapsuleHeader (\r
97 IN EFI_CAPSULE_HEADER *CapsuleHeader,\r
98 IN UINT64 CapsuleSize\r
99 );\r
100\r
101extern BOOLEAN mDxeCapsuleLibEndOfDxe;\r
102BOOLEAN mNeedReset;\r
103\r
104VOID **mCapsulePtr;\r
105EFI_STATUS *mCapsuleStatusArray;\r
106UINT32 mCapsuleTotalNumber;\r
107\r
108/**\r
109 Function indicate the current completion progress of the firmware\r
110 update. Platform may override with own specific progress function.\r
111\r
112 @param[in] Completion A value between 1 and 100 indicating the current\r
113 completion progress of the firmware update\r
114\r
115 @retval EFI_SUCESS The capsule update progress was updated.\r
116 @retval EFI_INVALID_PARAMETER Completion is greater than 100%.\r
117**/\r
118EFI_STATUS\r
119EFIAPI\r
120UpdateImageProgress (\r
121 IN UINTN Completion\r
122 )\r
123{\r
124 EFI_STATUS Status;\r
125 UINTN Seconds;\r
126 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;\r
127\r
128 DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));\r
129\r
130 if (Completion > 100) {\r
131 return EFI_INVALID_PARAMETER;\r
132 }\r
133\r
134 //\r
135 // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.\r
136 //\r
137 Seconds = 5 * 60;\r
138 Color = NULL;\r
139 if (mFmpProgress != NULL) {\r
140 Seconds = mFmpProgress->WatchdogSeconds;\r
141 Color = &mFmpProgress->ProgressBarForegroundColor;\r
142 }\r
143\r
144 //\r
145 // Cancel the watchdog timer\r
146 //\r
147 gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);\r
148\r
149 if (Completion != 100) {\r
150 //\r
151 // Arm the watchdog timer from PCD setting\r
152 //\r
153 if (Seconds != 0) {\r
154 DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));\r
155 gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);\r
156 }\r
157 }\r
158\r
159 Status = DisplayUpdateProgress (Completion, Color);\r
160\r
161 return Status;\r
162}\r
163\r
164/**\r
165 This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.\r
166**/\r
167VOID\r
168InitCapsulePtr (\r
169 VOID\r
170 )\r
171{\r
172 EFI_PEI_HOB_POINTERS HobPointer;\r
173 UINTN Index;\r
174\r
175 //\r
176 // Find all capsule images from hob\r
177 //\r
178 HobPointer.Raw = GetHobList ();\r
179 while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {\r
180 if (!IsValidCapsuleHeader((VOID *)(UINTN)HobPointer.Capsule->BaseAddress, HobPointer.Capsule->Length)) {\r
181 HobPointer.Header->HobType = EFI_HOB_TYPE_UNUSED; // Mark this hob as invalid\r
182 } else {\r
183 mCapsuleTotalNumber++;\r
184 }\r
185 HobPointer.Raw = GET_NEXT_HOB (HobPointer);\r
186 }\r
187\r
188 DEBUG ((DEBUG_INFO, "mCapsuleTotalNumber - 0x%x\n", mCapsuleTotalNumber));\r
189\r
190 if (mCapsuleTotalNumber == 0) {\r
191 return ;\r
192 }\r
193\r
194 //\r
195 // Init temp Capsule Data table.\r
196 //\r
197 mCapsulePtr = (VOID **) AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);\r
198 if (mCapsulePtr == NULL) {\r
199 DEBUG ((DEBUG_ERROR, "Allocate mCapsulePtr fail!\n"));\r
200 mCapsuleTotalNumber = 0;\r
201 return ;\r
202 }\r
203 mCapsuleStatusArray = (EFI_STATUS *) AllocateZeroPool (sizeof (EFI_STATUS) * mCapsuleTotalNumber);\r
204 if (mCapsuleStatusArray == NULL) {\r
205 DEBUG ((DEBUG_ERROR, "Allocate mCapsuleStatusArray fail!\n"));\r
206 FreePool (mCapsulePtr);\r
207 mCapsulePtr = NULL;\r
208 mCapsuleTotalNumber = 0;\r
209 return ;\r
210 }\r
211 SetMemN (mCapsuleStatusArray, sizeof (EFI_STATUS) * mCapsuleTotalNumber, EFI_NOT_READY);\r
212\r
213 //\r
214 // Find all capsule images from hob\r
215 //\r
216 HobPointer.Raw = GetHobList ();\r
217 Index = 0;\r
218 while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {\r
219 mCapsulePtr [Index++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;\r
220 HobPointer.Raw = GET_NEXT_HOB (HobPointer);\r
221 }\r
222}\r
223\r
224/**\r
225 This function returns if all capsule images are processed.\r
226\r
227 @retval TRUE All capsule images are processed.\r
228 @retval FALSE Not all capsule images are processed.\r
229**/\r
230BOOLEAN\r
231AreAllImagesProcessed (\r
232 VOID\r
233 )\r
234{\r
235 UINTN Index;\r
236\r
237 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
238 if (mCapsuleStatusArray[Index] == EFI_NOT_READY) {\r
239 return FALSE;\r
240 }\r
241 }\r
242\r
243 return TRUE;\r
244}\r
245\r
246/**\r
247 This function populates capsule in the configuration table.\r
248**/\r
249VOID\r
250PopulateCapsuleInConfigurationTable (\r
251 VOID\r
252 )\r
253{\r
254 VOID **CapsulePtrCache;\r
255 EFI_GUID *CapsuleGuidCache;\r
256 EFI_CAPSULE_HEADER *CapsuleHeader;\r
257 EFI_CAPSULE_TABLE *CapsuleTable;\r
258 UINT32 CacheIndex;\r
259 UINT32 CacheNumber;\r
260 UINT32 CapsuleNumber;\r
261 UINTN Index;\r
262 UINTN Size;\r
263 EFI_STATUS Status;\r
264\r
265 if (mCapsuleTotalNumber == 0) {\r
266 return ;\r
267 }\r
268\r
269 CapsulePtrCache = NULL;\r
270 CapsuleGuidCache = NULL;\r
271 CacheIndex = 0;\r
272 CacheNumber = 0;\r
273\r
274 CapsulePtrCache = (VOID **) AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);\r
275 if (CapsulePtrCache == NULL) {\r
276 DEBUG ((DEBUG_ERROR, "Allocate CapsulePtrCache fail!\n"));\r
277 return ;\r
278 }\r
279 CapsuleGuidCache = (EFI_GUID *) AllocateZeroPool (sizeof (EFI_GUID) * mCapsuleTotalNumber);\r
280 if (CapsuleGuidCache == NULL) {\r
281 DEBUG ((DEBUG_ERROR, "Allocate CapsuleGuidCache fail!\n"));\r
282 FreePool (CapsulePtrCache);\r
283 return ;\r
284 }\r
285\r
286 //\r
287 // Capsules who have CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE always are used for operating\r
288 // System to have information persist across a system reset. EFI System Table must\r
289 // point to an array of capsules that contains the same CapsuleGuid value. And agents\r
290 // searching for this type capsule will look in EFI System Table and search for the\r
291 // capsule's Guid and associated pointer to retrieve the data. Two steps below describes\r
292 // how to sorting the capsules by the unique guid and install the array to EFI System Table.\r
293 // Firstly, Loop for all coalesced capsules, record unique CapsuleGuids and cache them in an\r
294 // array for later sorting capsules by CapsuleGuid.\r
295 //\r
296 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
297 CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];\r
298 if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {\r
299 //\r
300 // For each capsule, we compare it with known CapsuleGuid in the CacheArray.\r
301 // If already has the Guid, skip it. Whereas, record it in the CacheArray as\r
302 // an additional one.\r
303 //\r
304 CacheIndex = 0;\r
305 while (CacheIndex < CacheNumber) {\r
306 if (CompareGuid(&CapsuleGuidCache[CacheIndex],&CapsuleHeader->CapsuleGuid)) {\r
307 break;\r
308 }\r
309 CacheIndex++;\r
310 }\r
311 if (CacheIndex == CacheNumber) {\r
312 CopyMem(&CapsuleGuidCache[CacheNumber++],&CapsuleHeader->CapsuleGuid,sizeof(EFI_GUID));\r
313 }\r
314 }\r
315 }\r
316\r
317 //\r
318 // Secondly, for each unique CapsuleGuid in CacheArray, gather all coalesced capsules\r
319 // whose guid is the same as it, and malloc memory for an array which preceding\r
320 // with UINT32. The array fills with entry point of capsules that have the same\r
321 // CapsuleGuid, and UINT32 represents the size of the array of capsules. Then install\r
322 // this array into EFI System Table, so that agents searching for this type capsule\r
323 // will look in EFI System Table and search for the capsule's Guid and associated\r
324 // pointer to retrieve the data.\r
325 //\r
326 for (CacheIndex = 0; CacheIndex < CacheNumber; CacheIndex++) {\r
327 CapsuleNumber = 0;\r
328 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
329 CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];\r
330 if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {\r
331 if (CompareGuid (&CapsuleGuidCache[CacheIndex], &CapsuleHeader->CapsuleGuid)) {\r
332 //\r
333 // Cache Caspuleheader to the array, this array is uniqued with certain CapsuleGuid.\r
334 //\r
335 CapsulePtrCache[CapsuleNumber++] = (VOID*)CapsuleHeader;\r
336 }\r
337 }\r
338 }\r
339 if (CapsuleNumber != 0) {\r
340 Size = sizeof(EFI_CAPSULE_TABLE) + (CapsuleNumber - 1) * sizeof(VOID*);\r
341 CapsuleTable = AllocateRuntimePool (Size);\r
342 if (CapsuleTable == NULL) {\r
343 DEBUG ((DEBUG_ERROR, "Allocate CapsuleTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));\r
344 continue;\r
345 }\r
346 CapsuleTable->CapsuleArrayNumber = CapsuleNumber;\r
347 CopyMem(&CapsuleTable->CapsulePtr[0], CapsulePtrCache, CapsuleNumber * sizeof(VOID*));\r
348 Status = gBS->InstallConfigurationTable (&CapsuleGuidCache[CacheIndex], (VOID*)CapsuleTable);\r
349 if (EFI_ERROR (Status)) {\r
350 DEBUG ((DEBUG_ERROR, "InstallConfigurationTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));\r
351 }\r
352 }\r
353 }\r
354\r
355 FreePool(CapsuleGuidCache);\r
356 FreePool(CapsulePtrCache);\r
357}\r
358\r
359/**\r
360\r
361 This routine is called to process capsules.\r
362\r
363 Caution: This function may receive untrusted input.\r
364\r
365 Each individual capsule result is recorded in capsule record variable.\r
366\r
367 @param[in] FirstRound TRUE: First round. Need skip the FMP capsules with non zero EmbeddedDriverCount.\r
368 FALSE: Process rest FMP capsules.\r
369\r
370 @retval EFI_SUCCESS There is no error when processing capsules.\r
371 @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules.\r
372\r
373**/\r
374EFI_STATUS\r
375ProcessTheseCapsules (\r
376 IN BOOLEAN FirstRound\r
377 )\r
378{\r
379 EFI_STATUS Status;\r
380 EFI_CAPSULE_HEADER *CapsuleHeader;\r
381 UINT32 Index;\r
382 ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;\r
383 UINT16 EmbeddedDriverCount;\r
384\r
385 REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesBegin)));\r
386\r
387 if (FirstRound) {\r
388 InitCapsulePtr ();\r
389 }\r
390\r
391 if (mCapsuleTotalNumber == 0) {\r
392 //\r
393 // We didn't find a hob, so had no errors.\r
394 //\r
395 DEBUG ((DEBUG_ERROR, "We can not find capsule data in capsule update boot mode.\n"));\r
396 return EFI_SUCCESS;\r
397 }\r
398\r
399 if (AreAllImagesProcessed ()) {\r
400 return EFI_SUCCESS;\r
401 }\r
402\r
403 //\r
404 // Check the capsule flags,if contains CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE, install\r
405 // capsuleTable to configure table with EFI_CAPSULE_GUID\r
406 //\r
407 if (FirstRound) {\r
408 PopulateCapsuleInConfigurationTable ();\r
409 }\r
410\r
411 REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdatingFirmware)));\r
412\r
413 //\r
414 // If Windows UX capsule exist, process it first\r
415 //\r
416 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
417 CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];\r
418 if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {\r
419 DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));\r
420 DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));\r
421 Status = ProcessCapsuleImage (CapsuleHeader);\r
422 mCapsuleStatusArray [Index] = EFI_SUCCESS;\r
423 DEBUG((DEBUG_INFO, "ProcessCapsuleImage (Ux) - %r\n", Status));\r
424 break;\r
425 }\r
426 }\r
427\r
428 DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));\r
429\r
430 //\r
431 // All capsules left are recognized by platform.\r
432 //\r
433 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
434 if (mCapsuleStatusArray [Index] != EFI_NOT_READY) {\r
435 // already processed\r
436 continue;\r
437 }\r
438 CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];\r
439 if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {\r
440 //\r
441 // Call capsule library to process capsule image.\r
442 //\r
443 EmbeddedDriverCount = 0;\r
444 if (IsFmpCapsule(CapsuleHeader)) {\r
445 Status = ValidateFmpCapsule (CapsuleHeader, &EmbeddedDriverCount);\r
446 if (EFI_ERROR(Status)) {\r
447 DEBUG((DEBUG_ERROR, "ValidateFmpCapsule failed. Ignore!\n"));\r
448 mCapsuleStatusArray [Index] = EFI_ABORTED;\r
449 continue;\r
450 }\r
451 } else {\r
452 mCapsuleStatusArray [Index] = EFI_ABORTED;\r
453 continue;\r
454 }\r
455\r
456 if ((!FirstRound) || (EmbeddedDriverCount == 0)) {\r
457 DEBUG((DEBUG_INFO, "ProcessCapsuleImage - 0x%x\n", CapsuleHeader));\r
458 Status = ProcessCapsuleImage (CapsuleHeader);\r
459 mCapsuleStatusArray [Index] = Status;\r
460 DEBUG((DEBUG_INFO, "ProcessCapsuleImage - %r\n", Status));\r
461\r
462 if (Status != EFI_NOT_READY) {\r
463 if (EFI_ERROR(Status)) {\r
464 REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));\r
465 DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));\r
466 } else {\r
467 REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));\r
468 }\r
469\r
470 if ((CapsuleHeader->Flags & PcdGet16(PcdSystemRebootAfterCapsuleProcessFlag)) != 0 ||\r
471 IsFmpCapsule(CapsuleHeader)) {\r
472 mNeedReset = TRUE;\r
473 }\r
474 }\r
475 }\r
476 }\r
477 }\r
478\r
479 Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);\r
480 //\r
481 // Always sync ESRT Cache from FMP Instance\r
482 //\r
483 if (!EFI_ERROR(Status)) {\r
484 EsrtManagement->SyncEsrtFmp();\r
485 }\r
486 Status = EFI_SUCCESS;\r
487\r
488 REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesEnd)));\r
489\r
490 return Status;\r
491}\r
492\r
493/**\r
494 Do reset system.\r
495**/\r
496VOID\r
497DoResetSystem (\r
498 VOID\r
499 )\r
500{\r
501 DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));\r
502\r
503 REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));\r
504\r
505 gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);\r
506\r
507 CpuDeadLoop();\r
508}\r
509\r
510/**\r
511\r
512 This routine is called to process capsules.\r
513\r
514 Caution: This function may receive untrusted input.\r
515\r
516 The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.\r
517 If there is no EFI_HOB_UEFI_CAPSULE, this routine does nothing.\r
518\r
519 This routine should be called twice in BDS.\r
520 1) The first call must be before EndOfDxe. The system capsules is processed.\r
521 If device capsule FMP protocols are exposted at this time and device FMP\r
522 capsule has zero EmbeddedDriverCount, the device capsules are processed.\r
523 Each individual capsule result is recorded in capsule record variable.\r
524 System may reset in this function, if reset is required by capsule and\r
525 all capsules are processed.\r
526 If not all capsules are processed, reset will be defered to second call.\r
527\r
528 2) The second call must be after EndOfDxe and after ConnectAll, so that all\r
529 device capsule FMP protocols are exposed.\r
530 The system capsules are skipped. If the device capsules are NOT processed\r
531 in first call, they are processed here.\r
532 Each individual capsule result is recorded in capsule record variable.\r
533 System may reset in this function, if reset is required by capsule\r
534 processed in first call and second call.\r
535\r
536 @retval EFI_SUCCESS There is no error when processing capsules.\r
537 @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules.\r
538\r
539**/\r
540EFI_STATUS\r
541EFIAPI\r
542ProcessCapsules (\r
543 VOID\r
544 )\r
545{\r
546 EFI_STATUS Status;\r
547\r
548 if (!mDxeCapsuleLibEndOfDxe) {\r
549 Status = ProcessTheseCapsules(TRUE);\r
550\r
551 //\r
552 // Reboot System if and only if all capsule processed.\r
553 // If not, defer reset to 2nd process.\r
554 //\r
555 if (mNeedReset && AreAllImagesProcessed()) {\r
556 DoResetSystem();\r
557 }\r
558 } else {\r
559 Status = ProcessTheseCapsules(FALSE);\r
560 //\r
561 // Reboot System if required after all capsule processed\r
562 //\r
563 if (mNeedReset) {\r
564 DoResetSystem();\r
565 }\r
566 }\r
567 return Status;\r
568}\r