1 /** @file 2 Implement TPM1.2 Ownership related command. 3 4 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved. <BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #include <Uefi.h> 16 #include <IndustryStandard/Tpm12.h> 17 #include <Library/BaseMemoryLib.h> 18 #include <Library/BaseLib.h> 19 #include <Library/Tpm12DeviceLib.h> 20 21 #pragma pack(1) 22 23 typedef struct { 24 TPM_RQU_COMMAND_HDR Hdr; 25 } TPM_CMD_FORCE_CLEAR; 26 27 typedef struct { 28 TPM_RSP_COMMAND_HDR Hdr; 29 } TPM_RSP_FORCE_CLEAR; 30 31 #pragma pack() 32 33 /** 34 Send ForceClear command to TPM1.2. 35 36 @retval EFI_SUCCESS Operation completed successfully. 37 @retval EFI_DEVICE_ERROR Unexpected device behavior. 38 **/ 39 EFI_STATUS 40 EFIAPI Tpm12ForceClear(VOID)41Tpm12ForceClear ( 42 VOID 43 ) 44 { 45 EFI_STATUS Status; 46 UINT32 TpmRecvSize; 47 UINT32 TpmSendSize; 48 TPM_CMD_FORCE_CLEAR SendBuffer; 49 TPM_RSP_FORCE_CLEAR RecvBuffer; 50 UINT32 ReturnCode; 51 52 // 53 // send Tpm command TPM_ORD_ForceClear 54 // 55 TpmRecvSize = sizeof (TPM_RSP_FORCE_CLEAR); 56 TpmSendSize = sizeof (TPM_CMD_FORCE_CLEAR); 57 SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND); 58 SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize); 59 SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_ForceClear); 60 61 Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer); 62 if (EFI_ERROR (Status)) { 63 return Status; 64 } 65 ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode); 66 switch (ReturnCode) { 67 case TPM_SUCCESS: 68 return EFI_SUCCESS; 69 default: 70 return EFI_DEVICE_ERROR; 71 } 72 }