2 * Stubs for the ptimer-test
4 * Copyright (c) 2016 Dmitry Osipenko <digetx@gmail.com>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
11 #include "qemu/osdep.h"
12 #include "qemu/main-loop.h"
13 #include "sysemu/replay.h"
14 #include "migration/vmstate.h"
15 #include "sysemu/cpu-timers.h"
17 #include "ptimer-test.h"
19 const VMStateInfo vmstate_info_uint8
;
20 const VMStateInfo vmstate_info_uint32
;
21 const VMStateInfo vmstate_info_uint64
;
22 const VMStateInfo vmstate_info_int64
;
23 const VMStateInfo vmstate_info_timer
;
30 QEMUTimerListGroup main_loop_tlg
;
32 int64_t ptimer_test_time_ns
;
34 /* under qtest_enabled(), will not artificially limit period - see hw/core/ptimer.c. */
38 void timer_init_full(QEMUTimer
*ts
,
39 QEMUTimerListGroup
*timer_list_group
, QEMUClockType type
,
40 int scale
, int attributes
,
41 QEMUTimerCB
*cb
, void *opaque
)
43 if (!timer_list_group
) {
44 timer_list_group
= &main_loop_tlg
;
46 ts
->timer_list
= timer_list_group
->tl
[type
];
50 ts
->attributes
= attributes
;
54 void timer_mod(QEMUTimer
*ts
, int64_t expire_time
)
56 QEMUTimerList
*timer_list
= ts
->timer_list
;
57 QEMUTimer
*t
= &timer_list
->active_timers
;
59 while (t
->next
!= NULL
) {
67 ts
->expire_time
= MAX(expire_time
* ts
->scale
, 0);
72 void timer_del(QEMUTimer
*ts
)
74 QEMUTimerList
*timer_list
= ts
->timer_list
;
75 QEMUTimer
*t
= &timer_list
->active_timers
;
77 while (t
->next
!= NULL
) {
87 int64_t qemu_clock_get_ns(QEMUClockType type
)
89 return ptimer_test_time_ns
;
92 int64_t qemu_clock_deadline_ns_all(QEMUClockType type
, int attr_mask
)
94 QEMUTimerList
*timer_list
= main_loop_tlg
.tl
[QEMU_CLOCK_VIRTUAL
];
95 QEMUTimer
*t
= timer_list
->active_timers
.next
;
96 int64_t deadline
= -1;
100 deadline
= t
->expire_time
;
102 deadline
= MIN(deadline
, t
->expire_time
);
111 QEMUBH
*qemu_bh_new(QEMUBHFunc
*cb
, void *opaque
)
113 QEMUBH
*bh
= g_new(QEMUBH
, 1);
121 void qemu_bh_delete(QEMUBH
*bh
)