From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lmc0t-0001uJ-5c for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:55:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lmc0o-0001nj-Ch for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:55:58 -0400 Received: from [199.232.76.173] (port=49781 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lmc0o-0001na-7z for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:55:54 -0400 Received: from mx2.redhat.com ([66.187.237.31]:51066) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lmc0n-0006Gu-M1 for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:55:54 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2PMtre5032347 for ; Wed, 25 Mar 2009 18:55:53 -0400 Message-Id: <20090325225438.765838184@amt.cnet> Date: Wed, 25 Mar 2009 19:47:15 -0300 From: Marcelo Tosatti References: <20090325224714.853788328@amt.cnet> Content-Disposition: inline; filename=abstract-qemu-event Subject: [Qemu-devel] [patch 01/10] qemu: create helper for event notification Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcelo Tosatti Signed-off-by: Marcelo Tosatti Index: trunk/hw/dma.c =================================================================== --- trunk.orig/hw/dma.c +++ trunk/hw/dma.c @@ -445,9 +445,7 @@ int DMA_write_memory (int nchan, void *b /* request the emulator to transfer a new DMA memory block ASAP */ void DMA_schedule(int nchan) { - CPUState *env = cpu_single_env; - if (env) - cpu_exit(env); + qemu_notify_event(); } static void dma_reset(void *opaque) Index: trunk/vl.c =================================================================== --- trunk.orig/vl.c +++ trunk/vl.c @@ -1182,9 +1182,8 @@ void qemu_mod_timer(QEMUTimer *ts, int64 qemu_rearm_alarm_timer(alarm_timer); } /* Interrupt execution to force deadline recalculation. */ - if (use_icount && cpu_single_env) { - cpu_exit(cpu_single_env); - } + if (use_icount) + qemu_notify_event(); } } @@ -1337,8 +1336,6 @@ static void host_alarm_handler(int host_ qemu_get_clock(vm_clock))) || qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock))) { - CPUState *env = next_cpu; - #ifdef _WIN32 struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv; SetEvent(data->host_alarm); @@ -1348,16 +1345,7 @@ static void host_alarm_handler(int host_ #endif alarm_timer->flags |= ALARM_FLAG_EXPIRED; - if (env) { - /* stop the currently executing cpu because a timer occured */ - cpu_exit(env); -#ifdef USE_KQEMU - if (env->kqemu_enabled) { - kqemu_cpu_interrupt(env); - } -#endif - } - event_pending = 1; + qemu_notify_event(); } } @@ -3333,15 +3321,7 @@ static int ram_load(QEMUFile *f, void *o void qemu_service_io(void) { - CPUState *env = cpu_single_env; - if (env) { - cpu_exit(env); -#ifdef USE_KQEMU - if (env->kqemu_enabled) { - kqemu_cpu_interrupt(env); - } -#endif - } + qemu_notify_event(); } /***********************************************************/ @@ -3409,15 +3389,12 @@ void qemu_bh_schedule_idle(QEMUBH *bh) void qemu_bh_schedule(QEMUBH *bh) { - CPUState *env = cpu_single_env; if (bh->scheduled) return; bh->scheduled = 1; bh->idle = 0; /* stop the currently executing CPU to execute the BH ASAP */ - if (env) { - cpu_exit(env); - } + qemu_notify_event(); } void qemu_bh_cancel(QEMUBH *bh) @@ -3626,22 +3603,32 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } - if (cpu_single_env) - cpu_exit(cpu_single_env); + qemu_notify_event(); } void qemu_system_shutdown_request(void) { shutdown_requested = 1; - if (cpu_single_env) - cpu_exit(cpu_single_env); + qemu_notify_event(); } void qemu_system_powerdown_request(void) { powerdown_requested = 1; - if (cpu_single_env) - cpu_exit(cpu_single_env); + qemu_notify_event(); +} + +void qemu_notify_event(void) +{ + CPUState *env = cpu_single_env; + + if (env) { + cpu_exit(env); +#ifdef USE_KQEMU + if (env->kqemu_enabled) + kqemu_cpu_interrupt(env); +#endif + } } #ifdef _WIN32 Index: trunk/qemu-common.h =================================================================== --- trunk.orig/qemu-common.h +++ trunk/qemu-common.h @@ -186,6 +186,9 @@ int cpu_load(QEMUFile *f, void *opaque, /* Force QEMU to stop what it's doing and service IO */ void qemu_service_io(void); +/* Force QEMU to process pending events */ +void qemu_notify_event(void); + typedef struct QEMUIOVector { struct iovec *iov; int niov; Index: trunk/hw/mac_dbdma.c =================================================================== --- trunk.orig/hw/mac_dbdma.c +++ trunk/hw/mac_dbdma.c @@ -651,9 +651,7 @@ void DBDMA_register_channel(void *dbdma, void DBDMA_schedule(void) { - CPUState *env = cpu_single_env; - if (env) - cpu_exit(env); + qemu_notify_event(); } static void