trunk/src/emu/cpu/sh2/sh2drc.c
| r21476 | r21477 | |
| 7 | 7 | Released for general non-commercial use under the MAME license |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | 9 | |
| 10 | | ST-V status: |
| 11 | | colmns97 & stress crash due to SCSP stream->machine() getting corrupted. |
| 12 | | |
| 13 | | cottonbm w/US bios: run to 60323B4 on master, then MOV insn @ 602f5aa crashes? |
| 14 | | actually crash on slave @ 6032b38 after above. reading wrong addr for jump vector. |
| 15 | | |
| 16 | 10 | ***************************************************************************/ |
| 17 | 11 | |
| 18 | 12 | #include "emu.h" |
| r21476 | r21477 | |
| 128 | 122 | |
| 129 | 123 | static void cfunc_printf_probe(void *param); |
| 130 | 124 | static void cfunc_unimplemented(void *param); |
| 131 | | static void cfunc_checkirqs(void *param); |
| 132 | 125 | static void cfunc_fastirq(void *param); |
| 133 | 126 | static void cfunc_MAC_W(void *param); |
| 134 | 127 | static void cfunc_MAC_L(void *param); |
| r21476 | r21477 | |
| 284 | 277 | } |
| 285 | 278 | |
| 286 | 279 | /*------------------------------------------------- |
| 287 | | cfunc_checkirqs - checks for pending IRQs |
| 288 | | -------------------------------------------------*/ |
| 289 | | static void cfunc_checkirqs(void *param) |
| 290 | | { |
| 291 | | sh2_state *sh2 = (sh2_state *)param; |
| 292 | | // if NMI is pending, evec etc are already set up |
| 293 | | if (sh2->pending_nmi) |
| 294 | | { |
| 295 | | sh2->pending_nmi = 0; |
| 296 | | } |
| 297 | | else |
| 298 | | { |
| 299 | | sh2->evec = 0xffffffff; |
| 300 | | CHECK_PENDING_IRQ("cfunc_checkirqs"); |
| 301 | | } |
| 302 | | } |
| 303 | | |
| 304 | | /*------------------------------------------------- |
| 305 | 280 | cfunc_fastirq - checks for pending IRQs |
| 306 | 281 | -------------------------------------------------*/ |
| 307 | 282 | static void cfunc_fastirq(void *param) |
| r21476 | r21477 | |
| 1196 | 1171 | |
| 1197 | 1172 | UML_LABEL(block, label++); // label: |
| 1198 | 1173 | |
| 1174 | #if 0 // DO NOT ENABLE - SEVERE AARON DAMAGE |
| 1175 | for (int ramnum = 0; ramnum < SH2_MAX_FASTRAM; ramnum++) |
| 1176 | { |
| 1177 | if (sh2->fastram[ramnum].base != NULL && (!iswrite || !sh2->fastram[ramnum].readonly)) |
| 1178 | { |
| 1179 | void *fastbase = (UINT8 *)sh2->fastram[ramnum].base - sh2->fastram[ramnum].start; |
| 1180 | UINT32 skip = label++; |
| 1181 | if (sh2->fastram[ramnum].end != 0xffffffff) |
| 1182 | { |
| 1183 | UML_CMP(block, I0, sh2->fastram[ramnum].end); // cmp i0,end |
| 1184 | UML_JMPc(block, COND_A, skip); // ja skip |
| 1185 | } |
| 1186 | if (sh2->fastram[ramnum].start != 0x00000000) |
| 1187 | { |
| 1188 | UML_CMP(block, I0, sh2->fastram[ramnum].start);// cmp i0,fastram_start |
| 1189 | UML_JMPc(block, COND_B, skip); // jb skip |
| 1190 | } |
| 1191 | |
| 1192 | if (!iswrite) |
| 1193 | { |
| 1194 | if (size == 1) |
| 1195 | { |
| 1196 | UML_XOR(block, I0, I0, BYTE4_XOR_LE(0)); |
| 1197 | UML_LOAD(block, I0, fastbase, I0, SIZE_BYTE, SCALE_x1); // load i0,fastbase,i0,byte |
| 1198 | } |
| 1199 | else if (size == 2) |
| 1200 | { |
| 1201 | UML_XOR(block, I0, I0, WORD_XOR_LE(0)); |
| 1202 | UML_LOAD(block, I0, fastbase, I0, SIZE_WORD, SCALE_x1); // load i0,fastbase,i0,word_x1 |
| 1203 | } |
| 1204 | else if (size == 4) |
| 1205 | { |
| 1206 | UML_LOAD(block, I0, fastbase, I0, SIZE_DWORD, SCALE_x1); // load i0,fastbase,i0,dword_x1 |
| 1207 | } |
| 1208 | UML_RET(block); // ret |
| 1209 | } |
| 1210 | else |
| 1211 | { |
| 1212 | if (size == 1) |
| 1213 | { |
| 1214 | UML_XOR(block, I0, I0, BYTE4_XOR_LE(0)); |
| 1215 | UML_STORE(block, fastbase, I0, I1, SIZE_BYTE, SCALE_x1);// store fastbase,i0,i1,byte |
| 1216 | } |
| 1217 | else if (size == 2) |
| 1218 | { |
| 1219 | UML_XOR(block, I0, I0, WORD_XOR_LE(0)); |
| 1220 | UML_STORE(block, fastbase, I0, I1, SIZE_WORD, SCALE_x1);// store fastbase,i0,i1,word_x1 |
| 1221 | } |
| 1222 | else if (size == 4) |
| 1223 | { |
| 1224 | UML_STORE(block, fastbase, I0, I1, SIZE_DWORD, SCALE_x1); // store fastbase,i0,i1,dword_x1 |
| 1225 | } |
| 1226 | UML_RET(block); // ret |
| 1227 | } |
| 1228 | |
| 1229 | UML_LABEL(block, skip); // skip: |
| 1230 | } |
| 1231 | } |
| 1232 | #endif |
| 1233 | |
| 1199 | 1234 | if (iswrite) |
| 1200 | 1235 | { |
| 1201 | 1236 | switch (size) |
| r21476 | r21477 | |
| 1405 | 1440 | |
| 1406 | 1441 | /*------------------------------------------------- |
| 1407 | 1442 | log_add_disasm_comment - add a comment |
| 1408 | | including disassembly of a MIPS instruction |
| 1443 | including disassembly of an SH2 instruction |
| 1409 | 1444 | -------------------------------------------------*/ |
| 1410 | 1445 | |
| 1411 | 1446 | static void log_add_disasm_comment(drcuml_block *block, UINT32 pc, UINT32 op) |
| r21476 | r21477 | |
| 1981 | 2016 | return TRUE; |
| 1982 | 2017 | |
| 1983 | 2018 | case 0x1b: // SLEEP(); |
| 1984 | | // inlined special version of generate_update_cycles here |
| 1985 | | // if an interrupt is taken, the return address is set to the next instruction |
| 1986 | | UML_CALLC(block, cfunc_checkirqs, sh2); |
| 2019 | { |
| 2020 | int skip = compiler->labelnum+1; |
| 2021 | compiler->labelnum += 3; |
| 1987 | 2022 | |
| 1988 | | UML_MOV(block, I0, mem(&sh2->evec)); // mov r0, evec |
| 1989 | | UML_CMP(block, I0, 0xffffffff); // cmp r0, 0xffffffff |
| 1990 | | UML_JMPc(block, COND_Z, compiler->labelnum); // jz skip |
| 2023 | UML_MOV(block, I0, mem(&sh2->sleep_mode)); // mov i0, sleep_mode |
| 2024 | UML_CMP(block, I0, 0x2); // cmp i0, #2 |
| 2025 | UML_JMPc(block, COND_E, skip+1); // beq skip + 1 |
| 2026 | // sleep mode != 2 |
| 2027 | UML_CMP(block, I0, 0x0); // cmp i0, #0 |
| 2028 | UML_JMPc(block, COND_NE, skip); // bne skip |
| 2029 | UML_MOV(block, mem(&sh2->sleep_mode), 0x1); // mov sleep_mode, #1 |
| 2030 | |
| 2031 | UML_LABEL(block, skip); // skip: |
| 2032 | generate_update_cycles(sh2, block, compiler, desc->pc, TRUE); // repeat this insn |
| 2033 | UML_JMP(block, skip+2); // jmp skip+2 |
| 1991 | 2034 | |
| 1992 | | UML_SUB(block, R32(15), R32(15), 4); // sub R15, R15, #4 |
| 1993 | | UML_MOV(block, I0, R32(15)); // mov r0, R15 |
| 1994 | | UML_MOV(block, I1, mem(&sh2->irqsr)); // mov r1, irqsr |
| 1995 | | UML_CALLH(block, *sh2->write32); // call write32 |
| 2035 | UML_LABEL(block, skip+1); // skip + 1: |
| 2036 | // sleep_mode == 2 |
| 2037 | UML_MOV(block, mem(&sh2->sleep_mode), 0x0); // sleep_mode = 0 |
| 2038 | generate_update_cycles(sh2, block, compiler, desc->pc+2, TRUE); // go to next insn |
| 1996 | 2039 | |
| 1997 | | UML_SUB(block, R32(15), R32(15), 4); // sub R15, R15, #4 |
| 1998 | | UML_MOV(block, I0, R32(15)); // mov r0, R15 |
| 1999 | | UML_MOV(block, I1, desc->pc+2); // mov r1, nextpc |
| 2000 | | UML_CALLH(block, *sh2->write32); // call write32 |
| 2001 | | |
| 2002 | | UML_HASHJMP(block, 0, mem(&sh2->evec), *sh2->nocode); // hashjmp sh2->evec |
| 2003 | | |
| 2004 | | UML_LABEL(block, compiler->labelnum++); // skip: |
| 2005 | | |
| 2006 | | // now go "out of cycles" |
| 2007 | | if (compiler->cycles > 0) |
| 2008 | | { |
| 2009 | | UML_MOV(block, mem(&sh2->icount), 0); // mov icount, #0 |
| 2010 | | UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0 |
| 2011 | | UML_EXH(block, *sh2->out_of_cycles, desc->pc); // go out of cycles |
| 2040 | UML_LABEL(block, skip+2); // skip + 2: |
| 2012 | 2041 | } |
| 2013 | | else |
| 2014 | | { |
| 2015 | | UML_HASHJMP(block, 0, desc->pc, *sh2->nocode); |
| 2016 | | } |
| 2017 | | |
| 2018 | 2042 | return TRUE; |
| 2019 | 2043 | |
| 2020 | 2044 | case 0x22: // STCVBR(Rn); |
| r21476 | r21477 | |
| 3187 | 3211 | |
| 3188 | 3212 | |
| 3189 | 3213 | /*------------------------------------------------- |
| 3214 | sh2drc_add_fastram - add a new fastram |
| 3215 | region |
| 3216 | -------------------------------------------------*/ |
| 3217 | |
| 3218 | void sh2drc_add_fastram(device_t *device, offs_t start, offs_t end, UINT8 readonly, void *base) |
| 3219 | { |
| 3220 | sh2_state *sh2 = get_safe_token(device); |
| 3221 | if (sh2->fastram_select < ARRAY_LENGTH(sh2->fastram)) |
| 3222 | { |
| 3223 | sh2->fastram[sh2->fastram_select].start = start; |
| 3224 | sh2->fastram[sh2->fastram_select].end = end; |
| 3225 | sh2->fastram[sh2->fastram_select].readonly = readonly; |
| 3226 | sh2->fastram[sh2->fastram_select].base = base; |
| 3227 | sh2->fastram_select++; |
| 3228 | } |
| 3229 | } |
| 3230 | |
| 3231 | /*------------------------------------------------- |
| 3190 | 3232 | sh2_internal_a5 - read handler for |
| 3191 | 3233 | SH2 internal map |
| 3192 | 3234 | -------------------------------------------------*/ |