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

@ -6,7 +6,7 @@
End-of-Dxe event. End-of-Dxe event.
Copyright (c) 2014-2015, Red Hat, Inc.<BR> Copyright (c) 2014-2015, Red Hat, Inc.<BR>
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
@ -28,12 +28,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/LockBoxLib.h> #include <Library/LockBoxLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Guid/AcpiVariableCompatibility.h> #include <Guid/AcpiVariableCompatibility.h>
#include <Guid/AcpiS3Context.h> #include <Guid/AcpiS3Context.h>
#include <Guid/Acpi.h> #include <Guid/Acpi.h>
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>
#include <Protocol/LockBox.h>
#include <IndustryStandard/Acpi.h> #include <IndustryStandard/Acpi.h>
EFI_GUID mAcpiS3IdtrProfileGuid = { EFI_GUID mAcpiS3IdtrProfileGuid = {
@ -538,15 +536,6 @@ InstallEndOfDxeCallback (
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
if (!FeaturePcdGet (PcdSmmSmramRequire)) {
Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEfiLockBoxProtocolGuid, NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
}
Status = gBS->CreateEventEx ( Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
TPL_CALLBACK, TPL_CALLBACK,

View File

@ -1,7 +1,7 @@
## @file ## @file
# AcpiS3Save module installs EndOfDxe callback to prepare S3 boot data. # AcpiS3Save module installs EndOfDxe callback to prepare S3 boot data.
# #
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials are # This program and the accompanying materials are
# licensed and made available under the terms and conditions of the BSD License # licensed and made available under the terms and conditions of the BSD License
@ -36,7 +36,6 @@
MdeModulePkg/MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses] [LibraryClasses]
PcdLib PcdLib
@ -49,7 +48,6 @@
LockBoxLib LockBoxLib
DebugLib DebugLib
DxeServicesLib DxeServicesLib
QemuFwCfgLib
[Guids] [Guids]
gEfiAcpiVariableGuid # ALWAYS_CONSUMED gEfiAcpiVariableGuid # ALWAYS_CONSUMED
@ -59,7 +57,6 @@
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
[Protocols] [Protocols]
gEfiLockBoxProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLegacyRegion2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED gEfiLegacyRegion2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gFrameworkEfiMpServiceProtocolGuid # PROTOCOL SOMETIMES_CONSUMED gFrameworkEfiMpServiceProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
@ -71,7 +68,6 @@
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize ## CONSUMES gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize ## CONSUMES
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize ## CONSUMES gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire ## CONSUMES
[Depex] [Depex]
gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid

View File

@ -1,6 +1,6 @@
/** @file /** @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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -18,6 +18,8 @@
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Protocol/LockBox.h>
#include <LockBoxLib.h> #include <LockBoxLib.h>
/** /**
@ -115,5 +117,30 @@ LockBoxDxeLibInitialize (
IN EFI_SYSTEM_TABLE *SystemTable 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;
} }

View File

@ -3,7 +3,7 @@
# Library implementing the LockBox interface for OVMF # Library implementing the LockBox interface for OVMF
# #
# Copyright (C) 2013, Red Hat, Inc. # Copyright (C) 2013, Red Hat, Inc.
# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials are licensed and made available # This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this # under the terms and conditions of the BSD License which accompanies this
@ -39,6 +39,10 @@
BaseMemoryLib BaseMemoryLib
DebugLib DebugLib
UefiBootServicesTableLib UefiBootServicesTableLib
QemuFwCfgLib
[Protocols]
gEfiLockBoxProtocolGuid ## SOMETIMES_PRODUCES
[Pcd] [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase