Lines Matching defs:vatpit

29 __FBSDID("$FreeBSD: releng/11.0/sys/amd64/vmm/io/vatpit.c 283291 2015-05-22 17:05:21Z jkim $");
45 #include "vatpit.h"
49 #define VATPIT_LOCK(vatpit) mtx_lock_spin(&((vatpit)->mtx))
50 #define VATPIT_UNLOCK(vatpit) mtx_unlock_spin(&((vatpit)->mtx))
51 #define VATPIT_LOCKED(vatpit) mtx_owned(&((vatpit)->mtx))
73 struct vatpit *vatpit;
94 struct vatpit {
103 static void pit_timer_start_cntr0(struct vatpit *vatpit);
106 vatpit_get_out(struct vatpit *vatpit, int channel)
112 c = &vatpit->channel[channel];
116 delta_ticks = (sbinuptime() - c->now_sbt) / vatpit->freq_sbt;
131 struct vatpit *vatpit;
135 vatpit = arg->vatpit;
136 c = &vatpit->channel[arg->channel_num];
139 VM_CTR1(vatpit->vm, "atpit t%d fired", arg->channel_num);
141 VATPIT_LOCK(vatpit);
152 pit_timer_start_cntr0(vatpit);
155 vatpic_pulse_irq(vatpit->vm, 0);
156 vioapic_pulse_irq(vatpit->vm, 2);
159 VATPIT_UNLOCK(vatpit);
164 pit_timer_start_cntr0(struct vatpit *vatpit)
169 c = &vatpit->channel[0];
171 delta = c->initial * vatpit->freq_sbt;
191 pit_update_counter(struct vatpit *vatpit, struct channel *c, bool latch)
214 delta_ticks = (sbinuptime() - c->now_sbt) / vatpit->freq_sbt;
228 pit_readback1(struct vatpit *vatpit, int channel, uint8_t cmd)
232 c = &vatpit->channel[channel];
239 (void) pit_update_counter(vatpit, c, true);
249 if (c->mode == TIMER_INTTC && vatpit_get_out(vatpit, channel))
259 pit_readback(struct vatpit *vatpit, uint8_t cmd)
268 error = pit_readback1(vatpit, 0, cmd);
270 error = pit_readback1(vatpit, 1, cmd);
272 error = pit_readback1(vatpit, 2, cmd);
279 vatpit_update_mode(struct vatpit *vatpit, uint8_t val)
289 return (pit_readback(vatpit, val));
306 c = &vatpit->channel[sel >> 6];
308 pit_update_counter(vatpit, c, true);
322 struct vatpit *vatpit;
327 vatpit = vm_atpit(vm);
336 VM_CTR0(vatpit->vm, "vatpit attempt to read mode");
340 VATPIT_LOCK(vatpit);
341 error = vatpit_update_mode(vatpit, val);
342 VATPIT_UNLOCK(vatpit);
350 c = &vatpit->channel[port - TIMER_CNTR0];
352 VATPIT_LOCK(vatpit);
371 tmp = pit_update_counter(vatpit, c, false);
390 pit_timer_start_cntr0(vatpit);
396 VATPIT_UNLOCK(vatpit);
405 struct vatpit *vatpit;
407 vatpit = vm_atpit(vm);
410 VATPIT_LOCK(vatpit);
411 if (vatpit_get_out(vatpit, 2))
416 VATPIT_UNLOCK(vatpit);
422 struct vatpit *
425 struct vatpit *vatpit;
430 vatpit = malloc(sizeof(struct vatpit), M_VATPIT, M_WAITOK | M_ZERO);
431 vatpit->vm = vm;
433 mtx_init(&vatpit->mtx, "vatpit lock", NULL, MTX_SPIN);
436 vatpit->freq_sbt = bttosbt(bt);
439 callout_init(&vatpit->channel[i].callout, 1);
440 arg = &vatpit->channel[i].callout_arg;
441 arg->vatpit = vatpit;
445 return (vatpit);
449 vatpit_cleanup(struct vatpit *vatpit)
454 callout_drain(&vatpit->channel[i].callout);
456 free(vatpit, M_VATPIT);