[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 01/11] qemu: create helper for event notification
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 01/11] qemu: create helper for event notification |
Date: |
Thu, 02 Apr 2009 20:32:51 -0300 |
User-agent: |
quilt/0.46-1 |
Signed-off-by: Marcelo Tosatti <address@hidden>
Index: trunk/vl.c
===================================================================
--- trunk.orig/vl.c
+++ trunk/vl.c
@@ -1183,9 +1183,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();
}
}
@@ -1338,8 +1337,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);
@@ -1349,16 +1346,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();
}
}
@@ -3334,15 +3322,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();
}
/***********************************************************/
@@ -3410,15 +3390,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)
@@ -3627,22 +3604,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
--
- [Qemu-devel] [patch 00/11] iothread v2, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 03/11] qemu: per-arch cpu_has_work, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 07/11] qemu: handle reset/poweroff/shutdown in iothread, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 05/11] qemu: separate thread for io, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 06/11] qemu: per-cpu thread information, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 04/11] qemu: introduce main_loop_break, Marcelo Tosatti, 2009/04/02
- [Qemu-devel] [patch 09/11] qemu: handle vmstop from cpu context, Marcelo Tosatti, 2009/04/02