]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c
SecurityPkg: Fix bug in TPM 1.2 SelfTest
[mirror_edk2.git] / SecurityPkg / Library / Tpm12CommandLib / Tpm12PhysicalPresence.c
CommitLineData
83b9662f
MK
1/** @file\r
2 Implement TPM1.2 Physical Presence related command.\r
3\r
4Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
23typedef 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
31Send 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
41EFI_STATUS\r
42EFIAPI\r
43Tpm12PhysicalPresence (\r
44 IN TPM_PHYSICAL_PRESENCE PhysicalPresence\r
45 )\r
46{\r
47 TPM_CMD_PHYSICAL_PRESENCE Command;\r
48 TPM_RSP_COMMAND_HDR Response;\r
49 UINT32 Length;\r
50\r
51 //\r
52 // send Tpm command TSC_ORD_PhysicalPresence\r
53 //\r
54 Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
55 Command.Hdr.paramSize = SwapBytes32 (sizeof (Command));\r
56 Command.Hdr.ordinal = SwapBytes32 (TSC_ORD_PhysicalPresence);\r
57 Command.PhysicalPresence = SwapBytes16 (PhysicalPresence);\r
58 Length = sizeof (Response);\r
59 return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r
60}\r