Removed save_device pattern if favor of just accepting the

device from the reset.
This commit is contained in:
Aaron Giles 2008-11-10 08:56:38 +00:00
parent 6f4ee44948
commit b5f1e96c98
20 changed files with 24 additions and 60 deletions

View File

@ -304,10 +304,9 @@ INLINE void SetRegister( int rIndex, UINT32 value )
static CPU_RESET( arm ) static CPU_RESET( arm )
{ {
cpu_irq_callback save_irqcallback = arm.irq_callback; cpu_irq_callback save_irqcallback = arm.irq_callback;
const device_config *save_device = arm.device;
memset(&arm, 0, sizeof(arm)); memset(&arm, 0, sizeof(arm));
arm.irq_callback = save_irqcallback; arm.irq_callback = save_irqcallback;
arm.device = save_device; arm.device = device;
/* start up in SVC mode with interrupts disabled. */ /* start up in SVC mode with interrupts disabled. */
R15 = eARM_MODE_SVC|I_MASK|F_MASK; R15 = eARM_MODE_SVC|I_MASK|F_MASK;

View File

@ -103,7 +103,7 @@ static CPU_INIT( arm7 )
static CPU_RESET( arm7 ) static CPU_RESET( arm7 )
{ {
// must call core reset // must call core reset
arm7_core_reset(); arm7_core_reset(device);
} }
static CPU_EXIT( arm7 ) static CPU_EXIT( arm7 )

View File

@ -520,14 +520,13 @@ static void arm7_core_init(const char *cpuname, int index)
} }
// CPU RESET // CPU RESET
static void arm7_core_reset(void) static void arm7_core_reset(const device_config *device)
{ {
cpu_irq_callback save_irqcallback = ARM7.irq_callback; cpu_irq_callback save_irqcallback = ARM7.irq_callback;
const device_config *save_device = ARM7.device;
memset(&ARM7, 0, sizeof(ARM7)); memset(&ARM7, 0, sizeof(ARM7));
ARM7.irq_callback = save_irqcallback; ARM7.irq_callback = save_irqcallback;
ARM7.device = save_device; ARM7.device = device;
/* start up in SVC mode with interrupts disabled. */ /* start up in SVC mode with interrupts disabled. */
SwitchMode(eARM7_MODE_SVC); SwitchMode(eARM7_MODE_SVC);

View File

@ -1724,15 +1724,13 @@ static CPU_RESET( hyperstone )
//TODO: Add different reset initializations for BCR, MCR, FCR, TPR //TODO: Add different reset initializations for BCR, MCR, FCR, TPR
emu_timer *save_timer; emu_timer *save_timer;
const device_config *save_device;
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
save_timer = hyperstone.timer; save_timer = hyperstone.timer;
save_irqcallback = hyperstone.irq_callback; save_irqcallback = hyperstone.irq_callback;
save_device = hyperstone.device;
memset(&hyperstone, 0, sizeof(hyperstone_regs)); memset(&hyperstone, 0, sizeof(hyperstone_regs));
hyperstone.irq_callback = save_irqcallback; hyperstone.irq_callback = save_irqcallback;
hyperstone.device = save_device; hyperstone.device = device;
hyperstone.timer = save_timer; hyperstone.timer = save_timer;
hyperstone.tr_clocks_per_tick = 2; hyperstone.tr_clocks_per_tick = 2;

View File

@ -1536,13 +1536,11 @@ static CPU_RESET( f8 )
UINT8 data; UINT8 data;
int i; int i;
cpu_irq_callback save_callback; cpu_irq_callback save_callback;
const device_config *save_device;
save_callback = f8.irq_callback; save_callback = f8.irq_callback;
save_device = f8.device;
memset(&f8, 0, sizeof(f8_Regs)); memset(&f8, 0, sizeof(f8_Regs));
f8.irq_callback = save_callback; f8.irq_callback = save_callback;
f8.device = save_device; f8.device = device;
f8.w&=~I; f8.w&=~I;
/* save PC0 to PC1 and reset PC0 */ /* save PC0 to PC1 and reset PC0 */

View File

@ -193,15 +193,13 @@ static CPU_INIT( h6280 )
static CPU_RESET( h6280 ) static CPU_RESET( h6280 )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
int i; int i;
/* wipe out the h6280 structure */ /* wipe out the h6280 structure */
save_irqcallback = h6280.irq_callback; save_irqcallback = h6280.irq_callback;
save_device = h6280.device;
memset(&h6280, 0, sizeof(h6280_Regs)); memset(&h6280, 0, sizeof(h6280_Regs));
h6280.irq_callback = save_irqcallback; h6280.irq_callback = save_irqcallback;
h6280.device = save_device; h6280.device = device;
/* set I and B flags */ /* set I and B flags */
P = _fI | _fB; P = _fI | _fB;

View File

@ -616,13 +616,11 @@ static void build_opcode_table(UINT32 features)
static CPU_RESET( i386 ) static CPU_RESET( i386 )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
memset( &I, 0, sizeof(I386_REGS) ); memset( &I, 0, sizeof(I386_REGS) );
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.device = save_device; I.device = device;
I.sreg[CS].selector = 0xf000; I.sreg[CS].selector = 0xf000;
I.sreg[CS].base = 0xffff0000; I.sreg[CS].base = 0xffff0000;
@ -1074,13 +1072,11 @@ static CPU_INIT( i486 )
static CPU_RESET( i486 ) static CPU_RESET( i486 )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
memset( &I, 0, sizeof(I386_REGS) ); memset( &I, 0, sizeof(I386_REGS) );
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.device = save_device; I.device = device;
I.sreg[CS].selector = 0xf000; I.sreg[CS].selector = 0xf000;
I.sreg[CS].base = 0xffff0000; I.sreg[CS].base = 0xffff0000;
@ -1184,13 +1180,11 @@ static CPU_INIT( pentium )
static CPU_RESET( pentium ) static CPU_RESET( pentium )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
memset( &I, 0, sizeof(I386_REGS) ); memset( &I, 0, sizeof(I386_REGS) );
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.device = save_device; I.device = device;
I.sreg[CS].selector = 0xf000; I.sreg[CS].selector = 0xf000;
I.sreg[CS].base = 0xffff0000; I.sreg[CS].base = 0xffff0000;
@ -1314,13 +1308,11 @@ static CPU_INIT( mediagx )
static CPU_RESET( mediagx ) static CPU_RESET( mediagx )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
memset( &I, 0, sizeof(I386_REGS) ); memset( &I, 0, sizeof(I386_REGS) );
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.device = save_device; I.device = device;
I.sreg[CS].selector = 0xf000; I.sreg[CS].selector = 0xf000;
I.sreg[CS].base = 0xffff0000; I.sreg[CS].base = 0xffff0000;

View File

@ -1387,21 +1387,19 @@ static CPU_INIT( i8085 )
static CPU_RESET( i8085 ) static CPU_RESET( i8085 )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
void (*save_sodcallback)(int); void (*save_sodcallback)(int);
int (*save_sidcallback)(void); int (*save_sidcallback)(void);
int cputype_bak = I.cputype; int cputype_bak = I.cputype;
init_tables(); init_tables();
save_device = I.device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_sodcallback = I.sod_callback; save_sodcallback = I.sod_callback;
save_sidcallback = I.sid_callback; save_sidcallback = I.sid_callback;
memset(&I, 0, sizeof(i8085_Regs)); memset(&I, 0, sizeof(i8085_Regs));
I.device = save_device;
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.sod_callback = save_sodcallback; I.sod_callback = save_sodcallback;
I.sid_callback = save_sidcallback; I.sid_callback = save_sidcallback;
I.device = device;
change_pc(I.PC.d); change_pc(I.PC.d);
I.cputype = cputype_bak; I.cputype = cputype_bak;

View File

@ -160,16 +160,14 @@ static CPU_INIT( i8088 )
static CPU_RESET( i8086 ) static CPU_RESET( i8086 )
{ {
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
memory_interface save_mem; memory_interface save_mem;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
save_mem = I.mem; save_mem = I.mem;
memset(&I, 0, sizeof (I)); memset(&I, 0, sizeof (I));
I.device = save_device;
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.mem = save_mem; I.mem = save_mem;
I.device = device;
I.sregs[CS] = 0xf000; I.sregs[CS] = 0xf000;
I.base[CS] = SegBase(CS); I.base[CS] = SegBase(CS);

View File

@ -451,10 +451,9 @@ static CPU_INIT( m6805 )
static CPU_RESET( m6805 ) static CPU_RESET( m6805 )
{ {
cpu_irq_callback save_irqcallback = m6805.irq_callback; cpu_irq_callback save_irqcallback = m6805.irq_callback;
const device_config *save_device = m6805.device;
memset(&m6805, 0, sizeof(m6805)); memset(&m6805, 0, sizeof(m6805));
m6805.irq_callback = save_irqcallback; m6805.irq_callback = save_irqcallback;
m6805.device = save_device; m6805.device = device;
/* Force CPU sub-type and relevant masks */ /* Force CPU sub-type and relevant masks */
m6805.subtype = SUBTYPE_M6805; m6805.subtype = SUBTYPE_M6805;
SP_MASK = 0x07f; SP_MASK = 0x07f;

View File

@ -789,10 +789,9 @@ static CPU_INIT( s2650 )
static CPU_RESET( s2650 ) static CPU_RESET( s2650 )
{ {
cpu_irq_callback save_irqcallback = S.irq_callback; cpu_irq_callback save_irqcallback = S.irq_callback;
const device_config *save_device = S.device;
memset(&S, 0, sizeof(S)); memset(&S, 0, sizeof(S));
S.irq_callback = save_irqcallback; S.irq_callback = save_irqcallback;
S.device = save_device; S.device = device;
S.psl = COM | WC; S.psl = COM | WC;
S.psu = 0; S.psu = 0;
} }

View File

@ -1725,10 +1725,9 @@ static void BuildTable(void)
static CPU_RESET( SE3208 ) static CPU_RESET( SE3208 )
{ {
cpu_irq_callback save_irqcallback = Context.irq_callback; cpu_irq_callback save_irqcallback = Context.irq_callback;
const device_config *save_device = Context.device;
memset(&Context,0,sizeof(_SE3208Context)); memset(&Context,0,sizeof(_SE3208Context));
Context.irq_callback = save_irqcallback; Context.irq_callback = save_irqcallback;
Context.device = save_device; Context.device = device;
Context.PC=SE3208_Read32(0); Context.PC=SE3208_Read32(0);
Context.SR=0; Context.SR=0;
Context.IRQ=CLEAR_LINE; Context.IRQ=CLEAR_LINE;

View File

@ -2146,7 +2146,6 @@ static CPU_RESET( sh2 )
void (*f)(UINT32 data); void (*f)(UINT32 data);
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
cpunum = sh2->cpu_number; cpunum = sh2->cpu_number;
m = sh2->m; m = sh2->m;
@ -2156,7 +2155,6 @@ static CPU_RESET( sh2 )
f = sh2->ftcsr_read_callback; f = sh2->ftcsr_read_callback;
save_irqcallback = sh2->irq_callback; save_irqcallback = sh2->irq_callback;
save_device = sh2->device;
save_is_slave = sh2->is_slave; save_is_slave = sh2->is_slave;
dma_callback_kludge = sh2->dma_callback_kludge; dma_callback_kludge = sh2->dma_callback_kludge;
@ -2166,7 +2164,7 @@ static CPU_RESET( sh2 )
sh2->is_slave = save_is_slave; sh2->is_slave = save_is_slave;
sh2->ftcsr_read_callback = f; sh2->ftcsr_read_callback = f;
sh2->irq_callback = save_irqcallback; sh2->irq_callback = save_irqcallback;
sh2->device = save_device; sh2->device = device;
sh2->timer = tsave; sh2->timer = tsave;
sh2->dma_timer[0] = tsaved0; sh2->dma_timer[0] = tsaved0;

View File

@ -785,7 +785,6 @@ static CPU_RESET( sh2 )
void (*f)(UINT32 data); void (*f)(UINT32 data);
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
cpunum = sh2->cpu_number; cpunum = sh2->cpu_number;
m = sh2->m; m = sh2->m;
@ -795,7 +794,6 @@ static CPU_RESET( sh2 )
f = sh2->ftcsr_read_callback; f = sh2->ftcsr_read_callback;
save_irqcallback = sh2->irq_callback; save_irqcallback = sh2->irq_callback;
save_device = sh2->device;
sh2->ppc = sh2->pc = sh2->pr = sh2->sr = sh2->gbr = sh2->vbr = sh2->mach = sh2->macl = 0; sh2->ppc = sh2->pc = sh2->pr = sh2->sr = sh2->gbr = sh2->vbr = sh2->mach = sh2->macl = 0;
sh2->evec = sh2->irqsr = 0; sh2->evec = sh2->irqsr = 0;
@ -811,7 +809,7 @@ static CPU_RESET( sh2 )
sh2->ftcsr_read_callback = f; sh2->ftcsr_read_callback = f;
sh2->irq_callback = save_irqcallback; sh2->irq_callback = save_irqcallback;
sh2->device = save_device; sh2->device = device;
sh2->timer = tsave; sh2->timer = tsave;
sh2->dma_timer[0] = tsaved0; sh2->dma_timer[0] = tsaved0;

View File

@ -3248,7 +3248,6 @@ static CPU_RESET( sh4 )
void (*f)(UINT32 data); void (*f)(UINT32 data);
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
cpunum = sh4.cpu_number; cpunum = sh4.cpu_number;
m = sh4.m; m = sh4.m;
@ -3264,7 +3263,6 @@ static CPU_RESET( sh4 )
f = sh4.ftcsr_read_callback; f = sh4.ftcsr_read_callback;
save_irqcallback = sh4.irq_callback; save_irqcallback = sh4.irq_callback;
save_device = sh4.device;
save_is_slave = sh4.is_slave; save_is_slave = sh4.is_slave;
savecpu_clock = sh4.cpu_clock; savecpu_clock = sh4.cpu_clock;
savebus_clock = sh4.bus_clock; savebus_clock = sh4.bus_clock;
@ -3276,7 +3274,7 @@ static CPU_RESET( sh4 )
sh4.pm_clock = savepm_clock; sh4.pm_clock = savepm_clock;
sh4.ftcsr_read_callback = f; sh4.ftcsr_read_callback = f;
sh4.irq_callback = save_irqcallback; sh4.irq_callback = save_irqcallback;
sh4.device = save_device; sh4.device = device;
sh4.dma_timer[0] = tsaved[0]; sh4.dma_timer[0] = tsaved[0];
sh4.dma_timer[1] = tsaved[1]; sh4.dma_timer[1] = tsaved[1];

View File

@ -684,7 +684,6 @@ static CPU_RESET( tms34010 )
const device_config *screen = tms.screen; const device_config *screen = tms.screen;
UINT16 *shiftreg = tms.shiftreg; UINT16 *shiftreg = tms.shiftreg;
cpu_irq_callback save_irqcallback = tms.irq_callback; cpu_irq_callback save_irqcallback = tms.irq_callback;
const device_config *save_device = tms.device;
emu_timer *save_scantimer = tms.scantimer; emu_timer *save_scantimer = tms.scantimer;
memset(&tms, 0, sizeof(tms)); memset(&tms, 0, sizeof(tms));
@ -693,8 +692,8 @@ static CPU_RESET( tms34010 )
tms.screen = screen; tms.screen = screen;
tms.shiftreg = shiftreg; tms.shiftreg = shiftreg;
tms.irq_callback = save_irqcallback; tms.irq_callback = save_irqcallback;
tms.device = save_device;
tms.scantimer = save_scantimer; tms.scantimer = save_scantimer;
tms.device = device;
/* fetch the initial PC and reset the state */ /* fetch the initial PC and reset the state */
PC = RLONG(0xffffffe0) & 0xfffffff0; PC = RLONG(0xffffffe0) & 0xfffffff0;

View File

@ -1607,15 +1607,13 @@ static CPU_RESET( upd7810 )
{ {
UPD7810_CONFIG save_config; UPD7810_CONFIG save_config;
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_config = upd7810.config; save_config = upd7810.config;
save_irqcallback = upd7810.irq_callback; save_irqcallback = upd7810.irq_callback;
save_device = upd7810.device;
memset(&upd7810, 0, sizeof(upd7810)); memset(&upd7810, 0, sizeof(upd7810));
upd7810.config = save_config; upd7810.config = save_config;
upd7810.irq_callback = save_irqcallback; upd7810.irq_callback = save_irqcallback;
upd7810.device = save_device; upd7810.device = device;
upd7810.opXX = opXX_7810; upd7810.opXX = opXX_7810;
upd7810.op48 = op48; upd7810.op48 = op48;

View File

@ -112,13 +112,11 @@ static CPU_RESET( nec )
unsigned int i,j,c; unsigned int i,j,c;
static const BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH }; static const BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH };
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
save_irqcallback = I.irq_callback; save_irqcallback = I.irq_callback;
save_device = I.device;
memset( &I, 0, sizeof(I) ); memset( &I, 0, sizeof(I) );
I.irq_callback = save_irqcallback; I.irq_callback = save_irqcallback;
I.device = save_device; I.device = device;
I.sregs[CS] = 0xffff; I.sregs[CS] = 0xffff;

View File

@ -1940,7 +1940,6 @@ static CPU_RESET( z180 )
{ {
z80_daisy_state *save_daisy; z80_daisy_state *save_daisy;
cpu_irq_callback save_irqcallback; cpu_irq_callback save_irqcallback;
const device_config *save_device;
int i, p; int i, p;
#if BIG_FLAGS_ARRAY #if BIG_FLAGS_ARRAY
int oldval, newval, val; int oldval, newval, val;
@ -2021,7 +2020,6 @@ static CPU_RESET( z180 )
save_daisy = Z180.daisy; save_daisy = Z180.daisy;
save_irqcallback = Z180.irq_callback; save_irqcallback = Z180.irq_callback;
save_device = Z180.device;
memset(&Z180, 0, sizeof(Z180)); memset(&Z180, 0, sizeof(Z180));
Z180.daisy = save_daisy; Z180.daisy = save_daisy;
Z180.irq_callback = save_irqcallback; Z180.irq_callback = save_irqcallback;
@ -2040,6 +2038,7 @@ static CPU_RESET( z180 )
Z180.read_tcr_tmdr[1] = 0; Z180.read_tcr_tmdr[1] = 0;
Z180.tmdr_value[0] = 0xffff; Z180.tmdr_value[0] = 0xffff;
Z180.tmdr_value[1] = 0xffff; Z180.tmdr_value[1] = 0xffff;
Z180.device = device;
/* reset io registers */ /* reset io registers */
IO_CNTLA0 = Z180_CNTLA0_RESET; IO_CNTLA0 = Z180_CNTLA0_RESET;

View File

@ -463,10 +463,9 @@ INLINE void Interrupt(void)
static CPU_RESET( z8000 ) static CPU_RESET( z8000 )
{ {
cpu_irq_callback save_irqcallback = Z.irq_callback; cpu_irq_callback save_irqcallback = Z.irq_callback;
const device_config *save_device = Z.device;
memset(&Z, 0, sizeof(z8000_Regs)); memset(&Z, 0, sizeof(z8000_Regs));
Z.irq_callback = save_irqcallback; Z.irq_callback = save_irqcallback;
Z.device = save_device; Z.device = device;
FCW = RDMEM_W( 2 ); /* get reset FCW */ FCW = RDMEM_W( 2 ); /* get reset FCW */
PC = RDMEM_W( 4 ); /* get reset PC */ PC = RDMEM_W( 4 ); /* get reset PC */
change_pc(PC); change_pc(PC);