| 459 | "i8254 timer frequency"); |
| 460 | |
| 461 | static unsigned |
| 462 | i8254_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 | |
| 500 | static int |
| 501 | attimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period) |
nothing calls this directly
no test coverage detected