CPU interface organization shuffle. The file cpuintrf.h now merely

describes the interface, but does not contain any implementation.
All remaining bits of implementation have been migrated either to
cpuexec.c or to debugcpu.c. Specifically, cpu_dasm() is now
debug_cpu_disassemble(), and cpu_set_dasm_override() is now
debug_cpu_set_dasm_override(). Also moved memory_address_physical()
to debug_cpu_translate(), since it was only ever used for
debugging.

Changed all CPU and sound cores to use memory_find_address_space()
instead of cpu_get_address_space(). The former is reliable even
during early initialization when the CPU cores generally need it.

Removed the dummy CPU core and cpuintrf.c.

Changed the core execution loop to directly call the execute
function instead of using the inline helper (which has been removed).
This commit is contained in:
Aaron Giles 2008-12-22 17:35:27 +00:00
parent b4c9d1fc87
commit a70fdf00a1
46 changed files with 324 additions and 506 deletions

1
.gitattributes vendored
View File

@ -488,7 +488,6 @@ src/emu/cpu/z8000/z8000ops.c svneol=native#text/plain
src/emu/cpu/z8000/z8000tbl.c svneol=native#text/plain
src/emu/cpuexec.c svneol=native#text/plain
src/emu/cpuexec.h svneol=native#text/plain
src/emu/cpuintrf.c svneol=native#text/plain
src/emu/cpuintrf.h svneol=native#text/plain
src/emu/crsshair.c svneol=native#text/plain
src/emu/crsshair.h svneol=native#text/plain

View File

@ -685,9 +685,9 @@ static adsp2100_state *adsp21xx_init(const device_config *device, cpu_irq_callba
/* fetch device parameters */
adsp->device = device;
adsp->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
adsp->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
adsp->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
adsp->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
adsp->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
adsp->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* copy function pointers from the config */
if (config != NULL)

View File

@ -81,7 +81,7 @@ static CPU_INIT( arm7 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
#if TEST_COPROC_FUNCS
// setup co-proc callbacks example

View File

@ -429,7 +429,7 @@ static CPU_INIT( asap )
asap->src2val[i] = i;
asap->irq_callback = irqcallback;
asap->device = device;
asap->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
asap->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
}
static CPU_RESET( asap )

View File

@ -893,8 +893,8 @@ static CPU_INIT( cdp1802 )
/* get address spaces */
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* set initial values */

View File

@ -184,9 +184,9 @@ static CPU_INIT( cop410 )
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */

View File

@ -186,9 +186,9 @@ static CPU_INIT( cop420 )
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */

View File

@ -198,9 +198,9 @@ static CPU_INIT( cop444 )
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */

View File

@ -212,8 +212,8 @@ static CPU_INIT(h8)
h8->mode_8bit = 0;
h8->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
h8->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
h8->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
h8->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
state_save_register_device_item(device, 0, h8->h8err);
state_save_register_device_item_array(device, 0, h8->regs);

View File

@ -222,8 +222,8 @@ static CPU_INIT(h8bit)
h8->mode_8bit = 1;
h8->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
h8->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
h8->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
h8->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
state_save_register_device_item(device, 0, h8->h8err);
state_save_register_device_item_array(device, 0, h8->regs);

View File

@ -513,7 +513,7 @@ static CPU_INIT( hd6309 )
m68_state->irq_callback = irqcallback;
m68_state->device = device;
m68_state->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
m68_state->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
/* setup regtable */

View File

@ -409,7 +409,7 @@ static void init_common(int isdsp, const device_config *device, cpu_irq_callback
jaguar->irq_callback = irqcallback;
jaguar->device = device;
jaguar->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
jaguar->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
if (configdata != NULL)
jaguar->cpu_interrupt = configdata->cpu_int_callback;

View File

@ -886,9 +886,9 @@ static CPU_INIT( m6800 )
{
m6800_state *cpustate = device->token;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
// cpustate->subtype = SUBTYPE_M6800;
cpustate->insn = m6800_insn;
@ -1283,9 +1283,9 @@ static CPU_INIT( m6801 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
cpustate->clock = device->clock / 4;
cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate);
@ -1308,9 +1308,9 @@ static CPU_INIT( m6802 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
state_register(cpustate, "m6802");
}
@ -1329,9 +1329,9 @@ static CPU_INIT( m6803 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
cpustate->clock = device->clock / 4;
cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate);
@ -1669,9 +1669,9 @@ static CPU_INIT( m6808 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
state_register(cpustate, "m6808");
}
@ -1691,9 +1691,9 @@ static CPU_INIT( hd63701 )
cpustate->irq_callback = irqcallback;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
cpustate->clock = device->clock / 4;
cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate);
@ -2041,9 +2041,9 @@ static CPU_INIT( nsc8105 )
// cpustate->subtype = SUBTYPE_NSC8105;
cpustate->device = device;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
cpustate->insn = nsc8105_insn;
cpustate->cycles = cycles_nsc8105;

View File

@ -504,7 +504,7 @@ static CPU_INIT( m68k )
m68ki_cpu_core *m68k = device->token;
m68k->device = device;
m68k->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
m68k->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
m68k->int_ack_callback = irqcallback;
/* The first call to this function initializes the opcode handler jump table */

View File

@ -373,7 +373,7 @@ static CPU_INIT( m6809 )
m68_state->irq_callback = irqcallback;
m68_state->device = device;
m68_state->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
m68_state->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
/* setup regtable */

View File

@ -709,9 +709,9 @@ static void mcs48_init(const device_config *device, cpu_irq_callback irqcallback
cpustate->device = device;
cpustate->int_rom_size = romsize;
cpustate->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* ensure that regptr is valid before get_info gets called */
update_regptr(cpustate);

View File

@ -2050,9 +2050,9 @@ static CPU_INIT( mcs51 )
mcs51_state->irq_callback = irqcallback;
mcs51_state->device = device;
mcs51_state->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
mcs51_state->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
mcs51_state->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
mcs51_state->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
mcs51_state->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
mcs51_state->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
mcs51_state->features = FEATURE_NONE;
mcs51_state->ram_mask = 0x7F; /* 128 bytes of ram */

View File

@ -1626,7 +1626,7 @@ static CPU_INIT( psxcpu )
psxcpu->irq_callback = irqcallback;
psxcpu->device = device;
psxcpu->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
psxcpu->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
mips_state_register( "psxcpu", device );
}

View File

@ -724,8 +724,8 @@ void sh2_common_init(SH2 *sh2, const device_config *device, cpu_irq_callback irq
}
sh2->irq_callback = irqcallback;
sh2->device = device;
sh2->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh2->internal = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh2->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
sh2->internal = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
state_save_register_device_item(device, 0, sh2->pc);
state_save_register_device_item(device, 0, sh2->r[15]);

View File

@ -3270,9 +3270,9 @@ static CPU_RESET( sh4 )
sh4->ftcsr_read_callback = f;
sh4->irq_callback = save_irqcallback;
sh4->device = device;
sh4->internal = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
sh4->internal = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
sh4->dma_timer[0] = tsaved[0];
sh4->dma_timer[1] = tsaved[1];
@ -3383,9 +3383,9 @@ static CPU_INIT( sh4 )
sh4->irq_callback = irqcallback;
sh4->device = device;
sh4->internal = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
sh4->internal = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
sh4->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
sh4_default_exception_priorities(sh4);
sh4->irln = 15;
sh4->test_irq = 0;

View File

@ -364,7 +364,7 @@ static CPU_INIT( tms32031 )
tms->irq_callback = irqcallback;
tms->device = device;
tms->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
tms->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
/* copy in the xf write routines */
tms->bootoffset = (configdata != NULL) ? configdata->bootoffset : 0;

View File

@ -740,7 +740,7 @@ static CPU_RESET( tms34010 )
/* the first time we are run */
tms->reset_deferred = tms->config->halt_on_reset;
if (tms->config->halt_on_reset)
tms34010_io_register_w(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), REG_HSTCTLH, 0x8000, 0xffff);
tms34010_io_register_w(memory_find_address_space(device, ADDRESS_SPACE_PROGRAM), REG_HSTCTLH, 0x8000, 0xffff);
}
@ -1636,7 +1636,7 @@ void tms34010_host_w(const device_config *cpu, int reg, int data)
/* control register */
case TMS34010_HOST_CONTROL:
tms->external_host_access = TRUE;
space = cpu_get_address_space(tms->device, ADDRESS_SPACE_PROGRAM);
space = memory_find_address_space(tms->device, ADDRESS_SPACE_PROGRAM);
tms34010_io_register_w(space, REG_HSTCTLH, data & 0xff00, 0xffff);
tms34010_io_register_w(space, REG_HSTCTLL, data & 0x00ff, 0xffff);
tms->external_host_access = FALSE;

