summaryrefslogtreecommitdiff
path: root/Core/EM/TCG2/TisLib/TcgPc.h
blob: 18b1a43d31f4c4c13aba959118faa1dfac1a6c66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/*++

   Copyright (c) 2005 Intel Corporation. All rights reserved
   This software and associated documentation (if any) is furnished
   under a license and may only be used or copied in accordance
   with the terms of the license. Except as permitted by such
   license, no part of this software or documentation may be
   reproduced, stored in a retrieval system, or transmitted in any
   form or by any means without the express written consent of
   Intel Corporation.


   Module Name:

   TpmDev.h

   Abstract:

   Header file for tpm device drivers

   --*/

//*************************************************************************
// $Header: /Alaska/SOURCE/Modules/TCG2/Libraries/TisLib/TcgPc.h 1     4/21/14 2:15p Fredericko $
//
// $Revision: 1 $
//
// $Date: 4/21/14 2:15p $
//*************************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/TCG2/Libraries/TisLib/TcgPc.h $
// 
// 1     4/21/14 2:15p Fredericko
// 
// 1     10/08/13 11:58a Fredericko
// Initial Check-In for Tpm-Next module
// 
// 1     7/10/13 5:50p Fredericko
// [TAG]  		EIP120969
// [Category]  	New Feature
// [Description]  	TCG (TPM20)
// [Files]  		TisLib.cif
// TisLib.mak
// TcgTpm12.h
// TpmLib.h
// TcgCommon.h
// ZTEICTcmOrdinals.h
// TpmLib.c
// TcgCommon.c
// TisLib.sdl
// sha1.h
// INTTcgAcpi.h
// TcgPc.h
// TcmPc.h
// TcgEfiTpm.h
// TcgEFI12.h
// 
// 4     3/29/11 12:26p Fredericko
// 
// 3     3/28/11 12:27p Fredericko
// [TAG]        EIP 54642
// [Category] Improvement
// [Description] 1. Checkin Files related to TCG function override 
// 2. Include TCM and TPM auto detection
// [Files] Affects all TCG files
// 
// 2     5/19/10 5:23p Fredericko
// 
// Included File Header
// Included File Revision History 
// Code Beautification
// EIP 37653
//
//*************************************************************************
//*************************************************************************
//<AMI_FHDR_START>
//
// Name:  TcgPc.h
//
// Description: 
//  Contains Industry Standard #defines and Structures for TCG
//
//<AMI_FHDR_END>
//*************************************************************************
#ifndef _TPMPC_H_
#define _TPMPC_H_

#include "TcgEfi12.h"
#include "INTTcgAcpi.h"
#include "TcmPc.h"

#pragma pack (push)
#pragma pack (1)

typedef struct _TPM_1_2_REGISTERS
{
    UINT8  Access;            // 0
    UINT8  Reserved1[7];      // 1
    UINT32 IntEnable;         // 8
    UINT8  IntVector;         // 0ch
    UINT8  Reserved2[3];      // 0dh
    UINT32 IntSts;            // 10h
    UINT32 IntfCapability;    // 14h
    UINT8  Sts;               // 18h
    UINT16 BurstCount;        // 19h
    UINT8  Reserved3[9];
    UINT32 DataFifo;          // 24h
    UINT8  Reserved4[0xed8];  // 28h
    UINT16 Vid;               // 0f00h
    UINT16 Did;               // 0f02h
    UINT8  Rid;               // 0f04h
    UINT8  TcgDefined[0x7b];  // 0f05h
    UINT32 LegacyAddress1;    // 0f80h
    UINT32 LegacyAddress1Ex;  // 0f84h
    UINT32 LegacyAddress2;    // 0f88h
    UINT32 LegacyAddress2Ex;  // 0f8ch
    UINT8  VendorDefined[0x70]; // 0f90h
} TPM_1_2_REGISTERS;

typedef struct _TCG_ACPI_TABLE
{
    EFI_ACPI_DESCRIPTION_HEADER Header;
    UINT16                      Reserved;
    UINT32                      LogMaxLength;
    EFI_PHYSICAL_ADDRESS        LogStart;
} TCG_ACPI_TABLE;

//
// Trusted Computing Platform Alliance Capabilities Table (TCPA)
//
typedef struct
{
    EFI_ACPI_DESCRIPTION_HEADER Header;
    UINT16                      Reserved;
    UINT32                      LogAreaMaxLength;
    UINT64                      LogAreaStartAddress;
} EFI_ACPI_TCPA_CAPABILITIES_TABLE;

#pragma pack (pop)

typedef volatile TPM_1_2_REGISTERS *TPM_1_2_REGISTERS_PTR;

#define TPM_ACC_VALID           _TPM_NTH_BIT( 7 )
#define TPM_ACC_ACTIVE_LOCALITY _TPM_NTH_BIT( 5 )
#define TPM_ACC_BEEN_SEIZED     _TPM_NTH_BIT( 4 )
#define TPM_ACC_SEIZE           _TPM_NTH_BIT( 3 )
#define TPM_ACC_PENDING_REQUEST _TPM_NTH_BIT( 2 )
#define TPM_ACC_REQUEST_USE     _TPM_NTH_BIT( 1 )
#define TPM_ACC_ESTABLISHMENT   _TPM_NTH_BIT( 0 )

