]>
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 | |
289b714b | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
83b9662f MK |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <PiPei.h>\r | |
10 | #include <Library/Tpm12CommandLib.h>\r | |
11 | #include <Library/BaseLib.h>\r | |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/Tpm12DeviceLib.h>\r | |
14 | \r | |
15 | #pragma pack(1)\r | |
16 | \r | |
17 | typedef struct {\r | |
18 | TPM_RQU_COMMAND_HDR Hdr;\r | |
19 | TPM_PHYSICAL_PRESENCE PhysicalPresence;\r | |
20 | } TPM_CMD_PHYSICAL_PRESENCE;\r | |
21 | \r | |
22 | #pragma pack()\r | |
23 | \r | |
24 | /**\r | |
25 | Send TSC_PhysicalPresence command to TPM.\r | |
26 | \r | |
27 | @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.\r | |
28 | \r | |
29 | @retval EFI_SUCCESS Operation completed successfully.\r | |
30 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
31 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
32 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
33 | \r | |
34 | **/\r | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | Tpm12PhysicalPresence (\r | |
38 | IN TPM_PHYSICAL_PRESENCE PhysicalPresence\r | |
39 | )\r | |
40 | {\r | |
950a3bc7 | 41 | EFI_STATUS Status;\r |
83b9662f MK |
42 | TPM_CMD_PHYSICAL_PRESENCE Command;\r |
43 | TPM_RSP_COMMAND_HDR Response;\r | |
44 | UINT32 Length;\r | |
45 | \r | |
46 | //\r | |
47 | // send Tpm command TSC_ORD_PhysicalPresence\r | |
48 | //\r | |
49 | Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r | |
50 | Command.Hdr.paramSize = SwapBytes32 (sizeof (Command));\r | |
51 | Command.Hdr.ordinal = SwapBytes32 (TSC_ORD_PhysicalPresence);\r | |
52 | Command.PhysicalPresence = SwapBytes16 (PhysicalPresence);\r | |
53 | Length = sizeof (Response);\r | |
950a3bc7 ZC |
54 | \r |
55 | Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r | |
56 | if (EFI_ERROR (Status)) {\r | |
57 | return Status;\r | |
58 | }\r | |
59 | \r | |
60 | if (SwapBytes32(Response.returnCode) != TPM_SUCCESS) {\r | |
61 | DEBUG ((EFI_D_ERROR, "Tpm12PhysicalPresence: Response Code error! 0x%08x\r\n", SwapBytes32(Response.returnCode)));\r | |
62 | return EFI_DEVICE_ERROR;\r | |
63 | }\r | |
64 | \r | |
65 | return EFI_SUCCESS;\r | |
83b9662f | 66 | }\r |