]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Tcg/TcgSmm/Tpm.asl
9d5e6ddc110b5841dcac276600cc1a58790928e9
[mirror_edk2.git] / SecurityPkg / Tcg / TcgSmm / Tpm.asl
1 /** @file
2 The TPM definition block in ACPI table for physical presence
3 and MemoryClear.
4
5 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
6 Copyright (c) Microsoft Corporation.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 DefinitionBlock (
12 "Tpm.aml",
13 "SSDT",
14 2,
15 "INTEL ",
16 "TcgTable",
17 0x1000
18 )
19 {
20 Scope (\_SB)
21 {
22 Device (TPM)
23 {
24 //
25 // Define _HID, "PNP0C31" is defined in
26 // "Secure Startup-FVE and TPM Admin BIOS and Platform Requirements"
27 //
28 Name (_HID, EISAID ("PNP0C31"))
29
30 //
31 // Readable name of this device, don't know if this way is correct yet
32 //
33 Name (_STR, Unicode ("TPM 1.2 Device"))
34
35 //
36 // Return the resource consumed by TPM device
37 //
38 Name (_CRS, ResourceTemplate () {
39 Memory32Fixed (ReadWrite, 0xfed40000, 0x5000)
40 })
41
42 //
43 // Operational region for Smi port access
44 //
45 OperationRegion (SMIP, SystemIO, FixedPcdGet16 (PcdSmiCommandIoPort), 1)
46 Field (SMIP, ByteAcc, NoLock, Preserve)
47 {
48 IOPN, 8
49 }
50
51 //
52 // Operational region for TPM access
53 //
54 OperationRegion (TPMR, SystemMemory, 0xfed40000, 0x5000)
55 Field (TPMR, AnyAcc, NoLock, Preserve)
56 {
57 ACC0, 8,
58 }
59
60 //
61 // Operational region for TPM support, TPM Physical Presence and TPM Memory Clear
62 // Region Offset 0xFFFF0000 and Length 0xF0 will be fixed in C code.
63 //
64 OperationRegion (TNVS, SystemMemory, 0xFFFF0000, 0xF0)
65 Field (TNVS, AnyAcc, NoLock, Preserve)
66 {
67 PPIN, 8, // Software SMI for Physical Presence Interface
68 PPIP, 32, // Used for save physical presence parameter
69 PPRP, 32, // Physical Presence request operation response
70 PPRQ, 32, // Physical Presence request operation
71 LPPR, 32, // Last Physical Presence request operation
72 FRET, 32, // Physical Presence function return code
73 MCIN, 8, // Software SMI for Memory Clear Interface
74 MCIP, 32, // Used for save the Mor parameter
75 MORD, 32, // Memory Overwrite Request Data
76 MRET, 32, // Memory Overwrite function return code
77 UCRQ, 32 // Physical Presence request operation to Get User Confirmation Status
78 }
79
80 Method (PTS, 1, Serialized)
81 {
82 //
83 // Detect Sx state for MOR, only S4, S5 need to handle
84 //
85 If (LAnd (LLess (Arg0, 6), LGreater (Arg0, 3)))
86 {
87 //
88 // Bit4 -- DisableAutoDetect. 0 -- Firmware MAY autodetect.
89 //
90 If (LNot (And (MORD, 0x10)))
91 {
92 //
93 // Trigger the SMI through ACPI _PTS method.
94 //
95 Store (0x02, MCIP)
96
97 //
98 // Trigger the SMI interrupt
99 //
100 Store (MCIN, IOPN)
101 }
102 }
103 Return (0)
104 }
105
106 Method (_STA, 0)
107 {
108 if (LEqual (ACC0, 0xff))
109 {
110 Return (0)
111 }
112 Return (0x0f)
113 }
114
115 //
116 // TCG Hardware Information
117 //
118 Method (HINF, 1, Serialized, 0, {BuffObj, PkgObj}, {UnknownObj}) // IntObj
119 {
120 //
121 // Switch by function index
122 //
123 Switch (ToInteger(Arg0))
124 {
125 Case (0)
126 {
127 //
128 // Standard query
129 //
130 Return (Buffer () {0x03})
131 }
132 Case (1)
133 {
134 //
135 // Return failure if no TPM present
136 //
137 Name(TPMV, Package () {0x01, Package () {0x1, 0x20}})
138 if (LEqual (_STA (), 0x00))
139 {
140 Return (Package () {0x00})
141 }
142
143 //
144 // Return TPM version
145 //
146 Return (TPMV)
147 }
148 Default {BreakPoint}
149 }
150 Return (Buffer () {0})
151 }
152
153 Name(TPM2, Package (0x02){
154 Zero,
155 Zero
156 })
157
158 Name(TPM3, Package (0x03){
159 Zero,
160 Zero,
161 Zero
162 })
163
164 //
165 // TCG Physical Presence Interface
166 //
167 Method (TPPI, 2, Serialized, 0, {BuffObj, PkgObj, IntObj, StrObj}, {UnknownObj, UnknownObj}) // IntObj, PkgObj
168 {
169 //
170 // Switch by function index
171 //
172 Switch (ToInteger(Arg0))
173 {
174 Case (0)
175 {
176 //
177 // Standard query, supports function 1-8
178 //
179 Return (Buffer () {0xFF, 0x01})
180 }
181 Case (1)
182 {
183 //
184 // a) Get Physical Presence Interface Version
185 //
186 Return ("1.2")
187 }
188 Case (2)
189 {
190 //
191 // b) Submit TPM Operation Request to Pre-OS Environment
192 //
193
194 Store (DerefOf (Index (Arg1, 0x00)), PPRQ)
195 Store (0x02, PPIP)
196
197 //
198 // Trigger the SMI interrupt
199 //
200 Store (PPIN, IOPN)
201 Return (FRET)
202
203
204 }
205 Case (3)
206 {
207 //
208 // c) Get Pending TPM Operation Requested By the OS
209 //
210
211 Store (PPRQ, Index (TPM2, 0x01))
212 Return (TPM2)
213 }
214 Case (4)
215 {
216 //
217 // d) Get Platform-Specific Action to Transition to Pre-OS Environment
218 //
219 Return (2)
220 }
221 Case (5)
222 {
223 //
224 // e) Return TPM Operation Response to OS Environment
225 //
226 Store (0x05, PPIP)
227
228 //
229 // Trigger the SMI interrupt
230 //
231 Store (PPIN, IOPN)
232
233 Store (LPPR, Index (TPM3, 0x01))
234 Store (PPRP, Index (TPM3, 0x02))
235
236 Return (TPM3)
237 }
238 Case (6)
239 {
240
241 //
242 // f) Submit preferred user language (Not implemented)
243 //
244
245 Return (3)
246
247 }
248 Case (7)
249 {
250 //
251 // g) Submit TPM Operation Request to Pre-OS Environment 2
252 //
253 Store (7, PPIP)
254 Store (DerefOf (Index (Arg1, 0x00)), PPRQ)
255
256 //
257 // Trigger the SMI interrupt
258 //
259 Store (PPIN, IOPN)
260 Return (FRET)
261 }
262 Case (8)
263 {
264 //
265 // e) Get User Confirmation Status for Operation
266 //
267 Store (8, PPIP)
268 Store (DerefOf (Index (Arg1, 0x00)), UCRQ)
269
270 //
271 // Trigger the SMI interrupt
272 //
273 Store (PPIN, IOPN)
274
275 Return (FRET)
276 }
277
278 Default {BreakPoint}
279 }
280 Return (1)
281 }
282
283 Method (TMCI, 2, Serialized, 0, IntObj, {UnknownObj, UnknownObj}) // IntObj, PkgObj
284 {
285 //
286 // Switch by function index
287 //
288 Switch (ToInteger (Arg0))
289 {
290 Case (0)
291 {
292 //
293 // Standard query, supports function 1-1
294 //
295 Return (Buffer () {0x03})
296 }
297 Case (1)
298 {
299 //
300 // Save the Operation Value of the Request to MORD (reserved memory)
301 //
302 Store (DerefOf (Index (Arg1, 0x00)), MORD)
303
304 //
305 // Trigger the SMI through ACPI _DSM method.
306 //
307 Store (0x01, MCIP)
308
309 //
310 // Trigger the SMI interrupt
311 //
312 Store (MCIN, IOPN)
313 Return (MRET)
314 }
315 Default {BreakPoint}
316 }
317 Return (1)
318 }
319
320 Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj})
321 {
322
323 //
324 // TCG Hardware Information
325 //
326 If(LEqual(Arg0, ToUUID ("cf8e16a5-c1e8-4e25-b712-4f54a96702c8")))
327 {
328 Return (HINF (Arg2))
329 }
330
331 //
332 // TCG Physical Presence Interface
333 //
334 If(LEqual(Arg0, ToUUID ("3dddfaa6-361b-4eb4-a424-8d10089d1653")))
335 {
336 Return (TPPI (Arg2, Arg3))
337 }
338
339 //
340 // TCG Memory Clear Interface
341 //
342 If(LEqual(Arg0, ToUUID ("376054ed-cc13-4675-901c-4756d7f2d45d")))
343 {
344 Return (TMCI (Arg2, Arg3))
345 }
346
347 Return (Buffer () {0})
348 }
349 }
350 }
351 }