OvmfPkg: Install LockBox protocol in constructor of LockBoxDxeLib

Currently, the LockBox protocol is installed in entrypoint of
OVMF AcpiS3SaveDxe.

We can let the first driver run with LockBoxDxeLib linked to have its
library constructor to install LockBox protocol on the ImageHandle.
As other drivers may have gEfiLockBoxProtocolGuid dependency,
the first driver should run before them.

The later patches to retire AcpiS3SaveDxe for OVMF depends on this patch.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Star Zeng
2016-04-07 18:19:24 +08:00
committed by Laszlo Ersek
parent a1726e3089
commit 522e17544f
4 changed files with 36 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
/** @file
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,8 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Protocol/LockBox.h>
#include <LockBoxLib.h>
/**
@@ -115,5 +117,30 @@ LockBoxDxeLibInitialize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return LockBoxLibInitialize ();
EFI_STATUS Status;
VOID *Interface;
Status = LockBoxLibInitialize ();
if (!EFI_ERROR (Status)) {
if (QemuFwCfgS3Enabled ()) {
//
// When S3 enabled, the first driver run with this library linked will
// have this library constructor to install LockBox protocol on the
// ImageHandle. As other drivers may have gEfiLockBoxProtocolGuid
// dependency, the first driver should run before them.
//
Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface);
if (EFI_ERROR (Status)) {
Status = gBS->InstallProtocolInterface (
&ImageHandle,
&gEfiLockBoxProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
ASSERT_EFI_ERROR (Status);
}
}
}
return Status;
}