--- trunk/src/cpus/cpu_sparc.c 2007/10/08 16:21:26 35 +++ trunk/src/cpus/cpu_sparc.c 2007/10/08 16:21:34 36 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $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 $ * * SPARC CPU emulation. */ @@ -139,15 +139,24 @@ cpu->cd.sparc.tick |= SPARC_TICK_NPT; /* Insert number of Windows and Trap levels into the version reg.: */ - cpu->cd.sparc.ver |= MAXWIN | (MAXTL << SPARC_VER_MAXTL_SHIFT); + cpu->cd.sparc.ver |= N_REG_WINDOWS | (MAXTL << SPARC_VER_MAXTL_SHIFT); /* Misc. initial settings suitable for userland emulation: */ - cpu->cd.sparc.cansave = cpu->cd.sparc.cpu_type.nwindows - 1; - cpu->cd.sparc.cleanwin = cpu->cd.sparc.cpu_type.nwindows / 2; + cpu->cd.sparc.cansave = cpu->cd.sparc.cpu_type.nwindows - 2; + cpu->cd.sparc.canrestore = 0; + cpu->cd.sparc.cleanwin = 1; + cpu->cd.sparc.otherwin = 0; + + if (cpu->cd.sparc.cansave + cpu->cd.sparc.canrestore + + cpu->cd.sparc.otherwin != cpu->cd.sparc.cpu_type.nwindows - 2) { + fatal("Fatal internal error: inconsistent windowing " + "parameters!\n"); + exit(1); + } - if (cpu->cd.sparc.cpu_type.nwindows >= MAXWIN) { + if (cpu->cd.sparc.cpu_type.nwindows > N_REG_WINDOWS) { fatal("Fatal internal error: nwindows = %1 is more than %i\n", - cpu->cd.sparc.cpu_type.nwindows, MAXWIN); + cpu->cd.sparc.cpu_type.nwindows, N_REG_WINDOWS); exit(1); } @@ -287,6 +296,73 @@ } } } + + if (coprocs & 1) { + int sum; + + debug("cpu%i: cwp = 0x%02x\n", x, cpu->cd.sparc.cwp); + debug("cpu%i: cansave = 0x%02x\n", x, cpu->cd.sparc.cansave); + debug("cpu%i: canrestore = 0x%02x\n", x, + cpu->cd.sparc.canrestore); + debug("cpu%i: otherwin = 0x%02x\n", x, + cpu->cd.sparc.otherwin); + debug("cpu%i: cleanwin = 0x%02x\n", x, + cpu->cd.sparc.cleanwin); + + sum = cpu->cd.sparc.cansave + cpu->cd.sparc.canrestore + + cpu->cd.sparc.otherwin; + debug("cpu%i: cansave + canrestore + otherwin = %i + %i + %i" + " = %i", x, cpu->cd.sparc.cansave, cpu->cd.sparc.canrestore, + cpu->cd.sparc.otherwin, sum); + if (sum == cpu->cd.sparc.cpu_type.nwindows - 2) + debug(" (consistent)\n"); + else + debug(" (INCONSISTENT!)\n"); + + debug("cpu%i: wstate: other = %i, normal = %i\n", + x, (cpu->cd.sparc.wstate & SPARC_WSTATE_OTHER_MASK) + >> SPARC_WSTATE_OTHER_SHIFT, cpu->cd.sparc.wstate & + SPARC_WSTATE_NORMAL_MASK); + + debug("cpu%i: asi = 0x%02x\n", x, cpu->cd.sparc.asi); + debug("cpu%i: tl = 0x%02x\n", x, cpu->cd.sparc.tl); + debug("cpu%i: pil = 0x%02x\n", x, cpu->cd.sparc.pil); + + for (i=0; icd.sparc.tpc[i]); + else + debug("%016"PRIx64"\n", + (uint64_t) cpu->cd.sparc.tpc[i]); + + debug("cpu%i: tnpc[%i] = 0x", x, i); + if (bits32) + debug("%08"PRIx32"\n", + (uint32_t) cpu->cd.sparc.tnpc[i]); + else + debug("%016"PRIx64"\n", + (uint64_t) cpu->cd.sparc.tnpc[i]); + + debug("cpu%i: tstate[%i] = 0x", x, i); + if (bits32) + debug("%08"PRIx32"\n", + (uint32_t) cpu->cd.sparc.tstate[i]); + else + debug("%016"PRIx64"\n", + (uint64_t) cpu->cd.sparc.tstate[i]); + + debug("cpu%i: ttype[%i] = 0x"PRIx32"\n", + x, i, cpu->cd.sparc.ttype[i]); + } + + debug("cpu%i: tba = 0x", x); + if (bits32) + debug("%08"PRIx32"\n", (uint32_t) cpu->cd.sparc.tba); + else + debug("%016"PRIx64"\n", (uint64_t) cpu->cd.sparc.tba); + } }