From 86de700207fb0114ec52fafc36f84e1cbe508fd8 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Mon, 14 Feb 2022 00:33:18 +0000 Subject: entering idle loop works with timer --- kc/core/pit8253.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'kc/core/pit8253.c') 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); } -- cgit v1.3.1-1-g115d