diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-01-03 19:28:24 +0100 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-01-16 20:10:51 +0100 |
commit | a855f63e2fdd990837391b0e61e78b3f06b56916 (patch) | |
tree | 55ced87ffaa58b6a28fc2694a0b4007c11c2d315 /MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | |
parent | d0def00d33fa5d4a70c427dfc9a36d826b42967d (diff) | |
download | edk2-a855f63e2fdd990837391b0e61e78b3f06b56916.tar.gz edk2-a855f63e2fdd990837391b0e61e78b3f06b56916.tar.bz2 edk2-a855f63e2fdd990837391b0e61e78b3f06b56916.zip |
MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
In preparation of providing a standalone MM based variable runtime
driver, move the existing SMM driver to the new MM services table,
and factor out some pieces that are specific to the traditional
driver, mainly related to the use of UEFI boot services, which are
not accessible to standalone MM drivers.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c')
-rw-r--r-- | MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 8c53f84ff6..5aa70d7416 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c @@ -15,6 +15,7 @@ SmmVariableGetStatistics() should also do validation based on its own knowledge.
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -28,18 +29,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/SmmVariable.h>
#include <Protocol/SmmFirmwareVolumeBlock.h>
#include <Protocol/SmmFaultTolerantWrite.h>
-#include <Protocol/SmmEndOfDxe.h>
+#include <Protocol/MmEndOfDxe.h>
#include <Protocol/SmmVarCheck.h>
-#include <Library/SmmServicesTableLib.h>
-#include <Library/SmmMemLib.h>
+#include <Library/MmServicesTableLib.h>
#include <Guid/SmmVariableCommon.h>
#include "Variable.h"
extern VARIABLE_INFO_ENTRY *gVariableInfo;
-EFI_HANDLE mSmmVariableHandle = NULL;
-EFI_HANDLE mVariableHandle = NULL;
BOOLEAN mAtRuntime = FALSE;
UINT8 *mVariableBufferPayload = NULL;
UINTN mVariableBufferPayloadSize;
@@ -218,7 +216,7 @@ GetFtwProtocol ( //
// Locate Smm Fault Tolerent Write protocol
//
- Status = gSmst->SmmLocateProtocol (
+ Status = gMmst->MmLocateProtocol (
&gEfiSmmFaultTolerantWriteProtocolGuid,
NULL,
FtwProtocol
@@ -248,7 +246,7 @@ GetFvbByHandle ( //
// To get the SMM FVB protocol interface on the handle
//
- return gSmst->SmmHandleProtocol (
+ return gMmst->MmHandleProtocol (
FvBlockHandle,
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
(VOID **) FvBlock
@@ -287,7 +285,7 @@ GetFvbCountAndBuffer ( BufferSize = 0;
*NumberHandles = 0;
*Buffer = NULL;
- Status = gSmst->SmmLocateHandle (
+ Status = gMmst->MmLocateHandle (
ByProtocol,
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
NULL,
@@ -303,7 +301,7 @@ GetFvbCountAndBuffer ( return EFI_OUT_OF_RESOURCES;
}
- Status = gSmst->SmmLocateHandle (
+ Status = gMmst->MmLocateHandle (
ByProtocol,
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
NULL,
@@ -500,7 +498,7 @@ SmmVariableHandler ( return EFI_SUCCESS;
}
- if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ if (!VariableSmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -911,13 +909,7 @@ SmmFtwNotificationEvent ( //
// Notify the variable wrapper driver the variable write service is ready
//
- Status = gBS->InstallProtocolInterface (
- &mSmmVariableHandle,
- &gSmmVariableWriteGuid,
- EFI_NATIVE_INTERFACE,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
+ VariableNotifySmmWriteReady ();
return EFI_SUCCESS;
}
@@ -929,17 +921,13 @@ SmmFtwNotificationEvent ( for variable read and write services being available. It also registers
a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
@retval EFI_SUCCESS Variable service successfully initialized.
**/
EFI_STATUS
EFIAPI
-VariableServiceInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+MmVariableServiceInitialize (
+ VOID
)
{
EFI_STATUS Status;
@@ -957,7 +945,7 @@ VariableServiceInitialize ( // Install the Smm Variable Protocol on a new handle.
//
VariableHandle = NULL;
- Status = gSmst->SmmInstallProtocolInterface (
+ Status = gMmst->MmInstallProtocolInterface (
&VariableHandle,
&gEfiSmmVariableProtocolGuid,
EFI_NATIVE_INTERFACE,
@@ -965,7 +953,7 @@ VariableServiceInitialize ( );
ASSERT_EFI_ERROR (Status);
- Status = gSmst->SmmInstallProtocolInterface (
+ Status = gMmst->MmInstallProtocolInterface (
&VariableHandle,
&gEdkiiSmmVarCheckProtocolGuid,
EFI_NATIVE_INTERFACE,
@@ -976,7 +964,7 @@ VariableServiceInitialize ( mVariableBufferPayloadSize = GetMaxVariableSize () +
OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - GetVariableHeaderSize ();
- Status = gSmst->SmmAllocatePool (
+ Status = gMmst->MmAllocatePool (
EfiRuntimeServicesData,
mVariableBufferPayloadSize,
(VOID **)&mVariableBufferPayload
@@ -987,25 +975,19 @@ VariableServiceInitialize ( /// Register SMM variable SMI handler
///
VariableHandle = NULL;
- Status = gSmst->SmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
+ Status = gMmst->MmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
ASSERT_EFI_ERROR (Status);
//
// Notify the variable wrapper driver the variable service is ready
//
- Status = SystemTable->BootServices->InstallProtocolInterface (
- &mVariableHandle,
- &gEfiSmmVariableProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &gSmmVariable
- );
- ASSERT_EFI_ERROR (Status);
+ VariableNotifySmmReady ();
//
// Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
//
- Status = gSmst->SmmRegisterProtocolNotify (
- &gEfiSmmEndOfDxeProtocolGuid,
+ Status = gMmst->MmRegisterProtocolNotify (
+ &gEfiMmEndOfDxeProtocolGuid,
SmmEndOfDxeCallback,
&SmmEndOfDxeRegistration
);
@@ -1014,7 +996,7 @@ VariableServiceInitialize ( //
// Register FtwNotificationEvent () notify function.
//
- Status = gSmst->SmmRegisterProtocolNotify (
+ Status = gMmst->MmRegisterProtocolNotify (
&gEfiSmmFaultTolerantWriteProtocolGuid,
SmmFtwNotificationEvent,
&SmmFtwRegistration
|