--- 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:43:45 1.1.1.5 @@ -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.5 2018/04/24 16:43:45 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); @@ -4494,10 +4530,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 +4546,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 +4558,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 +4596,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 +4612,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 +4624,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 +4665,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 +4684,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 +4721,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 +4731,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 +4750,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 +4787,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 +4797,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 +4866,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 +4906,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 +4923,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 +4942,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 +4979,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 +4992,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 +5008,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 +5020,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 +5058,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 +5074,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 +5086,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 +5124,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 +5140,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 +5152,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 +5193,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 +5358,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 +5385,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 +5457,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 +5514,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++; @@ -5595,10 +5670,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 +5697,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: */ @@ -5688,7 +5764,7 @@ tme_m68k_write(struct tme_m68k *ic, /* 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; }