Revision ab8131af
b/hw/ppc/ppc_booke.c | ||
---|---|---|
131 | 131 |
struct QEMUTimer *timer) |
132 | 132 |
{ |
133 | 133 |
ppc_tb_t *tb_env = env->tb_env; |
134 |
uint64_t lapse;
|
|
134 |
uint64_t delta_tick, ticks = 0;
|
|
135 | 135 |
uint64_t tb; |
136 |
uint64_t period = 1 << (target_bit + 1);
|
|
136 |
uint64_t period; |
|
137 | 137 |
uint64_t now; |
138 | 138 |
|
139 | 139 |
now = qemu_get_clock_ns(vm_clock); |
140 | 140 |
tb = cpu_ppc_get_tb(tb_env, now, tb_env->tb_offset); |
141 |
period = 1ULL << target_bit; |
|
142 |
delta_tick = period - (tb & (period - 1)); |
|
141 | 143 |
|
142 |
lapse = period - ((tb - (1 << target_bit)) & (period - 1)); |
|
144 |
/* the timer triggers only when the selected bit toggles from 0 to 1 */ |
|
145 |
if (tb & period) { |
|
146 |
ticks = period; |
|
147 |
} |
|
143 | 148 |
|
144 |
*next = now + muldiv64(lapse, get_ticks_per_sec(), tb_env->tb_freq); |
|
149 |
if (ticks + delta_tick < ticks) { |
|
150 |
/* Overflow, so assume the biggest number we can express. */ |
|
151 |
ticks = UINT64_MAX; |
|
152 |
} else { |
|
153 |
ticks += delta_tick; |
|
154 |
} |
|
155 |
|
|
156 |
*next = now + muldiv64(ticks, get_ticks_per_sec(), tb_env->tb_freq); |
|
157 |
if ((*next < now) || (*next > INT64_MAX)) { |
|
158 |
/* Overflow, so assume the biggest number the qemu timer supports. */ |
|
159 |
*next = INT64_MAX; |
|
160 |
} |
|
145 | 161 |
|
146 | 162 |
/* XXX: If expire time is now. We can't run the callback because we don't |
147 | 163 |
* have access to it. So we just set the timer one nanosecond later. |
Also available in: Unified diff