/** @file
Copyright (c) 2010 - 2011, 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 which accompanies this distribution. The
full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiSmm.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/LockBoxLib.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCommunication.h>
#include <Protocol/SmmAccess2.h>
#include <Guid/SmmLockBox.h>
/**
This function check if the address is in SMRAM.
@param Buffer the buffer address to be checked.
@param Length the buffer length to be checked.
@retval TRUE this address is in SMRAM.
@retval FALSE this address is NOT in SMRAM.
**/
)
{
if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||
return TRUE;
}
}
return FALSE;
}
/**
Dispatch function for SMM lock box save.
@param LockBoxParameterSave parameter of lock box save
**/
)
{
//
// Sanity check
//
if (mLocked) {
return ;
}
//
// Save data
//
Status = SaveLockBox (
);
return ;
}
/**
Dispatch function for SMM lock box set attributes.
@param LockBoxParameterSetAttributes parameter of lock box set attributes
**/
)
{
//
// Sanity check
//
if (mLocked) {
return ;
}
//
// Update data
//
);
return ;
}
/**
Dispatch function for SMM lock box update.
@param LockBoxParameterUpdate parameter of lock box update
**/
)
{
//
// Sanity check
//
if (mLocked) {
return ;
}
//
// Update data
//
Status = UpdateLockBox (
);
return ;
}
/**
Dispatch function for SMM lock box restore.
@param LockBoxParameterRestore parameter of lock box restore
**/
)
{
//
// Sanity check
//
return ;
}
//
// Restore data
//
Status = RestoreLockBox (
NULL,
);
} else {
Status = RestoreLockBox (
);
}
return ;
}
/**
Dispatch function for SMM lock box restore all in place.
@param LockBoxParameterRestoreAllInPlace parameter of lock box restore all in place
**/
)
{
return ;
}
/**
Dispatch function for a Software SMI handler.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the
handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@retval EFI_SUCCESS Command is handled successfully.
**/
)
{
switch (LockBoxParameterHeader->Command) {
break;
break;
break;
SmmLockBoxSetAttributes ((EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)(UINTN)LockBoxParameterHeader);
break;
SmmLockBoxRestoreAllInPlace ((EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)(UINTN)LockBoxParameterHeader);
break;
default:
break;
}
return EFI_SUCCESS;
}
/**
Smm Ready To Lock event notification handler.
It sets a flag indicating that SMRAM has been locked.
@param[in] Protocol Points to the protocol's unique identifier.
@param[in] Interface Points to the interface instance.
@param[in] Handle The handle on which the interface was installed.
@retval EFI_SUCCESS Notification handler runs successfully.
**/
)
{
return EFI_SUCCESS;
}
/**
Entry Point for LockBox SMM driver.
@param[in] ImageHandle Image handle of this driver.
@param[in] SystemTable A Pointer to the EFI System Table.
@retval EFI_SUCEESS
@return Others Some error occurs.
**/
)
{
//
// Get SMRAM information
//
Size = 0;
Size,
(VOID **)&mSmramRanges
);
//
// Register LockBox communication handler
//
);
//
// Register SMM Ready To Lock Protocol notification
//
);
//
// Install NULL to DXE data base as notify
//
ImageHandle = NULL;
);
return Status;
}