Skip to content

Commit

Permalink
target-openrisc: Use cpu_exec_interrupt qom hook
Browse files Browse the repository at this point in the history
Cc: Jia Liu <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Tested-by: Jia Liu <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
rth7680 authored and pm215 committed Sep 25, 2014
1 parent 87afe46 commit fbb96c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
18 changes: 0 additions & 18 deletions cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,24 +528,6 @@ int cpu_exec(CPUArchState *env)
cc->do_interrupt(cpu);
next_tb = 0;
}

#elif defined(TARGET_OPENRISC)
{
int idx = -1;
if ((interrupt_request & CPU_INTERRUPT_HARD)
&& (env->sr & SR_IEE)) {
idx = EXCP_INT;
}
if ((interrupt_request & CPU_INTERRUPT_TIMER)
&& (env->sr & SR_TEE)) {
idx = EXCP_TICK;
}
if (idx >= 0) {
cpu->exception_index = idx;
cc->do_interrupt(cpu);
next_tb = 0;
}
}
#endif
/* The target hook has 3 exit conditions:
False when the interrupt isn't processed,
Expand Down
1 change: 1 addition & 0 deletions target-openrisc/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data)
cc->class_by_name = openrisc_cpu_class_by_name;
cc->has_work = openrisc_cpu_has_work;
cc->do_interrupt = openrisc_cpu_do_interrupt;
cc->cpu_exec_interrupt = openrisc_cpu_exec_interrupt;
cc->dump_state = openrisc_cpu_dump_state;
cc->set_pc = openrisc_cpu_set_pc;
cc->gdb_read_register = openrisc_cpu_gdb_read_register;
Expand Down
1 change: 1 addition & 0 deletions target-openrisc/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ OpenRISCCPU *cpu_openrisc_init(const char *cpu_model);
void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf);
int cpu_openrisc_exec(CPUOpenRISCState *s);
void openrisc_cpu_do_interrupt(CPUState *cpu);
bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req);
void openrisc_cpu_dump_state(CPUState *cpu, FILE *f,
fprintf_function cpu_fprintf, int flags);
hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
Expand Down
20 changes: 20 additions & 0 deletions target-openrisc/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,23 @@ void openrisc_cpu_do_interrupt(CPUState *cs)

cs->exception_index = -1;
}

bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
{
OpenRISCCPU *cpu = OPENRISC_CPU(cs);
CPUOpenRISCState *env = &cpu->env;
int idx = -1;

if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->sr & SR_IEE)) {
idx = EXCP_INT;
}
if ((interrupt_request & CPU_INTERRUPT_TIMER) && (env->sr & SR_TEE)) {
idx = EXCP_TICK;
}
if (idx >= 0) {
cs->exception_index = idx;
openrisc_cpu_do_interrupt(cs);
return true;
}
return false;
}

0 comments on commit fbb96c4

Please sign in to comment.