diff --git a/src/system/kernel/arch/x86/timers/pit.h b/src/system/kernel/arch/x86/timers/pit.h index f237501f35..13420aeb33 100644 --- a/src/system/kernel/arch/x86/timers/pit.h +++ b/src/system/kernel/arch/x86/timers/pit.h @@ -7,6 +7,39 @@ #include +/* ports */ +#define PIT_CTRL 0x43 +#define PIT_CNT0 0x40 +#define PIT_CNT1 0x41 +#define PIT_CNT2 0x42 + +/* commands */ +#define PIT_SELCH0 0x00 +#define PIT_SELCH1 0x40 +#define PIT_SELCH2 0x80 + +#define PIT_RWLOW 0x10 +#define PIT_RWHIGH 0x20 +#define PIT_RWBOTH 0x30 + +#define PIT_MD_INTON0 0x00 +#define PIT_MD_ONESHOT 0x02 +#define PIT_MD_RTGEN 0x04 +#define PIT_MD_SQGEN 0x06 +#define PIT_MD_SW_STRB 0x08 +#define PIT_MD_HW_STRB 0x0A + +#define PIT_BCD 0x01 + +#define PIT_LATCH 0x00 + +#define PIT_READ 0xF0 +#define PIT_CNT 0x20 +#define PIT_STAT 0x10 + +#define PIT_CLOCK_RATE 1193180 +#define PIT_MAX_TIMER_INTERVAL (0xffff * 1000000ll / PIT_CLOCK_RATE) + /* Method Prototypes */ static int pit_get_prio(void); static status_t pit_set_hardware_timer(bigtime_t relativeTimeout); diff --git a/src/system/kernel/arch/x86/timers/x86_pit.c b/src/system/kernel/arch/x86/timers/x86_pit.c index c07d77f367..a9007d124a 100644 --- a/src/system/kernel/arch/x86/timers/x86_pit.c +++ b/src/system/kernel/arch/x86/timers/x86_pit.c @@ -15,9 +15,6 @@ #include "pit.h" -#define PIT_CLOCK_RATE 1193180 -#define PIT_MAX_TIMER_INTERVAL (0xffff * 1000000ll / PIT_CLOCK_RATE) - static bool sPITTimerInitialized = false; struct timer_info gPITTimer = { @@ -55,9 +52,9 @@ pit_set_hardware_timer(bigtime_t relativeTimeout) else nextEventClocks = 0xffff; - out8(0x30, 0x43); - out8(nextEventClocks & 0xff, 0x40); - out8((nextEventClocks >> 8) & 0xff, 0x40); + out8(PIT_SELCH0 | PIT_RWBOTH | PIT_MD_INTON0, PIT_CTRL); + out8(nextEventClocks & 0xff, PIT_CNT0); + out8((nextEventClocks >> 8) & 0xff, PIT_CNT0); arch_int_enable_io_interrupt(0); return B_OK; @@ -78,9 +75,9 @@ pit_init(struct kernel_args *args) if (sPITTimerInitialized) { return B_OK; } - + install_io_interrupt_handler(0, &pit_timer_interrupt, NULL, 0); - pit_clear_hardware_timer(); + pit_clear_hardware_timer(); sPITTimerInitialized = true;