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