SecurityPkg/Tpm12CommandLib: Add TPM 1.2 commands used by TCG modules

Add the following APIs that are required by TcgPei and/or TcgDxe to
the Tpm12CommandLib instance:
  Tpm12Extend()
  Tpm12PhysicalPresence()
  Tpm12ContinueSelfTest()
  Tpm12GetCapabilityFlagPermanent()
  Tpm12GetCapabilityFlagVolatile()

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@19727 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Michael Kinney
2016-01-21 19:30:05 +00:00
committed by mdkinney
parent e7c83012fd
commit 83b9662fb0
8 changed files with 441 additions and 187 deletions

View File

@@ -12,24 +12,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <IndustryStandard/Tpm12.h>
#include <PiPei.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseLib.h>
#include <Library/Tpm12DeviceLib.h>
#pragma pack(1)
typedef struct {
TPM_RQU_COMMAND_HDR Hdr;
} TPM_CMD_FORCE_CLEAR;
typedef struct {
TPM_RSP_COMMAND_HDR Hdr;
} TPM_RSP_FORCE_CLEAR;
#pragma pack()
/**
Send ForceClear command to TPM1.2.
@@ -42,28 +29,24 @@ Tpm12ForceClear (
VOID
)
{
EFI_STATUS Status;
UINT32 TpmRecvSize;
UINT32 TpmSendSize;
TPM_CMD_FORCE_CLEAR SendBuffer;
TPM_RSP_FORCE_CLEAR RecvBuffer;
UINT32 ReturnCode;
EFI_STATUS Status;
TPM_RQU_COMMAND_HDR Command;
TPM_RSP_COMMAND_HDR Response;
UINT32 Length;
//
// send Tpm command TPM_ORD_ForceClear
//
TpmRecvSize = sizeof (TPM_RSP_FORCE_CLEAR);
TpmSendSize = sizeof (TPM_CMD_FORCE_CLEAR);
SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_ForceClear);
Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
Command.paramSize = SwapBytes32 (sizeof (Command));
Command.ordinal = SwapBytes32 (TPM_ORD_ForceClear);
Length = sizeof (Response);
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer);
Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
if (EFI_ERROR (Status)) {
return Status;
}
ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode);
switch (ReturnCode) {
switch (SwapBytes32 (Response.returnCode)) {
case TPM_SUCCESS:
return EFI_SUCCESS;
default: