FmpDevicePkg FmpDxe: Lock variables in entrypoint instead of callback
authorStar Zeng <star.zeng@intel.com>
Tue, 7 Aug 2018 10:01:12 +0000 (18:01 +0800)
committerStar Zeng <star.zeng@intel.com>
Wed, 8 Aug 2018 11:18:29 +0000 (19:18 +0800)
commit9e6c4f1527e6f72d6ada10aa39854f2bdd40772f
tree52a6c37d58143c87f5292fafb5938700dab92ad2
parent6ec4d300fe5929a43b9118adc80aa909f61ab665
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>
FmpDevicePkg/FmpDxe/FmpDxe.c