]>
Commit | Line | Data |
---|---|---|
83b9662f MK |
1 | /** @file\r |
2 | Implement TPM1.2 Physical Presence related command.\r | |
3 | \r | |
4 | Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>\r | |
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 <PiPei.h>\r | |
16 | #include <Library/Tpm12CommandLib.h>\r | |
17 | #include <Library/BaseLib.h>\r | |
18 | #include <Library/DebugLib.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_PHYSICAL_PRESENCE PhysicalPresence;\r | |
26 | } TPM_CMD_PHYSICAL_PRESENCE;\r | |
27 | \r | |
28 | #pragma pack()\r | |
29 | \r | |
30 | /**\r | |
31 | Send TSC_PhysicalPresence command to TPM.\r | |
32 | \r | |
33 | @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.\r | |
34 | \r | |
35 | @retval EFI_SUCCESS Operation completed successfully.\r | |
36 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
37 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
38 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
39 | \r | |
40 | **/\r | |
41 | EFI_STATUS\r | |
42 | EFIAPI\r | |
43 | Tpm12PhysicalPresence (\r | |
44 | IN TPM_PHYSICAL_PRESENCE PhysicalPresence\r | |
45 | )\r | |
46 | {\r | |
950a3bc7 | 47 | EFI_STATUS Status;\r |
83b9662f MK |
48 | TPM_CMD_PHYSICAL_PRESENCE Command;\r |
49 | TPM_RSP_COMMAND_HDR Response;\r | |
50 | UINT32 Length;\r | |
51 | \r | |
52 | //\r | |
53 | // send Tpm command TSC_ORD_PhysicalPresence\r | |
54 | //\r | |
55 | Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r | |
56 | Command.Hdr.paramSize = SwapBytes32 (sizeof (Command));\r | |
57 | Command.Hdr.ordinal = SwapBytes32 (TSC_ORD_PhysicalPresence);\r | |
58 | Command.PhysicalPresence = SwapBytes16 (PhysicalPresence);\r | |
59 | Length = sizeof (Response);\r | |
950a3bc7 ZC |
60 | \r |
61 | Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r | |
62 | if (EFI_ERROR (Status)) {\r | |
63 | return Status;\r | |
64 | }\r | |
65 | \r | |
66 | if (SwapBytes32(Response.returnCode) != TPM_SUCCESS) {\r | |
67 | DEBUG ((EFI_D_ERROR, "Tpm12PhysicalPresence: Response Code error! 0x%08x\r\n", SwapBytes32(Response.returnCode)));\r | |
68 | return EFI_DEVICE_ERROR;\r | |
69 | }\r | |
70 | \r | |
71 | return EFI_SUCCESS;\r | |
83b9662f | 72 | }\r |