25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_sparc.c,v 1.39 2006/12/30 13:30:55 debug Exp $ |
* $Id: cpu_sparc.c,v 1.42 2007/03/18 02:54:59 debug Exp $ |
29 |
* |
* |
30 |
* SPARC CPU emulation. |
* SPARC CPU emulation. |
31 |
*/ |
*/ |
139 |
cpu->cd.sparc.tick |= SPARC_TICK_NPT; |
cpu->cd.sparc.tick |= SPARC_TICK_NPT; |
140 |
|
|
141 |
/* Insert number of Windows and Trap levels into the version reg.: */ |
/* Insert number of Windows and Trap levels into the version reg.: */ |
142 |
cpu->cd.sparc.ver |= MAXWIN | (MAXTL << SPARC_VER_MAXTL_SHIFT); |
cpu->cd.sparc.ver |= N_REG_WINDOWS | (MAXTL << SPARC_VER_MAXTL_SHIFT); |
143 |
|
|
144 |
/* Misc. initial settings suitable for userland emulation: */ |
/* Misc. initial settings suitable for userland emulation: */ |
145 |
cpu->cd.sparc.cansave = cpu->cd.sparc.cpu_type.nwindows - 1; |
cpu->cd.sparc.cansave = cpu->cd.sparc.cpu_type.nwindows - 2; |
146 |
cpu->cd.sparc.cleanwin = cpu->cd.sparc.cpu_type.nwindows / 2; |
cpu->cd.sparc.canrestore = 0; |
147 |
|
cpu->cd.sparc.cleanwin = 1; |
148 |
|
cpu->cd.sparc.otherwin = 0; |
149 |
|
|
150 |
|
if (cpu->cd.sparc.cansave + cpu->cd.sparc.canrestore |
151 |
|
+ cpu->cd.sparc.otherwin != cpu->cd.sparc.cpu_type.nwindows - 2) { |
152 |
|
fatal("Fatal internal error: inconsistent windowing " |
153 |
|
"parameters!\n"); |
154 |
|
exit(1); |
155 |
|
} |
156 |
|
|
157 |
if (cpu->cd.sparc.cpu_type.nwindows >= MAXWIN) { |
if (cpu->cd.sparc.cpu_type.nwindows > N_REG_WINDOWS) { |
158 |
fatal("Fatal internal error: nwindows = %1 is more than %i\n", |
fatal("Fatal internal error: nwindows = %1 is more than %i\n", |
159 |
cpu->cd.sparc.cpu_type.nwindows, MAXWIN); |
cpu->cd.sparc.cpu_type.nwindows, N_REG_WINDOWS); |
160 |
exit(1); |
exit(1); |
161 |
} |
} |
162 |
|
|
296 |
} |
} |
297 |
} |
} |
298 |
} |
} |
299 |
|
|
300 |
|
if (coprocs & 1) { |
301 |
|
int sum; |
302 |
|
|
303 |
|
debug("cpu%i: cwp = 0x%02x\n", x, cpu->cd.sparc.cwp); |
304 |
|
debug("cpu%i: cansave = 0x%02x\n", x, cpu->cd.sparc.cansave); |
305 |
|
debug("cpu%i: canrestore = 0x%02x\n", x, |
306 |
|
cpu->cd.sparc.canrestore); |
307 |
|
debug("cpu%i: otherwin = 0x%02x\n", x, |
308 |
|
cpu->cd.sparc.otherwin); |
309 |
|
debug("cpu%i: cleanwin = 0x%02x\n", x, |
310 |
|
cpu->cd.sparc.cleanwin); |
311 |
|
|
312 |
|
sum = cpu->cd.sparc.cansave + cpu->cd.sparc.canrestore + |
313 |
|
cpu->cd.sparc.otherwin; |
314 |
|
debug("cpu%i: cansave + canrestore + otherwin = %i + %i + %i" |
315 |
|
" = %i", x, cpu->cd.sparc.cansave, cpu->cd.sparc.canrestore, |
316 |
|
cpu->cd.sparc.otherwin, sum); |
317 |
|
if (sum == cpu->cd.sparc.cpu_type.nwindows - 2) |
318 |
|
debug(" (consistent)\n"); |
319 |
|
else |
320 |
|
debug(" (INCONSISTENT!)\n"); |
321 |
|
|
322 |
|
debug("cpu%i: wstate: other = %i, normal = %i\n", |
323 |
|
x, (cpu->cd.sparc.wstate & SPARC_WSTATE_OTHER_MASK) |
324 |
|
>> SPARC_WSTATE_OTHER_SHIFT, cpu->cd.sparc.wstate & |
325 |
|
SPARC_WSTATE_NORMAL_MASK); |
326 |
|
|
327 |
|
debug("cpu%i: asi = 0x%02x\n", x, cpu->cd.sparc.asi); |
328 |
|
debug("cpu%i: tl = 0x%02x\n", x, cpu->cd.sparc.tl); |
329 |
|
debug("cpu%i: pil = 0x%02x\n", x, cpu->cd.sparc.pil); |
330 |
|
|
331 |
|
for (i=0; i<MAXTL; i++) { |
332 |
|
debug("cpu%i: tpc[%i] = 0x", x, i); |
333 |
|
if (bits32) |
334 |
|
debug("%08"PRIx32"\n", |
335 |
|
(uint32_t) cpu->cd.sparc.tpc[i]); |
336 |
|
else |
337 |
|
debug("%016"PRIx64"\n", |
338 |
|
(uint64_t) cpu->cd.sparc.tpc[i]); |
339 |
|
|
340 |
|
debug("cpu%i: tnpc[%i] = 0x", x, i); |
341 |
|
if (bits32) |
342 |
|
debug("%08"PRIx32"\n", |
343 |
|
(uint32_t) cpu->cd.sparc.tnpc[i]); |
344 |
|
else |
345 |
|
debug("%016"PRIx64"\n", |
346 |
|
(uint64_t) cpu->cd.sparc.tnpc[i]); |
347 |
|
|
348 |
|
debug("cpu%i: tstate[%i] = 0x", x, i); |
349 |
|
if (bits32) |
350 |
|
debug("%08"PRIx32"\n", |
351 |
|
(uint32_t) cpu->cd.sparc.tstate[i]); |
352 |
|
else |
353 |
|
debug("%016"PRIx64"\n", |
354 |
|
(uint64_t) cpu->cd.sparc.tstate[i]); |
355 |
|
|
356 |
|
debug("cpu%i: ttype[%i] = 0x"PRIx32"\n", |
357 |
|
x, i, cpu->cd.sparc.ttype[i]); |
358 |
|
} |
359 |
|
|
360 |
|
debug("cpu%i: tba = 0x", x); |
361 |
|
if (bits32) |
362 |
|
debug("%08"PRIx32"\n", (uint32_t) cpu->cd.sparc.tba); |
363 |
|
else |
364 |
|
debug("%016"PRIx64"\n", (uint64_t) cpu->cd.sparc.tba); |
365 |
|
} |
366 |
} |
} |
367 |
|
|
368 |
|
|