void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit) { int64_t now = qemu_get_clock_ns(vm_clock); uint64_t real_limit = limit & ~timer->disabled_mask; timer->disabled = (limit & timer->disabled_mask) ? 1 : 0; int64_t expires = cpu_to_timer_ticks(real_limit, timer->frequency) + timer->clock_offset; if (expires < now) { expires = now + 1; } TIMER_DPRINTF("%s set_limit limit=0x%016lx (%s) p=%p " "called with limit=0x%016lx at 0x%016lx (delta=0x%016lx)\n", timer->name, real_limit, timer->disabled?"disabled":"enabled", timer, limit, timer_to_cpu_ticks(now - timer->clock_offset, timer->frequency), timer_to_cpu_ticks(expires - now, timer->frequency)); if (!real_limit) { TIMER_DPRINTF("%s set_limit limit=ZERO - not starting timer\n", timer->name); qemu_del_timer(timer->qtimer); } else if (timer->disabled) { qemu_del_timer(timer->qtimer); } else { qemu_mod_timer(timer->qtimer, expires); } }
void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit) { int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); uint64_t real_limit = limit & ~timer->disabled_mask; timer->disabled = (limit & timer->disabled_mask) ? 1 : 0; int64_t expires = cpu_to_timer_ticks(real_limit, timer->frequency) + timer->clock_offset; if (expires < now) { expires = now + 1; } trace_sparc64_cpu_tick_set_limit(timer->name, real_limit, timer->disabled ? "disabled" : "enabled", timer, limit, timer_to_cpu_ticks( now - timer->clock_offset, timer->frequency ), timer_to_cpu_ticks( expires - now, timer->frequency )); if (!real_limit) { trace_sparc64_cpu_tick_set_limit_zero(timer->name); timer_del(timer->qtimer); } else if (timer->disabled) { timer_del(timer->qtimer); } else { timer_mod(timer->qtimer, expires); } }
void cpu_tick_set_count(CPUTimer *timer, uint64_t count) { uint64_t real_count = count & ~timer->disabled_mask; uint64_t disabled_bit = count & timer->disabled_mask; int64_t vm_clock_offset = qemu_get_clock_ns(vm_clock) - cpu_to_timer_ticks(real_count, timer->frequency); TIMER_DPRINTF("%s set_count count=0x%016lx (%s) p=%p\n", timer->name, real_count, timer->disabled?"disabled":"enabled", timer); timer->disabled = disabled_bit ? 1 : 0; timer->clock_offset = vm_clock_offset; }
void cpu_tick_set_count(CPUTimer *timer, uint64_t count) { uint64_t real_count = count & ~timer->npt_mask; uint64_t npt_bit = count & timer->npt_mask; int64_t vm_clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - cpu_to_timer_ticks(real_count, timer->frequency); trace_sparc64_cpu_tick_set_count(timer->name, real_count, timer->npt ? "disabled" : "enabled", timer); timer->npt = npt_bit ? 1 : 0; timer->clock_offset = vm_clock_offset; }
void cpu_tick_set_count(CPUTimer *timer, uint64_t count) { uint64_t real_count = count & ~timer->npt_mask; uint64_t npt_bit = count & timer->npt_mask; int64_t vm_clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - cpu_to_timer_ticks(real_count, timer->frequency); TIMER_DPRINTF("%s set_count count=0x%016lx (npt %s) p=%p\n", timer->name, real_count, timer->npt ? "disabled" : "enabled", timer); timer->npt = npt_bit ? 1 : 0; timer->clock_offset = vm_clock_offset; }