debuggers.hg

view tools/firmware/rombios/32bit/tcgbios/tcgbios.h @ 13681:c07326324f8d

[HVM] Add TCG BIOS extensions to the high memory area along with
some often-used libc utility functions. The TCG extensions are
described here:

https://www.trustedcomputinggroup.org/specs/PCClient/TCG_PCClientImplementationforBIOS_1-20_1-00.pdf

I have tried to keep the patching with rombios.c to a minimum, but
some amount of code needs to be inserted at various locations.

The code is currently deactivated, but can be activated by setting
BX_TCGBIOS to '1'.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@localhost.localdomain
date Fri Jan 26 16:38:32 2007 +0000 (2007-01-26)
parents
children 5c0bf00e371d
line source
1 #ifndef TCGBIOS_H
2 #define TCGBIOS_H
5 /* TCPA ACPI definitions */
6 #define TCPA_ACPI_CLASS_CLIENT 0
7 #define TCPA_ACPI_CLASS_SERVER 1
9 /* Define for section 12.3 */
10 #define TCG_PC_OK 0x0
11 #define TCG_PC_TPMERROR 0x1
12 #define TCG_PC_LOGOVERFLOW 0x2
13 #define TCG_PC_UNSUPPORTED 0x3
15 #define TPM_ALG_SHA 0x4
17 #define TCG_MAGIC 0x41504354L
18 #define TCG_VERSION_MAJOR 1
19 #define TCG_VERSION_MINOR 2
21 #define TPM_OK 0x0
22 #define TPM_RET_BASE 0x1
23 #define TCG_GENERAL_ERROR (TPM_RET_BASE + 0x0)
24 #define TCG_TPM_IS_LOCKED (TPM_RET_BASE + 0x1)
25 #define TCG_NO_RESPONSE (TPM_RET_BASE + 0x2)
26 #define TCG_INVALID_RESPONSE (TPM_RET_BASE + 0x3)
27 #define TCG_INVALID_ACCESS_REQUEST (TPM_RET_BASE + 0x4)
28 #define TCG_FIRMWARE_ERROR (TPM_RET_BASE + 0x5)
29 #define TCG_INTEGRITY_CHECK_FAILED (TPM_RET_BASE + 0x6)
30 #define TCG_INVALID_DEVICE_ID (TPM_RET_BASE + 0x7)
31 #define TCG_INVALID_VENDOR_ID (TPM_RET_BASE + 0x8)
32 #define TCG_UNABLE_TO_OPEN (TPM_RET_BASE + 0x9)
33 #define TCG_UNABLE_TO_CLOSE (TPM_RET_BASE + 0xa)
34 #define TCG_RESPONSE_TIMEOUT (TPM_RET_BASE + 0xb)
35 #define TCG_INVALID_COM_REQUEST (TPM_RET_BASE + 0xc)
36 #define TCG_INVALID_ADR_REQUEST (TPM_RET_BASE + 0xd)
37 #define TCG_WRITE_BYTE_ERROR (TPM_RET_BASE + 0xe)
38 #define TCG_READ_BYTE_ERROR (TPM_RET_BASE + 0xf)
39 #define TCG_BLOCK_WRITE_TIMEOUT (TPM_RET_BASE + 0x10)
40 #define TCG_CHAR_WRITE_TIMEOUT (TPM_RET_BASE + 0x11)
41 #define TCG_CHAR_READ_TIMEOUT (TPM_RET_BASE + 0x12)
42 #define TCG_BLOCK_READ_TIMEOUT (TPM_RET_BASE + 0x13)
43 #define TCG_TRANSFER_ABORT (TPM_RET_BASE + 0x14)
44 #define TCG_INVALID_DRV_FUNCTION (TPM_RET_BASE + 0x15)
45 #define TCG_OUTPUT_BUFFER_TOO_SHORT (TPM_RET_BASE + 0x16)
46 #define TCG_FATAL_COM_ERROR (TPM_RET_BASE + 0x17)
47 #define TCG_INVALID_INPUT_PARA (TPM_RET_BASE + 0x18)
48 #define TCG_TCG_COMMAND_ERROR (TPM_RET_BASE + 0x19)
49 #define TCG_INTERFACE_SHUTDOWN (TPM_RET_BASE + 0x20)
50 //define TCG_PC_UNSUPPORTED (TPM_RET_BASE + 0x21)
51 #define TCG_PC_TPM_NOT_PRESENT (TPM_RET_BASE + 0x22)
52 #define TCG_PC_TPM_DEACTIVATED (TPM_RET_BASE + 0x23)
55 #define TPM_INVALID_ADR_REQUEST TCG_INVALID_ADR_REQUEST
56 #define TPM_IS_LOCKED TCG_TPM_IS_LOCKED
57 #define TPM_INVALID_DEVICE_ID TCG_INVALID_DEVICE_ID
58 #define TPM_INVALID_VENDOR_ID TCG_INVALID_VENDOR_ID
59 //define TPM_RESERVED_REG_INVALID
60 #define TPM_FIRMWARE_ERROR TCG_FIRMWARE_ERROR
61 #define TPM_UNABLE_TO_OPEN TCG_UNABLE_TO_OPEN
62 #define TPM_UNABLE_TO_CLOSE TCG_UNABLE_TO_CLOSE
63 #define TPM_INVALID_RESPONSE TCG_INVALID_RESPONSE
64 #define TPM_RESPONSE_TIMEOUT TCG_RESPONSE_TIMEOUT
65 #define TPM_INVALID_ACCESS_REQUEST TCG_INVALID_ACCESS_REQUEST
66 #define TPM_TRANSFER_ABORT TCG_TRANSFER_ABORT
67 #define TPM_GENERAL_ERROR TCG_GENERAL_ERROR
69 #define TPM_ST_CLEAR 0x0
70 #define TPM_ST_STATE 0x1
71 #define TPM_ST_DEACTIVATED 0x2
73 /* event types: 10.4.1 / table 11 */
74 #define EV_POST_CODE 1
75 #define EV_SEPARATOR 4
76 #define EV_ACTION 5
77 #define EV_EVENT_TAG 6
78 #define EV_COMPACT_HASH 12
79 #define EV_IPL 13
80 #define EV_IPL_PARTITION_DATA 14
83 // MA Driver defines
84 #define CODE_MAInitTPM 0x01
85 #define CODE_MAHashAllExtendTPM 0x02
86 #define CODE_MAPhysicalPresenceTPM 0x03
87 /* vendor specific ones */
88 #define CODE_MAIsTPMPresent 0x80
89 #define CODE_MAHashAll 0x81
90 #define CODE_MATransmit 0x82
92 /*
93 indices for commands to be sent via proprietary
94 _TCG_SendCommand function
95 */
96 #define IDX_CMD_TPM_Startup_0x01 0
97 #define IDX_CMD_TSC_PhysicalPresence_0x20 1
98 #define IDX_CMD_TSC_PhysicalPresence_0x08 2
99 #define IDX_CMD_TSC_PhysicalPresence_0x100 3
100 #define IDX_CMD_TSC_PhysicalPresence_0x10 4
101 #define IDX_CMD_TPM_PhysicalEnable 5
102 #define IDX_CMD_TPM_PhysicalSetDeactivated_0x00 6
103 #define IDX_CMD_TPM_SHA1Start 7
106 /* hardware registers for TPM TIS */
107 #define TPM_ACCESS 0x0
108 #define TPM_INT_ENABLE 0x8
109 #define TPM_INT_VECTOR 0xc
110 #define TPM_INT_STATUS 0x10
111 #define TPM_INTF_CAPABILITY 0x14
112 #define TPM_STS 0x18
113 #define TPM_DATA_FIFO 0x24
114 #define TPM_DID_VID 0xf00
115 #define TPM_RID 0xf04
117 /* address of locality 0 (TIS) */
118 #define TPM_TIS_BASE_ADDRESS 0xfed40000
120 #define ASCII32(a,b,c,d) ((((Bit32u)a) << 0) | (((Bit32u)b) << 8) | \
121 (((Bit32u)c) << 16) | (((Bit32u)d) << 24) )
122 #define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A') /* "TCPA" */
125 #define STATUS_FLAG_SHUTDOWN (1 << 0)
127 #define ACPI_SEGMENT 0xE000
129 /* Input and Output blocks for the TCG BIOS commands */
131 struct hleei_short
132 {
133 uint16_t ipblength;
134 uint16_t reserved;
135 uint32_t hashdataptr;
136 uint32_t hashdatalen;
137 uint32_t pcrindex;
138 uint32_t logdataptr;
139 uint32_t logdatalen;
140 } __attribute__((packed));
142 struct hleei_long
143 {
144 uint16_t ipblength;
145 uint16_t reserved;
146 uint32_t hashdataptr;
147 uint32_t hashdatalen;
148 uint32_t pcrindex;
149 uint32_t reserved2;
150 uint32_t logdataptr;
151 uint32_t logdatalen;
152 } __attribute__((packed));
154 struct hleeo
155 {
156 uint16_t opblength;
157 uint16_t reserved;
158 uint32_t eventnumber;
159 uint8_t hashvalue[20];
160 } __attribute__((packed));
164 struct pttti
165 {
166 uint16_t ipblength;
167 uint16_t reserved;
168 uint16_t opblength;
169 uint16_t reserved2;
170 uint8_t tpmoperandin[0];
171 } __attribute__((packed));
173 struct pttto
174 {
175 uint16_t opblength;
176 uint16_t reserved;
177 uint8_t tpmoperandout[0];
178 };
181 struct hlei
182 {
183 uint16_t ipblength;
184 uint16_t reserved;
185 uint32_t hashdataptr;
186 uint32_t hashdatalen;
187 uint32_t pcrindex;
188 uint32_t logeventtype;
189 uint32_t logdataptr;
190 uint32_t logdatalen;
191 } __attribute__((packed));
193 struct hleo
194 {
195 uint16_t opblength;
196 uint16_t reserved;
197 uint32_t eventnumber;
198 } __attribute__((packed));
200 struct hai
201 {
202 uint16_t ipblength;
203 uint16_t reserved;
204 uint32_t hashdataptr;
205 uint32_t hashdatalen;
206 uint32_t algorithmid;
207 } __attribute__((packed));
209 struct ti
210 {
211 uint16_t ipblength;
212 uint16_t reserved;
213 uint16_t opblength;
214 uint16_t reserved2;
215 uint8_t tssoperandin[0];
216 } __attribute__((packed));
218 struct to
219 {
220 uint16_t opblength;
221 uint16_t reserved;
222 uint8_t tssoperandout[0];
223 } __attribute__((packed));
226 struct pcpes
227 {
228 uint32_t pcrindex;
229 uint32_t eventtype;
230 uint8_t digest[20];
231 uint32_t eventdatasize;
232 uint32_t event;
233 } __attribute__((packed));
236 struct acpi_header
237 {
238 uint32_t signature;
239 uint32_t length;
240 uint8_t revision;
241 uint8_t checksum;
242 uint8_t oem_id[6];
243 uint64_t oem_table_id;
244 uint32_t oem_revision;
245 uint32_t creator_id;
246 uint32_t creator_revision;
247 } __attribute__((packed));
249 struct acpi_20_rsdt {
250 struct acpi_header header;
251 uint32_t entry[1];
252 } __attribute__((packed));
254 struct acpi_20_rsdp {
255 uint64_t signature;
256 uint8_t checksum;
257 uint8_t oem_id[6];
258 uint8_t revision;
259 uint32_t rsdt_address;
260 uint32_t length;
261 uint64_t xsdt_address;
262 uint8_t extended_checksum;
263 uint8_t reserved[3];
264 } __attribute__((packed));
266 struct acpi_20_tcpa_client {
267 uint32_t laml;
268 uint64_t lasa;
269 } __attribute__((packed));
271 struct acpi_20_tcpa_server {
272 uint16_t reserved;
273 uint32_t laml;
274 uint64_t lasa;
275 /* more here */
276 } __attribute__((packed));
278 struct acpi_20_tcpa {
279 struct acpi_header header;
280 uint16_t platform_class;
281 union {
282 struct acpi_20_tcpa_client client;
283 struct acpi_20_tcpa_server server;
284 } u;
285 } __attribute__((packed));
288 #endif