Lines Matching refs:gictimer

20 static void gic_vptimer_update(MIPSGICTimerState *gictimer,  in gic_vptimer_update()  argument
26 wait = gictimer->vptimers[vp_index].comparelo - gictimer->sh_counterlo - in gic_vptimer_update()
30 timer_mod(gictimer->vptimers[vp_index].qtimer, next); in gic_vptimer_update()
33 static void gic_vptimer_expire(MIPSGICTimerState *gictimer, uint32_t vp_index, in gic_vptimer_expire() argument
36 if (gictimer->countstop) { in gic_vptimer_expire()
40 gictimer->cb(gictimer->opaque, vp_index); in gic_vptimer_expire()
41 gic_vptimer_update(gictimer, vp_index, now); in gic_vptimer_expire()
47 MIPSGICTimerState *gictimer = vptimer->gictimer; in gic_vptimer_cb() local
48 gic_vptimer_expire(gictimer, vptimer->vp_index, in gic_vptimer_cb()
52 uint32_t mips_gictimer_get_sh_count(MIPSGICTimerState *gictimer) in mips_gictimer_get_sh_count() argument
55 if (gictimer->countstop) { in mips_gictimer_get_sh_count()
56 return gictimer->sh_counterlo; in mips_gictimer_get_sh_count()
60 for (i = 0; i < gictimer->num_vps; i++) { in mips_gictimer_get_sh_count()
61 if (timer_pending(gictimer->vptimers[i].qtimer) in mips_gictimer_get_sh_count()
62 && timer_expired(gictimer->vptimers[i].qtimer, now)) { in mips_gictimer_get_sh_count()
64 gic_vptimer_expire(gictimer, i, now); in mips_gictimer_get_sh_count()
67 return gictimer->sh_counterlo + (uint32_t)(now / TIMER_PERIOD); in mips_gictimer_get_sh_count()
71 void mips_gictimer_store_sh_count(MIPSGICTimerState *gictimer, uint64_t count) in mips_gictimer_store_sh_count() argument
76 if (gictimer->countstop || !gictimer->vptimers[0].qtimer) { in mips_gictimer_store_sh_count()
77 gictimer->sh_counterlo = count; in mips_gictimer_store_sh_count()
81 gictimer->sh_counterlo = count - (uint32_t)(now / TIMER_PERIOD); in mips_gictimer_store_sh_count()
83 for (i = 0; i < gictimer->num_vps; i++) { in mips_gictimer_store_sh_count()
84 gic_vptimer_update(gictimer, i, now); in mips_gictimer_store_sh_count()
89 uint32_t mips_gictimer_get_vp_compare(MIPSGICTimerState *gictimer, in mips_gictimer_get_vp_compare() argument
92 return gictimer->vptimers[vp_index].comparelo; in mips_gictimer_get_vp_compare()
95 void mips_gictimer_store_vp_compare(MIPSGICTimerState *gictimer, in mips_gictimer_store_vp_compare() argument
98 gictimer->vptimers[vp_index].comparelo = (uint32_t) compare; in mips_gictimer_store_vp_compare()
99 gic_vptimer_update(gictimer, vp_index, in mips_gictimer_store_vp_compare()
103 uint8_t mips_gictimer_get_countstop(MIPSGICTimerState *gictimer) in mips_gictimer_get_countstop() argument
105 return gictimer->countstop; in mips_gictimer_get_countstop()
108 void mips_gictimer_start_count(MIPSGICTimerState *gictimer) in mips_gictimer_start_count() argument
110 gictimer->countstop = 0; in mips_gictimer_start_count()
111 mips_gictimer_store_sh_count(gictimer, gictimer->sh_counterlo); in mips_gictimer_start_count()
114 void mips_gictimer_stop_count(MIPSGICTimerState *gictimer) in mips_gictimer_stop_count() argument
118 gictimer->countstop = 1; in mips_gictimer_stop_count()
120 gictimer->sh_counterlo += in mips_gictimer_stop_count()
122 for (i = 0; i < gictimer->num_vps; i++) { in mips_gictimer_stop_count()
123 timer_del(gictimer->vptimers[i].qtimer); in mips_gictimer_stop_count()
131 MIPSGICTimerState *gictimer = g_new(MIPSGICTimerState, 1); in mips_gictimer_init() local
132 gictimer->vptimers = g_new(MIPSGICTimerVPState, nvps); in mips_gictimer_init()
133 gictimer->countstop = 1; in mips_gictimer_init()
134 gictimer->num_vps = nvps; in mips_gictimer_init()
135 gictimer->opaque = opaque; in mips_gictimer_init()
136 gictimer->cb = cb; in mips_gictimer_init()
138 gictimer->vptimers[i].gictimer = gictimer; in mips_gictimer_init()
139 gictimer->vptimers[i].vp_index = i; in mips_gictimer_init()
140 gictimer->vptimers[i].qtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, in mips_gictimer_init()
142 &gictimer->vptimers[i]); in mips_gictimer_init()
144 return gictimer; in mips_gictimer_init()