2 Implement TPM1.2 Physical Presence related command.
4 Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/Tpm12CommandLib.h>
11 #include <Library/BaseLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/Tpm12DeviceLib.h>
18 TPM_RQU_COMMAND_HDR Hdr
;
19 TPM_PHYSICAL_PRESENCE PhysicalPresence
;
20 } TPM_CMD_PHYSICAL_PRESENCE
;
25 Send TSC_PhysicalPresence command to TPM.
27 @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.
29 @retval EFI_SUCCESS Operation completed successfully.
30 @retval EFI_TIMEOUT The register can't run into the expected status in time.
31 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
32 @retval EFI_DEVICE_ERROR Unexpected device behavior.
37 Tpm12PhysicalPresence (
38 IN TPM_PHYSICAL_PRESENCE PhysicalPresence
42 TPM_CMD_PHYSICAL_PRESENCE Command
;
43 TPM_RSP_COMMAND_HDR Response
;
47 // send Tpm command TSC_ORD_PhysicalPresence
49 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
50 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
51 Command
.Hdr
.ordinal
= SwapBytes32 (TSC_ORD_PhysicalPresence
);
52 Command
.PhysicalPresence
= SwapBytes16 (PhysicalPresence
);
53 Length
= sizeof (Response
);
55 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
56 if (EFI_ERROR (Status
)) {
60 if (SwapBytes32 (Response
.returnCode
) != TPM_SUCCESS
) {
61 DEBUG ((DEBUG_ERROR
, "Tpm12PhysicalPresence: Response Code error! 0x%08x\r\n", SwapBytes32 (Response
.returnCode
)));
62 return EFI_DEVICE_ERROR
;