From 8a9208612eec8ddae4c418485d848ecfa0613699 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 30 Oct 2023 22:12:14 +0100 Subject: Meta: Move kernel and userland to their own folders. This is to allow both the kernel and the userland to share certain header files and to make the folder structure a bit more clear. --- drivers/pit.c | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 drivers/pit.c (limited to 'drivers/pit.c') diff --git a/drivers/pit.c b/drivers/pit.c deleted file mode 100644 index 711883c..0000000 --- a/drivers/pit.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "pit.h" - -#define PIT_IO_CHANNEL_0 0x40 -#define PIT_IO_MODE_COMMAND 0x43 - -uint64_t clock_num_ms_ticks = 0; -uint64_t pit_counter = 0; -uint16_t hertz; - -uint64_t pit_num_ms(void) { return clock_num_ms_ticks; } - -uint16_t read_pit_count(void) { - uint16_t count = 0; - - outb(PIT_IO_MODE_COMMAND, 0x0 /*0b00000000*/); - - count = inb(PIT_IO_CHANNEL_0); - count |= inb(PIT_IO_CHANNEL_0) << 8; - - return count; -} - -void set_pit_count(uint16_t hertz) { - uint16_t divisor = 1193180 / hertz; - - /* - * 0b00110110 - * ^^ - * channel - 0 - * ^^ - * r/w mode - LSB then MSB - * ^^^ - * mode - 3 Square Wave Mode - * ^ - * BCD - no - */ - outb(PIT_IO_MODE_COMMAND, 0x36 /*0b00110110*/); - outb(PIT_IO_CHANNEL_0, divisor & 0xFF); - outb(PIT_IO_CHANNEL_0, (divisor & 0xFF00) >> 8); -} - -__attribute__((interrupt)) void -int_clock(__attribute__((unused)) struct interrupt_frame *frame) { - outb(0x20, 0x20); - pit_counter++; - if (pit_counter >= hertz / 1000) { - pit_counter = 0; - clock_num_ms_ticks++; - } - switch_task(); -} - -void pit_install(void) { - install_handler(int_clock, INT_32_INTERRUPT_GATE(0x0), 0x20); -} -- cgit v1.2.3