Commit d9f75a4eb449c96dd47731a4d6f1619f3c23b5e7
1 parent
96248fd8
qemu: create helper for event notification (Marcelo Tosatti)
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7236 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
25 additions
and
25 deletions
hw/mac_dbdma.c
@@ -651,9 +651,7 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, | @@ -651,9 +651,7 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, | ||
651 | 651 | ||
652 | void DBDMA_schedule(void) | 652 | void DBDMA_schedule(void) |
653 | { | 653 | { |
654 | - CPUState *env = cpu_single_env; | ||
655 | - if (env) | ||
656 | - cpu_exit(env); | 654 | + qemu_notify_event(); |
657 | } | 655 | } |
658 | 656 | ||
659 | static void | 657 | static void |
qemu-common.h
@@ -186,6 +186,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id); | @@ -186,6 +186,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id); | ||
186 | /* Force QEMU to stop what it's doing and service IO */ | 186 | /* Force QEMU to stop what it's doing and service IO */ |
187 | void qemu_service_io(void); | 187 | void qemu_service_io(void); |
188 | 188 | ||
189 | +/* Force QEMU to process pending events */ | ||
190 | +void qemu_notify_event(void); | ||
191 | + | ||
189 | typedef struct QEMUIOVector { | 192 | typedef struct QEMUIOVector { |
190 | struct iovec *iov; | 193 | struct iovec *iov; |
191 | int niov; | 194 | int niov; |
vl.c
@@ -1193,9 +1193,8 @@ void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time) | @@ -1193,9 +1193,8 @@ void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time) | ||
1193 | qemu_rearm_alarm_timer(alarm_timer); | 1193 | qemu_rearm_alarm_timer(alarm_timer); |
1194 | } | 1194 | } |
1195 | /* Interrupt execution to force deadline recalculation. */ | 1195 | /* Interrupt execution to force deadline recalculation. */ |
1196 | - if (use_icount && cpu_single_env) { | ||
1197 | - cpu_exit(cpu_single_env); | ||
1198 | - } | 1196 | + if (use_icount) |
1197 | + qemu_notify_event(); | ||
1199 | } | 1198 | } |
1200 | } | 1199 | } |
1201 | 1200 | ||
@@ -1370,6 +1369,7 @@ static void host_alarm_handler(int host_signum) | @@ -1370,6 +1369,7 @@ static void host_alarm_handler(int host_signum) | ||
1370 | #endif | 1369 | #endif |
1371 | } | 1370 | } |
1372 | event_pending = 1; | 1371 | event_pending = 1; |
1372 | + qemu_notify_event(); | ||
1373 | } | 1373 | } |
1374 | } | 1374 | } |
1375 | 1375 | ||
@@ -3406,15 +3406,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) | @@ -3406,15 +3406,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) | ||
3406 | 3406 | ||
3407 | void qemu_service_io(void) | 3407 | void qemu_service_io(void) |
3408 | { | 3408 | { |
3409 | - CPUState *env = cpu_single_env; | ||
3410 | - if (env) { | ||
3411 | - cpu_exit(env); | ||
3412 | -#ifdef CONFIG_KQEMU | ||
3413 | - if (env->kqemu_enabled) { | ||
3414 | - kqemu_cpu_interrupt(env); | ||
3415 | - } | ||
3416 | -#endif | ||
3417 | - } | 3409 | + qemu_notify_event(); |
3418 | } | 3410 | } |
3419 | 3411 | ||
3420 | /***********************************************************/ | 3412 | /***********************************************************/ |
@@ -3482,15 +3474,12 @@ void qemu_bh_schedule_idle(QEMUBH *bh) | @@ -3482,15 +3474,12 @@ void qemu_bh_schedule_idle(QEMUBH *bh) | ||
3482 | 3474 | ||
3483 | void qemu_bh_schedule(QEMUBH *bh) | 3475 | void qemu_bh_schedule(QEMUBH *bh) |
3484 | { | 3476 | { |
3485 | - CPUState *env = cpu_single_env; | ||
3486 | if (bh->scheduled) | 3477 | if (bh->scheduled) |
3487 | return; | 3478 | return; |
3488 | bh->scheduled = 1; | 3479 | bh->scheduled = 1; |
3489 | bh->idle = 0; | 3480 | bh->idle = 0; |
3490 | /* stop the currently executing CPU to execute the BH ASAP */ | 3481 | /* stop the currently executing CPU to execute the BH ASAP */ |
3491 | - if (env) { | ||
3492 | - cpu_exit(env); | ||
3493 | - } | 3482 | + qemu_notify_event(); |
3494 | } | 3483 | } |
3495 | 3484 | ||
3496 | void qemu_bh_cancel(QEMUBH *bh) | 3485 | void qemu_bh_cancel(QEMUBH *bh) |
@@ -3701,22 +3690,32 @@ void qemu_system_reset_request(void) | @@ -3701,22 +3690,32 @@ void qemu_system_reset_request(void) | ||
3701 | } else { | 3690 | } else { |
3702 | reset_requested = 1; | 3691 | reset_requested = 1; |
3703 | } | 3692 | } |
3704 | - if (cpu_single_env) | ||
3705 | - cpu_exit(cpu_single_env); | 3693 | + qemu_notify_event(); |
3706 | } | 3694 | } |
3707 | 3695 | ||
3708 | void qemu_system_shutdown_request(void) | 3696 | void qemu_system_shutdown_request(void) |
3709 | { | 3697 | { |
3710 | shutdown_requested = 1; | 3698 | shutdown_requested = 1; |
3711 | - if (cpu_single_env) | ||
3712 | - cpu_exit(cpu_single_env); | 3699 | + qemu_notify_event(); |
3713 | } | 3700 | } |
3714 | 3701 | ||
3715 | void qemu_system_powerdown_request(void) | 3702 | void qemu_system_powerdown_request(void) |
3716 | { | 3703 | { |
3717 | powerdown_requested = 1; | 3704 | powerdown_requested = 1; |
3718 | - if (cpu_single_env) | ||
3719 | - cpu_exit(cpu_single_env); | 3705 | + qemu_notify_event(); |
3706 | +} | ||
3707 | + | ||
3708 | +void qemu_notify_event(void) | ||
3709 | +{ | ||
3710 | + CPUState *env = cpu_single_env; | ||
3711 | + | ||
3712 | + if (env) { | ||
3713 | + cpu_exit(env); | ||
3714 | +#ifdef USE_KQEMU | ||
3715 | + if (env->kqemu_enabled) | ||
3716 | + kqemu_cpu_interrupt(env); | ||
3717 | +#endif | ||
3718 | + } | ||
3720 | } | 3719 | } |
3721 | 3720 | ||
3722 | #ifdef _WIN32 | 3721 | #ifdef _WIN32 |