View File

@ -3447,8 +3447,8 @@ static CPU_INIT( z80 )
z80->daisy = z80daisy_init(device, device->static_config);
z80->irq_callback = irqcallback;
z80->device = device;
z80->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
z80->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
z80->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
z80->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
z80->IX = z80->IY = 0xffff; /* IX and IY are FFFF after a reset! */
z80->F = ZF; /* Zero flag is set */

View File

@ -62,6 +62,7 @@ struct _cpu_class_data
/* execution lists */
const device_config *device; /* pointer back to our device */
cpu_class_data *next; /* pointer to the next CPU to execute, in order */
cpu_execute_func execute; /* execute function pointer */
/* cycle counting and executing */
int profiler; /* profiler tag */
@ -325,11 +326,11 @@ void cpuexec_timeslice(running_machine *machine)
classdata->cycles_stolen = 0;
global->executingcpu = classdata->device;
if (!call_debugger)
ran = cpu_execute(classdata->device, classdata->cycles_running);
ran = (*classdata->execute)(classdata->device, classdata->cycles_running);
else
{
debugger_start_cpu_hook(classdata->device, target);
ran = cpu_execute(classdata->device, classdata->cycles_running);
ran = (*classdata->execute)(classdata->device, classdata->cycles_running);
debugger_stop_cpu_hook(classdata->device);
}
@ -469,11 +470,6 @@ static DEVICE_START( cpu )
header->space[spacenum] = memory_find_address_space(device, spacenum);
header->set_info = (cpu_set_info_func)device_get_info_fct(device, CPUINFO_FCT_SET_INFO);
header->execute = (cpu_execute_func)device_get_info_fct(device, CPUINFO_FCT_EXECUTE);
header->burn = (cpu_burn_func)device_get_info_fct(device, CPUINFO_FCT_BURN);
header->translate = (cpu_translate_func)device_get_info_fct(device, CPUINFO_FCT_TRANSLATE);
header->disassemble = (cpu_disassemble_func)device_get_info_fct(device, CPUINFO_FCT_DISASSEMBLE);
header->dasm_override = NULL;
/* fill in the input states and IRQ callback information */
for (line = 0; line < ARRAY_LENGTH(classdata->input); line++)
@ -486,6 +482,7 @@ static DEVICE_START( cpu )
/* fill in the suspend states */
classdata->device = device;
classdata->execute = (cpu_execute_func)device_get_info_fct(device, CPUINFO_FCT_EXECUTE);
classdata->profiler = index + PROFILER_CPU1;
classdata->suspend = SUSPEND_REASON_RESET;
classdata->inttrigger = index + TRIGGER_INT;

View File

