diff options
| author | Ada Christine <adachristine18@gmail.com> | 2022-02-14 00:33:18 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2022-02-14 00:33:18 +0000 |
| commit | 86de700207fb0114ec52fafc36f84e1cbe508fd8 (patch) | |
| tree | 830649e3b7081e4c43d579a6ded67f7ee18add92 /kc/core/pit8253.c | |
| parent | e8a76b2f6b53d99640ceb2850bf4e45118b923f1 (diff) | |
entering idle loop works with timer
Diffstat (limited to 'kc/core/pit8253.c')
| -rw-r--r-- | kc/core/pit8253.c | 17 |
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); } |
