diff --git a/kernel/include/framebuffer.h b/kernel/include/framebuffer.h
new file mode 100644
index 0000000..dc26553
--- /dev/null
+++ b/kernel/include/framebuffer.h
@@ -0,0 +1,23 @@
+/* Calcite, kernel/include/framebuffer.h
+ * Copyright 2025 Benji Dial
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#include
+
+extern uint8_t *fb_base;
+extern int fb_width;
+extern int fb_height;
+extern int fb_pitch;
diff --git a/kernel/include/keyboard.h b/kernel/include/keyboard.h
new file mode 100644
index 0000000..e8a909b
--- /dev/null
+++ b/kernel/include/keyboard.h
@@ -0,0 +1,20 @@
+/* Calcite, kernel/include/keyboard.h
+ * Copyright 2025 Benji Dial
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#pragma once
+
+void on_keyboard_irq();
diff --git a/kernel/src/entry.c b/kernel/src/entry.c
index 724c0fa..fb8d2d1 100644
--- a/kernel/src/entry.c
+++ b/kernel/src/entry.c
@@ -15,7 +15,9 @@
* this program. If not, see .
*/
+#include
#include
+#include
#include
#include
#include
@@ -75,11 +77,6 @@ static void map_kernel_region(
physical_start + i, (uint8_t *)virtual_start + i, writable, executable);
}
-static uint8_t *fb_base;
-static int fb_width;
-static int fb_height;
-static int fb_pitch;
-
static uint8_t *initfs_start;
static uint64_t initfs_length;
@@ -179,11 +176,17 @@ static uint64_t initfs_length;
[[noreturn]] static void with_kernel_page_tables() {
- //further initialization
+ //set initfs
set_initfs(initfs_start, initfs_length);
+
+ //set up interrupts
+
+ set_irq_handler(0x01, &on_keyboard_irq);
enable_interrupts();
+ //halt repeatedly
+
while (1)
__asm__ ("hlt");
diff --git a/kernel/src/framebuffer.c b/kernel/src/framebuffer.c
new file mode 100644
index 0000000..e261248
--- /dev/null
+++ b/kernel/src/framebuffer.c
@@ -0,0 +1,23 @@
+/* Calcite, kernel/src/framebuffer.c
+ * Copyright 2025 Benji Dial
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#include
+
+uint8_t *fb_base;
+int fb_width;
+int fb_height;
+int fb_pitch;
diff --git a/kernel/src/interrupts.c b/kernel/src/interrupts.c
index 28483e3..94575aa 100644
--- a/kernel/src/interrupts.c
+++ b/kernel/src/interrupts.c
@@ -192,8 +192,8 @@ void enable_interrupts_asm(
void enable_interrupts() {
- the_tss.ist1 = (uint64_t)&interrupt_stack_one;
- the_tss.ist2 = (uint64_t)&interrupt_stack_two;
+ the_tss.ist1 = (uint64_t)interrupt_stack_one + INTERRUPT_STACK_SIZE;
+ the_tss.ist2 = (uint64_t)interrupt_stack_two + INTERRUPT_STACK_SIZE;
//having the table past the end of the tss will lead to a gpf when the
//cpu tries to access it, which is the same effect as a disabled port.
diff --git a/kernel/src/keyboard.asm b/kernel/src/keyboard.asm
new file mode 100644
index 0000000..275250b
--- /dev/null
+++ b/kernel/src/keyboard.asm
@@ -0,0 +1,38 @@
+ ; Calcite, kernel/src/paging.asm
+ ; Copyright 2025 Benji Dial
+ ;
+ ; This program is free software: you can redistribute it and/or modify
+ ; it under the terms of the GNU General Public License as published by
+ ; the Free Software Foundation, either version 3 of the License, or (at
+ ; your option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but
+ ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ ; more details.
+ ;
+ ; You should have received a copy of the GNU General Public License along with
+ ; this program. If not, see .
+
+
+bits 64
+
+section .text
+
+;referenced in keyboard.c
+;return type is int
+;returns -1 if no byte available
+global read_keyboard_byte
+read_keyboard_byte:
+
+ in al, 0x64
+ test al, 0x01
+ jz .no_data
+
+ xor eax, eax
+ in al, 0x60
+ ret
+
+.no_data:
+ mov eax, -1
+ ret
diff --git a/kernel/src/keyboard.c b/kernel/src/keyboard.c
new file mode 100644
index 0000000..33a7f6a
--- /dev/null
+++ b/kernel/src/keyboard.c
@@ -0,0 +1,40 @@
+/* Calcite, kernel/src/keyboard.c
+ * Copyright 2025 Benji Dial
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#include
+#include
+
+//defined in keyboard.asm
+//returns -1 if no byte available
+int read_keyboard_byte();
+
+static uint32_t color = 1;
+
+void on_keyboard_irq() {
+
+ while (read_keyboard_byte() != -1)
+ ;
+
+ color ^= color << 13;
+ color ^= color >> 17;
+ color ^= color << 5;
+
+ for (int y = 0; y < fb_height; ++y)
+ for (int x = 0; x < fb_width; ++x)
+ *(uint32_t *)&fb_base[y * fb_pitch + x * 4] = color & 0x00ffffff;
+
+}