Enhance Capsule driver to update capsule one by one.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9082 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2009-08-18 01:23:29 +00:00
parent bdb140d76b
commit 409d47b49e

View File

@ -63,6 +63,7 @@ UpdateCapsule (
UINTN ArrayNumber; UINTN ArrayNumber;
EFI_STATUS Status; EFI_STATUS Status;
EFI_CAPSULE_HEADER *CapsuleHeader; EFI_CAPSULE_HEADER *CapsuleHeader;
BOOLEAN NeedReset;
// //
// Capsule Count can't be less than one. // Capsule Count can't be less than one.
@ -70,7 +71,7 @@ UpdateCapsule (
if (CapsuleCount < 1) { if (CapsuleCount < 1) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
NeedReset = FALSE;
CapsuleHeader = NULL; CapsuleHeader = NULL;
for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) { for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
@ -92,27 +93,52 @@ UpdateCapsule (
} }
// //
// Assume that capsules have the same flags on reseting or not. // Walk through all capsules, record whether there is a capsule
// needs reset. And then process capsules which has no reset flag directly.
// //
CapsuleHeader = CapsuleHeaderArray[0]; for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {
CapsuleHeader = CapsuleHeaderArray[ArrayNumber];
//
// Here should be in the boot-time for non-reset capsule image
// Platform specific update for the non-reset capsule image.
//
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) == 0) {
if (EfiAtRuntime ()) {
Status = EFI_UNSUPPORTED;
} else {
Status = ProcessCapsuleImage(CapsuleHeader);
}
if (EFI_ERROR(Status)) {
return Status;
}
} else {
NeedReset = TRUE;
}
}
// //
// Process across reset capsule image. // After launching all capsules who has no reset flag, if no more capsules claims
// for a system reset just return.
// //
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) { if (!NeedReset) {
// return EFI_SUCCESS;
// Check if the platform supports update capsule across a system reset
//
if (!FeaturePcdGet(PcdSupportUpdateCapsuleReset)) {
return EFI_UNSUPPORTED;
} }
// //
// ScatterGatherList is only referenced if the capsules are defined to persist across // ScatterGatherList is only referenced if the capsules are defined to persist across
// system reset. // system reset.
// //
if (ScatterGatherList == (EFI_PHYSICAL_ADDRESS) (UINTN) NULL) { if (ScatterGatherList == (EFI_PHYSICAL_ADDRESS) (UINTN) NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} else { }
//
// Check if the platform supports update capsule across a system reset
//
if (!FeaturePcdGet(PcdSupportUpdateCapsuleReset)) {
return EFI_UNSUPPORTED;
}
// //
// ScatterGatherList is only referenced if the capsules are defined to persist across // ScatterGatherList is only referenced if the capsules are defined to persist across
// system reset. Set its value into NV storage to let pre-boot driver to pick it up // system reset. Set its value into NV storage to let pre-boot driver to pick it up
@ -125,38 +151,8 @@ UpdateCapsule (
sizeof (UINTN), sizeof (UINTN),
(VOID *) &ScatterGatherList (VOID *) &ScatterGatherList
); );
if (Status != EFI_SUCCESS) {
return Status; return Status;
}
//
// Successfully set the capsule image address into EFI variable.
//
return EFI_SUCCESS;
}
}
//
// Process the non-reset capsule image.
//
if (EfiAtRuntime ()) {
//
// Runtime mode doesn't support the non-reset capsule image.
//
return EFI_UNSUPPORTED;
}
//
// Here should be in the boot-time for non-reset capsule image
// Platform specific update for the non-reset capsule image.
//
for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {
Status = ProcessCapsuleImage (CapsuleHeaderArray[ArrayNumber]);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
} }
/** /**