@ -49,6 +49,11 @@ enum
TYPE DEFINITIONS
***************************************************************************/
/* opaque definition of CPU internal and debugging info */
typedef struct _cpu_debug_data cpu_debug_data;
/* interrupt callback for VBLANK and timed interrupts */
typedef void (*cpu_interrupt_func)(const device_config *device);
@ -68,6 +73,16 @@ struct _cpu_config
};
/* public data at the end of the device->token */
typedef struct _cpu_class_header cpu_class_header;
struct _cpu_class_header
{
cpu_debug_data * debug; /* debugging data */
const address_space * space[ADDRESS_SPACES]; /* address spaces */
cpu_set_info_func set_info; /* this CPU's set_info function */
};
/***************************************************************************
CPU DEVICE CONFIGURATION MACROS
@ -133,6 +148,9 @@ struct _cpu_config
#define cputag_get_cpu(mach, tag) devtag_get_device(mach, CPU, tag)
/* helpers for using machine/cputag instead of cpu objects */
#define cputag_reset(mach, tag) devtag_reset(mach, CPU, tag)
#define cputag_get_index(mach, tag) cpu_get_index(cputag_get_cpu(mach, tag))
#define cputag_get_address_space(mach, tag, space) cpu_get_address_space(cputag_get_cpu(mach, tag), space)
#define cputag_suspend(mach, tag, reason, eat) cpu_suspend(cputag_get_cpu(mach, tag), reason, eat)
#define cputag_resume(mach, tag, reason) cpu_resume(cputag_get_cpu(mach, tag), reason)
#define cputag_is_suspended(mach, tag, reason) cpu_is_suspended(cputag_get_cpu(mach, tag), reason)
@ -292,7 +310,6 @@ void cpu_set_irq_callback(const device_config *cpu, cpu_irq_callback callback);
INLINE FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
cpu_get_type - return the type of the
specified CPU
@ -305,5 +322,45 @@ INLINE cpu_type cpu_get_type(const device_config *device)
}
/*-------------------------------------------------
cpu_get_class_header - return a pointer to
the class header
-------------------------------------------------*/
INLINE cpu_class_header *cpu_get_class_header(const device_config *device)
{
if (device->token != NULL)
return (cpu_class_header *)((UINT8 *)device->token + device->tokenbytes) - 1;
return NULL;
}
/*-------------------------------------------------
cpu_get_debug_data - return a pointer to
the given CPU's debugger data
-------------------------------------------------*/
INLINE cpu_debug_data *cpu_get_debug_data(const device_config *device)
{
cpu_class_header *classheader = cpu_get_class_header(device);
return classheader->debug;
}
/*-------------------------------------------------
cpu_get_address_space - return a pointer to
the given CPU's address space
-------------------------------------------------*/
INLINE const address_space *cpu_get_address_space(const device_config *device, int spacenum)
{
/* it is faster to pull this from the class header, but only after we've started */
if (device->token != NULL)
{
cpu_class_header *classheader = cpu_get_class_header(device);
return classheader->space[spacenum];
}
return memory_find_address_space(device, spacenum);
}
#endif /* __CPUEXEC_H__ */

View File

@ -1,207 +0,0 @@
/***************************************************************************
cpuintrf.c
Core CPU interface functions and definitions.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
***************************************************************************/
#include "driver.h"
/* mingw-gcc defines this */
#undef i386
/***************************************************************************
DEBUGGING
***************************************************************************/
#define VERBOSE 0
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
/***************************************************************************
CONSTANTS
***************************************************************************/
#define TEMP_STRING_POOL_ENTRIES 16
#define MAX_STRING_LENGTH 256
/***************************************************************************
LIVE CPU ACCESSORS
***************************************************************************/
/*-------------------------------------------------
cpu_get_physical_pc_byte - return the PC,
corrected to a byte offset and translated to
physical space, on a given CPU
-------------------------------------------------*/
offs_t cpu_get_physical_pc_byte(const device_config *device)
{
const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
offs_t pc;
pc = memory_address_to_byte(space, device_get_info_int(device, CPUINFO_INT_PC));
memory_address_physical(space, TRANSLATE_FETCH, &pc);
return pc;
}
/*-------------------------------------------------
cpu_dasm - disassemble a line at a given PC
on a given CPU
-------------------------------------------------*/
offs_t cpu_dasm(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
{
cpu_class_header *classheader = cpu_get_class_header(device);
offs_t result = 0;
/* check for disassembler override */
if (classheader->dasm_override != NULL)
result = (*classheader->dasm_override)(device, buffer, pc, oprom, opram);
/* if we have a disassembler, run it */
if (result == 0 && classheader->disassemble != NULL)
result = (*classheader->disassemble)(device, buffer, pc, oprom, opram);
/* if we still have nothing, output vanilla bytes */
if (result == 0)
{
result = cpu_get_min_opcode_bytes(device);
switch (result)
{
case 1:
default:
sprintf(buffer, "$%02X", *(UINT8 *)oprom);
break;
case 2:
sprintf(buffer, "$%04X", *(UINT16 *)oprom);
break;
case 4:
sprintf(buffer, "$%08X", *(UINT32 *)oprom);
break;
case 8:
sprintf(buffer, "$%08X%08X", (UINT32)(*(UINT64 *)oprom >> 32), (UINT32)(*(UINT64 *)oprom >> 0));
break;
}
}
/* make sure we get good results */
assert((result & DASMFLAG_LENGTHMASK) != 0);
#ifdef MAME_DEBUG
{
const address_space *space = classheader->space[ADDRESS_SPACE_PROGRAM];
int bytes = memory_address_to_byte(space, result & DASMFLAG_LENGTHMASK);
assert(bytes >= cpu_get_min_opcode_bytes(device));
assert(bytes <= cpu_get_max_opcode_bytes(device));
(void) bytes; /* appease compiler */
}
#endif
return result;
}
/*-------------------------------------------------
cpu_set_dasm_override - set a dasm override
handler
-------------------------------------------------*/
void cpu_set_dasm_override(const device_config *device, cpu_disassemble_func dasm_override)
{
cpu_class_header *classheader = cpu_get_class_header(device);
classheader->dasm_override = dasm_override;
}
/***************************************************************************
DUMMY CPU DEFINITION
***************************************************************************/
typedef struct _dummy_context dummy_context;
struct _dummy_context
{
int icount;
};
static CPU_INIT( dummy ) { }
static CPU_RESET( dummy ) { }
static CPU_EXIT( dummy ) { }
static CPU_EXECUTE( dummy ) { return cycles; }
static CPU_DISASSEMBLE( dummy )
{
strcpy(buffer, "???");
return 1;
}
static CPU_SET_INFO( dummy )
{
}
CPU_GET_INFO( dummy )
{
dummy_context *cpustate = (device != NULL) ? device->token : NULL;
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(dummy_context); break;
case CPUINFO_INT_INPUT_LINES: info->i = 1; break;
case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break;
case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break;
case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break;
case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break;
case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break;
case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 1; break;
case CPUINFO_INT_MIN_CYCLES: info->i = 1; break;
case CPUINFO_INT_MAX_CYCLES: info->i = 1; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 8; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA: info->i = 0; break;
case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break;
case CPUINFO_INT_INPUT_STATE + 0: info->i = 0; break;
case CPUINFO_INT_PREVIOUSPC: info->i = 0; break;
case CPUINFO_INT_PC: info->i = 0; break;
case CPUINFO_INT_SP: info->i = 0; break;
/* --- the following bits of info are returned as pointers to data or functions --- */
case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(dummy); break;
case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(dummy); break;
case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(dummy); break;
case CPUINFO_FCT_EXIT: info->exit = CPU_EXIT_NAME(dummy); break;
case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(dummy);break;
case CPUINFO_FCT_BURN: info->burn = NULL; break;
case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(dummy); break;
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case CPUINFO_STR_NAME: strcpy(info->s, ""); break;
case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "no CPU"); break;
case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "0.0"); break;
case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "The MAME team"); break;
case CPUINFO_STR_FLAGS: strcpy(info->s, "--"); break;
}
}

