MCPcopy Create free account
hub / github.com/F-Stack/f-stack / i8254_get_timecount

Function i8254_get_timecount

freebsd/x86/isa/clock.c:461–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459 "i8254 timer frequency");
460
461static unsigned
462i8254_get_timecount(struct timecounter *tc)
463{
464 device_t dev = (device_t)tc->tc_priv;
465 struct attimer_softc *sc = device_get_softc(dev);
466 register_t flags;
467 uint16_t count;
468 u_int high, low;
469
470 if (sc->period == 0)
471 return (i8254_max_count - getit());
472
473#ifdef __amd64__
474 flags = read_rflags();
475#else
476 flags = read_eflags();
477#endif
478 mtx_lock_spin(&clock_lock);
479
480 /* Select timer0 and latch counter value. */
481 outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
482
483 low = inb(TIMER_CNTR0);
484 high = inb(TIMER_CNTR0);
485 count = i8254_max_count - ((high << 8) | low);
486 if (count < i8254_lastcount ||
487 (!i8254_ticked && (clkintr_pending ||
488 ((count < 20 || (!(flags & PSL_I) &&
489 count < i8254_max_count / 2u)) &&
490 i8254_pending != NULL && i8254_pending(i8254_intsrc))))) {
491 i8254_ticked = 1;
492 i8254_offset += i8254_max_count;
493 }
494 i8254_lastcount = count;
495 count += i8254_offset;
496 mtx_unlock_spin(&clock_lock);
497 return (count);
498}
499
500static int
501attimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)

Callers

nothing calls this directly

Calls 6

device_get_softcFunction · 0.85
getitFunction · 0.85
read_rflagsFunction · 0.85
read_eflagsFunction · 0.85
outbFunction · 0.50
inbFunction · 0.50

Tested by

no test coverage detected