debuggers.hg

view tools/firmware/rombios/tcgbios.c @ 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 8f1921600cfd
line source
1 /*
2 * Implementation of stub functions for calls to the TCG BIOS
3 * extension in 32bit memory area.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Copyright (C) IBM Corporation, 2006
20 *
21 * Author: Stefan Berger <stefanb@us.ibm.com>
22 */
24 /*******************************************************************
25 Support for TCPA ACPI logging
26 ******************************************************************/
28 /*
29 * Extend the ACPI log with the given entry by copying the
30 * entry data into the log.
31 * Input
32 * Pointer to the structure to be copied into the log
33 *
34 * Output:
35 * lower 16 bits of return code contain entry number
36 * if entry number is '0', then upper 16 bits contain error code.
37 */
38 Bit32u tcpa_extend_acpi_log(entry_ptr)
39 Bit32u entry_ptr;
40 {
41 ASM_START
42 DoUpcall IDX_TCPA_EXTEND_ACPI_LOG
43 ASM_END
44 }
47 /*
48 initialize the TCPA ACPI subsystem; find the ACPI tables and determine
49 where the TCPA table is.
50 */
51 void
52 tcpa_acpi_init()
53 {
54 ASM_START
55 DoUpcall IDX_TCPA_ACPI_INIT
56 ASM_END
57 }
60 /*
61 * Add measurement to log about call of int 19h
62 */
63 void
64 tcpa_calling_int19h()
65 {
66 ASM_START
67 DoUpcall IDX_TCPA_CALLING_INT19H
68 ASM_END
69 }
71 /*
72 * Add measurement to log about retuning from int 19h
73 */
74 void
75 tcpa_returned_int19h()
76 {
77 ASM_START
78 DoUpcall IDX_TCPA_RETURNED_INT19H
79 ASM_END
80 }
82 /*
83 * Add event separators for PCRs 0 to 7; specs 8.2.3
84 */
85 void
86 tcpa_add_event_separators()
87 {
88 ASM_START
89 DoUpcall IDX_TCPA_ADD_EVENT_SEPARATORS
90 ASM_END
91 }
94 /*
95 * Add a wake event to the log
96 */
97 void
98 tcpa_wake_event()
99 {
100 ASM_START
101 DoUpcall IDX_TCPA_WAKE_EVENT
102 ASM_END
103 }
106 /*
107 * Add measurement to the log about option rom scan
108 * 10.4.3 : action 14
109 */
110 void
111 tcpa_start_option_rom_scan()
112 {
113 ASM_START
114 DoUpcall IDX_TCPA_START_OPTION_ROM_SCAN
115 ASM_END
116 }
119 /*
120 * Add measurement to the log about an option rom
121 */
122 void
123 tcpa_option_rom(seg)
124 Bit32u seg;
125 {
126 ASM_START
127 DoUpcall IDX_TCPA_OPTION_ROM
128 ASM_END
129 }
131 /*
132 * Add a measurement regarding the boot device (CDRom, Floppy, HDD) to
133 * the list of measurements.
134 */
135 void
136 tcpa_add_bootdevice(bootcd, bootdrv)
137 Bit32u bootcd;
138 Bit32u bootdrv;
139 {
140 ASM_START
141 DoUpcall IDX_TCPA_ADD_BOOTDEVICE
142 ASM_END
143 }
145 /*
146 * Add a measurement to the log in support of 8.2.5.3
147 * Creates two log entries
148 *
149 * Input parameter:
150 * seg : segment where the IPL data are located
151 */
152 void
153 tcpa_ipl(seg)
154 Bit32u seg;
155 {
156 ASM_START
157 DoUpcall IDX_TCPA_IPL
158 ASM_END
159 }
162 Bit32u
163 tcpa_initialize_tpm(physpres)
164 Bit32u physpres;
165 {
166 ASM_START
167 DoUpcall IDX_TCPA_INITIALIZE_TPM
168 ASM_END
169 }
171 void
172 tcpa_measure_post(from, to)
173 Bit32u from;
174 Bit32u to;
175 {
176 ASM_START
177 DoUpcall IDX_TCPA_MEASURE_POST
178 ASM_END
179 }
181 ASM_START
182 MACRO POST_MEASURE
183 push word #0x000f
184 push #?2
185 push word #0x000f
186 push #?1
187 call _tcpa_measure_post
188 add sp, #8
189 MEND
190 ASM_END
192 void
193 tcpa_do_measure_POSTs()
194 {
195 ASM_START
197 POST_MEASURE post, nmi
198 POST_MEASURE floppy_drive_post, hard_drive_post
199 POST_MEASURE hard_drive_post, ebda_post
200 POST_MEASURE ebda_post, eoi_jmp_post
201 POST_MEASURE eoi_jmp_post, timer_tick_post
202 POST_MEASURE timer_tick_post, int76_handler
204 ret
205 ASM_END
206 }
208 Bit32u
209 TCGInterruptHandler(regs_ptr, es, ds, flags_ptr)
210 Bit32u regs_ptr;
211 Bit16u es;
212 Bit16u ds;
213 Bit32u flags_ptr;
214 {
215 ASM_START
216 DoUpcall IDX_TCGINTERRUPTHANDLER
217 ASM_END
218 }
220 /*
221 * C-dispatcher for the TCG BIOS functions
222 */
223 #define TCG_MAGIC 0x41504354L
224 void
225 int1a_function32(regs, ES, DS, FLAGS)
226 pushad_regs_t regs;
227 Bit16u ES, DS, FLAGS;
228 {
229 Bit16u rc;
231 switch (regs.u.r8.ah) {
232 case 0xbb:
233 /*
234 * all functions except for TCG_StatusCheck need to have the
235 * TCG_MAGIC in 'ebx'.
236 */
237 if (regs.u.r8.al != 0 &&
238 regs.u.r32.ebx != TCG_MAGIC) {
239 SET_CF();
240 return;
241 }
242 switch(regs.u.r8.al) {
243 case 0x00:
244 case 0x01:
245 case 0x02:
246 case 0x03:
247 case 0x04:
248 case 0x05:
249 case 0x06:
250 case 0x07:
251 TCGInterruptHandler(((Bit32u)get_SS() << 4) + (Bit32u)&regs,
252 ES, DS,
253 ((Bit32u)get_SS() << 4) + (Bit32u)&FLAGS);
254 break;
256 default:
257 SET_CF();
258 }
259 default:
260 SET_CF();
261 break;
262 }
263 }