mirror of https://github.com/acidanthera/audk.git
FmpDevicePkg FmpDxe: Lock variables in entrypoint instead of callback
Current code locks variables in PcdFmpDeviceLockEventGuid callback by VariableLock protocol whose interface will be closed at EndOfDxe. So the PcdFmpDeviceLockEventGuid callback needs be executed before the EndOfDxe callback in Variable driver. When PcdFmpDeviceLockEventGuid = gEfiEndOfDxeEventGroupGuid, the callback's execution sequence depends on the callback's TPL and registration sequence. When PcdFmpDeviceLockEventGuid = gEfiEventReadyToBootGuid, the PcdFmpDeviceLockEventGuid callback will be executed after the EndOfDxe callback in Variable driver, the locking will fail. The patch moves the variables locking logic to entrypoint. The patch also moves the IsLockFmpDeviceAtLockEventGuidRequired () checking to entrypoint. The entrypoint's final return status should be better to depend on the return status of RegisterFmpInstaller/InstallFmpInstance, but not gBS->CreateEventEx. So the patch also moves the RegisterFmpInstaller/InstallFmpInstance calling to the end of entrypoint. Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
parent
6ec4d300fe
commit
9e6c4f1527
|
@ -1248,17 +1248,6 @@ FmpDxeLockEventNotify (
|
|||
EFI_STATUS Status;
|
||||
|
||||
if (!mFmpDeviceLocked) {
|
||||
if (IsLockFmpDeviceAtLockEventGuidRequired ()) {
|
||||
//
|
||||
// Lock all UEFI Variables used by this module.
|
||||
//
|
||||
Status = LockAllFmpVariables ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n"));
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "FmpDxe: All variables locked\n"));
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the firmware device
|
||||
//
|
||||
|
@ -1271,9 +1260,6 @@ FmpDxeLockEventNotify (
|
|||
}
|
||||
}
|
||||
mFmpDeviceLocked = TRUE;
|
||||
} else {
|
||||
DEBUG ((DEBUG_VERBOSE, "FmpDxe: Not calling FmpDeviceLock() because mfg mode\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1417,23 +1403,15 @@ FmpDxeEntryPoint (
|
|||
//
|
||||
DetectTestKey ();
|
||||
|
||||
if (IsLockFmpDeviceAtLockEventGuidRequired ()) {
|
||||
//
|
||||
// Register with library the install function so if the library uses
|
||||
// UEFI driver model/driver binding protocol it can install FMP on its device handle
|
||||
// If library is simple lib that does not use driver binding then it should return
|
||||
// unsupported and this will install the FMP instance on the ImageHandle
|
||||
// Lock all UEFI Variables used by this module.
|
||||
//
|
||||
Status = RegisterFmpInstaller (InstallFmpInstance);
|
||||
if (Status == EFI_UNSUPPORTED) {
|
||||
DEBUG ((DEBUG_INFO, "FmpDxe: FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n"));
|
||||
Status = InstallFmpInstance (ImageHandle);
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib registration returned %r. No FMP installed.\n", Status));
|
||||
Status = LockAllFmpVariables ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n", Status));
|
||||
} else {
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"FmpDxe: FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n"
|
||||
));
|
||||
DEBUG ((DEBUG_INFO, "FmpDxe: All variables locked\n"));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1457,9 +1435,31 @@ FmpDxeEntryPoint (
|
|||
&mFmpDeviceLockEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to register for ready to boot. Status = %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to register notification. Status = %r\n", Status));
|
||||
}
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else {
|
||||
DEBUG ((DEBUG_VERBOSE, "FmpDxe: Not registering notification to call FmpDeviceLock() because mfg mode\n"));
|
||||
}
|
||||
|
||||
//
|
||||
// Register with library the install function so if the library uses
|
||||
// UEFI driver model/driver binding protocol it can install FMP on its device handle
|
||||
// If library is simple lib that does not use driver binding then it should return
|
||||
// unsupported and this will install the FMP instance on the ImageHandle
|
||||
//
|
||||
Status = RegisterFmpInstaller (InstallFmpInstance);
|
||||
if (Status == EFI_UNSUPPORTED) {
|
||||
DEBUG ((DEBUG_INFO, "FmpDxe: FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n"));
|
||||
Status = InstallFmpInstance (ImageHandle);
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib registration returned %r. No FMP installed.\n", Status));
|
||||
} else {
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"FmpDxe: FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n"
|
||||
));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue