Commit 85e3023e2f081b9302ca5ea0705212d7e49e00dd
1 parent
14e51cc7
Remove unused timers
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3862 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
40 additions
and
27 deletions
hw/slavio_timer.c
... | ... | @@ -104,7 +104,11 @@ static void slavio_timer_get_out(SLAVIO_TIMERState *s) |
104 | 104 | else |
105 | 105 | limit = s->limit; |
106 | 106 | |
107 | - count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer)); | |
107 | + if (s->timer) | |
108 | + count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer)); | |
109 | + else | |
110 | + count = 0; | |
111 | + | |
108 | 112 | DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit, |
109 | 113 | s->counthigh, s->count); |
110 | 114 | s->count = count & TIMER_COUNT_MASK32; |
... | ... | @@ -190,15 +194,18 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, |
190 | 194 | qemu_irq_lower(s->irq); |
191 | 195 | s->limit = TIMER_MAX_COUNT64; |
192 | 196 | DPRINTF("processor %d user timer reset\n", s->slave_index); |
193 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
197 | + if (s->timer) | |
198 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
194 | 199 | } else { |
195 | 200 | // set limit, reset counter |
196 | 201 | qemu_irq_lower(s->irq); |
197 | 202 | s->limit = val & TIMER_MAX_COUNT32; |
198 | - if (s->limit == 0) /* free-run */ | |
199 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | |
200 | - else | |
201 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
203 | + if (s->timer) { | |
204 | + if (s->limit == 0) /* free-run */ | |
205 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | |
206 | + else | |
207 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
208 | + } | |
202 | 209 | } |
203 | 210 | break; |
204 | 211 | case TIMER_COUNTER: |
... | ... | @@ -207,28 +214,33 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, |
207 | 214 | qemu_irq_lower(s->irq); |
208 | 215 | s->limit = TIMER_MAX_COUNT64; |
209 | 216 | DPRINTF("processor %d user timer reset\n", s->slave_index); |
210 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
217 | + if (s->timer) | |
218 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
211 | 219 | } else |
212 | 220 | DPRINTF("not user timer\n"); |
213 | 221 | break; |
214 | 222 | case TIMER_COUNTER_NORST: |
215 | 223 | // set limit without resetting counter |
216 | 224 | s->limit = val & TIMER_MAX_COUNT32; |
217 | - if (s->limit == 0) /* free-run */ | |
218 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); | |
219 | - else | |
220 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0); | |
225 | + if (s->timer) { | |
226 | + if (s->limit == 0) /* free-run */ | |
227 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); | |
228 | + else | |
229 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0); | |
230 | + } | |
221 | 231 | break; |
222 | 232 | case TIMER_STATUS: |
223 | 233 | if (slavio_timer_is_user(s)) { |
224 | 234 | // start/stop user counter |
225 | 235 | if ((val & 1) && !s->running) { |
226 | 236 | DPRINTF("processor %d user timer started\n", s->slave_index); |
227 | - ptimer_run(s->timer, 0); | |
237 | + if (s->timer) | |
238 | + ptimer_run(s->timer, 0); | |
228 | 239 | s->running = 1; |
229 | 240 | } else if (!(val & 1) && s->running) { |
230 | 241 | DPRINTF("processor %d user timer stopped\n", s->slave_index); |
231 | - ptimer_stop(s->timer); | |
242 | + if (s->timer) | |
243 | + ptimer_stop(s->timer); | |
232 | 244 | s->running = 0; |
233 | 245 | } |
234 | 246 | } |
... | ... | @@ -280,29 +292,26 @@ static void slavio_timer_save(QEMUFile *f, void *opaque) |
280 | 292 | qemu_put_be64s(f, &s->limit); |
281 | 293 | qemu_put_be32s(f, &s->count); |
282 | 294 | qemu_put_be32s(f, &s->counthigh); |
283 | - qemu_put_be32(f, 0); // Was irq | |
284 | 295 | qemu_put_be32s(f, &s->reached); |
285 | 296 | qemu_put_be32s(f, &s->running); |
286 | - qemu_put_be32s(f, 0); // Was mode | |
287 | - qemu_put_ptimer(f, s->timer); | |
297 | + if (s->timer) | |
298 | + qemu_put_ptimer(f, s->timer); | |
288 | 299 | } |
289 | 300 | |
290 | 301 | static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id) |
291 | 302 | { |
292 | 303 | SLAVIO_TIMERState *s = opaque; |
293 | - uint32_t tmp; | |
294 | 304 | |
295 | - if (version_id != 2) | |
305 | + if (version_id != 3) | |
296 | 306 | return -EINVAL; |
297 | 307 | |
298 | 308 | qemu_get_be64s(f, &s->limit); |
299 | 309 | qemu_get_be32s(f, &s->count); |
300 | 310 | qemu_get_be32s(f, &s->counthigh); |
301 | - qemu_get_be32s(f, &tmp); // Was irq | |
302 | 311 | qemu_get_be32s(f, &s->reached); |
303 | 312 | qemu_get_be32s(f, &s->running); |
304 | - qemu_get_be32s(f, &tmp); // Was mode | |
305 | - qemu_get_ptimer(f, s->timer); | |
313 | + if (s->timer) | |
314 | + qemu_get_ptimer(f, s->timer); | |
306 | 315 | |
307 | 316 | return 0; |
308 | 317 | } |
... | ... | @@ -315,8 +324,10 @@ static void slavio_timer_reset(void *opaque) |
315 | 324 | s->count = 0; |
316 | 325 | s->reached = 0; |
317 | 326 | s->slave_mode = 0; |
318 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | |
319 | - ptimer_run(s->timer, 0); | |
327 | + if (!s->master || s->slave_index < s->master->num_slaves) { | |
328 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | |
329 | + ptimer_run(s->timer, 0); | |
330 | + } | |
320 | 331 | s->running = 1; |
321 | 332 | qemu_irq_lower(s->irq); |
322 | 333 | } |
... | ... | @@ -336,9 +347,11 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr, |
336 | 347 | s->irq = irq; |
337 | 348 | s->master = master; |
338 | 349 | s->slave_index = slave_index; |
339 | - bh = qemu_bh_new(slavio_timer_irq, s); | |
340 | - s->timer = ptimer_init(bh); | |
341 | - ptimer_set_period(s->timer, TIMER_PERIOD); | |
350 | + if (!master || slave_index < master->num_slaves) { | |
351 | + bh = qemu_bh_new(slavio_timer_irq, s); | |
352 | + s->timer = ptimer_init(bh); | |
353 | + ptimer_set_period(s->timer, TIMER_PERIOD); | |
354 | + } | |
342 | 355 | |
343 | 356 | slavio_timer_io_memory = cpu_register_io_memory(0, slavio_timer_mem_read, |
344 | 357 | slavio_timer_mem_write, s); |
... | ... | @@ -348,7 +361,7 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr, |
348 | 361 | else |
349 | 362 | cpu_register_physical_memory(addr, SYS_TIMER_SIZE, |
350 | 363 | slavio_timer_io_memory); |
351 | - register_savevm("slavio_timer", addr, 2, slavio_timer_save, | |
364 | + register_savevm("slavio_timer", addr, 3, slavio_timer_save, | |
352 | 365 | slavio_timer_load, s); |
353 | 366 | qemu_register_reset(slavio_timer_reset, s); |
354 | 367 | slavio_timer_reset(s); | ... | ... |