mirror of https://github.com/acidanthera/audk.git
SecurityPkg/TcgPei: Replace TpmCommLib with Tpm12DeviceLib
Update TCG drivers for TPM 1.2 devices to use Tpm12DeviceLib instead of TpmCommLib. This is required to support TPM 1.2 hardware devices that are not on LPC bus. The current versions of the TCG PEIM and DXE driver contain MMIO reads/writes to a TPM attached to an LPC bus. In order to support TPMs that are connected to other bus types, the TGC PEIM and DXE drivers must be updated to not perform any direct register accesses to any TPMs. Cc: Chao Zhang <chao.b.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19721 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8ab970f210
commit
b558f8bceb
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Initialize TPM device and measure FVs before handing off control to DXE.
|
||||
|
||||
Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 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
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -32,7 +32,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/PeimEntryPoint.h>
|
||||
#include <Library/TpmCommLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
|
@ -207,7 +206,6 @@ EndofPeiSignalNotifyCallBack (
|
|||
@param[in] HashData Physical address of the start of the data buffer
|
||||
to be hashed, extended, and logged.
|
||||
@param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
|
||||
@param[in] NewEventData Pointer to the new event data.
|
||||
|
||||
|
@ -221,7 +219,6 @@ HashLogExtendEvent (
|
|||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN UINT8 *HashData,
|
||||
IN UINTN HashDataLen,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN TCG_PCR_EVENT_HDR *NewEventHdr,
|
||||
IN UINT8 *NewEventData
|
||||
)
|
||||
|
@ -247,7 +244,6 @@ HashLogExtendEvent (
|
|||
|
||||
Status = TpmCommExtend (
|
||||
PeiServices,
|
||||
TpmHandle,
|
||||
&NewEventHdr->Digest,
|
||||
NewEventHdr->PCRIndex,
|
||||
NULL
|
||||
|
@ -286,7 +282,6 @@ Done:
|
|||
Measure CRTM version.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
|
||||
|
@ -296,8 +291,7 @@ Done:
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
MeasureCRTMVersion (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle
|
||||
IN EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
TCG_PCR_EVENT_HDR TcgEventHdr;
|
||||
|
@ -315,7 +309,6 @@ MeasureCRTMVersion (
|
|||
PeiServices,
|
||||
(UINT8*)PcdGetPtr (PcdFirmwareVersionString),
|
||||
TcgEventHdr.EventSize,
|
||||
TpmHandle,
|
||||
&TcgEventHdr,
|
||||
(UINT8*)PcdGetPtr (PcdFirmwareVersionString)
|
||||
);
|
||||
|
@ -345,9 +338,6 @@ MeasureFvImage (
|
|||
EFI_STATUS Status;
|
||||
EFI_PLATFORM_FIRMWARE_BLOB FvBlob;
|
||||
TCG_PCR_EVENT_HDR TcgEventHdr;
|
||||
TIS_TPM_HANDLE TpmHandle;
|
||||
|
||||
TpmHandle = (TIS_TPM_HANDLE) (UINTN) TPM_BASE_ADDRESS;
|
||||
|
||||
//
|
||||
// Check if it is in Excluded FV list
|
||||
|
@ -388,7 +378,6 @@ MeasureFvImage (
|
|||
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
|
||||
(UINT8*) (UINTN) FvBlob.BlobBase,
|
||||
(UINTN) FvBlob.BlobLength,
|
||||
TpmHandle,
|
||||
&TcgEventHdr,
|
||||
(UINT8*) &FvBlob
|
||||
);
|
||||
|
@ -410,7 +399,6 @@ MeasureFvImage (
|
|||
Measure main BIOS.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
|
||||
|
@ -420,8 +408,7 @@ MeasureFvImage (
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
MeasureMainBios (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle
|
||||
IN EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
@ -556,12 +543,9 @@ PhysicalPresencePpiNotifyCallback (
|
|||
PEI_LOCK_PHYSICAL_PRESENCE_PPI *LockPhysicalPresencePpi;
|
||||
BOOLEAN LifetimeLock;
|
||||
BOOLEAN CmdEnable;
|
||||
TIS_TPM_HANDLE TpmHandle;
|
||||
TPM_PHYSICAL_PRESENCE PhysicalPresenceValue;
|
||||
|
||||
TpmHandle = (TIS_TPM_HANDLE) (UINTN) TPM_BASE_ADDRESS;
|
||||
|
||||
Status = TpmCommGetCapability (PeiServices, TpmHandle, NULL, &LifetimeLock, &CmdEnable);
|
||||
Status = TpmCommGetCapability (PeiServices, NULL, &LifetimeLock, &CmdEnable);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
@ -591,7 +575,6 @@ PhysicalPresencePpiNotifyCallback (
|
|||
|
||||
Status = TpmCommPhysicalPresence (
|
||||
PeiServices,
|
||||
TpmHandle,
|
||||
PhysicalPresenceValue
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@ -621,7 +604,6 @@ PhysicalPresencePpiNotifyCallback (
|
|||
//
|
||||
Status = TpmCommPhysicalPresence (
|
||||
PeiServices,
|
||||
TpmHandle,
|
||||
TPM_PHYSICAL_PRESENCE_CMD_ENABLE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@ -634,7 +616,6 @@ PhysicalPresencePpiNotifyCallback (
|
|||
//
|
||||
Status = TpmCommPhysicalPresence (
|
||||
PeiServices,
|
||||
TpmHandle,
|
||||
TPM_PHYSICAL_PRESENCE_LOCK
|
||||
);
|
||||
return Status;
|
||||
|
@ -644,7 +625,6 @@ PhysicalPresencePpiNotifyCallback (
|
|||
Check if TPM chip is activeated or not.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
|
||||
@retval TRUE TPM is activated.
|
||||
@retval FALSE TPM is deactivated.
|
||||
|
@ -653,14 +633,13 @@ PhysicalPresencePpiNotifyCallback (
|
|||
BOOLEAN
|
||||
EFIAPI
|
||||
IsTpmUsable (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle
|
||||
IN EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN Deactivated;
|
||||
|
||||
Status = TpmCommGetCapability (PeiServices, TpmHandle, &Deactivated, NULL, NULL);
|
||||
Status = TpmCommGetCapability (PeiServices, &Deactivated, NULL, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -684,7 +663,6 @@ PeimEntryMP (
|
|||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
TIS_TPM_HANDLE TpmHandle;
|
||||
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid,
|
||||
|
@ -699,18 +677,17 @@ PeimEntryMP (
|
|||
mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
|
||||
ASSERT (mMeasuredChildFvInfo != NULL);
|
||||
|
||||
TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS;
|
||||
Status = TisPcRequestUseTpm ((TIS_PC_REGISTERS_PTR)TpmHandle);
|
||||
Status = Tpm12RequestUseTpm ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (IsTpmUsable (PeiServices, TpmHandle)) {
|
||||
if (IsTpmUsable (PeiServices)) {
|
||||
if (PcdGet8 (PcdTpmScrtmPolicy) == 1) {
|
||||
Status = MeasureCRTMVersion (PeiServices, TpmHandle);
|
||||
Status = MeasureCRTMVersion (PeiServices);
|
||||
}
|
||||
|
||||
Status = MeasureMainBios (PeiServices, TpmHandle);
|
||||
Status = MeasureMainBios (PeiServices);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -745,7 +722,6 @@ PeimEntryMA (
|
|||
EFI_STATUS Status;
|
||||
EFI_STATUS Status2;
|
||||
EFI_BOOT_MODE BootMode;
|
||||
TIS_TPM_HANDLE TpmHandle;
|
||||
|
||||
if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
|
||||
DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
|
||||
|
@ -776,15 +752,14 @@ PeimEntryMA (
|
|||
}
|
||||
|
||||
if (!mImageInMemory) {
|
||||
TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS;
|
||||
Status = TisPcRequestUseTpm ((TIS_PC_REGISTERS_PTR)TpmHandle);
|
||||
Status = Tpm12RequestUseTpm ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "TPM not detected!\n"));
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (PcdGet8 (PcdTpmInitializationPolicy) == 1) {
|
||||
Status = TpmCommStartup ((EFI_PEI_SERVICES**)PeiServices, TpmHandle, BootMode);
|
||||
Status = TpmCommStartup ((EFI_PEI_SERVICES**)PeiServices, BootMode);
|
||||
if (EFI_ERROR (Status) ) {
|
||||
goto Done;
|
||||
}
|
||||
|
@ -794,7 +769,7 @@ PeimEntryMA (
|
|||
// TpmSelfTest is optional on S3 path, skip it to save S3 time
|
||||
//
|
||||
if (BootMode != BOOT_ON_S3_RESUME) {
|
||||
Status = TpmCommContinueSelfTest ((EFI_PEI_SERVICES**)PeiServices, TpmHandle);
|
||||
Status = TpmCommContinueSelfTest ((EFI_PEI_SERVICES**)PeiServices);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# This module will initialize TPM device, measure reported FVs and BIOS version.
|
||||
# This module may also lock TPM physical presence and physicalPresenceLifetimeLock.
|
||||
#
|
||||
# Copyright (c) 2006 - 2015, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -34,13 +34,13 @@
|
|||
|
||||
[Sources]
|
||||
TcgPei.c
|
||||
TisPei.c
|
||||
TpmComm.c
|
||||
TpmComm.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
CryptoPkg/CryptoPkg.dec
|
||||
SecurityPkg/SecurityPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
|
@ -49,9 +49,9 @@
|
|||
PeiServicesLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
TpmCommLib
|
||||
BaseCryptLib
|
||||
Tpm12DeviceLib
|
||||
TimerLib
|
||||
IoLib
|
||||
PeiServicesTablePointerLib
|
||||
BaseLib
|
||||
PcdLib
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
/** @file
|
||||
TIS (TPM Interface Specification) functions used by TPM PEI driver.
|
||||
|
||||
Copyright (c) 2005 - 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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 <IndustryStandard/Tpm12.h>
|
||||
#include <IndustryStandard/UefiTcgPlatform.h>
|
||||
#include <Library/TpmCommLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
/**
|
||||
Send a command to TPM for execution and return response data.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TisReg TPM register space base address.
|
||||
@param[in] BufferIn Buffer for command data.
|
||||
@param[in] SizeIn Size of command data.
|
||||
@param[in, out] BufferOut Buffer for response data.
|
||||
@param[in, out] SizeOut Size of response data.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
@retval EFI_DEVICE_ERROR Unexpected device behavior.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
TisTpmCommand (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_PC_REGISTERS_PTR TisReg,
|
||||
IN UINT8 *BufferIn,
|
||||
IN UINT32 SizeIn,
|
||||
IN OUT UINT8 *BufferOut,
|
||||
IN OUT UINT32 *SizeOut
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT16 BurstCount;
|
||||
UINT32 Index;
|
||||
UINT32 TpmOutSize;
|
||||
UINT16 Data16;
|
||||
UINT32 Data32;
|
||||
|
||||
Status = TisPcPrepareCommand (TisReg);
|
||||
if (EFI_ERROR (Status)){
|
||||
DEBUG ((DEBUG_ERROR, "Tpm is not ready for command!\n"));
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Send the command data to Tpm
|
||||
//
|
||||
Index = 0;
|
||||
while (Index < SizeIn) {
|
||||
Status = TisPcReadBurstCount (TisReg, &BurstCount);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_TIMEOUT;
|
||||
goto Exit;
|
||||
}
|
||||
for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {
|
||||
MmioWrite8((UINTN)&TisReg->DataFifo, *(BufferIn + Index));
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check the Tpm status STS_EXPECT change from 1 to 0
|
||||
//
|
||||
Status = TisPcWaitRegisterBits (
|
||||
&TisReg->Status,
|
||||
(UINT8) TIS_PC_VALID,
|
||||
TIS_PC_STS_EXPECT,
|
||||
TIS_TIMEOUT_C
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "The send buffer too small!\n"));
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
// Executed the TPM command and waiting for the response data ready
|
||||
//
|
||||
MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_GO);
|
||||
Status = TisPcWaitRegisterBits (
|
||||
&TisReg->Status,
|
||||
(UINT8) (TIS_PC_VALID | TIS_PC_STS_DATA),
|
||||
0,
|
||||
TIS_TIMEOUT_B
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Wait for Tpm response data time out!!\n"));
|
||||
Status = EFI_TIMEOUT;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
// Get response data header
|
||||
//
|
||||
Index = 0;
|
||||
BurstCount = 0;
|
||||
while (Index < sizeof (TPM_RSP_COMMAND_HDR)) {
|
||||
Status = TisPcReadBurstCount (TisReg, &BurstCount);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_TIMEOUT;
|
||||
goto Exit;
|
||||
}
|
||||
for (; BurstCount > 0; BurstCount--) {
|
||||
*(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
|
||||
Index++;
|
||||
if (Index == sizeof (TPM_RSP_COMMAND_HDR)) break;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check the reponse data header (tag,parasize and returncode )
|
||||
//
|
||||
CopyMem (&Data16, BufferOut, sizeof (UINT16));
|
||||
if (SwapBytes16 (Data16) != TPM_TAG_RSP_COMMAND ) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
CopyMem (&Data32, (BufferOut + 2), sizeof (UINT32));
|
||||
TpmOutSize = SwapBytes32 (Data32);
|
||||
if (*SizeOut < TpmOutSize) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
goto Exit;
|
||||
}
|
||||
*SizeOut = TpmOutSize;
|
||||
//
|
||||
// Continue reading the remaining data
|
||||
//
|
||||
while ( Index < TpmOutSize ) {
|
||||
for (; BurstCount > 0; BurstCount--) {
|
||||
*(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
|
||||
Index++;
|
||||
if (Index == TpmOutSize) {
|
||||
Status = EFI_SUCCESS;
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
Status = TisPcReadBurstCount (TisReg, &BurstCount);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_TIMEOUT;
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
Exit:
|
||||
MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
|
||||
return Status;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Utility functions used by TPM PEI driver.
|
||||
|
||||
Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 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
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -14,38 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include "TpmComm.h"
|
||||
|
||||
/**
|
||||
Send a command to TPM for execution and return response data.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TisReg TPM register space base address.
|
||||
@param[in] BufferIn Buffer for command data.
|
||||
@param[in] SizeIn Size of command data.
|
||||
@param[in, out] BufferOut Buffer for response data.
|
||||
@param[in, out] SizeOut size of response data.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
@retval EFI_DEVICE_ERROR Unexpected device behavior.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
TisTpmCommand (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_PC_REGISTERS_PTR TisReg,
|
||||
IN UINT8 *BufferIn,
|
||||
IN UINT32 SizeIn,
|
||||
IN OUT UINT8 *BufferOut,
|
||||
IN OUT UINT32 *SizeOut
|
||||
);
|
||||
|
||||
/**
|
||||
Send TPM_Startup command to TPM.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[in] BootMode Boot mode.
|
||||
@param[in] BootMode Boot mode.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
|
@ -56,7 +29,6 @@ TisTpmCommand (
|
|||
EFI_STATUS
|
||||
TpmCommStartup (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN EFI_BOOT_MODE BootMode
|
||||
)
|
||||
{
|
||||
|
@ -80,7 +52,7 @@ TpmCommStartup (
|
|||
SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
|
||||
SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_Startup);
|
||||
SendBuffer.TpmSt = SwapBytes16 (TpmSt);
|
||||
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
|
||||
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -88,8 +60,7 @@ TpmCommStartup (
|
|||
Send TPM_ContinueSelfTest command to TPM.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -98,8 +69,7 @@ TpmCommStartup (
|
|||
**/
|
||||
EFI_STATUS
|
||||
TpmCommContinueSelfTest (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle
|
||||
IN EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
@ -116,7 +86,7 @@ TpmCommContinueSelfTest (
|
|||
SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
|
||||
SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
|
||||
SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest);
|
||||
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
|
||||
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -124,11 +94,10 @@ TpmCommContinueSelfTest (
|
|||
Get TPM capability flags.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[out] Deactivated Returns deactivated flag.
|
||||
@param[out] LifetimeLock Returns physicalPresenceLifetimeLock permanent flag.
|
||||
@param[out] CmdEnable Returns physicalPresenceCMDEnable permanent flag.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -138,7 +107,6 @@ TpmCommContinueSelfTest (
|
|||
EFI_STATUS
|
||||
TpmCommGetCapability (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
OUT BOOLEAN *Deactivated, OPTIONAL
|
||||
OUT BOOLEAN *LifetimeLock, OPTIONAL
|
||||
OUT BOOLEAN *CmdEnable OPTIONAL
|
||||
|
@ -162,7 +130,7 @@ TpmCommGetCapability (
|
|||
SendBuffer.Capability = SwapBytes32 (TPM_CAP_FLAG);
|
||||
SendBuffer.CapabilityFlagSize = SwapBytes32 (sizeof (TPM_CAP_FLAG_PERMANENT));
|
||||
SendBuffer.CapabilityFlag = SwapBytes32 (TPM_CAP_FLAG_PERMANENT);
|
||||
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
|
||||
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
@ -185,11 +153,10 @@ TpmCommGetCapability (
|
|||
Extend a TPM PCR.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[in] DigestToExtend The 160 bit value representing the event to be recorded.
|
||||
@param[in] PcrIndex The PCR to be updated.
|
||||
@param[out] NewPcrValue New PCR value after extend.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -199,7 +166,6 @@ TpmCommGetCapability (
|
|||
EFI_STATUS
|
||||
TpmCommExtend (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN TPM_DIGEST *DigestToExtend,
|
||||
IN TPM_PCRINDEX PcrIndex,
|
||||
OUT TPM_DIGEST *NewPcrValue
|
||||
|
@ -221,7 +187,7 @@ TpmCommExtend (
|
|||
SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_Extend);
|
||||
SendBuffer.PcrIndex = SwapBytes32 (PcrIndex);
|
||||
CopyMem (&SendBuffer.TpmDigest, (UINT8 *)DigestToExtend, sizeof (TPM_DIGEST));
|
||||
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
|
||||
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
@ -238,9 +204,8 @@ TpmCommExtend (
|
|||
Send TSC_PhysicalPresence command to TPM.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -250,7 +215,6 @@ TpmCommExtend (
|
|||
EFI_STATUS
|
||||
TpmCommPhysicalPresence (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN TPM_PHYSICAL_PRESENCE PhysicalPresence
|
||||
)
|
||||
{
|
||||
|
@ -269,6 +233,40 @@ TpmCommPhysicalPresence (
|
|||
SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
|
||||
SendBuffer.Hdr.ordinal = SwapBytes32 (TSC_ORD_PhysicalPresence);
|
||||
SendBuffer.PhysicalPresence = SwapBytes16 (PhysicalPresence);
|
||||
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
|
||||
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Single function calculates SHA1 digest value for all raw data. It
|
||||
combines Sha1Init(), Sha1Update() and Sha1Final().
|
||||
|
||||
@param[in] Data Raw data to be digested.
|
||||
@param[in] DataLen Size of the raw data.
|
||||
@param[out] Digest Pointer to a buffer that stores the final digest.
|
||||
|
||||
@retval EFI_SUCCESS Always successfully calculate the final digest.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TpmCommHashAll (
|
||||
IN CONST UINT8 *Data,
|
||||
IN UINTN DataLen,
|
||||
OUT TPM_DIGEST *Digest
|
||||
)
|
||||
{
|
||||
VOID *Sha1Ctx;
|
||||
UINTN CtxSize;
|
||||
|
||||
CtxSize = Sha1GetContextSize ();
|
||||
Sha1Ctx = AllocatePool (CtxSize);
|
||||
ASSERT (Sha1Ctx != NULL);
|
||||
|
||||
Sha1Init (Sha1Ctx);
|
||||
Sha1Update (Sha1Ctx, Data, DataLen);
|
||||
Sha1Final (Sha1Ctx, (UINT8 *)Digest);
|
||||
|
||||
FreePool (Sha1Ctx);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
The header file for TPM PEI driver.
|
||||
|
||||
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2005 - 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
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -17,7 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include <IndustryStandard/Tpm12.h>
|
||||
#include <IndustryStandard/UefiTcgPlatform.h>
|
||||
#include <Library/TpmCommLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseCryptLib.h>
|
||||
#include <Library/Tpm12DeviceLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
@ -57,9 +59,8 @@ typedef struct {
|
|||
Send TPM_Startup command to TPM.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
@param[in] BootMode Boot mode.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -69,7 +70,6 @@ typedef struct {
|
|||
EFI_STATUS
|
||||
TpmCommStartup (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN EFI_BOOT_MODE BootMode
|
||||
);
|
||||
|
||||
|
@ -77,8 +77,7 @@ TpmCommStartup (
|
|||
Send TPM_ContinueSelfTest command to TPM.
|
||||
|
||||
@param[in] PeiServices Describes the list of possible PEI Services.
|
||||
@param[in] TpmHandle TPM handle.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_TIMEOUT The register can't run into the expected status in time.
|
||||
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
|
||||
|
@ -87,8 +86,7 @@ TpmCommStartup (
|
|||
**/
|
||||
EFI_STATUS
|
||||
TpmCommContinueSelfTest (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle
|
||||
IN EFI_PEI_SERVICES **PeiServices
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -109,7 +107,6 @@ TpmCommContinueSelfTest (
|
|||
EFI_STATUS
|
||||
TpmCommGetCapability (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
OUT BOOLEAN *Deactivated, OPTIONAL
|
||||
OUT BOOLEAN *LifetimeLock, OPTIONAL
|
||||
OUT BOOLEAN *CmdEnable OPTIONAL
|
||||
|
@ -133,7 +130,6 @@ TpmCommGetCapability (
|
|||
EFI_STATUS
|
||||
TpmCommExtend (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN TPM_DIGEST *DigestToExtend,
|
||||
IN TPM_PCRINDEX PcrIndex,
|
||||
OUT TPM_DIGEST *NewPcrValue
|
||||
|
@ -156,8 +152,25 @@ TpmCommExtend (
|
|||
EFI_STATUS
|
||||
TpmCommPhysicalPresence (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN TIS_TPM_HANDLE TpmHandle,
|
||||
IN TPM_PHYSICAL_PRESENCE PhysicalPresence
|
||||
);
|
||||
|
||||
/**
|
||||
Single function calculates SHA1 digest value for all raw data. It
|
||||
combines Sha1Init(), Sha1Update() and Sha1Final().
|
||||
|
||||
@param[in] Data Raw data to be digested.
|
||||
@param[in] DataLen Size of the raw data.
|
||||
@param[out] Digest Pointer to a buffer that stores the final digest.
|
||||
|
||||
@retval EFI_SUCCESS Always successfully calculate the final digest.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TpmCommHashAll (
|
||||
IN CONST UINT8 *Data,
|
||||
IN UINTN DataLen,
|
||||
OUT TPM_DIGEST *Digest
|
||||
);
|
||||
|
||||
#endif // _TPM_COMM_H_
|
||||
|
|
Loading…
Reference in New Issue