#define TPM_STS_VALID           _TPM_NTH_BIT( 7 )
#define TPM_STS_READY           _TPM_NTH_BIT( 6 )
#define TPM_STS_GO              _TPM_NTH_BIT( 5 )
#define TPM_STS_DATA_AVAILABLE  _TPM_NTH_BIT( 4 )
#define TPM_STS_EXPECT          _TPM_NTH_BIT( 3 )
#define TPM_STS_RESPONSE_RETRY  _TPM_NTH_BIT( 1 )

#define TPM_BASE_ADDRESS            0xFED40000

#define TPM_H2NS( x ) \
    (((UINT16)(x) << 8) | ((UINT16)(x) >> 8))
#define TPM_H2NL( x ) \
    (UINT32)((((UINT32)(x)) >> 24)    \
             | (((x) >> 8) & 0xff00)  \
             | ((x) << 24)            \
             | (((x) & 0xff00) << 8))

#define TPM_N2HS( x ) TPM_H2NS( x )
#define TPM_N2HL( x ) TPM_H2NL( x )

//
// PCR Usage
//
#define PCRi_CRTM_AND_POST_BIOS                  0
#define PCRi_HOST_PLATFORM_CONFIG                1
#define PCRi_OPROM_CODE                          2
#define PCRi_OPROM_CONFIG_AND_DATA               3
#define PCRi_IPL_CODE                            4
#define PCRi_IPL_CONFIG_AND_DATA                 5
#define PCRi_STATE_TRANSITION                    6
#define PCRi_HOST_PLATFORM_MANUFACTURER_CONTROL  7

//
// TCG Event Logs
//
#define TPM_LOG_AREA_MAX_LEN        0x10000

//
// TCG Event Types
//
#define EV_PREBOOT_CERT             0
#define EV_UNUSED                   2
#define EV_NO_ACTION                3
#define EV_ACTION                   5
#define EV_EVENT_TAG                6
#define EV_CPU_MICROCODE            9
#define EV_PLATFORM_CONFIG_FLAGS    10
#define EV_TABLE_OF_DEVICES         11
#define EV_COMPACT_HASH             12
#define EV_IPL                      13
#define EV_IPL_PARTITION_DATA       14
#define EV_NONHOST_CODE             15
#define EV_NONHOST_CONFIG           16

//
// TCG Event IDs
//
#define EV_ID_NULL                      0
#define EV_ID_SMBIOS_RECORD             1
#define EV_ID_BIS_CERTIFICATE           2
#define EV_ID_POST_BIOS_STRING          3
#define EV_ID_ESCD                      4
#define EV_ID_RAW_CMOS                  5
#define EV_ID_RAW_NVRAM                 6
#define EV_ID_OPROM_EXECUTE             7
#define EV_ID_OPROM_CONFIG              8
#define EV_ID_OPROM_MICROCODE_UPDATE    9

#pragma pack (push)
#pragma pack (1)

//
// _EFI_TCG_EV_S_CRTM_VERSION
//
struct _EFI_TCG_EV_S_CRTM_VERSION
{
    EFI_GUID VersionGuid;
};

//
// _EFI_TCG_EV_POST_CODE
//
struct _EFI_TCG_EV_POST_CODE
{
    EFI_PHYSICAL_ADDRESS PostCodeAddress;
    UINT64               PostCodeLength;
};

//
// _EFI_TCG_EV_TAG_OPTION_ROM_EXECUTE
//
struct _EFI_TCG_EV_TAG_OPTION_ROM_EXECUTE
{
    UINT16     Reserved;
    UINT16     PFA;
    TCG_DIGEST Hash;
};

//
// _EFI_TCG_EV_CPU_MICROCODE
//
struct _EFI_TCG_EV_CPU_MICROCODE
{
    EFI_PHYSICAL_ADDRESS MicrocodeEntrypoint;
};

//
// _EFI_TCG_EV_TAG_EVENT_DATA
//
union _EFI_TCG_EV_TAG_EVENT_DATA
{
    struct _EFI_TCG_EV_TAG_OPTION_ROM_EXECUTE
    OptionRomExecute;
};

//
// _EFI_TCG_EV_TAG
//
struct _EFI_TCG_EV_TAG
{
    UINT32 EventID;
    UINT32 EventSize;
    union _EFI_TCG_EV_TAG_EVENT_DATA EventData;
};

//
// EFI_TCG_PCR_EVENT_HEADER
//
typedef struct _EFI_TCG_PCR_EVENT_HEADER
{
    TPM_PCRINDEX PCRIndex;
    UINT32       EventType;
    TCG_DIGEST   Digest;
    UINT32       EventDataSize;
} EFI_TCG_PCR_EVENT_HEADER;

//
// EFI_TCG_PCR_EVENT_DATA
//
typedef union _EFI_TCG_PCR_EVENT_DATA
{
    struct _EFI_TCG_EV_S_CRTM_VERSION SCrtmVersion;
    struct _EFI_TCG_EV_POST_CODE PostCode;
    struct _EFI_TCG_EV_TAG Tagged;
    struct _EFI_TCG_EV_CPU_MICROCODE Mcu;
} EFI_TCG_PCR_EVENT_DATA;

//
// EFI_TCG_PCR_EVENT
// equivalent to TCG_PCR_EVENT in the TCG PC Client Spec
//
typedef struct _EFI_TCG_PCR_EVENT
{
    EFI_TCG_PCR_EVENT_HEADER Header;
    EFI_TCG_PCR_EVENT_DATA   Event;
} EFI_TCG_PCR_EVENT;

#pragma pack (pop)

#endif  // _TPMPC_H_