Revision: 14791
          http://sourceforge.net/p/edk2/code/14791
Author:   jyao1
Date:     2013-10-21 05:56:07 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
Add TPM1.2 SaveState API.

Signed off by: Yao, Jiewen <[email protected]>
Reviewed by: Dong Guo <[email protected]>

Modified Paths:
--------------
    trunk/edk2/SecurityPkg/Include/Library/Tpm12CommandLib.h
    trunk/edk2/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c

Modified: trunk/edk2/SecurityPkg/Include/Library/Tpm12CommandLib.h
===================================================================
--- trunk/edk2/SecurityPkg/Include/Library/Tpm12CommandLib.h    2013-10-21 
05:22:01 UTC (rev 14790)
+++ trunk/edk2/SecurityPkg/Include/Library/Tpm12CommandLib.h    2013-10-21 
05:56:07 UTC (rev 14791)
@@ -32,6 +32,18 @@
   );
 
 /**
+  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.
 
   @retval EFI_SUCCESS      Operation completed successfully.

Modified: trunk/edk2/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
===================================================================
--- trunk/edk2/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c       
2013-10-21 05:22:01 UTC (rev 14790)
+++ trunk/edk2/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c       
2013-10-21 05:56:07 UTC (rev 14791)
@@ -29,6 +29,14 @@
   TPM_RSP_COMMAND_HDR   Hdr;
 } 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()
 
 /**
@@ -75,4 +83,45 @@
   default:
     return EFI_DEVICE_ERROR;
   }
-}
\ No newline at end of file
+}
+
+/**
+  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;
+  }
+}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to