[PATCH sh4: system emulator interrupt update
Hi everyone,
This patch updates the interrupt and exception code for the sh4 system emulator. Together with the delay slot patch posted yesterday this patch implements working interrupts for the sh4 system emulator. There are unfortunately no sources that actually hook up to the interrupt controller yet - will post a patch for sh_timer in the near future. Changes included in this patch:
- sh_intc now fully emulates intc registers and deliver interrupts
- do_interrupt() is updated to hook in sh_intc interrupts
- code to call do_interrupt() for sh4 is added in cpu-exec.c
- exception updates for do_interrupt() - masking etc
- trapa instruction immediate data fix
cpu-exec.c | 5 +- hw/sh7750.c | 2 hw/sh_intc.c | 123 +++++++++++++++++++++++++++++++++++++++------------ hw/sh_intc.h | 8 ++- target-sh4/cpu.h | 1 target-sh4/helper.c | 75 ++++++++++++++++++++++++------- target-sh4/op.c | 2 7 files changed, 169 insertions(+), 47 deletions(-)
Please apply.
/ magnus
cpu-exec.c +4 -1
@@ -511,7 +511,10 @@ int cpu_exec(CPUState *env1) BREAK_CHAIN; }#elif defined(TARGET_SH4) -/* XXXXX */ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +do_interrupt (env); +BREAK_CHAIN ; + }#elif defined(TARGET_ALPHA)if (interrupt_request &CPU_INTERRUPT_HARD ) {do_interrupt (env);
hw/sh7750.c +2 -0
@@ -551,6 +551,8 @@ SH7750State *sh7750_init(CPUSH4State * c_INTC_ARRAY (vectors), _INTC_ARRAY(groups)); + cpu->intc_handle = &s->intc; +sh_serial_init (0x1fe00000 ,0 , s->periph_freq, serial_hds[0 ]);sh_serial_init (0x1fe80000 ,SH_SERIAL_FEAT_SCIF , s->periph_freq, serial_hds[1 ]);
hw/sh_intc.c +96 -27
188 lines not on this page · raw message
hw/sh_intc.h +7 -1
@@ -35,9 +35,11 @@ struct intc_source {unsigned short vect;intc_enum next_enum_id; -int asserted; +int asserted;/* emulates the interrupt signal line from device to intc */ int enable_count;int enable_max; +int pending;/* emulates the result of signal and masking */ +struct intc_desc *parent; };struct intc_desc {
@@ -49,9 +51,13 @@ struct intc_desc {int nr_prio_regs;int iomemtype; +int pending;/* number of interrupt sources that has pending set */ }; +int sh_intc_get_pending_vector (struct intc_desc *desc,int imask);struct intc_source *sh_intc_source (struct intc_desc *desc,intc_enum id); +void sh_intc_toggle_source (struct intc_source *source, +int enable_adj,int assert_adj); void sh_intc_register_sources(struct intc_desc *desc, struct intc_vect *vectors,
target-sh4/cpu.h +1 -0
@@ -121,6 +121,7 @@ typedef struct CPUSH4State {int exception_index; CPU_COMMON tlb_t utlb[UTLB_SIZE]; /* unified translation table */tlb_t itlb[ITLB_SIZE ];/* instruction translation table */ +void *intc_handle; } CPUSH4State;CPUSH4State *cpu_sh4_init (const char *cpu_model);
target-sh4/helper.c +58 -17
102 lines not on this page · raw message
target-sh4/op.c +1 -1
@@ -419,7 +419,7 @@ void OPPROTO op_subv_T0_T1(void) void OPPROTO op_trapa(void) { - env->tra =PARAM1 *2 ; + env->tra =PARAM1 <<2 ; env->exception_index =0x160 ;do_raise_exception ();RETURN ();