diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index b1a1f08a47a..bdfd4dbf826 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -39,7 +39,7 @@ const size_t debugger_commands::MAX_GLOBALS = 1000; bool debugger_commands::cheat_address_is_valid(address_space &space, offs_t address) { - return m_cpu.translate(space, TRANSLATE_READ, &address) && (space.get_write_ptr(address) != nullptr); + return space.device().memory().translate(space.spacenum(), TRANSLATE_READ, address) && (space.get_write_ptr(address) != nullptr); } @@ -1727,7 +1727,7 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) if (i + j <= endoffset) { offs_t curaddr = i + j; - if (m_cpu.translate(*space, TRANSLATE_READ_DEBUG, &curaddr)) + if (space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, curaddr)) { UINT64 value = m_cpu.read_memory(*space, i + j, width, TRUE); util::stream_format(output, " %0*X", width * 2, value); @@ -1748,7 +1748,7 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) for (UINT64 j = 0; j < 16 && (i + j) <= endoffset; j++) { offs_t curaddr = i + j; - if (m_cpu.translate(*space, TRANSLATE_READ_DEBUG, &curaddr)) + if (space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, curaddr)) { UINT8 byte = m_cpu.read_byte(*space, i + j, TRUE); util::stream_format(output, "%c", (byte >= 32 && byte < 127) ? byte : '.'); @@ -2379,7 +2379,7 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[]) /* make sure we can translate the address */ tempaddr = pcbyte; - if (m_cpu.translate(*space, TRANSLATE_FETCH_DEBUG, &tempaddr)) + if (space->device().memory().translate(space->spacenum(), TRANSLATE_FETCH_DEBUG, tempaddr)) { UINT8 opbuf[64], argbuf[64]; @@ -2766,7 +2766,7 @@ void debugger_commands::execute_map(int ref, int params, const char *param[]) { static const char *const intnames[] = { "Read", "Write", "Fetch" }; taddress = space->address_to_byte(address) & space->bytemask(); - if (m_cpu.translate(*space, intention, &taddress)) + if (space->device().memory().translate(space->spacenum(), intention, taddress)) { const char *mapname = space->get_handler_string((intention == TRANSLATE_WRITE_DEBUG) ? ROW_WRITE : ROW_READ, taddress); m_console.printf( diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index e76abd6fec6..d28a15bd79b 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -348,24 +348,6 @@ bool debugger_cpu::comment_load(bool is_inline) -/*************************************************************************** - MEMORY AND DISASSEMBLY HELPERS -***************************************************************************/ - -/*------------------------------------------------- - translate - return the physical address - corresponding to the given logical address --------------------------------------------------*/ - -bool debugger_cpu::translate(address_space &space, int intention, offs_t *address) -{ - device_memory_interface *memory; - if (space.device().interface(memory)) - return memory->translate(space.spacenum(), intention, *address); - return true; -} - - /*************************************************************************** DEBUGGER MEMORY ACCESSORS ***************************************************************************/ @@ -377,6 +359,8 @@ bool debugger_cpu::translate(address_space &space, int intention, offs_t *addres UINT8 debugger_cpu::read_byte(address_space &space, offs_t address, int apply_translation) { + device_memory_interface &memory = space.device().memory(); + /* mask against the logical byte mask */ address &= space.logbytemask(); @@ -387,11 +371,11 @@ UINT8 debugger_cpu::read_byte(address_space &space, offs_t address, int apply_tr /* translate if necessary; if not mapped, return 0xff */ UINT64 custom; UINT8 result; - if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { result = 0xff; } - else if (space.device().memory().read(space.spacenum(), address, 1, custom)) + else if (memory.read(space.spacenum(), address, 1, custom)) { /* if there is a custom read handler, and it returns true, use that value */ result = custom; } @@ -431,6 +415,7 @@ UINT16 debugger_cpu::read_word(address_space &space, offs_t address, int apply_t } else { /* otherwise, this proceeds like the byte case */ + device_memory_interface &memory = space.device().memory(); /* all accesses from this point on are for the debugger */ m_debugger_access = true; @@ -438,11 +423,11 @@ UINT16 debugger_cpu::read_word(address_space &space, offs_t address, int apply_t /* translate if necessary; if not mapped, return 0xffff */ UINT64 custom; - if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { result = 0xffff; } - else if (space.device().memory().read(space.spacenum(), address, 2, custom)) + else if (memory.read(space.spacenum(), address, 2, custom)) { /* if there is a custom read handler, and it returns true, use that value */ result = custom; } @@ -484,17 +469,18 @@ UINT32 debugger_cpu::read_dword(address_space &space, offs_t address, int apply_ } else { /* otherwise, this proceeds like the byte case */ + device_memory_interface &memory = space.device().memory(); /* all accesses from this point on are for the debugger */ m_debugger_access = true; space.set_debugger_access(true); UINT64 custom; - if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { /* translate if necessary; if not mapped, return 0xffffffff */ result = 0xffffffff; } - else if (space.device().memory().read(space.spacenum(), address, 4, custom)) + else if (memory.read(space.spacenum(), address, 4, custom)) { /* if there is a custom read handler, and it returns true, use that value */ result = custom; } @@ -536,6 +522,7 @@ UINT64 debugger_cpu::read_qword(address_space &space, offs_t address, int apply_ } else { /* otherwise, this proceeds like the byte case */ + device_memory_interface &memory = space.device().memory(); /* all accesses from this point on are for the debugger */ m_debugger_access = true; @@ -543,11 +530,11 @@ UINT64 debugger_cpu::read_qword(address_space &space, offs_t address, int apply_ /* translate if necessary; if not mapped, return 0xffffffffffffffff */ UINT64 custom; - if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { result = ~(UINT64)0; } - else if (space.device().memory().read(space.spacenum(), address, 8, custom)) + else if (memory.read(space.spacenum(), address, 8, custom)) { /* if there is a custom read handler, and it returns true, use that value */ result = custom; } @@ -591,6 +578,8 @@ UINT64 debugger_cpu::read_memory(address_space &space, offs_t address, int size, void debugger_cpu::write_byte(address_space &space, offs_t address, UINT8 data, int apply_translation) { + device_memory_interface &memory = space.device().memory(); + /* mask against the logical byte mask */ address &= space.logbytemask(); @@ -599,11 +588,11 @@ void debugger_cpu::write_byte(address_space &space, offs_t address, UINT8 data, space.set_debugger_access(true); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_WRITE_DEBUG, address)) ; /* if there is a custom write handler, and it returns true, use that */ - else if (space.device().memory().write(space.spacenum(), address, 1, data)) + else if (memory.write(space.spacenum(), address, 1, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -646,16 +635,18 @@ void debugger_cpu::write_word(address_space &space, offs_t address, UINT16 data, /* otherwise, this proceeds like the byte case */ else { + device_memory_interface &memory = space.device().memory(); + /* all accesses from this point on are for the debugger */ m_debugger_access = true; space.set_debugger_access(true); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_WRITE_DEBUG, address)) ; /* if there is a custom write handler, and it returns true, use that */ - else if (space.device().memory().write(space.spacenum(), address, 2, data)) + else if (memory.write(space.spacenum(), address, 2, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -699,15 +690,17 @@ void debugger_cpu::write_dword(address_space &space, offs_t address, UINT32 data /* otherwise, this proceeds like the byte case */ else { + device_memory_interface &memory = space.device().memory(); + /* all accesses from this point on are for the debugger */ space.set_debugger_access(m_debugger_access = true); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_WRITE_DEBUG, address)) ; /* if there is a custom write handler, and it returns true, use that */ - else if (space.device().memory().write(space.spacenum(), address, 4, data)) + else if (memory.write(space.spacenum(), address, 4, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -751,16 +744,18 @@ void debugger_cpu::write_qword(address_space &space, offs_t address, UINT64 data /* otherwise, this proceeds like the byte case */ else { + device_memory_interface &memory = space.device().memory(); + /* all accesses from this point on are for the debugger */ m_debugger_access = true; space.set_debugger_access(true); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_WRITE_DEBUG, address)) ; /* if there is a custom write handler, and it returns true, use that */ - else if (space.device().memory().write(space.spacenum(), address, 8, data)) + else if (memory.write(space.spacenum(), address, 8, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -800,6 +795,8 @@ void debugger_cpu::write_memory(address_space &space, offs_t address, UINT64 dat UINT64 debugger_cpu::read_opcode(address_space &space, offs_t address, int size) { + device_memory_interface &memory = space.device().memory(); + UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2; /* keep in logical range */ @@ -808,8 +805,7 @@ UINT64 debugger_cpu::read_opcode(address_space &space, offs_t address, int size) /* return early if we got the result directly */ m_debugger_access = true; space.set_debugger_access(true); - device_memory_interface *memory; - if (space.device().interface(memory) && memory->readop(address, size, result2)) + if (memory.readop(address, size, result2)) { m_debugger_access = false; space.set_debugger_access(false); @@ -830,7 +826,7 @@ UINT64 debugger_cpu::read_opcode(address_space &space, offs_t address, int size) } /* translate to physical first */ - if (!translate(space, TRANSLATE_FETCH_DEBUG, &address)) + if (!memory.translate(space.spacenum(), TRANSLATE_FETCH_DEBUG, address)) return result; /* keep in physical range */ diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index ffb390ea226..bc4ee3675cf 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -508,9 +508,6 @@ public: /* ----- debugger memory accessors ----- */ - /* return the physical address corresponding to the given logical address */ - bool translate(address_space &space, int intention, offs_t *address); - /* return a byte from the specified memory space */ UINT8 read_byte(address_space &space, offs_t address, int apply_translation); diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index bd8207e1138..e49010e2ef6 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -269,7 +269,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs) // get the disassembly, but only if mapped instlen = 1; - if (machine().debugger().cpu().translate(source.m_space, TRANSLATE_FETCH, &physpcbyte)) + if (source.m_space.device().memory().translate(source.m_space.spacenum(), TRANSLATE_FETCH, physpcbyte)) { char dasmbuffer[100]; instlen = source.m_disasmintf->disassemble(dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK; @@ -395,7 +395,7 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) char buffer[100]; int numbytes = 0; offs_t physpcbyte = pcbyte; - if (machine().debugger().cpu().translate(source.m_space, TRANSLATE_FETCH_DEBUG, &physpcbyte)) + if (source.m_space.device().memory().translate(source.m_space.spacenum(), TRANSLATE_FETCH_DEBUG, physpcbyte)) { UINT8 opbuf[64], argbuf[64]; diff --git a/src/mame/drivers/chihiro.cpp b/src/mame/drivers/chihiro.cpp index b4af01645a2..d23a545de6f 100644 --- a/src/mame/drivers/chihiro.cpp +++ b/src/mame/drivers/chihiro.cpp @@ -377,7 +377,6 @@ Thanks to Alex, Mr Mudkips, and Philip Burke for this info. #include "video/poly.h" #include "debug/debugcon.h" #include "debug/debugcmd.h" -#include "debug/debugcpu.h" #include "debugger.h" #include "includes/chihiro.h" #include "includes/xbox.h" @@ -506,7 +505,7 @@ St. Instr. Comment void chihiro_state::jamtable_disasm(address_space &space, UINT32 address, UINT32 size) // 0xff000080 == fff00080 { offs_t addr = (offs_t)address; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &addr)) + if (!space.device().memory().translate(space.spacenum(), TRANSLATE_READ_DEBUG, addr)) { machine().debugger().console().printf("Address is unmapped.\n"); return; diff --git a/src/mame/drivers/pc88va.cpp b/src/mame/drivers/pc88va.cpp index 37b2dc73f7e..e27944a5040 100644 --- a/src/mame/drivers/pc88va.cpp +++ b/src/mame/drivers/pc88va.cpp @@ -27,7 +27,6 @@ #include "emu.h" #include "cpu/nec/nec.h" #include "cpu/z80/z80.h" -#include "debug/debugcpu.h" #include "machine/i8255.h" #include "machine/pic8259.h" #include "machine/pit8253.h" diff --git a/src/mame/drivers/sun4.cpp b/src/mame/drivers/sun4.cpp index 95551566d5e..3550a84e173 100644 --- a/src/mame/drivers/sun4.cpp +++ b/src/mame/drivers/sun4.cpp @@ -406,7 +406,6 @@ #include "debug/debugcon.h" #include "debug/debugcmd.h" -#include "debug/debugcpu.h" #include "debugger.h" #define TIMEKEEPER_TAG "timekpr" diff --git a/src/mame/drivers/xbox.cpp b/src/mame/drivers/xbox.cpp index 375ecaf869b..1bd75dce3ca 100644 --- a/src/mame/drivers/xbox.cpp +++ b/src/mame/drivers/xbox.cpp @@ -21,7 +21,6 @@ #include "bitmap.h" #include "debug/debugcon.h" #include "debug/debugcmd.h" -#include "debug/debugcpu.h" #include "debugger.h" #include "includes/chihiro.h" #include "includes/xbox.h" diff --git a/src/mame/machine/macpci.cpp b/src/mame/machine/macpci.cpp index 705f686f056..a8f9f0e007f 100644 --- a/src/mame/machine/macpci.cpp +++ b/src/mame/machine/macpci.cpp @@ -16,7 +16,6 @@ #include "machine/applefdc.h" #include "machine/sonydriv.h" #include "includes/macpci.h" -#include "debug/debugcpu.h" #include "machine/ram.h" #include "debugger.h" diff --git a/src/mame/machine/xbox.cpp b/src/mame/machine/xbox.cpp index 13db44bea65..09dfa898575 100644 --- a/src/mame/machine/xbox.cpp +++ b/src/mame/machine/xbox.cpp @@ -14,7 +14,6 @@ #include "debugger.h" #include "debug/debugcon.h" #include "debug/debugcmd.h" -#include "debug/debugcpu.h" #include "includes/chihiro.h" #include "includes/xbox.h" #include "includes/xbox_usb.h" @@ -35,7 +34,7 @@ void xbox_base_state::dump_string_command(int ref, int params, const char **para return; offs_t address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -47,7 +46,7 @@ void xbox_base_state::dump_string_command(int ref, int params, const char **para machine().debugger().console().printf("Length %d word\n", length); machine().debugger().console().printf("MaximumLength %d word\n", maximumlength); machine().debugger().console().printf("Buffer %08X byte* ", buffer); - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &buffer)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, buffer)) { machine().debugger().console().printf("\nBuffer is unmapped.\n"); return; @@ -76,7 +75,7 @@ void xbox_base_state::dump_process_command(int ref, int params, const char **par return; offs_t address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -113,7 +112,7 @@ void xbox_base_state::dump_list_command(int ref, int params, const char **param) UINT64 start = addr; offs_t address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -137,7 +136,7 @@ void xbox_base_state::dump_list_command(int ref, int params, const char **param) if (addr == old) break; address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) break; } } @@ -154,7 +153,7 @@ void xbox_base_state::dump_dpc_command(int ref, int params, const char **param) return; offs_t address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -181,7 +180,7 @@ void xbox_base_state::dump_timer_command(int ref, int params, const char **param return; offs_t address = (offs_t)addr; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -204,7 +203,7 @@ void xbox_base_state::curthread_command(int ref, int params, const char **param) UINT64 fsbase = m_maincpu->state_int(44); offs_t address = (offs_t)fsbase + 0x28; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) { machine().debugger().console().printf("Address is unmapped.\n"); return; @@ -214,14 +213,14 @@ void xbox_base_state::curthread_command(int ref, int params, const char **param) machine().debugger().console().printf("Current thread is %08X\n", kthrd); address = (offs_t)kthrd + 0x1c; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) return; UINT32 topstack = space.read_dword_unaligned(address); machine().debugger().console().printf("Current thread stack top is %08X\n", topstack); address = (offs_t)kthrd + 0x28; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) return; UINT32 tlsdata = space.read_dword_unaligned(address); @@ -229,7 +228,7 @@ void xbox_base_state::curthread_command(int ref, int params, const char **param) address = (offs_t)topstack - 0x210 - 8; else address = (offs_t)tlsdata - 8; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address)) return; machine().debugger().console().printf("Current thread function is %08X\n", space.read_dword_unaligned(address)); } @@ -325,7 +324,7 @@ void xbox_base_state::vprogdis_command(int ref, int params, const char **param) if (type == 1) { offs_t addr = (offs_t)address; - if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &addr)) + if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, addr)) return; instruction[0] = space.read_dword_unaligned(address); instruction[1] = space.read_dword_unaligned(address + 4); diff --git a/src/mame/machine/xbox_usb.cpp b/src/mame/machine/xbox_usb.cpp index 38efc96c984..e9431c98459 100644 --- a/src/mame/machine/xbox_usb.cpp +++ b/src/mame/machine/xbox_usb.cpp @@ -11,10 +11,6 @@ #include "machine/idectrl.h" #include "video/poly.h" #include "bitmap.h" -#include "debugger.h" -#include "debug/debugcon.h" -#include "debug/debugcmd.h" -#include "debug/debugcpu.h" #include "includes/chihiro.h" #include "includes/xbox.h" #include "includes/xbox_usb.h" diff --git a/src/mame/video/rmnimbus.cpp b/src/mame/video/rmnimbus.cpp index 654e7f48b96..3b0a1aefc69 100644 --- a/src/mame/video/rmnimbus.cpp +++ b/src/mame/video/rmnimbus.cpp @@ -27,7 +27,6 @@ #include "emu.h" #include "debugger.h" -#include "debug/debugcpu.h" #include "debug/debugcon.h" #include "includes/rmnimbus.h"