--- tme/ic/m68k/m68k-insns-auto.c 2018/04/24 16:41:52 1.1.1.4 +++ tme/ic/m68k/m68k-insns-auto.c 2018/04/24 16:45:38 1.1.1.6 @@ -1,5 +1,5 @@ /* automatically generated by m68k-insns-auto.sh, do not edit! */ -_TME_RCSID("$Id: m68k-insns-auto.c,v 1.1.1.4 2018/04/24 16:41:52 root Exp $"); +_TME_RCSID("$Id: m68k-insns-auto.c,v 1.1.1.6 2018/04/24 16:45:38 root Exp $"); #include "m68k-impl.h" @@ -3881,9 +3881,10 @@ TME_M68K_INSN(tme_m68k_moves32) void tme_m68k_read_memx8(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address); tme_uint8_t mem_value; const tme_shared tme_uint8_t *mem; @@ -3897,10 +3898,13 @@ tme_m68k_read_memx8(struct tme_m68k *ic) /* if we aren't restarting, and this address is properly aligned, and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address, - linear_address))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint8_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address); @@ -3931,7 +3935,7 @@ tme_m68k_read_memx8(struct tme_m68k *ic) tme_m68k_verify_mem8(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx8, TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_memx8\t%d:0x%08x:\t0x%02x"), + _("read_memx8 %d:0x%08x: 0x%02x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx8)); @@ -3941,9 +3945,10 @@ tme_m68k_read_memx8(struct tme_m68k *ic) void tme_m68k_read_mem8(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address); tme_uint8_t mem_value; const tme_shared tme_uint8_t *mem; @@ -3957,10 +3962,13 @@ tme_m68k_read_mem8(struct tme_m68k *ic, /* if we aren't restarting, and this address is properly aligned, and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address, - linear_address))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint8_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address); @@ -3991,7 +3999,7 @@ tme_m68k_read_mem8(struct tme_m68k *ic, tme_m68k_verify_mem8(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint8(ireg), TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_mem8\t%d:0x%08x:\t0x%02x"), + _("read_mem8 %d:0x%08x: 0x%02x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint8(ireg))); @@ -4001,9 +4009,10 @@ tme_m68k_read_mem8(struct tme_m68k *ic, void tme_m68k_write_memx8(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address); tme_uint8_t mem_value; tme_shared tme_uint8_t *mem; @@ -4015,7 +4024,7 @@ tme_m68k_write_memx8(struct tme_m68k *ic tme_m68k_verify_mem8(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx8, TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_memx8\t%d:0x%08x:\t0x%02x"), + _("write_memx8 %d:0x%08x: 0x%02x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx8)); @@ -4026,10 +4035,13 @@ tme_m68k_write_memx8(struct tme_m68k *ic /* if we aren't restarting, and this address is properly aligned, and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address, - linear_address))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint8_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address); @@ -4061,9 +4073,10 @@ tme_m68k_write_memx8(struct tme_m68k *ic void tme_m68k_write_mem8(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address); tme_uint8_t mem_value; tme_shared tme_uint8_t *mem; @@ -4075,7 +4088,7 @@ tme_m68k_write_mem8(struct tme_m68k *ic, tme_m68k_verify_mem8(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint8(ireg), TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_mem8\t%d:0x%08x:\t0x%02x"), + _("write_mem8 %d:0x%08x: 0x%02x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint8(ireg))); @@ -4086,10 +4099,13 @@ tme_m68k_write_mem8(struct tme_m68k *ic, /* if we aren't restarting, and this address is properly aligned, and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address, - linear_address))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint8_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address); @@ -4121,10 +4137,11 @@ tme_m68k_write_mem8(struct tme_m68k *ic, void tme_m68k_read_memx16(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; const tme_shared tme_uint16_t *mem; @@ -4139,10 +4156,13 @@ tme_m68k_read_memx16(struct tme_m68k *ic and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4173,7 +4193,7 @@ tme_m68k_read_memx16(struct tme_m68k *ic tme_m68k_verify_mem16(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx16, TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_memx16\t%d:0x%08x:\t0x%04x"), + _("read_memx16 %d:0x%08x: 0x%04x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx16)); @@ -4183,10 +4203,11 @@ tme_m68k_read_memx16(struct tme_m68k *ic void tme_m68k_read_mem16(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; const tme_shared tme_uint16_t *mem; @@ -4201,10 +4222,13 @@ tme_m68k_read_mem16(struct tme_m68k *ic, and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4235,7 +4259,7 @@ tme_m68k_read_mem16(struct tme_m68k *ic, tme_m68k_verify_mem16(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint16(ireg), TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_mem16\t%d:0x%08x:\t0x%04x"), + _("read_mem16 %d:0x%08x: 0x%04x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint16(ireg))); @@ -4245,10 +4269,11 @@ tme_m68k_read_mem16(struct tme_m68k *ic, tme_uint16_t tme_m68k_fetch16(struct tme_m68k *ic, tme_uint32_t pc) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_PROGRAM(ic); tme_uint32_t linear_address_first = pc; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = tme_memory_atomic_pointer_read(struct tme_m68k_tlb *, ic->_tme_m68k_itlb, &ic->_tme_m68k_tlbs_rwlock); + struct tme_m68k_tlb *tlb = &ic->_tme_m68k_itlb; tme_uint16_t mem_value; const tme_shared tme_uint16_t *mem; unsigned int fetch_slow_next = ic->_tme_m68k_insn_fetch_slow_next; @@ -4313,10 +4338,13 @@ tme_m68k_fetch16(struct tme_m68k *ic, tm and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && ((sizeof(tme_uint16_t) - 1) & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4350,7 +4378,7 @@ tme_m68k_fetch16(struct tme_m68k *ic, tm tme_m68k_verify_mem16(ic, function_code, pc, *((tme_uint16_t *) (((tme_uint8_t *) &ic->_tme_m68k_insn_fetch_buffer[0]) + fetch_slow_next)), TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("fetch16\t%d:0x%08x:\t0x%04x"), + _("fetch16 %d:0x%08x: 0x%04x"), function_code, pc, *((tme_uint16_t *) (((tme_uint8_t *) &ic->_tme_m68k_insn_fetch_buffer[0]) + fetch_slow_next)))); @@ -4367,10 +4395,11 @@ tme_m68k_fetch16(struct tme_m68k *ic, tm void tme_m68k_pop16(struct tme_m68k *ic, tme_uint16_t *_value) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_DATA(ic); tme_uint32_t linear_address_first = ic->tme_m68k_ireg_a7; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; const tme_shared tme_uint16_t *mem; @@ -4385,10 +4414,13 @@ tme_m68k_pop16(struct tme_m68k *ic, tme_ and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4419,7 +4451,7 @@ tme_m68k_pop16(struct tme_m68k *ic, tme_ tme_m68k_verify_mem16(ic, function_code, ic->tme_m68k_ireg_a7, *_value, TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("pop16\t%d:0x%08x:\t0x%04x"), + _("pop16 %d:0x%08x: 0x%04x"), function_code, ic->tme_m68k_ireg_a7, *_value)); @@ -4432,10 +4464,11 @@ tme_m68k_pop16(struct tme_m68k *ic, tme_ void tme_m68k_write_memx16(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; tme_shared tme_uint16_t *mem; @@ -4447,7 +4480,7 @@ tme_m68k_write_memx16(struct tme_m68k *i tme_m68k_verify_mem16(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx16, TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_memx16\t%d:0x%08x:\t0x%04x"), + _("write_memx16 %d:0x%08x: 0x%04x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx16)); @@ -4459,10 +4492,13 @@ tme_m68k_write_memx16(struct tme_m68k *i and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -4470,6 +4506,15 @@ tme_m68k_write_memx16(struct tme_m68k *i /* get the value to write, in big-endian byte order: */ mem_value = tme_htobe_u16(ic->tme_m68k_ireg_memx16); +#if 1 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write_memx16 #1; mem %x, val %x\n", (int)mem, (int)mem_value); + } + } +#endif + /* do the 16-bit bus write: */ tme_memory_bus_write16(mem, mem_value, tlb->tme_m68k_tlb_bus_rwlock, sizeof(tme_uint8_t), sizeof(tme_uint32_t)); @@ -4479,6 +4524,16 @@ tme_m68k_write_memx16(struct tme_m68k *i /* otherwise, do the bus cycles the slow way: */ else { +#if 1 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + mem = (tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); + mem_value = tme_htobe_u16(ic->tme_m68k_ireg_memx16); + printf("tme_m68k_write_memx16 #2; mem %x, val %x\n", (int)mem, (int)mem_value); + } + } +#endif tme_m68k_write16(ic, tlb, &ic->_tme_m68k_ea_function_code, &ic->_tme_m68k_ea_address, @@ -4494,10 +4549,11 @@ tme_m68k_write_memx16(struct tme_m68k *i void tme_m68k_write_mem16(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; tme_shared tme_uint16_t *mem; @@ -4509,7 +4565,7 @@ tme_m68k_write_mem16(struct tme_m68k *ic tme_m68k_verify_mem16(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint16(ireg), TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_mem16\t%d:0x%08x:\t0x%04x"), + _("write_mem16 %d:0x%08x: 0x%04x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint16(ireg))); @@ -4521,10 +4577,13 @@ tme_m68k_write_mem16(struct tme_m68k *ic and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -4556,10 +4615,11 @@ tme_m68k_write_mem16(struct tme_m68k *ic void tme_m68k_push16(struct tme_m68k *ic, tme_uint16_t value) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_DATA(ic); tme_uint32_t linear_address_first = ic->tme_m68k_ireg_a7 - sizeof(tme_uint16_t); tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint16_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint16_t mem_value; tme_shared tme_uint16_t *mem; @@ -4571,7 +4631,7 @@ tme_m68k_push16(struct tme_m68k *ic, tme tme_m68k_verify_mem16(ic, function_code, linear_address_first, value, TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("push16\t%d:0x%08x:\t0x%04x"), + _("push16 %d:0x%08x: 0x%04x"), function_code, linear_address_first, value)); @@ -4583,10 +4643,13 @@ tme_m68k_push16(struct tme_m68k *ic, tme and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint16_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -4621,10 +4684,11 @@ tme_m68k_push16(struct tme_m68k *ic, tme void tme_m68k_read_memx32(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; const tme_shared tme_uint32_t *mem; @@ -4639,10 +4703,13 @@ tme_m68k_read_memx32(struct tme_m68k *ic and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4673,7 +4740,7 @@ tme_m68k_read_memx32(struct tme_m68k *ic tme_m68k_verify_mem32(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx32, TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_memx32\t%d:0x%08x:\t0x%08x"), + _("read_memx32 %d:0x%08x: 0x%08x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx32)); @@ -4683,10 +4750,11 @@ tme_m68k_read_memx32(struct tme_m68k *ic void tme_m68k_read_mem32(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; const tme_shared tme_uint32_t *mem; @@ -4701,10 +4769,13 @@ tme_m68k_read_mem32(struct tme_m68k *ic, and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4735,7 +4806,7 @@ tme_m68k_read_mem32(struct tme_m68k *ic, tme_m68k_verify_mem32(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint32(ireg), TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("read_mem32\t%d:0x%08x:\t0x%08x"), + _("read_mem32 %d:0x%08x: 0x%08x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint32(ireg))); @@ -4745,10 +4816,11 @@ tme_m68k_read_mem32(struct tme_m68k *ic, tme_uint32_t tme_m68k_fetch32(struct tme_m68k *ic, tme_uint32_t pc) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_PROGRAM(ic); tme_uint32_t linear_address_first = pc; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = tme_memory_atomic_pointer_read(struct tme_m68k_tlb *, ic->_tme_m68k_itlb, &ic->_tme_m68k_tlbs_rwlock); + struct tme_m68k_tlb *tlb = &ic->_tme_m68k_itlb; tme_uint32_t mem_value; const tme_shared tme_uint32_t *mem; unsigned int fetch_slow_next = ic->_tme_m68k_insn_fetch_slow_next; @@ -4813,10 +4885,13 @@ tme_m68k_fetch32(struct tme_m68k *ic, tm and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && ((sizeof(tme_uint16_t) - 1) & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4850,7 +4925,7 @@ tme_m68k_fetch32(struct tme_m68k *ic, tm tme_m68k_verify_mem32(ic, function_code, pc, *((tme_uint32_t *) (((tme_uint8_t *) &ic->_tme_m68k_insn_fetch_buffer[0]) + fetch_slow_next)), TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("fetch32\t%d:0x%08x:\t0x%08x"), + _("fetch32 %d:0x%08x: 0x%08x"), function_code, pc, *((tme_uint32_t *) (((tme_uint8_t *) &ic->_tme_m68k_insn_fetch_buffer[0]) + fetch_slow_next)))); @@ -4867,10 +4942,11 @@ tme_m68k_fetch32(struct tme_m68k *ic, tm void tme_m68k_pop32(struct tme_m68k *ic, tme_uint32_t *_value) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_DATA(ic); tme_uint32_t linear_address_first = ic->tme_m68k_ireg_a7; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; const tme_shared tme_uint32_t *mem; @@ -4885,10 +4961,13 @@ tme_m68k_pop32(struct tme_m68k *ic, tme_ and this TLB entry covers the operand and allows fast reads: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_READ(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_read != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (const tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_read + linear_address_first); @@ -4919,7 +4998,7 @@ tme_m68k_pop32(struct tme_m68k *ic, tme_ tme_m68k_verify_mem32(ic, function_code, ic->tme_m68k_ireg_a7, *_value, TME_BUS_CYCLE_READ); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("pop32\t%d:0x%08x:\t0x%08x"), + _("pop32 %d:0x%08x: 0x%08x"), function_code, ic->tme_m68k_ireg_a7, *_value)); @@ -4932,10 +5011,11 @@ tme_m68k_pop32(struct tme_m68k *ic, tme_ void tme_m68k_write_memx32(struct tme_m68k *ic) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; tme_shared tme_uint32_t *mem; @@ -4947,7 +5027,7 @@ tme_m68k_write_memx32(struct tme_m68k *i tme_m68k_verify_mem32(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx32, TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_memx32\t%d:0x%08x:\t0x%08x"), + _("write_memx32 %d:0x%08x: 0x%08x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_memx32)); @@ -4959,10 +5039,13 @@ tme_m68k_write_memx32(struct tme_m68k *i and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -4994,10 +5077,11 @@ tme_m68k_write_memx32(struct tme_m68k *i void tme_m68k_write_mem32(struct tme_m68k *ic, int ireg) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; tme_shared tme_uint32_t *mem; @@ -5009,7 +5093,7 @@ tme_m68k_write_mem32(struct tme_m68k *ic tme_m68k_verify_mem32(ic, ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint32(ireg), TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("write_mem32\t%d:0x%08x:\t0x%08x"), + _("write_mem32 %d:0x%08x: 0x%08x"), ic->_tme_m68k_ea_function_code, ic->_tme_m68k_ea_address, ic->tme_m68k_ireg_uint32(ireg))); @@ -5021,10 +5105,13 @@ tme_m68k_write_mem32(struct tme_m68k *ic and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -5056,10 +5143,11 @@ tme_m68k_write_mem32(struct tme_m68k *ic void tme_m68k_push32(struct tme_m68k *ic, tme_uint32_t value) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = TME_M68K_FUNCTION_CODE_DATA(ic); tme_uint32_t linear_address_first = ic->tme_m68k_ireg_a7 - sizeof(tme_uint32_t); tme_uint32_t linear_address_last = linear_address_first + sizeof(tme_uint32_t) - 1; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); tme_uint32_t mem_value; tme_shared tme_uint32_t *mem; @@ -5071,7 +5159,7 @@ tme_m68k_push32(struct tme_m68k *ic, tme tme_m68k_verify_mem32(ic, function_code, linear_address_first, value, TME_BUS_CYCLE_WRITE); tme_m68k_log(ic, 1000, TME_OK, (TME_M68K_LOG_HANDLE(ic), - _("push32\t%d:0x%08x:\t0x%08x"), + _("push32 %d:0x%08x: 0x%08x"), function_code, linear_address_first, value)); @@ -5083,10 +5171,13 @@ tme_m68k_push32(struct tme_m68k *ic, tme and this TLB entry covers the operand and allows fast writes: */ if (__tme_predict_true(!TME_M68K_SEQUENCE_RESTARTING && (ic->_tme_m68k_bus_16bit & linear_address_first) == 0 - && TME_M68K_TLB_OK_FAST_WRITE(tlb, - function_code, - linear_address_first, - linear_address_last))) { + && tme_m68k_tlb_is_valid(tlb) + && tlb->tme_m68k_tlb_bus_context == bus_context + && (tlb->tme_m68k_tlb_function_codes_mask + & TME_BIT(function_code)) + && linear_address_first >= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + && linear_address_last <= (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last + && tlb->tme_m68k_tlb_emulator_off_write != TME_EMULATOR_OFF_UNDEF)) { /* make the emulator memory pointer: */ mem = (tme_shared tme_uint32_t *) (tlb->tme_m68k_tlb_emulator_off_write + linear_address_first); @@ -5121,9 +5212,10 @@ tme_m68k_push32(struct tme_m68k *ic, tme void tme_m68k_read_mem(struct tme_m68k *ic, tme_uint8_t *buffer, unsigned int count) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); #ifdef _TME_M68K_STATS ic->tme_m68k_stats.tme_m68k_stats_memory_total++; @@ -5285,10 +5377,11 @@ tme_m68k_read(struct tme_m68k *ic, } /* loop while this TLB entry is invalid or does not apply: */ - for (; __tme_predict_false(tme_bus_tlb_is_invalid(&tlb->tme_m68k_tlb_bus_tlb) + for (; __tme_predict_false(tme_m68k_tlb_is_invalid(tlb) + || tlb->tme_m68k_tlb_bus_context != ic->_tme_m68k_bus_context || (tlb->tme_m68k_tlb_function_codes_mask & TME_BIT(function_code)) == 0 - || linear_address < tlb->tme_m68k_tlb_linear_first - || linear_address > tlb->tme_m68k_tlb_linear_last + || linear_address < (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + || linear_address > (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last || (tlb->tme_m68k_tlb_emulator_off_read == TME_EMULATOR_OFF_UNDEF && (tlb->tme_m68k_tlb_cycles_ok & TME_BUS_CYCLE_READ) == 0)); ) { @@ -5311,8 +5404,8 @@ tme_m68k_read(struct tme_m68k *ic, /* limit the cycle size to addresses covered by the TLB entry: */ if (__tme_predict_false((cycle_size - 1) - > (tlb->tme_m68k_tlb_linear_last - linear_address))) { - cycle_size = (tlb->tme_m68k_tlb_linear_last - linear_address) + 1; + > (((tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last) - linear_address))) { + cycle_size = (((tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last) - linear_address) + 1; } /* if this is a little-endian host, and this isn't a raw read: */ @@ -5383,7 +5476,7 @@ tme_m68k_read(struct tme_m68k *ic, /* if the TLB entry was invalidated before the read: */ if (err == EBADF - && tme_bus_tlb_is_invalid(&tlb->tme_m68k_tlb_bus_tlb)) { + && tme_m68k_tlb_is_invalid(tlb)) { cycle.tme_bus_cycle_size = 0; } @@ -5440,9 +5533,10 @@ tme_m68k_read(struct tme_m68k *ic, void tme_m68k_write_mem(struct tme_m68k *ic, tme_uint8_t *buffer, unsigned int count) { + tme_bus_context_t bus_context = ic->_tme_m68k_bus_context; unsigned int function_code = ic->_tme_m68k_ea_function_code; tme_uint32_t linear_address_first = ic->_tme_m68k_ea_address; - struct tme_m68k_tlb *tlb = TME_M68K_TLB_ENTRY(ic, function_code, linear_address_first); + struct tme_m68k_tlb *tlb = TME_M68K_DTLB_ENTRY(ic, bus_context, function_code, linear_address_first); #ifdef _TME_M68K_STATS ic->tme_m68k_stats.tme_m68k_stats_memory_total++; @@ -5495,6 +5589,20 @@ tme_m68k_write(struct tme_m68k *ic, tme_uint8_t reg_buffer[sizeof(tme_uint32_t) * 2]; tme_shared tme_uint8_t *mem; +#if 1 + int should_fault = 0; + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write; *_linear_address %x\n", (int)*_linear_address); + if ((int)*_linear_address == 0x509000) { + should_fault = 1; + } + printf("tme_m68k_write; should_fault %d\n", should_fault); + } + } +#endif + /* if we're not restarting, everything is fresh: */ if (!TME_M68K_SEQUENCE_RESTARTING) { function_code = *_function_code; @@ -5536,6 +5644,14 @@ tme_m68k_write(struct tme_m68k *ic, transfer number and return: */ else { TME_M68K_SEQUENCE_TRANSFER_STEP; +#if 0 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write; returning\n"); + } + } +#endif return; } @@ -5543,6 +5659,14 @@ tme_m68k_write(struct tme_m68k *ic, exception = TME_M68K_EXCEPTION_NONE; cycle_size = 0; for(; transferred < reg_size; ) { +#if 0 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write; loop %x\n", (int)linear_address); + } + } +#endif resid = reg_size - transferred; /* start the bus cycle structure: */ @@ -5595,10 +5719,11 @@ tme_m68k_write(struct tme_m68k *ic, } /* loop while this TLB entry is invalid or does not apply: */ - for (; __tme_predict_false(tme_bus_tlb_is_invalid(&tlb->tme_m68k_tlb_bus_tlb) + for (; __tme_predict_false(tme_m68k_tlb_is_invalid(tlb) + || tlb->tme_m68k_tlb_bus_context != ic->_tme_m68k_bus_context || (tlb->tme_m68k_tlb_function_codes_mask & TME_BIT(function_code)) == 0 - || linear_address < tlb->tme_m68k_tlb_linear_first - || linear_address > tlb->tme_m68k_tlb_linear_last + || linear_address < (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_first + || linear_address > (tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last || (tlb->tme_m68k_tlb_emulator_off_write == TME_EMULATOR_OFF_UNDEF && (tlb->tme_m68k_tlb_cycles_ok & TME_BUS_CYCLE_WRITE) == 0)); ) { @@ -5621,8 +5746,8 @@ tme_m68k_write(struct tme_m68k *ic, /* limit the cycle size to addresses covered by the TLB entry: */ if (__tme_predict_false((cycle_size - 1) - > (tlb->tme_m68k_tlb_linear_last - linear_address))) { - cycle_size = (tlb->tme_m68k_tlb_linear_last - linear_address) + 1; + > (((tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last) - linear_address))) { + cycle_size = (((tme_bus_addr32_t) tlb->tme_m68k_tlb_linear_last) - linear_address) + 1; } /* if this is a little-endian host, and this isn't a raw write: */ @@ -5686,9 +5811,19 @@ tme_m68k_write(struct tme_m68k *ic, tme_m68k_callout_relock(ic); tme_m68k_tlb_busy(tlb); +#if 0 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write; old %x\n", (int)err); + err = ENOENT; + } + } +#endif + /* if the TLB entry was invalidated before the write: */ if (err == EBADF - && tme_bus_tlb_is_invalid(&tlb->tme_m68k_tlb_bus_tlb)) { + && tme_m68k_tlb_is_invalid(tlb)) { cycle.tme_bus_cycle_size = 0; } @@ -5715,6 +5850,18 @@ tme_m68k_write(struct tme_m68k *ic, transferred += cycle.tme_bus_cycle_size; } +#if 1 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + if (0) printf("tme_m68k_write; not returning\n"); + if (should_fault) { + printf("tme_m68k_write; faulting\n"); + exception = TME_M68K_EXCEPTION_BERR; + } + } + } +#endif /* NB: there is no need to explicitly unlock a device. if a locked bus cycle to a device faults, the lock must be automatically unlocked: */ @@ -5751,6 +5898,15 @@ tme_m68k_write(struct tme_m68k *ic, /* otherwise, this transfer has now completed: */ TME_M68K_SEQUENCE_TRANSFER_STEP; + +#if 0 + { + extern int printf(const char *format, ...); + if ((int)ic->tme_m68k_ireg_pc == 0x3c3bc) { + printf("tme_m68k_write; end\n"); + } + } +#endif } TME_M68K_INSN(tme_m68k_abcd)