Add TPM1.2 SaveState API.

Signed off by: Yao, Jiewen <Jiewen.yao@intel.com>
Reviewed by: Dong Guo <Gui.dong@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14791 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jyao1 2013-10-21 05:56:07 +00:00 committed by jyao1
parent 22031c4f6b
commit 9318b08eb5
2 changed files with 62 additions and 1 deletions

View File

@ -31,6 +31,18 @@ Tpm12Startup (
IN TPM_STARTUP_TYPE TpmSt IN TPM_STARTUP_TYPE TpmSt
); );
/**
Send SaveState command to TPM1.2.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
**/
EFI_STATUS
EFIAPI
Tpm12SaveState (
VOID
);
/** /**
Send ForceClear command to TPM1.2. Send ForceClear command to TPM1.2.

View File

@ -29,6 +29,14 @@ typedef struct {
TPM_RSP_COMMAND_HDR Hdr; TPM_RSP_COMMAND_HDR Hdr;
} TPM_RSP_START_UP; } TPM_RSP_START_UP;
typedef struct {
TPM_RQU_COMMAND_HDR Hdr;
} TPM_CMD_SAVE_STATE;
typedef struct {
TPM_RSP_COMMAND_HDR Hdr;
} TPM_RSP_SAVE_STATE;
#pragma pack() #pragma pack()
/** /**
@ -76,3 +84,44 @@ Tpm12Startup (
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
} }
/**
Send SaveState command to TPM1.2.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
**/
EFI_STATUS
EFIAPI
Tpm12SaveState (
VOID
)
{
EFI_STATUS Status;
UINT32 TpmRecvSize;
UINT32 TpmSendSize;
TPM_CMD_SAVE_STATE SendBuffer;
TPM_RSP_SAVE_STATE RecvBuffer;
UINT32 ReturnCode;
//
// send Tpm command TPM_ORD_SaveState
//
TpmRecvSize = sizeof (TPM_RSP_SAVE_STATE);
TpmSendSize = sizeof (TPM_CMD_SAVE_STATE);
SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_SaveState);
Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer);
if (EFI_ERROR (Status)) {
return Status;
}
ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode);
switch (ReturnCode) {
case TPM_SUCCESS:
return EFI_SUCCESS;
default:
return EFI_DEVICE_ERROR;
}
}