View File

@ -25,7 +25,6 @@
CONSTANTS
***************************************************************************/
#define MAX_CPU 8
#define MAX_INPUT_EVENTS 32
@ -229,8 +228,18 @@ enum
MACROS
***************************************************************************/
#define IRQ_CALLBACK(func) int func(const device_config *device, int irqline)
/* device iteration helpers */
#define cpu_count(config) device_list_items((config)->devicelist, CPU)
#define cpu_first(config) device_list_first((config)->devicelist, CPU)
#define cpu_next(previous) ((previous)->typenext)
#define cpu_get_index(cpu) device_list_index((cpu)->machine->config->devicelist, CPU, (cpu)->tag)
/* IRQ callback to be called by CPU cores when an IRQ is actually taken */
#define IRQ_CALLBACK(func) int func(const device_config *device, int irqline)
/* CPU interface functions */
#define CPU_GET_INFO_NAME(name) cpu_get_info_##name
#define CPU_GET_INFO(name) void CPU_GET_INFO_NAME(name)(const device_config *device, UINT32 state, cpuinfo *info)
#define CPU_GET_INFO_CALL(name) CPU_GET_INFO_NAME(name)(device, state, info)
@ -304,8 +313,9 @@ enum
#define CPU_EXPORT_STRING_CALL(name) CPU_EXPORT_STRING_NAME(name)(device, baseptr, entry, string)
#define cpu_get_index(cpu) device_list_index((cpu)->machine->config->devicelist, CPU, (cpu)->tag)
/* base macro for defining CPU state entries */
#define CPU_STATE_ENTRY(_index, _symbol, _format, _struct, _member, _datamask, _validmask, _flags) \
{ _index, _validmask, offsetof(_struct, _member), _datamask, sizeof(((_struct *)0)->_member), _flags, _symbol, _format },
/* helpers for accessing common CPU state */
@ -342,33 +352,21 @@ enum
#define cpu_set_reg(cpu, reg, val) device_set_info_int(cpu, CPUINFO_INT_REGISTER + (reg), (val))
/* helpers for using machine/cputag instead of cpu objects */
#define cputag_reset(mach, tag) device_reset(cputag_get_cpu(mach, tag))
#define cputag_get_index(mach, tag) cpu_get_index(cputag_get_cpu(mach, tag))
#define cputag_get_address_space(mach, tag, space) cpu_get_address_space(cputag_get_cpu(mach, tag), space)
#define CPU_STATE_ENTRY(_index, _symbol, _format, _struct, _member, _datamask, _validmask, _flags) \
{ _index, _validmask, offsetof(_struct, _member), _datamask, sizeof(((_struct *)0)->_member), _flags, _symbol, _format },
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
/* opaque definition of CPU internal and debugging info */
typedef struct _cpu_debug_data cpu_debug_data;
/* forward declaration of types */
typedef union _cpuinfo cpuinfo;
typedef struct _cpu_state_entry cpu_state_entry;
/* define the various callback functions */
/* IRQ callback to be called by CPU cores when an IRQ is actually taken */
typedef int (*cpu_irq_callback)(const device_config *device, int irqnum);
/* CPU interface functions */
typedef void (*cpu_get_info_func)(const device_config *device, UINT32 state, cpuinfo *info);
typedef void (*cpu_set_info_func)(const device_config *device, UINT32 state, cpuinfo *info);
typedef void (*cpu_init_func)(const device_config *device, cpu_irq_callback irqcallback);
@ -387,6 +385,10 @@ typedef void (*cpu_state_io_func)(const device_config *device, void *baseptr, co
typedef void (*cpu_string_io_func)(const device_config *device, void *baseptr, const cpu_state_entry *entry, char *string);
/* a cpu_type is just a pointer to the CPU's get_info function */
typedef cpu_get_info_func cpu_type;
/* structure describing a single item of exposed CPU state */
struct _cpu_state_entry
{
@ -412,10 +414,6 @@ struct _cpu_state_table
};
/* a cpu_type is just a pointer to the CPU's get_info function */
typedef cpu_get_info_func cpu_type;
/* cpuinfo union used to pass data to/from the get_info/set_info functions */
union _cpuinfo
{
@ -450,112 +448,5 @@ union _cpuinfo
};
/* partial data hanging off of the classtoken */
typedef struct _cpu_class_header cpu_class_header;
struct _cpu_class_header
{
cpu_debug_data * debug; /* debugging data */
const address_space * space[ADDRESS_SPACES]; /* address spaces */
/* table of core functions */
cpu_set_info_func set_info;
cpu_execute_func execute;
cpu_burn_func burn;
cpu_translate_func translate;
cpu_disassemble_func disassemble;
cpu_disassemble_func dasm_override;
};
/***************************************************************************
CPU DEFINITIONS
***************************************************************************/
#define cpu_count(config) device_list_items((config)->devicelist, CPU)
#define cpu_first(config) device_list_first((config)->devicelist, CPU)
#define cpu_next(previous) device_list_next((previous), CPU)
CPU_GET_INFO( dummy );
#define CPU_DUMMY CPU_GET_INFO_NAME( dummy )
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
/* ----- live CPU accessors ----- */
/* return the PC, corrected to a byte offset and translated to physical space, on a given CPU */
offs_t cpu_get_physical_pc_byte(const device_config *cpu);
/* disassemble a line at a given PC on a given CPU */
offs_t cpu_dasm(const device_config *cpu, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
/* set a dasm override handler */
void cpu_set_dasm_override(const device_config *cpu, cpu_disassemble_func dasm_override);
/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
cpu_get_class_header - return a pointer to
the class header
-------------------------------------------------*/
INLINE cpu_class_header *cpu_get_class_header(const device_config *device)
{
if (device->token != NULL)
return (cpu_class_header *)((UINT8 *)device->token + device->tokenbytes) - 1;
return NULL;
}
/*-------------------------------------------------
cpu_get_debug_data - return a pointer to
the given CPU's debugger data
-------------------------------------------------*/
INLINE cpu_debug_data *cpu_get_debug_data(const device_config *device)
{
cpu_class_header *classheader = cpu_get_class_header(device);
return classheader->debug;
}
/*-------------------------------------------------
cpu_get_address_space - return a pointer to
the given CPU's address space
-------------------------------------------------*/
INLINE const address_space *cpu_get_address_space(const device_config *device, int spacenum)
{
/* it is faster to pull this from the class header, but only after we've started */
if (device->token != NULL)
{
cpu_class_header *classheader = cpu_get_class_header(device);
return classheader->space[spacenum];
}
return memory_find_address_space(device, spacenum);
}
/*-------------------------------------------------
cpu_execute - execute the requested cycles on
a given CPU
-------------------------------------------------*/
INLINE int cpu_execute(const device_config *device, int cycles)
{
cpu_class_header *classheader = cpu_get_class_header(device);
return (*classheader->execute)(device, cycles);
}
#endif /* __CPUINTRF_H__ */

View File

@ -1557,7 +1557,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
if (i + j <= endoffset)
{
offs_t curaddr = i + j;
if (memory_address_physical(space, TRANSLATE_READ, &curaddr))
if (debug_cpu_translate(space, TRANSLATE_READ, &curaddr))
{
UINT8 byte = debug_read_byte(space, i + j, TRUE);
outdex += sprintf(&output[outdex], " %02X", byte);
@ -1576,7 +1576,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
if (i + j <= endoffset)
{
offs_t curaddr = i + j;
if (memory_address_physical(space, TRANSLATE_READ_DEBUG, &curaddr))
if (debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &curaddr))
{
UINT16 word = debug_read_word(space, i + j, TRUE);
outdex += sprintf(&output[outdex], " %04X", word);
@ -1595,7 +1595,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
if (i + j <= endoffset)
{
offs_t curaddr = i + j;
if (memory_address_physical(space, TRANSLATE_READ_DEBUG, &curaddr))
if (debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &curaddr))
{
UINT32 dword = debug_read_dword(space, i + j, TRUE);
outdex += sprintf(&output[outdex], " %08X", dword);
@ -1614,7 +1614,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
if (i + j <= endoffset)
{
offs_t curaddr = i + j;
if (memory_address_physical(space, TRANSLATE_READ_DEBUG, &curaddr))
if (debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &curaddr))
{
UINT64 qword = debug_read_qword(space, i + j, TRUE);
outdex += sprintf(&output[outdex], " %08X%08X", (UINT32)(qword >> 32), (UINT32)qword);
@ -1635,7 +1635,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
for (j = 0; j < 16 && (i + j) <= endoffset; j++)
{
offs_t curaddr = i + j;
if (memory_address_physical(space, TRANSLATE_READ_DEBUG, &curaddr))
if (debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &curaddr))
{
UINT8 byte = debug_read_byte(space, i + j, TRUE);
outdex += sprintf(&output[outdex], "%c", (byte >= 32 && byte < 128) ? byte : '.');
@ -1809,7 +1809,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch
/* make sure we can translate the address */
tempaddr = pcbyte;
if (memory_address_physical(space, TRANSLATE_FETCH_DEBUG, &tempaddr))
if (debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &tempaddr))
{
UINT8 opbuf[64], argbuf[64];
@ -1821,7 +1821,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch
}
/* disassemble the result */
i += numbytes = cpu_dasm(space->cpu, disasm, offset + i, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
i += numbytes = debug_cpu_disassemble(space->cpu, disasm, offset + i, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
}
/* print the bytes */
@ -2012,7 +2012,7 @@ static void execute_history(running_machine *machine, int ref, int params, const
argbuf[numbytes] = debug_read_opcode(space, pcbyte + numbytes, 1, TRUE);
}
cpu_dasm(space->cpu, buffer, pc, opbuf, argbuf);
debug_cpu_disassemble(space->cpu, buffer, pc, opbuf, argbuf);
debug_console_printf(machine, "%0*X: %s\n", space->logaddrchars, pc, buffer);
}
@ -2102,7 +2102,7 @@ static void execute_map(running_machine *machine, int ref, int params, const cha
{
static const char *const intnames[] = { "Read", "Write", "Fetch" };
taddress = memory_address_to_byte(space, address) & space->bytemask;
if (memory_address_physical(space, intention, &taddress))
if (debug_cpu_translate(space, intention, &taddress))
{
const char *mapname = memory_get_handler_string(space, intention == TRANSLATE_WRITE_DEBUG, taddress);
debug_console_printf(machine, "%7s: %08X logical == %08X physical -> %s\n", intnames[intention & 3], (UINT32)address, memory_byte_to_address(space, taddress), mapname);

View File

@ -328,7 +328,7 @@ UINT32 debug_comment_get_opcode_crc32(const device_config *device, offs_t addres
argbuf[i] = debug_read_opcode(space, address + i, 1, TRUE);
}
numbytes = cpu_dasm(device, buff, address & addrmask, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
numbytes = debug_cpu_disassemble(device, buff, address & addrmask, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
numbytes = memory_address_to_byte(space, numbytes);
crc = crc32(0, argbuf, numbytes);

View File

@ -203,6 +203,8 @@ void debug_cpu_init(running_machine *machine)
info->read = (cpu_read_func)device_get_info_fct(info->device, CPUINFO_FCT_READ);
info->write = (cpu_write_func)device_get_info_fct(info->device, CPUINFO_FCT_WRITE);
info->readop = (cpu_readop_func)device_get_info_fct(info->device, CPUINFO_FCT_READOP);
info->translate = (cpu_translate_func)device_get_info_fct(info->device, CPUINFO_FCT_TRANSLATE);
info->disassemble = (cpu_disassemble_func)device_get_info_fct(info->device, CPUINFO_FCT_DISASSEMBLE);
/* allocate a symbol table */
info->symtable = symtable_alloc(global->symtable, (void *)cpu);
@ -359,6 +361,98 @@ symbol_table *debug_cpu_get_symtable(const device_config *device)
/***************************************************************************
MEMORY AND DISASSEMBLY HELPERS
***************************************************************************/
/*-------------------------------------------------
debug_cpu_translate - return the physical
address corresponding to the given logical
address
-------------------------------------------------*/
int debug_cpu_translate(const address_space *space, int intention, offs_t *address)
{
cpu_debug_data *info = cpu_get_debug_data(space->cpu);
if (info->translate != NULL)
return (*info->translate)(space->cpu, space->spacenum, intention, address);
else
return TRUE;
}
/*-------------------------------------------------
debug_cpu_disassemble - disassemble a line at
a given PC on a given CPU
-------------------------------------------------*/
offs_t debug_cpu_disassemble(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
{
cpu_debug_data *info = cpu_get_debug_data(device);
offs_t result = 0;
/* check for disassembler override */
if (info->dasm_override != NULL)
result = (*info->dasm_override)(device, buffer, pc, oprom, opram);
/* if we have a disassembler, run it */
if (result == 0 && info->disassemble != NULL)
result = (*info->disassemble)(device, buffer, pc, oprom, opram);
/* if we still have nothing, output vanilla bytes */
if (result == 0)
{
result = cpu_get_min_opcode_bytes(device);
switch (result)
{
case 1:
default:
sprintf(buffer, "$%02X", *(UINT8 *)oprom);
break;
case 2:
sprintf(buffer, "$%04X", *(UINT16 *)oprom);
break;
case 4:
sprintf(buffer, "$%08X", *(UINT32 *)oprom);
break;
case 8:
sprintf(buffer, "$%08X%08X", (UINT32)(*(UINT64 *)oprom >> 32), (UINT32)(*(UINT64 *)oprom >> 0));
break;
}
}
/* make sure we get good results */
assert((result & DASMFLAG_LENGTHMASK) != 0);
#ifdef MAME_DEBUG
{
const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
int bytes = memory_address_to_byte(space, result & DASMFLAG_LENGTHMASK);
assert(bytes >= cpu_get_min_opcode_bytes(device));
assert(bytes <= cpu_get_max_opcode_bytes(device));
(void) bytes; /* appease compiler */
}
#endif
return result;
}
/*-------------------------------------------------
debug_cpu_set_dasm_override - set an override
handler for disassembly
-------------------------------------------------*/
void debug_cpu_set_dasm_override(const device_config *device, cpu_disassemble_func dasm_override)
{
cpu_debug_data *info = cpu_get_debug_data(device);
info->dasm_override = dasm_override;
}
/***************************************************************************
CORE DEBUGGER HOOKS
***************************************************************************/
@ -1255,7 +1349,7 @@ UINT8 debug_read_byte(const address_space *space, offs_t address, int apply_tran
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, return 0xff */
if (apply_translation && !memory_address_physical(space, TRANSLATE_READ_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
result = 0xff;
/* if there is a custom read handler, and it returns TRUE, use that value */
@ -1308,7 +1402,7 @@ UINT16 debug_read_word(const address_space *space, offs_t address, int apply_tra
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, return 0xffff */
if (apply_translation && !memory_address_physical(space, TRANSLATE_READ_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
result = 0xffff;
/* if there is a custom read handler, and it returns TRUE, use that value */
@ -1363,7 +1457,7 @@ UINT32 debug_read_dword(const address_space *space, offs_t address, int apply_tr
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, return 0xffffffff */
if (apply_translation && !memory_address_physical(space, TRANSLATE_READ_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
result = 0xffffffff;
/* if there is a custom read handler, and it returns TRUE, use that value */
@ -1418,7 +1512,7 @@ UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_tr
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, return 0xffffffffffffffff */
if (apply_translation && !memory_address_physical(space, TRANSLATE_READ_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
result = ~(UINT64)0;
/* if there is a custom read handler, and it returns TRUE, use that value */
@ -1454,7 +1548,7 @@ void debug_write_byte(const address_space *space, offs_t address, UINT8 data, in
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, we're done */
if (apply_translation && !memory_address_physical(space, TRANSLATE_WRITE_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns TRUE, use that */
@ -1507,7 +1601,7 @@ void debug_write_word(const address_space *space, offs_t address, UINT16 data, i
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, we're done */
if (apply_translation && !memory_address_physical(space, TRANSLATE_WRITE_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns TRUE, use that */
@ -1561,7 +1655,7 @@ void debug_write_dword(const address_space *space, offs_t address, UINT32 data,
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, we're done */
if (apply_translation && !memory_address_physical(space, TRANSLATE_WRITE_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns TRUE, use that */
@ -1615,7 +1709,7 @@ void debug_write_qword(const address_space *space, offs_t address, UINT64 data,
memory_set_debugger_access(space, global->debugger_access = TRUE);
/* translate if necessary; if not mapped, we're done */
if (apply_translation && !memory_address_physical(space, TRANSLATE_WRITE_DEBUG, &address))
if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns TRUE, use that */
@ -1669,7 +1763,7 @@ UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, i
}
/* translate to physical first */
if (!memory_address_physical(space, TRANSLATE_FETCH_DEBUG, &address))
if (!debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &address))
return ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size));
/* keep in physical range */
@ -2262,7 +2356,7 @@ static UINT32 dasm_wrapped(const device_config *device, char *buffer, offs_t pc)
argbuf[numbytes] = debug_read_opcode(space, pcbyte + numbytes, 1, TRUE);
}
return cpu_dasm(device, buffer, pc, opbuf, argbuf);
return debug_cpu_disassemble(device, buffer, pc, opbuf, argbuf);
}

View File

@ -100,29 +100,32 @@ struct _debug_hotspot_entry
/* In cpuintrf.h: typedef struct _cpu_debug_data cpu_debug_data; */
struct _cpu_debug_data
{
const device_config *device; /* CPU device object */
symbol_table * symtable; /* symbol table for expression evaluation */
UINT32 flags; /* debugging flags for this CPU */
UINT8 opwidth; /* width of an opcode */
offs_t stepaddr; /* step target address for DEBUG_FLAG_STEPPING_OVER */
int stepsleft; /* number of steps left until done */
offs_t stopaddr; /* stop address for DEBUG_FLAG_STOP_PC */
attotime stoptime; /* stop time for DEBUG_FLAG_STOP_TIME */
int stopirq; /* stop IRQ number for DEBUG_FLAG_STOP_INTERRUPT */
int stopexception; /* stop exception number for DEBUG_FLAG_STOP_EXCEPTION */
attotime endexectime; /* ending time of the current execution */
debug_trace_info trace; /* trace info */
debug_cpu_breakpoint *bplist; /* list of breakpoints */
debug_hotspot_entry *hotspots; /* hotspot list */
offs_t pc_history[DEBUG_HISTORY_SIZE]; /* history of recent PCs */
UINT32 pc_history_index; /* current history index */
int hotspot_count; /* number of hotspots */
int hotspot_threshhold; /* threshhold for the number of hits to print */
cpu_read_func read; /* memory read routine */
cpu_write_func write; /* memory write routine */
cpu_readop_func readop; /* opcode read routine */
debug_instruction_hook_func instrhook; /* per-instruction callback hook */
debug_cpu_watchpoint *wplist[ADDRESS_SPACES]; /* watchpoint lists for each address space */
const device_config * device; /* CPU device object */
symbol_table * symtable; /* symbol table for expression evaluation */
UINT32 flags; /* debugging flags for this CPU */
UINT8 opwidth; /* width of an opcode */
offs_t stepaddr; /* step target address for DEBUG_FLAG_STEPPING_OVER */
int stepsleft; /* number of steps left until done */
offs_t stopaddr; /* stop address for DEBUG_FLAG_STOP_PC */
attotime stoptime; /* stop time for DEBUG_FLAG_STOP_TIME */
int stopirq; /* stop IRQ number for DEBUG_FLAG_STOP_INTERRUPT */
int stopexception; /* stop exception number for DEBUG_FLAG_STOP_EXCEPTION */
attotime endexectime; /* ending time of the current execution */
debug_trace_info trace; /* trace info */
debug_cpu_breakpoint * bplist; /* list of breakpoints */
debug_hotspot_entry * hotspots; /* hotspot list */
offs_t pc_history[DEBUG_HISTORY_SIZE]; /* history of recent PCs */
UINT32 pc_history_index; /* current history index */
int hotspot_count; /* number of hotspots */
int hotspot_threshhold; /* threshhold for the number of hits to print */
cpu_read_func read; /* memory read routine */
cpu_write_func write; /* memory write routine */
cpu_readop_func readop; /* opcode read routine */
cpu_translate_func translate; /* pointer to CPU's translate function */
cpu_disassemble_func disassemble; /* pointer to CPU's dissasemble function */
cpu_disassemble_func dasm_override; /* pointer to provided override function */
debug_instruction_hook_func instrhook; /* per-instruction callback hook */
debug_cpu_watchpoint * wplist[ADDRESS_SPACES]; /* watchpoint lists for each address space */
};
@ -199,6 +202,19 @@ symbol_table *debug_cpu_get_symtable(const device_config *device);
/* ----- memory and disassembly helpers ----- */
/* return the physical address corresponding to the given logical address */
int debug_cpu_translate(const address_space *space, int intention, offs_t *address);
/* disassemble a line at a given PC on a given CPU */
offs_t debug_cpu_disassemble(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
/* set an override handler for disassembly */
void debug_cpu_set_dasm_override(const device_config *device, cpu_disassemble_func dasm_override);
/* ----- core debugger hooks ----- */
/* the CPU execution system calls this hook before beginning execution for the given CPU */

View File

@ -1730,8 +1730,8 @@ static offs_t disasm_view_find_pc_backwards(const address_space *space, offs_t t
/* get the disassembly, but only if mapped */
instlen = 1;
if (memory_address_physical(space, TRANSLATE_FETCH, &physpcbyte))
instlen = cpu_dasm(space->cpu, dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK;
if (debug_cpu_translate(space, TRANSLATE_FETCH, &physpcbyte))
instlen = debug_cpu_disassemble(space->cpu, dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK;
/* count this one */
instcount++;
@ -1891,7 +1891,7 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int
/* make sure we can translate the address, and then disassemble the result */
physpcbyte = pcbyte;
if (memory_address_physical(space, TRANSLATE_FETCH_DEBUG, &physpcbyte))
if (debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &physpcbyte))
{
UINT8 opbuf[64], argbuf[64];
@ -1903,7 +1903,7 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int
}
/* disassemble the result */
pc += numbytes = cpu_dasm(space->cpu, buffer, pc & space->logaddrmask, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
pc += numbytes = debug_cpu_disassemble(space->cpu, buffer, pc & space->logaddrmask, opbuf, argbuf) & DASMFLAG_LENGTHMASK;
}
else
strcpy(buffer, "<unmapped>");
@ -3021,7 +3021,7 @@ static int memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs,
offs_t dummyaddr = offs;
int ismapped;
ismapped = memdata->no_translation ? TRUE : memory_address_physical(space, TRANSLATE_READ_DEBUG, &dummyaddr);
ismapped = memdata->no_translation ? TRUE : debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &dummyaddr);
*data = ~(UINT64)0;
if (ismapped)
{

View File

@ -42,7 +42,6 @@ EMUOBJS = \
$(EMUOBJ)/clifront.o \
$(EMUOBJ)/config.o \
$(EMUOBJ)/cpuexec.o \
$(EMUOBJ)/cpuintrf.o \
$(EMUOBJ)/crsshair.o \
$(EMUOBJ)/debugger.o \
$(EMUOBJ)/devintrf.o \

View File

@ -34,8 +34,8 @@ UINT32 *generic_nvram32;
/* memory card status */
static int memcard_inserted;
/* interrupt status */
static UINT8 interrupt_enable[MAX_CPU];
/* interrupt status for up to 8 CPUs */
static UINT8 interrupt_enable[8];

View File

@ -149,7 +149,7 @@ struct _running_machine
const input_port_config *portconfig; /* points to a list of input port configurations */
/* CPU information */
const device_config * cpu[MAX_CPU]; /* array of CPU devices */
const device_config * cpu[8]; /* array of first 8 CPU devices */
/* game-related information */
const game_driver * gamedrv; /* points to the definition of the game machine */

View File

@ -1316,27 +1316,6 @@ UINT64 *_memory_install_device_handler64(const address_space *space, const devic
/***************************************************************************
MISCELLANEOUS UTILITIES
***************************************************************************/
/*-------------------------------------------------
memory_address_physical - return the physical
address corresponding to the given logical
address
-------------------------------------------------*/
int memory_address_physical(const address_space *space, int intention, offs_t *address)
{
cpu_class_header *classheader = cpu_get_class_header(space->cpu);
if (classheader->translate != NULL)
return (*classheader->translate)(space->cpu, space->spacenum, intention, address);
else
return TRUE;
}
/***************************************************************************
DEBUGGER HELPERS
***************************************************************************/

View File

@ -940,13 +940,6 @@ UINT64 *_memory_install_device_handler64(const address_space *space, const devic
/* ----- miscellaneous utilities ----- */
/* return the physical address corresponding to the given logical address */
int memory_address_physical(const address_space *space, int intention, offs_t *address);
/* ----- debugger helpers ----- */
/* return a string describing the handler at a particular offset */

View File

@ -408,7 +408,7 @@ static unsigned char Y8950PortHandler_r(void *param)
{
struct y8950_info *info = param;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if (info->intf->portread)
return info->intf->portread(space,info->index);
return 0;
@ -418,7 +418,7 @@ static void Y8950PortHandler_w(void *param,unsigned char data)
{
struct y8950_info *info = param;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if (info->intf->portwrite)
info->intf->portwrite(space,info->index,data);
}
@ -427,7 +427,7 @@ static unsigned char Y8950KeyboardHandler_r(void *param)
{
struct y8950_info *info = param;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if (info->intf->keyboardread)
return info->intf->keyboardread(space,info->index);
return 0;
@ -437,7 +437,7 @@ static void Y8950KeyboardHandler_w(void *param,unsigned char data)
{
struct y8950_info *info = param;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if (info->intf->keyboardwrite)
info->intf->keyboardwrite(space,info->index,data);
}

View File

@ -720,7 +720,7 @@ static void AICA_UpdateSlotReg(struct _AICA *AICA,int s,int r)
static void AICA_UpdateReg(struct _AICA *AICA, int reg)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(AICA->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(AICA->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
switch(reg&0xff)
{
case 0x4:

View File

@ -387,7 +387,7 @@ INLINE UINT16 mix_3D(ay8910_context *psg)
static void ay8910_write_reg(ay8910_context *psg, int r, int v)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
//if (r >= 11 && r <= 13 ) printf("%d %x %02x\n", PSG->index, r, v);
psg->regs[r] = v;
@ -783,7 +783,7 @@ int ay8910_read_ym(void *chip)
{
ay8910_context *psg = chip;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
int r = psg->register_latch;
if (r > 15) return 0;

View File

@ -833,7 +833,7 @@ static int pokey_register_r(int chip, int offs)
}
#endif
space = cpu_get_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
space = memory_find_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
switch (offs & 15)
{
case POT0_C: case POT1_C: case POT2_C: case POT3_C:
@ -985,7 +985,7 @@ static void pokey_register_w(int chip, int offs, int data)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, chip);
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
int ch_mask = 0, new_val;
#ifdef MAME_DEBUG

View File

@ -698,7 +698,7 @@ static void SCSP_UpdateSlotReg(struct _SCSP *SCSP,int s,int r)
static void SCSP_UpdateReg(struct _SCSP *SCSP, int reg)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(SCSP->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(SCSP->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
switch(reg&0x3f)
{
case 0x2:

View File

@ -1046,7 +1046,7 @@ void ym2151_write_reg(void *_chip, int r, int v)
{
YM2151 *chip = _chip;
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
YM2151Operator *op = &chip->oper[ (r&0x07)*4+((r&0x18)>>3) ];
/* adjust bus to 8 bits */

View File

@ -1375,7 +1375,7 @@ static TIMER_CALLBACK( ymf271_timer_b_tick )
static UINT8 ymf271_read_ext_memory(YMF271Chip *chip, UINT32 address)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if( chip->ext_mem_read ) {
return chip->ext_mem_read(space,address);
} else {
@ -1388,7 +1388,7 @@ static UINT8 ymf271_read_ext_memory(YMF271Chip *chip, UINT32 address)
static void ymf271_write_ext_memory(YMF271Chip *chip, UINT32 address, UINT8 data)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
if( chip->ext_mem_write ) {
chip->ext_mem_write(space, address, data);
}

View File

@ -869,7 +869,7 @@ static void write_to_register(struct YMZ280BChip *chip, int data)
if (chip->ext_ram_write)
{
/* temporary hack until this is converted to a device */
const address_space *space = cpu_get_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
chip->ext_ram_write(space, chip->rom_readback_addr, data);
}
else

View File

@ -171,7 +171,7 @@ static WRITE8_HANDLER( port40_w )
// Bits 1-3 are all set high upon death, until the game continues
// Bit 6 is used only in Malzak II, and is set high after checking
// the selected version
// logerror("S2650 [0x%04x]: port 0x40 write: 0x%02x\n",cpu_get_physical_pc_byte(space->machine->cpu[0]),data);
// logerror("S2650 [0x%04x]: port 0x40 write: 0x%02x\n",cpu_get_pc(space->machine->cpu[0]),data);
if(data & 0x40)
malzak_bank1 = 1;
else