summaryrefslogtreecommitdiff
path: root/kc/core/pit8253.c
diff options
context:
space:
mode:
Diffstat (limited to 'kc/core/pit8253.c')
-rw-r--r--kc/core/pit8253.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/kc/core/pit8253.c b/kc/core/pit8253.c
index 75e0467..8be2872 100644
--- a/kc/core/pit8253.c
+++ b/kc/core/pit8253.c
@@ -1,6 +1,7 @@
#include "pit8253.h"
#include "pic8259.h"
#include "port.h"
+#include "kprint.h"
#define PIT8253_DATA0 0x40
#define PIT8253_CMD 0x43
@@ -12,12 +13,28 @@
#define CONFIG_CHANNEL_0 (SEL_CHANNEL0|ACC_LOHI|MODE_RATE|BIN_COUNT)
+static uint64_t count = 0;
+
+int pit8253_callback(uint8_t irq)
+{
+ (void)irq;
+ count++;
+
+ if (!(count % (185)))
+ {
+ kprintf("it's been about %lu seconds\n", count / 18);
+ }
+
+ return 0;
+}
+
void pit8253_init(void)
{
outb(PIT8253_CMD, CONFIG_CHANNEL_0);
outb(PIT8253_DATA0, 0xff);
outb(PIT8253_DATA0, 0xff);
+ pic8259_irq_install(0, pit8253_callback);
pic8259_irq_unmask(0);
}