Fixed handling of interrupts when the CPU was in the STOP state.

This commit is contained in:
Aaron Giles 2008-10-02 05:31:24 +00:00
parent 18c6cfb56a
commit cf63e2baa8
2 changed files with 12 additions and 27 deletions

View File

@ -782,20 +782,17 @@ void m68k_set_cpu_type(unsigned int cpu_type)
/* Execute some instructions until we use up num_cycles clock cycles */ /* Execute some instructions until we use up num_cycles clock cycles */
/* ASG: removed per-instruction interrupt checks */ /* ASG: removed per-instruction interrupt checks */
int m68k_execute(int num_cycles) int m68k_execute(int num_cycles)
{
/* Make sure we're not stopped */
if(!CPU_STOPPED)
{ {
/* Set our pool of clock cycles available */ /* Set our pool of clock cycles available */
SET_CYCLES(num_cycles); SET_CYCLES(num_cycles);
m68ki_initial_cycles = num_cycles; m68ki_initial_cycles = num_cycles;
/* See if interrupts came in */
m68ki_check_interrupts(); m68ki_check_interrupts();
/* ASG: update cycles */ /* Make sure we're not stopped */
USE_CYCLES(CPU_INT_CYCLES); if(!CPU_STOPPED)
CPU_INT_CYCLES = 0; {
/* Return point if we had an address error */ /* Return point if we had an address error */
m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */ m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */
@ -825,22 +822,14 @@ int m68k_execute(int num_cycles)
/* set previous PC to current PC for the next entry into the loop */ /* set previous PC to current PC for the next entry into the loop */
REG_PPC = REG_PC; REG_PPC = REG_PC;
}
/* ASG: update cycles */ else
USE_CYCLES(CPU_INT_CYCLES); SET_CYCLES(0);
CPU_INT_CYCLES = 0;
/* return how many clocks we used */ /* return how many clocks we used */
return m68ki_initial_cycles - GET_CYCLES(); return m68ki_initial_cycles - GET_CYCLES();
} }
/* We get here if the CPU is stopped or halted */
SET_CYCLES(0);
CPU_INT_CYCLES = 0;
return num_cycles;
}
int m68k_cycles_run(void) int m68k_cycles_run(void)
{ {
@ -1034,7 +1023,6 @@ void m68k_state_register(const char *type, int index)
state_save_register_item(type, index, REG_CAAR); state_save_register_item(type, index, REG_CAAR);
state_save_register_item(type, index, m68k_substate.sr); state_save_register_item(type, index, m68k_substate.sr);
state_save_register_item(type, index, CPU_INT_LEVEL); state_save_register_item(type, index, CPU_INT_LEVEL);
state_save_register_item(type, index, CPU_INT_CYCLES);
state_save_register_item(type, index, m68k_substate.stopped); state_save_register_item(type, index, m68k_substate.stopped);
state_save_register_item(type, index, m68k_substate.halted); state_save_register_item(type, index, m68k_substate.halted);
state_save_register_item(type, index, CPU_PREF_ADDR); state_save_register_item(type, index, CPU_PREF_ADDR);

View File

@ -333,7 +333,6 @@
#define FLAG_INT_MASK m68ki_cpu.int_mask #define FLAG_INT_MASK m68ki_cpu.int_mask
#define CPU_INT_LEVEL m68ki_cpu.int_level /* ASG: changed from CPU_INTS_PENDING */ #define CPU_INT_LEVEL m68ki_cpu.int_level /* ASG: changed from CPU_INTS_PENDING */
#define CPU_INT_CYCLES m68ki_cpu.int_cycles /* ASG */
#define CPU_STOPPED m68ki_cpu.stopped #define CPU_STOPPED m68ki_cpu.stopped
#define CPU_PREF_ADDR m68ki_cpu.pref_addr #define CPU_PREF_ADDR m68ki_cpu.pref_addr
#define CPU_PREF_DATA m68ki_cpu.pref_data #define CPU_PREF_DATA m68ki_cpu.pref_data
@ -562,7 +561,6 @@
if(CPU_STOPPED) \ if(CPU_STOPPED) \
{ \ { \
SET_CYCLES(0); \ SET_CYCLES(0); \
CPU_INT_CYCLES = 0; \
return m68ki_initial_cycles; \ return m68ki_initial_cycles; \
} \ } \
} }
@ -877,7 +875,6 @@ struct _m68ki_cpu_core
uint c_flag; /* Carry */ uint c_flag; /* Carry */
uint int_mask; /* I0-I2 */ uint int_mask; /* I0-I2 */
uint int_level; /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */ uint int_level; /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */
uint int_cycles; /* ASG: extra cycles from generated interrupts */
uint stopped; /* Stopped state */ uint stopped; /* Stopped state */
uint pref_addr; /* Last prefetch address */ uint pref_addr; /* Last prefetch address */
uint pref_data; /* Data in the prefetch queue */ uint pref_data; /* Data in the prefetch queue */
@ -2027,7 +2024,7 @@ void m68ki_exception_interrupt(uint int_level)
m68ki_jump(new_pc); m68ki_jump(new_pc);
/* Defer cycle counting until later */ /* Defer cycle counting until later */
CPU_INT_CYCLES += CYC_EXCEPTION[vector]; USE_CYCLES(CYC_EXCEPTION[vector]);
#if !M68K_EMULATE_INT_ACK #if !M68K_EMULATE_INT_ACK
/* Automatically clear IRQ if we are not using an acknowledge scheme */ /* Automatically clear IRQ if we are not using an acknowledge scheme */