diff options
author | 2018-05-11 01:12:28 +0900 | |
---|---|---|
committer | 2018-05-11 18:23:04 +0900 | |
commit | 4c24f25845f129f77829fc6d8e701a0e3762be80 (patch) | |
tree | 9bd0b9d5cf348f95ffa86911b71956fdd7f8b410 /src/devices/cpu | |
parent | de781d1d84e064956df88bfec929b573d4800789 (diff) |
emumem: Rename direct_read_handler to memory_access_cache. Parametrize the template on more information (data width, endianness) to make it possible to turn it into an handler cache eventually, and not just a memory block cache. Make it capable of large and unaligned accesses. [O. Galibert]
Diffstat (limited to 'src/devices/cpu')
203 files changed, 978 insertions, 1018 deletions
diff --git a/src/devices/cpu/8x300/8x300.cpp b/src/devices/cpu/8x300/8x300.cpp index 761ad4310e4..130df2dd7e3 100644 --- a/src/devices/cpu/8x300/8x300.cpp +++ b/src/devices/cpu/8x300/8x300.cpp @@ -14,7 +14,7 @@ #include "8x300dasm.h" #include "debugger.h" -#define FETCHOP(a) (m_direct->read_word(a)) +#define FETCHOP(a) (m_cache->read_word(a)) #define CYCLES(x) do { m_icount -= (x); } while (0) #define READPORT(a) (m_io->read_byte(a)) #define WRITEPORT(a,v) (m_io->write_byte((a), (v))) @@ -97,7 +97,7 @@ uint8_t n8x300_cpu_device::get_reg(uint8_t reg) void n8x300_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<1, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); save_item(NAME(m_PC)); diff --git a/src/devices/cpu/8x300/8x300.h b/src/devices/cpu/8x300/8x300.h index aa62259ba1a..e3e3d68e7f6 100644 --- a/src/devices/cpu/8x300/8x300.h +++ b/src/devices/cpu/8x300/8x300.h @@ -72,7 +72,7 @@ protected: bool m_increment_pc; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<1, 0, ENDIANNESS_BIG> *m_cache; address_space *m_io; uint16_t m_PC; // Program Counter diff --git a/src/devices/cpu/adsp2100/adsp2100.cpp b/src/devices/cpu/adsp2100/adsp2100.cpp index ed17f8b8405..ff08e96b72b 100644 --- a/src/devices/cpu/adsp2100/adsp2100.cpp +++ b/src/devices/cpu/adsp2100/adsp2100.cpp @@ -418,7 +418,7 @@ void adsp21xx_device::device_start() // get our address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-2>(); + m_cache = m_program->cache<2, -2, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = has_space(AS_IO) ? &space(AS_IO) : nullptr; @@ -806,7 +806,7 @@ inline void adsp21xx_device::program_write(uint32_t addr, uint32_t data) inline uint32_t adsp21xx_device::opcode_read() { - return m_direct->read_dword(m_pc); + return m_cache->read_dword(m_pc); } diff --git a/src/devices/cpu/adsp2100/adsp2100.h b/src/devices/cpu/adsp2100/adsp2100.h index 1c45875c727..31c7d257572 100644 --- a/src/devices/cpu/adsp2100/adsp2100.h +++ b/src/devices/cpu/adsp2100/adsp2100.h @@ -450,7 +450,7 @@ protected: address_space * m_program; address_space * m_data; address_space * m_io; - direct_read_data<-2> *m_direct; + memory_access_cache<2, -2, ENDIANNESS_LITTLE> *m_cache; // tables uint8_t m_condition_table[0x1000]; diff --git a/src/devices/cpu/alph8201/alph8201.cpp b/src/devices/cpu/alph8201/alph8201.cpp index 81c1e6df4aa..c0b17ed7fd5 100644 --- a/src/devices/cpu/alph8201/alph8201.cpp +++ b/src/devices/cpu/alph8201/alph8201.cpp @@ -394,7 +394,7 @@ const alpha8201_cpu_device::s_opcode alpha8201_cpu_device::opcode_8301[256]= void alpha8201_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); state_add( ALPHA8201_PC, "PC", m_pc.w.l ).callimport().mask(0x3ff).formatstr("%03X"); state_add( ALPHA8201_SP, "SP", m_sp ).callimport().callexport().formatstr("%02X"); diff --git a/src/devices/cpu/alph8201/alph8201.h b/src/devices/cpu/alph8201/alph8201.h index 77f442161c6..46c00143f6b 100644 --- a/src/devices/cpu/alph8201/alph8201.h +++ b/src/devices/cpu/alph8201/alph8201.h @@ -87,8 +87,8 @@ protected: u8 M_RDMEM(u16 A) { return m_program->read_byte(A); } void M_WRMEM(u16 A, u8 V) { m_program->write_byte(A, V); } - u8 M_RDOP(u16 A) { return m_direct->read_byte(A); } - u8 M_RDOP_ARG(u16 A) { return m_direct->read_byte(A); } + u8 M_RDOP(u16 A) { return m_cache->read_byte(A); } + u8 M_RDOP_ARG(u16 A) { return m_cache->read_byte(A); } u8 RD_REG(u8 x) { return m_RAM[(m_regPtr<<3)+(x)]; } void WR_REG(u8 x, u8 d) { m_RAM[(m_regPtr<<3)+(x)]=(d); } @@ -388,7 +388,7 @@ protected: u8 m_halt; /* halt input line */ address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; int m_inst_cycles; diff --git a/src/devices/cpu/am29000/am29000.cpp b/src/devices/cpu/am29000/am29000.cpp index 3f5faedf0d2..a3f0c4ca91c 100644 --- a/src/devices/cpu/am29000/am29000.cpp +++ b/src/devices/cpu/am29000/am29000.cpp @@ -131,9 +131,9 @@ device_memory_interface::space_config_vector am29000_cpu_device::memory_space_co void am29000_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); m_data = &space(AS_DATA); - m_datadirect = m_data->direct<0>(); + m_datacache = m_data->cache<2, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); m_cfg = (PRL_AM29000 | PRL_REV_D) << CFG_PRL_SHIFT; @@ -511,7 +511,7 @@ uint32_t am29000_cpu_device::read_program_word(uint32_t address) { /* TODO: ROM enable? */ if (m_cps & CPS_PI || m_cps & CPS_RE) - return m_direct->read_dword(address); + return m_cache->read_dword(address); else { fatalerror("Am29000 instruction MMU translation enabled!\n"); @@ -658,7 +658,7 @@ void am29000_cpu_device::execute_run() if (m_cfg & CFG_VF) { uint32_t vaddr = m_vab | m_exception_queue[0] * 4; - uint32_t vect = m_datadirect->read_dword(vaddr); + uint32_t vect = m_datacache->read_dword(vaddr); m_pc = vect & ~3; m_next_pc = m_pc; diff --git a/src/devices/cpu/am29000/am29000.h b/src/devices/cpu/am29000/am29000.h index d856fdf93d1..4061fadbe64 100644 --- a/src/devices/cpu/am29000/am29000.h +++ b/src/devices/cpu/am29000/am29000.h @@ -630,10 +630,10 @@ protected: uint32_t m_next_pc; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_BIG> *m_cache; address_space *m_data; - direct_read_data<0> *m_datadirect; + memory_access_cache<2, 0, ENDIANNESS_BIG> *m_datacache; address_space *m_io; typedef void ( am29000_cpu_device::*opcode_func ) (); diff --git a/src/devices/cpu/arm/arm.cpp b/src/devices/cpu/arm/arm.cpp index 5e8bf859d7d..c2036ab166d 100644 --- a/src/devices/cpu/arm/arm.cpp +++ b/src/devices/cpu/arm/arm.cpp @@ -346,7 +346,7 @@ void arm_cpu_device::execute_run() /* load instruction */ pc = R15; - insn = m_direct->read_dword( pc & ADDRESS_MASK ); + insn = m_pr32( pc & ADDRESS_MASK ); switch (insn >> INSN_COND_SHIFT) { @@ -510,7 +510,14 @@ void arm_cpu_device::execute_set_input(int irqline, int state) void arm_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + + if(m_program->endianness() == ENDIANNESS_LITTLE) { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + } else { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + } save_item(NAME(m_sArmRegister)); save_item(NAME(m_coproRegister)); diff --git a/src/devices/cpu/arm/arm.h b/src/devices/cpu/arm/arm.h index e7bbee69087..2751be58ab0 100644 --- a/src/devices/cpu/arm/arm.h +++ b/src/devices/cpu/arm/arm.h @@ -74,7 +74,7 @@ protected: uint8_t m_pendingIrq; uint8_t m_pendingFiq; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u32 (offs_t)> m_pr32; endianness_t m_endian; copro_type m_copro_type; diff --git a/src/devices/cpu/arm7/arm7.cpp b/src/devices/cpu/arm7/arm7.cpp index 357938d61e8..41705bd9b85 100644 --- a/src/devices/cpu/arm7/arm7.cpp +++ b/src/devices/cpu/arm7/arm7.cpp @@ -566,7 +566,16 @@ void arm7_cpu_device::postload() void arm7_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + + if(m_program->endianness() == ENDIANNESS_LITTLE) { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } else { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } save_item(NAME(m_insn_prefetch_depth)); save_item(NAME(m_insn_prefetch_count)); @@ -751,7 +760,7 @@ void arm7_cpu_device::update_insn_prefetch(uint32_t curr_pc) { break; } - uint32_t op = m_direct->read_dword(pc); + uint32_t op = m_pr32(pc); //printf("ipb[%d] <- %08x(%08x)\n", index, op, pc); m_insn_prefetch_buffer[index] = op; m_insn_prefetch_address[index] = pc; diff --git a/src/devices/cpu/arm7/arm7.h b/src/devices/cpu/arm7/arm7.h index d2fc97a27c5..dfb6fad6eaa 100644 --- a/src/devices/cpu/arm7/arm7.h +++ b/src/devices/cpu/arm7/arm7.h @@ -160,7 +160,8 @@ protected: int m_icount; endianness_t m_endian; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u32 (offs_t)> m_pr32; + std::function<const void * (offs_t)> m_prptr; /* Coprocessor Registers */ uint32_t m_control; diff --git a/src/devices/cpu/arm7/arm7core.h b/src/devices/cpu/arm7/arm7core.h index c33bdee9dd2..a6a7838bed4 100644 --- a/src/devices/cpu/arm7/arm7core.h +++ b/src/devices/cpu/arm7/arm7core.h @@ -163,7 +163,7 @@ struct arm_state int m_icount; endianness_t m_endian; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u32 (offs_t)> m_pr32; /* Coprocessor Registers */ uint32_t m_control; diff --git a/src/devices/cpu/arm7/arm7drc.hxx b/src/devices/cpu/arm7/arm7drc.hxx index aa1e396b0bd..b26f56bfaee 100644 --- a/src/devices/cpu/arm7/arm7drc.hxx +++ b/src/devices/cpu/arm7/arm7drc.hxx @@ -1196,12 +1196,12 @@ void arm7_cpu_device::generate_checksum_block(drcuml_block &block, compiler_stat if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { uint32_t sum = seqhead->opptr.l[0]; - void *base = m_direct->read_ptr(seqhead->physpc); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, uml::I0, base, 0, uml::SIZE_DWORD, uml::SCALE_x4); // load i0,base,0,dword if (seqhead->delay.first() != nullptr && seqhead->physpc != seqhead->delay.first()->physpc) { - base = m_direct->read_ptr(seqhead->delay.first()->physpc); + base = m_prptr(seqhead->delay.first()->physpc); UML_LOAD(block, uml::I1, base, 0, uml::SIZE_DWORD, uml::SCALE_x4); // load i1,base,dword UML_ADD(block, uml::I0, uml::I0, uml::I1); // add i0,i0,i1 @@ -1217,20 +1217,20 @@ void arm7_cpu_device::generate_checksum_block(drcuml_block &block, compiler_stat else { uint32_t sum = 0; - void *base = m_direct->read_ptr(seqhead->physpc); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, uml::I0, base, 0, uml::SIZE_DWORD, uml::SCALE_x4); // load i0,base,0,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - base = m_direct->read_ptr(curdesc->physpc); + base = m_prptr(curdesc->physpc); UML_LOAD(block, uml::I1, base, 0, uml::SIZE_DWORD, uml::SCALE_x4); // load i1,base,dword UML_ADD(block, uml::I0, uml::I0, uml::I1); // add i0,i0,i1 sum += curdesc->opptr.l[0]; if (curdesc->delay.first() != nullptr && (curdesc == seqlast || (curdesc->next() != nullptr && curdesc->next()->physpc != curdesc->delay.first()->physpc))) { - base = m_direct->read_ptr(curdesc->delay.first()->physpc); + base = m_prptr(curdesc->delay.first()->physpc); UML_LOAD(block, uml::I1, base, 0, uml::SIZE_DWORD, uml::SCALE_x4); // load i1,base,dword UML_ADD(block, uml::I0, uml::I0, uml::I1); // add i0,i0,i1 sum += curdesc->delay.first()->opptr.l[0]; diff --git a/src/devices/cpu/asap/asap.cpp b/src/devices/cpu/asap/asap.cpp index a0baeb3467f..e87c8f9b326 100644 --- a/src/devices/cpu/asap/asap.cpp +++ b/src/devices/cpu/asap/asap.cpp @@ -153,7 +153,7 @@ asap_device::asap_device(const machine_config &mconfig, const char *tag, device_ m_irq_state(0), m_icount(0), m_program(nullptr), - m_direct(nullptr) + m_cache(nullptr) { // initialize the src2val table to contain immediates for low values for (int i = 0; i < REGBASE; i++) @@ -184,7 +184,7 @@ void asap_device::device_start() { // get our address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_pc).noshow(); @@ -321,7 +321,7 @@ std::unique_ptr<util::disasm_interface> asap_device::create_disassembler() inline uint32_t asap_device::readop(offs_t pc) { - return m_direct->read_dword(pc); + return m_cache->read_dword(pc); } diff --git a/src/devices/cpu/asap/asap.h b/src/devices/cpu/asap/asap.h index 2f8df62fc0b..912932f9e36 100644 --- a/src/devices/cpu/asap/asap.h +++ b/src/devices/cpu/asap/asap.h @@ -238,7 +238,7 @@ protected: uint8_t m_irq_state; int m_icount; address_space * m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; // src2val table, registers are at the end uint32_t m_src2val[65536]; diff --git a/src/devices/cpu/capricorn/capricorn.cpp b/src/devices/cpu/capricorn/capricorn.cpp index 5a18141157d..cb2b58c1a37 100644 --- a/src/devices/cpu/capricorn/capricorn.cpp +++ b/src/devices/cpu/capricorn/capricorn.cpp @@ -170,7 +170,7 @@ void capricorn_cpu_device::device_start() state_add(STATE_GENFLAGS , "GENFLAGS" , m_flags).noshow().formatstr("%9s"); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); save_item(NAME(m_reg)); save_item(NAME(m_arp)); @@ -299,7 +299,7 @@ void capricorn_cpu_device::WM(ea_addr_t& addr , uint8_t v) uint8_t capricorn_cpu_device::fetch() { m_genpc = read_u16(REG_PC | GP_REG_MASK); - return m_direct->read_byte(m_genpc); + return m_cache->read_byte(m_genpc); } void capricorn_cpu_device::offset_pc(uint16_t offset) diff --git a/src/devices/cpu/capricorn/capricorn.h b/src/devices/cpu/capricorn/capricorn.h index 22df8389743..4204f136b31 100644 --- a/src/devices/cpu/capricorn/capricorn.h +++ b/src/devices/cpu/capricorn/capricorn.h @@ -44,7 +44,7 @@ protected: private: address_space_config m_program_config; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; diff --git a/src/devices/cpu/ccpu/ccpu.cpp b/src/devices/cpu/ccpu/ccpu.cpp index 02bf0b123fd..740c803ad44 100644 --- a/src/devices/cpu/ccpu/ccpu.cpp +++ b/src/devices/cpu/ccpu/ccpu.cpp @@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(CCPU, ccpu_cpu_device, "ccpu", "Cinematronics CPU") MACROS ***************************************************************************/ -#define READOP(a) (m_direct->read_byte(a)) +#define READOP(a) (m_cache->read_byte(a)) #define RDMEM(a) (m_data->read_word((a) & 0xfff)) #define WRMEM(a,v) (m_data->write_word((a), (v))) @@ -107,7 +107,7 @@ void ccpu_cpu_device::device_start() assert(!m_vector_callback.isnull()); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/ccpu/ccpu.h b/src/devices/cpu/ccpu/ccpu.h index 1afc876d3b0..fea9eccbd4e 100644 --- a/src/devices/cpu/ccpu/ccpu.h +++ b/src/devices/cpu/ccpu/ccpu.h @@ -109,7 +109,7 @@ protected: int m_icount; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/cop400/cop400.cpp b/src/devices/cpu/cop400/cop400.cpp index 47646cc440a..6317e4451f8 100644 --- a/src/devices/cpu/cop400/cop400.cpp +++ b/src/devices/cpu/cop400/cop400.cpp @@ -96,7 +96,7 @@ DEFINE_DEVICE_TYPE(COP446C, cop446c_cpu_device, "cop446c", "National Semiconduct MACROS ***************************************************************************/ -#define ROM(a) m_direct->read_byte(a) +#define ROM(a) m_cache->read_byte(a) #define RAM_R(a) m_data->read_byte(a) #define RAM_W(a, v) m_data->write_byte(a, v) @@ -1074,7 +1074,7 @@ void cop400_cpu_device::device_start() { /* find address spaces */ m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); /* find i/o handlers */ diff --git a/src/devices/cpu/cop400/cop400.h b/src/devices/cpu/cop400/cop400.h index 6c32ab274d2..197cf86abf1 100644 --- a/src/devices/cpu/cop400/cop400.h +++ b/src/devices/cpu/cop400/cop400.h @@ -211,7 +211,7 @@ protected: bool m_has_inil; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; uint8_t m_featuremask; diff --git a/src/devices/cpu/cosmac/cosmac.cpp b/src/devices/cpu/cosmac/cosmac.cpp index 7be0ae0dd76..ca709bdb943 100644 --- a/src/devices/cpu/cosmac/cosmac.cpp +++ b/src/devices/cpu/cosmac/cosmac.cpp @@ -291,7 +291,7 @@ cosmac_device::cosmac_device(const machine_config &mconfig, device_type type, co m_dmaout(CLEAR_LINE), m_program(nullptr), m_io(nullptr), - m_direct(nullptr) + m_cache(nullptr) { for (auto & elem : m_ef) elem = CLEAR_LINE; @@ -338,7 +338,7 @@ void cosmac_device::device_start() // get our address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); // register our state for the debugger @@ -505,7 +505,7 @@ std::unique_ptr<util::disasm_interface> cdp1802_device::create_disassembler() inline uint8_t cosmac_device::read_opcode(offs_t pc) { - return m_direct->read_byte(pc); + return m_cache->read_byte(pc); } diff --git a/src/devices/cpu/cosmac/cosmac.h b/src/devices/cpu/cosmac/cosmac.h index e52762fbc10..4a535f3c4c1 100644 --- a/src/devices/cpu/cosmac/cosmac.h +++ b/src/devices/cpu/cosmac/cosmac.h @@ -437,7 +437,7 @@ protected: int m_icount; address_space * m_program; address_space * m_io; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; // opcode/condition tables typedef void (cosmac_device::*ophandler)(); diff --git a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp index 270ac0e29c8..0fa20e4e26c 100644 --- a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp +++ b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp @@ -183,7 +183,7 @@ void cquestsnd_cpu_device::device_start() m_sound_data = (uint16_t*)machine().root_device().memregion(m_sound_region_tag)->base(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-3>(); + m_cache = m_program->cache<3, -3, ENDIANNESS_LITTLE>(); memset(m_ram, 0, sizeof(m_ram)); m_q = 0; @@ -262,7 +262,7 @@ void cquestrot_cpu_device::device_start() m_linedata_w.resolve_safe(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-3>(); + m_cache = m_program->cache<3, -3, ENDIANNESS_LITTLE>(); memset(m_ram, 0, sizeof(m_ram)); m_q = 0; @@ -393,7 +393,7 @@ void cquestlin_cpu_device::device_start() m_linedata_r.resolve_safe(0); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-3>(); + m_cache = m_program->cache<3, -3, ENDIANNESS_LITTLE>(); memset(m_ram, 0, sizeof(m_ram)); m_q = 0; @@ -542,7 +542,7 @@ void cquestsnd_cpu_device::execute_run() do { /* Decode the instruction */ - uint64_t inst = m_direct->read_qword(SND_PC); + uint64_t inst = m_cache->read_qword(SND_PC); uint32_t inslow = inst & 0xffffffff; uint32_t inshig = inst >> 32; @@ -798,7 +798,7 @@ void cquestrot_cpu_device::execute_run() do { /* Decode the instruction */ - uint64_t inst = m_direct->read_qword(ROT_PC); + uint64_t inst = m_cache->read_qword(ROT_PC); uint32_t inslow = inst & 0xffffffff; uint32_t inshig = inst >> 32; @@ -1218,7 +1218,7 @@ void cquestlin_cpu_device::execute_run() int prog = (m_clkcnt & 3) ? BACKGROUND : FOREGROUND; m_curpc = LINE_PC; - uint64_t inst = m_direct->read_qword(LINE_PC); + uint64_t inst = m_cache->read_qword(LINE_PC); uint32_t inslow = inst & 0xffffffff; uint32_t inshig = inst >> 32; diff --git a/src/devices/cpu/cubeqcpu/cubeqcpu.h b/src/devices/cpu/cubeqcpu/cubeqcpu.h index cc8cc85bf93..f0da8a314da 100644 --- a/src/devices/cpu/cubeqcpu/cubeqcpu.h +++ b/src/devices/cpu/cubeqcpu/cubeqcpu.h @@ -118,7 +118,7 @@ private: uint16_t *m_sound_data; address_space *m_program; - direct_read_data<-3> *m_direct; + memory_access_cache<3, -3, ENDIANNESS_LITTLE> *m_cache; int m_icount; int do_sndjmp(int jmp); @@ -227,7 +227,7 @@ private: uint8_t m_clkcnt; address_space *m_program; - direct_read_data<-3> *m_direct; + memory_access_cache<3, -3, ENDIANNESS_LITTLE> *m_cache; int m_icount; // For the debugger @@ -344,7 +344,7 @@ private: uint32_t m_o_stack[32768]; /* Stack DRAM: 32kx20 */ address_space *m_program; - direct_read_data<-3> *m_direct; + memory_access_cache<3, -3, ENDIANNESS_LITTLE> *m_cache; int m_icount; // For the debugger diff --git a/src/devices/cpu/diablo/diablo1300.cpp b/src/devices/cpu/diablo/diablo1300.cpp index 582320c37b8..5c809be344d 100644 --- a/src/devices/cpu/diablo/diablo1300.cpp +++ b/src/devices/cpu/diablo/diablo1300.cpp @@ -27,7 +27,7 @@ inline uint16_t diablo1300_cpu_device::opcode_read(uint16_t address) { - return m_direct->read_word(address); + return m_cache->read_word(address); } inline uint16_t diablo1300_cpu_device::program_read16(uint16_t address) @@ -81,7 +81,7 @@ diablo1300_cpu_device::diablo1300_cpu_device(const machine_config &mconfig, cons , m_power_on(ASSERT_LINE) , m_program(nullptr) , m_data(nullptr) - , m_direct(nullptr) + , m_cache(nullptr) { // Allocate & setup @@ -92,7 +92,7 @@ void diablo1300_cpu_device::device_start() { m_program = &space(AS_PROGRAM); m_data = &space(AS_DATA); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_pc).noshow(); diff --git a/src/devices/cpu/diablo/diablo1300.h b/src/devices/cpu/diablo/diablo1300.h index a143d121aca..4919448c081 100644 --- a/src/devices/cpu/diablo/diablo1300.h +++ b/src/devices/cpu/diablo/diablo1300.h @@ -74,7 +74,7 @@ protected: // address spaces address_space *m_program; address_space *m_data; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; }; // device type definition diff --git a/src/devices/cpu/dsp16/dsp16.cpp b/src/devices/cpu/dsp16/dsp16.cpp index 56a014ed045..5fbc4c2ad10 100644 --- a/src/devices/cpu/dsp16/dsp16.cpp +++ b/src/devices/cpu/dsp16/dsp16.cpp @@ -186,7 +186,7 @@ dsp16_device_base::dsp16_device_base( { "ram", ENDIANNESS_BIG, 16, yaau_bits, -1, std::move(data_map) }, { "exm", ENDIANNESS_BIG, 16, 16, -1 } } , m_yaau_bits(yaau_bits) - , m_workram(*this, "workram"), m_spaces{ nullptr, nullptr, nullptr }, m_direct(nullptr), m_workram_mask(0U) + , m_workram(*this, "workram"), m_spaces{ nullptr, nullptr, nullptr }, m_pcache(nullptr), m_workram_mask(0U) , m_drc_cache(CACHE_SIZE), m_core(nullptr, [] (core_state *core) { core->~core_state(); }), m_recompiler() , m_cache_mode(cache::NONE), m_phase(phase::PURGE), m_int_enable{ 0U, 0U }, m_flags(FLAGS_NONE), m_cache_ptr(0U), m_cache_limit(0U), m_cache_iterations(0U) , m_exm_in(1U), m_int_in(CLEAR_LINE), m_iack_out(1U) @@ -231,7 +231,7 @@ void dsp16_device_base::device_start() m_spaces[AS_PROGRAM] = &space(AS_PROGRAM); m_spaces[AS_DATA] = &space(AS_DATA); m_spaces[AS_IO] = &space(AS_IO); - m_direct = m_spaces[AS_PROGRAM]->direct<-1>(); + m_pcache = m_spaces[AS_PROGRAM]->cache<1, -1, ENDIANNESS_BIG>(); m_workram_mask = u16((m_workram.bytes() >> 1) - 1); if (allow_drc()) @@ -1133,7 +1133,7 @@ template <bool Debugger, bool Caching> inline void dsp16_device_base::execute_so set_predicate(predicate); if (fetch_target) - *fetch_target = m_direct->read_word(fetch_addr); + *fetch_target = m_pcache->read_word(fetch_addr); if (phase::OP1 == m_phase) { @@ -1274,7 +1274,7 @@ template <bool Debugger> inline void dsp16_device_base::execute_some_cache() m_core->op_dau_ad(op) = d; if (last_instruction) { - m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_rom_data = m_pcache->read_word(m_core->xaau_pt); m_phase = phase::OP2; } else @@ -1289,7 +1289,7 @@ template <bool Debugger> inline void dsp16_device_base::execute_some_cache() m_core->op_dau_ad(op) = m_core->dau_f1(op); m_core->dau_temp = s16(m_core->dau_y >> 16); m_core->dau_set_y(yaau_read<Debugger>(op)); - m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_rom_data = m_pcache->read_word(m_core->xaau_pt); m_phase = phase::OP2; break; @@ -1298,7 +1298,7 @@ template <bool Debugger> inline void dsp16_device_base::execute_some_cache() m_core->dau_set_y(yaau_read<Debugger>(op)); if (last_instruction) { - m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_rom_data = m_pcache->read_word(m_core->xaau_pt); m_phase = phase::OP2; } else @@ -1384,7 +1384,7 @@ template <bool Debugger> inline void dsp16_device_base::execute_some_cache() // overlapped fetch of next instruction from ROM mode_change = true; m_cache_mode = cache::NONE; - m_cache[m_cache_ptr = 0] = m_direct->read_word(m_core->xaau_pc); + m_cache[m_cache_ptr = 0] = m_pcache->read_word(m_core->xaau_pc); m_st_pcbase = m_core->xaau_pc; } else @@ -1420,7 +1420,7 @@ inline void dsp16_device_base::overlap_rom_data_read() case 0x19: // F1 ; y = a0 ; x = *pt++[i] case 0x1b: // F1 ; y = a1 ; x = *pt++[i] case 0x1f: // F1 ; y = Y ; x = *pt++[i] - m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_rom_data = m_pcache->read_word(m_core->xaau_pt); break; } } diff --git a/src/devices/cpu/dsp16/dsp16.h b/src/devices/cpu/dsp16/dsp16.h index 395ac25e84a..c0fca2c9960 100644 --- a/src/devices/cpu/dsp16/dsp16.h +++ b/src/devices/cpu/dsp16/dsp16.h @@ -325,7 +325,7 @@ private: // memory system access required_shared_ptr<u16> m_workram; address_space *m_spaces[3]; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_BIG> *m_pcache; u16 m_workram_mask; // recompiler stuff diff --git a/src/devices/cpu/dsp16/dsp16fe.cpp b/src/devices/cpu/dsp16/dsp16fe.cpp index 2957a930281..f7387768ccb 100644 --- a/src/devices/cpu/dsp16/dsp16fe.cpp +++ b/src/devices/cpu/dsp16/dsp16fe.cpp @@ -30,7 +30,7 @@ bool dsp16_device_base::frontend::describe(opcode_desc &desc, opcode_desc const desc.length = 1U; desc.cycles = 1U; - u16 const op(m_host.m_direct->read_word(desc.physpc)); + u16 const op(m_host.m_pcache->read_word(desc.physpc)); switch (op >> 11) { case 0x00: // goto JA @@ -221,7 +221,7 @@ bool dsp16_device_base::frontend::describe(opcode_desc &desc, opcode_desc const u16 dsp16_device_base::frontend::read_op(opcode_desc const &desc, u16 offset) const { - return m_host.m_direct->read_word((desc.physpc & XAAU_I_EXT) | ((desc.physpc + offset) & XAAU_I_MASK)); + return m_host.m_pcache->read_word((desc.physpc & XAAU_I_EXT) | ((desc.physpc + offset) & XAAU_I_MASK)); } /*********************************************************************** diff --git a/src/devices/cpu/dsp32/dsp32.cpp b/src/devices/cpu/dsp32/dsp32.cpp index 388484975e9..26310c760ad 100644 --- a/src/devices/cpu/dsp32/dsp32.cpp +++ b/src/devices/cpu/dsp32/dsp32.cpp @@ -175,7 +175,7 @@ dsp32c_device::dsp32c_device(const machine_config &mconfig, const char *tag, dev m_lastpins(0), m_ppc(0), m_program(nullptr), - m_direct(nullptr), + m_cache(nullptr), m_output_pins_changed(*this) { // set our instruction counter @@ -192,7 +192,7 @@ void dsp32c_device::device_start() // get our address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_r[15]).noshow(); @@ -415,7 +415,7 @@ std::unique_ptr<util::disasm_interface> dsp32c_device::create_disassembler() inline uint32_t dsp32c_device::ROPCODE(offs_t pc) { - return m_direct->read_dword(pc); + return m_cache->read_dword(pc); } inline uint8_t dsp32c_device::RBYTE(offs_t addr) diff --git a/src/devices/cpu/dsp32/dsp32.h b/src/devices/cpu/dsp32/dsp32.h index 5596714f03f..7de09dd1198 100644 --- a/src/devices/cpu/dsp32/dsp32.h +++ b/src/devices/cpu/dsp32/dsp32.h @@ -421,7 +421,7 @@ protected: uint8_t m_lastpins; uint32_t m_ppc; address_space * m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; devcb_write32 m_output_pins_changed; // tables diff --git a/src/devices/cpu/dsp56k/dsp56k.cpp b/src/devices/cpu/dsp56k/dsp56k.cpp index 4b916bbfebe..f937359070e 100644 --- a/src/devices/cpu/dsp56k/dsp56k.cpp +++ b/src/devices/cpu/dsp56k/dsp56k.cpp @@ -141,7 +141,7 @@ device_memory_interface::space_config_vector dsp56k_device::memory_space_config( /*************************************************************************** MEMORY ACCESSORS ***************************************************************************/ -#define ROPCODE(pc) cpustate->direct->read_word(pc) +#define ROPCODE(pc) cpustate->cache->read_word(pc) /*************************************************************************** @@ -292,7 +292,7 @@ void dsp56k_device::device_start() save_item(NAME(m_dsp56k_core.peripheral_ram)); m_dsp56k_core.program = &space(AS_PROGRAM); - m_dsp56k_core.direct = m_dsp56k_core.program->direct<-1>(); + m_dsp56k_core.cache = m_dsp56k_core.program->cache<1, -1, ENDIANNESS_LITTLE>(); m_dsp56k_core.data = &space(AS_DATA); state_add(DSP56K_PC, "PC", m_dsp56k_core.PCU.pc).formatstr("%04X"); diff --git a/src/devices/cpu/dsp56k/dsp56k.h b/src/devices/cpu/dsp56k/dsp56k.h index ea8e5f8c281..e13b160c8a4 100644 --- a/src/devices/cpu/dsp56k/dsp56k.h +++ b/src/devices/cpu/dsp56k/dsp56k.h @@ -192,7 +192,7 @@ struct dsp56k_core void (*output_pins_changed)(uint32_t pins); cpu_device *device; address_space *program; - direct_read_data<-1> *direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *cache; address_space *data; uint16_t peripheral_ram[0x40]; diff --git a/src/devices/cpu/e132xs/32xsdefs.h b/src/devices/cpu/e132xs/32xsdefs.h index 94333e2adf9..1a81b30dc5b 100644 --- a/src/devices/cpu/e132xs/32xsdefs.h +++ b/src/devices/cpu/e132xs/32xsdefs.h @@ -130,7 +130,7 @@ #define IO_WRITE_W(addr, data) m_io->write_dword(((addr) >> 11) & 0x7ffc, data) -#define READ_OP(addr) m_direct->read_word((addr), m_core->opcodexor) +#define READ_OP(addr) m_pr16(addr) // set C in adds/addsi/subs/sums #define SETCARRYS 0 diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index f23a5a6c8e9..31e9e1fa3c5 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1123,7 +1123,29 @@ void hyperstone_device::init(int scale_mask) m_instruction_length = 0; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if (m_program->data_width() == 16) + { + auto cache = m_program->cache<1, 0, ENDIANNESS_BIG>(); + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } + else + { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~3)); + ptr += (~address >> 1) & 3; + return ptr; + }; + else + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~3)); + ptr += (address >> 1) & 3; + return ptr; + }; + } m_io = &space(AS_IO); m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(hyperstone_device::timer_callback), this)); @@ -1309,95 +1331,77 @@ void hyperstone_device::init(int scale_mask) void e116t_device::device_start() { init(0); - m_core->opcodexor = 0; } void e116xt_device::device_start() { init(3); - m_core->opcodexor = 0; } void e116xs_device::device_start() { init(7); - m_core->opcodexor = 0; } void e116xsr_device::device_start() { init(7); - m_core->opcodexor = 0; } void gms30c2116_device::device_start() { init(0); - m_core->opcodexor = 0; } void gms30c2216_device::device_start() { init(0); - m_core->opcodexor = 0; } void e132n_device::device_start() { init(0); - m_core->opcodexor = WORD_XOR_BE(0); } void e132t_device::device_start() { init(0); - m_core->opcodexor = WORD_XOR_BE(0); } void e132xn_device::device_start() { init(3); - m_core->opcodexor = WORD_XOR_BE(0); } void e132xt_device::device_start() { init(3); - m_core->opcodexor = WORD_XOR_BE(0); } void e132xs_device::device_start() { init(7); - m_core->opcodexor = WORD_XOR_BE(0); } void e132xsr_device::device_start() { init(7); - m_core->opcodexor = WORD_XOR_BE(0); } void gms30c2132_device::device_start() { init(0); - m_core->opcodexor = WORD_XOR_BE(0); } void gms30c2232_device::device_start() { init(0); - m_core->opcodexor = WORD_XOR_BE(0); } void hyperstone_device::device_reset() { //TODO: Add different reset initializations for BCR, MCR, FCR, TPR - m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); - m_io = &space(AS_IO); - m_core->tr_clocks_per_tick = 2; m_core->trap_entry = s_trap_entries[E132XS_ENTRY_MEM3]; // default entry point @ MEM3 diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 57cd7516d6e..c9df8f271f6 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -185,8 +185,6 @@ protected: uint32_t delay_slot; uint32_t delay_slot_taken; - uint32_t opcodexor; - int32_t intblock; uint32_t arg0; @@ -305,7 +303,8 @@ protected: const address_space_config m_program_config; const address_space_config m_io_config; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u16 (offs_t)> m_pr16; + std::function<const void * (offs_t)> m_prptr; address_space *m_io; uint16_t m_op; // opcode diff --git a/src/devices/cpu/e132xs/e132xsdrc.cpp b/src/devices/cpu/e132xs/e132xsdrc.cpp index 98daaa45817..0603e8eeeec 100644 --- a/src/devices/cpu/e132xs/e132xsdrc.cpp +++ b/src/devices/cpu/e132xs/e132xsdrc.cpp @@ -786,10 +786,10 @@ void hyperstone_device::generate_checksum_block(drcuml_block &block, compiler_st { uint32_t sum = seqhead->opptr.w[0]; uint32_t addr = seqhead->physpc; - void *base = m_direct->read_ptr(addr, m_core->opcodexor); + const void *base = m_prptr(addr); if (base == nullptr) { - printf("m_direct->read_ptr returned nullptr for address %08x\n", addr); + printf("cache read_ptr returned nullptr for address %08x\n", addr); return; } UML_LOAD(block, I0, base, 0, SIZE_WORD, SCALE_x1); @@ -797,7 +797,7 @@ void hyperstone_device::generate_checksum_block(drcuml_block &block, compiler_st if (seqhead->delay.first() != nullptr && seqhead->physpc != seqhead->delay.first()->physpc) { addr = seqhead->delay.first()->physpc; - base = m_direct->read_ptr(addr, m_core->opcodexor); + base = m_prptr(addr); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_WORD, SCALE_x1); UML_ADD(block, I0, I0, I1); @@ -812,10 +812,10 @@ void hyperstone_device::generate_checksum_block(drcuml_block &block, compiler_st else /* full verification; sum up everything */ { uint32_t addr = seqhead->physpc; - void *base = m_direct->read_ptr(addr, m_core->opcodexor); + const void *base = m_prptr(addr); if (base == nullptr) { - printf("m_direct->read_ptr returned nullptr for address %08x\n", addr); + printf("cache read_ptr returned nullptr for address %08x\n", addr); return; } UML_LOAD(block, I0, base, 0, SIZE_WORD, SCALE_x1); @@ -824,7 +824,7 @@ void hyperstone_device::generate_checksum_block(drcuml_block &block, compiler_st if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { addr = curdesc->physpc; - base = m_direct->read_ptr(addr, m_core->opcodexor); + base = m_prptr(addr); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_WORD, SCALE_x1); UML_ADD(block, I0, I0, I1); @@ -833,7 +833,7 @@ void hyperstone_device::generate_checksum_block(drcuml_block &block, compiler_st if (curdesc->delay.first() != nullptr && (curdesc == seqlast || (curdesc->next() != nullptr && curdesc->next()->physpc != curdesc->delay.first()->physpc))) { addr = curdesc->delay.first()->physpc; - base = m_direct->read_ptr(addr, m_core->opcodexor); + base = m_prptr(addr); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_WORD, SCALE_x1); UML_ADD(block, I0, I0, I1); diff --git a/src/devices/cpu/e132xs/e132xsfe.cpp b/src/devices/cpu/e132xs/e132xsfe.cpp index 474661e5821..0b2edeb0b0b 100644 --- a/src/devices/cpu/e132xs/e132xsfe.cpp +++ b/src/devices/cpu/e132xs/e132xsfe.cpp @@ -46,17 +46,17 @@ inline uint32_t e132xs_frontend::imm_length(opcode_desc &desc, uint16_t op) inline uint16_t e132xs_frontend::read_word(opcode_desc &desc) { - return m_cpu->m_direct->read_word(desc.physpc, m_cpu->m_core->opcodexor); + return m_cpu->m_pr16(desc.physpc); } inline uint16_t e132xs_frontend::read_imm1(opcode_desc &desc) { - return m_cpu->m_direct->read_word(desc.physpc + 2, m_cpu->m_core->opcodexor); + return m_cpu->m_pr16(desc.physpc + 2); } inline uint16_t e132xs_frontend::read_imm2(opcode_desc &desc) { - return m_cpu->m_direct->read_word(desc.physpc + 4, m_cpu->m_core->opcodexor); + return m_cpu->m_pr16(desc.physpc + 4); } inline uint32_t e132xs_frontend::read_ldstxx_imm(opcode_desc &desc) diff --git a/src/devices/cpu/esrip/esrip.cpp b/src/devices/cpu/esrip/esrip.cpp index b4cfa1f0d01..d3b8b54e225 100644 --- a/src/devices/cpu/esrip/esrip.cpp +++ b/src/devices/cpu/esrip/esrip.cpp @@ -193,7 +193,7 @@ void esrip_device::device_start() m_ipt_ram.resize(IPT_RAM_SIZE/2); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-3>(); + m_cache = m_program->cache<3, -3, ENDIANNESS_BIG>(); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_rip_pc).noshow(); @@ -1879,7 +1879,7 @@ void esrip_device::execute_run() m_pl7 = m_l7; /* Latch instruction */ - inst = m_direct->read_qword(RIP_PC); + inst = m_cache->read_qword(RIP_PC); in_h = inst >> 32; in_l = inst & 0xffffffff; diff --git a/src/devices/cpu/esrip/esrip.h b/src/devices/cpu/esrip/esrip.h index 1c13848d40d..a97675e9be4 100644 --- a/src/devices/cpu/esrip/esrip.h +++ b/src/devices/cpu/esrip/esrip.h @@ -196,7 +196,7 @@ protected: uint8_t *m_lbrm; address_space *m_program; - direct_read_data<-3> *m_direct; + memory_access_cache<3, -3, ENDIANNESS_BIG> *m_cache; int m_icount; diff --git a/src/devices/cpu/f8/f8.cpp b/src/devices/cpu/f8/f8.cpp index 1f98ed1fe76..136f6cec2a7 100644 --- a/src/devices/cpu/f8/f8.cpp +++ b/src/devices/cpu/f8/f8.cpp @@ -77,7 +77,7 @@ void f8_cpu_device::state_string_export(const device_state_entry &entry, std::st void f8_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_iospace = &space(AS_IO); save_item(NAME(m_debug_pc)); @@ -315,7 +315,7 @@ void f8_cpu_device::ROMC_00(int insttim) * of PC0. */ - m_dbus = m_direct->read_byte(m_pc0); + m_dbus = m_cache->read_byte(m_pc0); m_pc0 += 1; m_icount -= insttim; /* ROMC00 is usually short, not short+long, but DS is long */ } @@ -328,7 +328,7 @@ void f8_cpu_device::ROMC_01() * location addressed by PC0; then all devices add the 8-bit value * on the data bus as signed binary number to PC0. */ - m_dbus = m_direct->read_byte(m_pc0); + m_dbus = m_cache->read_byte(m_pc0); m_pc0 += (s8)m_dbus; m_icount -= cL; } @@ -352,7 +352,7 @@ void f8_cpu_device::ROMC_03(int insttim) * Similiar to 0x00, except that it is used for immediate operands * fetches (using PC0) instead of instruction fetches. */ - m_dbus = m_io = m_direct->read_byte(m_pc0); + m_dbus = m_io = m_cache->read_byte(m_pc0); m_pc0 += 1; m_icount -= insttim; } @@ -446,7 +446,7 @@ void f8_cpu_device::ROMC_0C() * by PC0 into the data bus; then all devices move the value that * has just been placed on the data bus into the low order byte of PC0. */ - m_dbus = m_direct->read_byte(m_pc0); + m_dbus = m_cache->read_byte(m_pc0); m_pc0 = (m_pc0 & 0xff00) | m_dbus; m_icount -= cL; } @@ -469,7 +469,7 @@ void f8_cpu_device::ROMC_0E() * The value on the data bus is then moved to the low order byte * of DC0 by all devices. */ - m_dbus = m_direct->read_byte(m_pc0); + m_dbus = m_cache->read_byte(m_pc0); m_dc0 = (m_dc0 & 0xff00) | m_dbus; m_icount -= cL; } @@ -507,7 +507,7 @@ void f8_cpu_device::ROMC_11() * data bus. All devices must then move the contents of the * data bus to the upper byte of DC0. */ - m_dbus = m_direct->read_byte(m_pc0); + m_dbus = m_cache->read_byte(m_pc0); m_dc0 = (m_dc0 & 0x00ff) | (m_dbus << 8); m_icount -= cL; } diff --git a/src/devices/cpu/f8/f8.h b/src/devices/cpu/f8/f8.h index a8cf2ca367d..cdd8f03b862 100644 --- a/src/devices/cpu/f8/f8.h +++ b/src/devices/cpu/f8/f8.h @@ -70,7 +70,7 @@ private: u16 m_io; /* last I/O address */ u16 m_irq_vector; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_iospace; int m_icount; u8 m_r[64]; /* scratchpad RAM */ diff --git a/src/devices/cpu/g65816/g65816.cpp b/src/devices/cpu/g65816/g65816.cpp index 711a2976e2b..8b547f1e317 100644 --- a/src/devices/cpu/g65816/g65816.cpp +++ b/src/devices/cpu/g65816/g65816.cpp @@ -857,8 +857,8 @@ void g65816_device::device_start() address_space &program_space = space(AS_PROGRAM); m_data_space = has_space(AS_DATA) ? &space(AS_DATA) : &program_space; - m_program_direct = program_space.direct<0>(); - m_opcode_direct = (has_space(AS_OPCODES) ? space(AS_OPCODES) : program_space).direct<0>(); + m_program_cache = program_space.cache<0, 0, ENDIANNESS_LITTLE>(); + m_opcode_cache = (has_space(AS_OPCODES) ? space(AS_OPCODES) : program_space).cache<0, 0, ENDIANNESS_LITTLE>(); save_item(NAME(m_a)); save_item(NAME(m_b)); diff --git a/src/devices/cpu/g65816/g65816.h b/src/devices/cpu/g65816/g65816.h index 4078ffcea0c..e53f9eb784b 100644 --- a/src/devices/cpu/g65816/g65816.h +++ b/src/devices/cpu/g65816/g65816.h @@ -229,8 +229,8 @@ protected: unsigned m_ir; /* Instruction Register */ unsigned m_irq_delay; /* delay 1 instruction before checking irq */ address_space *m_data_space; - direct_read_data<0> *m_program_direct; - direct_read_data<0> *m_opcode_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_program_cache; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_opcode_cache; unsigned m_stopped; /* Sets how the CPU is stopped */ const opcode_func* m_opcodes; get_reg_func m_get_reg; diff --git a/src/devices/cpu/g65816/g65816cm.h b/src/devices/cpu/g65816/g65816cm.h index 5eea37da37d..6991eca301e 100644 --- a/src/devices/cpu/g65816/g65816cm.h +++ b/src/devices/cpu/g65816/g65816cm.h @@ -15,8 +15,8 @@ #define g65816_read_8(addr) m_data_space->read_byte(addr) #define g65816_write_8(addr,data) m_data_space->write_byte(addr,data) -#define g65816_read_8_immediate(A) m_program_direct->read_byte(A) -#define g65816_read_8_opcode(A) m_opcode_direct->read_byte(A) +#define g65816_read_8_immediate(A) m_program_cache->read_byte(A) +#define g65816_read_8_opcode(A) m_opcode_cache->read_byte(A) #define g65816_jumping(A) #define g65816_branching(A) diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index 14705c93dd7..2a38aed615f 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -301,7 +301,7 @@ void h6280_device::device_reset() m_io_buffer = 0; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); /* set I and B flags */ @@ -2375,7 +2375,7 @@ void h6280_device::pull(uint8_t &value) ***************************************************************/ uint8_t h6280_device::read_opcode() { - return m_direct->read_byte(translated(PCW)); + return m_cache->read_byte(translated(PCW)); } /*************************************************************** @@ -2383,7 +2383,7 @@ uint8_t h6280_device::read_opcode() ***************************************************************/ uint8_t h6280_device::read_opcode_arg() { - return m_direct->read_byte(translated(PCW)); + return m_cache->read_byte(translated(PCW)); } diff --git a/src/devices/cpu/h6280/h6280.h b/src/devices/cpu/h6280/h6280.h index a1f64139b1a..22155e0edb6 100644 --- a/src/devices/cpu/h6280/h6280.h +++ b/src/devices/cpu/h6280/h6280.h @@ -357,7 +357,7 @@ protected: // address spaces address_space *m_program; address_space *m_io; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; typedef void (h6280_device::*ophandler)(); diff --git a/src/devices/cpu/h8/h8.cpp b/src/devices/cpu/h8/h8.cpp index f8588a55b66..3863407c64c 100644 --- a/src/devices/cpu/h8/h8.cpp +++ b/src/devices/cpu/h8/h8.cpp @@ -19,7 +19,7 @@ h8_device::h8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool mode_a16, address_map_constructor map_delegate) : cpu_device(mconfig, type, tag, owner, clock), program_config("program", ENDIANNESS_BIG, 16, mode_a16 ? 16 : 24, 0, map_delegate), - io_config("io", ENDIANNESS_BIG, 16, 16, -1), program(nullptr), io(nullptr), direct(nullptr), PPC(0), NPC(0), PC(0), PIR(0), EXR(0), CCR(0), MAC(0), MACF(0), + io_config("io", ENDIANNESS_BIG, 16, 16, -1), program(nullptr), io(nullptr), cache(nullptr), PPC(0), NPC(0), PC(0), PIR(0), EXR(0), CCR(0), MAC(0), MACF(0), TMP1(0), TMP2(0), TMPR(0), inst_state(0), inst_substate(0), icount(0), bcount(0), irq_vector(0), taken_irq_vector(0), irq_level(0), taken_irq_level(0), irq_required(false), irq_nmi(false) { supports_advanced = false; @@ -32,7 +32,7 @@ h8_device::h8_device(const machine_config &mconfig, device_type type, const char void h8_device::device_start() { program = &space(AS_PROGRAM); - direct = program->direct<0>(); + cache = program->cache<1, 0, ENDIANNESS_BIG>(); io = &space(AS_IO); state_add(STATE_GENPC, "GENPC", NPC).noshow(); @@ -328,7 +328,7 @@ void h8_device::state_string_export(const device_state_entry &entry, std::string uint16_t h8_device::read16i(uint32_t adr) { icount--; - return direct->read_word(adr & ~1); + return cache->read_word(adr & ~1); } uint16_t h8_device::fetch() diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h index aa3de0c91ef..598e033fa87 100644 --- a/src/devices/cpu/h8/h8.h +++ b/src/devices/cpu/h8/h8.h @@ -112,7 +112,7 @@ protected: address_space_config program_config, io_config; address_space *program, *io; - direct_read_data<0> *direct; + memory_access_cache<1, 0, ENDIANNESS_BIG> *cache; h8_dma_device *dma_device; h8_dtc_device *dtc_device; h8_dma_state *current_dma; diff --git a/src/devices/cpu/hphybrid/hphybrid.cpp b/src/devices/cpu/hphybrid/hphybrid.cpp index 1104e146a7b..280686f5bfa 100644 --- a/src/devices/cpu/hphybrid/hphybrid.cpp +++ b/src/devices/cpu/hphybrid/hphybrid.cpp @@ -202,7 +202,7 @@ void hp_hybrid_cpu_device::device_start() } m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_BIG>(); m_io = &space(AS_IO); save_item(NAME(m_reg_A)); @@ -761,7 +761,7 @@ uint16_t hp_hybrid_cpu_device::RM(uint32_t addr) return read_non_common_reg(addr_wo_bsc); } } else { - return m_direct->read_word(addr); + return m_cache->read_word(addr); } } diff --git a/src/devices/cpu/hphybrid/hphybrid.h b/src/devices/cpu/hphybrid/hphybrid.h index b81c26f08e9..700a2e09894 100644 --- a/src/devices/cpu/hphybrid/hphybrid.h +++ b/src/devices/cpu/hphybrid/hphybrid.h @@ -140,7 +140,7 @@ private: address_space_config m_io_config; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_BIG> *m_cache; address_space *m_io; uint32_t get_ea(uint16_t opcode); diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index a267ab5e548..bfcebd533b2 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -3231,7 +3231,18 @@ void i386_device::i386_common_init() } m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->data_width() == 16) { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + } else { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + } + m_io = &space(AS_IO); m_smi = false; m_debugger_temp = 0; diff --git a/src/devices/cpu/i386/i386.h b/src/devices/cpu/i386/i386.h index 71ea0800216..4112aaf61e1 100644 --- a/src/devices/cpu/i386/i386.h +++ b/src/devices/cpu/i386/i386.h @@ -216,7 +216,9 @@ protected: uint8_t m_irq_state; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t)> m_pr8; + std::function<u16 (offs_t)> m_pr16; + std::function<u32 (offs_t)> m_pr32; address_space *m_io; uint32_t m_a20_mask; diff --git a/src/devices/cpu/i386/i386priv.h b/src/devices/cpu/i386/i386priv.h index e4a16e5aca6..f341edf2551 100644 --- a/src/devices/cpu/i386/i386priv.h +++ b/src/devices/cpu/i386/i386priv.h @@ -542,7 +542,7 @@ uint8_t i386_device::FETCH() if(!translate_address(m_CPL,TRANSLATE_FETCH,&address,&error)) PF_THROW(error); - value = m_direct->read_byte(address & m_a20_mask); + value = m_pr8(address & m_a20_mask); #ifdef DEBUG_MISSING_OPCODE m_opcode_bytes[m_opcode_bytes_length] = value; m_opcode_bytes_length = (m_opcode_bytes_length + 1) & 15; @@ -563,7 +563,7 @@ uint16_t i386_device::FETCH16() if(!translate_address(m_CPL,TRANSLATE_FETCH,&address,&error)) PF_THROW(error); address &= m_a20_mask; - value = m_direct->read_word(address); + value = m_pr16(address); m_eip += 2; m_pc += 2; } @@ -584,7 +584,7 @@ uint32_t i386_device::FETCH32() PF_THROW(error); address &= m_a20_mask; - value = m_direct->read_dword(address); + value = m_pr32(address); m_eip += 4; m_pc += 4; } diff --git a/src/devices/cpu/i8008/i8008.cpp b/src/devices/cpu/i8008/i8008.cpp index 1964c8a4307..351edefb024 100644 --- a/src/devices/cpu/i8008/i8008.cpp +++ b/src/devices/cpu/i8008/i8008.cpp @@ -39,7 +39,7 @@ i8008_device::i8008_device(const machine_config &mconfig, const char *tag, devic , m_program_config("program", ENDIANNESS_LITTLE, 8, 14) , m_io_config("io", ENDIANNESS_LITTLE, 8, 8) , m_program(nullptr) - , m_direct(nullptr) + , m_cache(nullptr) { // set our instruction counter set_icountptr(m_icount); @@ -53,7 +53,7 @@ void i8008_device::device_start() { // find address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); // save state @@ -601,7 +601,7 @@ inline void i8008_device::pop_stack() inline uint8_t i8008_device::rop() { - uint8_t retVal = m_direct->read_byte(GET_PC.w.l); + uint8_t retVal = m_cache->read_byte(GET_PC.w.l); GET_PC.w.l = (GET_PC.w.l + 1) & 0x3fff; m_PC = GET_PC; return retVal; @@ -639,7 +639,7 @@ inline void i8008_device::set_reg(uint8_t reg, uint8_t val) inline uint8_t i8008_device::arg() { - uint8_t retVal = m_direct->read_byte(GET_PC.w.l); + uint8_t retVal = m_cache->read_byte(GET_PC.w.l); GET_PC.w.l = (GET_PC.w.l + 1) & 0x3fff; m_PC = GET_PC; return retVal; diff --git a/src/devices/cpu/i8008/i8008.h b/src/devices/cpu/i8008/i8008.h index 0aedcadd37c..15667390abb 100644 --- a/src/devices/cpu/i8008/i8008.h +++ b/src/devices/cpu/i8008/i8008.h @@ -83,7 +83,7 @@ protected: address_space *m_program; address_space *m_io; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; }; // device type definition diff --git a/src/devices/cpu/i8085/i8085.cpp b/src/devices/cpu/i8085/i8085.cpp index de8c120d19e..0e2bfeaecd1 100644 --- a/src/devices/cpu/i8085/i8085.cpp +++ b/src/devices/cpu/i8085/i8085.cpp @@ -345,8 +345,8 @@ void i8085a_cpu_device::device_start() } m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); - m_opcode_direct = has_space(AS_OPCODES) ? space(AS_OPCODES).direct<0>() : m_direct; + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_opcode_cache = has_space(AS_OPCODES) ? space(AS_OPCODES).cache<0, 0, ENDIANNESS_LITTLE>() : m_cache; m_io = &space(AS_IO); /* resolve callbacks */ @@ -669,21 +669,21 @@ u8 i8085a_cpu_device::get_rim_value() // memory access u8 i8085a_cpu_device::read_arg() { - return m_direct->read_byte(m_PC.w.l++); + return m_cache->read_byte(m_PC.w.l++); } PAIR i8085a_cpu_device::read_arg16() { PAIR p; - p.b.l = m_direct->read_byte(m_PC.w.l++); - p.b.h = m_direct->read_byte(m_PC.w.l++); + p.b.l = m_cache->read_byte(m_PC.w.l++); + p.b.h = m_cache->read_byte(m_PC.w.l++); return p; } u8 i8085a_cpu_device::read_op() { set_status(0xa2); // instruction fetch - return m_opcode_direct->read_byte(m_PC.w.l++); + return m_opcode_cache->read_byte(m_PC.w.l++); } u8 i8085a_cpu_device::read_mem(u32 a) diff --git a/src/devices/cpu/i8085/i8085.h b/src/devices/cpu/i8085/i8085.h index c9f3bd17b87..9d94e850580 100644 --- a/src/devices/cpu/i8085/i8085.h +++ b/src/devices/cpu/i8085/i8085.h @@ -139,8 +139,8 @@ private: bool m_ietemp; /* import/export temp space */ address_space *m_program; - direct_read_data<0> *m_direct; - direct_read_data<0> *m_opcode_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_opcode_cache; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/i86/i186.cpp b/src/devices/cpu/i86/i186.cpp index e1edfedaebd..7738ee64d6c 100644 --- a/src/devices/cpu/i86/i186.cpp +++ b/src/devices/cpu/i86/i186.cpp @@ -125,7 +125,6 @@ i80188_cpu_device::i80188_cpu_device(const machine_config &mconfig, const char * : i80186_cpu_device(mconfig, I80188, tag, owner, clock, 8) { memcpy(m_timing, m_i80186_timing, sizeof(m_i80186_timing)); - m_fetch_xor = 0; set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(i80186_cpu_device::int_callback), this)); } @@ -133,7 +132,6 @@ i80186_cpu_device::i80186_cpu_device(const machine_config &mconfig, const char * : i80186_cpu_device(mconfig, I80186, tag, owner, clock, 16) { memcpy(m_timing, m_i80186_timing, sizeof(m_i80186_timing)); - m_fetch_xor = BYTE_XOR_LE(0); set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(i80186_cpu_device::int_callback), this)); } @@ -166,7 +164,7 @@ device_memory_interface::space_config_vector i80186_cpu_device::memory_space_con uint8_t i80186_cpu_device::fetch() { - uint8_t data = m_direct_opcodes->read_byte(update_pc(), m_fetch_xor); + uint8_t data = m_or8(update_pc()); m_ip++; return data; } diff --git a/src/devices/cpu/i86/i286.cpp b/src/devices/cpu/i86/i286.cpp index 623c2070ff5..5ef63380888 100644 --- a/src/devices/cpu/i86/i286.cpp +++ b/src/devices/cpu/i86/i286.cpp @@ -176,7 +176,6 @@ i80286_cpu_device::i80286_cpu_device(const machine_config &mconfig, const char * { memcpy(m_timing, m_i80286_timing, sizeof(m_i80286_timing)); m_amask = 0xffffff; - m_fetch_xor = BYTE_XOR_LE(0); memset(m_sregs, 0x00, sizeof(m_sregs)); m_sregs[CS] = 0xf000; memset(m_base, 0x00, sizeof(m_base)); @@ -1026,7 +1025,7 @@ uint8_t i80286_cpu_device::fetch() if(m_ip > m_limit[CS]) throw TRAP(FAULT_GP, 0); - data = m_direct_opcodes->read_byte( update_pc() & m_amask, m_fetch_xor ); + data = m_or8(update_pc() & m_amask); m_ip++; return data; } diff --git a/src/devices/cpu/i86/i86.cpp b/src/devices/cpu/i86/i86.cpp index d2f0f60834d..f56f5a40045 100644 --- a/src/devices/cpu/i86/i86.cpp +++ b/src/devices/cpu/i86/i86.cpp @@ -95,14 +95,12 @@ i8088_cpu_device::i8088_cpu_device(const machine_config &mconfig, const char *ta : i8086_cpu_device(mconfig, I8088, tag, owner, clock, 8) { memcpy(m_timing, m_i8086_timing, sizeof(m_i8086_timing)); - m_fetch_xor = 0; } i8086_cpu_device::i8086_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : i8086_cpu_device(mconfig, I8086, tag, owner, clock, 16) { memcpy(m_timing, m_i8086_timing, sizeof(m_i8086_timing)); - m_fetch_xor = BYTE_XOR_LE(0); } i8086_cpu_device::i8086_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int data_bus_size) @@ -139,7 +137,7 @@ device_memory_interface::space_config_vector i8086_cpu_device::memory_space_conf uint8_t i8086_cpu_device::fetch() { uint8_t data; - data = m_direct_opcodes->read_byte(update_pc(), m_fetch_xor); + data = m_or8(update_pc()); m_ip++; return data; } @@ -470,8 +468,14 @@ void i8086_common_cpu_device::device_start() { m_program = &space(AS_PROGRAM); m_opcodes = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; - m_direct = m_program->direct<0>(); - m_direct_opcodes = m_opcodes->direct<0>(); + + if(m_opcodes->data_width() == 8) { + auto cache = m_opcodes->cache<0, 0, ENDIANNESS_LITTLE>(); + m_or8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = m_opcodes->cache<1, 0, ENDIANNESS_LITTLE>(); + m_or8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } m_io = &space(AS_IO); save_item(NAME(m_regs.w)); diff --git a/src/devices/cpu/i86/i86.h b/src/devices/cpu/i86/i86.h index 7d2330e2d11..5c7af40f92b 100644 --- a/src/devices/cpu/i86/i86.h +++ b/src/devices/cpu/i86/i86.h @@ -314,9 +314,8 @@ protected: uint8_t m_test_state; address_space *m_program, *m_opcodes; - direct_read_data<0> *m_direct, *m_direct_opcodes; + std::function<u8 (offs_t)> m_or8; address_space *m_io; - offs_t m_fetch_xor; int m_icount; uint32_t m_prefix_seg; /* the latest prefix segment */ diff --git a/src/devices/cpu/i960/i960.cpp b/src/devices/cpu/i960/i960.cpp index c15c9de821f..28ab1163d97 100644 --- a/src/devices/cpu/i960/i960.cpp +++ b/src/devices/cpu/i960/i960.cpp @@ -19,7 +19,7 @@ i960_cpu_device::i960_cpu_device(const machine_config &mconfig, const char *tag, : cpu_device(mconfig, I960, tag, owner, clock) , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) , m_rcache_pos(0), m_SAT(0), m_PRCB(0), m_PC(0), m_AC(0), m_IP(0), m_PIP(0), m_ICR(0), m_bursting(0), m_immediate_irq(0) - , m_immediate_vector(0), m_immediate_pri(0), m_program(nullptr), m_direct(nullptr), m_icount(0) + , m_immediate_vector(0), m_immediate_pri(0), m_program(nullptr), m_cache(nullptr), m_icount(0) { } @@ -116,7 +116,7 @@ uint32_t i960_cpu_device::get_ea(uint32_t opcode) case 0x5: // address of this instruction + the offset dword + 8 // which in reality is "address of next instruction + the offset dword" - ret = m_direct->read_dword(m_IP); + ret = m_cache->read_dword(m_IP); m_IP += 4; ret += m_IP; return ret; @@ -125,22 +125,22 @@ uint32_t i960_cpu_device::get_ea(uint32_t opcode) return m_r[abase] + (m_r[index] << scale); case 0xc: - ret = m_direct->read_dword(m_IP); + ret = m_cache->read_dword(m_IP); m_IP += 4; return ret; case 0xd: - ret = m_direct->read_dword(m_IP) + m_r[abase]; + ret = m_cache->read_dword(m_IP) + m_r[abase]; m_IP += 4; return ret; case 0xe: - ret = m_direct->read_dword(m_IP) + (m_r[index] << scale); + ret = m_cache->read_dword(m_IP) + (m_r[index] << scale); m_IP += 4; return ret; case 0xf: - ret = m_direct->read_dword(m_IP) + m_r[abase] + (m_r[index] << scale); + ret = m_cache->read_dword(m_IP) + m_r[abase] + (m_r[index] << scale); m_IP += 4; return ret; @@ -2118,7 +2118,7 @@ void i960_cpu_device::execute_run() m_bursting = 0; - opcode = m_direct->read_dword(m_IP); + opcode = m_cache->read_dword(m_IP); m_IP += 4; m_stalled = false; @@ -2202,7 +2202,7 @@ void i960_cpu_device::execute_set_input(int irqline, int state) void i960_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); save_item(NAME(m_IP)); save_item(NAME(m_PIP)); diff --git a/src/devices/cpu/i960/i960.h b/src/devices/cpu/i960/i960.h index cb5164cd7dd..a17a52c401b 100644 --- a/src/devices/cpu/i960/i960.h +++ b/src/devices/cpu/i960/i960.h @@ -139,7 +139,7 @@ private: int m_immediate_pri; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; diff --git a/src/devices/cpu/ie15/ie15.cpp b/src/devices/cpu/ie15/ie15.cpp index 9b101558139..90a58f83e9f 100644 --- a/src/devices/cpu/ie15/ie15.cpp +++ b/src/devices/cpu/ie15/ie15.cpp @@ -35,7 +35,7 @@ ie15_cpu_device::ie15_cpu_device(const machine_config &mconfig, const char *tag, : cpu_device(mconfig, IE15_CPU, tag, owner, clock) , m_program_config("program", ENDIANNESS_LITTLE, 8, 14) , m_io_config("io", ENDIANNESS_LITTLE, 8, 8), m_A(0), m_CF(0), m_ZF(0), m_RF(0), m_flags(0) - , m_program(nullptr), m_io(nullptr), m_direct(nullptr) + , m_program(nullptr), m_io(nullptr), m_cache(nullptr) { // set our instruction counter set_icountptr(m_icount); @@ -49,7 +49,7 @@ void ie15_cpu_device::device_start() { // find address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); // save state @@ -406,14 +406,14 @@ inline void ie15_cpu_device::execute_one(int opcode) inline uint8_t ie15_cpu_device::rop() { - uint8_t retVal = m_direct->read_byte(m_PC.w.l); + uint8_t retVal = m_cache->read_byte(m_PC.w.l); m_PC.w.l = (m_PC.w.l + 1) & 0x0fff; return retVal; } inline uint8_t ie15_cpu_device::arg() { - uint8_t retVal = m_direct->read_byte(m_PC.w.l); + uint8_t retVal = m_cache->read_byte(m_PC.w.l); return retVal; } diff --git a/src/devices/cpu/ie15/ie15.h b/src/devices/cpu/ie15/ie15.h index b39d1c183b6..6b4b21e8dfc 100644 --- a/src/devices/cpu/ie15/ie15.h +++ b/src/devices/cpu/ie15/ie15.h @@ -74,7 +74,7 @@ protected: address_space *m_program; address_space *m_io; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; }; // device type definition diff --git a/src/devices/cpu/jaguar/jaguar.cpp b/src/devices/cpu/jaguar/jaguar.cpp index 69f5b80ca94..538db0aaaea 100644 --- a/src/devices/cpu/jaguar/jaguar.cpp +++ b/src/devices/cpu/jaguar/jaguar.cpp @@ -134,7 +134,7 @@ const jaguar_cpu_device::op_func jaguar_cpu_device::dsp_op_table[64] = MEMORY ACCESSORS ***************************************************************************/ -#define ROPCODE(pc) (m_direct->read_word(pc, WORD_XOR_BE(0))) +#define ROPCODE(pc) (m_cache->read_word(pc)) // SC414200AT DEFINE_DEVICE_TYPE(JAGUARGPU, jaguargpu_cpu_device, "jaguargpu", "Motorola Atari Jaguar GPU \"Tom\"") @@ -339,7 +339,7 @@ void jaguar_cpu_device::device_start() init_tables(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); m_cpu_interrupt.resolve_safe(); save_item(NAME(m_r)); diff --git a/src/devices/cpu/jaguar/jaguar.h b/src/devices/cpu/jaguar/jaguar.h index b16bf1e2c00..40a4292f65b 100644 --- a/src/devices/cpu/jaguar/jaguar.h +++ b/src/devices/cpu/jaguar/jaguar.h @@ -139,7 +139,7 @@ protected: int m_bankswitch_icount; devcb_write_line m_cpu_interrupt; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_BIG> *m_cache; uint32_t m_internal_ram_start; uint32_t m_internal_ram_end; diff --git a/src/devices/cpu/lc8670/lc8670.cpp b/src/devices/cpu/lc8670/lc8670.cpp index 74b8b15c8f0..46894a67a52 100644 --- a/src/devices/cpu/lc8670/lc8670.cpp +++ b/src/devices/cpu/lc8670/lc8670.cpp @@ -196,7 +196,7 @@ void lc8670_cpu_device::device_start() m_program = &space(AS_PROGRAM); m_data = &space(AS_DATA); m_io = &space(AS_IO); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); // set our instruction counter set_icountptr(m_icount); @@ -1075,7 +1075,7 @@ WRITE8_MEMBER(lc8670_cpu_device::regs_w) inline uint8_t lc8670_cpu_device::fetch() { - uint8_t data = m_direct->read_byte(m_pc); + uint8_t data = m_cache->read_byte(m_pc); set_pc(m_pc + 1); diff --git a/src/devices/cpu/lc8670/lc8670.h b/src/devices/cpu/lc8670/lc8670.h index 8a7f2ad045d..c52a2a7ae72 100644 --- a/src/devices/cpu/lc8670/lc8670.h +++ b/src/devices/cpu/lc8670/lc8670.h @@ -199,7 +199,7 @@ private: address_space * m_program; // program space (ROM or flash) address_space * m_data; // internal RAM/register address_space * m_io; // I/O ports - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; // timers static const device_timer_id BASE_TIMER = 1; diff --git a/src/devices/cpu/lh5801/5801tbl.hxx b/src/devices/cpu/lh5801/5801tbl.hxx index 4e48c8c9092..ac83d0c772e 100644 --- a/src/devices/cpu/lh5801/5801tbl.hxx +++ b/src/devices/cpu/lh5801/5801tbl.hxx @@ -26,8 +26,8 @@ uint8_t lh5801_cpu_device::lh5801_add_generic(int left, int right, int carry) uint16_t lh5801_cpu_device::lh5801_readop_word() { uint16_t r; - r=m_direct->read_byte(P++)<<8; - r|=m_direct->read_byte(P++); + r=m_cache->read_byte(P++)<<8; + r|=m_cache->read_byte(P++); return r; } @@ -221,7 +221,7 @@ void lh5801_cpu_device::lh5801_jmp(uint16_t adr) void lh5801_cpu_device::lh5801_branch_plus(int doit) { - uint8_t t=m_direct->read_byte(P++); + uint8_t t=m_cache->read_byte(P++); if (doit) { m_icount-=3; P+=t; @@ -230,7 +230,7 @@ void lh5801_cpu_device::lh5801_branch_plus(int doit) void lh5801_cpu_device::lh5801_branch_minus(int doit) { - uint8_t t=m_direct->read_byte(P++); + uint8_t t=m_cache->read_byte(P++); if (doit) { m_icount-=3; P-=t; @@ -239,7 +239,7 @@ void lh5801_cpu_device::lh5801_branch_minus(int doit) void lh5801_cpu_device::lh5801_lop() { - uint8_t t=m_direct->read_byte(P++); + uint8_t t=m_cache->read_byte(P++); m_icount-=8; if (UL--) { m_icount-=3; @@ -355,7 +355,7 @@ void lh5801_cpu_device::lh5801_instruction_fd() int oper; int adr; - oper=m_direct->read_byte(P++); + oper=m_cache->read_byte(P++); switch (oper) { case 0x01: lh5801_sbc(m_io->read_byte(X)); m_icount-=11;break; case 0x03: lh5801_adc(m_io->read_byte(X)); m_icount-=11;break; @@ -396,29 +396,29 @@ void lh5801_cpu_device::lh5801_instruction_fd() case 0x40: lh5801_inc(&XH);m_icount-=9;break; case 0x42: lh5801_dec(&XH);m_icount-=9;break; case 0x48: X=S;m_icount-=11;break; - case 0x49: lh5801_and_mem(*m_io, X, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x49: lh5801_and_mem(*m_io, X, m_cache->read_byte(P++)); m_icount-=17;break; case 0x4a: X=X;m_icount-=11;break; //!!! - case 0x4b: lh5801_ora_mem(*m_io, X, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x4b: lh5801_ora_mem(*m_io, X, m_cache->read_byte(P++)); m_icount-=17;break; case 0x4c: m_bf=0;/*off !*/ m_icount-=8;break; - case 0x4d: lh5801_bit(m_io->read_byte(X), m_direct->read_byte(P++));m_icount-=14;break; + case 0x4d: lh5801_bit(m_io->read_byte(X), m_cache->read_byte(P++));m_icount-=14;break; case 0x4e: S=X;m_icount-=11;break; - case 0x4f: lh5801_add_mem(*m_io, X, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x4f: lh5801_add_mem(*m_io, X, m_cache->read_byte(P++)); m_icount-=17;break; case 0x50: lh5801_inc(&YH);m_icount-=9;break; case 0x52: lh5801_dec(&YH);m_icount-=9;break; case 0x58: X=P;m_icount-=11;break; - case 0x59: lh5801_and_mem(*m_io, Y, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x59: lh5801_and_mem(*m_io, Y, m_cache->read_byte(P++)); m_icount-=17;break; case 0x5a: Y=X;m_icount-=11;break; - case 0x5b: lh5801_ora_mem(*m_io, Y, m_direct->read_byte(P++)); m_icount-=17;break; - case 0x5d: lh5801_bit(m_io->read_byte(Y), m_direct->read_byte(P++));m_icount-=14;break; + case 0x5b: lh5801_ora_mem(*m_io, Y, m_cache->read_byte(P++)); m_icount-=17;break; + case 0x5d: lh5801_bit(m_io->read_byte(Y), m_cache->read_byte(P++));m_icount-=14;break; case 0x5e: lh5801_jmp(X);m_icount-=11;break; // P=X - case 0x5f: lh5801_add_mem(*m_io, Y, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x5f: lh5801_add_mem(*m_io, Y, m_cache->read_byte(P++)); m_icount-=17;break; case 0x60: lh5801_inc(&UH);m_icount-=9;break; case 0x62: lh5801_dec(&UH);m_icount-=9;break; - case 0x69: lh5801_and_mem(*m_io, U, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x69: lh5801_and_mem(*m_io, U, m_cache->read_byte(P++)); m_icount-=17;break; case 0x6a: U=X;m_icount-=11;break; - case 0x6b: lh5801_ora_mem(*m_io, U, m_direct->read_byte(P++)); m_icount-=17;break; - case 0x6d: lh5801_bit(m_io->read_byte(X), m_direct->read_byte(P++));m_icount-=14;break; - case 0x6f: lh5801_add_mem(*m_io, U, m_direct->read_byte(P++)); m_icount-=17;break; + case 0x6b: lh5801_ora_mem(*m_io, U, m_cache->read_byte(P++)); m_icount-=17;break; + case 0x6d: lh5801_bit(m_io->read_byte(X), m_cache->read_byte(P++));m_icount-=14;break; + case 0x6f: lh5801_add_mem(*m_io, U, m_cache->read_byte(P++)); m_icount-=17;break; case 0x81: m_t|=IE; /*sie !*/m_icount-=8;break; case 0x88: lh5801_push_word(X); m_icount-=14;break; case 0x8a: lh5801_pop(); m_icount-=12; break; @@ -454,20 +454,20 @@ void lh5801_cpu_device::lh5801_instruction_fd() case 0xea: lh5801_adr(&m_u);m_icount-=11;break; case 0xe9: adr=lh5801_readop_word(); - lh5801_and_mem(*m_io, adr, m_direct->read_byte(P++)); m_icount-=23; + lh5801_and_mem(*m_io, adr, m_cache->read_byte(P++)); m_icount-=23; break; case 0xeb: adr=lh5801_readop_word(); - lh5801_ora_mem(*m_io, adr, m_direct->read_byte(P++)); m_icount-=23; + lh5801_ora_mem(*m_io, adr, m_cache->read_byte(P++)); m_icount-=23; break; case 0xec: m_t=m_a; m_icount-=9;break; case 0xed: adr=lh5801_readop_word(); - lh5801_bit(m_io->read_byte(adr), m_direct->read_byte(P++)); + lh5801_bit(m_io->read_byte(adr), m_cache->read_byte(P++)); m_icount-=20;break; case 0xef: adr=lh5801_readop_word(); - lh5801_add_mem(*m_io, adr, m_direct->read_byte(P++)); m_icount-=23; + lh5801_add_mem(*m_io, adr, m_cache->read_byte(P++)); m_icount-=23; break; default: @@ -480,7 +480,7 @@ void lh5801_cpu_device::lh5801_instruction() int oper; int adr; - oper=m_direct->read_byte(P++); + oper=m_cache->read_byte(P++); switch (oper) { case 0x00: lh5801_sbc(XL); m_icount-=6;break; case 0x01: lh5801_sbc(m_program->read_byte(X)); m_icount-=7;break; @@ -539,14 +539,14 @@ void lh5801_cpu_device::lh5801_instruction() case 0x45: lh5801_lin(&m_x);m_icount-=6;break; case 0x46: X--;m_icount-=5;break; case 0x47: lh5801_lde(&m_x);m_icount-=6;break; - case 0x48: XH=m_direct->read_byte(P++);m_icount-=6;break; - case 0x49: lh5801_and_mem(*m_program, X, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x4a: XL=m_direct->read_byte(P++);m_icount-=6;break; - case 0x4b: lh5801_ora_mem(*m_program, X, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x4c: lh5801_cpa(XH, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x4d: lh5801_bit(m_program->read_byte(X), m_direct->read_byte(P++));m_icount-=10;break; - case 0x4e: lh5801_cpa(XL, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x4f: lh5801_add_mem(*m_program, X, m_direct->read_byte(P++)); m_icount-=13;break; + case 0x48: XH=m_cache->read_byte(P++);m_icount-=6;break; + case 0x49: lh5801_and_mem(*m_program, X, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x4a: XL=m_cache->read_byte(P++);m_icount-=6;break; + case 0x4b: lh5801_ora_mem(*m_program, X, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x4c: lh5801_cpa(XH, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x4d: lh5801_bit(m_program->read_byte(X), m_cache->read_byte(P++));m_icount-=10;break; + case 0x4e: lh5801_cpa(XL, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x4f: lh5801_add_mem(*m_program, X, m_cache->read_byte(P++)); m_icount-=13;break; case 0x50: lh5801_inc(&YL);m_icount-=5;break; case 0x51: lh5801_sin(&m_y); m_icount-=6;break; case 0x52: lh5801_dec(&YL);m_icount-=5;break; @@ -555,14 +555,14 @@ void lh5801_cpu_device::lh5801_instruction() case 0x55: lh5801_lin(&m_y);m_icount-=6;break; case 0x56: Y--;m_icount-=5;break; case 0x57: lh5801_lde(&m_y);m_icount-=6;break; - case 0x58: YH=m_direct->read_byte(P++);m_icount-=6;break; - case 0x59: lh5801_and_mem(*m_program, Y, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x5a: YL=m_direct->read_byte(P++);m_icount-=6;break; - case 0x5b: lh5801_ora_mem(*m_program, Y, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x5c: lh5801_cpa(YH, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x5d: lh5801_bit(m_program->read_byte(Y), m_direct->read_byte(P++));m_icount-=10;break; - case 0x5e: lh5801_cpa(YL, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x5f: lh5801_add_mem(*m_program, Y, m_direct->read_byte(P++)); m_icount-=13;break; + case 0x58: YH=m_cache->read_byte(P++);m_icount-=6;break; + case 0x59: lh5801_and_mem(*m_program, Y, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x5a: YL=m_cache->read_byte(P++);m_icount-=6;break; + case 0x5b: lh5801_ora_mem(*m_program, Y, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x5c: lh5801_cpa(YH, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x5d: lh5801_bit(m_program->read_byte(Y), m_cache->read_byte(P++));m_icount-=10;break; + case 0x5e: lh5801_cpa(YL, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x5f: lh5801_add_mem(*m_program, Y, m_cache->read_byte(P++)); m_icount-=13;break; case 0x60: lh5801_inc(&UL);m_icount-=5;break; case 0x61: lh5801_sin(&m_u); m_icount-=6;break; case 0x62: lh5801_dec(&UL);m_icount-=5;break; @@ -571,14 +571,14 @@ void lh5801_cpu_device::lh5801_instruction() case 0x65: lh5801_lin(&m_u);m_icount-=6;break; case 0x66: U--;m_icount-=5;break; case 0x67: lh5801_lde(&m_u);m_icount-=6;break; - case 0x68: UH=m_direct->read_byte(P++);m_icount-=6;break; - case 0x69: lh5801_and_mem(*m_program, U, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x6a: UL=m_direct->read_byte(P++);m_icount-=6;break; - case 0x6b: lh5801_ora_mem(*m_program, U, m_direct->read_byte(P++)); m_icount-=13;break; - case 0x6c: lh5801_cpa(UH, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x6d: lh5801_bit(m_program->read_byte(U), m_direct->read_byte(P++));m_icount-=10;break; - case 0x6e: lh5801_cpa(UL, m_direct->read_byte(P++)); m_icount-=7;break; - case 0x6f: lh5801_add_mem(*m_program, U, m_direct->read_byte(P++)); m_icount-=13;break; + case 0x68: UH=m_cache->read_byte(P++);m_icount-=6;break; + case 0x69: lh5801_and_mem(*m_program, U, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x6a: UL=m_cache->read_byte(P++);m_icount-=6;break; + case 0x6b: lh5801_ora_mem(*m_program, U, m_cache->read_byte(P++)); m_icount-=13;break; + case 0x6c: lh5801_cpa(UH, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x6d: lh5801_bit(m_program->read_byte(U), m_cache->read_byte(P++));m_icount-=10;break; + case 0x6e: lh5801_cpa(UL, m_cache->read_byte(P++)); m_icount-=7;break; + case 0x6f: lh5801_add_mem(*m_program, U, m_cache->read_byte(P++)); m_icount-=13;break; case 0x80: lh5801_sbc(XH); m_icount-=6;break; case 0x81: lh5801_branch_plus(!(m_t&C)); m_icount-=8; break; case 0x82: lh5801_adc(XH); m_icount-=6;break; @@ -626,25 +626,25 @@ void lh5801_cpu_device::lh5801_instruction() case 0xad: lh5801_eor(m_program->read_byte(lh5801_readop_word())); m_icount-=13;break; case 0xae: m_program->write_byte(lh5801_readop_word(),m_a); m_icount-=12;break; case 0xaf: lh5801_bit(m_program->read_byte(lh5801_readop_word()),m_a); m_icount-=13;break; - case 0xb1: lh5801_sbc(m_direct->read_byte(P++)); m_icount-=7;break; - case 0xb3: lh5801_adc(m_direct->read_byte(P++)); m_icount-=7;break; - case 0xb5: lh5801_lda(m_direct->read_byte(P++)); m_icount-=6;break; - case 0xb7: lh5801_cpa(m_a, m_direct->read_byte(P++)); m_icount-=7;break; + case 0xb1: lh5801_sbc(m_cache->read_byte(P++)); m_icount-=7;break; + case 0xb3: lh5801_adc(m_cache->read_byte(P++)); m_icount-=7;break; + case 0xb5: lh5801_lda(m_cache->read_byte(P++)); m_icount-=6;break; + case 0xb7: lh5801_cpa(m_a, m_cache->read_byte(P++)); m_icount-=7;break; case 0xb8: m_pv=0;/*rpv!*/ m_icount-=4; break; - case 0xb9: lh5801_and(m_direct->read_byte(P++)); m_icount-=7;break; + case 0xb9: lh5801_and(m_cache->read_byte(P++)); m_icount-=7;break; case 0xba: lh5801_jmp(lh5801_readop_word()); m_icount-=12;break; - case 0xbb: lh5801_ora(m_direct->read_byte(P++)); m_icount-=7;break; - case 0xbd: lh5801_eor(m_direct->read_byte(P++)); m_icount-=7;break; + case 0xbb: lh5801_ora(m_cache->read_byte(P++)); m_icount-=7;break; + case 0xbd: lh5801_eor(m_cache->read_byte(P++)); m_icount-=7;break; case 0xbe: lh5801_sjp(); m_icount-=19; break; - case 0xbf: lh5801_bit(m_a, m_direct->read_byte(P++));m_icount-=7;break; - case 0xc1: lh5801_vector(!(m_t&C), m_direct->read_byte(P++)); m_icount-=8;break; - case 0xc3: lh5801_vector(m_t&C, m_direct->read_byte(P++)); m_icount-=8;break; - case 0xc5: lh5801_vector(!(m_t&H), m_direct->read_byte(P++)); m_icount-=8;break; - case 0xc7: lh5801_vector(m_t&H, m_direct->read_byte(P++)); m_icount-=8;break; - case 0xc9: lh5801_vector(!(m_t&Z), m_direct->read_byte(P++)); m_icount-=8;break; - case 0xcb: lh5801_vector(m_t&Z, m_direct->read_byte(P++)); m_icount-=8;break; - case 0xcd: lh5801_vector(1, m_direct->read_byte(P++)); m_icount-=7;break; - case 0xcf: lh5801_vector(m_t&V, m_direct->read_byte(P++)); m_icount-=8;break; + case 0xbf: lh5801_bit(m_a, m_cache->read_byte(P++));m_icount-=7;break; + case 0xc1: lh5801_vector(!(m_t&C), m_cache->read_byte(P++)); m_icount-=8;break; + case 0xc3: lh5801_vector(m_t&C, m_cache->read_byte(P++)); m_icount-=8;break; + case 0xc5: lh5801_vector(!(m_t&H), m_cache->read_byte(P++)); m_icount-=8;break; + case 0xc7: lh5801_vector(m_t&H, m_cache->read_byte(P++)); m_icount-=8;break; + case 0xc9: lh5801_vector(!(m_t&Z), m_cache->read_byte(P++)); m_icount-=8;break; + case 0xcb: lh5801_vector(m_t&Z, m_cache->read_byte(P++)); m_icount-=8;break; + case 0xcd: lh5801_vector(1, m_cache->read_byte(P++)); m_icount-=7;break; + case 0xcf: lh5801_vector(m_t&V, m_cache->read_byte(P++)); m_icount-=8;break; case 0xd1: lh5801_ror(); m_icount-=6; break; case 0xd3: lh5801_drr(*m_program, X); m_icount-=12; break; case 0xd5: lh5801_shr(); m_icount-=6; break; @@ -656,17 +656,17 @@ void lh5801_cpu_device::lh5801_instruction() case 0xe1: m_pu=1;/*spu!*/ m_icount-=4; break; case 0xe3: m_pu=0;/*rpu!*/ m_icount-=4; break; case 0xe9: - adr=lh5801_readop_word();lh5801_and_mem(*m_program, adr, m_direct->read_byte(P++)); + adr=lh5801_readop_word();lh5801_and_mem(*m_program, adr, m_cache->read_byte(P++)); m_icount-=19;break; case 0xeb: - adr=lh5801_readop_word();lh5801_ora_mem(*m_program, adr, m_direct->read_byte(P++)); + adr=lh5801_readop_word();lh5801_ora_mem(*m_program, adr, m_cache->read_byte(P++)); m_icount-=19;break; case 0xed: - adr=lh5801_readop_word();lh5801_bit(m_program->read_byte(adr), m_direct->read_byte(P++)); + adr=lh5801_readop_word();lh5801_bit(m_program->read_byte(adr), m_cache->read_byte(P++)); m_icount-=16;break; case 0xef: adr=lh5801_readop_word(); - lh5801_add_mem(*m_program, adr, m_direct->read_byte(P++)); m_icount-=19; + lh5801_add_mem(*m_program, adr, m_cache->read_byte(P++)); m_icount-=19; break; case 0xf1: lh5801_aex(); m_icount-=6; break; case 0xf5: m_program->write_byte(Y++, m_program->read_byte(X++)); m_icount-=7; break; //tin diff --git a/src/devices/cpu/lh5801/lh5801.cpp b/src/devices/cpu/lh5801/lh5801.cpp index 07876db8ed1..cf1718c3922 100644 --- a/src/devices/cpu/lh5801/lh5801.cpp +++ b/src/devices/cpu/lh5801/lh5801.cpp @@ -92,7 +92,7 @@ void lh5801_cpu_device::device_start() { m_program = &space(AS_PROGRAM); m_io = &space(AS_IO); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_in_func.resolve_safe(0); diff --git a/src/devices/cpu/lh5801/lh5801.h b/src/devices/cpu/lh5801/lh5801.h index c8a8b59c3a2..fbdb54a0f31 100644 --- a/src/devices/cpu/lh5801/lh5801.h +++ b/src/devices/cpu/lh5801/lh5801.h @@ -103,7 +103,7 @@ private: address_space *m_program; //ME0 address_space *m_io; //ME1 - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; PAIR m_s; PAIR m_p; diff --git a/src/devices/cpu/m37710/m37710.cpp b/src/devices/cpu/m37710/m37710.cpp index 7cb82503c0d..afbaa5bb12b 100644 --- a/src/devices/cpu/m37710/m37710.cpp +++ b/src/devices/cpu/m37710/m37710.cpp @@ -1002,7 +1002,7 @@ void m37710_cpu_device::device_start() memset(m_m37710_regs, 0, sizeof(m_m37710_regs)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); m_ICount = 0; diff --git a/src/devices/cpu/m37710/m37710.h b/src/devices/cpu/m37710/m37710.h index be36f1f412a..2156c23f8a5 100644 --- a/src/devices/cpu/m37710/m37710.h +++ b/src/devices/cpu/m37710/m37710.h @@ -171,7 +171,7 @@ private: uint32_t m_source; /* temp register */ uint32_t m_destination; /* temp register */ address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<1, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_io; uint32_t m_stopped; /* Sets how the CPU is stopped */ diff --git a/src/devices/cpu/m37710/m37710cm.h b/src/devices/cpu/m37710/m37710cm.h index 80b294ac277..4eb5742a4b1 100644 --- a/src/devices/cpu/m37710/m37710cm.h +++ b/src/devices/cpu/m37710/m37710cm.h @@ -23,10 +23,10 @@ #define M37710_CALL_DEBUGGER(x) debugger_instruction_hook(x) #define m37710_read_8(addr) m_program->read_byte(addr) #define m37710_write_8(addr,data) m_program->write_byte(addr,data) -#define m37710_read_8_immediate(A) m_direct->read_byte(A, BYTE_XOR_LE(0)) +#define m37710_read_8_immediate(A) m_cache->read_byte(A) #define m37710_read_16(addr) m_program->read_word_unaligned(addr) #define m37710_write_16(addr,data) m_program->write_word_unaligned(addr,data) -#define m37710_read_16_immediate(A) m_direct->read_word(A) +#define m37710_read_16_immediate(A) m_cache->read_word(A) /* ======================================================================== */ diff --git a/src/devices/cpu/m6502/deco16.cpp b/src/devices/cpu/m6502/deco16.cpp index 52d6ec640a2..87e5a256400 100644 --- a/src/devices/cpu/m6502/deco16.cpp +++ b/src/devices/cpu/m6502/deco16.cpp @@ -30,7 +30,7 @@ std::unique_ptr<util::disasm_interface> deco16_device::create_disassembler() void deco16_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_default_nd>(); else mintf = std::make_unique<mi_default_normal>(); diff --git a/src/devices/cpu/m6502/m4510.cpp b/src/devices/cpu/m6502/m4510.cpp index c91e873a443..9e67462e4d0 100644 --- a/src/devices/cpu/m6502/m4510.cpp +++ b/src/devices/cpu/m6502/m4510.cpp @@ -37,7 +37,7 @@ std::unique_ptr<util::disasm_interface> m4510_device::create_disassembler() void m4510_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_4510_nd>(this); else mintf = std::make_unique<mi_4510_normal>(this); @@ -82,12 +82,12 @@ uint8_t m4510_device::mi_4510_normal::read(uint16_t adr) uint8_t m4510_device::mi_4510_normal::read_sync(uint16_t adr) { - return sdirect->read_byte(base->map(adr)); + return scache->read_byte(base->map(adr)); } uint8_t m4510_device::mi_4510_normal::read_arg(uint16_t adr) { - return direct->read_byte(base->map(adr)); + return cache->read_byte(base->map(adr)); } void m4510_device::mi_4510_normal::write(uint16_t adr, uint8_t val) diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp index 38459863003..9ed8d4b63f0 100644 --- a/src/devices/cpu/m6502/m6502.cpp +++ b/src/devices/cpu/m6502/m6502.cpp @@ -27,12 +27,12 @@ m6502_device::m6502_device(const machine_config &mconfig, device_type type, cons sprogram_config("decrypted_opcodes", ENDIANNESS_LITTLE, 8, 16), PPC(0), NPC(0), PC(0), SP(0), TMP(0), TMP2(0), A(0), X(0), Y(0), P(0), IR(0), inst_state_base(0), mintf(nullptr), inst_state(0), inst_substate(0), icount(0), nmi_state(false), irq_state(false), apu_irq_state(false), v_state(false), irq_taken(false), sync(false), inhibit_interrupts(false) { - direct_disabled = false; + cache_disabled = false; } void m6502_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_default_nd>(); else mintf = std::make_unique<mi_default_normal>(); @@ -45,8 +45,8 @@ void m6502_device::init() mintf->program = &space(AS_PROGRAM); mintf->sprogram = has_space(AS_OPCODES) ? &space(AS_OPCODES) : mintf->program; - mintf->direct = mintf->program->direct<0>(); - mintf->sdirect = mintf->sprogram->direct<0>(); + mintf->cache = mintf->program->cache<0, 0, ENDIANNESS_LITTLE>(); + mintf->scache = mintf->sprogram->cache<0, 0, ENDIANNESS_LITTLE>(); sync_w.resolve_safe(); @@ -525,12 +525,12 @@ uint8_t m6502_device::mi_default_normal::read(uint16_t adr) uint8_t m6502_device::mi_default_normal::read_sync(uint16_t adr) { - return sdirect->read_byte(adr); + return scache->read_byte(adr); } uint8_t m6502_device::mi_default_normal::read_arg(uint16_t adr) { - return direct->read_byte(adr); + return cache->read_byte(adr); } diff --git a/src/devices/cpu/m6502/m6502.h b/src/devices/cpu/m6502/m6502.h index 185598a8320..18e7f54a920 100644 --- a/src/devices/cpu/m6502/m6502.h +++ b/src/devices/cpu/m6502/m6502.h @@ -11,8 +11,8 @@ #ifndef MAME_CPU_M6502_M6502_H #define MAME_CPU_M6502_M6502_H -#define MCFG_M6502_DISABLE_DIRECT() \ - downcast<m6502_device *>(device)->disable_direct(); +#define MCFG_M6502_DISABLE_CACHE() \ + downcast<m6502_device *>(device)->disable_cache(); #define MCFG_M6502_SYNC_CALLBACK(_cb) \ devcb = &downcast<m6502_device &>(*device).set_sync_callback(DEVCB_##_cb); @@ -29,7 +29,7 @@ public: m6502_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); bool get_sync() const { return sync; } - void disable_direct() { direct_disabled = true; } + void disable_cache() { cache_disabled = true; } template<class Object> devcb_base &set_sync_callback(Object &&cb) { return sync_w.set_callback(std::forward<Object>(cb)); } @@ -41,7 +41,7 @@ protected: class memory_interface { public: address_space *program, *sprogram; - direct_read_data<0> *direct, *sdirect; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *cache, *scache; virtual ~memory_interface() {} virtual uint8_t read(uint16_t adr) = 0; @@ -127,7 +127,7 @@ protected: int inst_state, inst_substate; int icount; bool nmi_state, irq_state, apu_irq_state, v_state; - bool irq_taken, sync, direct_disabled, inhibit_interrupts; + bool irq_taken, sync, cache_disabled, inhibit_interrupts; uint8_t read(uint16_t adr) { return mintf->read(adr); } uint8_t read_9(uint16_t adr) { return mintf->read_9(adr); } diff --git a/src/devices/cpu/m6502/m6504.cpp b/src/devices/cpu/m6502/m6504.cpp index 9f29f569790..b065e36f8ce 100644 --- a/src/devices/cpu/m6502/m6504.cpp +++ b/src/devices/cpu/m6502/m6504.cpp @@ -22,7 +22,7 @@ m6504_device::m6504_device(const machine_config &mconfig, const char *tag, devic void m6504_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_6504_nd>(); else mintf = std::make_unique<mi_6504_normal>(); @@ -37,12 +37,12 @@ uint8_t m6504_device::mi_6504_normal::read(uint16_t adr) uint8_t m6504_device::mi_6504_normal::read_sync(uint16_t adr) { - return sdirect->read_byte(adr & 0x1fff); + return scache->read_byte(adr & 0x1fff); } uint8_t m6504_device::mi_6504_normal::read_arg(uint16_t adr) { - return direct->read_byte(adr & 0x1fff); + return cache->read_byte(adr & 0x1fff); } void m6504_device::mi_6504_normal::write(uint16_t adr, uint8_t val) diff --git a/src/devices/cpu/m6502/m6507.cpp b/src/devices/cpu/m6502/m6507.cpp index e76dbf9a03d..2932eb2923a 100644 --- a/src/devices/cpu/m6502/m6507.cpp +++ b/src/devices/cpu/m6502/m6507.cpp @@ -22,7 +22,7 @@ m6507_device::m6507_device(const machine_config &mconfig, const char *tag, devic void m6507_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_6507_nd>(); else mintf = std::make_unique<mi_6507_normal>(); @@ -37,12 +37,12 @@ uint8_t m6507_device::mi_6507_normal::read(uint16_t adr) uint8_t m6507_device::mi_6507_normal::read_sync(uint16_t adr) { - return sdirect->read_byte(adr & 0x1fff); + return scache->read_byte(adr & 0x1fff); } uint8_t m6507_device::mi_6507_normal::read_arg(uint16_t adr) { - return direct->read_byte(adr & 0x1fff); + return cache->read_byte(adr & 0x1fff); } void m6507_device::mi_6507_normal::write(uint16_t adr, uint8_t val) diff --git a/src/devices/cpu/m6502/m6509.cpp b/src/devices/cpu/m6502/m6509.cpp index 8536d04fe04..95c2d62b79a 100644 --- a/src/devices/cpu/m6502/m6509.cpp +++ b/src/devices/cpu/m6502/m6509.cpp @@ -25,7 +25,7 @@ m6509_device::m6509_device(const machine_config &mconfig, const char *tag, devic void m6509_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_6509_nd>(this); else mintf = std::make_unique<mi_6509_normal>(this); @@ -72,7 +72,7 @@ uint8_t m6509_device::mi_6509_normal::read(uint16_t adr) uint8_t m6509_device::mi_6509_normal::read_sync(uint16_t adr) { - uint8_t res = sdirect->read_byte(base->adr_in_bank_i(adr)); + uint8_t res = scache->read_byte(base->adr_in_bank_i(adr)); if(adr == 0x0000) res = base->bank_i_r(); else if(adr == 0x0001) @@ -82,7 +82,7 @@ uint8_t m6509_device::mi_6509_normal::read_sync(uint16_t adr) uint8_t m6509_device::mi_6509_normal::read_arg(uint16_t adr) { - uint8_t res = direct->read_byte(base->adr_in_bank_i(adr)); + uint8_t res = cache->read_byte(base->adr_in_bank_i(adr)); if(adr == 0x0000) res = base->bank_i_r(); else if(adr == 0x0001) diff --git a/src/devices/cpu/m6502/m6510.cpp b/src/devices/cpu/m6502/m6510.cpp index a977fc0c072..92ec15dbc25 100644 --- a/src/devices/cpu/m6502/m6510.cpp +++ b/src/devices/cpu/m6502/m6510.cpp @@ -44,7 +44,7 @@ void m6510_device::device_start() read_port.resolve_safe(0); write_port.resolve_safe(); - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_6510_nd>(this); else mintf = std::make_unique<mi_6510_normal>(this); @@ -118,7 +118,7 @@ uint8_t m6510_device::mi_6510_normal::read(uint16_t adr) uint8_t m6510_device::mi_6510_normal::read_sync(uint16_t adr) { - uint8_t res = sdirect->read_byte(adr); + uint8_t res = scache->read_byte(adr); if(adr == 0x0000) res = base->dir_r(); else if(adr == 0x0001) @@ -128,7 +128,7 @@ uint8_t m6510_device::mi_6510_normal::read_sync(uint16_t adr) uint8_t m6510_device::mi_6510_normal::read_arg(uint16_t adr) { - uint8_t res = direct->read_byte(adr); + uint8_t res = cache->read_byte(adr); if(adr == 0x0000) res = base->dir_r(); else if(adr == 0x0001) diff --git a/src/devices/cpu/m6502/m65ce02.cpp b/src/devices/cpu/m6502/m65ce02.cpp index a882daf75df..e336e936545 100644 --- a/src/devices/cpu/m6502/m65ce02.cpp +++ b/src/devices/cpu/m6502/m65ce02.cpp @@ -44,7 +44,7 @@ void m65ce02_device::init() void m65ce02_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_default_nd>(); else mintf = std::make_unique<mi_default_normal>(); diff --git a/src/devices/cpu/m6502/xavix.cpp b/src/devices/cpu/m6502/xavix.cpp index f8e6e87e0f6..6df019c5bb8 100644 --- a/src/devices/cpu/m6502/xavix.cpp +++ b/src/devices/cpu/m6502/xavix.cpp @@ -65,7 +65,7 @@ offs_t xavix_device::pc_to_external(u16 pc) void xavix_device::device_start() { - if(direct_disabled) + if(cache_disabled) mintf = std::make_unique<mi_xavix_nd>(this); else mintf = std::make_unique<mi_xavix_normal>(this); @@ -106,7 +106,7 @@ uint8_t xavix_device::mi_xavix_normal::read_sync(uint16_t adr) else if (adr == 0xff) return base->m_databank; - return sdirect->read_byte(base->adr_with_codebank(adr)); + return scache->read_byte(base->adr_with_codebank(adr)); } uint8_t xavix_device::mi_xavix_normal::read_arg(uint16_t adr) @@ -116,7 +116,7 @@ uint8_t xavix_device::mi_xavix_normal::read_arg(uint16_t adr) else if (adr == 0xff) return base->m_databank; - return direct->read_byte(base->adr_with_codebank(adr)); + return cache->read_byte(base->adr_with_codebank(adr)); } void xavix_device::mi_xavix_normal::write(uint16_t adr, uint8_t val) diff --git a/src/devices/cpu/m6800/m6800.cpp b/src/devices/cpu/m6800/m6800.cpp index 9182b899ffe..c5e26e43564 100644 --- a/src/devices/cpu/m6800/m6800.cpp +++ b/src/devices/cpu/m6800/m6800.cpp @@ -133,14 +133,14 @@ TODO: /* opcodes. In case of system with memory mapped I/O, this function can be */ /* used to greatly speed up emulation */ /****************************************************************************/ -#define M_RDOP(Addr) ((unsigned)m_decrypted_opcodes_direct->read_byte(Addr)) +#define M_RDOP(Addr) ((unsigned)m_opcodes_cache->read_byte(Addr)) /****************************************************************************/ /* M6800_RDOP_ARG() is identical to M6800_RDOP() but it's used for reading */ /* opcode arguments. This difference can be used to support systems that */ /* use different encoding mechanisms for opcodes and opcode arguments */ /****************************************************************************/ -#define M_RDOP_ARG(Addr) ((unsigned)m_direct->read_byte(Addr)) +#define M_RDOP_ARG(Addr) ((unsigned)m_cache->read_byte(Addr)) /* macros to access memory */ #define IMMBYTE(b) b = M_RDOP_ARG(PCD); PC++ @@ -464,9 +464,9 @@ void m6800_cpu_device::EAT_CYCLES() void m6800_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); - m_decrypted_opcodes = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; - m_decrypted_opcodes_direct = m_decrypted_opcodes->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); + m_opcodes = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; + m_opcodes_cache = m_opcodes->cache<0, 0, ENDIANNESS_BIG>(); m_pc.d = 0; m_s.d = 0; diff --git a/src/devices/cpu/m6800/m6800.h b/src/devices/cpu/m6800/m6800.h index 74db573b96c..018280813fb 100644 --- a/src/devices/cpu/m6800/m6800.h +++ b/src/devices/cpu/m6800/m6800.h @@ -84,8 +84,8 @@ protected: uint8_t m_irq_state[3]; /* IRQ line state [IRQ1,TIN,SC1] */ /* Memory spaces */ - address_space *m_program, *m_decrypted_opcodes; - direct_read_data<0> *m_direct, *m_decrypted_opcodes_direct; + address_space *m_program, *m_opcodes; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache, *m_opcodes_cache; const op_func *m_insn; const uint8_t *m_cycles; /* clock cycle of instruction table */ diff --git a/src/devices/cpu/m68000/m68000.h b/src/devices/cpu/m68000/m68000.h index 7800b842328..f2f0995196e 100644 --- a/src/devices/cpu/m68000/m68000.h +++ b/src/devices/cpu/m68000/m68000.h @@ -236,54 +236,21 @@ protected: /* Redirect memory calls */ - typedef delegate<uint8_t (offs_t)> m68k_read8_delegate; - typedef delegate<uint16_t (offs_t)> m68k_readimm16_delegate; - typedef delegate<uint16_t (offs_t)> m68k_read16_delegate; - typedef delegate<uint32_t (offs_t)> m68k_read32_delegate; - typedef delegate<void (offs_t, uint8_t)> m68k_write8_delegate; - typedef delegate<void (offs_t, uint16_t)> m68k_write16_delegate; - typedef delegate<void (offs_t, uint32_t)> m68k_write32_delegate; - - void init8(address_space &space, address_space &ospace); - void init16(address_space &space, address_space &ospace); - void init32(address_space &space, address_space &ospace); - void init32mmu(address_space &space, address_space &ospace); - void init32hmmu(address_space &space, address_space &ospace); - - offs_t m_opcode_xor; // Address Calculation - m68k_readimm16_delegate m_readimm16; // Immediate read 16 bit - m68k_read8_delegate m_read8; - m68k_read16_delegate m_read16; - m68k_read32_delegate m_read32; - m68k_write8_delegate m_write8; - m68k_write16_delegate m_write16; - m68k_write32_delegate m_write32; - - uint16_t m68008_read_immediate_16(offs_t address); - uint16_t read_immediate_16(offs_t address); - uint16_t simple_read_immediate_16(offs_t address); - - void m68000_write_byte(offs_t address, uint8_t data); - - uint8_t read_byte_32_mmu(offs_t address); - void write_byte_32_mmu(offs_t address, uint8_t data); - uint16_t read_immediate_16_mmu(offs_t address); - uint16_t readword_d32_mmu(offs_t address); - void writeword_d32_mmu(offs_t address, uint16_t data); - uint32_t readlong_d32_mmu(offs_t address); - void writelong_d32_mmu(offs_t address, uint32_t data); - - uint8_t read_byte_32_hmmu(offs_t address); - void write_byte_32_hmmu(offs_t address, uint8_t data); - uint16_t read_immediate_16_hmmu(offs_t address); - uint16_t readword_d32_hmmu(offs_t address); - void writeword_d32_hmmu(offs_t address, uint16_t data); - uint32_t readlong_d32_hmmu(offs_t address); - void writelong_d32_hmmu(offs_t address, uint32_t data); - + void init8(address_space &space, address_space &ospace); + void init16(address_space &space, address_space &ospace); + void init32(address_space &space, address_space &ospace); + void init32mmu(address_space &space, address_space &ospace); + void init32hmmu(address_space &space, address_space &ospace); + + std::function<u16 (offs_t)> m_readimm16; // Immediate read 16 bit + std::function<u8 (offs_t)> m_read8; + std::function<u16 (offs_t)> m_read16; + std::function<u32 (offs_t)> m_read32; + std::function<void (offs_t, u8 )> m_write8; + std::function<void (offs_t, u16)> m_write16; + std::function<void (offs_t, u32)> m_write32; address_space *m_space, *m_ospace; - direct_read_data<0> *m_direct, *m_odirect; uint32_t m_iotemp; diff --git a/src/devices/cpu/m68000/m68kcpu.cpp b/src/devices/cpu/m68000/m68kcpu.cpp index a0c74be63b2..ef197ec7981 100644 --- a/src/devices/cpu/m68000/m68kcpu.cpp +++ b/src/devices/cpu/m68000/m68kcpu.cpp @@ -1206,71 +1206,40 @@ void m68000_base_device::set_fpu_enable(int enable) * 8-bit data memory interface ****************************************************************************/ -uint16_t m68000_base_device::m68008_read_immediate_16(offs_t address) -{ - return (m_odirect->read_byte(address) << 8) | (m_odirect->read_byte(address + 1)); -} - void m68000_base_device::init8(address_space &space, address_space &ospace) { m_space = &space; - m_direct = space.direct<0>(); m_ospace = &ospace; - m_odirect = ospace.direct<0>(); - m_opcode_xor = 0; + auto ocache = ospace.cache<0, 0, ENDIANNESS_BIG>(); - m_readimm16 = m68k_readimm16_delegate(&m68000_base_device::m68008_read_immediate_16, this); - m_read8 = m68k_read8_delegate(&address_space::read_byte, &space); - m_read16 = m68k_read16_delegate(&address_space::read_word, &space); - m_read32 = m68k_read32_delegate(&address_space::read_dword, &space); - m_write8 = m68k_write8_delegate(&address_space::write_byte, &space); - m_write16 = m68k_write16_delegate(&address_space::write_word, &space); - m_write32 = m68k_write32_delegate(&address_space::write_dword, &space); + m_readimm16 = [ocache](offs_t address) -> u16 { return ocache->read_word(address); }; + m_read8 = [this](offs_t address) -> u8 { return m_space->read_byte(address); }; + m_read16 = [this](offs_t address) -> u16 { return m_space->read_word(address); }; + m_read32 = [this](offs_t address) -> u32 { return m_space->read_dword(address); }; + m_write8 = [this](offs_t address, u8 data) { m_space->write_byte(address, data); }; + m_write16 = [this](offs_t address, u16 data) { m_space->write_word(address, data); }; + m_write32 = [this](offs_t address, u32 data) { m_space->write_dword(address, data); }; } /**************************************************************************** * 16-bit data memory interface ****************************************************************************/ -uint16_t m68000_base_device::read_immediate_16(offs_t address) -{ - return m_odirect->read_word((address), m_opcode_xor); -} - -uint16_t m68000_base_device::simple_read_immediate_16(offs_t address) -{ - return m_odirect->read_word(address); -} - -void m68000_base_device::m68000_write_byte(offs_t address, uint8_t data) -{ - static const uint16_t masks[] = {0xff00, 0x00ff}; - - m_space->write_word(address & ~1, data | (data << 8), masks[address & 1]); -} - void m68000_base_device::init16(address_space &space, address_space &ospace) { m_space = &space; - m_direct = space.direct<0>(); m_ospace = &ospace; - m_odirect = ospace.direct<0>(); - - m_opcode_xor = 0; + auto ocache = ospace.cache<1, 0, ENDIANNESS_BIG>(); - m_readimm16 = m68k_readimm16_delegate(&m68000_base_device::simple_read_immediate_16, this); - m_read8 = m68k_read8_delegate(&address_space::read_byte, &space); - m_read16 = m68k_read16_delegate(&address_space::read_word, &space); - m_read32 = m68k_read32_delegate(&address_space::read_dword, &space); - m_write8 = m68k_write8_delegate(&m68000_base_device::m68000_write_byte, this); - m_write16 = m68k_write16_delegate(&address_space::write_word, &space); - m_write32 = m68k_write32_delegate(&address_space::write_dword, &space); + m_readimm16 = [ocache](offs_t address) -> u16 { return ocache->read_word(address); }; + m_read8 = [this](offs_t address) -> u8 { return m_space->read_byte(address); }; + m_read16 = [this](offs_t address) -> u16 { return m_space->read_word(address); }; + m_read32 = [this](offs_t address) -> u32 { return m_space->read_dword(address); }; + m_write8 = [this](offs_t address, u8 data) { m_space->write_word(address & ~1, data | (data << 8), address & 1 ? 0x00ff : 0xff00); }; + m_write16 = [this](offs_t address, u16 data) { m_space->write_word(address, data); }; + m_write32 = [this](offs_t address, u32 data) { m_space->write_dword(address, data); }; } - - - - /**************************************************************************** * 32-bit data memory interface ****************************************************************************/ @@ -1279,365 +1248,259 @@ void m68000_base_device::init16(address_space &space, address_space &ospace) void m68000_base_device::init32(address_space &space, address_space &ospace) { m_space = &space; - m_direct = space.direct<0>(); m_ospace = &ospace; - m_odirect = ospace.direct<0>(); - m_opcode_xor = WORD_XOR_BE(0); + auto ocache = ospace.cache<2, 0, ENDIANNESS_BIG>(); - m_readimm16 = m68k_readimm16_delegate(&m68000_base_device::read_immediate_16, this); - m_read8 = m68k_read8_delegate(&address_space::read_byte, &space); - m_read16 = m68k_read16_delegate(&address_space::read_word_unaligned, &space); - m_read32 = m68k_read32_delegate(&address_space::read_dword_unaligned, &space); - m_write8 = m68k_write8_delegate(&address_space::write_byte, &space); - m_write16 = m68k_write16_delegate(&address_space::write_word_unaligned, &space); - m_write32 = m68k_write32_delegate(&address_space::write_dword_unaligned, &space); -} - -/* interface for 32-bit data bus with PMMU (68EC020, 68020) */ -uint8_t m68000_base_device::read_byte_32_mmu(offs_t address) -{ - if (m_pmmu_enabled) - { - address = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { - return ~0; - } - } + m_readimm16 = [ocache](offs_t address) -> u16 { return ocache->read_word(address); }; + m_read8 = [this](offs_t address) -> u8 { return m_space->read_byte(address); }; + m_read16 = [this](offs_t address) -> u16 { return m_space->read_word_unaligned(address); }; + m_read32 = [this](offs_t address) -> u32 { return m_space->read_dword_unaligned(address); }; + m_write8 = [this](offs_t address, u8 data) { m_space->write_byte(address, data); }; + m_write16 = [this](offs_t address, u16 data) { m_space->write_word_unaligned(address, data); }; + m_write32 = [this](offs_t address, u32 data) { m_space->write_dword_unaligned(address, data); }; - return m_space->read_byte(address); } -void m68000_base_device::write_byte_32_mmu(offs_t address, uint8_t data) +/* interface for 32-bit data bus with PMMU */ +void m68000_base_device::init32mmu(address_space &space, address_space &ospace) { - if (m_pmmu_enabled) - { - address = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { - return; - } - } - - m_space->write_byte(address, data); -} + m_space = &space; + m_ospace = &ospace; + auto ocache = ospace.cache<2, 0, ENDIANNESS_BIG>(); -uint16_t m68000_base_device::read_immediate_16_mmu(offs_t address) -{ - if (m_pmmu_enabled) - { - address = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { + m_readimm16 = [this, ocache](offs_t address) -> u16 { + if (m_pmmu_enabled) { + address = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) return ~0; } - } - - return m_odirect->read_word((address), m_opcode_xor); -} -/* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */ -uint16_t m68000_base_device::readword_d32_mmu(offs_t address) -{ - uint16_t result; + return ocache->read_word(address); + }; - if (m_pmmu_enabled) - { - uint32_t address0 = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { - return ~0; - } else if (WORD_ALIGNED(address)) { - return m_space->read_word(address0); - } else { - uint32_t address1 = pmmu_translate_addr(address + 1); - if (m_mmu_tmp_buserror_occurred) { - return ~0; - } else { - result = m_space->read_byte(address0) << 8; - return result | m_space->read_byte(address1); - } + m_read8 = [this](offs_t address) -> u8 { + if (m_pmmu_enabled) { + address = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) + return ~0; } - } - - if (WORD_ALIGNED(address)) - return m_space->read_word(address); - result = m_space->read_byte(address) << 8; - return result | m_space->read_byte(address + 1); -} + return m_space->read_byte(address); + }; -/* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */ -void m68000_base_device::writeword_d32_mmu(offs_t address, uint16_t data) -{ - if (m_pmmu_enabled) - { - uint32_t address0 = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { - return; - } else if (WORD_ALIGNED(address)) { - m_space->write_word(address0, data); - return; - } else { - uint32_t address1 = pmmu_translate_addr(address + 1); - if (m_mmu_tmp_buserror_occurred) { - return; - } else { - m_space->write_byte(address0, data >> 8); - m_space->write_byte(address1, data); - return; - } + m_read16 = [this](offs_t address) -> u16 { + if (m_pmmu_enabled) { + u32 address0 = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) + return ~0; + if (WORD_ALIGNED(address)) + return m_space->read_word(address0); + u32 address1 = pmmu_translate_addr(address + 1); + if (m_mmu_tmp_buserror_occurred) + return ~0; + u16 result = m_space->read_byte(address0) << 8; + return result | m_space->read_byte(address1); } - } - - if (WORD_ALIGNED(address)) - { - m_space->write_word(address, data); - return; - } - m_space->write_byte(address, data >> 8); - m_space->write_byte(address + 1, data); -} - -/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */ -uint32_t m68000_base_device::readlong_d32_mmu(offs_t address) -{ - uint32_t result; - - if (m_pmmu_enabled) - { - uint32_t address0 = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { - return ~0; - } else if ((address +3) & 0xfc) { - // not at page boundary; use default code - address = address0; - } else if (DWORD_ALIGNED(address)) { // 0 - return m_space->read_dword(address0); - } else { - uint32_t address2 = pmmu_translate_addr(address+2); - if (m_mmu_tmp_buserror_occurred) { + + if (WORD_ALIGNED(address)) + return m_space->read_word(address); + u16 result = m_space->read_byte(address) << 8; + return result | m_space->read_byte(address + 1); + }; + + m_read32 = [this](offs_t address) -> u32 { + if (m_pmmu_enabled) { + u32 address0 = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) return ~0; - } else if (WORD_ALIGNED(address)) { // 2 - result = m_space->read_word(address0) << 16; - return result | m_space->read_word(address2); - } else { - uint32_t address1 = pmmu_translate_addr(address+1); - uint32_t address3 = pmmu_translate_addr(address+3); - if (m_mmu_tmp_buserror_occurred) { + if ((address +3) & 0xfc) + // not at page boundary; use default code + address = address0; + else if (DWORD_ALIGNED(address)) // 0 + return m_space->read_dword(address0); + else { + u32 address2 = pmmu_translate_addr(address+2); + if (m_mmu_tmp_buserror_occurred) return ~0; - } else { - result = m_space->read_byte(address0) << 24; - result |= m_space->read_word(address1) << 8; - return result | m_space->read_byte(address3); + if (WORD_ALIGNED(address)) { // 2 + u16 result = m_space->read_word(address0) << 16; + return result | m_space->read_word(address2); } + u32 address1 = pmmu_translate_addr(address+1); + u32 address3 = pmmu_translate_addr(address+3); + if (m_mmu_tmp_buserror_occurred) + return ~0; + u32 result = m_space->read_byte(address0) << 24; + result |= m_space->read_word(address1) << 8; + return result | m_space->read_byte(address3); } } - } - - if (DWORD_ALIGNED(address)) - return m_space->read_dword(address); - else if (WORD_ALIGNED(address)) - { - result = m_space->read_word(address) << 16; - return result | m_space->read_word(address + 2); - } - result = m_space->read_byte(address) << 24; - result |= m_space->read_word(address + 1) << 8; - return result | m_space->read_byte(address + 3); -} + if (DWORD_ALIGNED(address)) + return m_space->read_dword(address); + if (WORD_ALIGNED(address)) { + u32 result = m_space->read_word(address) << 16; + return result | m_space->read_word(address + 2); + } + u32 result = m_space->read_byte(address) << 24; + result |= m_space->read_word(address + 1) << 8; + return result | m_space->read_byte(address + 3); + }; + + m_write8 = [this](offs_t address, u8 data) { + if (m_pmmu_enabled) { + address = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) + return; + } + m_space->write_byte(address, data); + }; -/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */ -void m68000_base_device::writelong_d32_mmu(offs_t address, uint32_t data) -{ - if (m_pmmu_enabled) - { - uint32_t address0 = pmmu_translate_addr(address); - if (m_mmu_tmp_buserror_occurred) { + m_write16 = [this](offs_t address, u16 data) { + if (m_pmmu_enabled) { + u32 address0 = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) + return; + if (WORD_ALIGNED(address)) { + m_space->write_word(address0, data); + return; + } + u32 address1 = pmmu_translate_addr(address + 1); + if (m_mmu_tmp_buserror_occurred) + return; + m_space->write_byte(address0, data >> 8); + m_space->write_byte(address1, data); return; - } else if ((address +3) & 0xfc) { - // not at page boundary; use default code - address = address0; - } else if (DWORD_ALIGNED(address)) { // 0 - m_space->write_dword(address0, data); + } + + if (WORD_ALIGNED(address)) { + m_space->write_word(address, data); return; - } else { - uint32_t address2 = pmmu_translate_addr(address+2); - if (m_mmu_tmp_buserror_occurred) { + } + m_space->write_byte(address, data >> 8); + m_space->write_byte(address + 1, data); + }; + + m_write32 = [this](offs_t address, u32 data) { + if (m_pmmu_enabled) { + u32 address0 = pmmu_translate_addr(address); + if (m_mmu_tmp_buserror_occurred) return; - } else if (WORD_ALIGNED(address)) { // 2 - m_space->write_word(address0, data >> 16); - m_space->write_word(address2, data); + if ((address +3) & 0xfc) { + // not at page boundary; use default code + address = address0; + } else if (DWORD_ALIGNED(address)) { // 0 + m_space->write_dword(address0, data); return; } else { - uint32_t address1 = pmmu_translate_addr(address+1); - uint32_t address3 = pmmu_translate_addr(address+3); - if (m_mmu_tmp_buserror_occurred) { + u32 address2 = pmmu_translate_addr(address+2); + if (m_mmu_tmp_buserror_occurred) return; - } else { - m_space->write_byte(address0, data >> 24); - m_space->write_word(address1, data >> 8); - m_space->write_byte(address3, data); + if (WORD_ALIGNED(address)) { // 2 + m_space->write_word(address0, data >> 16); + m_space->write_word(address2, data); return; } + u32 address1 = pmmu_translate_addr(address+1); + u32 address3 = pmmu_translate_addr(address+3); + if (m_mmu_tmp_buserror_occurred) + return; + m_space->write_byte(address0, data >> 24); + m_space->write_word(address1, data >> 8); + m_space->write_byte(address3, data); + return; } } - } - if (DWORD_ALIGNED(address)) - { - m_space->write_dword(address, data); - return; - } - else if (WORD_ALIGNED(address)) - { - m_space->write_word(address, data >> 16); - m_space->write_word(address + 2, data); - return; - } - m_space->write_byte(address, data >> 24); - m_space->write_word(address + 1, data >> 8); - m_space->write_byte(address + 3, data); + if (DWORD_ALIGNED(address)) { + m_space->write_dword(address, data); + return; + } + if (WORD_ALIGNED(address)) { + m_space->write_word(address, data >> 16); + m_space->write_word(address + 2, data); + return; + } + m_space->write_byte(address, data >> 24); + m_space->write_word(address + 1, data >> 8); + m_space->write_byte(address + 3, data); + }; } -void m68000_base_device::init32mmu(address_space &space, address_space &ospace) +void m68000_base_device::init32hmmu(address_space &space, address_space &ospace) { m_space = &space; - m_direct = space.direct<0>(); m_ospace = &ospace; - m_odirect = ospace.direct<0>(); - m_opcode_xor = WORD_XOR_BE(0); - - m_readimm16 = m68k_readimm16_delegate(&m68000_base_device::read_immediate_16_mmu, this); - m_read8 = m68k_read8_delegate(&m68000_base_device::read_byte_32_mmu, this); - m_read16 = m68k_read16_delegate(&m68000_base_device::readword_d32_mmu, this); - m_read32 = m68k_read32_delegate(&m68000_base_device::readlong_d32_mmu, this); - m_write8 = m68k_write8_delegate(&m68000_base_device::write_byte_32_mmu, this); - m_write16 = m68k_write16_delegate(&m68000_base_device::writeword_d32_mmu, this); - m_write32 = m68k_write32_delegate(&m68000_base_device::writelong_d32_mmu, this); -} - - -/* interface for 32-bit data bus with PMMU (68EC020, 68020) */ -uint8_t m68000_base_device::read_byte_32_hmmu(offs_t address) -{ - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } - - return m_space->read_byte(address); -} - -void m68000_base_device::write_byte_32_hmmu(offs_t address, uint8_t data) -{ - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } - - m_space->write_byte(address, data); -} - -uint16_t m68000_base_device::read_immediate_16_hmmu(offs_t address) -{ - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } - - return m_odirect->read_word((address), m_opcode_xor); -} - -/* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */ -uint16_t m68000_base_device::readword_d32_hmmu(offs_t address) -{ - uint16_t result; - - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } - - if (WORD_ALIGNED(address)) - return m_space->read_word(address); - result = m_space->read_byte(address) << 8; - return result | m_space->read_byte(address + 1); -} - -/* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */ -void m68000_base_device::writeword_d32_hmmu(offs_t address, uint16_t data) -{ - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } + auto ocache = ospace.cache<2, 0, ENDIANNESS_BIG>(); - if (WORD_ALIGNED(address)) - { - m_space->write_word(address, data); - return; - } - m_space->write_byte(address, data >> 8); - m_space->write_byte(address + 1, data); -} + m_readimm16 = [this, ocache](offs_t address) -> u16 { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); + return ocache->read_word(address); + }; -/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */ -uint32_t m68000_base_device::readlong_d32_hmmu(offs_t address) -{ - uint32_t result; + m_read8 = [this](offs_t address) -> u8 { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); + return m_space->read_byte(address); + }; - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } + m_read16 = [this](offs_t address) -> u16 { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); + if (WORD_ALIGNED(address)) + return m_space->read_word(address); + u16 result = m_space->read_byte(address) << 8; + return result | m_space->read_byte(address + 1); + }; + + m_read32 = [this](offs_t address) -> u32 { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); - if (DWORD_ALIGNED(address)) - return m_space->read_dword(address); - else if (WORD_ALIGNED(address)) - { - result = m_space->read_word(address) << 16; - return result | m_space->read_word(address + 2); - } - result = m_space->read_byte(address) << 24; - result |= m_space->read_word(address + 1) << 8; - return result | m_space->read_byte(address + 3); -} + if (DWORD_ALIGNED(address)) + return m_space->read_dword(address); + if (WORD_ALIGNED(address)) { + u32 result = m_space->read_word(address) << 16; + return result | m_space->read_word(address + 2); + } + u32 result = m_space->read_byte(address) << 24; + result |= m_space->read_word(address + 1) << 8; + return result | m_space->read_byte(address + 3); + }; -/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */ -void m68000_base_device::writelong_d32_hmmu(offs_t address, uint32_t data) -{ - if (m_hmmu_enabled) - { - address = hmmu_translate_addr(address); - } + m_write8 = [this](offs_t address, u8 data) { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); + m_space->write_byte(address, data); + }; - if (DWORD_ALIGNED(address)) - { - m_space->write_dword(address, data); - return; - } - else if (WORD_ALIGNED(address)) - { - m_space->write_word(address, data >> 16); - m_space->write_word(address + 2, data); - return; - } - m_space->write_byte(address, data >> 24); - m_space->write_word(address + 1, data >> 8); - m_space->write_byte(address + 3, data); -} + m_write16 = [this](offs_t address, u16 data) { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); + if (WORD_ALIGNED(address)) { + m_space->write_word(address, data); + return; + } + m_space->write_byte(address, data >> 8); + m_space->write_byte(address + 1, data); + }; -void m68000_base_device::init32hmmu(address_space &space, address_space &ospace) -{ - m_space = &space; - m_direct = space.direct<0>(); - m_ospace = &ospace; - m_odirect = ospace.direct<0>(); - m_opcode_xor = WORD_XOR_BE(0); + m_write32 = [this](offs_t address, u32 data) { + if (m_hmmu_enabled) + address = hmmu_translate_addr(address); - m_readimm16 = m68k_readimm16_delegate(&m68000_base_device::read_immediate_16_hmmu, this); - m_read8 = m68k_read8_delegate(&m68000_base_device::read_byte_32_hmmu, this); - m_read16 = m68k_read16_delegate(&m68000_base_device::readword_d32_hmmu, this); - m_read32 = m68k_read32_delegate(&m68000_base_device::readlong_d32_hmmu, this); - m_write8 = m68k_write8_delegate(&m68000_base_device::write_byte_32_hmmu, this); - m_write16 = m68k_write16_delegate(&m68000_base_device::writeword_d32_hmmu, this); - m_write32 = m68k_write32_delegate(&m68000_base_device::writelong_d32_hmmu, this); + if (DWORD_ALIGNED(address)) { + m_space->write_dword(address, data); + return; + } + if (WORD_ALIGNED(address)) { + m_space->write_word(address, data >> 16); + m_space->write_word(address + 2, data); + return; + } + m_space->write_byte(address, data >> 24); + m_space->write_word(address + 1, data >> 8); + m_space->write_byte(address + 3, data); + }; } void m68000_base_device::set_reset_callback(write_line_delegate callback) @@ -2358,18 +2221,8 @@ void m68000_base_device::clear_all() m_int_ack_callback = device_irq_acknowledge_delegate(); m_program = nullptr; - m_opcode_xor = 0; -// m_readimm16 = 0; -// m_read8 = 0; -// m_read16 = 0; -// m_read32 = 0; -// m_write8 = 0; -// m_write16 = 0; -// m_write32 = 0; - m_space = nullptr; - m_direct = nullptr; - + m_ospace = nullptr; m_iotemp = 0; diff --git a/src/devices/cpu/m6805/m6805.cpp b/src/devices/cpu/m6805/m6805.cpp index a1275b8088a..bc1e33d76ec 100644 --- a/src/devices/cpu/m6805/m6805.cpp +++ b/src/devices/cpu/m6805/m6805.cpp @@ -263,7 +263,7 @@ m6805_base_device::m6805_base_device( void m6805_base_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); // set our instruction counter set_icountptr(m_icount); diff --git a/src/devices/cpu/m6805/m6805.h b/src/devices/cpu/m6805/m6805.h index 74090368f09..ad3b2ca61ec 100644 --- a/src/devices/cpu/m6805/m6805.h +++ b/src/devices/cpu/m6805/m6805.h @@ -145,8 +145,8 @@ protected: unsigned rdmem(u32 addr) { return unsigned(m_program->read_byte(addr)); } void wrmem(u32 addr, u8 value) { m_program->write_byte(addr, value); } - unsigned rdop(u32 addr) { return unsigned(m_direct->read_byte(addr)); } - unsigned rdop_arg(u32 addr) { return unsigned(m_direct->read_byte(addr)); } + unsigned rdop(u32 addr) { return unsigned(m_cache->read_byte(addr)); } + unsigned rdop_arg(u32 addr) { return unsigned(m_cache->read_byte(addr)); } unsigned rm(u32 addr) { return rdmem(addr); } void rm16(u32 addr, PAIR &p); @@ -277,7 +277,7 @@ protected: // address spaces address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; }; diff --git a/src/devices/cpu/m6809/m6809.cpp b/src/devices/cpu/m6809/m6809.cpp index c5eba10d5f1..f9ceda47ddc 100644 --- a/src/devices/cpu/m6809/m6809.cpp +++ b/src/devices/cpu/m6809/m6809.cpp @@ -159,8 +159,8 @@ void m6809_base_device::device_start() m_mintf->m_program = &space(AS_PROGRAM); m_mintf->m_sprogram = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_mintf->m_program; - m_mintf->m_direct = m_mintf->m_program->direct<0>(); - m_mintf->m_sdirect = m_mintf->m_sprogram->direct<0>(); + m_mintf->m_cache = m_mintf->m_program->cache<0, 0, ENDIANNESS_BIG>(); + m_mintf->m_scache = m_mintf->m_sprogram->cache<0, 0, ENDIANNESS_BIG>(); m_lic_func.resolve_safe(); @@ -586,12 +586,12 @@ uint8_t m6809_base_device::mi_default::read(uint16_t adr) uint8_t m6809_base_device::mi_default::read_opcode(uint16_t adr) { - return m_sdirect->read_byte(adr); + return m_scache->read_byte(adr); } uint8_t m6809_base_device::mi_default::read_opcode_arg(uint16_t adr) { - return m_direct->read_byte(adr); + return m_cache->read_byte(adr); } diff --git a/src/devices/cpu/m6809/m6809.h b/src/devices/cpu/m6809/m6809.h index 2187b87bf2d..6886dcbb3d3 100644 --- a/src/devices/cpu/m6809/m6809.h +++ b/src/devices/cpu/m6809/m6809.h @@ -35,7 +35,7 @@ protected: class memory_interface { public: address_space *m_program, *m_sprogram; - direct_read_data<0> *m_direct, *m_sdirect; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache, *m_scache; virtual ~memory_interface() {} virtual uint8_t read(uint16_t adr) = 0; diff --git a/src/devices/cpu/mb86233/mb86233.cpp b/src/devices/cpu/mb86233/mb86233.cpp index 59b83241f37..0b0ebba380e 100644 --- a/src/devices/cpu/mb86233/mb86233.cpp +++ b/src/devices/cpu/mb86233/mb86233.cpp @@ -89,7 +89,7 @@ std::unique_ptr<util::disasm_interface> mb86233_device::create_disassembler() void mb86233_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-2>(); + m_cache = m_program->cache<2, -2, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); @@ -722,7 +722,7 @@ void mb86233_device::execute_run() while(m_icount > 0) { m_ppc = m_pc; debugger_instruction_hook(m_ppc); - u32 opcode = m_direct->read_dword(m_pc++); + u32 opcode = m_cache->read_dword(m_pc++); switch((opcode >> 26) & 0x3f) { case 0x00: { diff --git a/src/devices/cpu/mb86233/mb86233.h b/src/devices/cpu/mb86233/mb86233.h index 255b16d16e4..94c189a08ff 100644 --- a/src/devices/cpu/mb86233/mb86233.h +++ b/src/devices/cpu/mb86233/mb86233.h @@ -89,7 +89,7 @@ private: address_space_config m_rf_config; address_space *m_program, *m_data, *m_io, *m_rf; - direct_read_data<-2> *m_direct; + memory_access_cache<2, -2, ENDIANNESS_LITTLE> *m_cache; int m_icount; u32 m_st, m_a, m_b, m_d, m_p; diff --git a/src/devices/cpu/mb86235/mb86235.cpp b/src/devices/cpu/mb86235/mb86235.cpp index 6fad9a71636..fc56ce12390 100644 --- a/src/devices/cpu/mb86235/mb86235.cpp +++ b/src/devices/cpu/mb86235/mb86235.cpp @@ -68,7 +68,7 @@ void mb86235_device::execute_run() curpc = check_previous_op_stall() ? m_core->cur_fifo_state.pc : m_core->pc; debugger_instruction_hook(curpc); - opcode = m_direct->read_qword(curpc); + opcode = m_pcache->read_qword(curpc); m_core->ppc = curpc; @@ -92,7 +92,7 @@ void mb86235_device::execute_run() void mb86235_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-3>(); + m_pcache = m_program->cache<3, -3, ENDIANNESS_LITTLE>(); m_dataa = &space(AS_DATA); m_datab = &space(AS_IO); diff --git a/src/devices/cpu/mb86235/mb86235.h b/src/devices/cpu/mb86235/mb86235.h index f0a394bed5b..2df714f9bd4 100644 --- a/src/devices/cpu/mb86235/mb86235.h +++ b/src/devices/cpu/mb86235/mb86235.h @@ -85,7 +85,7 @@ protected: // device_disasm_interface overrides virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; - direct_read_data<-3> *m_direct; + memory_access_cache<3, -3, ENDIANNESS_LITTLE> *m_pcache; private: diff --git a/src/devices/cpu/mb86235/mb86235fe.cpp b/src/devices/cpu/mb86235/mb86235fe.cpp index 5e60cfe6216..41ad97ebb87 100644 --- a/src/devices/cpu/mb86235/mb86235fe.cpp +++ b/src/devices/cpu/mb86235/mb86235fe.cpp @@ -63,7 +63,7 @@ mb86235_frontend::mb86235_frontend(mb86235_device *core, uint32_t window_start, bool mb86235_frontend::describe(opcode_desc &desc, const opcode_desc *prev) { - uint64_t opcode = desc.opptr.q[0] = m_core->m_direct->read_qword(desc.pc, 0); + uint64_t opcode = desc.opptr.q[0] = m_core->m_pcache->read_qword(desc.pc, 0); desc.length = 1; desc.cycles = 1; diff --git a/src/devices/cpu/mb88xx/mb88xx.cpp b/src/devices/cpu/mb88xx/mb88xx.cpp index 12320524b41..78f9220d5f8 100644 --- a/src/devices/cpu/mb88xx/mb88xx.cpp +++ b/src/devices/cpu/mb88xx/mb88xx.cpp @@ -47,7 +47,7 @@ DEFINE_DEVICE_TYPE(MB8844, mb8844_cpu_device, "mb8844", "Fujitsu MB8844") MACROS ***************************************************************************/ -#define READOP(a) (m_direct->read_byte(a)) +#define READOP(a) (m_cache->read_byte(a)) #define RDMEM(a) (m_data->read_byte(a)) #define WRMEM(a,v) (m_data->write_byte((a), (v))) @@ -183,7 +183,7 @@ std::unique_ptr<util::disasm_interface> mb88_cpu_device::create_disassembler() void mb88_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_data = &space(AS_DATA); m_read_k.resolve_safe(0); diff --git a/src/devices/cpu/mb88xx/mb88xx.h b/src/devices/cpu/mb88xx/mb88xx.h index b37524de3d5..6afe25aa57d 100644 --- a/src/devices/cpu/mb88xx/mb88xx.h +++ b/src/devices/cpu/mb88xx/mb88xx.h @@ -217,7 +217,7 @@ private: uint8_t m_pending_interrupt; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_data; int m_icount; diff --git a/src/devices/cpu/mc68hc11/mc68hc11.cpp b/src/devices/cpu/mc68hc11/mc68hc11.cpp index 2a3fa7c36be..902b3ca4a91 100644 --- a/src/devices/cpu/mc68hc11/mc68hc11.cpp +++ b/src/devices/cpu/mc68hc11/mc68hc11.cpp @@ -307,13 +307,13 @@ void mc68hc11_cpu_device::hc11_regs_w(uint32_t address, uint8_t value) uint8_t mc68hc11_cpu_device::FETCH() { - return m_direct->read_byte(m_pc++); + return m_cache->read_byte(m_pc++); } uint16_t mc68hc11_cpu_device::FETCH16() { uint16_t w; - w = (m_direct->read_byte(m_pc) << 8) | (m_direct->read_byte(m_pc+1)); + w = m_cache->read_word(m_pc); m_pc += 2; return w; } @@ -397,7 +397,7 @@ void mc68hc11_cpu_device::device_start() m_internal_ram.resize(m_internal_ram_size); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); save_item(NAME(m_pc)); diff --git a/src/devices/cpu/mc68hc11/mc68hc11.h b/src/devices/cpu/mc68hc11/mc68hc11.h index d09e6ca3732..f2d834b7ad4 100644 --- a/src/devices/cpu/mc68hc11/mc68hc11.h +++ b/src/devices/cpu/mc68hc11/mc68hc11.h @@ -100,7 +100,7 @@ private: int m_ad_channel; uint8_t m_irq_state[2]; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_program; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/mcs40/mcs40.cpp b/src/devices/cpu/mcs40/mcs40.cpp index c04715bcdb1..19f4cbbdf4a 100644 --- a/src/devices/cpu/mcs40/mcs40.cpp +++ b/src/devices/cpu/mcs40/mcs40.cpp @@ -102,7 +102,7 @@ mcs40_cpu_device_base::mcs40_cpu_device_base( { "ramport", ENDIANNESS_LITTLE, 8, u8(5), 0 }, { "program", ENDIANNESS_LITTLE, 8, u8(rom_width - 3), 0 }, } , m_spaces{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } - , m_direct(nullptr) + , m_cache(nullptr) , m_bus_cycle_cb() , m_sync_cb(*this) , m_cm_rom_cb{ { *this }, { *this } } @@ -142,7 +142,7 @@ void mcs40_cpu_device_base::device_start() m_spaces[AS_RAM_STATUS] = &space(AS_RAM_STATUS); m_spaces[AS_RAM_PORTS] = &space(AS_RAM_PORTS); m_spaces[AS_PROGRAM_MEMORY] = &space(AS_PROGRAM_MEMORY); - m_direct = m_spaces[AS_ROM]->direct<0>(); + m_cache = m_spaces[AS_ROM]->cache<0, 0, ENDIANNESS_LITTLE>(); m_bus_cycle_cb.bind_relative_to(*owner()); m_sync_cb.resolve_safe(); @@ -637,7 +637,7 @@ inline void mcs40_cpu_device_base::do_m1() update_cm_rom(0x0fU); } // TODO: just read the high nybble here - MAME doesn't support this - u8 const read = m_direct->read_byte(rom_bank() | m_rom_addr); + u8 const read = m_cache->read_byte(rom_bank() | m_rom_addr); if (cycle::OP == m_cycle) { m_opr = (m_stop_ff) ? 0x0U : (read >> 4); @@ -655,7 +655,7 @@ inline void mcs40_cpu_device_base::do_m1() inline void mcs40_cpu_device_base::do_m2() { // TODO: just read the low nybble here - MAME doesn't support this - u8 const read = m_direct->read_byte(rom_bank() | m_rom_addr); + u8 const read = m_cache->read_byte(rom_bank() | m_rom_addr); if (cycle::OP == m_cycle) m_opa = (m_stop_ff) ? 0x0U : (read & 0x0fU); else diff --git a/src/devices/cpu/mcs40/mcs40.h b/src/devices/cpu/mcs40/mcs40.h index a18fe7a85c2..337e171736b 100644 --- a/src/devices/cpu/mcs40/mcs40.h +++ b/src/devices/cpu/mcs40/mcs40.h @@ -283,7 +283,7 @@ private: // address spaces address_space_config const m_space_config[7]; address_space *m_spaces[7]; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; // bus snooping callback bus_cycle_delegate m_bus_cycle_cb; diff --git a/src/devices/cpu/mcs48/mcs48.cpp b/src/devices/cpu/mcs48/mcs48.cpp index 0bfbdf05a5a..f80cfbc9381 100644 --- a/src/devices/cpu/mcs48/mcs48.cpp +++ b/src/devices/cpu/mcs48/mcs48.cpp @@ -361,7 +361,7 @@ uint8_t mcs48_cpu_device::opcode_fetch() { uint16_t address = m_pc; m_pc = ((m_pc + 1) & 0x7ff) | (m_pc & 0x800); - return m_direct->read_byte(address); + return m_cache->read_byte(address); } @@ -374,7 +374,7 @@ uint8_t mcs48_cpu_device::argument_fetch() { uint16_t address = m_pc; m_pc = ((m_pc + 1) & 0x7ff) | (m_pc & 0x800); - return m_direct->read_byte(address); + return m_cache->read_byte(address); } @@ -1078,7 +1078,7 @@ void mcs48_cpu_device::device_start() m_ea = (m_int_rom_size ? 0 : 1); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = (m_feature_mask & EXT_BUS_FEATURE) != 0 ? &space(AS_IO) : nullptr; diff --git a/src/devices/cpu/mcs48/mcs48.h b/src/devices/cpu/mcs48/mcs48.h index bbe85861bce..35b2feec29b 100644 --- a/src/devices/cpu/mcs48/mcs48.h +++ b/src/devices/cpu/mcs48/mcs48.h @@ -237,7 +237,7 @@ protected: /* Memory spaces */ address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/mcs51/mcs51.cpp b/src/devices/cpu/mcs51/mcs51.cpp index 29dc46e89c2..25bc28dda2d 100644 --- a/src/devices/cpu/mcs51/mcs51.cpp +++ b/src/devices/cpu/mcs51/mcs51.cpp @@ -402,8 +402,8 @@ device_memory_interface::space_config_vector mcs51_cpu_device::memory_space_conf ***************************************************************************/ /* Read Opcode/Opcode Arguments from Program Code */ -#define ROP(pc) m_direct->read_byte(pc) -#define ROP_ARG(pc) m_direct->read_byte(pc) +#define ROP(pc) m_cache->read_byte(pc) +#define ROP_ARG(pc) m_cache->read_byte(pc) /* Read a byte from External Code Memory (Usually Program Rom(s) Space) */ #define CODEMEM_R(a) (uint8_t)m_program->read_byte(a) @@ -1988,7 +1988,7 @@ void mcs51_cpu_device::execute_run() /* Read next opcode */ PPC = PC; debugger_instruction_hook(PC); - op = m_direct->read_byte(PC++); + op = m_cache->read_byte(PC++); /* process opcode and count cycles */ m_inst_cycles = mcs51_cycles[op]; @@ -2103,7 +2103,7 @@ uint8_t mcs51_cpu_device::sfr_read(size_t offset) void mcs51_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/mcs51/mcs51.h b/src/devices/cpu/mcs51/mcs51.h index a54df5ec3b5..32425cdc0f3 100644 --- a/src/devices/cpu/mcs51/mcs51.h +++ b/src/devices/cpu/mcs51/mcs51.h @@ -181,7 +181,7 @@ protected: /* Memory spaces */ address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/mcs96/mcs96.cpp b/src/devices/cpu/mcs96/mcs96.cpp index ca5bfafad69..455cc7f3e00 100644 --- a/src/devices/cpu/mcs96/mcs96.cpp +++ b/src/devices/cpu/mcs96/mcs96.cpp @@ -15,7 +15,7 @@ mcs96_device::mcs96_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int data_width) : cpu_device(mconfig, type, tag, owner, clock), program_config("program", ENDIANNESS_LITTLE, data_width, 16), - program(nullptr), direct(nullptr), icount(0), bcount(0), inst_state(0), cycles_scaling(0), pending_irq(0), + program(nullptr), icount(0), bcount(0), inst_state(0), cycles_scaling(0), pending_irq(0), PC(0), PPC(0), PSW(0), OP1(0), OP2(0), OP3(0), OPI(0), TMP(0), irq_requested(false) { } @@ -23,7 +23,14 @@ mcs96_device::mcs96_device(const machine_config &mconfig, device_type type, cons void mcs96_device::device_start() { program = &space(AS_PROGRAM); - direct = program->direct<0>(); + if(program->data_width() == 8) { + auto cache = program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } + set_icountptr(icount); state_add(STATE_GENPC, "GENPC", PC).noshow(); diff --git a/src/devices/cpu/mcs96/mcs96.h b/src/devices/cpu/mcs96/mcs96.h index 3ff9f02d4d2..9358c64cbee 100644 --- a/src/devices/cpu/mcs96/mcs96.h +++ b/src/devices/cpu/mcs96/mcs96.h @@ -65,7 +65,7 @@ protected: address_space_config program_config; address_space *program; - direct_read_data<0> *direct; + std::function<u8 (offs_t address)> m_pr8; int icount, bcount, inst_state, cycles_scaling; uint8_t pending_irq; @@ -89,7 +89,7 @@ protected: inline void next(int cycles) { icount -= cycles_scaling*cycles; inst_state = STATE_FETCH; } inline void next_noirq(int cycles) { icount -= cycles_scaling*cycles; inst_state = STATE_FETCH_NOIRQ; } void check_irq(); - inline uint8_t read_pc() { return direct->read_byte(PC++); } + inline uint8_t read_pc() { return m_pr8(PC++); } void reg_w8(uint8_t adr, uint8_t data); void reg_w16(uint8_t adr, uint16_t data); diff --git a/src/devices/cpu/mips/mips3.cpp b/src/devices/cpu/mips/mips3.cpp index ca8a621dc72..411c6ca5d6f 100644 --- a/src/devices/cpu/mips/mips3.cpp +++ b/src/devices/cpu/mips/mips3.cpp @@ -96,7 +96,7 @@ static const uint8_t fpmode_source[4] = MEMORY ACCESSORS ***************************************************************************/ -#define ROPCODE(pc) direct->read_dword(pc) +#define ROPCODE(pc) m_lr32(pc) DEFINE_DEVICE_TYPE(VR4300BE, vr4300be_device, "vr4300be", "NEC VR4300 (big)") @@ -337,7 +337,18 @@ void mips3_device::device_start() m_cpu_clock = clock(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->endianness() == ENDIANNESS_LITTLE) + { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } + else + { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } /* set up the endianness */ m_program->accessors(m_memory); diff --git a/src/devices/cpu/mips/mips3.h b/src/devices/cpu/mips/mips3.h index 019920df79e..6c192b5436c 100644 --- a/src/devices/cpu/mips/mips3.h +++ b/src/devices/cpu/mips/mips3.h @@ -362,7 +362,8 @@ private: loadstore_func m_sdr; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u32 (offs_t)> m_pr32; + std::function<const void * (offs_t)> m_prptr; uint32_t c_system_clock; uint32_t m_cpu_clock; emu_timer * m_compare_int_timer; diff --git a/src/devices/cpu/mips/mips3drc.cpp b/src/devices/cpu/mips/mips3drc.cpp index a226fcbcbc7..3be62994a27 100644 --- a/src/devices/cpu/mips/mips3drc.cpp +++ b/src/devices/cpu/mips/mips3drc.cpp @@ -1075,14 +1075,14 @@ void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state & if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { uint32_t sum = seqhead->opptr.l[0]; - void *base = m_direct->read_ptr(seqhead->physpc); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword if (seqhead->delay.first() != nullptr && !(seqhead->delay.first()->flags & OPFLAG_VIRTUAL_NOOP) && seqhead->physpc != seqhead->delay.first()->physpc) { - base = m_direct->read_ptr(seqhead->delay.first()->physpc); + base = m_prptr(seqhead->delay.first()->physpc); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 @@ -1102,20 +1102,20 @@ void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state & for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - void *base = m_direct->read_ptr(seqhead->physpc); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword UML_CMP(block, I0, curdesc->opptr.l[0]); // cmp i0,opptr[0] UML_EXHc(block, COND_NE, *m_nocode, epc(seqhead)); // exne nocode,seqhead->pc } #else uint32_t sum = 0; - void *base = m_direct->read_ptr(seqhead->physpc); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - base = m_direct->read_ptr(curdesc->physpc); + base = m_prptr(curdesc->physpc); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 @@ -1125,7 +1125,7 @@ void mips3_device::generate_checksum_block(drcuml_block &block, compiler_state & && !(curdesc->delay.first()->flags & OPFLAG_VIRTUAL_NOOP) && (curdesc == seqlast || (curdesc->next() != nullptr && curdesc->next()->physpc != curdesc->delay.first()->physpc))) { - base = m_direct->read_ptr(curdesc->delay.first()->physpc); + base = m_prptr(curdesc->delay.first()->physpc); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 diff --git a/src/devices/cpu/mips/mips3fe.cpp b/src/devices/cpu/mips/mips3fe.cpp index a530d026c75..bfaf0c682d2 100644 --- a/src/devices/cpu/mips/mips3fe.cpp +++ b/src/devices/cpu/mips/mips3fe.cpp @@ -49,7 +49,7 @@ bool mips3_frontend::describe(opcode_desc &desc, const opcode_desc *prev) // fetch the opcode assert((desc.physpc & 3) == 0); - op = desc.opptr.l[0] = m_mips3->m_direct->read_dword(desc.physpc); + op = desc.opptr.l[0] = m_mips3->m_pr32(desc.physpc); // all instructions are 4 bytes and default to a single cycle each desc.length = 4; diff --git a/src/devices/cpu/mips/r3000.cpp b/src/devices/cpu/mips/r3000.cpp index 60ddfc1b594..1cf74b4bff4 100644 --- a/src/devices/cpu/mips/r3000.cpp +++ b/src/devices/cpu/mips/r3000.cpp @@ -130,7 +130,6 @@ r3000_device::r3000_device(const machine_config &mconfig, device_type type, cons m_program_config_be("program", ENDIANNESS_BIG, 32, 29), m_program_config_le("program", ENDIANNESS_LITTLE, 32, 29), m_program(nullptr), - m_direct(nullptr), m_chip_type(chiptype), m_hasfpu(false), m_endianness(ENDIANNESS_BIG), @@ -214,7 +213,18 @@ void r3000_device::device_start() { // get our address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->endianness() == ENDIANNESS_LITTLE) + { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } + else + { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } // determine the cache sizes switch (m_chip_type) @@ -470,7 +480,7 @@ std::unique_ptr<util::disasm_interface> r3000_device::create_disassembler() inline uint32_t r3000_device::readop(offs_t pc) { - return m_direct->read_dword(pc); + return m_pr32(pc); } uint8_t r3000_device::readmem(offs_t offset) diff --git a/src/devices/cpu/mips/r3000.h b/src/devices/cpu/mips/r3000.h index 86ecec13a5b..0abea62316d 100644 --- a/src/devices/cpu/mips/r3000.h +++ b/src/devices/cpu/mips/r3000.h @@ -194,7 +194,8 @@ protected: const address_space_config m_program_config_be; const address_space_config m_program_config_le; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u32 (offs_t)> m_pr32; + std::function<const void * (offs_t)> m_prptr; // configuration chip_type m_chip_type; diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp index 941eb3f95e1..50e7f587cf7 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp +++ b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp @@ -80,7 +80,7 @@ void hp_nanoprocessor_device::device_start() state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).noshow().formatstr("%10s"); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); save_item(NAME(m_reg_A)); @@ -507,7 +507,7 @@ uint16_t hp_nanoprocessor_device::pa_offset(unsigned off) const uint8_t hp_nanoprocessor_device::fetch(void) { - uint8_t res = m_direct->read_byte(m_reg_PA); + uint8_t res = m_cache->read_byte(m_reg_PA); m_reg_PA = pa_offset(1); return res; } diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor.h b/src/devices/cpu/nanoprocessor/nanoprocessor.h index 2d8390020a0..145ec5e2e5b 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor.h +++ b/src/devices/cpu/nanoprocessor/nanoprocessor.h @@ -114,7 +114,7 @@ private: address_space_config m_io_config; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_io; // device_t overrides diff --git a/src/devices/cpu/nec/nec.cpp b/src/devices/cpu/nec/nec.cpp index 5b95f818d78..9b7661adc82 100644 --- a/src/devices/cpu/nec/nec.cpp +++ b/src/devices/cpu/nec/nec.cpp @@ -218,7 +218,7 @@ void nec_common_device::do_prefetch(int previous_ICount) uint8_t nec_common_device::fetch() { prefetch(); - return m_direct->read_byte((Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } uint16_t nec_common_device::fetchword() @@ -238,7 +238,7 @@ static uint8_t parity_table[256]; uint8_t nec_common_device::fetchop() { prefetch(); - return m_direct->read_byte(( Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } @@ -419,7 +419,14 @@ void nec_common_device::device_start() save_item(NAME(m_prefetch_reset)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->data_width() == 8) { + auto cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } + m_io = &space(AS_IO); state_add( NEC_PC, "PC", m_debugger_temp).callimport().callexport().formatstr("%05X"); diff --git a/src/devices/cpu/nec/nec.h b/src/devices/cpu/nec/nec.h index 244c448f794..becf599aa94 100644 --- a/src/devices/cpu/nec/nec.h +++ b/src/devices/cpu/nec/nec.h @@ -88,7 +88,7 @@ private: uint8_t m_halted; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t address)> m_dr8; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/nec/v25.cpp b/src/devices/cpu/nec/v25.cpp index 48f3e1d9e27..7a076f2c6c3 100644 --- a/src/devices/cpu/nec/v25.cpp +++ b/src/devices/cpu/nec/v25.cpp @@ -137,7 +137,7 @@ void v25_common_device::do_prefetch(int previous_ICount) uint8_t v25_common_device::fetch() { prefetch(); - return m_direct->read_byte((Sreg(PS)<<4)+m_ip++, m_fetch_xor); + return m_dr8((Sreg(PS)<<4)+m_ip++); } uint16_t v25_common_device::fetchword() @@ -161,7 +161,7 @@ uint8_t v25_common_device::fetchop() uint8_t ret; prefetch(); - ret = m_direct->read_byte(( Sreg(PS)<<4)+m_ip++, m_fetch_xor); + ret = m_dr8((Sreg(PS)<<4)+m_ip++); if (m_MF == 0) if (m_v25v35_decryptiontable) @@ -511,7 +511,13 @@ void v25_common_device::device_start() save_item(NAME(m_prefetch_reset)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_program->data_width() == 8) { + auto cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } else { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_dr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + } m_io = &space(AS_IO); m_pt_in.resolve_safe(0xff); diff --git a/src/devices/cpu/nec/v25.h b/src/devices/cpu/nec/v25.h index e9ab912111b..27a63b739b0 100644 --- a/src/devices/cpu/nec/v25.h +++ b/src/devices/cpu/nec/v25.h @@ -141,7 +141,7 @@ private: uint32_t m_IDB; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t address)> m_dr8; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/pic16c5x/pic16c5x.cpp b/src/devices/cpu/pic16c5x/pic16c5x.cpp index 2be8f7ac8cc..fda2968f25c 100644 --- a/src/devices/cpu/pic16c5x/pic16c5x.cpp +++ b/src/devices/cpu/pic16c5x/pic16c5x.cpp @@ -202,7 +202,7 @@ void pic16c5x_device::update_internalram_ptr() -#define PIC16C5x_RDOP(A) (m_direct->read_word(A)) +#define PIC16C5x_RDOP(A) (m_cache->read_word(A)) #define PIC16C5x_RAM_RDMEM(A) ((uint8_t)m_data->read_byte(A)) #define PIC16C5x_RAM_WRMEM(A,V) (m_data->write_byte(A,V)) @@ -888,7 +888,7 @@ enum void pic16c5x_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_read_a.resolve_safe(0); diff --git a/src/devices/cpu/pic16c5x/pic16c5x.h b/src/devices/cpu/pic16c5x/pic16c5x.h index 1f141322c08..0cff2843715 100644 --- a/src/devices/cpu/pic16c5x/pic16c5x.h +++ b/src/devices/cpu/pic16c5x/pic16c5x.h @@ -169,7 +169,7 @@ private: int m_inst_cycles; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; // i/o handlers diff --git a/src/devices/cpu/pic16c62x/pic16c62x.cpp b/src/devices/cpu/pic16c62x/pic16c62x.cpp index aed2fc1bc83..93ec19349cd 100644 --- a/src/devices/cpu/pic16c62x/pic16c62x.cpp +++ b/src/devices/cpu/pic16c62x/pic16c62x.cpp @@ -176,7 +176,7 @@ void pic16c62x_device::update_internalram_ptr() m_internalram = (uint8_t *)m_data->get_write_ptr(0x00); } -#define PIC16C62x_RDOP(A) (m_direct->read_word(A)) +#define PIC16C62x_RDOP(A) (m_cache->read_word(A)) #define PIC16C62x_RAM_RDMEM(A) ((uint8_t)m_data->read_byte(A)) #define PIC16C62x_RAM_WRMEM(A,V) (m_data->write_byte(A,V)) #define PIC16C62x_In(Port) ((uint8_t)m_io->read_byte((Port))) @@ -873,7 +873,7 @@ void pic16c62x_device::build_opcode_table(void) void pic16c62x_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/pic16c62x/pic16c62x.h b/src/devices/cpu/pic16c62x/pic16c62x.h index 05366354d31..0d228b4b8fd 100644 --- a/src/devices/cpu/pic16c62x/pic16c62x.h +++ b/src/devices/cpu/pic16c62x/pic16c62x.h @@ -113,7 +113,7 @@ private: int m_inst_cycles; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/powerpc/ppc.h b/src/devices/cpu/powerpc/ppc.h index 97c7ed631ae..5bf746ecd4d 100644 --- a/src/devices/cpu/powerpc/ppc.h +++ b/src/devices/cpu/powerpc/ppc.h @@ -490,8 +490,9 @@ protected: int m_buffered_dma_rate[4]; /* internal stuff */ - direct_read_data<0> *m_direct; - offs_t m_codexor; + std::function<u32 (offs_t)> m_pr32; + std::function<const void * (offs_t)> m_prptr; + uint32_t m_system_clock; uint32_t m_cpu_clock; uint64_t m_tb_zero_cycles; diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp index 1d4b92ad549..6c76ccc6684 100644 --- a/src/devices/cpu/powerpc/ppccom.cpp +++ b/src/devices/cpu/powerpc/ppccom.cpp @@ -698,7 +698,6 @@ void ppc_device::device_start() m_pit_reload = 0; m_irqstate = 0; memset(m_buffered_dma_rate, 0, sizeof(m_buffered_dma_rate)); - m_codexor = 0; m_system_clock = 0; m_cpu_clock = 0; m_tb_zero_cycles = 0; @@ -715,15 +714,36 @@ void ppc_device::device_start() m_cache_line_size = 32; m_cpu_clock = clock(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if(m_cap & PPCCAP_4XX) + { + auto cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + m_prptr = [cache](offs_t address) -> const void * { return cache->read_ptr(address); }; + } + else + { + auto cache = m_program->cache<3, 0, ENDIANNESS_BIG>(); + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword(address); }; + if(space_config()->m_endianness != ENDIANNESS_NATIVE) + m_prptr = [cache](offs_t address) -> const void * { + const u32 *ptr = static_cast<u32 *>(cache->read_ptr(address & ~7)); + if(!(address & 4)) + ptr++; + return ptr; + }; + else + m_prptr = [cache](offs_t address) -> const void * { + const u32 *ptr = static_cast<u32 *>(cache->read_ptr(address & ~7)); + if(address & 4) + ptr++; + return ptr; + }; + } m_system_clock = c_bus_frequency != 0 ? c_bus_frequency : clock(); m_dcr_read_func = read32_delegate(); m_dcr_write_func = write32_delegate(); m_tb_divisor = (m_tb_divisor * clock() + m_system_clock / 2 - 1) / m_system_clock; - m_codexor = 0; - if (!(m_cap & PPCCAP_4XX) && space_config()->m_endianness != ENDIANNESS_NATIVE) - m_codexor = 4; /* allocate a timer for the compare interrupt */ if ((m_cap & PPCCAP_OEA) && (m_tb_divisor)) diff --git a/src/devices/cpu/powerpc/ppcdrc.cpp b/src/devices/cpu/powerpc/ppcdrc.cpp index fd4f6179160..e41d1d5dd8d 100644 --- a/src/devices/cpu/powerpc/ppcdrc.cpp +++ b/src/devices/cpu/powerpc/ppcdrc.cpp @@ -1626,7 +1626,7 @@ void ppc_device::generate_checksum_block(drcuml_block &block, compiler_state *co { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { - void *base = m_direct->read_ptr(seqhead->physpc, m_codexor); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,dword UML_CMP(block, I0, seqhead->opptr.l[0]); // cmp i0,*opptr UML_EXHc(block, COND_NE, *m_nocode, seqhead->pc); // exne nocode,seqhead->pc @@ -1640,20 +1640,20 @@ void ppc_device::generate_checksum_block(drcuml_block &block, compiler_state *co for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - void *base = m_direct->read_ptr(seqhead->physpc, m_codexor); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,dword UML_CMP(block, I0, curdesc->opptr.l[0]); // cmp i0,*opptr UML_EXHc(block, COND_NE, *m_nocode, seqhead->pc); // exne nocode,seqhead->pc } #else uint32_t sum = 0; - void *base = m_direct->read_ptr(seqhead->physpc, m_codexor); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - base = m_direct->read_ptr(curdesc->physpc, m_codexor); + base = m_prptr(curdesc->physpc); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 sum += curdesc->opptr.l[0]; diff --git a/src/devices/cpu/powerpc/ppcfe.cpp b/src/devices/cpu/powerpc/ppcfe.cpp index 67c90d37897..23270357f06 100644 --- a/src/devices/cpu/powerpc/ppcfe.cpp +++ b/src/devices/cpu/powerpc/ppcfe.cpp @@ -83,7 +83,7 @@ bool ppc_device::frontend::describe(opcode_desc &desc, const opcode_desc *prev) } // fetch the opcode - op = desc.opptr.l[0] = m_ppc.m_direct->read_dword(desc.physpc, m_ppc.m_codexor); + op = desc.opptr.l[0] = m_ppc.m_pr32(desc.physpc); // all instructions are 4 bytes and default to a single cycle each desc.length = 4; diff --git a/src/devices/cpu/pps4/pps4.cpp b/src/devices/cpu/pps4/pps4.cpp index 82c6c9b42f9..f17b420a004 100644 --- a/src/devices/cpu/pps4/pps4.cpp +++ b/src/devices/cpu/pps4/pps4.cpp @@ -153,7 +153,7 @@ std::unique_ptr<util::disasm_interface> pps4_device::create_disassembler() */ inline u8 pps4_device::ROP() { - const u8 op = m_direct->read_byte(m_P & 0xFFF); + const u8 op = m_cache->read_byte(m_P & 0xFFF); m_Ip = m_I1; // save previous opcode m_P = (m_P + 1) & 0xFFF; m_icount -= 1; @@ -169,7 +169,7 @@ inline u8 pps4_device::ROP() */ inline u8 pps4_device::ARG() { - const u8 arg = m_direct->read_byte(m_P & 0xFFF); + const u8 arg = m_cache->read_byte(m_P & 0xFFF); m_P = (m_P + 1) & 0xFFF; m_icount -= 1; return arg; @@ -1569,7 +1569,7 @@ void pps4_device::execute_run() void pps4_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/pps4/pps4.h b/src/devices/cpu/pps4/pps4.h index 8d3fb79cef7..f551cf2c0be 100644 --- a/src/devices/cpu/pps4/pps4.h +++ b/src/devices/cpu/pps4/pps4.h @@ -93,7 +93,7 @@ protected: devcb_write8 m_do_cb; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp index 534eb5c07f2..8ee9040d38c 100644 --- a/src/devices/cpu/psx/psx.cpp +++ b/src/devices/cpu/psx/psx.cpp @@ -1448,7 +1448,7 @@ void psxcpu_device::update_cop0( int reg ) ( m_cp0r[ CP0_SR ] & SR_IEC ) != 0 && ( m_cp0r[ CP0_SR ] & m_cp0r[ CP0_CAUSE ] & CAUSE_IP ) != 0 ) { - m_op = m_direct->read_dword( m_pc ); + m_op = m_cache->read_dword( m_pc ); execute_unstoppable_instructions( 1 ); exception( EXC_INT ); } @@ -1475,11 +1475,11 @@ void psxcpu_device::fetch_next_op() { uint32_t safepc = m_delayv & ~m_bad_word_address_mask; - m_op = m_direct->read_dword( safepc ); + m_op = m_cache->read_dword( safepc ); } else { - m_op = m_direct->read_dword( m_pc + 4 ); + m_op = m_cache->read_dword( m_pc + 4 ); } } @@ -1819,7 +1819,7 @@ void psxcpu_device::device_start() { // get our address spaces m_program = &space( AS_PROGRAM ); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); save_item( NAME( m_op ) ); save_item( NAME( m_pc ) ); @@ -2331,7 +2331,7 @@ void psxcpu_device::execute_run() } else { - m_op = m_direct->read_dword(m_pc); + m_op = m_cache->read_dword(m_pc); if( m_berr ) { diff --git a/src/devices/cpu/psx/psx.h b/src/devices/cpu/psx/psx.h index 9b18f8df5ff..ca417ee9607 100644 --- a/src/devices/cpu/psx/psx.h +++ b/src/devices/cpu/psx/psx.h @@ -235,7 +235,7 @@ protected: // address spaces const address_space_config m_program_config; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; // other internal states int m_icount; diff --git a/src/devices/cpu/rsp/rsp.cpp b/src/devices/cpu/rsp/rsp.cpp index 1037f33d845..2a3d122fce1 100644 --- a/src/devices/cpu/rsp/rsp.cpp +++ b/src/devices/cpu/rsp/rsp.cpp @@ -382,7 +382,7 @@ void rsp_device::device_start() m_exec_output = fopen("rsp_execute.txt", "wt"); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_pcache = m_program->cache<2, 0, ENDIANNESS_BIG>(); resolve_cb(); if (m_isdrc) diff --git a/src/devices/cpu/rsp/rsp.h b/src/devices/cpu/rsp/rsp.h index 8c3604473da..a4a3b239c1b 100644 --- a/src/devices/cpu/rsp/rsp.h +++ b/src/devices/cpu/rsp/rsp.h @@ -236,7 +236,7 @@ private: address_space *m_program; protected: - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_BIG> *m_pcache; private: std::unique_ptr<cop2> m_cop2; diff --git a/src/devices/cpu/rsp/rspdrc.cpp b/src/devices/cpu/rsp/rspdrc.cpp index 52022213f43..a91db94ceeb 100644 --- a/src/devices/cpu/rsp/rspdrc.cpp +++ b/src/devices/cpu/rsp/rspdrc.cpp @@ -654,12 +654,12 @@ void rsp_device::generate_checksum_block(drcuml_block &block, compiler_state &co if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { uint32_t sum = seqhead->opptr.l[0]; - void *base = m_direct->read_ptr(seqhead->physpc | 0x1000); + void *base = m_pcache->read_ptr(seqhead->physpc | 0x1000); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword if (seqhead->delay.first() != nullptr && seqhead->physpc != seqhead->delay.first()->physpc) { - base = m_direct->read_ptr((seqhead->delay.first()->physpc & 0x00000fff) | 0x1000); + base = m_pcache->read_ptr((seqhead->delay.first()->physpc & 0x00000fff) | 0x1000); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 @@ -676,13 +676,13 @@ void rsp_device::generate_checksum_block(drcuml_block &block, compiler_state &co else { uint32_t sum = 0; - void *base = m_direct->read_ptr(seqhead->physpc | 0x1000); + void *base = m_pcache->read_ptr(seqhead->physpc | 0x1000); UML_LOAD(block, I0, base, 0, SIZE_DWORD, SCALE_x4); // load i0,base,0,dword sum += seqhead->opptr.l[0]; for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - base = m_direct->read_ptr(curdesc->physpc | 0x1000); + base = m_pcache->read_ptr(curdesc->physpc | 0x1000); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 @@ -690,7 +690,7 @@ void rsp_device::generate_checksum_block(drcuml_block &block, compiler_state &co if (curdesc->delay.first() != nullptr && (curdesc == seqlast || (curdesc->next() != nullptr && curdesc->next()->physpc != curdesc->delay.first()->physpc))) { - base = m_direct->read_ptr((curdesc->delay.first()->physpc & 0x00000fff) | 0x1000); + base = m_pcache->read_ptr((curdesc->delay.first()->physpc & 0x00000fff) | 0x1000); assert(base != nullptr); UML_LOAD(block, I1, base, 0, SIZE_DWORD, SCALE_x4); // load i1,base,dword UML_ADD(block, I0, I0, I1); // add i0,i0,i1 diff --git a/src/devices/cpu/rsp/rspfe.cpp b/src/devices/cpu/rsp/rspfe.cpp index ce4d4dceb0e..bb7fbfebd47 100644 --- a/src/devices/cpu/rsp/rspfe.cpp +++ b/src/devices/cpu/rsp/rspfe.cpp @@ -38,7 +38,7 @@ bool rsp_device::frontend::describe(opcode_desc &desc, const opcode_desc *prev) uint32_t op, opswitch; // fetch the opcode - op = desc.opptr.l[0] = m_rsp.m_direct->read_dword((desc.physpc & 0x00000fff) | 0x1000); + op = desc.opptr.l[0] = m_rsp.m_pcache->read_dword((desc.physpc & 0x00000fff) | 0x1000); // all instructions are 4 bytes and default to a single cycle each desc.length = 4; diff --git a/src/devices/cpu/s2650/s2650.cpp b/src/devices/cpu/s2650/s2650.cpp index 46229053837..0b306682249 100644 --- a/src/devices/cpu/s2650/s2650.cpp +++ b/src/devices/cpu/s2650/s2650.cpp @@ -36,7 +36,7 @@ s2650_device::s2650_device(const machine_config &mconfig, const char *tag, devic , m_sense_handler(*this) , m_flag_handler(*this), m_intack_handler(*this) , m_ppc(0), m_page(0), m_iar(0), m_ea(0), m_psl(0), m_psu(0), m_r(0) - , m_halt(0), m_ir(0), m_irq_state(0), m_icount(0), m_direct(nullptr) + , m_halt(0), m_ir(0), m_irq_state(0), m_icount(0), m_cache(nullptr) , m_debugger_temp(0) { memset(m_reg, 0x00, sizeof(m_reg)); @@ -266,7 +266,7 @@ inline int s2650_device::check_irq_line() ***************************************************************/ inline uint8_t s2650_device::ROP() { - uint8_t result = m_direct->read_byte(m_page + m_iar); + uint8_t result = m_cache->read_byte(m_page + m_iar); m_iar = (m_iar + 1) & PMSK; return result; } @@ -277,7 +277,7 @@ inline uint8_t s2650_device::ROP() ***************************************************************/ inline uint8_t s2650_device::ARG() { - uint8_t result = m_direct->read_byte(m_page + m_iar); + uint8_t result = m_cache->read_byte(m_page + m_iar); m_iar = (m_iar + 1) & PMSK; return result; } @@ -826,7 +826,7 @@ void s2650_device::device_start() m_flag_handler.resolve_safe(); m_intack_handler.resolve_safe(); - m_direct = space(AS_PROGRAM).direct<0>(); + m_cache = space(AS_PROGRAM).cache<0, 0, ENDIANNESS_LITTLE>(); save_item(NAME(m_ppc)); save_item(NAME(m_page)); diff --git a/src/devices/cpu/s2650/s2650.h b/src/devices/cpu/s2650/s2650.h index 1524f1d9e30..fd0a7d29286 100644 --- a/src/devices/cpu/s2650/s2650.h +++ b/src/devices/cpu/s2650/s2650.h @@ -95,7 +95,7 @@ private: uint8_t m_irq_state; int m_icount; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; // For debugger uint16_t m_debugger_temp; diff --git a/src/devices/cpu/saturn/satops.hxx b/src/devices/cpu/saturn/satops.hxx index a42d9745cd2..8a1ecfe1c1d 100644 --- a/src/devices/cpu/saturn/satops.hxx +++ b/src/devices/cpu/saturn/satops.hxx @@ -9,7 +9,7 @@ int saturn_device::READ_OP() { uint8_t data; m_icount-=3; - data=m_direct->read_byte(m_pc); + data=m_cache->read_byte(m_pc); saturn_assert(data<0x10); m_pc=(m_pc+1)&0xfffff; return data; @@ -19,7 +19,7 @@ int saturn_device::READ_OP_ARG() { uint8_t data; m_icount-=3; - data=m_direct->read_byte(m_pc); + data=m_cache->read_byte(m_pc); saturn_assert(data<0x10); m_pc=(m_pc+1)&0xfffff; return data; diff --git a/src/devices/cpu/saturn/saturn.cpp b/src/devices/cpu/saturn/saturn.cpp index 591b0ff57c9..14b05baf3dd 100644 --- a/src/devices/cpu/saturn/saturn.cpp +++ b/src/devices/cpu/saturn/saturn.cpp @@ -53,7 +53,7 @@ saturn_device::saturn_device(const machine_config &mconfig, const char *tag, dev , m_id_func(*this) , m_crc_func(*this) , m_rsi_func(*this), m_pc(0), m_oldpc(0), m_p(0), m_out(0), m_carry(0), m_decimal(0), m_st(0), m_hst(0), m_nmi_state(0), m_irq_state(0), m_irq_enable(0), m_in_irq(0), - m_pending_irq(0), m_sleeping(0), m_monitor_id(0), m_monitor_in(0), m_program(nullptr), m_direct(nullptr), m_icount(0), m_debugger_temp(0) + m_pending_irq(0), m_sleeping(0), m_monitor_id(0), m_monitor_in(0), m_program(nullptr), m_cache(nullptr), m_icount(0), m_debugger_temp(0) { } @@ -93,7 +93,7 @@ std::unique_ptr<util::disasm_interface> saturn_device::create_disassembler() void saturn_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_out_func.resolve_safe(); m_in_func.resolve_safe(0); diff --git a/src/devices/cpu/saturn/saturn.h b/src/devices/cpu/saturn/saturn.h index b912ce25f70..f5b1d42eb42 100644 --- a/src/devices/cpu/saturn/saturn.h +++ b/src/devices/cpu/saturn/saturn.h @@ -149,7 +149,7 @@ typedef uint8_t Saturn64[16]; int m_monitor_id; int m_monitor_in; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; int64_t m_debugger_temp; diff --git a/src/devices/cpu/sc61860/sc61860.cpp b/src/devices/cpu/sc61860/sc61860.cpp index 00095916644..bfb39ee305a 100644 --- a/src/devices/cpu/sc61860/sc61860.cpp +++ b/src/devices/cpu/sc61860/sc61860.cpp @@ -110,7 +110,7 @@ void sc61860_device::device_start() m_2ms_tick_timer->adjust(attotime::from_hz(500), 0, attotime::from_hz(500)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_reset.resolve(); m_brk.resolve(); m_x.resolve(); diff --git a/src/devices/cpu/sc61860/sc61860.h b/src/devices/cpu/sc61860/sc61860.h index 61acce6f46e..18ea784db2d 100644 --- a/src/devices/cpu/sc61860/sc61860.h +++ b/src/devices/cpu/sc61860/sc61860.h @@ -135,7 +135,7 @@ private: emu_timer *m_2ms_tick_timer; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; int m_icount; uint8_t m_ram[0x100]; // internal special ram, should be 0x60, 0x100 to avoid memory corruption for now diff --git a/src/devices/cpu/sc61860/scops.hxx b/src/devices/cpu/sc61860/scops.hxx index 55c0d72d8ef..4ceec0df223 100644 --- a/src/devices/cpu/sc61860/scops.hxx +++ b/src/devices/cpu/sc61860/scops.hxx @@ -18,18 +18,18 @@ uint8_t sc61860_device::READ_OP() { - return m_direct->read_byte(m_pc++); + return m_cache->read_byte(m_pc++); } uint8_t sc61860_device::READ_OP_ARG() { - return m_direct->read_byte(m_pc++); + return m_cache->read_byte(m_pc++); } uint16_t sc61860_device::READ_OP_ARG_WORD() { - uint16_t t=m_direct->read_byte(m_pc++)<<8; - t|=m_direct->read_byte(m_pc++); + uint16_t t=m_cache->read_byte(m_pc++)<<8; + t|=m_cache->read_byte(m_pc++); return t; } diff --git a/src/devices/cpu/scmp/scmp.cpp b/src/devices/cpu/scmp/scmp.cpp index 4c78a0a8e9c..bb19aef3536 100644 --- a/src/devices/cpu/scmp/scmp.cpp +++ b/src/devices/cpu/scmp/scmp.cpp @@ -31,7 +31,7 @@ scmp_device::scmp_device(const machine_config &mconfig, const char *tag, device_ scmp_device::scmp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, type, tag, owner, clock) , m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0) - , m_AC(0), m_ER(0), m_SR(0), m_program(nullptr), m_direct(nullptr), m_icount(0) + , m_AC(0), m_ER(0), m_SR(0), m_program(nullptr), m_cache(nullptr), m_icount(0) , m_flag_out_func(*this) , m_sout_func(*this) , m_sin_func(*this) @@ -70,14 +70,14 @@ uint8_t scmp_device::ROP() { uint16_t pc = m_PC.w.l; m_PC.w.l = ADD12(m_PC.w.l,1); - return m_direct->read_byte( pc); + return m_cache->read_byte( pc); } uint8_t scmp_device::ARG() { uint16_t pc = m_PC.w.l; m_PC.w.l = ADD12(m_PC.w.l,1); - return m_direct->read_byte(pc); + return m_cache->read_byte(pc); } uint8_t scmp_device::RM(uint32_t a) @@ -502,7 +502,7 @@ void scmp_device::device_start() } m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); /* resolve callbacks */ m_flag_out_func.resolve_safe(); diff --git a/src/devices/cpu/scmp/scmp.h b/src/devices/cpu/scmp/scmp.h index 51d897b073d..9a3a6f2fece 100644 --- a/src/devices/cpu/scmp/scmp.h +++ b/src/devices/cpu/scmp/scmp.h @@ -68,7 +68,7 @@ private: uint8_t m_SR; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; devcb_write8 m_flag_out_func; diff --git a/src/devices/cpu/score/score.cpp b/src/devices/cpu/score/score.cpp index a12ee32185b..3a3b1ce6b15 100644 --- a/src/devices/cpu/score/score.cpp +++ b/src/devices/cpu/score/score.cpp @@ -73,7 +73,7 @@ void score7_cpu_device::device_start() { // find address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); // set our instruction counter set_icountptr(m_icount); @@ -283,7 +283,7 @@ int32_t score7_cpu_device::sign_extend(uint32_t data, uint8_t len) uint32_t score7_cpu_device::fetch() { - return m_direct->read_dword(m_pc & ~3); + return m_cache->read_dword(m_pc & ~3); } uint8_t score7_cpu_device::read_byte(offs_t offset) diff --git a/src/devices/cpu/score/score.h b/src/devices/cpu/score/score.h index a258d3e6420..1cc791d3402 100644 --- a/src/devices/cpu/score/score.h +++ b/src/devices/cpu/score/score.h @@ -108,7 +108,7 @@ private: address_space_config m_program_config; address_space * m_program; - direct_read_data<0> * m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; // internal state int m_icount; diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp index d0823d3f7af..787649174c5 100644 --- a/src/devices/cpu/se3208/se3208.cpp +++ b/src/devices/cpu/se3208/se3208.cpp @@ -51,7 +51,7 @@ DEFINE_DEVICE_TYPE(SE3208, se3208_device, "se3208", "ADChips SE3208") se3208_device::se3208_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, SE3208, tag, owner, clock) , m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0) - , m_PC(0), m_SR(0), m_SP(0), m_ER(0), m_PPC(0), m_program(nullptr), m_direct(nullptr), m_IRQ(0), m_NMI(0), m_icount(0) + , m_PC(0), m_SR(0), m_SP(0), m_ER(0), m_PPC(0), m_program(nullptr), m_cache(nullptr), m_IRQ(0), m_NMI(0), m_icount(0) { } device_memory_interface::space_config_vector se3208_device::memory_space_config() const @@ -1721,7 +1721,7 @@ void se3208_device::device_reset() m_ER = 0; m_PPC = 0; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); m_PC=SE3208_Read32(0); m_SR=0; m_IRQ=CLEAR_LINE; @@ -1760,7 +1760,7 @@ void se3208_device::execute_run() { do { - uint16_t Opcode=m_direct->read_word(m_PC, WORD_XOR_LE(0)); + uint16_t Opcode=m_cache->read_word(m_PC, WORD_XOR_LE(0)); m_PPC = m_PC; debugger_instruction_hook(m_PC); @@ -1786,7 +1786,7 @@ void se3208_device::device_start() BuildTable(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); save_item(NAME(m_R)); save_item(NAME(m_PC)); diff --git a/src/devices/cpu/se3208/se3208.h b/src/devices/cpu/se3208/se3208.h index de65d3ae83d..b62470c987f 100644 --- a/src/devices/cpu/se3208/se3208.h +++ b/src/devices/cpu/se3208/se3208.h @@ -54,7 +54,7 @@ private: uint32_t m_PPC; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; uint8_t m_IRQ; uint8_t m_NMI; diff --git a/src/devices/cpu/sh/sh.cpp b/src/devices/cpu/sh/sh.cpp index 6bcb1a6fea7..03fecd135ac 100644 --- a/src/devices/cpu/sh/sh.cpp +++ b/src/devices/cpu/sh/sh.cpp @@ -2506,10 +2506,7 @@ void sh_common_execution::generate_checksum_block(drcuml_block &block, compiler_ { if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) { - void *base; - if (m_xor == 0) base = m_direct->read_ptr(seqhead->physpc, SH2_CODE_XOR(0)); - else if (m_xor == 1) base = m_direct->read_ptr(seqhead->physpc, SH34LE_CODE_XOR(0)); - else base = m_direct->read_ptr(seqhead->physpc, SH34BE_CODE_XOR(0)); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_WORD, SCALE_x2); // load i0,base,word UML_CMP(block, I0, seqhead->opptr.w[0]); // cmp i0,*opptr @@ -2521,19 +2518,14 @@ void sh_common_execution::generate_checksum_block(drcuml_block &block, compiler_ else { uint32_t sum = 0; - void *base; - if (m_xor == 0) base = m_direct->read_ptr(seqhead->physpc, SH2_CODE_XOR(0)); - else if (m_xor == 1) base = m_direct->read_ptr(seqhead->physpc, SH34LE_CODE_XOR(0)); - else base = m_direct->read_ptr(seqhead->physpc, SH34BE_CODE_XOR(0)); + const void *base = m_prptr(seqhead->physpc); UML_LOAD(block, I0, base, 0, SIZE_WORD, SCALE_x4); // load i0,base,word sum += seqhead->opptr.w[0]; for (curdesc = seqhead->next(); curdesc != seqlast->next(); curdesc = curdesc->next()) if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) { - if (m_xor == 0) base = m_direct->read_ptr(curdesc->physpc, SH2_CODE_XOR(0)); - else if (m_xor == 1) base = m_direct->read_ptr(curdesc->physpc, SH34LE_CODE_XOR(0)); - else base = m_direct->read_ptr(curdesc->physpc, SH34BE_CODE_XOR(0)); + base = m_prptr(curdesc->physpc); UML_LOAD(block, I1, base, 0, SIZE_WORD, SCALE_x2); // load i1,*opptr,word UML_ADD(block, I0, I0, I1); // add i0,i0,i1 diff --git a/src/devices/cpu/sh/sh.h b/src/devices/cpu/sh/sh.h index f9b057c9361..145f56a734f 100644 --- a/src/devices/cpu/sh/sh.h +++ b/src/devices/cpu/sh/sh.h @@ -110,7 +110,6 @@ public: , m_interrupt(nullptr) , m_nocode(nullptr) , m_out_of_cycles(nullptr) - , m_xor(0) { } // Data that needs to be stored close to the generated DRC code @@ -373,7 +372,8 @@ public: void sh2drc_add_fastram(offs_t start, offs_t end, uint8_t readonly, void *base); - direct_read_data<0> *m_direct; + std::function<u16 (offs_t)> m_pr16; + std::function<const void * (offs_t)> m_prptr; address_space *m_program; std::unique_ptr<drcuml_state> m_drcuml; /* DRC UML generator state */ @@ -438,7 +438,6 @@ public: int m_cpu_type; uint32_t m_am; bool m_isdrc; - int m_xor; void sh2drc_set_options(uint32_t options); void sh2drc_add_pcflush(offs_t address); diff --git a/src/devices/cpu/sh/sh2.cpp b/src/devices/cpu/sh/sh2.cpp index 38f2998841d..497048b4ace 100644 --- a/src/devices/cpu/sh/sh2.cpp +++ b/src/devices/cpu/sh/sh2.cpp @@ -448,7 +448,23 @@ void sh2_device::device_start() m_ftcsr_read_cb.bind_relative_to(*owner()); m_decrypted_program = has_space(AS_OPCODES) ? &space(AS_OPCODES) : &space(AS_PROGRAM); - m_direct = m_decrypted_program->direct<0>(); + auto cache = m_decrypted_program->cache<2, 0, ENDIANNESS_BIG>(); + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + if (m_decrypted_program->endianness() != ENDIANNESS_NATIVE) + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~3)); + if(!(address & 2)) + ptr++; + return ptr; + }; + else + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~3)); + if(address & 2) + ptr++; + return ptr; + }; + m_internal = &space(AS_PROGRAM); save_item(NAME(m_cpu_off)); diff --git a/src/devices/cpu/sh/sh4.cpp b/src/devices/cpu/sh/sh4.cpp index 32714989808..75eef42871a 100644 --- a/src/devices/cpu/sh/sh4.cpp +++ b/src/devices/cpu/sh/sh4.cpp @@ -119,28 +119,24 @@ sh4_base_device::sh4_base_device(const machine_config &mconfig, device_type type sh3_device::sh3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sh3_base_device(mconfig, SH3LE, tag, owner, clock, ENDIANNESS_LITTLE) { - m_xor = 1; } sh3be_device::sh3be_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sh3_base_device(mconfig, SH3BE, tag, owner, clock, ENDIANNESS_BIG) { - m_xor = 2; } sh4_device::sh4_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sh4_base_device(mconfig, SH4LE, tag, owner, clock, ENDIANNESS_LITTLE) { - m_xor = 1; } sh4be_device::sh4be_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sh4_base_device(mconfig, SH4BE, tag, owner, clock, ENDIANNESS_BIG) { - m_xor = 2; } @@ -1887,7 +1883,7 @@ void sh34_base_device::execute_run() uint16_t opcode; - if (!m_sh4_mmu_enabled) opcode = m_direct->read_word(m_sh2_state->pc & SH34_AM, WORD2_XOR_LE(0)); + if (!m_sh4_mmu_enabled) opcode = m_pr16(m_sh2_state->pc & SH34_AM); else opcode = RW(m_sh2_state->pc); // should probably use a different function as this needs to go through the ITLB if (m_sh2_state->m_delay) @@ -1928,7 +1924,7 @@ void sh3be_device::execute_run() m_sh2_state->m_ppc = m_sh2_state->pc & SH34_AM; debugger_instruction_hook(m_sh2_state->pc & SH34_AM); - const uint16_t opcode = m_direct->read_word(m_sh2_state->pc & SH34_AM, WORD_XOR_LE(6)); + const uint16_t opcode = m_pr16(m_sh2_state->pc & SH34_AM); if (m_sh2_state->m_delay) { @@ -1968,7 +1964,7 @@ void sh4be_device::execute_run() m_sh2_state->m_ppc = m_sh2_state->pc & SH34_AM; debugger_instruction_hook(m_sh2_state->pc & SH34_AM); - const uint16_t opcode = m_direct->read_word(m_sh2_state->pc & SH34_AM, WORD_XOR_LE(6)); + const uint16_t opcode = m_pr16(m_sh2_state->pc & SH34_AM); if (m_sh2_state->m_delay) { @@ -2059,7 +2055,41 @@ void sh34_base_device::device_start() m_internal = &space(AS_PROGRAM); m_program = &space(AS_PROGRAM); m_io = &space(AS_IO); - m_direct = m_program->direct<0>(); + if (m_program->endianness() == ENDIANNESS_LITTLE) + { + auto cache = m_program->cache<3, 0, ENDIANNESS_LITTLE>(); + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~7)); + ptr += (~address >> 1) & 3; + return ptr; + }; + else + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~7)); + ptr += (address >> 1) & 3; + return ptr; + }; + } + else + { + auto cache = m_program->cache<3, 0, ENDIANNESS_BIG>(); + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word(address); }; + if (ENDIANNESS_NATIVE != ENDIANNESS_BIG) + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~7)); + ptr += (~address >> 1) & 3; + return ptr; + }; + else + m_prptr = [cache](offs_t address) -> const void * { + const u16 *ptr = static_cast<u16 *>(cache->read_ptr(address & ~7)); + ptr += (address >> 1) & 3; + return ptr; + }; + } + sh4_default_exception_priorities(); m_irln = 15; m_sh2_state->m_test_irq = 0; diff --git a/src/devices/cpu/sh/sh4fe.cpp b/src/devices/cpu/sh/sh4fe.cpp index ca122cd4eb4..0f88f98b9ae 100644 --- a/src/devices/cpu/sh/sh4fe.cpp +++ b/src/devices/cpu/sh/sh4fe.cpp @@ -26,17 +26,17 @@ sh4_frontend::sh4_frontend(sh_common_execution *device, uint32_t window_start, u uint16_t sh4_frontend::read_word(opcode_desc &desc) { if (desc.physpc >= 0xe0000000) - return m_sh->m_direct->read_word(desc.physpc, SH34LE_CODE_XOR(0)); + return m_sh->m_pr16(desc.physpc); - return m_sh->m_direct->read_word(desc.physpc & SH34_AM, SH34LE_CODE_XOR(0)); + return m_sh->m_pr16(desc.physpc & SH34_AM); } uint16_t sh4be_frontend::read_word(opcode_desc &desc) { if (desc.physpc >= 0xe0000000) - return m_sh->m_direct->read_word(desc.physpc, SH34BE_CODE_XOR(0)); + return m_sh->m_pr16(desc.physpc); - return m_sh->m_direct->read_word(desc.physpc & SH34_AM, SH34BE_CODE_XOR(0)); + return m_sh->m_pr16(desc.physpc & SH34_AM); } diff --git a/src/devices/cpu/sh/sh_fe.cpp b/src/devices/cpu/sh/sh_fe.cpp index 1abede64dc4..efee8bf506f 100644 --- a/src/devices/cpu/sh/sh_fe.cpp +++ b/src/devices/cpu/sh/sh_fe.cpp @@ -31,7 +31,7 @@ sh_frontend::sh_frontend(sh_common_execution *device, uint32_t window_start, uin inline uint16_t sh_frontend::read_word(opcode_desc &desc) { - return m_sh->m_direct->read_word(desc.physpc, SH2_CODE_XOR(0)); + return m_sh->m_pr16(desc.physpc); } bool sh_frontend::describe(opcode_desc &desc, const opcode_desc *prev) diff --git a/src/devices/cpu/ssp1601/ssp1601.cpp b/src/devices/cpu/ssp1601/ssp1601.cpp index 43bb84a8ffe..8f449d6d6a9 100644 --- a/src/devices/cpu/ssp1601/ssp1601.cpp +++ b/src/devices/cpu/ssp1601/ssp1601.cpp @@ -45,7 +45,7 @@ #define PPC m_ppc.w.h -#define FETCH() m_direct->read_word(rPC++) +#define FETCH() m_cache->read_word(rPC++) #define PROGRAM_WORD(a) m_program->read_word(a) #define GET_PPC_OFFS() PPC @@ -522,7 +522,7 @@ void ssp1601_device::device_start() m_gr[0].w.h = 0xffff; // constant reg m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_BIG>(); m_io = &space(AS_IO); state_add( SSP_R0, "REG0", m_gr[0].w.h).formatstr("%04X"); diff --git a/src/devices/cpu/ssp1601/ssp1601.h b/src/devices/cpu/ssp1601/ssp1601.h index cc7414991c3..dae9d3408bf 100644 --- a/src/devices/cpu/ssp1601/ssp1601.h +++ b/src/devices/cpu/ssp1601/ssp1601.h @@ -72,7 +72,7 @@ private: int m_g_cycles; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_BIG> *m_cache; address_space *m_io; void update_P(); diff --git a/src/devices/cpu/t11/t11.cpp b/src/devices/cpu/t11/t11.cpp index 80894f2cb73..a771b61b241 100644 --- a/src/devices/cpu/t11/t11.cpp +++ b/src/devices/cpu/t11/t11.cpp @@ -78,7 +78,7 @@ device_memory_interface::space_config_vector t11_device::memory_space_config() c int t11_device::ROPCODE() { PC &= 0xfffe; - int val = m_direct->read_word(PC); + int val = m_cache->read_word(PC); PC += 2; return val; } @@ -261,7 +261,7 @@ void t11_device::device_start() m_initial_pc = initial_pc[c_initial_mode >> 13]; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); m_out_reset_func.resolve_safe(); save_item(NAME(m_ppc.w.l)); diff --git a/src/devices/cpu/t11/t11.h b/src/devices/cpu/t11/t11.h index 085032028c9..371f05780c7 100644 --- a/src/devices/cpu/t11/t11.h +++ b/src/devices/cpu/t11/t11.h @@ -80,7 +80,7 @@ protected: uint8_t m_irq_state; int m_icount; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<1, 0, ENDIANNESS_LITTLE> *m_cache; devcb_write_line m_out_reset_func; inline int ROPCODE(); diff --git a/src/devices/cpu/tms32010/tms32010.cpp b/src/devices/cpu/tms32010/tms32010.cpp index 88538b8e1ee..3476f7b6e4f 100644 --- a/src/devices/cpu/tms32010/tms32010.cpp +++ b/src/devices/cpu/tms32010/tms32010.cpp @@ -214,7 +214,7 @@ std::unique_ptr<util::disasm_interface> tms32010_device::create_disassembler() * used to greatly speed up emulation */ -#define TMS32010_RDOP(A) (m_direct->read_word(A)) +#define TMS32010_RDOP(A) (m_cache->read_word(A)) /**************************************************************************** @@ -223,7 +223,7 @@ std::unique_ptr<util::disasm_interface> tms32010_device::create_disassembler() * that use different encoding mechanisms for opcodes and opcode arguments */ -#define TMS32010_RDOP_ARG(A) (m_direct->read_word(A)) +#define TMS32010_RDOP_ARG(A) (m_cache->read_word(A)) /************************************************************************ @@ -836,7 +836,7 @@ void tms32010_device::device_start() save_item(NAME(m_addr_mask)); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/tms32010/tms32010.h b/src/devices/cpu/tms32010/tms32010.h index a9662ff75be..9185248dc27 100644 --- a/src/devices/cpu/tms32010/tms32010.h +++ b/src/devices/cpu/tms32010/tms32010.h @@ -109,7 +109,7 @@ private: int m_addr_mask; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/tms32025/tms32025.cpp b/src/devices/cpu/tms32025/tms32025.cpp index 59644505755..b9a64d90f07 100644 --- a/src/devices/cpu/tms32025/tms32025.cpp +++ b/src/devices/cpu/tms32025/tms32025.cpp @@ -639,8 +639,8 @@ void tms32025_device::addt() void tms32025_device::adlk() { m_oldacc.d = m_ACC.d; - if (SXM) m_ALU.d = (int16_t)m_direct->read_word(m_PC); - else m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + if (SXM) m_ALU.d = (int16_t)m_cache->read_word(m_PC); + else m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d += m_ALU.d; @@ -659,7 +659,7 @@ void tms32025_device::and_() void tms32025_device::andk() { m_oldacc.d = m_ACC.d; - m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d &= m_ALU.d; @@ -674,7 +674,7 @@ void tms32025_device::apac() } void tms32025_device::br() { - m_PC = m_direct->read_word(m_PC); + m_PC = m_cache->read_word(m_PC); MODIFY_AR_ARP(); } void tms32025_device::bacc() @@ -683,43 +683,43 @@ void tms32025_device::bacc() } void tms32025_device::banz() { - if (m_AR[ARP]) m_PC = m_direct->read_word(m_PC); + if (m_AR[ARP]) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bbnz() { - if (TC) m_PC = m_direct->read_word(m_PC); + if (TC) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bbz() { - if (TC == 0) m_PC = m_direct->read_word(m_PC); + if (TC == 0) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bc() { - if (CARRY) m_PC = m_direct->read_word(m_PC); + if (CARRY) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bgez() { - if ( (int32_t)(m_ACC.d) >= 0 ) m_PC = m_direct->read_word(m_PC); + if ( (int32_t)(m_ACC.d) >= 0 ) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bgz() { - if ( (int32_t)(m_ACC.d) > 0 ) m_PC = m_direct->read_word(m_PC); + if ( (int32_t)(m_ACC.d) > 0 ) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bioz() { - if (m_bio_in() != CLEAR_LINE) m_PC = m_direct->read_word(m_PC); + if (m_bio_in() != CLEAR_LINE) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } @@ -737,14 +737,14 @@ void tms32025_device::bitt() } void tms32025_device::blez() { - if ( (int32_t)(m_ACC.d) <= 0 ) m_PC = m_direct->read_word(m_PC); + if ( (int32_t)(m_ACC.d) <= 0 ) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::blkd() { /** Fix cycle timing **/ if (m_init_load_addr) { - m_PFC = m_direct->read_word(m_PC); + m_PFC = m_cache->read_word(m_PC); m_PC++; } m_ALU.d = m_data->read_word(m_PFC); @@ -755,29 +755,29 @@ void tms32025_device::blkd() void tms32025_device::blkp() { /** Fix cycle timing **/ if (m_init_load_addr) { - m_PFC = m_direct->read_word(m_PC); + m_PFC = m_cache->read_word(m_PC); m_PC++; } - m_ALU.d = m_direct->read_word(m_PFC); + m_ALU.d = m_cache->read_word(m_PFC); PUTDATA(m_ALU.d); m_PFC++; m_tms32025_dec_cycles += (2*CLK); } void tms32025_device::blz() { - if ( (int32_t)(m_ACC.d) < 0 ) m_PC = m_direct->read_word(m_PC); + if ( (int32_t)(m_ACC.d) < 0 ) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bnc() { - if (CARRY == 0) m_PC = m_direct->read_word(m_PC); + if (CARRY == 0) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bnv() { - if (OV == 0) m_PC = m_direct->read_word(m_PC); + if (OV == 0) m_PC = m_cache->read_word(m_PC); else { m_PC++ ; CLR0(OV_FLAG); @@ -786,14 +786,14 @@ void tms32025_device::bnv() } void tms32025_device::bnz() { - if (m_ACC.d != 0) m_PC = m_direct->read_word(m_PC); + if (m_ACC.d != 0) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } void tms32025_device::bv() { if (OV) { - m_PC = m_direct->read_word(m_PC); + m_PC = m_cache->read_word(m_PC); CLR0(OV_FLAG); } else m_PC++ ; @@ -801,7 +801,7 @@ void tms32025_device::bv() } void tms32025_device::bz() { - if (m_ACC.d == 0) m_PC = m_direct->read_word(m_PC); + if (m_ACC.d == 0) m_PC = m_cache->read_word(m_PC); else m_PC++ ; MODIFY_AR_ARP(); } @@ -814,7 +814,7 @@ void tms32025_device::call() { m_PC++ ; PUSH_STACK(m_PC); - m_PC = m_direct->read_word(m_PC - 1); + m_PC = m_cache->read_word(m_PC - 1); MODIFY_AR_ARP(); } void tms32025_device::cmpl() @@ -954,8 +954,8 @@ void tms32025_device::lact() } void tms32025_device::lalk() { - if (SXM) m_ALU.d = (int16_t)m_direct->read_word(m_PC); - else m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + if (SXM) m_ALU.d = (int16_t)m_cache->read_word(m_PC); + else m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d = m_ALU.d; @@ -992,7 +992,7 @@ void tms32025_device::lph() } void tms32025_device::lrlk() { - m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_AR[m_opcode.b.h & 7] = m_ALU.w.l; } @@ -1065,7 +1065,7 @@ void tms32025_device::mac() /** RAM blocks B0,B1,B2 may be important ! { /** Fix cycle timing **/ m_oldacc.d = m_ACC.d; if (m_init_load_addr) { - m_PFC = m_direct->read_word(m_PC); + m_PFC = m_cache->read_word(m_PC); m_PC++; } SHIFT_Preg_TO_ALU(); @@ -1074,7 +1074,7 @@ void tms32025_device::mac() /** RAM blocks B0,B1,B2 may be important ! CALCULATE_ADD_CARRY(); GETDATA(0, 0); m_Treg = m_ALU.w.l; - m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_direct->read_word(m_PFC) ); + m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_cache->read_word(m_PFC) ); m_PFC++; m_tms32025_dec_cycles += (2*CLK); } @@ -1082,7 +1082,7 @@ void tms32025_device::macd() /** RAM blocks B0,B1,B2 may be important ! { /** Fix cycle timing **/ m_oldacc.d = m_ACC.d; if (m_init_load_addr) { - m_PFC = m_direct->read_word(m_PC); + m_PFC = m_cache->read_word(m_PC); m_PC++; } SHIFT_Preg_TO_ALU(); @@ -1094,7 +1094,7 @@ void tms32025_device::macd() /** RAM blocks B0,B1,B2 may be important ! m_data->write_word(m_memaccess+1, m_ALU.w.l); } m_Treg = m_ALU.w.l; - m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_direct->read_word(m_PFC) ); + m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_cache->read_word(m_PFC) ); m_PFC++; m_tms32025_dec_cycles += (2*CLK); } @@ -1167,7 +1167,7 @@ void tms32025_device::or_() } void tms32025_device::ork() { - m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d |= (m_ALU.d); @@ -1286,8 +1286,8 @@ void tms32025_device::sar_ar7() { PUTDATA(m_AR[7]); } void tms32025_device::sblk() { m_oldacc.d = m_ACC.d; - if (SXM) m_ALU.d = (int16_t)m_direct->read_word(m_PC); - else m_ALU.d = (uint16_t)m_direct->read_word(m_PC); + if (SXM) m_ALU.d = (int16_t)m_cache->read_word(m_PC); + else m_ALU.d = (uint16_t)m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d -= m_ALU.d; @@ -1478,7 +1478,7 @@ void tms32025_device::tblr() if (m_init_load_addr) { m_PFC = m_ACC.w.l; } - m_ALU.w.l = m_direct->read_word(m_PFC); + m_ALU.w.l = m_cache->read_word(m_PFC); if ( (CNF0) && ( (uint16_t)(m_PFC) >= 0xff00 ) ) {} /** TMS32025 only */ else m_tms32025_dec_cycles += (1*CLK); PUTDATA(m_ALU.w.l); @@ -1507,7 +1507,7 @@ void tms32025_device::xor_() } void tms32025_device::xork() { - m_ALU.d = m_direct->read_word(m_PC); + m_ALU.d = m_cache->read_word(m_PC); m_PC++; m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d ^= m_ALU.d; @@ -1621,7 +1621,7 @@ const tms32025_device::tms32025_opcode tms32025_device::s_opcode_Dx_subset[8]= void tms32025_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_BIG>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); @@ -1969,7 +1969,7 @@ void tms32025_device::execute_run() debugger_instruction_hook(m_PC); - m_opcode.d = m_direct->read_word(m_PC); + m_opcode.d = m_cache->read_word(m_PC); m_PC++; if (m_opcode.b.h == 0xCE) /* Opcode 0xCExx has many sub-opcodes in its minor byte */ @@ -2003,7 +2003,7 @@ void tms32025_device::execute_run() debugger_instruction_hook(m_PC); - m_opcode.d = m_direct->read_word(m_PC); + m_opcode.d = m_cache->read_word(m_PC); m_PC++; m_tms32025_dec_cycles += (1*CLK); diff --git a/src/devices/cpu/tms32025/tms32025.h b/src/devices/cpu/tms32025/tms32025.h index 2bb7fdc4c0c..6a3354f5bbd 100644 --- a/src/devices/cpu/tms32025/tms32025.h +++ b/src/devices/cpu/tms32025/tms32025.h @@ -141,7 +141,7 @@ protected: optional_shared_ptr<uint16_t> m_b3; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_BIG> *m_cache; address_space *m_data; address_space *m_io; diff --git a/src/devices/cpu/tms32031/tms32031.cpp b/src/devices/cpu/tms32031/tms32031.cpp index 83677827bc7..bf4b39c7e42 100644 --- a/src/devices/cpu/tms32031/tms32031.cpp +++ b/src/devices/cpu/tms32031/tms32031.cpp @@ -290,7 +290,7 @@ tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type m_is_idling(false), m_icount(0), m_program(nullptr), - m_direct(nullptr), + m_cache(nullptr), m_mcbl_mode(false), m_xf0_cb(*this), m_xf1_cb(*this), @@ -362,7 +362,7 @@ inline uint32_t tms3203x_device::ROPCODE(offs_t pc) if (m_mcbl_mode && pc < 0x1000) return m_bootrom[pc]; - return m_direct->read_dword(pc); + return m_cache->read_dword(pc); } @@ -397,7 +397,7 @@ void tms3203x_device::device_start() { // find address spaces m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-2>(); + m_cache = m_program->cache<2, -2, ENDIANNESS_LITTLE>(); // resolve devcb handlers m_xf0_cb.resolve_safe(); @@ -745,7 +745,7 @@ void tms3203x_device::execute_set_input(int inputnum, int state) { // switch between microcomputer/boot loader and microprocessor modes m_mcbl_mode = (state == ASSERT_LINE); - m_direct->force_update(); + m_cache->force_update(); return; } diff --git a/src/devices/cpu/tms32031/tms32031.h b/src/devices/cpu/tms32031/tms32031.h index 3d919bb2c78..dc11f88d8dd 100644 --- a/src/devices/cpu/tms32031/tms32031.h +++ b/src/devices/cpu/tms32031/tms32031.h @@ -788,7 +788,7 @@ protected: uint32_t m_iotemp; address_space * m_program; - direct_read_data<-2> *m_direct; + memory_access_cache<2, -2, ENDIANNESS_LITTLE> *m_cache; uint32_t * m_bootrom; bool m_mcbl_mode; diff --git a/src/devices/cpu/tms32051/tms32051.cpp b/src/devices/cpu/tms32051/tms32051.cpp index a929937004b..de83a4a9ecd 100644 --- a/src/devices/cpu/tms32051/tms32051.cpp +++ b/src/devices/cpu/tms32051/tms32051.cpp @@ -130,7 +130,7 @@ std::unique_ptr<util::disasm_interface> tms32051_device::create_disassembler() #define CYCLES(x) (m_icount -= x) -#define ROPCODE() m_direct->read_word(m_pc++) +#define ROPCODE() m_cache->read_word(m_pc++) void tms32051_device::CHANGE_PC(uint16_t new_pc) { @@ -187,7 +187,7 @@ void tms32051_device::delay_slot(uint16_t startpc) void tms32051_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<-1>(); + m_cache = m_program->cache<1, -1, ENDIANNESS_LITTLE>(); m_data = &space(AS_DATA); m_io = &space(AS_IO); diff --git a/src/devices/cpu/tms32051/tms32051.h b/src/devices/cpu/tms32051/tms32051.h index f1aee2bff1e..49f1f041a55 100644 --- a/src/devices/cpu/tms32051/tms32051.h +++ b/src/devices/cpu/tms32051/tms32051.h @@ -161,7 +161,7 @@ protected: } m_shadow; address_space *m_program; - direct_read_data<-1> *m_direct; + memory_access_cache<1, -1, ENDIANNESS_LITTLE> *m_cache; address_space *m_data; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/tms32082/tms32082.cpp b/src/devices/cpu/tms32082/tms32082.cpp index 78b9257ab21..eec9c19c4b3 100644 --- a/src/devices/cpu/tms32082/tms32082.cpp +++ b/src/devices/cpu/tms32082/tms32082.cpp @@ -222,7 +222,7 @@ void tms32082_mp_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).noshow(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); set_icountptr(m_icount); } @@ -439,7 +439,7 @@ void tms32082_mp_device::execute_set_input(int inputnum, int state) uint32_t tms32082_mp_device::fetch() { - uint32_t w = m_direct->read_dword(m_fetchpc); + uint32_t w = m_cache->read_dword(m_fetchpc); m_fetchpc += 4; return w; } @@ -521,7 +521,7 @@ void tms32082_pp_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).noshow(); m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_BIG>(); set_icountptr(m_icount); } diff --git a/src/devices/cpu/tms32082/tms32082.h b/src/devices/cpu/tms32082/tms32082.h index c4d7a32963c..d281ac0eb78 100644 --- a/src/devices/cpu/tms32082/tms32082.h +++ b/src/devices/cpu/tms32082/tms32082.h @@ -131,7 +131,7 @@ protected: int m_icount; address_space *m_program; - direct_read_data<0> * m_direct; + memory_access_cache<2, 0, ENDIANNESS_BIG> * m_cache; write32_delegate m_cmd_callback; @@ -191,7 +191,7 @@ protected: int m_icount; address_space *m_program; - direct_read_data<0> * m_direct; + memory_access_cache<2, 0, ENDIANNESS_BIG> * m_cache; }; diff --git a/src/devices/cpu/tms34010/34010ops.hxx b/src/devices/cpu/tms34010/34010ops.hxx index 85a1b932747..85cab6d13f2 100644 --- a/src/devices/cpu/tms34010/34010ops.hxx +++ b/src/devices/cpu/tms34010/34010ops.hxx @@ -80,13 +80,13 @@ void tms340x0_device::unimpl(uint16_t op) { /* kludge for Super High Impact -- this doesn't seem to cause */ /* an illegal opcode exception */ - if (m_direct->read_word(m_pc - 0x10) == 0x0007) + if (m_cache->read_word(m_pc - 0x10) == 0x0007) return; /* 9 Ball Shootout calls to FFDF7468, expecting it */ /* to execute the next instruction from FFDF7470 */ /* but the instruction at FFDF7460 is an 0x0001 */ - if (m_direct->read_word(m_pc - 0x10) == 0x0001) + if (m_cache->read_word(m_pc - 0x10) == 0x0001) return; PUSH(m_pc); @@ -96,7 +96,7 @@ void tms340x0_device::unimpl(uint16_t op) COUNT_UNKNOWN_CYCLES(16); /* extra check to prevent bad things */ - if (m_pc == 0 || s_opcode_table[m_direct->read_word(m_pc) >> 4] == &tms34010_device::unimpl) + if (m_pc == 0 || s_opcode_table[m_cache->read_word(m_pc) >> 4] == &tms34010_device::unimpl) { set_input_line(INPUT_LINE_HALT, ASSERT_LINE); machine().debug_break(); diff --git a/src/devices/cpu/tms34010/tms34010.cpp b/src/devices/cpu/tms34010/tms34010.cpp index 1d9dd640cd0..3851b16dd37 100644 --- a/src/devices/cpu/tms34010/tms34010.cpp +++ b/src/devices/cpu/tms34010/tms34010.cpp @@ -39,7 +39,7 @@ tms340x0_device::tms340x0_device(const machine_config &mconfig, device_type type : cpu_device(mconfig, type, tag, owner, clock) , device_video_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_LITTLE, 16, 32, 3), m_pc(0), m_ppc(0), m_st(0), m_pixel_write(nullptr), m_pixel_read(nullptr), m_raster_op(nullptr), m_pixel_op(nullptr), m_pixel_op_timing(0), m_convsp(0), m_convdp(0), m_convmp(0), m_gfxcycles(0), m_pixelshift(0), m_is_34020(0), m_reset_deferred(false) - , m_halt_on_reset(false), m_hblank_stable(0), m_external_host_access(0), m_executing(0), m_program(nullptr), m_direct(nullptr) + , m_halt_on_reset(false), m_hblank_stable(0), m_external_host_access(0), m_executing(0), m_program(nullptr), m_cache(nullptr) , m_pixclock(0) , m_pixperclock(0), m_scantimer(nullptr), m_icount(0) , m_output_int_cb(*this) @@ -182,32 +182,32 @@ inline uint32_t tms340x0_device::ROPCODE() { uint32_t pc = m_pc; m_pc += 2 << 3; - return m_direct->read_word(pc); + return m_cache->read_word(pc); } inline int16_t tms340x0_device::PARAM_WORD() { uint32_t pc = m_pc; m_pc += 2 << 3; - return m_direct->read_word(pc); + return m_cache->read_word(pc); } inline int32_t tms340x0_device::PARAM_LONG() { uint32_t pc = m_pc; m_pc += 4 << 3; - return (uint16_t)m_direct->read_word(pc) | (m_direct->read_word(pc + 16) << 16); + return (uint16_t)m_cache->read_word(pc) | (m_cache->read_word(pc + 16) << 16); } inline int16_t tms340x0_device::PARAM_WORD_NO_INC() { - return m_direct->read_word(m_pc); + return m_cache->read_word(m_pc); } inline int32_t tms340x0_device::PARAM_LONG_NO_INC() { uint32_t pc = m_pc; - return (uint16_t)m_direct->read_word(pc) | (m_direct->read_word(pc + 16) << 16); + return (uint16_t)m_cache->read_word(pc) | (m_cache->read_word(pc + 16) << 16); } /* read memory byte */ @@ -588,7 +588,7 @@ void tms340x0_device::device_start() m_external_host_access = false; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<03>(); + m_cache = m_program->cache<1, 3, ENDIANNESS_LITTLE>(); /* set up the state table */ { diff --git a/src/devices/cpu/tms34010/tms34010.h b/src/devices/cpu/tms34010/tms34010.h index da4993cd92b..27176ceb54e 100644 --- a/src/devices/cpu/tms34010/tms34010.h +++ b/src/devices/cpu/tms34010/tms34010.h @@ -324,7 +324,7 @@ protected: uint8_t m_external_host_access; uint8_t m_executing; address_space *m_program; - direct_read_data<3> *m_direct; + memory_access_cache<1, 3, ENDIANNESS_LITTLE> *m_cache; uint32_t m_pixclock; /* the pixel clock (0 means don't adjust screen size) */ int m_pixperclock; /* pixels per clock */ emu_timer *m_scantimer; diff --git a/src/devices/cpu/tms7000/tms7000.cpp b/src/devices/cpu/tms7000/tms7000.cpp index be619f1083b..3d22d7654f7 100644 --- a/src/devices/cpu/tms7000/tms7000.cpp +++ b/src/devices/cpu/tms7000/tms7000.cpp @@ -196,7 +196,7 @@ void tms7000_device::device_start() { // init/zerofill m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); set_icountptr(m_icount); @@ -632,7 +632,7 @@ void tms7000_device::execute_run() { debugger_instruction_hook(m_pc); - m_op = m_direct->read_byte(m_pc++); + m_op = m_cache->read_byte(m_pc++); execute_one(m_op); } while (m_icount > 0); } diff --git a/src/devices/cpu/tms7000/tms7000.h b/src/devices/cpu/tms7000/tms7000.h index 17a065ac4d0..125a43d5dec 100644 --- a/src/devices/cpu/tms7000/tms7000.h +++ b/src/devices/cpu/tms7000/tms7000.h @@ -125,7 +125,7 @@ protected: uint32_t m_info_flags; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; int m_icount; bool m_irq_state[2]; @@ -172,8 +172,8 @@ protected: inline uint16_t read_mem16(uint16_t address) { return m_program->read_byte(address) << 8 | m_program->read_byte((address + 1) & 0xffff); } inline void write_mem16(uint16_t address, uint16_t data) { m_program->write_byte(address, data >> 8 & 0xff); m_program->write_byte((address + 1) & 0xffff, data & 0xff); } - inline uint8_t imm8() { return m_direct->read_byte(m_pc++); } - inline uint16_t imm16() { uint16_t ret = m_direct->read_byte(m_pc++) << 8; return ret | m_direct->read_byte(m_pc++); } + inline uint8_t imm8() { return m_cache->read_byte(m_pc++); } + inline uint16_t imm16() { uint16_t ret = m_cache->read_byte(m_pc++) << 8; return ret | m_cache->read_byte(m_pc++); } inline uint8_t pull8() { return m_program->read_byte(m_sp--); } inline void push8(uint8_t data) { m_program->write_byte(++m_sp, data); } diff --git a/src/devices/cpu/upd7725/upd7725.cpp b/src/devices/cpu/upd7725/upd7725.cpp index 7103453dd66..c0e00ab1341 100644 --- a/src/devices/cpu/upd7725/upd7725.cpp +++ b/src/devices/cpu/upd7725/upd7725.cpp @@ -33,7 +33,7 @@ necdsp_device::necdsp_device(const machine_config &mconfig, device_type type, co m_irq_firing(0), m_program(nullptr), m_data(nullptr), - m_direct(nullptr), + m_cache(nullptr), m_in_int_cb(*this), //m_in_si_cb(*this), //m_in_sck_cb(*this), @@ -68,7 +68,7 @@ void necdsp_device::device_start() // get our address spaces m_program = &space(AS_PROGRAM); m_data = &space(AS_DATA); - m_direct = m_program->direct<-2>(); + m_cache = m_program->cache<2, -2, ENDIANNESS_BIG>(); // register our state for the debugger state_add(STATE_GENPC, "GENPC", regs.pc).noshow(); @@ -340,7 +340,7 @@ void necdsp_device::execute_run() if (m_irq_firing == 0) // normal opcode { - opcode = m_direct->read_dword(regs.pc) >> 8; + opcode = m_cache->read_dword(regs.pc) >> 8; regs.pc++; } else if (m_irq_firing == 1) // if we're in an interrupt cycle, execute a op 'nop' first... diff --git a/src/devices/cpu/upd7725/upd7725.h b/src/devices/cpu/upd7725/upd7725.h index e98256f2789..93d5019245b 100644 --- a/src/devices/cpu/upd7725/upd7725.h +++ b/src/devices/cpu/upd7725/upd7725.h @@ -189,7 +189,7 @@ private: // 2 = next opcode is the second half of int firing 'CALL 0100' int m_irq_firing; address_space *m_program, *m_data; - direct_read_data<-2> *m_direct; + memory_access_cache<2, -2, ENDIANNESS_BIG> *m_cache; protected: // device callbacks diff --git a/src/devices/cpu/upd7810/upd7810.cpp b/src/devices/cpu/upd7810/upd7810.cpp index 5a6aa265458..158eab94fc8 100644 --- a/src/devices/cpu/upd7810/upd7810.cpp +++ b/src/devices/cpu/upd7810/upd7810.cpp @@ -1571,7 +1571,7 @@ void upd78c05_device::handle_timers(int cycles) void upd7810_device::base_device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_to_func.resolve_safe(); m_co0_func.resolve_safe(); diff --git a/src/devices/cpu/upd7810/upd7810.h b/src/devices/cpu/upd7810/upd7810.h index 9eb27540bec..bde0a6c6a7f 100644 --- a/src/devices/cpu/upd7810/upd7810.h +++ b/src/devices/cpu/upd7810/upd7810.h @@ -414,7 +414,7 @@ protected: const struct opcode_s *m_op70; const struct opcode_s *m_op74; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; int m_icount; uint8_t RP(offs_t port); diff --git a/src/devices/cpu/upd7810/upd7810_macros.h b/src/devices/cpu/upd7810/upd7810_macros.h index 7db095a74e1..8331bf69432 100644 --- a/src/devices/cpu/upd7810/upd7810_macros.h +++ b/src/devices/cpu/upd7810/upd7810_macros.h @@ -104,8 +104,8 @@ // MEMORY/OPCODE READ/WRITE //************************************************************************** -#define RDOP(O) O = m_direct->read_byte(PCD); PC++ -#define RDOPARG(A) A = m_direct->read_byte(PCD); PC++ +#define RDOP(O) O = m_cache->read_byte(PCD); PC++ +#define RDOPARG(A) A = m_cache->read_byte(PCD); PC++ #define RM(A) m_program->read_byte(A) #define WM(A,V) m_program->write_byte(A,V) diff --git a/src/devices/cpu/v30mz/v30mz.cpp b/src/devices/cpu/v30mz/v30mz.cpp index 0ea963f297f..7c0e767da75 100644 --- a/src/devices/cpu/v30mz/v30mz.cpp +++ b/src/devices/cpu/v30mz/v30mz.cpp @@ -147,7 +147,7 @@ device_memory_interface::space_config_vector v30mz_cpu_device::memory_space_conf void v30mz_cpu_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); save_item(NAME(m_regs.w)); @@ -319,7 +319,7 @@ inline void v30mz_cpu_device::write_port(uint16_t port, uint8_t data) inline uint8_t v30mz_cpu_device::fetch_op() { - uint8_t data = m_direct->read_byte( pc() ); + uint8_t data = m_cache->read_byte( pc() ); m_ip++; return data; } @@ -327,7 +327,7 @@ inline uint8_t v30mz_cpu_device::fetch_op() inline uint8_t v30mz_cpu_device::fetch() { - uint8_t data = m_direct->read_byte( pc() ); + uint8_t data = m_cache->read_byte( pc() ); m_ip++; return data; } diff --git a/src/devices/cpu/v30mz/v30mz.h b/src/devices/cpu/v30mz/v30mz.h index 14db6b4d2fb..90eddd0f842 100644 --- a/src/devices/cpu/v30mz/v30mz.h +++ b/src/devices/cpu/v30mz/v30mz.h @@ -187,7 +187,7 @@ protected: uint8_t m_fire_trap; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_io; int m_icount; diff --git a/src/devices/cpu/v60/v60.cpp b/src/devices/cpu/v60/v60.cpp index 187e12a065f..0952d1fb189 100644 --- a/src/devices/cpu/v60/v60.cpp +++ b/src/devices/cpu/v60/v60.cpp @@ -123,19 +123,9 @@ std::unique_ptr<util::disasm_interface> v60_device::create_disassembler() // memory accessors -#if defined(LSB_FIRST) && !defined(ALIGN_INTS) -#define OpRead8(a) (m_direct->read_byte(a)) -#define OpRead16(a) (m_direct->read_word(a)) -#define OpRead32(a) (m_direct->read_dword(a)) -#else -#define OpRead8(a) (m_direct->read_byte((a), m_fetch_xor)) -#define OpRead16(a) ((m_direct->read_byte(((a)+0), m_fetch_xor) << 0) | \ - (m_direct->read_byte(((a)+1), m_fetch_xor) << 8)) -#define OpRead32(a) ((m_direct->read_byte(((a)+0), m_fetch_xor) << 0) | \ - (m_direct->read_byte(((a)+1), m_fetch_xor) << 8) | \ - (m_direct->read_byte(((a)+2), m_fetch_xor) << 16) | \ - (m_direct->read_byte(((a)+3), m_fetch_xor) << 24)) -#endif +#define OpRead8(a) m_pr8(a) +#define OpRead16(a) m_pr16(a) +#define OpRead32(a) m_pr32(a) // macros stolen from MAME for flags calc @@ -421,7 +411,21 @@ void v60_device::device_start() m_moddim = 0; m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + if (m_program->data_width() == 16) + { + auto cache = m_program->cache<1, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word_unaligned(address); }; + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword_unaligned(address); }; + } + else + { + auto cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); + m_pr8 = [cache](offs_t address) -> u8 { return cache->read_byte(address); }; + m_pr16 = [cache](offs_t address) -> u16 { return cache->read_word_unaligned(address); }; + m_pr32 = [cache](offs_t address) -> u32 { return cache->read_dword_unaligned(address); }; + } + m_io = &space(AS_IO); save_item(NAME(m_fetch_xor)); diff --git a/src/devices/cpu/v60/v60.h b/src/devices/cpu/v60/v60.h index d43dceded65..a0c7ebe6e7e 100644 --- a/src/devices/cpu/v60/v60.h +++ b/src/devices/cpu/v60/v60.h @@ -162,7 +162,9 @@ private: uint8_t m_irq_line; uint8_t m_nmi_line; address_space *m_program; - direct_read_data<0> *m_direct; + std::function<u8 (offs_t)> m_pr8; + std::function<u16 (offs_t)> m_pr16; + std::function<u32 (offs_t)> m_pr32; address_space *m_io; uint32_t m_PPC; int m_icount; diff --git a/src/devices/cpu/v810/v810.cpp b/src/devices/cpu/v810/v810.cpp index 823b65626e0..19de0e7cfca 100644 --- a/src/devices/cpu/v810/v810.cpp +++ b/src/devices/cpu/v810/v810.cpp @@ -145,7 +145,7 @@ std::unique_ptr<util::disasm_interface> v810_device::create_disassembler() #define WIO_H(addr, val) (m_io->write_word(addr,val)) #define WIO_W(addr, val) (m_io->write_dword(addr,val)) -#define R_OP(addr) (m_direct->read_word(addr)) +#define R_OP(addr) (m_cache->read_word(addr)) #define GET1 (op&0x1f) #define GET2 ((op>>5)&0x1f) @@ -1256,7 +1256,7 @@ const v810_device::opcode_func v810_device::s_OpCodeTable[64] = void v810_device::device_start() { m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<2, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); m_irq_line = 0; diff --git a/src/devices/cpu/v810/v810.h b/src/devices/cpu/v810/v810.h index d248f26d1bd..cf43c6cf4d1 100644 --- a/src/devices/cpu/v810/v810.h +++ b/src/devices/cpu/v810/v810.h @@ -118,7 +118,7 @@ private: uint8_t m_irq_state; uint8_t m_nmi_line; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_io; uint32_t m_PPC; int m_icount; diff --git a/src/devices/cpu/z180/z180.cpp b/src/devices/cpu/z180/z180.cpp index 118b0371475..0102df56865 100644 --- a/src/devices/cpu/z180/z180.cpp +++ b/src/devices/cpu/z180/z180.cpp @@ -2016,9 +2016,9 @@ void z180_device::device_start() } m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); m_oprogram = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; - m_odirect = m_oprogram->direct<0>(); + m_ocache = m_oprogram->cache<0, 0, ENDIANNESS_LITTLE>(); m_iospace = &space(AS_IO); /* set up the state table */ diff --git a/src/devices/cpu/z180/z180.h b/src/devices/cpu/z180/z180.h index 7a902722b0c..fe8f05f8749 100644 --- a/src/devices/cpu/z180/z180.h +++ b/src/devices/cpu/z180/z180.h @@ -186,9 +186,9 @@ private: uint8_t m_dma0_cnt; /* dma0 counter / divide by 20 */ uint8_t m_dma1_cnt; /* dma1 counter / divide by 20 */ address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; address_space *m_oprogram; - direct_read_data<0> *m_odirect; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_ocache; address_space *m_iospace; uint8_t m_rtemp; uint32_t m_ioltemp; diff --git a/src/devices/cpu/z180/z180dd.hxx b/src/devices/cpu/z180/z180dd.hxx index bd2a9fc7137..0676af905ae 100644 --- a/src/devices/cpu/z180/z180dd.hxx +++ b/src/devices/cpu/z180/z180dd.hxx @@ -2,7 +2,7 @@ // copyright-holders:Juergen Buchmueller OP(illegal,1) { logerror("Z180 '%s' ill. opcode $%02x $%02x\n", - tag(), m_odirect->read_byte((_PCD-1)&0xffff), m_odirect->read_byte(_PCD)); + tag(), m_ocache->read_byte((_PCD-1)&0xffff), m_ocache->read_byte(_PCD)); } /********************************************************** diff --git a/src/devices/cpu/z180/z180ed.hxx b/src/devices/cpu/z180/z180ed.hxx index df123a07a23..68925107c1d 100644 --- a/src/devices/cpu/z180/z180ed.hxx +++ b/src/devices/cpu/z180/z180ed.hxx @@ -3,7 +3,7 @@ OP(illegal,2) { logerror("Z180 '%s' ill. opcode $ed $%02x\n", - tag(), m_odirect->read_byte((_PCD-1)&0xffff)); + tag(), m_ocache->read_byte((_PCD-1)&0xffff)); } /********************************************************** diff --git a/src/devices/cpu/z180/z180ops.h b/src/devices/cpu/z180/z180ops.h index 1c1fa8322f6..320a66a2994 100644 --- a/src/devices/cpu/z180/z180ops.h +++ b/src/devices/cpu/z180/z180ops.h @@ -117,7 +117,7 @@ uint8_t z180_device::ROP() offs_t addr = _PCD; _PC++; m_extra_cycles += IO_DCNTL >> 6; // memory wait states - return m_odirect->read_byte(MMU_REMAP_ADDR(addr)); + return m_ocache->read_byte(MMU_REMAP_ADDR(addr)); } /**************************************************************** @@ -131,7 +131,7 @@ uint8_t z180_device::ARG() offs_t addr = _PCD; _PC++; m_extra_cycles += IO_DCNTL >> 6; // memory wait states - return m_direct->read_byte(MMU_REMAP_ADDR(addr)); + return m_cache->read_byte(MMU_REMAP_ADDR(addr)); } uint32_t z180_device::ARG16() @@ -139,7 +139,7 @@ uint32_t z180_device::ARG16() offs_t addr = _PCD; _PC += 2; m_extra_cycles += (IO_DCNTL >> 6) * 2; // memory wait states - return m_direct->read_byte(MMU_REMAP_ADDR(addr)) | (m_direct->read_byte(MMU_REMAP_ADDR(addr+1)) << 8); + return m_cache->read_byte(MMU_REMAP_ADDR(addr)) | (m_cache->read_byte(MMU_REMAP_ADDR(addr+1)) << 8); } /*************************************************************** diff --git a/src/devices/cpu/z8/z8.cpp b/src/devices/cpu/z8/z8.cpp index 2d62447f013..3307ec04102 100644 --- a/src/devices/cpu/z8/z8.cpp +++ b/src/devices/cpu/z8/z8.cpp @@ -261,7 +261,7 @@ uint16_t z8_device::mask_external_address(uint16_t addr) uint8_t z8_device::fetch() { uint16_t real_pc = (m_pc < m_rom_size) ? m_pc : mask_external_address(m_pc); - uint8_t data = m_direct->read_byte(real_pc); + uint8_t data = m_cache->read_byte(real_pc); m_pc++; @@ -274,7 +274,7 @@ uint8_t z8_device::fetch_opcode() m_ppc = (m_pc < m_rom_size) ? m_pc : mask_external_address(m_pc); debugger_instruction_hook(m_ppc); - uint8_t data = m_direct->read_byte(m_ppc); + uint8_t data = m_cache->read_byte(m_ppc); m_pc++; @@ -780,7 +780,7 @@ void z8_device::device_start() /* find address spaces */ m_program = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<0, 0, ENDIANNESS_BIG>(); m_data = has_space(AS_DATA) ? &space(AS_DATA) : m_program; /* allocate timers */ @@ -839,8 +839,8 @@ void z8_device::take_interrupt(int irq) stack_push_byte(m_r[Z8_REGISTER_FLAGS]); // branch to the vector - m_pc = m_direct->read_byte(vector) << 8; - m_pc |= m_direct->read_byte(vector + 1); + m_pc = m_cache->read_byte(vector) << 8; + m_pc |= m_cache->read_byte(vector + 1); } void z8_device::process_interrupts() diff --git a/src/devices/cpu/z8/z8.h b/src/devices/cpu/z8/z8.h index afd403334ad..ff37f5f2edd 100644 --- a/src/devices/cpu/z8/z8.h +++ b/src/devices/cpu/z8/z8.h @@ -99,7 +99,7 @@ private: address_space_config m_data_config; address_space *m_program; - direct_read_data<0> *m_direct; + memory_access_cache<0, 0, ENDIANNESS_BIG> *m_cache; address_space *m_data; // callbacks diff --git a/src/devices/cpu/z8/z8ops.hxx b/src/devices/cpu/z8/z8ops.hxx index 6775298b98f..1cf49f81832 100644 --- a/src/devices/cpu/z8/z8ops.hxx +++ b/src/devices/cpu/z8/z8ops.hxx @@ -149,7 +149,7 @@ void z8_device::load_from_memory(address_space &space) uint8_t data; if (&space == m_program && address < m_rom_size) - data = m_direct->read_byte(address); + data = m_cache->read_byte(address); else data = space.read_byte(mask_external_address(address)); @@ -181,7 +181,7 @@ void z8_device::load_from_memory_autoinc(address_space &space) uint8_t data; if (&space == m_program && address < m_rom_size) - data = m_direct->read_byte(address); + data = m_cache->read_byte(address); else data = space.read_byte(mask_external_address(address)); register_write(real_dst, data); diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index f59a61847cd..3454f6773e3 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -479,7 +479,7 @@ inline uint8_t z80_device::rop() { unsigned pc = PCD; PC++; - uint8_t res = m_decrypted_opcodes_direct->read_byte(pc); + uint8_t res = m_opcodes_cache->read_byte(pc); m_icount -= 2; m_refresh_cb((m_i << 8) | (m_r2 & 0x80) | ((m_r-1) & 0x7f), 0x00, 0xff); m_icount += 2; @@ -496,14 +496,14 @@ inline uint8_t z80_device::arg() { unsigned pc = PCD; PC++; - return m_direct->read_byte(pc); + return m_cache->read_byte(pc); } inline uint16_t z80_device::arg16() { unsigned pc = PCD; PC += 2; - return m_direct->read_byte(pc) | (m_direct->read_byte((pc+1)&0xffff) << 8); + return m_cache->read_byte(pc) | (m_cache->read_byte((pc+1)&0xffff) << 8); } /*************************************************************** @@ -1955,7 +1955,7 @@ OP(xycb,ff) { A = set(7, rm(m_ea)); wm(m_ea, A); } /* SET 7,A=(XY+o) */ OP(illegal,1) { logerror("Z80 ill. opcode $%02x $%02x ($%04x)\n", - m_decrypted_opcodes_direct->read_byte((PCD-1)&0xffff), m_decrypted_opcodes_direct->read_byte(PCD), PCD-1); + m_opcodes_cache->read_byte((PCD-1)&0xffff), m_opcodes_cache->read_byte(PCD), PCD-1); } /********************************************************** @@ -2543,7 +2543,7 @@ OP(fd,ff) { illegal_1(); op_ff(); } /* DB FD OP(illegal,2) { logerror("Z80 ill. opcode $ed $%02x\n", - m_decrypted_opcodes_direct->read_byte((PCD-1)&0xffff)); + m_opcodes_cache->read_byte((PCD-1)&0xffff)); } /********************************************************** @@ -3406,9 +3406,9 @@ void z80_device::device_start() m_ea = 0; m_program = &space(AS_PROGRAM); - m_decrypted_opcodes = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; - m_direct = m_program->direct<0>(); - m_decrypted_opcodes_direct = m_decrypted_opcodes->direct<0>(); + m_opcodes = has_space(AS_OPCODES) ? &space(AS_OPCODES) : m_program; + m_cache = m_program->cache<0, 0, ENDIANNESS_LITTLE>(); + m_opcodes_cache = m_opcodes->cache<0, 0, ENDIANNESS_LITTLE>(); m_io = &space(AS_IO); IX = IY = 0xffff; /* IX and IY are FFFF after a reset! */ @@ -3702,7 +3702,7 @@ z80_device::z80_device(const machine_config &mconfig, device_type type, const ch cpu_device(mconfig, type, tag, owner, clock), z80_daisy_chain_interface(mconfig, *this), m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0), - m_decrypted_opcodes_config("decrypted_opcodes", ENDIANNESS_LITTLE, 8, 16, 0), + m_opcodes_config("opcodes", ENDIANNESS_LITTLE, 8, 16, 0), m_io_config("io", ENDIANNESS_LITTLE, 8, 16, 0), m_irqack_cb(*this), m_refresh_cb(*this), @@ -3715,7 +3715,7 @@ device_memory_interface::space_config_vector z80_device::memory_space_config() c if(has_configured_map(AS_OPCODES)) return space_config_vector { std::make_pair(AS_PROGRAM, &m_program_config), - std::make_pair(AS_OPCODES, &m_decrypted_opcodes_config), + std::make_pair(AS_OPCODES, &m_opcodes_config), std::make_pair(AS_IO, &m_io_config) }; else diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index 84943b528bc..b24e8244309 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -239,13 +239,13 @@ protected: // address spaces const address_space_config m_program_config; - const address_space_config m_decrypted_opcodes_config; + const address_space_config m_opcodes_config; const address_space_config m_io_config; address_space *m_program; - address_space *m_decrypted_opcodes; + address_space *m_opcodes; address_space *m_io; - direct_read_data<0> *m_direct; - direct_read_data<0> *m_decrypted_opcodes_direct; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_cache; + memory_access_cache<0, 0, ENDIANNESS_LITTLE> *m_opcodes_cache; devcb_write_line m_irqack_cb; devcb_write8 m_refresh_cb; devcb_write_line m_halt_cb; diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp index ae49854fb2f..756db749534 100644 --- a/src/devices/cpu/z8000/z8000.cpp +++ b/src/devices/cpu/z8000/z8000.cpp @@ -37,7 +37,7 @@ z8002_device::z8002_device(const machine_config &mconfig, device_type type, cons , m_program_config("program", ENDIANNESS_BIG, 16, addrbits, 0) , m_io_config("io", ENDIANNESS_BIG, iobits, 16, 0) , m_mo_out(*this) - , m_ppc(0), m_pc(0), m_psapseg(0), m_psapoff(0), m_fcw(0), m_refresh(0), m_nspseg(0), m_nspoff(0), m_irq_req(0), m_irq_vec(0), m_op_valid(0), m_nmi_state(0), m_mi(0), m_program(nullptr), m_data(nullptr), m_direct(nullptr), m_io(nullptr), m_icount(0) + , m_ppc(0), m_pc(0), m_psapseg(0), m_psapoff(0), m_fcw(0), m_refresh(0), m_nspseg(0), m_nspoff(0), m_irq_req(0), m_irq_vec(0), m_op_valid(0), m_nmi_state(0), m_mi(0), m_program(nullptr), m_data(nullptr), m_cache(nullptr), m_io(nullptr), m_icount(0) , m_vector_mult(vecmult) { } @@ -663,7 +663,7 @@ void z8001_device::device_start() m_data = &space(AS_DATA); else m_data = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<1, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); init_tables(); @@ -686,7 +686,7 @@ void z8002_device::device_start() m_data = &space(AS_DATA); else m_data = &space(AS_PROGRAM); - m_direct = m_program->direct<0>(); + m_cache = m_program->cache<1, 0, ENDIANNESS_BIG>(); m_io = &space(AS_IO); init_tables(); diff --git a/src/devices/cpu/z8000/z8000.h b/src/devices/cpu/z8000/z8000.h index 4ae13025828..46cd26200d1 100644 --- a/src/devices/cpu/z8000/z8000.h +++ b/src/devices/cpu/z8000/z8000.h @@ -96,7 +96,7 @@ protected: int m_mi; address_space *m_program; address_space *m_data; - direct_read_data<0> *m_direct; + memory_access_cache<1, 0, ENDIANNESS_BIG> *m_cache; address_space *m_io; int m_icount; int m_vector_mult; |