debuggers.hg

view tools/firmware/rombios/tcgbios.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 46f8fc57b1a4
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(bootcd,seg,off,count)
154 Bit32u bootcd;
155 Bit32u seg;
156 Bit32u off;
157 Bit32u count;
158 {
159 ASM_START
160 DoUpcall(IDX_TCPA_IPL)
161 ASM_END
162 }
165 Bit32u
166 tcpa_initialize_tpm(physpres)
167 Bit32u physpres;
168 {
169 ASM_START
170 DoUpcall(IDX_TCPA_INITIALIZE_TPM)
171 ASM_END
172 }
174 void
175 tcpa_measure_post(from, to)
176 Bit32u from;
177 Bit32u to;
178 {
179 ASM_START
180 DoUpcall(IDX_TCPA_MEASURE_POST)
181 ASM_END
182 }
184 ASM_START
185 MACRO POST_MEASURE
186 push word #0x000f
187 push #?2
188 push word #0x000f
189 push #?1
190 call _tcpa_measure_post
191 add sp, #8
192 MEND
193 ASM_END
195 void
196 tcpa_do_measure_POSTs()
197 {
198 ASM_START
200 POST_MEASURE(post, nmi)
201 POST_MEASURE(floppy_drive_post, hard_drive_post)
202 POST_MEASURE(hard_drive_post, ebda_post)
203 POST_MEASURE(ebda_post, eoi_jmp_post)
204 POST_MEASURE(eoi_jmp_post, timer_tick_post)
205 POST_MEASURE(timer_tick_post, int76_handler)
207 ret
208 ASM_END
209 }
211 Bit32u
212 TCGInterruptHandler(regs_ptr, es, ds, flags_ptr)
213 Bit32u regs_ptr;
214 Bit16u es;
215 Bit16u ds;
216 Bit32u flags_ptr;
217 {
218 ASM_START
219 DoUpcall(IDX_TCGINTERRUPTHANDLER)
220 ASM_END
221 }
223 /*
224 * C-dispatcher for the TCG BIOS functions
225 */
226 #define TCG_MAGIC 0x41504354L
227 void
228 int1a_function32(regs, ES, DS, FLAGS)
229 pushad_regs_t regs;
230 Bit16u ES, DS, FLAGS;
231 {
232 Bit16u rc;
234 BX_DEBUG_INT1A("int1a_32: AX=%04x\n", regs.u.r16.ax);
236 switch (regs.u.r8.ah) {
237 case 0xbb:
238 /*
239 * all functions except for TCG_StatusCheck need to have the
240 * TCG_MAGIC in 'ebx'.
241 */
242 if (regs.u.r8.al != 0 &&
243 regs.u.r32.ebx != TCG_MAGIC) {
244 SET_CF();
245 return;
246 }
247 switch(regs.u.r8.al) {
248 case 0x00:
249 case 0x01:
250 case 0x02:
251 case 0x03:
252 case 0x04:
253 case 0x05:
254 case 0x06:
255 case 0x07:
256 TCGInterruptHandler(((Bit32u)get_SS() << 4) + (Bit32u)&regs,
257 ES, DS,
258 ((Bit32u)get_SS() << 4) + (Bit32u)&FLAGS);
259 break;
261 default:
262 SET_CF();
263 }
264 break;
265 default:
266 SET_CF();
267 break;
268 }
269 BX_DEBUG_INT1A("int1a_32: FLAGS=%04x\n", FLAGS);
270 }