--- tme/ic/m68k/m68k-execute.c 2018/04/24 16:41:55 1.1.1.4 +++ tme/ic/m68k/m68k-execute.c 2018/04/24 16:45:39 1.1.1.6 @@ -1,4 +1,4 @@ -/* $Id: m68k-execute.c,v 1.1.1.4 2018/04/24 16:41:55 root Exp $ */ +/* $Id: m68k-execute.c,v 1.1.1.6 2018/04/24 16:45:39 root Exp $ */ /* ic/m68k/m68k-execute.c - executes Motorola 68k instructions: */ @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -_TME_RCSID("$Id: m68k-execute.c,v 1.1.1.4 2018/04/24 16:41:55 root Exp $"); +_TME_RCSID("$Id: m68k-execute.c,v 1.1.1.6 2018/04/24 16:45:39 root Exp $"); /* includes: */ #include "m68k-auto.h" @@ -45,6 +45,7 @@ _TME_M68K_EXECUTE_NAME(struct tme_m68k * #undef _TME_M68K_SEQUENCE_RESTARTING #undef _TME_M68K_INSN_FETCH_SAVE #ifdef _TME_M68K_EXECUTE_FAST + tme_bus_context_t bus_context; struct tme_m68k_tlb *tlb; const tme_shared tme_uint8_t *fetch_fast_next; #define _TME_M68K_INSN_FETCH_SAVE \ @@ -111,12 +112,22 @@ do { \ #endif /* TME_THREADS_COOPERATIVE */ } + if (ic->_tme_m68k_mode == TME_M68K_MODE_DIE) + return; + #ifdef _TME_M68K_EXECUTE_FAST /* get our instruction TLB entry and reload it: */ - tlb = tme_memory_atomic_pointer_read(struct tme_m68k_tlb *, ic->_tme_m68k_itlb, &ic->_tme_m68k_tlbs_rwlock); + bus_context = ic->_tme_m68k_bus_context; + tlb = &ic->_tme_m68k_itlb; tme_m68k_tlb_busy(tlb); - if (!TME_M68K_TLB_OK_FAST_READ(tlb, function_code_program, ic->tme_m68k_ireg_pc, ic->tme_m68k_ireg_pc)) { + if (__tme_predict_false(tme_m68k_tlb_is_invalid(tlb) + || tlb->tme_m68k_tlb_bus_context != bus_context + || (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code_program)) == 0 + || ic->tme_m68k_ireg_pc < (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + || ic->tme_m68k_ireg_pc > (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + || tlb->tme_m68k_tlb_emulator_off_read == TME_EMULATOR_OFF_UNDEF)) { tme_m68k_tlb_fill(ic, tlb, function_code_program, ic->tme_m68k_ireg_pc, @@ -132,7 +143,7 @@ do { \ } /* set up to do fast reads from the instruction TLB entry: */ - ic->_tme_m68k_insn_fetch_fast_last = tlb->tme_m68k_tlb_emulator_off_read + tlb->tme_m68k_tlb_linear_last - (sizeof(tme_uint32_t) - 1); + ic->_tme_m68k_insn_fetch_fast_last = tlb->tme_m68k_tlb_emulator_off_read + ((tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last) - (sizeof(tme_uint32_t) - 1); ic->_tme_m68k_insn_fetch_fast_itlb = tlb; ic->_tme_m68k_group0_hook = tme_m68k_group0_hook_fast; #else /* !_TME_M68K_EXECUTE_FAST */ @@ -144,6 +155,14 @@ do { \ /* the execution loop: */ for (;;) { +#if 0 + extern int _m68k_dead; + if (_m68k_dead) { + extern void tme_m68k_kill_cpu(struct tme_m68k *ic); + tme_m68k_kill_cpu(ic); + } +#endif + /* reset for this instruction: */ #ifdef _TME_M68K_EXECUTE_FAST fetch_fast_next = tlb->tme_m68k_tlb_emulator_off_read + ic->tme_m68k_ireg_pc; @@ -152,10 +171,11 @@ do { \ && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF && (tlb->tme_m68k_tlb_function_codes_mask & TME_BIT(function_code_program)) != 0 && (fetch_fast_next > ic->_tme_m68k_insn_fetch_fast_last - || ((tme_bus_tlb_is_valid(&tlb->tme_m68k_tlb_bus_tlb) + || ((tme_m68k_tlb_is_valid(tlb) || !TME_THREADS_COOPERATIVE) - && ic->tme_m68k_ireg_pc >= tlb->tme_m68k_tlb_linear_first - && (ic->tme_m68k_ireg_pc + sizeof(tme_uint16_t) - 1) <= tlb->tme_m68k_tlb_linear_last))); + && tlb->tme_m68k_tlb_bus_context == ic->_tme_m68k_bus_context + && ic->tme_m68k_ireg_pc >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && (ic->tme_m68k_ireg_pc + sizeof(tme_uint16_t) - 1) <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last))); tme_m68k_verify_begin(ic, fetch_fast_next); #else /* !_TME_M68K_EXECUTE_FAST */ linear_pc = ic->tme_m68k_ireg_pc; @@ -821,6 +841,21 @@ do { \ /* an instruction has ended: */ tme_m68k_verify_end(ic, func); +#if 1 + if ((int)ic->tme_m68k_ireg_pc < 0x80000) + { + extern int printf(const char *format, ...); + //printf("finished %08x\n", (int)ic->tme_m68k_ireg_pc); + + if ((int)ic->tme_m68k_ireg_pc == 0x3c3c0) { +#ifdef _TME_M68K_EXECUTE_FAST +#else + printf("blammo; old %x\n", (int)exceptions); + exceptions |= TME_M68K_EXCEPTION_BERR; +#endif + } + } +#endif /* update the PC: */ ic->tme_m68k_ireg_pc = ic->tme_m68k_ireg_pc_next; TME_M68K_SEQUENCE_START; @@ -891,7 +926,7 @@ do { \ entry, but we didn't make any callouts at all (for TLB fills, slow bus cycles, etc.) where we would have noticed this earlier: */ - if (tme_bus_tlb_is_invalid(&tlb->tme_m68k_tlb_bus_tlb)) { + if (tme_m68k_tlb_is_invalid(tlb)) { tme_m68k_redispatch(ic); } #endif /* _TME_M68K_EXECUTE_FAST */