From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LxPkC-0004Er-6X for qemu-devel@nongnu.org; Fri, 24 Apr 2009 14:03:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LxPkA-0004EM-SE for qemu-devel@nongnu.org; Fri, 24 Apr 2009 14:03:23 -0400 Received: from [199.232.76.173] (port=36807 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LxPkA-0004E8-3u for qemu-devel@nongnu.org; Fri, 24 Apr 2009 14:03:22 -0400 Received: from savannah.gnu.org ([199.232.41.3]:35155 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LxPk9-0003F2-GN for qemu-devel@nongnu.org; Fri, 24 Apr 2009 14:03:21 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LxPk9-0002qX-0K for qemu-devel@nongnu.org; Fri, 24 Apr 2009 18:03:21 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LxPk8-0002qT-OY for qemu-devel@nongnu.org; Fri, 24 Apr 2009 18:03:20 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Fri, 24 Apr 2009 18:03:20 +0000 Subject: [Qemu-devel] [7238] qemu: per-arch cpu_has_work (Marcelo Tosatti) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7238 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7238 Author: aliguori Date: 2009-04-24 18:03:20 +0000 (Fri, 24 Apr 2009) Log Message: ----------- qemu: per-arch cpu_has_work (Marcelo Tosatti) Blue Swirl: fix Sparc32 breakage Signed-off-by: Marcelo Tosatti Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/cpu-all.h trunk/cpu-exec.c trunk/target-alpha/exec.h trunk/target-arm/exec.h trunk/target-cris/exec.h trunk/target-i386/exec.h trunk/target-m68k/exec.h trunk/target-mips/exec.h trunk/target-ppc/exec.h trunk/target-sh4/exec.h trunk/target-sparc/exec.h Modified: trunk/cpu-all.h =================================================================== --- trunk/cpu-all.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/cpu-all.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -775,6 +775,8 @@ void cpu_exit(CPUState *s); +int qemu_cpu_has_work(CPUState *env); + /* Breakpoint/watchpoint flags */ #define BP_MEM_READ 0x01 #define BP_MEM_WRITE 0x02 Modified: trunk/cpu-exec.c =================================================================== --- trunk/cpu-exec.c 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/cpu-exec.c 2009-04-24 18:03:20 UTC (rev 7238) @@ -50,6 +50,11 @@ //#define DEBUG_EXEC //#define DEBUG_SIGNAL +int qemu_cpu_has_work(CPUState *env) +{ + return cpu_has_work(env); +} + void cpu_loop_exit(void) { /* NOTE: the register at this point must be saved by hand because Modified: trunk/target-alpha/exec.h =================================================================== --- trunk/target-alpha/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-alpha/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -48,10 +48,15 @@ { } +static always_inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & CPU_INTERRUPT_HARD); +} + static always_inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; - if (env->interrupt_request & CPU_INTERRUPT_HARD) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-arm/exec.h =================================================================== --- trunk/target-arm/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-arm/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -37,14 +37,19 @@ { } +static inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & + (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB)); +} + static inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; /* An interrupt wakes the CPU even if the I and F CPSR bits are set. We use EXITTB to silently wake CPU without causing an actual interrupt. */ - if (env->interrupt_request & - (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB)) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-cris/exec.h =================================================================== --- trunk/target-cris/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-cris/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -40,6 +40,11 @@ void cpu_cris_flush_flags(CPUCRISState *env, int cc_op); void helper_movec(CPUCRISState *env, int reg, uint32_t val); +static inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)); +} + static inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; Modified: trunk/target-i386/exec.h =================================================================== --- trunk/target-i386/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-i386/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -338,14 +338,23 @@ #endif } +static inline int cpu_has_work(CPUState *env) +{ + int work; + + work = (env->interrupt_request & CPU_INTERRUPT_HARD) && + (env->eflags & IF_MASK); + work |= env->interrupt_request & CPU_INTERRUPT_NMI; + + return work; +} + static inline int cpu_halted(CPUState *env) { /* handle exit of HALTED state */ if (!env->halted) return 0; /* disable halt condition */ - if (((env->interrupt_request & CPU_INTERRUPT_HARD) && - (env->eflags & IF_MASK)) || - (env->interrupt_request & CPU_INTERRUPT_NMI)) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-m68k/exec.h =================================================================== --- trunk/target-m68k/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-m68k/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -41,10 +41,15 @@ #include "softmmu_exec.h" #endif +static inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & (CPU_INTERRUPT_HARD)); +} + static inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; - if (env->interrupt_request & CPU_INTERRUPT_HARD) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-mips/exec.h =================================================================== --- trunk/target-mips/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-mips/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -33,12 +33,18 @@ { } +static inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & + (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)); +} + + static inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; - if (env->interrupt_request & - (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-ppc/exec.h =================================================================== --- trunk/target-ppc/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-ppc/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -44,11 +44,17 @@ { } +static always_inline int cpu_has_work(CPUState *env) +{ + return (msr_ee && (env->interrupt_request & CPU_INTERRUPT_HARD)); +} + + static always_inline int cpu_halted (CPUState *env) { if (!env->halted) return 0; - if (msr_ee && (env->interrupt_request & CPU_INTERRUPT_HARD)) { + if (cpu_has_work(env)) { env->halted = 0; return 0; } Modified: trunk/target-sh4/exec.h =================================================================== --- trunk/target-sh4/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-sh4/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -28,10 +28,15 @@ #include "cpu.h" #include "exec-all.h" +static inline int cpu_has_work(CPUState *env) +{ + return (env->interrupt_request & CPU_INTERRUPT_HARD); +} + static inline int cpu_halted(CPUState *env) { if (!env->halted) return 0; - if (env->interrupt_request & CPU_INTERRUPT_HARD) { + if (cpu_has_work(env)) { env->halted = 0; env->intr_at_halt = 1; return 0; Modified: trunk/target-sparc/exec.h =================================================================== --- trunk/target-sparc/exec.h 2009-04-24 18:03:15 UTC (rev 7237) +++ trunk/target-sparc/exec.h 2009-04-24 18:03:20 UTC (rev 7238) @@ -24,10 +24,17 @@ /* op_helper.c */ void do_interrupt(CPUState *env); +static inline int cpu_has_work(CPUState *env1) +{ + return (env1->interrupt_request & CPU_INTERRUPT_HARD) && + (env1->psret != 0); +} + + static inline int cpu_halted(CPUState *env1) { if (!env1->halted) return 0; - if ((env1->interrupt_request & CPU_INTERRUPT_HARD) && (env1->psret != 0)) { + if (cpu_has_work(env1)) { env1->halted = 0; return 0; }