diff options
author | 2008-11-10 08:51:06 +0000 | |
---|---|---|
committer | 2008-11-10 08:51:06 +0000 | |
commit | 6f4ee44948a6b31d23cf3afe41ea1b0388e05fb6 (patch) | |
tree | 6150ff2c9458dd88ae908e0be7ed5443a67d820d /src | |
parent | 92f305310513e310dcca7f5b1c3fe7ec2b197775 (diff) |
Added CPU device parameters to all CPU callbacks except for the
context ones (which are going away), the disassembler (which should
have no dependencies on the live CPU), and the validity check.
Removed global token from all pointer-ified CPU cores that don't
have internal read/write callbacks (which still need to reference it).
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/cpu/adsp2100/adsp2100.c | 62 | ||||
-rw-r--r-- | src/emu/cpu/adsp2100/adsp2100.h | 8 | ||||
-rw-r--r-- | src/emu/cpu/drcfe.c | 4 | ||||
-rw-r--r-- | src/emu/cpu/i8x41/i8x41.c | 12 | ||||
-rw-r--r-- | src/emu/cpu/i960/i960.c | 19 | ||||
-rw-r--r-- | src/emu/cpu/i960/i960.h | 4 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m4510.c | 8 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6502.c | 16 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6502.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6509.c | 4 | ||||
-rw-r--r-- | src/emu/cpu/m68000/m68kmame.c | 36 | ||||
-rw-r--r-- | src/emu/cpu/mcs48/mcs48.c | 21 | ||||
-rw-r--r-- | src/emu/cpu/mcs51/mcs51.c | 19 | ||||
-rw-r--r-- | src/emu/cpu/mips/r3000.c | 43 | ||||
-rw-r--r-- | src/emu/cpu/tms32025/tms32025.c | 16 | ||||
-rw-r--r-- | src/emu/cpu/tms9900/99xxcore.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/vtlb.c | 4 | ||||
-rw-r--r-- | src/emu/cpu/z80/z80.c | 16 | ||||
-rw-r--r-- | src/emu/cpuintrf.c | 50 | ||||
-rw-r--r-- | src/emu/cpuintrf.h | 77 | ||||
-rw-r--r-- | src/emu/debug/debugcmd.c | 16 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.c | 61 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.h | 1 | ||||
-rw-r--r-- | src/emu/debug/debugvw.c | 20 | ||||
-rw-r--r-- | src/emu/sound/nes_apu.c | 2 | ||||
-rw-r--r-- | src/mame/audio/dcs.c | 18 | ||||
-rw-r--r-- | src/mame/drivers/model2.c | 10 |
27 files changed, 248 insertions, 303 deletions
diff --git a/src/emu/cpu/adsp2100/adsp2100.c b/src/emu/cpu/adsp2100/adsp2100.c index f23d0a65c47..f24c51fd41c 100644 --- a/src/emu/cpu/adsp2100/adsp2100.c +++ b/src/emu/cpu/adsp2100/adsp2100.c @@ -269,8 +269,6 @@ typedef struct PRIVATE GLOBAL VARIABLES ***************************************************************************/ -static void *token; - static UINT16 *reverse_table = 0; static UINT16 *mask_table = 0; static UINT8 *condition_table = 0; @@ -557,15 +555,6 @@ static CPU_GET_CONTEXT( adsp21xx ) static CPU_SET_CONTEXT( adsp21xx ) { - /* copy the context */ - if (src) - { - adsp2100_state *adsp; - token = src; - adsp = token; - CHANGEPC(adsp); - check_irqs(adsp); - } } @@ -578,8 +567,6 @@ static adsp2100_state *adsp21xx_init(const device_config *device, int index, int { adsp2100_state *adsp = device->token; - token = device->token; // temporary - /* create the tables */ if (!create_tables()) fatalerror("creating adsp2100 tables failed"); @@ -917,14 +904,15 @@ static CPU_EXECUTE( adsp21xx ) int check_debugger = ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0); adsp2100_state *adsp = device->token; + CHANGEPC(adsp); + check_irqs(adsp); + /* reset the core */ set_mstat(adsp, adsp->mstat); /* count cycles and interrupt cycles */ adsp->icount = cycles; - CHANGEPC(adsp); - do { UINT32 temp; @@ -1679,7 +1667,7 @@ extern CPU_DISASSEMBLE( adsp21xx ); static CPU_SET_INFO( adsp21xx ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -1792,7 +1780,7 @@ static CPU_SET_INFO( adsp21xx ) static CPU_GET_INFO( adsp21xx ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2076,7 +2064,7 @@ static CPU_INIT( adsp2100 ) static CPU_SET_INFO( adsp2100 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2093,7 +2081,7 @@ static CPU_SET_INFO( adsp2100 ) CPU_GET_INFO( adsp2100 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2134,7 +2122,7 @@ static CPU_INIT( adsp2101 ) static CPU_SET_INFO( adsp2101 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2158,7 +2146,7 @@ static CPU_SET_INFO( adsp2101 ) CPU_GET_INFO( adsp2101 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2209,7 +2197,7 @@ void adsp2104_load_boot_data(UINT8 *srcdata, UINT32 *dstdata) static CPU_SET_INFO( adsp2104 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2233,7 +2221,7 @@ static CPU_SET_INFO( adsp2104 ) CPU_GET_INFO( adsp2104 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2284,7 +2272,7 @@ void adsp2105_load_boot_data(UINT8 *srcdata, UINT32 *dstdata) static CPU_SET_INFO( adsp2105 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2305,7 +2293,7 @@ static CPU_SET_INFO( adsp2105 ) CPU_GET_INFO( adsp2105 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2353,7 +2341,7 @@ void adsp2115_load_boot_data(UINT8 *srcdata, UINT32 *dstdata) static CPU_SET_INFO( adsp2115 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2377,7 +2365,7 @@ static CPU_SET_INFO( adsp2115 ) CPU_GET_INFO( adsp2115 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2428,7 +2416,7 @@ void adsp2181_load_boot_data(UINT8 *srcdata, UINT32 *dstdata) static CPU_SET_INFO( adsp2181 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -2455,7 +2443,7 @@ static CPU_SET_INFO( adsp2181 ) CPU_GET_INFO( adsp2181 ) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2491,22 +2479,22 @@ CPU_GET_INFO( adsp2181 ) } } -void adsp2181_idma_addr_w(UINT16 data) +void adsp2181_idma_addr_w(const device_config *device, UINT16 data) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; adsp->idma_addr = data; adsp->idma_offs = 0; } -UINT16 adsp2181_idma_addr_r(void) +UINT16 adsp2181_idma_addr_r(const device_config *device) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; return adsp->idma_addr; } -void adsp2181_idma_data_w(UINT16 data) +void adsp2181_idma_data_w(const device_config *device, UINT16 data) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; /* program memory? */ if (!(adsp->idma_addr & 0x4000)) @@ -2531,9 +2519,9 @@ void adsp2181_idma_data_w(UINT16 data) WWORD_DATA(adsp->idma_addr++ & 0x3fff, data); } -UINT16 adsp2181_idma_data_r(void) +UINT16 adsp2181_idma_data_r(const device_config *device) { - adsp2100_state *adsp = token; + adsp2100_state *adsp = device->token; UINT16 result = 0xffff; /* program memory? */ diff --git a/src/emu/cpu/adsp2100/adsp2100.h b/src/emu/cpu/adsp2100/adsp2100.h index d2e07578c26..5e2843bd3d9 100644 --- a/src/emu/cpu/adsp2100/adsp2100.h +++ b/src/emu/cpu/adsp2100/adsp2100.h @@ -157,10 +157,10 @@ extern void adsp2115_load_boot_data(UINT8 *srcdata, UINT32 *dstdata); extern CPU_GET_INFO( adsp2181 ); extern void adsp2181_load_boot_data(UINT8 *srcdata, UINT32 *dstdata); -extern void adsp2181_idma_addr_w(UINT16 data); -extern UINT16 adsp2181_idma_addr_r(void); -extern void adsp2181_idma_data_w(UINT16 data); -extern UINT16 adsp2181_idma_data_r(void); +extern void adsp2181_idma_addr_w(const device_config *device, UINT16 data); +extern UINT16 adsp2181_idma_addr_r(const device_config *device); +extern void adsp2181_idma_data_w(const device_config *device, UINT16 data); +extern UINT16 adsp2181_idma_data_r(const device_config *device); #endif /* (HAS_ADSP2181) */ #endif /* __ADSP2100_H__ */ diff --git a/src/emu/cpu/drcfe.c b/src/emu/cpu/drcfe.c index a727668b5fc..296bcdf9179 100644 --- a/src/emu/cpu/drcfe.c +++ b/src/emu/cpu/drcfe.c @@ -56,6 +56,7 @@ struct _drcfe_state void * param; /* parameter for the callback */ /* CPU parameters */ + const device_config *device; /* CPU device object */ offs_t pageshift; /* shift to convert address to a page index */ cpu_translate_func translate; /* pointer to translation function */ offs_t codexor; /* XOR to reach code */ @@ -142,6 +143,7 @@ drcfe_state *drcfe_init(const device_config *cpu, const drcfe_config *config, vo drcfe->param = param; /* initialize the state */ + drcfe->device = cpu; drcfe->pageshift = cpu_get_page_shift(cpu, ADDRESS_SPACE_PROGRAM); drcfe->translate = (cpu_translate_func)cpu_get_info_fct(cpu, CPUINFO_PTR_TRANSLATE); #ifdef LSB_FIRST @@ -288,7 +290,7 @@ static opcode_desc *describe_one(drcfe_state *drcfe, offs_t curpc, const opcode_ desc->targetpc = BRANCH_TARGET_DYNAMIC; /* compute the physical PC */ - if (drcfe->translate != NULL && !(*drcfe->translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc)) + if (drcfe->translate != NULL && !(*drcfe->translate)(drcfe->device, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &desc->physpc)) { /* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */ /* mark as needing to validate; otherwise, just end the sequence here */ diff --git a/src/emu/cpu/i8x41/i8x41.c b/src/emu/cpu/i8x41/i8x41.c index 27c51e48c03..acd7de77dfc 100644 --- a/src/emu/cpu/i8x41/i8x41.c +++ b/src/emu/cpu/i8x41/i8x41.c @@ -141,8 +141,6 @@ struct _upi41_state_t { int icount; }; -static void *token; - #define RM(a) program_read_byte_8le(a) #define IRAM_R(a) data_read_byte_8le((a) & upi41_state->ram_mask) @@ -840,8 +838,6 @@ static CPU_INIT( i8x41 ) { upi41_state_t *upi41_state = device->token; - token = device->token; - upi41_state->irq_callback = irqcallback; upi41_state->device = device; upi41_state->subtype = 8041; @@ -866,9 +862,8 @@ static CPU_INIT( i8x41 ) static CPU_INIT( i8042 ) { - upi41_state_t *upi41_state; + upi41_state_t *upi41_state = device->token; CPU_INIT_CALL(i8x41); - upi41_state = token; upi41_state->subtype = 8042; upi41_state->ram_mask = I8X42_intRAM_MASK; } @@ -1023,7 +1018,6 @@ static CPU_GET_CONTEXT( i8x41 ) static CPU_SET_CONTEXT( i8x41 ) { - token = src; } /**************************************************************************** @@ -1103,7 +1097,7 @@ ADDRESS_MAP_END static CPU_SET_INFO( i8x41 ) { - upi41_state_t *upi41_state = token; + upi41_state_t *upi41_state = device->token; switch (state) { @@ -1195,7 +1189,7 @@ static CPU_SET_INFO( i8x41 ) CPU_GET_INFO( i8041 ) { - upi41_state_t *upi41_state = token; + upi41_state_t *upi41_state = (device != NULL) ? device->token : NULL; switch (state) { diff --git a/src/emu/cpu/i960/i960.c b/src/emu/cpu/i960/i960.c index 525bffd8e14..80194748e62 100644 --- a/src/emu/cpu/i960/i960.c +++ b/src/emu/cpu/i960/i960.c @@ -39,8 +39,6 @@ struct _i960_state_t { int icount; }; -static void *token; - static void do_call(i960_state_t *i960_state, UINT32 adr, int type, UINT32 stack); INLINE UINT32 i960_read_dword_unaligned(UINT32 address) @@ -1954,8 +1952,8 @@ INLINE void execute_op(i960_state_t *i960_state, UINT32 opcode) static CPU_EXECUTE( i960 ) { - UINT32 opcode; i960_state_t *i960_state = device->token; + UINT32 opcode; i960_state->icount = cycles; check_irqs(i960_state); @@ -1979,7 +1977,6 @@ static CPU_GET_CONTEXT( i960 ) static CPU_SET_CONTEXT( i960 ) { - token = src; } static void set_irq_line(i960_state_t *i960_state, int irqline, int state) @@ -2052,7 +2049,7 @@ static void set_irq_line(i960_state_t *i960_state, int irqline, int state) static CPU_SET_INFO( i960 ) { - i960_state_t *i960_state = token; + i960_state_t *i960_state = device->token; if(state >= CPUINFO_INT_REGISTER+I960_R0 && state <= CPUINFO_INT_REGISTER + I960_G15) { i960_state->r[state - (CPUINFO_INT_REGISTER + I960_R0)] = info->i; @@ -2079,8 +2076,6 @@ static CPU_INIT( i960 ) i960_state->irq_cb = irqcallback; i960_state->device = device; - token = device->token; - state_save_register_item("i960", index, i960_state->PIP); state_save_register_item("i960", index, i960_state->SAT); state_save_register_item("i960", index, i960_state->PRCB); @@ -2129,7 +2124,7 @@ static CPU_RESET( i960 ) CPU_GET_INFO( i960 ) { - i960_state_t *i960_state = token; + i960_state_t *i960_state = (device != NULL) ? device->token : NULL; if(state >= CPUINFO_INT_REGISTER+I960_R0 && state <= CPUINFO_INT_REGISTER + I960_G15) { info->i = i960_state->r[state - (CPUINFO_INT_REGISTER + I960_R0)]; @@ -2242,14 +2237,14 @@ CPU_GET_INFO( i960 ) // call from any read/write handler for a memory area that can't be bursted // on the real hardware (e.g. Model 2's interrupt control registers) -void i960_noburst(void) +void i960_noburst(const device_config *device) { - i960_state_t *i960_state = token; + i960_state_t *i960_state = device->token; i960_state->bursting = 0; } -void i960_stall(void) +void i960_stall(const device_config *device) { - i960_state_t *i960_state = token; + i960_state_t *i960_state = device->token; i960_state->IP = i960_state->PIP; } diff --git a/src/emu/cpu/i960/i960.h b/src/emu/cpu/i960/i960.h index 46a2f6930d0..778f027c6bb 100644 --- a/src/emu/cpu/i960/i960.h +++ b/src/emu/cpu/i960/i960.h @@ -62,7 +62,7 @@ enum }; CPU_GET_INFO( i960 ); -void i960_noburst(void); -void i960_stall(void); +void i960_noburst(const device_config *device); +void i960_stall(const device_config *device); #endif /* __I960_H__ */ diff --git a/src/emu/cpu/m6502/m4510.c b/src/emu/cpu/m6502/m4510.c index 2e6249387b3..98f5532cf42 100644 --- a/src/emu/cpu/m6502/m4510.c +++ b/src/emu/cpu/m6502/m4510.c @@ -275,7 +275,7 @@ INLINE void m4510_take_irq(m4510_Regs *m4510) static CPU_EXECUTE( m4510 ) { - m4510_Regs *m4510 = token; + m4510_Regs *m4510 = device->token; m4510->icount = cycles; @@ -399,7 +399,7 @@ ADDRESS_MAP_END static CPU_TRANSLATE( m4510 ) { - m4510_Regs *m4510 = token; + m4510_Regs *m4510 = device->token; if (space == ADDRESS_SPACE_PROGRAM) *address = M4510_MEM(*address); @@ -412,7 +412,7 @@ static CPU_TRANSLATE( m4510 ) static CPU_SET_INFO( m4510 ) { - m4510_Regs *m4510 = token; + m4510_Regs *m4510 = device->token; switch (state) { @@ -459,7 +459,7 @@ static CPU_SET_INFO( m4510 ) CPU_GET_INFO( m4510 ) { - m4510_Regs *m4510 = token; + m4510_Regs *m4510 = (device != NULL) ? device->token : NULL; switch (state) { diff --git a/src/emu/cpu/m6502/m6502.c b/src/emu/cpu/m6502/m6502.c index 964d4eef968..44373939be1 100644 --- a/src/emu/cpu/m6502/m6502.c +++ b/src/emu/cpu/m6502/m6502.c @@ -345,9 +345,9 @@ static CPU_INIT( n2a03 ) Bit 7 of address $4011 (the PSG's DPCM control register), when set, causes an IRQ to be generated. This function allows the IRQ to be called from the PSG core when such an occasion arises. */ -void n2a03_irq() +void n2a03_irq(const device_config *device) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = device->token; m6502_take_irq(m6502); } @@ -692,7 +692,7 @@ static CPU_EXECUTE( deco16 ) static CPU_SET_INFO( m6502 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = device->token; switch (state) { @@ -726,7 +726,7 @@ static CPU_SET_INFO( m6502 ) CPU_GET_INFO( m6502 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = (device != NULL) ? device->token : NULL; switch (state) { @@ -843,7 +843,7 @@ CPU_GET_INFO( n2a03 ) static CPU_SET_INFO( m6510 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = device->token; switch (state) { @@ -857,7 +857,7 @@ static CPU_SET_INFO( m6510 ) CPU_GET_INFO( m6510 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = (device != NULL) ? device->token : NULL; switch (state) { @@ -943,7 +943,7 @@ CPU_GET_INFO( m8502 ) static CPU_SET_INFO( m65c02 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = device->token; switch (state) { @@ -1007,7 +1007,7 @@ CPU_GET_INFO( m65sc02 ) static CPU_SET_INFO( deco16 ) { - m6502_Regs *m6502 = token; + m6502_Regs *m6502 = device->token; switch (state) { diff --git a/src/emu/cpu/m6502/m6502.h b/src/emu/cpu/m6502/m6502.h index d5250fd7f52..af8697738b3 100644 --- a/src/emu/cpu/m6502/m6502.h +++ b/src/emu/cpu/m6502/m6502.h @@ -177,7 +177,7 @@ extern CPU_GET_INFO( n2a03 ); Bit 7 of address $4011 (the PSG's DPCM control register), when set, causes an IRQ to be generated. This function allows the IRQ to be called from the PSG core when such an occasion arises. */ -extern void n2a03_irq(void); +extern void n2a03_irq(const device_config *device); #endif diff --git a/src/emu/cpu/m6502/m6509.c b/src/emu/cpu/m6502/m6509.c index 894ee943c1c..ff4936b026d 100644 --- a/src/emu/cpu/m6502/m6509.c +++ b/src/emu/cpu/m6502/m6509.c @@ -313,7 +313,7 @@ static void m6509_set_irq_line(m6509_Regs *m6509, int irqline, int state) static CPU_SET_INFO( m6509 ) { - m6509_Regs *m6509 = token; + m6509_Regs *m6509 = device->token; m6509_Regs *m6502 = m6509; switch (state) @@ -350,7 +350,7 @@ static CPU_SET_INFO( m6509 ) CPU_GET_INFO( m6509 ) { - m6509_Regs *m6502 = token; + m6509_Regs *m6502 = (device != NULL) ? device->token : NULL; m6509_Regs *m6509 = m6502; switch (state) diff --git a/src/emu/cpu/m68000/m68kmame.c b/src/emu/cpu/m68000/m68kmame.c index bf945e6822a..d42b879559c 100644 --- a/src/emu/cpu/m68000/m68kmame.c +++ b/src/emu/cpu/m68000/m68kmame.c @@ -5,8 +5,6 @@ /* global access */ -static void *token; - m68k_memory_interface m68k_memory_intf; offs_t m68k_encrypted_opcode_start[MAX_CPU]; offs_t m68k_encrypted_opcode_end[MAX_CPU]; @@ -156,7 +154,6 @@ static void set_irq_line(m68ki_cpu_core *m68k, int irqline, int state) static CPU_INIT( m68000 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68000); m68k_memory_intf = interface_d16; @@ -187,7 +184,6 @@ static CPU_SET_CONTEXT( m68000 ) { if (m68k_memory_intf.read8 != program_read_byte_16be) m68k_memory_intf = interface_d16; - token = src; } static CPU_DISASSEMBLE( m68000 ) @@ -203,7 +199,6 @@ static CPU_DISASSEMBLE( m68000 ) static CPU_INIT( m68008 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68008); m68k_memory_intf = interface_d8; @@ -234,7 +229,6 @@ static CPU_SET_CONTEXT( m68008 ) { if (m68k_memory_intf.read8 != program_read_byte_8be) m68k_memory_intf = interface_d8; - token = src; } static CPU_DISASSEMBLE( m68008 ) @@ -252,7 +246,6 @@ static CPU_DISASSEMBLE( m68008 ) static CPU_INIT( m68010 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68010); m68k_memory_intf = interface_d16; @@ -274,7 +267,6 @@ static CPU_DISASSEMBLE( m68010 ) static CPU_INIT( m68020 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68020); m68k_memory_intf = interface_d32; @@ -305,7 +297,6 @@ static CPU_SET_CONTEXT( m68020 ) { if (m68k_memory_intf.read8 != program_read_byte_32be) m68k_memory_intf = interface_d32; - token = src; } static CPU_DISASSEMBLE( m68020 ) @@ -322,7 +313,6 @@ static CPU_DISASSEMBLE( m68020 ) static CPU_INIT( m68ec020 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68EC020); m68k_memory_intf = interface_d32; @@ -345,7 +335,6 @@ static CPU_DISASSEMBLE( m68ec020 ) static CPU_INIT( m68040 ) { m68ki_cpu_core *m68k = device->token; - token = device->token; // temporary m68k_init(m68k); m68k_set_cpu_type(m68k, M68K_CPU_TYPE_68040); m68k_memory_intf = interface_d32; @@ -376,7 +365,6 @@ static CPU_SET_CONTEXT( m68040 ) { if (m68k_memory_intf.read8 != program_read_byte_32be) m68k_memory_intf = interface_d32; - token = src; } static CPU_DISASSEMBLE( m68040 ) @@ -392,7 +380,7 @@ static CPU_DISASSEMBLE( m68040 ) static CPU_SET_INFO( m68000 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -444,7 +432,7 @@ static CPU_SET_INFO( m68000 ) CPU_GET_INFO( m68000 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; int sr; switch (state) @@ -578,7 +566,7 @@ CPU_GET_INFO( m68000 ) static CPU_SET_INFO( m68008 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -624,7 +612,7 @@ static CPU_SET_INFO( m68008 ) CPU_GET_INFO( m68008 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; int sr; switch (state) @@ -763,7 +751,7 @@ CPU_GET_INFO( m68008 ) static CPU_SET_INFO( m68010 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -777,7 +765,7 @@ static CPU_SET_INFO( m68010 ) CPU_GET_INFO( m68010 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -808,7 +796,7 @@ CPU_GET_INFO( m68010 ) static CPU_SET_INFO( m68020 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -860,7 +848,7 @@ static CPU_SET_INFO( m68020 ) CPU_GET_INFO( m68020 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; int sr; switch (state) @@ -1010,7 +998,7 @@ CPU_GET_INFO( m68020 ) static CPU_SET_INFO( m68ec020 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -1022,7 +1010,7 @@ static CPU_SET_INFO( m68ec020 ) CPU_GET_INFO( m68ec020 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1050,7 +1038,7 @@ CPU_GET_INFO( m68ec020 ) #if HAS_M68040 static CPU_SET_INFO( m68040 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -1102,7 +1090,7 @@ static CPU_SET_INFO( m68040 ) CPU_GET_INFO( m68040 ) { - m68ki_cpu_core *m68k = token; + m68ki_cpu_core *m68k = (device != NULL) ? device->token : NULL; int sr; switch (state) diff --git a/src/emu/cpu/mcs48/mcs48.c b/src/emu/cpu/mcs48/mcs48.c index ab31ace179a..7892c22e075 100644 --- a/src/emu/cpu/mcs48/mcs48.c +++ b/src/emu/cpu/mcs48/mcs48.c @@ -171,12 +171,6 @@ struct _mcs48_opcode /*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ - -static void *token; - -/*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ @@ -703,8 +697,6 @@ static void mcs48_init(const device_config *device, int index, int clock, cpu_ir { mcs48_state *mcs48 = device->token; - token = device->token; // temporary - /* External access line * EA=1 : read from external rom * EA=0 : read from internal rom @@ -925,6 +917,9 @@ static CPU_EXECUTE( mcs48 ) mcs48_state *mcs48 = device->token; unsigned opcode; + update_regptr(mcs48); + change_pc(PC); + mcs48->icount = cycles; /* external interrupts may have been set since we last checked */ @@ -1002,12 +997,6 @@ static CPU_GET_CONTEXT( mcs48 ) static CPU_SET_CONTEXT( mcs48 ) { - mcs48_state *mcs48; - if( src ) - token = src; - mcs48 = token; - update_regptr(mcs48); - change_pc(PC); } /*------------------------------------------------- @@ -1017,7 +1006,7 @@ static CPU_SET_CONTEXT( mcs48 ) static CPU_SET_INFO( mcs48 ) { - mcs48_state *mcs48 = token; + mcs48_state *mcs48 = device->token; switch (state) { @@ -1053,7 +1042,7 @@ static CPU_SET_INFO( mcs48 ) static CPU_GET_INFO( mcs48 ) { - mcs48_state *mcs48 = token; + mcs48_state *mcs48 = (device != NULL) ? device->token : NULL; switch (state) { diff --git a/src/emu/cpu/mcs51/mcs51.c b/src/emu/cpu/mcs51/mcs51.c index a4ff5013fc2..320c5d7cb04 100644 --- a/src/emu/cpu/mcs51/mcs51.c +++ b/src/emu/cpu/mcs51/mcs51.c @@ -636,8 +636,6 @@ struct _mcs51_state_t GLOBAL VARIABLES ***************************************************************************/ -static void *token; - static void (*hold_serial_tx_callback)(int data); static int (*hold_serial_rx_callback)(void); @@ -1909,6 +1907,9 @@ static CPU_EXECUTE( mcs51 ) mcs51_state_t *mcs51_state = device->token; UINT8 op; + change_pc(PC); + update_ptrs(mcs51_state); + mcs51_state->icount = cycles; /* external interrupts may have been set since we last checked */ @@ -2057,8 +2058,6 @@ static CPU_INIT( mcs51 ) { mcs51_state_t *mcs51_state = device->token; - token = device->token; // temporary - mcs51_state->irq_callback = irqcallback; mcs51_state->device = device; @@ -2419,14 +2418,6 @@ static CPU_GET_CONTEXT( mcs51 ) static CPU_SET_CONTEXT( mcs51 ) { - mcs51_state_t *mcs51_state; - - if( src ) - token = src; - - mcs51_state = token; - change_pc(PC); - update_ptrs(mcs51_state); } /************************************************************************** @@ -2435,7 +2426,7 @@ static CPU_SET_CONTEXT( mcs51 ) static CPU_SET_INFO( mcs51 ) { - mcs51_state_t *mcs51_state = token; + mcs51_state_t *mcs51_state = device->token; switch (state) { @@ -2477,7 +2468,7 @@ static CPU_SET_INFO( mcs51 ) static CPU_GET_INFO( mcs51 ) { - mcs51_state_t *mcs51_state = token; + mcs51_state_t *mcs51_state = (device != NULL) ? device->token : NULL; switch (state) { diff --git a/src/emu/cpu/mips/r3000.c b/src/emu/cpu/mips/r3000.c index 8dd0e14cedf..03c896cfdc6 100644 --- a/src/emu/cpu/mips/r3000.c +++ b/src/emu/cpu/mips/r3000.c @@ -209,7 +209,6 @@ static void writecache_le_dword(offs_t offset, UINT32 data); static void *token; - static const memory_accessors be_memory = { program_read_byte_32be, program_read_word_32be, program_read_dword_32be, @@ -321,17 +320,6 @@ static CPU_GET_CONTEXT( r3000 ) static CPU_SET_CONTEXT( r3000 ) { - r3000_state *r3000; - - /* copy the context */ - if (src) - token = src; - - r3000 = token; - change_pc(r3000->pc); - - /* check for IRQs */ - check_irqs(r3000); } @@ -736,6 +724,8 @@ INLINE void handle_cop3(r3000_state *r3000, UINT32 op) static CPU_EXECUTE( r3000 ) { r3000_state *r3000 = device->token; + + token = device->token; /* count cycles and interrupt cycles */ r3000->icount = cycles; @@ -743,6 +733,9 @@ static CPU_EXECUTE( r3000 ) r3000->interrupt_cycles = 0; change_pc(r3000->pc); + /* check for IRQs */ + check_irqs(r3000); + /* core execution loop */ do { @@ -934,16 +927,20 @@ static CPU_EXECUTE( r3000 ) DISASSEMBLY HOOK ***************************************************************************/ -static CPU_DISASSEMBLE( r3000 ) +static CPU_DISASSEMBLE( r3000be ) { extern unsigned dasmr3k(char *, unsigned, UINT32); - r3000_state *r3000 = token; UINT32 op = *(UINT32 *)oprom; - if (r3000->bigendian) - op = BIG_ENDIANIZE_INT32(op); - else - op = LITTLE_ENDIANIZE_INT32(op); + op = BIG_ENDIANIZE_INT32(op); + return dasmr3k(buffer, pc, op); +} + +static CPU_DISASSEMBLE( r3000le ) +{ + extern unsigned dasmr3k(char *, unsigned, UINT32); + UINT32 op = *(UINT32 *)oprom; + op = LITTLE_ENDIANIZE_INT32(op); return dasmr3k(buffer, pc, op); } @@ -1162,7 +1159,7 @@ static void swr_le(r3000_state *r3000, UINT32 op) static CPU_SET_INFO( r3000 ) { - r3000_state *r3000 = token; + r3000_state *r3000 = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -1221,7 +1218,7 @@ static CPU_SET_INFO( r3000 ) static CPU_GET_INFO( r3000 ) { - r3000_state *r3000 = token; + r3000_state *r3000 = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1302,7 +1299,7 @@ static CPU_GET_INFO( r3000 ) case CPUINFO_PTR_EXIT: info->exit = CPU_EXIT_NAME(r3000); break; case CPUINFO_PTR_EXECUTE: info->execute = CPU_EXECUTE_NAME(r3000); break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(r3000); break; + case CPUINFO_PTR_DISASSEMBLE: /* provided per-CPU */ break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &r3000->icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1366,6 +1363,7 @@ CPU_GET_INFO( r3000be ) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(r3000be); break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(r3000be); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "R3000 (big)"); break; @@ -1384,6 +1382,7 @@ CPU_GET_INFO( r3000le ) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(r3000le); break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(r3000le); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "R3000 (little)"); break; @@ -1402,6 +1401,7 @@ CPU_GET_INFO( r3041be ) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(r3000be); break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(r3000be); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "R3041 (big)"); break; @@ -1420,6 +1420,7 @@ CPU_GET_INFO( r3041le ) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_RESET: info->reset = CPU_RESET_NAME(r3000le); break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(r3000le); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "R3041 (little)"); break; diff --git a/src/emu/cpu/tms32025/tms32025.c b/src/emu/cpu/tms32025/tms32025.c index 9cb562b55d7..38d69acfe2b 100644 --- a/src/emu/cpu/tms32025/tms32025.c +++ b/src/emu/cpu/tms32025/tms32025.c @@ -2191,15 +2191,15 @@ static CPU_READ( tms32025 ) *value = ((UINT16 *)ptr)[(offset & 0xff) / 2]; break; case 4: - CPU_READ_NAME(tms32025)(space, offset + 0, 2, &temp); + CPU_READ_NAME(tms32025)(device, space, offset + 0, 2, &temp); *value = temp << 16; - CPU_READ_NAME(tms32025)(space, offset + 2, 2, &temp); + CPU_READ_NAME(tms32025)(device, space, offset + 2, 2, &temp); *value |= temp & 0xffff; break; case 8: - CPU_READ_NAME(tms32025)(space, offset + 0, 4, &temp); + CPU_READ_NAME(tms32025)(device, space, offset + 0, 4, &temp); *value = temp << 32; - CPU_READ_NAME(tms32025)(space, offset + 4, 4, &temp); + CPU_READ_NAME(tms32025)(device, space, offset + 4, 4, &temp); *value |= temp & 0xffffffff; break; } @@ -2241,12 +2241,12 @@ static CPU_WRITE( tms32025 ) ((UINT16 *)ptr)[(offset & 0xff) / 2] = value; break; case 4: - CPU_WRITE_NAME(tms32025)(space, offset + 0, 2, value >> 16); - CPU_WRITE_NAME(tms32025)(space, offset + 2, 2, value); + CPU_WRITE_NAME(tms32025)(device, space, offset + 0, 2, value >> 16); + CPU_WRITE_NAME(tms32025)(device, space, offset + 2, 2, value); break; case 8: - CPU_WRITE_NAME(tms32025)(space, offset + 0, 4, value >> 32); - CPU_WRITE_NAME(tms32025)(space, offset + 4, 4, value); + CPU_WRITE_NAME(tms32025)(device, space, offset + 0, 4, value >> 32); + CPU_WRITE_NAME(tms32025)(device, space, offset + 4, 4, value); break; } return 1; diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h index f3790aff75c..b1092e064c2 100644 --- a/src/emu/cpu/tms9900/99xxcore.h +++ b/src/emu/cpu/tms9900/99xxcore.h @@ -4679,7 +4679,7 @@ static CPU_SET_INFO( tms99xx ) * Generic get_info **************************************************************************/ -void TMS99XX_GET_INFO(UINT32 state, cpuinfo *info) +void TMS99XX_GET_INFO(const device_config *device, UINT32 state, cpuinfo *info) { switch (state) { diff --git a/src/emu/cpu/vtlb.c b/src/emu/cpu/vtlb.c index f966046be25..f8992e1dcbc 100644 --- a/src/emu/cpu/vtlb.c +++ b/src/emu/cpu/vtlb.c @@ -30,6 +30,7 @@ /* VTLB state */ struct _vtlb_state { + const device_config *device; /* CPU device */ int space; /* address space */ int dynamic; /* number of dynamic entries */ int fixed; /* number of fixed entries */ @@ -64,6 +65,7 @@ vtlb_state *vtlb_alloc(const device_config *cpu, int space, int fixed_entries, i memset(vtlb, 0, sizeof(*vtlb)); /* fill in CPU information */ + vtlb->device = cpu; vtlb->space = space; vtlb->dynamic = dynamic_entries; vtlb->fixed = fixed_entries; @@ -152,7 +154,7 @@ int vtlb_fill(vtlb_state *vtlb, offs_t address, int intention) /* ask the CPU core to translate for us */ taddress = address; - if (!(*vtlb->translate)(vtlb->space, intention, &taddress)) + if (!(*vtlb->translate)(vtlb->device, vtlb->space, intention, &taddress)) { if (PRINTF_TLB) printf("failed: no translation\n"); diff --git a/src/emu/cpu/z80/z80.c b/src/emu/cpu/z80/z80.c index b1896707412..52cbbcc398c 100644 --- a/src/emu/cpu/z80/z80.c +++ b/src/emu/cpu/z80/z80.c @@ -207,8 +207,6 @@ struct _z80_state #define IFF2 z80->iff2 #define HALT z80->halt -static z80_state *token; - static UINT8 SZ[256]; /* zero and sign flags */ static UINT8 SZ_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */ static UINT8 SZP[256]; /* zero, sign and parity flags */ @@ -3430,8 +3428,6 @@ static CPU_INIT( z80 ) z80_state *z80 = device->token; int i, p; - token = device->token; // temporary - /* setup cycle tables */ cc[Z80_TABLE_op] = cc_op; cc[Z80_TABLE_cb] = cc_cb; @@ -3600,6 +3596,7 @@ static CPU_EXECUTE( z80 ) z80_state *z80 = device->token; z80->icount = cycles; + change_pc(PCD); /* check for NMIs on the way in; they can only be set externally */ /* via timers, and can't be dynamically enabled, so it is safe */ @@ -3640,7 +3637,7 @@ static CPU_EXECUTE( z80 ) ****************************************************************************/ static CPU_BURN( z80 ) { - z80_state *z80 = token; + z80_state *z80 = device->token; if( cycles > 0 ) { @@ -3663,11 +3660,6 @@ static CPU_GET_CONTEXT( z80 ) ****************************************************************************/ static CPU_SET_CONTEXT( z80 ) { - z80_state *z80; - if( src ) - token = src; - z80 = token; - change_pc(PCD); } /**************************************************************************** @@ -3701,7 +3693,7 @@ static void set_irq_line(z80_state *z80, int irqline, int state) static CPU_SET_INFO( z80 ) { - z80_state *z80 = token; + z80_state *z80 = device->token; switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -3755,7 +3747,7 @@ static CPU_SET_INFO( z80 ) CPU_GET_INFO( z80 ) { - z80_state *z80 = token; + z80_state *z80 = (device != NULL) ? device->token : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpuintrf.c b/src/emu/cpuintrf.c index 3896714ec3c..35e0c3ace6a 100644 --- a/src/emu/cpuintrf.c +++ b/src/emu/cpuintrf.c @@ -304,8 +304,8 @@ cpu_interface cpuintrf[CPU_COUNT]; static const struct { - int cputype; - void (*get_info)(UINT32 state, cpuinfo *info); + int cputype; + cpu_get_info_func get_info; } cpuintrf_map[] = { { CPU_DUMMY, CPU_GET_INFO_NAME(dummy) }, @@ -1062,43 +1062,43 @@ void cpuintrf_init(running_machine *machine) /* bootstrap the rest of the function pointers */ info.setinfo = NULL; - (*intf->get_info)(CPUINFO_PTR_SET_INFO, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_SET_INFO, &info); intf->set_info = info.setinfo; info.getcontext = NULL; - (*intf->get_info)(CPUINFO_PTR_GET_CONTEXT, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_GET_CONTEXT, &info); intf->get_context = info.getcontext; info.setcontext = NULL; - (*intf->get_info)(CPUINFO_PTR_SET_CONTEXT, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_SET_CONTEXT, &info); intf->set_context = info.setcontext; info.init = NULL; - (*intf->get_info)(CPUINFO_PTR_INIT, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_INIT, &info); intf->init = info.init; info.reset = NULL; - (*intf->get_info)(CPUINFO_PTR_RESET, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_RESET, &info); intf->reset = info.reset; info.exit = NULL; - (*intf->get_info)(CPUINFO_PTR_EXIT, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_EXIT, &info); intf->exit = info.exit; info.execute = NULL; - (*intf->get_info)(CPUINFO_PTR_EXECUTE, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_EXECUTE, &info); intf->execute = info.execute; info.burn = NULL; - (*intf->get_info)(CPUINFO_PTR_BURN, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_BURN, &info); intf->burn = info.burn; info.disassemble = NULL; - (*intf->get_info)(CPUINFO_PTR_DISASSEMBLE, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_DISASSEMBLE, &info); intf->disassemble = info.disassemble; info.translate = NULL; - (*intf->get_info)(CPUINFO_PTR_TRANSLATE, &info); + (*intf->get_info)(NULL, CPUINFO_PTR_TRANSLATE, &info); intf->translate = info.translate; /* get other miscellaneous stuff */ @@ -1215,7 +1215,7 @@ int cpuintrf_init_cpu(int cpunum, cpu_type cputype, int clock, const void *confi /* get the instruction count pointer */ info.icount = NULL; - (*cpudata->intf.get_info)(CPUINFO_PTR_INSTRUCTION_COUNTER, &info); + (*cpudata->intf.get_info)(cpudata->device, CPUINFO_PTR_INSTRUCTION_COUNTER, &info); cpudata->icount = info.icount; return 0; } @@ -1297,7 +1297,7 @@ INT64 cpu_get_info_int(const device_config *cpu, UINT32 state) VERIFY_CPU(cpu_get_info_int); cpu_push_context(cpu); info.i = 0; - (*cpudata->intf.get_info)(state, &info); + (*cpudata->intf.get_info)(cpu, state, &info); cpu_pop_context(); return info.i; } @@ -1310,7 +1310,7 @@ void *cpu_get_info_ptr(const device_config *cpu, UINT32 state) VERIFY_CPU(cpu_get_info_ptr); cpu_push_context(cpu); info.p = NULL; - (*cpudata->intf.get_info)(state, &info); + (*cpudata->intf.get_info)(cpu, state, &info); cpu_pop_context(); return info.p; } @@ -1323,7 +1323,7 @@ genf *cpu_get_info_fct(const device_config *cpu, UINT32 state) VERIFY_CPU(cpu_get_info_fct); cpu_push_context(cpu); info.f = NULL; - (*cpudata->intf.get_info)(state, &info); + (*cpudata->intf.get_info)(cpu, state, &info); cpu_pop_context(); return info.f; } @@ -1336,7 +1336,7 @@ const char *cpu_get_info_string(const device_config *cpu, UINT32 state) VERIFY_CPU(cpu_get_info_string); cpu_push_context(cpu); info.s = cpuintrf_temp_str(); - (*cpudata->intf.get_info)(state, &info); + (*cpudata->intf.get_info)(cpu, state, &info); cpu_pop_context(); return info.s; } @@ -1354,7 +1354,7 @@ void cpu_set_info_int(const device_config *cpu, UINT32 state, INT64 data) VERIFY_CPU(cpu_set_info_int); info.i = data; cpu_push_context(cpu); - (*cpudata->intf.set_info)(state, &info); + (*cpudata->intf.set_info)(cpu, state, &info); cpu_pop_context(); } @@ -1366,7 +1366,7 @@ void cpu_set_info_ptr(const device_config *cpu, UINT32 state, void *data) VERIFY_CPU(cpu_set_info_ptr); info.p = data; cpu_push_context(cpu); - (*cpudata->intf.set_info)(state, &info); + (*cpudata->intf.set_info)(cpu, state, &info); cpu_pop_context(); } @@ -1378,7 +1378,7 @@ void cpu_set_info_fct(const device_config *cpu, UINT32 state, genf *data) VERIFY_CPU(cpu_set_info_ptr); info.f = data; cpu_push_context(cpu); - (*cpudata->intf.set_info)(state, &info); + (*cpudata->intf.set_info)(cpu, state, &info); cpu_pop_context(); } @@ -1470,7 +1470,7 @@ offs_t cpu_get_physical_pc_byte(const device_config *cpu) else pc >>= shift; if (cpudata->intf.translate != NULL) - (cpudata->intf.translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &pc); + (cpudata->intf.translate)(cpu, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH, &pc); cpu_pop_context(); return pc; } @@ -1566,7 +1566,7 @@ INT64 cputype_get_info_int(cpu_type cputype, UINT32 state) VERIFY_CPUTYPE(cputype_get_info_int); info.i = 0; - (*cpuintrf[cputype].get_info)(state, &info); + (*cpuintrf[cputype].get_info)(NULL, state, &info); return info.i; } @@ -1576,7 +1576,7 @@ void *cputype_get_info_ptr(cpu_type cputype, UINT32 state) VERIFY_CPUTYPE(cputype_get_info_ptr); info.p = NULL; - (*cpuintrf[cputype].get_info)(state, &info); + (*cpuintrf[cputype].get_info)(NULL, state, &info); return info.p; } @@ -1586,7 +1586,7 @@ genf *cputype_get_info_fct(cpu_type cputype, UINT32 state) VERIFY_CPUTYPE(cputype_get_info_fct); info.f = NULL; - (*cpuintrf[cputype].get_info)(state, &info); + (*cpuintrf[cputype].get_info)(NULL, state, &info); return info.f; } @@ -1596,7 +1596,7 @@ const char *cputype_get_info_string(cpu_type cputype, UINT32 state) VERIFY_CPUTYPE(cputype_get_info_string); info.s = cpuintrf_temp_str(); - (*cpuintrf[cputype].get_info)(state, &info); + (*cpuintrf[cputype].get_info)(NULL, state, &info); return info.s; } diff --git a/src/emu/cpuintrf.h b/src/emu/cpuintrf.h index b7f4a56e4fa..b3927b75853 100644 --- a/src/emu/cpuintrf.h +++ b/src/emu/cpuintrf.h @@ -207,20 +207,12 @@ enum ***************************************************************************/ #define CPU_GET_INFO_NAME(name) cpu_get_info_##name -#define CPU_GET_INFO(name) void CPU_GET_INFO_NAME(name)(UINT32 state, cpuinfo *info) -#define CPU_GET_INFO_CALL(name) CPU_GET_INFO_NAME(name)(state, info) +#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) #define CPU_SET_INFO_NAME(name) cpu_set_info_##name -#define CPU_SET_INFO(name) void CPU_SET_INFO_NAME(name)(UINT32 state, cpuinfo *info) -#define CPU_SET_INFO_CALL(name) CPU_SET_INFO_NAME(name)(state, info) - -#define CPU_GET_CONTEXT_NAME(name) cpu_get_context_##name -#define CPU_GET_CONTEXT(name) void CPU_GET_CONTEXT_NAME(name)(void *dst) -#define CPU_GET_CONTEXT_CALL(name) CPU_GET_CONTEXT_NAME(name)(buffer) - -#define CPU_SET_CONTEXT_NAME(name) cpu_set_context_##name -#define CPU_SET_CONTEXT(name) void CPU_SET_CONTEXT_NAME(name)(void *src) -#define CPU_SET_CONTEXT_CALL(name) CPU_SET_CONTEXT_NAME(name)(buffer) +#define CPU_SET_INFO(name) void CPU_SET_INFO_NAME(name)(const device_config *device, UINT32 state, cpuinfo *info) +#define CPU_SET_INFO_CALL(name) CPU_SET_INFO_NAME(name)(device, state, info) #define CPU_INIT_NAME(name) cpu_init_##name #define CPU_INIT(name) void CPU_INIT_NAME(name)(const device_config *device, int index, int clock, cpu_irq_callback irqcallback) @@ -242,34 +234,42 @@ enum #define CPU_BURN(name) void CPU_BURN_NAME(name)(const device_config *device, int cycles) #define CPU_BURN_CALL(name) CPU_BURN_NAME(name)(device, cycles) -#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name -#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) -#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(buffer, pc, oprom, opram) - #define CPU_TRANSLATE_NAME(name) cpu_translate_##name -#define CPU_TRANSLATE(name) int CPU_TRANSLATE_NAME(name)(int space, int intention, offs_t *address) -#define CPU_TRANSLATE_CALL(name) CPU_TRANSLATE_NAME(name)(space, intention, address) +#define CPU_TRANSLATE(name) int CPU_TRANSLATE_NAME(name)(const device_config *device, int space, int intention, offs_t *address) +#define CPU_TRANSLATE_CALL(name) CPU_TRANSLATE_NAME(name)(device, space, intention, address) #define CPU_READ_NAME(name) cpu_read_##name -#define CPU_READ(name) int CPU_READ_NAME(name)(int space, UINT32 offset, int size, UINT64 *value) -#define CPU_READ_CALL(name) CPU_READ_NAME(name)(space, offset, size, value) +#define CPU_READ(name) int CPU_READ_NAME(name)(const device_config *device, int space, UINT32 offset, int size, UINT64 *value) +#define CPU_READ_CALL(name) CPU_READ_NAME(name)(device, space, offset, size, value) #define CPU_WRITE_NAME(name) cpu_write_##name -#define CPU_WRITE(name) int CPU_WRITE_NAME(name)(int space, UINT32 offset, int size, UINT64 value) -#define CPU_WRITE_CALL(name) CPU_WRITE_NAME(name)(space, offset, size, value) +#define CPU_WRITE(name) int CPU_WRITE_NAME(name)(const device_config *device, int space, UINT32 offset, int size, UINT64 value) +#define CPU_WRITE_CALL(name) CPU_WRITE_NAME(name)(device, space, offset, size, value) #define CPU_READOP_NAME(name) cpu_readop_##name -#define CPU_READOP(name) int CPU_READOP_NAME(name)(UINT32 offset, int size, UINT64 *value) -#define CPU_READOP_CALL(name) CPU_READOP_NAME(name)(offset, size, value) +#define CPU_READOP(name) int CPU_READOP_NAME(name)(const device_config *device, UINT32 offset, int size, UINT64 *value) +#define CPU_READOP_CALL(name) CPU_READOP_NAME(name)(device, offset, size, value) #define CPU_DEBUG_INIT_NAME(name) cpu_debug_init_##name -#define CPU_DEBUG_INIT(name) void CPU_DEBUG_INIT_NAME(name)(void) -#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)() +#define CPU_DEBUG_INIT(name) void CPU_DEBUG_INIT_NAME(name)(const device_config *device) +#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)(device) + +#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name +#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) +#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(buffer, pc, oprom, opram) #define CPU_VALIDITY_CHECK_NAME(name) cpu_validity_check_##name #define CPU_VALIDITY_CHECK(name) int CPU_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const void *config) #define CPU_VALIDITY_CHECK_CALL(name) CPU_VALIDITY_CHECK_NAME(name)(driver, config) +#define CPU_GET_CONTEXT_NAME(name) cpu_get_context_##name +#define CPU_GET_CONTEXT(name) void CPU_GET_CONTEXT_NAME(name)(void *dst) +#define CPU_GET_CONTEXT_CALL(name) CPU_GET_CONTEXT_NAME(name)(buffer) + +#define CPU_SET_CONTEXT_NAME(name) cpu_set_context_##name +#define CPU_SET_CONTEXT(name) void CPU_SET_CONTEXT_NAME(name)(void *src) +#define CPU_SET_CONTEXT_CALL(name) CPU_SET_CONTEXT_NAME(name)(buffer) + /*************************************************************************** @@ -283,22 +283,23 @@ typedef union _cpuinfo cpuinfo; /* define the various callback functions */ typedef int (*cpu_irq_callback)(const device_config *device, int irqnum); -typedef void (*cpu_get_info_func)(UINT32 state, cpuinfo *info); -typedef void (*cpu_set_info_func)(UINT32 state, cpuinfo *info); -typedef void (*cpu_get_context_func)(void *buffer); -typedef void (*cpu_set_context_func)(void *buffer); +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, int index, int clock, cpu_irq_callback irqcallback); typedef void (*cpu_reset_func)(const device_config *device); typedef void (*cpu_exit_func)(const device_config *device); typedef int (*cpu_execute_func)(const device_config *device, int cycles); typedef void (*cpu_burn_func)(const device_config *device, int cycles); -typedef offs_t (*cpu_disassemble_func)(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -typedef int (*cpu_translate_func)(int space, int intention, offs_t *address); -typedef int (*cpu_read_func)(int space, UINT32 offset, int size, UINT64 *value); -typedef int (*cpu_write_func)(int space, UINT32 offset, int size, UINT64 value); -typedef int (*cpu_readop_func)(UINT32 offset, int size, UINT64 *value); -typedef void (*cpu_debug_init_func)(void); +typedef int (*cpu_translate_func)(const device_config *device, int space, int intention, offs_t *address); +typedef int (*cpu_read_func)(const device_config *device, int space, UINT32 offset, int size, UINT64 *value); +typedef int (*cpu_write_func)(const device_config *device, int space, UINT32 offset, int size, UINT64 value); +typedef int (*cpu_readop_func)(const device_config *device, UINT32 offset, int size, UINT64 *value); +typedef void (*cpu_debug_init_func)(const device_config *device); + typedef int (*cpu_validity_check_func)(const game_driver *driver, const void *config); +typedef offs_t (*cpu_disassemble_func)(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); +typedef void (*cpu_get_context_func)(void *buffer); +typedef void (*cpu_set_context_func)(void *buffer); /* cpuinfo union used to pass data to/from the get_info/set_info functions */ @@ -317,12 +318,12 @@ union _cpuinfo cpu_exit_func exit; /* CPUINFO_PTR_EXIT */ cpu_execute_func execute; /* CPUINFO_PTR_EXECUTE */ cpu_burn_func burn; /* CPUINFO_PTR_BURN */ - cpu_disassemble_func disassemble; /* CPUINFO_PTR_DISASSEMBLE */ cpu_translate_func translate; /* CPUINFO_PTR_TRANSLATE */ cpu_read_func read; /* CPUINFO_PTR_READ */ cpu_write_func write; /* CPUINFO_PTR_WRITE */ cpu_readop_func readop; /* CPUINFO_PTR_READOP */ cpu_debug_init_func debug_init; /* CPUINFO_PTR_DEBUG_INIT */ + cpu_disassemble_func disassemble; /* CPUINFO_PTR_DISASSEMBLE */ cpu_validity_check_func validity_check; /* CPUINFO_PTR_VALIDITY_CHECK */ int * icount; /* CPUINFO_PTR_INSTRUCTION_COUNTER */ const addrmap8_token * internal_map8; /* CPUINFO_PTR_INTERNAL_MEMORY_MAP */ @@ -345,8 +346,8 @@ struct _cpu_interface cpu_exit_func exit; cpu_execute_func execute; cpu_burn_func burn; - cpu_disassemble_func disassemble; cpu_translate_func translate; + cpu_disassemble_func disassemble; /* other info */ size_t context_size; diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index 8b338293572..6af1780db6b 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -250,7 +250,7 @@ void debug_command_init(running_machine *machine) cpu_debug_init_func debug_init; debug_init = cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_DEBUG_INIT); if (debug_init != NULL) - (*debug_init)(); + (*debug_init)(machine->cpu[cpunum]); } add_exit_callback(machine, debug_command_exit); @@ -1498,7 +1498,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch if (i + j <= endoffset) { offs_t curaddr = i + j; - if (info->translate == NULL || (*info->translate)(spacenum, TRANSLATE_READ, &curaddr)) + if (info->translate == NULL || (*info->translate)(info->device, spacenum, TRANSLATE_READ, &curaddr)) { UINT8 byte = debug_read_byte(ref, i + j, TRUE); outdex += sprintf(&output[outdex], " %02X", byte); @@ -1517,7 +1517,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch if (i + j <= endoffset) { offs_t curaddr = i + j; - if (info->translate == NULL || (*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + if (info->translate == NULL || (*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT16 word = debug_read_word(ref, i + j, TRUE); outdex += sprintf(&output[outdex], " %04X", word); @@ -1536,7 +1536,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch if (i + j <= endoffset) { offs_t curaddr = i + j; - if (info->translate == NULL || (*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + if (info->translate == NULL || (*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT32 dword = debug_read_dword(ref, i + j, TRUE); outdex += sprintf(&output[outdex], " %08X", dword); @@ -1555,7 +1555,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch if (i + j <= endoffset) { offs_t curaddr = i + j; - if (info->translate == NULL || (*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + if (info->translate == NULL || (*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT64 qword = debug_read_qword(ref, i + j, TRUE); outdex += sprintf(&output[outdex], " %08X%08X", (UINT32)(qword >> 32), (UINT32)qword); @@ -1576,7 +1576,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 (info->translate == NULL || (*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + if (info->translate == NULL || (*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT8 byte = debug_read_byte(ref, i + j, TRUE); outdex += sprintf(&output[outdex], "%c", (byte >= 32 && byte < 128) ? byte : '.'); @@ -1767,7 +1767,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch /* make sure we can translate the address */ tempaddr = pcbyte; - if (info->translate == NULL || (*info->translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &tempaddr)) + if (info->translate == NULL || (*info->translate)(info->device, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &tempaddr)) { UINT8 opbuf[64], argbuf[64]; @@ -2077,7 +2077,7 @@ static void execute_map(running_machine *machine, int ref, int params, const cha taddress = ADDR2BYTE_MASKED(address, info, spacenum); if (info->translate != NULL) { - if ((*info->translate)(spacenum, intention, &taddress)) + if ((*info->translate)(info->device, spacenum, intention, &taddress)) { const char *mapname = memory_get_handler_string(intention == TRANSLATE_WRITE_DEBUG, cpunum, spacenum, taddress); debug_console_printf("%7s: %08X logical == %08X physical -> %s\n", intnames[intention & 3], (UINT32)address, BYTE2ADDR(taddress, info, spacenum), mapname); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 9c4bd904ecc..8a67d3b8588 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -226,14 +226,15 @@ void debug_cpu_init(running_machine *machine) /* reset the PC data */ info->valid = TRUE; info->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; - info->endianness = cpu_get_endianness(machine->cpu[cpunum]); - info->opwidth = cpu_get_min_opcode_bytes(machine->cpu[cpunum]); + info->device = machine->cpu[cpunum]; + info->endianness = cpu_get_endianness(info->device); + info->opwidth = cpu_get_min_opcode_bytes(info->device); /* fetch the memory accessors */ - info->translate = (cpu_translate_func)cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_TRANSLATE); - info->read = (cpu_read_func)cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_READ); - info->write = (cpu_write_func)cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_WRITE); - info->readop = (cpu_readop_func)cpu_get_info_fct(machine->cpu[cpunum], CPUINFO_PTR_READOP); + info->translate = (cpu_translate_func)cpu_get_info_fct(info->device, CPUINFO_PTR_TRANSLATE); + info->read = (cpu_read_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READ); + info->write = (cpu_write_func)cpu_get_info_fct(info->device, CPUINFO_PTR_WRITE); + info->readop = (cpu_readop_func)cpu_get_info_fct(info->device, CPUINFO_PTR_READOP); /* allocate a symbol table */ info->symtable = symtable_alloc(global_symtable); @@ -244,7 +245,7 @@ void debug_cpu_init(running_machine *machine) /* add all registers into it */ for (regnum = 0; regnum < MAX_REGS; regnum++) { - const char *str = cpu_get_reg_string(machine->cpu[cpunum], regnum); + const char *str = cpu_get_reg_string(info->device, regnum); const char *colon; char symname[256]; int charnum; @@ -272,11 +273,11 @@ void debug_cpu_init(running_machine *machine) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { debug_space_info *spaceinfo = &info->space[spacenum]; - int datawidth = cpu_get_databus_width(machine->cpu[cpunum], spacenum); - int logwidth = cpu_get_logaddr_width(machine->cpu[cpunum], spacenum); - int physwidth = cpu_get_addrbus_width(machine->cpu[cpunum], spacenum); - int addrshift = cpu_get_addrbus_shift(machine->cpu[cpunum], spacenum); - int pageshift = cpu_get_page_shift(machine->cpu[cpunum], spacenum); + int datawidth = cpu_get_databus_width(info->device, spacenum); + int logwidth = cpu_get_logaddr_width(info->device, spacenum); + int physwidth = cpu_get_addrbus_width(info->device, spacenum); + int addrshift = cpu_get_addrbus_shift(info->device, spacenum); + int pageshift = cpu_get_page_shift(info->device, spacenum); if (logwidth == 0) logwidth = physwidth; @@ -1678,11 +1679,11 @@ UINT8 debug_read_byte(int spacenum, offs_t address, int apply_translation) memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xff */ - if (apply_translation && info->translate != NULL && !(*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && info->translate != NULL && !(*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &address)) result = 0xff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info->read && (*info->read)(spacenum, address, 1, &custom)) + else if (info->read && (*info->read)(info->device, spacenum, address, 1, &custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1729,11 +1730,11 @@ UINT16 debug_read_word(int spacenum, offs_t address, int apply_translation) memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffff */ - if (apply_translation && info->translate != NULL && !(*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && info->translate != NULL && !(*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &address)) result = 0xffff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info->read && (*info->read)(spacenum, address, 2, &custom)) + else if (info->read && (*info->read)(info->device, spacenum, address, 2, &custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1782,11 +1783,11 @@ UINT32 debug_read_dword(int spacenum, offs_t address, int apply_translation) memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffffffff */ - if (apply_translation && info->translate != NULL && !(*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && info->translate != NULL && !(*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &address)) result = 0xffffffff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info->read && (*info->read)(spacenum, address, 4, &custom)) + else if (info->read && (*info->read)(info->device, spacenum, address, 4, &custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1835,11 +1836,11 @@ UINT64 debug_read_qword(int spacenum, offs_t address, int apply_translation) memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, return 0xffffffffffffffff */ - if (apply_translation && info->translate != NULL && !(*info->translate)(spacenum, TRANSLATE_READ_DEBUG, &address)) + if (apply_translation && info->translate != NULL && !(*info->translate)(info->device, spacenum, TRANSLATE_READ_DEBUG, &address)) result = ~(UINT64)0; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info->read && (*info->read)(spacenum, address, 8, &custom)) + else if (info->read && (*info->read)(info->device, spacenum, address, 8, &custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1870,11 +1871,11 @@ void debug_write_byte(int spacenum, offs_t address, UINT8 data, int apply_transl memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && info->translate != NULL && !(*info->translate)(spacenum, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && info->translate != NULL && !(*info->translate)(info->device, spacenum, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info->write && (*info->write)(spacenum, address, 1, data)) + else if (info->write && (*info->write)(info->device, spacenum, address, 1, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1921,11 +1922,11 @@ void debug_write_word(int spacenum, offs_t address, UINT16 data, int apply_trans memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && info->translate && !(*info->translate)(spacenum, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && info->translate && !(*info->translate)(info->device, spacenum, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info->write && (*info->write)(spacenum, address, 2, data)) + else if (info->write && (*info->write)(info->device, spacenum, address, 2, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1973,11 +1974,11 @@ void debug_write_dword(int spacenum, offs_t address, UINT32 data, int apply_tran memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && info->translate && !(*info->translate)(spacenum, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && info->translate && !(*info->translate)(info->device, spacenum, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info->write && (*info->write)(spacenum, address, 4, data)) + else if (info->write && (*info->write)(info->device, spacenum, address, 4, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -2024,11 +2025,11 @@ void debug_write_qword(int spacenum, offs_t address, UINT64 data, int apply_tran memory_set_debugger_access(global.debugger_access = TRUE); /* translate if necessary; if not mapped, we're done */ - if (apply_translation && info->translate && !(*info->translate)(spacenum, TRANSLATE_WRITE_DEBUG, &address)) + if (apply_translation && info->translate && !(*info->translate)(info->device, spacenum, TRANSLATE_WRITE_DEBUG, &address)) ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info->write && (*info->write)(spacenum, address, 8, data)) + else if (info->write && (*info->write)(info->device, spacenum, address, 8, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -2060,7 +2061,7 @@ UINT64 debug_read_opcode(offs_t address, int size, int arg) if (info->readop) { UINT64 result; - if ((*info->readop)(address, size, &result)) + if ((*info->readop)(info->device, address, size, &result)) return result; } @@ -2078,7 +2079,7 @@ UINT64 debug_read_opcode(offs_t address, int size, int arg) } /* translate to physical first */ - if (info->translate && !(*info->translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &address)) + if (info->translate && !(*info->translate)(info->device, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &address)) return ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)); /* keep in physical range */ diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index d17a91c84c4..b32d478921e 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -165,6 +165,7 @@ struct _debug_cpu_info UINT32 pc_history_index; /* current history index */ int hotspot_count; /* number of hotspots */ int hotspot_threshhold; /* threshhold for the number of hits to print */ + const device_config *device; /* CPU device object */ cpu_translate_func translate; /* address translation routine */ cpu_read_func read; /* memory read routine */ cpu_write_func write; /* memory write routine */ diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 779bea8640b..d017906737c 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -1360,7 +1360,7 @@ static offs_t disasm_back_up(int cpunum, const debug_cpu_info *cpuinfo, offs_t s /* get the disassembly, but only if mapped */ instlen = 1; - if (cpuinfo->translate == NULL || (*cpuinfo->translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &pcbyte)) + if (cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &pcbyte)) instlen = cpu_dasm(Machine->activecpu, dasmbuffer, testpc & addrmask, &opbuf[1000 + testpc - startpc], &argbuf[1000 + testpc - startpc]) & DASMFLAG_LENGTHMASK; /* count this one */ @@ -1538,7 +1538,7 @@ static int disasm_recompute(debug_view *view, offs_t pc, int startline, int line /* make sure we can translate the address */ tempaddr = pcbyte; - if (cpuinfo->translate == NULL || (*cpuinfo->translate)(ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &tempaddr)) + if (cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, ADDRESS_SPACE_PROGRAM, TRANSLATE_FETCH_DEBUG, &tempaddr)) { UINT8 opbuf[64], argbuf[64]; @@ -2771,7 +2771,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], "%02X ", memory_read_byte(memdata, addrbyte + i, !memdata->no_translation)); else len += sprintf(&data[len], "** "); @@ -2785,7 +2785,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], " %04X ", memory_read_word(memdata, addrbyte + 2 * i, !memdata->no_translation)); else len += sprintf(&data[len], " **** "); @@ -2799,7 +2799,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], " %08X ", memory_read_dword(memdata, addrbyte + 4 * i, !memdata->no_translation)); else len += sprintf(&data[len], " ******** "); @@ -2813,7 +2813,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT64 qword = memory_read_qword(memdata, addrbyte + 8 * i, !memdata->no_translation); len += sprintf(&data[len], " %08X%08X ", (UINT32)(qword >> 32), (UINT32)qword); @@ -2867,7 +2867,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], "%02X ", memory_read_byte(memdata, addrbyte + i, !memdata->no_translation)); else len += sprintf(&data[len], "** "); @@ -2881,7 +2881,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], " %04X ", memory_read_word(memdata, addrbyte + 2 * i, !memdata->no_translation)); else len += sprintf(&data[len], " **** "); @@ -2895,7 +2895,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) len += sprintf(&data[len], " %08X ", memory_read_dword(memdata, addrbyte + 4 * i, !memdata->no_translation)); else len += sprintf(&data[len], " ******** "); @@ -2909,7 +2909,7 @@ static void memory_update(debug_view *view) if (curaddr > maxaddr) len += sprintf(&data[len], " "); else if (memdata->raw_base != NULL || memdata->no_translation || - cpuinfo->translate == NULL || (*cpuinfo->translate)(memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) + cpuinfo->translate == NULL || (*cpuinfo->translate)(cpuinfo->device, memdata->spacenum, TRANSLATE_READ_DEBUG, &curaddr)) { UINT64 qword = memory_read_qword(memdata, addrbyte + 8 * i, !memdata->no_translation); len += sprintf(&data[len], " %08X%08X ", (UINT32)(qword >> 32), (UINT32)qword); diff --git a/src/emu/sound/nes_apu.c b/src/emu/sound/nes_apu.c index 8470303732d..bb166136b84 100644 --- a/src/emu/sound/nes_apu.c +++ b/src/emu/sound/nes_apu.c @@ -366,7 +366,7 @@ static int8 apu_dpcm(struct nesapu_info *info, dpcm_t *chan) if (chan->regs[0] & 0x80) /* IRQ Generator */ { chan->irq_occurred = TRUE; - n2a03_irq(); + n2a03_irq(Machine->cpu[info->APU.dpcm.cpu_num]); } break; } diff --git a/src/mame/audio/dcs.c b/src/mame/audio/dcs.c index d0d85fac166..c51ad861eef 100644 --- a/src/mame/audio/dcs.c +++ b/src/mame/audio/dcs.c @@ -1409,7 +1409,7 @@ WRITE32_HANDLER( dsio_idma_addr_w ) if (LOG_DCS_TRANSFERS) logerror("%08X:IDMA_addr = %04X\n", cpu_get_pc(machine->activecpu), data); cpu_push_context(machine->cpu[dcs.cpunum]); - adsp2181_idma_addr_w(data); + adsp2181_idma_addr_w(machine->cpu[dcs.cpunum], data); if (data == 0) dsio.start_on_next_write = 2; cpu_pop_context(); @@ -1423,14 +1423,14 @@ WRITE32_HANDLER( dsio_idma_data_w ) if (ACCESSING_BITS_0_15) { if (LOG_DCS_TRANSFERS) - logerror("%08X:IDMA_data_w(%04X) = %04X\n", pc, adsp2181_idma_addr_r(), data & 0xffff); - adsp2181_idma_data_w(data & 0xffff); + logerror("%08X:IDMA_data_w(%04X) = %04X\n", pc, adsp2181_idma_addr_r(machine->cpu[dcs.cpunum]), data & 0xffff); + adsp2181_idma_data_w(machine->cpu[dcs.cpunum], data & 0xffff); } if (ACCESSING_BITS_16_31) { if (LOG_DCS_TRANSFERS) - logerror("%08X:IDMA_data_w(%04X) = %04X\n", pc, adsp2181_idma_addr_r(), data >> 16); - adsp2181_idma_data_w(data >> 16); + logerror("%08X:IDMA_data_w(%04X) = %04X\n", pc, adsp2181_idma_addr_r(machine->cpu[dcs.cpunum]), data >> 16); + adsp2181_idma_data_w(machine->cpu[dcs.cpunum], data >> 16); } cpu_pop_context(); if (dsio.start_on_next_write && --dsio.start_on_next_write == 0) @@ -1445,10 +1445,10 @@ READ32_HANDLER( dsio_idma_data_r ) { UINT32 result; cpu_push_context(machine->cpu[dcs.cpunum]); - result = adsp2181_idma_data_r(); + result = adsp2181_idma_data_r(machine->cpu[dcs.cpunum]); cpu_pop_context(); if (LOG_DCS_TRANSFERS) - logerror("%08X:IDMA_data_r(%04X) = %04X\n", cpu_get_pc(machine->activecpu), adsp2181_idma_addr_r(), result); + logerror("%08X:IDMA_data_r(%04X) = %04X\n", cpu_get_pc(machine->activecpu), adsp2181_idma_addr_r(machine->cpu[dcs.cpunum]), result); return result; } @@ -1818,7 +1818,7 @@ static READ16_HANDLER( adsp_control_r ) break; case IDMA_CONTROL_REG: - result = adsp2181_idma_addr_r(); + result = adsp2181_idma_addr_r(machine->cpu[dcs.cpunum]); break; case TIMER_COUNT_REG: @@ -1899,7 +1899,7 @@ static WRITE16_HANDLER( adsp_control_w ) break; case IDMA_CONTROL_REG: - adsp2181_idma_addr_w(data); + adsp2181_idma_addr_w(machine->cpu[dcs.cpunum], data); break; } } diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index 10bd414469a..f209b83f1e2 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -172,7 +172,7 @@ static UINT32 copro_fifoout_pop(void) if (copro_fifoout_num == 0) { /* Reading from empty FIFO causes the i960 to enter wait state */ - i960_stall(); + i960_stall(Machine->activecpu); /* spin the main cpu and let the TGP catch up */ cpu_spinuntil_time(ATTOTIME_IN_USEC(100)); @@ -278,7 +278,7 @@ static NVRAM_HANDLER( model2 ) /* Timers - these count down at 25 MHz and pull IRQ2 when they hit 0 */ static READ32_HANDLER( timers_r ) { - i960_noburst(); + i960_noburst(machine->activecpu); // if timer is running, calculate current value if (model2_timerrun[offset]) @@ -297,7 +297,7 @@ static WRITE32_HANDLER( timers_w ) { attotime period; - i960_noburst(); + i960_noburst(machine->activecpu); COMBINE_DATA(&model2_timervals[offset]); model2_timerorig[offset] = model2_timervals[offset]; @@ -874,7 +874,7 @@ static READ32_HANDLER(desert_unk_r) static READ32_HANDLER(model2_irq_r) { - i960_noburst(); + i960_noburst(machine->activecpu); if (offset) { @@ -886,7 +886,7 @@ static READ32_HANDLER(model2_irq_r) static WRITE32_HANDLER(model2_irq_w) { - i960_noburst(); + i960_noburst(machine->activecpu); if (offset) { |