4 Caution: This module requires additional review when modified.
5 This module will have external input - capsule image.
6 This external input must be validated carefully to avoid security issue like
7 buffer overflow, integer overflow.
9 ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
10 input and do basic validation.
12 Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
18 #include <Protocol/EsrtManagement.h>
19 #include <Protocol/FirmwareManagementProgress.h>
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/UefiRuntimeServicesTableLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiLib.h>
28 #include <Library/PcdLib.h>
29 #include <Library/HobLib.h>
30 #include <Library/ReportStatusCodeLib.h>
31 #include <Library/CapsuleLib.h>
32 #include <Library/DisplayUpdateProgressLib.h>
34 #include <IndustryStandard/WindowsUxCapsule.h>
36 extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL
*mFmpProgress
;
39 Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
41 @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER
43 @retval TRUE It is a system FMP.
44 @retval FALSE It is a device FMP.
48 IN EFI_CAPSULE_HEADER
*CapsuleHeader
52 Validate Fmp capsules layout.
54 Caution: This function may receive untrusted input.
56 This function assumes the caller validated the capsule by using
57 IsValidCapsuleHeader(), so that all fields in EFI_CAPSULE_HEADER are correct.
58 The capsule buffer size is CapsuleHeader->CapsuleImageSize.
60 This function validates the fields in EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER
61 and EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER.
63 This function need support nested FMP capsule.
65 @param[in] CapsuleHeader Points to a capsule header.
66 @param[out] EmbeddedDriverCount The EmbeddedDriverCount in the FMP capsule.
68 @retval EFI_SUCESS Input capsule is a correct FMP capsule.
69 @retval EFI_INVALID_PARAMETER Input capsule is not a correct FMP capsule.
73 IN EFI_CAPSULE_HEADER
*CapsuleHeader
,
74 OUT UINT16
*EmbeddedDriverCount OPTIONAL
78 Validate if it is valid capsule header
80 This function assumes the caller provided correct CapsuleHeader pointer
83 This function validates the fields in EFI_CAPSULE_HEADER.
85 @param[in] CapsuleHeader Points to a capsule header.
86 @param[in] CapsuleSize Size of the whole capsule image.
90 IsValidCapsuleHeader (
91 IN EFI_CAPSULE_HEADER
*CapsuleHeader
,
96 Return if this capsule is a capsule name capsule, based upon CapsuleHeader.
98 @param[in] CapsuleHeader A pointer to EFI_CAPSULE_HEADER
100 @retval TRUE It is a capsule name capsule.
101 @retval FALSE It is not a capsule name capsule.
104 IsCapsuleNameCapsule (
105 IN EFI_CAPSULE_HEADER
*CapsuleHeader
109 Check the integrity of the capsule name capsule.
110 If the capsule is vaild, return the physical address of each capsule name string.
112 @param[in] CapsuleHeader Pointer to the capsule header of a capsule name capsule.
113 @param[out] CapsuleNameNum Number of capsule name.
115 @retval NULL Capsule name capsule is not valid.
116 @retval CapsuleNameBuf Array of capsule name physical address.
119 EFI_PHYSICAL_ADDRESS
*
120 ValidateCapsuleNameCapsuleIntegrity (
121 IN EFI_CAPSULE_HEADER
*CapsuleHeader
,
122 OUT UINTN
*CapsuleNameNum
125 extern BOOLEAN mDxeCapsuleLibEndOfDxe
;
126 BOOLEAN mNeedReset
= FALSE
;
129 CHAR16
**mCapsuleNamePtr
;
130 EFI_STATUS
*mCapsuleStatusArray
;
131 UINT32 mCapsuleTotalNumber
;
134 The firmware implements to process the capsule image.
136 Caution: This function may receive untrusted input.
138 @param[in] CapsuleHeader Points to a capsule header.
139 @param[in] CapFileName Capsule file name.
140 @param[out] ResetRequired Indicates whether reset is required or not.
142 @retval EFI_SUCESS Process Capsule Image successfully.
143 @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
144 @retval EFI_VOLUME_CORRUPTED FV volume in the capsule is corrupted.
145 @retval EFI_OUT_OF_RESOURCES Not enough memory.
149 ProcessThisCapsuleImage (
150 IN EFI_CAPSULE_HEADER
*CapsuleHeader
,
151 IN CHAR16
*CapFileName OPTIONAL
,
152 OUT BOOLEAN
*ResetRequired OPTIONAL
156 Function indicate the current completion progress of the firmware
157 update. Platform may override with own specific progress function.
159 @param[in] Completion A value between 1 and 100 indicating the current
160 completion progress of the firmware update
162 @retval EFI_SUCESS The capsule update progress was updated.
163 @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
167 UpdateImageProgress (
173 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION
*Color
;
175 DEBUG((DEBUG_INFO
, "Update Progress - %d%%\n", Completion
));
177 if (Completion
> 100) {
178 return EFI_INVALID_PARAMETER
;
182 // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
186 if (mFmpProgress
!= NULL
) {
187 Seconds
= mFmpProgress
->WatchdogSeconds
;
188 Color
= &mFmpProgress
->ProgressBarForegroundColor
;
192 // Cancel the watchdog timer
194 gBS
->SetWatchdogTimer (0, 0x0000, 0, NULL
);
196 if (Completion
!= 100) {
198 // Arm the watchdog timer from PCD setting
201 DEBUG ((DEBUG_VERBOSE
, "Arm watchdog timer %d seconds\n", Seconds
));
202 gBS
->SetWatchdogTimer (Seconds
, 0x0000, 0, NULL
);
206 Status
= DisplayUpdateProgress (Completion
, Color
);
212 This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
219 EFI_PEI_HOB_POINTERS HobPointer
;
223 UINTN CapsuleNameNumber
;
224 UINTN CapsuleNameTotalNumber
;
225 UINTN CapsuleNameCapsuleTotalNumber
;
226 VOID
**CapsuleNameCapsulePtr
;
227 EFI_PHYSICAL_ADDRESS
*CapsuleNameAddress
;
229 CapsuleNameNumber
= 0;
230 CapsuleNameTotalNumber
= 0;
231 CapsuleNameCapsuleTotalNumber
= 0;
232 CapsuleNameCapsulePtr
= NULL
;
235 // Find all capsule images from hob
237 HobPointer
.Raw
= GetHobList ();
238 while ((HobPointer
.Raw
= GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE
, HobPointer
.Raw
)) != NULL
) {
239 if (!IsValidCapsuleHeader((VOID
*)(UINTN
)HobPointer
.Capsule
->BaseAddress
, HobPointer
.Capsule
->Length
)) {
240 HobPointer
.Header
->HobType
= EFI_HOB_TYPE_UNUSED
; // Mark this hob as invalid
242 if (IsCapsuleNameCapsule((VOID
*)(UINTN
)HobPointer
.Capsule
->BaseAddress
)) {
243 CapsuleNameCapsuleTotalNumber
++;
245 mCapsuleTotalNumber
++;
248 HobPointer
.Raw
= GET_NEXT_HOB (HobPointer
);
251 DEBUG ((DEBUG_INFO
, "mCapsuleTotalNumber - 0x%x\n", mCapsuleTotalNumber
));
253 if (mCapsuleTotalNumber
== 0) {
258 // Init temp Capsule Data table.
260 mCapsulePtr
= (VOID
**) AllocateZeroPool (sizeof (VOID
*) * mCapsuleTotalNumber
);
261 if (mCapsulePtr
== NULL
) {
262 DEBUG ((DEBUG_ERROR
, "Allocate mCapsulePtr fail!\n"));
263 mCapsuleTotalNumber
= 0;
266 mCapsuleStatusArray
= (EFI_STATUS
*) AllocateZeroPool (sizeof (EFI_STATUS
) * mCapsuleTotalNumber
);
267 if (mCapsuleStatusArray
== NULL
) {
268 DEBUG ((DEBUG_ERROR
, "Allocate mCapsuleStatusArray fail!\n"));
269 FreePool (mCapsulePtr
);
271 mCapsuleTotalNumber
= 0;
274 SetMemN (mCapsuleStatusArray
, sizeof (EFI_STATUS
) * mCapsuleTotalNumber
, EFI_NOT_READY
);
276 CapsuleNameCapsulePtr
= (VOID
**) AllocateZeroPool (sizeof (VOID
*) * CapsuleNameCapsuleTotalNumber
);
277 if (CapsuleNameCapsulePtr
== NULL
) {
278 DEBUG ((DEBUG_ERROR
, "Allocate CapsuleNameCapsulePtr fail!\n"));
279 FreePool (mCapsulePtr
);
280 FreePool (mCapsuleStatusArray
);
282 mCapsuleStatusArray
= NULL
;
283 mCapsuleTotalNumber
= 0;
288 // Find all capsule images from hob
290 HobPointer
.Raw
= GetHobList ();
293 while ((HobPointer
.Raw
= GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE
, HobPointer
.Raw
)) != NULL
) {
294 if (IsCapsuleNameCapsule ((VOID
*) (UINTN
) HobPointer
.Capsule
->BaseAddress
)) {
295 CapsuleNameCapsulePtr
[Index2
++] = (VOID
*) (UINTN
) HobPointer
.Capsule
->BaseAddress
;
297 mCapsulePtr
[Index
++] = (VOID
*) (UINTN
) HobPointer
.Capsule
->BaseAddress
;
299 HobPointer
.Raw
= GET_NEXT_HOB (HobPointer
);
303 // Find Capsule On Disk Names
305 for (Index
= 0; Index
< CapsuleNameCapsuleTotalNumber
; Index
++) {
306 CapsuleNameAddress
= ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr
[Index
], &CapsuleNameNumber
);
307 if (CapsuleNameAddress
!= NULL
) {
308 CapsuleNameTotalNumber
+= CapsuleNameNumber
;
312 if (CapsuleNameTotalNumber
== mCapsuleTotalNumber
) {
313 mCapsuleNamePtr
= (CHAR16
**) AllocateZeroPool (sizeof (CHAR16
*) * mCapsuleTotalNumber
);
314 if (mCapsuleNamePtr
== NULL
) {
315 DEBUG ((DEBUG_ERROR
, "Allocate mCapsuleNamePtr fail!\n"));
316 FreePool (mCapsulePtr
);
317 FreePool (mCapsuleStatusArray
);
318 FreePool (CapsuleNameCapsulePtr
);
320 mCapsuleStatusArray
= NULL
;
321 mCapsuleTotalNumber
= 0;
325 for (Index
= 0, Index3
= 0; Index
< CapsuleNameCapsuleTotalNumber
; Index
++) {
326 CapsuleNameAddress
= ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr
[Index
], &CapsuleNameNumber
);
327 if (CapsuleNameAddress
!= NULL
) {
328 for (Index2
= 0; Index2
< CapsuleNameNumber
; Index2
++) {
329 mCapsuleNamePtr
[Index3
++] = (CHAR16
*)(UINTN
) CapsuleNameAddress
[Index2
];
334 mCapsuleNamePtr
= NULL
;
337 FreePool (CapsuleNameCapsulePtr
);
341 This function returns if all capsule images are processed.
343 @retval TRUE All capsule images are processed.
344 @retval FALSE Not all capsule images are processed.
347 AreAllImagesProcessed (
353 for (Index
= 0; Index
< mCapsuleTotalNumber
; Index
++) {
354 if (mCapsuleStatusArray
[Index
] == EFI_NOT_READY
) {
363 This function populates capsule in the configuration table.
366 PopulateCapsuleInConfigurationTable (
370 VOID
**CapsulePtrCache
;
371 EFI_GUID
*CapsuleGuidCache
;
372 EFI_CAPSULE_HEADER
*CapsuleHeader
;
373 EFI_CAPSULE_TABLE
*CapsuleTable
;
376 UINT32 CapsuleNumber
;
381 if (mCapsuleTotalNumber
== 0) {
385 CapsulePtrCache
= NULL
;
386 CapsuleGuidCache
= NULL
;
390 CapsulePtrCache
= (VOID
**) AllocateZeroPool (sizeof (VOID
*) * mCapsuleTotalNumber
);
391 if (CapsulePtrCache
== NULL
) {
392 DEBUG ((DEBUG_ERROR
, "Allocate CapsulePtrCache fail!\n"));
395 CapsuleGuidCache
= (EFI_GUID
*) AllocateZeroPool (sizeof (EFI_GUID
) * mCapsuleTotalNumber
);
396 if (CapsuleGuidCache
== NULL
) {
397 DEBUG ((DEBUG_ERROR
, "Allocate CapsuleGuidCache fail!\n"));
398 FreePool (CapsulePtrCache
);
403 // Capsules who have CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE always are used for operating
404 // System to have information persist across a system reset. EFI System Table must
405 // point to an array of capsules that contains the same CapsuleGuid value. And agents
406 // searching for this type capsule will look in EFI System Table and search for the
407 // capsule's Guid and associated pointer to retrieve the data. Two steps below describes
408 // how to sorting the capsules by the unique guid and install the array to EFI System Table.
409 // Firstly, Loop for all coalesced capsules, record unique CapsuleGuids and cache them in an
410 // array for later sorting capsules by CapsuleGuid.
412 for (Index
= 0; Index
< mCapsuleTotalNumber
; Index
++) {
413 CapsuleHeader
= (EFI_CAPSULE_HEADER
*) mCapsulePtr
[Index
];
414 if ((CapsuleHeader
->Flags
& CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE
) != 0) {
416 // For each capsule, we compare it with known CapsuleGuid in the CacheArray.
417 // If already has the Guid, skip it. Whereas, record it in the CacheArray as
418 // an additional one.
421 while (CacheIndex
< CacheNumber
) {
422 if (CompareGuid(&CapsuleGuidCache
[CacheIndex
],&CapsuleHeader
->CapsuleGuid
)) {
427 if (CacheIndex
== CacheNumber
) {
428 CopyMem(&CapsuleGuidCache
[CacheNumber
++],&CapsuleHeader
->CapsuleGuid
,sizeof(EFI_GUID
));
434 // Secondly, for each unique CapsuleGuid in CacheArray, gather all coalesced capsules
435 // whose guid is the same as it, and malloc memory for an array which preceding
436 // with UINT32. The array fills with entry point of capsules that have the same
437 // CapsuleGuid, and UINT32 represents the size of the array of capsules. Then install
438 // this array into EFI System Table, so that agents searching for this type capsule
439 // will look in EFI System Table and search for the capsule's Guid and associated
440 // pointer to retrieve the data.
442 for (CacheIndex
= 0; CacheIndex
< CacheNumber
; CacheIndex
++) {
444 for (Index
= 0; Index
< mCapsuleTotalNumber
; Index
++) {
445 CapsuleHeader
= (EFI_CAPSULE_HEADER
*) mCapsulePtr
[Index
];
446 if ((CapsuleHeader
->Flags
& CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE
) != 0) {
447 if (CompareGuid (&CapsuleGuidCache
[CacheIndex
], &CapsuleHeader
->CapsuleGuid
)) {
449 // Cache Caspuleheader to the array, this array is uniqued with certain CapsuleGuid.
451 CapsulePtrCache
[CapsuleNumber
++] = (VOID
*)CapsuleHeader
;
455 if (CapsuleNumber
!= 0) {
456 Size
= sizeof(EFI_CAPSULE_TABLE
) + (CapsuleNumber
- 1) * sizeof(VOID
*);
457 CapsuleTable
= AllocateRuntimePool (Size
);
458 if (CapsuleTable
== NULL
) {
459 DEBUG ((DEBUG_ERROR
, "Allocate CapsuleTable (%g) fail!\n", &CapsuleGuidCache
[CacheIndex
]));
462 CapsuleTable
->CapsuleArrayNumber
= CapsuleNumber
;
463 CopyMem(&CapsuleTable
->CapsulePtr
[0], CapsulePtrCache
, CapsuleNumber
* sizeof(VOID
*));
464 Status
= gBS
->InstallConfigurationTable (&CapsuleGuidCache
[CacheIndex
], (VOID
*)CapsuleTable
);
465 if (EFI_ERROR (Status
)) {
466 DEBUG ((DEBUG_ERROR
, "InstallConfigurationTable (%g) fail!\n", &CapsuleGuidCache
[CacheIndex
]));
471 FreePool(CapsuleGuidCache
);
472 FreePool(CapsulePtrCache
);
477 This routine is called to process capsules.
479 Caution: This function may receive untrusted input.
481 Each individual capsule result is recorded in capsule record variable.
483 @param[in] FirstRound TRUE: First round. Need skip the FMP capsules with non zero EmbeddedDriverCount.
484 FALSE: Process rest FMP capsules.
486 @retval EFI_SUCCESS There is no error when processing capsules.
487 @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules.
491 ProcessTheseCapsules (
492 IN BOOLEAN FirstRound
496 EFI_CAPSULE_HEADER
*CapsuleHeader
;
498 ESRT_MANAGEMENT_PROTOCOL
*EsrtManagement
;
499 UINT16 EmbeddedDriverCount
;
500 BOOLEAN ResetRequired
;
503 REPORT_STATUS_CODE(EFI_PROGRESS_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesBegin
)));
509 if (mCapsuleTotalNumber
== 0) {
511 // We didn't find a hob, so had no errors.
513 DEBUG ((DEBUG_ERROR
, "We can not find capsule data in capsule update boot mode.\n"));
518 if (AreAllImagesProcessed ()) {
523 // Check the capsule flags,if contains CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE, install
524 // capsuleTable to configure table with EFI_CAPSULE_GUID
527 PopulateCapsuleInConfigurationTable ();
530 REPORT_STATUS_CODE(EFI_PROGRESS_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeUpdatingFirmware
)));
533 // If Windows UX capsule exist, process it first
535 for (Index
= 0; Index
< mCapsuleTotalNumber
; Index
++) {
536 CapsuleHeader
= (EFI_CAPSULE_HEADER
*) mCapsulePtr
[Index
];
537 CapsuleName
= (mCapsuleNamePtr
== NULL
) ? NULL
: mCapsuleNamePtr
[Index
];
538 if (CompareGuid (&CapsuleHeader
->CapsuleGuid
, &gWindowsUxCapsuleGuid
)) {
539 DEBUG ((DEBUG_INFO
, "ProcessThisCapsuleImage (Ux) - 0x%x\n", CapsuleHeader
));
540 DEBUG ((DEBUG_INFO
, "Display logo capsule is found.\n"));
541 Status
= ProcessThisCapsuleImage (CapsuleHeader
, CapsuleName
, NULL
);
542 mCapsuleStatusArray
[Index
] = EFI_SUCCESS
;
543 DEBUG((DEBUG_INFO
, "ProcessThisCapsuleImage (Ux) - %r\n", Status
));
548 DEBUG ((DEBUG_INFO
, "Updating the firmware ......\n"));
551 // All capsules left are recognized by platform.
553 for (Index
= 0; Index
< mCapsuleTotalNumber
; Index
++) {
554 if (mCapsuleStatusArray
[Index
] != EFI_NOT_READY
) {
558 CapsuleHeader
= (EFI_CAPSULE_HEADER
*) mCapsulePtr
[Index
];
559 CapsuleName
= (mCapsuleNamePtr
== NULL
) ? NULL
: mCapsuleNamePtr
[Index
];
560 if (!CompareGuid (&CapsuleHeader
->CapsuleGuid
, &gWindowsUxCapsuleGuid
)) {
562 // Call capsule library to process capsule image.
564 EmbeddedDriverCount
= 0;
565 if (IsFmpCapsule(CapsuleHeader
)) {
566 Status
= ValidateFmpCapsule (CapsuleHeader
, &EmbeddedDriverCount
);
567 if (EFI_ERROR(Status
)) {
568 DEBUG((DEBUG_ERROR
, "ValidateFmpCapsule failed. Ignore!\n"));
569 mCapsuleStatusArray
[Index
] = EFI_ABORTED
;
573 mCapsuleStatusArray
[Index
] = EFI_ABORTED
;
577 if ((!FirstRound
) || (EmbeddedDriverCount
== 0)) {
578 DEBUG((DEBUG_INFO
, "ProcessThisCapsuleImage - 0x%x\n", CapsuleHeader
));
579 ResetRequired
= FALSE
;
580 Status
= ProcessThisCapsuleImage (CapsuleHeader
, CapsuleName
, &ResetRequired
);
581 mCapsuleStatusArray
[Index
] = Status
;
582 DEBUG((DEBUG_INFO
, "ProcessThisCapsuleImage - %r\n", Status
));
584 if (Status
!= EFI_NOT_READY
) {
585 if (EFI_ERROR(Status
)) {
586 REPORT_STATUS_CODE(EFI_ERROR_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed
)));
587 DEBUG ((DEBUG_ERROR
, "Capsule process failed!\n"));
589 REPORT_STATUS_CODE(EFI_PROGRESS_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess
)));
592 mNeedReset
|= ResetRequired
;
593 if ((CapsuleHeader
->Flags
& PcdGet16(PcdSystemRebootAfterCapsuleProcessFlag
)) != 0) {
601 Status
= gBS
->LocateProtocol(&gEsrtManagementProtocolGuid
, NULL
, (VOID
**)&EsrtManagement
);
603 // Always sync ESRT Cache from FMP Instance
605 if (!EFI_ERROR(Status
)) {
606 EsrtManagement
->SyncEsrtFmp();
608 Status
= EFI_SUCCESS
;
610 REPORT_STATUS_CODE(EFI_PROGRESS_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesEnd
)));
623 DEBUG((DEBUG_INFO
, "Capsule Request Cold Reboot."));
625 REPORT_STATUS_CODE(EFI_PROGRESS_CODE
, (EFI_SOFTWARE
| PcdGet32(PcdStatusCodeSubClassCapsule
) | PcdGet32(PcdCapsuleStatusCodeResettingSystem
)));
627 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
634 This routine is called to process capsules.
636 Caution: This function may receive untrusted input.
638 The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.
639 If there is no EFI_HOB_UEFI_CAPSULE, it means error occurs, force reset to
642 This routine should be called twice in BDS.
643 1) The first call must be before EndOfDxe. The system capsules is processed.
644 If device capsule FMP protocols are exposted at this time and device FMP
645 capsule has zero EmbeddedDriverCount, the device capsules are processed.
646 Each individual capsule result is recorded in capsule record variable.
647 System may reset in this function, if reset is required by capsule and
648 all capsules are processed.
649 If not all capsules are processed, reset will be defered to second call.
651 2) The second call must be after EndOfDxe and after ConnectAll, so that all
652 device capsule FMP protocols are exposed.
653 The system capsules are skipped. If the device capsules are NOT processed
654 in first call, they are processed here.
655 Each individual capsule result is recorded in capsule record variable.
656 System may reset in this function, if reset is required by capsule
657 processed in first call and second call.
659 @retval EFI_SUCCESS There is no error when processing capsules.
660 @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules.
671 if (!mDxeCapsuleLibEndOfDxe
) {
672 Status
= ProcessTheseCapsules(TRUE
);
675 // Reboot System if and only if all capsule processed.
676 // If not, defer reset to 2nd process.
678 if (mNeedReset
&& AreAllImagesProcessed()) {
682 Status
= ProcessTheseCapsules(FALSE
);
684 // Reboot System if required after all capsule processed