74 OUT UINT16 *EmbeddedDriverCount OPTIONAL
125extern BOOLEAN mDxeCapsuleLibEndOfDxe;
126BOOLEAN mNeedReset =
FALSE;
129CHAR16 **mCapsuleNamePtr;
131UINT32 mCapsuleTotalNumber;
151 IN CHAR16 *CapFileName OPTIONAL,
152 OUT BOOLEAN *ResetRequired OPTIONAL
175 DEBUG ((DEBUG_INFO,
"Update Progress - %d%%\n", Completion));
177 if (Completion > 100) {
178 return EFI_INVALID_PARAMETER;
194 gBS->SetWatchdogTimer (0, 0x0000, 0,
NULL);
196 if (Completion != 100) {
201 DEBUG ((DEBUG_VERBOSE,
"Arm watchdog timer %d seconds\n", Seconds));
202 gBS->SetWatchdogTimer (Seconds, 0x0000, 0,
NULL);
223 UINTN CapsuleNameNumber;
224 UINTN CapsuleNameTotalNumber;
225 UINTN CapsuleNameCapsuleTotalNumber;
226 VOID **CapsuleNameCapsulePtr;
229 CapsuleNameNumber = 0;
230 CapsuleNameTotalNumber = 0;
231 CapsuleNameCapsuleTotalNumber = 0;
232 CapsuleNameCapsulePtr =
NULL;
238 while ((HobPointer.Raw =
GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) !=
NULL) {
240 HobPointer.Header->
HobType = EFI_HOB_TYPE_UNUSED;
243 CapsuleNameCapsuleTotalNumber++;
245 mCapsuleTotalNumber++;
249 HobPointer.Raw = GET_NEXT_HOB (HobPointer);
252 DEBUG ((DEBUG_INFO,
"mCapsuleTotalNumber - 0x%x\n", mCapsuleTotalNumber));
254 if (mCapsuleTotalNumber == 0) {
261 mCapsulePtr = (VOID **)
AllocateZeroPool (
sizeof (VOID *) * mCapsuleTotalNumber);
262 if (mCapsulePtr ==
NULL) {
263 DEBUG ((DEBUG_ERROR,
"Allocate mCapsulePtr fail!\n"));
264 mCapsuleTotalNumber = 0;
269 if (mCapsuleStatusArray ==
NULL) {
270 DEBUG ((DEBUG_ERROR,
"Allocate mCapsuleStatusArray fail!\n"));
273 mCapsuleTotalNumber = 0;
277 SetMemN (mCapsuleStatusArray,
sizeof (
EFI_STATUS) * mCapsuleTotalNumber, EFI_NOT_READY);
279 CapsuleNameCapsulePtr = (VOID **)
AllocateZeroPool (
sizeof (VOID *) * CapsuleNameCapsuleTotalNumber);
280 if (CapsuleNameCapsulePtr ==
NULL) {
281 DEBUG ((DEBUG_ERROR,
"Allocate CapsuleNameCapsulePtr fail!\n"));
285 mCapsuleStatusArray =
NULL;
286 mCapsuleTotalNumber = 0;
296 while ((HobPointer.Raw =
GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) !=
NULL) {
298 CapsuleNameCapsulePtr[Index2++] = (VOID *)(
UINTN)HobPointer.Capsule->
BaseAddress;
303 HobPointer.Raw = GET_NEXT_HOB (HobPointer);
309 for (Index = 0; Index < CapsuleNameCapsuleTotalNumber; Index++) {
311 if (CapsuleNameAddress !=
NULL ) {
312 CapsuleNameTotalNumber += CapsuleNameNumber;
316 if (CapsuleNameTotalNumber == mCapsuleTotalNumber) {
317 mCapsuleNamePtr = (CHAR16 **)
AllocateZeroPool (
sizeof (CHAR16 *) * mCapsuleTotalNumber);
318 if (mCapsuleNamePtr ==
NULL) {
319 DEBUG ((DEBUG_ERROR,
"Allocate mCapsuleNamePtr fail!\n"));
324 mCapsuleStatusArray =
NULL;
325 mCapsuleTotalNumber = 0;
329 for (Index = 0, Index3 = 0; Index < CapsuleNameCapsuleTotalNumber; Index++) {
331 if (CapsuleNameAddress !=
NULL ) {
332 for (Index2 = 0; Index2 < CapsuleNameNumber; Index2++) {
333 mCapsuleNamePtr[Index3++] = (CHAR16 *)(
UINTN)CapsuleNameAddress[Index2];
338 mCapsuleNamePtr =
NULL;
357 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
358 if (mCapsuleStatusArray[Index] == EFI_NOT_READY) {
374 VOID **CapsulePtrCache;
380 UINT32 CapsuleNumber;
385 if (mCapsuleTotalNumber == 0) {
389 CapsulePtrCache =
NULL;
390 CapsuleGuidCache =
NULL;
394 CapsulePtrCache = (VOID **)
AllocateZeroPool (
sizeof (VOID *) * mCapsuleTotalNumber);
395 if (CapsulePtrCache ==
NULL) {
396 DEBUG ((DEBUG_ERROR,
"Allocate CapsulePtrCache fail!\n"));
401 if (CapsuleGuidCache ==
NULL) {
402 DEBUG ((DEBUG_ERROR,
"Allocate CapsuleGuidCache fail!\n"));
417 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
419 if ((CapsuleHeader->
Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {
426 while (CacheIndex < CacheNumber) {
434 if (CacheIndex == CacheNumber) {
449 for (CacheIndex = 0; CacheIndex < CacheNumber; CacheIndex++) {
451 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
453 if ((CapsuleHeader->
Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {
458 CapsulePtrCache[CapsuleNumber++] = (VOID *)CapsuleHeader;
463 if (CapsuleNumber != 0) {
466 if (CapsuleTable ==
NULL) {
467 DEBUG ((DEBUG_ERROR,
"Allocate CapsuleTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));
472 CopyMem (&CapsuleTable->
CapsulePtr[0], CapsulePtrCache, CapsuleNumber * sizeof (VOID *));
473 Status =
gBS->InstallConfigurationTable (&CapsuleGuidCache[CacheIndex], (VOID *)CapsuleTable);
474 if (EFI_ERROR (Status)) {
475 DEBUG ((DEBUG_ERROR,
"InstallConfigurationTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));
501 IN BOOLEAN FirstRound
508 UINT16 EmbeddedDriverCount;
509 BOOLEAN ResetRequired;
518 if (mCapsuleTotalNumber == 0) {
522 DEBUG ((DEBUG_ERROR,
"We can not find capsule data in capsule update boot mode.\n"));
544 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
546 CapsuleName = (mCapsuleNamePtr ==
NULL) ?
NULL : mCapsuleNamePtr[Index];
548 DEBUG ((DEBUG_INFO,
"ProcessThisCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
549 DEBUG ((DEBUG_INFO,
"Display logo capsule is found.\n"));
552 DEBUG ((DEBUG_INFO,
"ProcessThisCapsuleImage (Ux) - %r\n", Status));
557 DEBUG ((DEBUG_INFO,
"Updating the firmware ......\n"));
562 for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
563 if (mCapsuleStatusArray[Index] != EFI_NOT_READY) {
569 CapsuleName = (mCapsuleNamePtr ==
NULL) ?
NULL : mCapsuleNamePtr[Index];
574 EmbeddedDriverCount = 0;
577 if (EFI_ERROR (Status)) {
578 DEBUG ((DEBUG_ERROR,
"ValidateFmpCapsule failed. Ignore!\n"));
579 mCapsuleStatusArray[Index] = EFI_ABORTED;
583 mCapsuleStatusArray[Index] = EFI_ABORTED;
587 if ((!FirstRound) || (EmbeddedDriverCount == 0)) {
588 DEBUG ((DEBUG_INFO,
"ProcessThisCapsuleImage - 0x%x\n", CapsuleHeader));
589 ResetRequired =
FALSE;
591 mCapsuleStatusArray[Index] = Status;
592 DEBUG ((DEBUG_INFO,
"ProcessThisCapsuleImage - %r\n", Status));
594 if (Status != EFI_NOT_READY) {
595 if (EFI_ERROR (Status)) {
597 DEBUG ((DEBUG_ERROR,
"Capsule process failed!\n"));
602 mNeedReset |= ResetRequired;
603 if ((CapsuleHeader->
Flags &
PcdGet16 (PcdSystemRebootAfterCapsuleProcessFlag)) != 0) {
611 Status =
gBS->LocateProtocol (&gEsrtManagementProtocolGuid,
NULL, (VOID **)&EsrtManagement);
615 if (!EFI_ERROR (Status)) {
616 EsrtManagement->SyncEsrtFmp ();
634 DEBUG ((DEBUG_INFO,
"Capsule Request Cold Reboot."));
682 if (!mDxeCapsuleLibEndOfDxe) {
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
VOID *EFIAPI GetHobList(VOID)
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMemN(OUT VOID *Buffer, IN UINTN Length, IN UINTN Value)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
EFI_STATUS EFIAPI DisplayUpdateProgress(IN UINTN Completion, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color OPTIONAL)
EFI_STATUS ValidateFmpCapsule(IN EFI_CAPSULE_HEADER *CapsuleHeader, OUT UINT16 *EmbeddedDriverCount OPTIONAL)
BOOLEAN IsFmpCapsule(IN EFI_CAPSULE_HEADER *CapsuleHeader)
VOID InitCapsulePtr(VOID)
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL * mFmpProgress
EFI_STATUS ProcessTheseCapsules(IN BOOLEAN FirstRound)
BOOLEAN AreAllImagesProcessed(VOID)
EFI_PHYSICAL_ADDRESS * ValidateCapsuleNameCapsuleIntegrity(IN EFI_CAPSULE_HEADER *CapsuleHeader, OUT UINTN *CapsuleNameNum)
BOOLEAN IsCapsuleNameCapsule(IN EFI_CAPSULE_HEADER *CapsuleHeader)
EFI_STATUS EFIAPI ProcessThisCapsuleImage(IN EFI_CAPSULE_HEADER *CapsuleHeader, IN CHAR16 *CapFileName OPTIONAL, OUT BOOLEAN *ResetRequired OPTIONAL)
EFI_STATUS EFIAPI UpdateImageProgress(IN UINTN Completion)
BOOLEAN IsValidCapsuleHeader(IN EFI_CAPSULE_HEADER *CapsuleHeader, IN UINT64 CapsuleSize)
VOID PopulateCapsuleInConfigurationTable(VOID)
EFI_STATUS EFIAPI ProcessCapsules(VOID)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateRuntimePool(IN UINTN AllocationSize)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define REPORT_STATUS_CODE(Type, Value)
#define PcdGet16(TokenName)
#define PcdGet32(TokenName)
#define EFI_PROGRESS_CODE
UINT64 EFI_PHYSICAL_ADDRESS
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ProgressBarForegroundColor
UINT32 CapsuleArrayNumber
EFI_PHYSICAL_ADDRESS BaseAddress