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