summaryrefslogtreecommitdiff
path: root/kc/core/pit8253.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2022-02-13 18:47:58 +0000
committerAda Christine <adachristine18@gmail.com>2022-02-13 18:47:58 +0000
commite8a76b2f6b53d99640ceb2850bf4e45118b923f1 (patch)
tree9e7ab33233883a2db2aa60393b66e6d526edbaf1 /kc/core/pit8253.c
parent78788acf026b21b516fd981d321b0809c07de921 (diff)
rudimentary irq and timer support
Diffstat (limited to 'kc/core/pit8253.c')
-rw-r--r--kc/core/pit8253.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/kc/core/pit8253.c b/kc/core/pit8253.c
new file mode 100644
index 0000000..75e0467
--- /dev/null
+++ b/kc/core/pit8253.c
@@ -0,0 +1,36 @@
+#include "pit8253.h"
+#include "pic8259.h"
+#include "port.h"
+
+#define PIT8253_DATA0 0x40
+#define PIT8253_CMD 0x43
+
+#define SEL_CHANNEL0 0x0
+#define ACC_LOHI 0x30
+#define MODE_RATE 0x04
+#define BIN_COUNT 0x0
+
+#define CONFIG_CHANNEL_0 (SEL_CHANNEL0|ACC_LOHI|MODE_RATE|BIN_COUNT)
+
+void pit8253_init(void)
+{
+ outb(PIT8253_CMD, CONFIG_CHANNEL_0);
+ outb(PIT8253_DATA0, 0xff);
+ outb(PIT8253_DATA0, 0xff);
+
+ pic8259_irq_unmask(0);
+}
+
+void pit8253_start(void)
+{
+}
+
+void pit8253_stop(void)
+{
+}
+
+void pit8253_set_hz(uint16_t hz)
+{
+ (void)hz;
+}
+