• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   This library is used by other modules to send TPM12 command.
3 
4 Copyright (c) 2013 - 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
9 
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.
12 
13 **/
14 
15 #ifndef _TPM12_COMMAND_LIB_H_
16 #define _TPM12_COMMAND_LIB_H_
17 
18 #include <IndustryStandard/Tpm12.h>
19 
20 /**
21   Send Startup command to TPM1.2.
22 
23   @param TpmSt           Startup Type.
24 
25   @retval EFI_SUCCESS      Operation completed successfully.
26   @retval EFI_DEVICE_ERROR Unexpected device behavior.
27 **/
28 EFI_STATUS
29 EFIAPI
30 Tpm12Startup (
31   IN TPM_STARTUP_TYPE          TpmSt
32   );
33 
34 /**
35   Send SaveState command to TPM1.2.
36 
37   @retval EFI_SUCCESS      Operation completed successfully.
38   @retval EFI_DEVICE_ERROR Unexpected device behavior.
39 **/
40 EFI_STATUS
41 EFIAPI
42 Tpm12SaveState (
43   VOID
44   );
45 
46 /**
47   Send ForceClear command to TPM1.2.
48 
49   @retval EFI_SUCCESS      Operation completed successfully.
50   @retval EFI_DEVICE_ERROR Unexpected device behavior.
51 **/
52 EFI_STATUS
53 EFIAPI
54 Tpm12ForceClear (
55   VOID
56   );
57 
58 #pragma pack(1)
59 
60 typedef struct {
61   UINT16                            sizeOfSelect;
62   UINT8                             pcrSelect[3];
63 } TPM12_PCR_SELECTION;
64 
65 typedef struct {
66   TPM12_PCR_SELECTION               pcrSelection;
67   TPM_LOCALITY_SELECTION            localityAtRelease;
68   TPM_COMPOSITE_HASH                digestAtRelease;
69 } TPM12_PCR_INFO_SHORT;
70 
71 typedef struct {
72   TPM_STRUCTURE_TAG               tag;
73   TPM_NV_INDEX                    nvIndex;
74   TPM12_PCR_INFO_SHORT            pcrInfoRead;
75   TPM12_PCR_INFO_SHORT            pcrInfoWrite;
76   TPM_NV_ATTRIBUTES               permission;
77   BOOLEAN                         bReadSTClear;
78   BOOLEAN                         bWriteSTClear;
79   BOOLEAN                         bWriteDefine;
80   UINT32                          dataSize;
81 } TPM12_NV_DATA_PUBLIC;
82 
83 #pragma pack()
84 
85 /**
86   Send NV DefineSpace command to TPM1.2.
87 
88   @param PubInfo           The public parameters of the NV area.
89   @param EncAuth           The encrypted AuthData, only valid if the attributes require subsequent authorization.
90 
91   @retval EFI_SUCCESS      Operation completed successfully.
92   @retval EFI_DEVICE_ERROR Unexpected device behavior.
93 **/
94 EFI_STATUS
95 EFIAPI
96 Tpm12NvDefineSpace (
97   IN TPM12_NV_DATA_PUBLIC  *PubInfo,
98   IN TPM_ENCAUTH           *EncAuth
99   );
100 
101 /**
102   Send NV ReadValue command to TPM1.2.
103 
104   @param NvIndex           The index of the area to set.
105   @param Offset            The offset into the area.
106   @param DataSize          The size of the data area.
107   @param Data              The data to set the area to.
108 
109   @retval EFI_SUCCESS      Operation completed successfully.
110   @retval EFI_DEVICE_ERROR Unexpected device behavior.
111 **/
112 EFI_STATUS
113 EFIAPI
114 Tpm12NvReadValue (
115   IN TPM_NV_INDEX   NvIndex,
116   IN UINT32         Offset,
117   IN OUT UINT32     *DataSize,
118   OUT UINT8         *Data
119   );
120 
121 /**
122   Send NV WriteValue command to TPM1.2.
123 
124   @param NvIndex           The index of the area to set.
125   @param Offset            The offset into the NV Area.
126   @param DataSize          The size of the data parameter.
127   @param Data              The data to set the area to.
128 
129   @retval EFI_SUCCESS      Operation completed successfully.
130   @retval EFI_DEVICE_ERROR Unexpected device behavior.
131 **/
132 EFI_STATUS
133 EFIAPI
134 Tpm12NvWriteValue (
135   IN TPM_NV_INDEX   NvIndex,
136   IN UINT32         Offset,
137   IN UINT32         DataSize,
138   IN UINT8          *Data
139   );
140 
141 /**
142 Extend a TPM PCR.
143 
144 @param[in]  DigestToExtend    The 160 bit value representing the event to be recorded.
145 @param[in]  PcrIndex          The PCR to be updated.
146 @param[out] NewPcrValue       New PCR value after extend.
147 
148 @retval EFI_SUCCESS           Operation completed successfully.
149 @retval EFI_TIMEOUT           The register can't run into the expected status in time.
150 @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.
151 @retval EFI_DEVICE_ERROR      Unexpected device behavior.
152 
153 **/
154 EFI_STATUS
155 EFIAPI
156 Tpm12Extend (
157   IN  TPM_DIGEST    *DigestToExtend,
158   IN  TPM_PCRINDEX  PcrIndex,
159   OUT TPM_DIGEST    *NewPcrValue
160   );
161 
162 /**
163 Send TSC_PhysicalPresence command to TPM.
164 
165 @param[in] PhysicalPresence   The state to set the TPMs Physical Presence flags.
166 
167 @retval EFI_SUCCESS           Operation completed successfully.
168 @retval EFI_TIMEOUT           The register can't run into the expected status in time.
169 @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.
170 @retval EFI_DEVICE_ERROR      Unexpected device behavior.
171 
172 **/
173 EFI_STATUS
174 EFIAPI
175 Tpm12PhysicalPresence (
176   IN      TPM_PHYSICAL_PRESENCE     PhysicalPresence
177   );
178 
179 /**
180 Send TPM_ContinueSelfTest command to TPM.
181 
182 @retval EFI_SUCCESS           Operation completed successfully.
183 @retval EFI_TIMEOUT           The register can't run into the expected status in time.
184 @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.
185 @retval EFI_DEVICE_ERROR      Unexpected device behavior.
186 
187 **/
188 EFI_STATUS
189 EFIAPI
190 Tpm12ContinueSelfTest (
191   VOID
192   );
193 
194 /**
195 Get TPM capability permanent flags.
196 
197 @param[out] TpmPermanentFlags   Pointer to the buffer for returned flag structure.
198 
199 @retval EFI_SUCCESS           Operation completed successfully.
200 @retval EFI_TIMEOUT           The register can't run into the expected status in time.
201 @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.
202 @retval EFI_DEVICE_ERROR      Unexpected device behavior.
203 
204 **/
205 EFI_STATUS
206 EFIAPI
207 Tpm12GetCapabilityFlagPermanent (
208   OUT TPM_PERMANENT_FLAGS  *TpmPermanentFlags
209   );
210 
211 /**
212 Get TPM capability volatile flags.
213 
214 @param[out] VolatileFlags   Pointer to the buffer for returned flag structure.
215 
216 @retval EFI_SUCCESS      Operation completed successfully.
217 @retval EFI_DEVICE_ERROR The command was unsuccessful.
218 
219 **/
220 EFI_STATUS
221 EFIAPI
222 Tpm12GetCapabilityFlagVolatile (
223   OUT TPM_STCLEAR_FLAGS                 *VolatileFlags
224   );
225 #endif
226