2 Implement TPM1.2 Get Capabilities related commands.
4 Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/Tpm12CommandLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/Tpm12DeviceLib.h>
25 TPM_RQU_COMMAND_HDR Hdr
;
27 UINT32 CapabilityFlagSize
;
28 UINT32 CapabilityFlag
;
29 } TPM_CMD_GET_CAPABILITY
;
32 TPM_RSP_COMMAND_HDR Hdr
;
34 TPM_PERMANENT_FLAGS Flags
;
35 } TPM_RSP_GET_CAPABILITY_PERMANENT_FLAGS
;
38 TPM_RSP_COMMAND_HDR Hdr
;
40 TPM_STCLEAR_FLAGS Flags
;
41 } TPM_RSP_GET_CAPABILITY_STCLEAR_FLAGS
;
46 Get TPM capability permanent flags.
48 @param[out] TpmPermanentFlags Pointer to the buffer for returned flag structure.
50 @retval EFI_SUCCESS Operation completed successfully.
51 @retval EFI_TIMEOUT The register can't run into the expected status in time.
52 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
53 @retval EFI_DEVICE_ERROR Unexpected device behavior.
58 Tpm12GetCapabilityFlagPermanent (
59 OUT TPM_PERMANENT_FLAGS
*TpmPermanentFlags
63 TPM_CMD_GET_CAPABILITY Command
;
64 TPM_RSP_GET_CAPABILITY_PERMANENT_FLAGS Response
;
68 // send Tpm command TPM_ORD_GetCapability
70 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
71 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
72 Command
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_GetCapability
);
73 Command
.Capability
= SwapBytes32 (TPM_CAP_FLAG
);
74 Command
.CapabilityFlagSize
= SwapBytes32 (sizeof (TPM_CAP_FLAG_PERMANENT
));
75 Command
.CapabilityFlag
= SwapBytes32 (TPM_CAP_FLAG_PERMANENT
);
76 Length
= sizeof (Response
);
77 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
78 if (EFI_ERROR (Status
)) {
82 ZeroMem (TpmPermanentFlags
, sizeof (*TpmPermanentFlags
));
83 CopyMem (TpmPermanentFlags
, &Response
.Flags
, MIN (sizeof (*TpmPermanentFlags
), Response
.ResponseSize
));
89 Get TPM capability volatile flags.
91 @param[out] VolatileFlags Pointer to the buffer for returned flag structure.
93 @retval EFI_SUCCESS Operation completed successfully.
94 @retval EFI_DEVICE_ERROR The command was unsuccessful.
99 Tpm12GetCapabilityFlagVolatile (
100 OUT TPM_STCLEAR_FLAGS
*VolatileFlags
104 TPM_CMD_GET_CAPABILITY Command
;
105 TPM_RSP_GET_CAPABILITY_STCLEAR_FLAGS Response
;
109 // send Tpm command TPM_ORD_GetCapability
111 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
112 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
113 Command
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_GetCapability
);
114 Command
.Capability
= SwapBytes32 (TPM_CAP_FLAG
);
115 Command
.CapabilityFlagSize
= SwapBytes32 (sizeof (TPM_CAP_FLAG_VOLATILE
));
116 Command
.CapabilityFlag
= SwapBytes32 (TPM_CAP_FLAG_VOLATILE
);
117 Length
= sizeof (Response
);
118 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
119 if (EFI_ERROR (Status
)) {
123 ZeroMem (VolatileFlags
, sizeof (*VolatileFlags
));
124 CopyMem (VolatileFlags
, &Response
.Flags
, MIN (sizeof (*VolatileFlags
), Response
.ResponseSize
));