Tpm.asl 8.5 KB

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