Revision cd48d7e8
b/vl.c | ||
---|---|---|
592 | 592 |
|
593 | 593 |
struct qemu_alarm_timer { |
594 | 594 |
char const *name; |
595 |
unsigned int flags; |
|
596 |
|
|
597 | 595 |
int (*start)(struct qemu_alarm_timer *t); |
598 | 596 |
void (*stop)(struct qemu_alarm_timer *t); |
599 | 597 |
void (*rearm)(struct qemu_alarm_timer *t); |
600 | 598 |
void *priv; |
601 |
}; |
|
602 | 599 |
|
603 |
#define ALARM_FLAG_DYNTICKS 0x1
|
|
604 |
#define ALARM_FLAG_EXPIRED 0x2
|
|
600 |
unsigned int expired;
|
|
601 |
};
|
|
605 | 602 |
|
606 | 603 |
static inline int alarm_has_dynticks(struct qemu_alarm_timer *t) |
607 | 604 |
{ |
608 |
return t && (t->flags & ALARM_FLAG_DYNTICKS);
|
|
605 |
return t && t->rearm;
|
|
609 | 606 |
} |
610 | 607 |
|
611 | 608 |
static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) |
... | ... | |
721 | 718 |
static struct qemu_alarm_timer alarm_timers[] = { |
722 | 719 |
#ifndef _WIN32 |
723 | 720 |
#ifdef __linux__ |
724 |
{"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
|
|
721 |
{"dynticks", dynticks_start_timer, |
|
725 | 722 |
dynticks_stop_timer, dynticks_rearm_timer, NULL}, |
726 | 723 |
/* HPET - if available - is preferred */ |
727 |
{"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
|
|
724 |
{"hpet", hpet_start_timer, hpet_stop_timer, NULL, NULL}, |
|
728 | 725 |
/* ...otherwise try RTC */ |
729 |
{"rtc", 0, rtc_start_timer, rtc_stop_timer, NULL, NULL},
|
|
726 |
{"rtc", rtc_start_timer, rtc_stop_timer, NULL, NULL}, |
|
730 | 727 |
#endif |
731 |
{"unix", 0, unix_start_timer, unix_stop_timer, NULL, NULL},
|
|
728 |
{"unix", unix_start_timer, unix_stop_timer, NULL, NULL}, |
|
732 | 729 |
#else |
733 |
{"dynticks", ALARM_FLAG_DYNTICKS, win32_start_timer,
|
|
730 |
{"dynticks", win32_start_timer, |
|
734 | 731 |
win32_stop_timer, win32_rearm_timer, &alarm_win32_data}, |
735 |
{"win32", 0, win32_start_timer,
|
|
732 |
{"win32", win32_start_timer, |
|
736 | 733 |
win32_stop_timer, NULL, &alarm_win32_data}, |
737 | 734 |
#endif |
738 | 735 |
{NULL, } |
... | ... | |
880 | 877 |
|
881 | 878 |
/* Rearm if necessary */ |
882 | 879 |
if (pt == &active_timers[ts->clock->type]) { |
883 |
if ((alarm_timer->flags & ALARM_FLAG_EXPIRED) == 0) {
|
|
880 |
if (!alarm_timer->expired) {
|
|
884 | 881 |
qemu_rearm_alarm_timer(alarm_timer); |
885 | 882 |
} |
886 | 883 |
/* Interrupt execution to force deadline recalculation. */ |
... | ... | |
1053 | 1050 |
qemu_timer_expired(active_timers[QEMU_CLOCK_HOST], |
1054 | 1051 |
qemu_get_clock(host_clock))) { |
1055 | 1052 |
qemu_event_increment(); |
1056 |
if (alarm_timer) alarm_timer->flags |= ALARM_FLAG_EXPIRED;
|
|
1053 |
if (alarm_timer) alarm_timer->expired = 1;
|
|
1057 | 1054 |
|
1058 | 1055 |
#ifndef CONFIG_IOTHREAD |
1059 | 1056 |
if (next_cpu) { |
... | ... | |
1282 | 1279 |
int64_t nearest_delta_us = INT64_MAX; |
1283 | 1280 |
int64_t current_us; |
1284 | 1281 |
|
1282 |
assert(alarm_has_dynticks(t)); |
|
1285 | 1283 |
if (!active_timers[QEMU_CLOCK_REALTIME] && |
1286 | 1284 |
!active_timers[QEMU_CLOCK_VIRTUAL] && |
1287 | 1285 |
!active_timers[QEMU_CLOCK_HOST]) |
... | ... | |
1397 | 1395 |
{ |
1398 | 1396 |
struct qemu_alarm_win32 *data = t->priv; |
1399 | 1397 |
|
1398 |
assert(alarm_has_dynticks(t)); |
|
1400 | 1399 |
if (!active_timers[QEMU_CLOCK_REALTIME] && |
1401 | 1400 |
!active_timers[QEMU_CLOCK_VIRTUAL] && |
1402 | 1401 |
!active_timers[QEMU_CLOCK_HOST]) |
... | ... | |
3883 | 3882 |
slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0)); |
3884 | 3883 |
|
3885 | 3884 |
/* rearm timer, if not periodic */ |
3886 |
if (alarm_timer->flags & ALARM_FLAG_EXPIRED) {
|
|
3887 |
alarm_timer->flags &= ~ALARM_FLAG_EXPIRED;
|
|
3885 |
if (alarm_timer->expired) {
|
|
3886 |
alarm_timer->expired = 0;
|
|
3888 | 3887 |
qemu_rearm_alarm_timer(alarm_timer); |
3889 | 3888 |
} |
3890 | 3889 |
|
Also available in: Unified diff