static void slavio_timer_get_out(SLAVIO_TIMERState *s)

{

    int out;

    int64_t diff, ticks, count;

    uint32_t limit;



    // There are three clock tick units: CPU ticks, register units

    // (nanoseconds), and counter ticks (500 ns).

    if (s->mode == 1 && s->stopped)

	ticks = s->stop_time;

    else

	ticks = qemu_get_clock(vm_clock) - s->tick_offset;



    out = (ticks > s->expire_time);

    if (out)

	s->reached = 0x80000000;

    if (!s->limit)

	limit = 0x7fffffff;

    else

	limit = s->limit;



    // Convert register units to counter ticks

    limit = limit >> 9;



    // Convert cpu ticks to counter ticks

    diff = muldiv64(ticks - s->count_load_time, CNT_FREQ, ticks_per_sec);



    // Calculate what the counter should be, convert to register

    // units

    count = diff % limit;

    s->count = count << 9;

    s->counthigh = count >> 22;



    // Expire time: CPU ticks left to next interrupt

    // Convert remaining counter ticks to CPU ticks

    s->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ);



    DPRINTF("irq %d limit %d reached %d d %" PRId64 " count %d s->c %x diff %" PRId64 " stopped %d mode %d\n", s->irq, limit, s->reached?1:0, (ticks-s->count_load_time), count, s->count, s->expire_time - ticks, s->stopped, s->mode);



    if (s->mode != 1)

	pic_set_irq_cpu(s->intctl, s->irq, out, s->cpu);

}

static void slavio_timer_get_out(SLAVIO_TIMERState *s)

{

    int out;

    int64_t diff, ticks, count;

    uint32_t limit;



    

    

    if (s->mode == 1 && s->stopped)

	ticks = s->stop_time;

    else

	ticks = qemu_get_clock(vm_clock) - s->tick_offset;



    out = (ticks > s->expire_time);

    if (out)

	s->reached = 0x80000000;

    if (!s->limit)

	limit = 0x7fffffff;

    else

	limit = s->limit;



    

    limit = limit >> 9;



    

    diff = muldiv64(ticks - s->count_load_time, CNT_FREQ, ticks_per_sec);



    

    

    count = diff % limit;

    s->count = count << 9;

    s->counthigh = count >> 22;



    

    

    s->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ);



    DPRINTF("irq %d limit %d reached %d d %" PRId64 " count %d s->c %x diff %" PRId64 " stopped %d mode %d\n", s->irq, limit, s->reached?1:0, (ticks-s->count_load_time), count, s->count, s->expire_time - ticks, s->stopped, s->mode);



    if (s->mode != 1)

	pic_set_irq_cpu(s->intctl, s->irq, out, s->cpu);

}

    if (!s->limit) 	limit = 0x7fffffff; 	limit = s->limit;     limit = limit >> 9;
static void FUNC_0(SLAVIO_TIMERState *VAR_0)

{

    int VAR_1;

    int64_t diff, ticks, count;

    uint32_t limit;



    

    

    if (VAR_0->mode == 1 && VAR_0->stopped)

	ticks = VAR_0->stop_time;

    else

	ticks = qemu_get_clock(vm_clock) - VAR_0->tick_offset;



    VAR_1 = (ticks > VAR_0->expire_time);

    if (VAR_1)

	VAR_0->reached = 0x80000000;

    if (!VAR_0->limit)

	limit = 0x7fffffff;

    else

	limit = VAR_0->limit;



    

    limit = limit >> 9;



    

    diff = muldiv64(ticks - VAR_0->count_load_time, CNT_FREQ, ticks_per_sec);



    

    

    count = diff % limit;

    VAR_0->count = count << 9;

    VAR_0->counthigh = count >> 22;



    

    

    VAR_0->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ);



    DPRINTF("irq %d limit %d reached %d d %" PRId64 " count %d VAR_0->c %x diff %" PRId64 " stopped %d mode %d\n", VAR_0->irq, limit, VAR_0->reached?1:0, (ticks-VAR_0->count_load_time), count, VAR_0->count, VAR_0->expire_time - ticks, VAR_0->stopped, VAR_0->mode);



    if (VAR_0->mode != 1)

	pic_set_irq_cpu(VAR_0->intctl, VAR_0->irq, VAR_1, VAR_0->cpu);

}

static void FUNC_0(SLAVIO_TIMERState *VAR_0)
{ int VAR_1; int64_t diff, ticks, count; uint32_t limit; if (VAR_0->mode == 1 && VAR_0->stopped)
ticks = VAR_0->stop_time; else
ticks = qemu_get_clock(vm_clock) - VAR_0->tick_offset; VAR_1 = (ticks > VAR_0->expire_time); if (VAR_1)
VAR_0->reached = 0x80000000; if (!VAR_0->limit)
limit = 0x7fffffff; else
limit = VAR_0->limit; limit = limit >> 9; diff = muldiv64(ticks - VAR_0->count_load_time, CNT_FREQ, ticks_per_sec); count = diff % limit; VAR_0->count = count << 9; VAR_0->counthigh = count >> 22; VAR_0->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ); DPRINTF("irq %d limit %d reached %d d %" PRId64 " count %d VAR_0->c %x diff %" PRId64 " stopped %d mode %d\n", VAR_0->irq, limit, VAR_0->reached?1:0, (ticks-VAR_0->count_load_time), count, VAR_0->count, VAR_0->expire_time - ticks, VAR_0->stopped, VAR_0->mode); if (VAR_0->mode != 1)
pic_set_irq_cpu(VAR_0->intctl, VAR_0->irq, VAR_1, VAR_0->cpu); }