From 0583c8c1a345206906604816ef8a859738f88125 Mon Sep 17 00:00:00 2001 From: nub31 Date: Wed, 3 Sep 2025 17:43:23 +0200 Subject: [PATCH] ... --- src/arch/{arch.h => api.h} | 0 src/arch/x86_64/boot/boot.asm | 1 + src/arch/x86_64/entry.c | 6 +- src/arch/x86_64/interrupts/exceptions.c | 2 +- src/arch/x86_64/keyboard.c | 107 ------------------------ src/arch/x86_64/keyboard.h | 19 ----- src/arch/x86_64/{ => memory}/mmap.c | 2 +- src/arch/x86_64/{ => memory}/mmap.h | 4 +- src/arch/x86_64/{ => vga}/vga.c | 0 src/arch/x86_64/{ => vga}/vga.h | 0 src/kernel/pmm.c | 2 +- src/stdlib/stdio.c | 2 +- 12 files changed, 10 insertions(+), 135 deletions(-) rename src/arch/{arch.h => api.h} (100%) delete mode 100644 src/arch/x86_64/keyboard.c delete mode 100644 src/arch/x86_64/keyboard.h rename src/arch/x86_64/{ => memory}/mmap.c (98%) rename src/arch/x86_64/{ => memory}/mmap.h (52%) rename src/arch/x86_64/{ => vga}/vga.c (100%) rename src/arch/x86_64/{ => vga}/vga.h (100%) diff --git a/src/arch/arch.h b/src/arch/api.h similarity index 100% rename from src/arch/arch.h rename to src/arch/api.h diff --git a/src/arch/x86_64/boot/boot.asm b/src/arch/x86_64/boot/boot.asm index fdc22e4..ad67d1d 100644 --- a/src/arch/x86_64/boot/boot.asm +++ b/src/arch/x86_64/boot/boot.asm @@ -1,4 +1,5 @@ global _start +global pml4 extern entry %define FLAGS 0b10 diff --git a/src/arch/x86_64/entry.c b/src/arch/x86_64/entry.c index 8e14aab..ed8da34 100644 --- a/src/arch/x86_64/entry.c +++ b/src/arch/x86_64/entry.c @@ -1,11 +1,11 @@ #include "../../kernel/kernel.h" -#include "../arch.h" +#include "../api.h" #include "interrupts/idt.h" #include "interrupts/irq.h" -#include "mmap.h" +#include "memory/mmap.h" #include "multiboot.h" #include "util.h" -#include "vga.h" +#include "vga/vga.h" #include #include diff --git a/src/arch/x86_64/interrupts/exceptions.c b/src/arch/x86_64/interrupts/exceptions.c index 01112d8..fee04d0 100644 --- a/src/arch/x86_64/interrupts/exceptions.c +++ b/src/arch/x86_64/interrupts/exceptions.c @@ -1,5 +1,5 @@ #include "exceptions.h" -#include "../../arch.h" +#include "../../api.h" static const char* exception_messages[32] = { "divide by zero", diff --git a/src/arch/x86_64/keyboard.c b/src/arch/x86_64/keyboard.c deleted file mode 100644 index 156b644..0000000 --- a/src/arch/x86_64/keyboard.c +++ /dev/null @@ -1,107 +0,0 @@ -// #include "keyboard.h" -// #include "interrupts.h" -// #include "util.h" -// #include - -// #define SCANCODE_LEFT_SHIFT 42 -// #define SCANCODE_RIGHT_SHIFT 54 -// #define SCANCODE_CAPS_LOCK 58 - -// #define KEYBOARD_HANDLERS_LENGTH 32 - -// unsigned const char us_keymap[128] = { -// 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', 'q', 'w', -// 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', -// 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', -// 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// 0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// }; - -// unsigned const char us_keymap_shift[128] = { -// 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', '\t', 'Q', 'W', -// 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0, 'A', 'S', 'D', 'F', 'G', 'H', -// 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', -// 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// 0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// }; - -// bool shift = false; -// bool caps_lock = false; - -// // todo(nub): make dynamic when a memory allocator is implemented -// static keyboard_handler_t keyboard_handlers[KEYBOARD_HANDLERS_LENGTH]; -// static size_t handler_index = 0; - -// char scan_code_to_ascii(uint8_t scan_code) -// { -// if (scan_code >= 128) -// { -// return 0; -// } - -// if ((!caps_lock && shift) || (caps_lock && !shift)) -// { -// return us_keymap_shift[scan_code]; -// } -// else -// { -// return us_keymap[scan_code]; -// } -// } - -// void handle_keyboard(const isr_frame_t* frame) -// { -// uint8_t code = inb(0x60); -// uint8_t scan_code = code & 0x7F; -// bool pressed = (code & 0x80) == 0; - -// switch (scan_code) -// { -// case SCANCODE_LEFT_SHIFT: -// case SCANCODE_RIGHT_SHIFT: -// { -// shift = pressed; -// break; -// } -// case SCANCODE_CAPS_LOCK: -// { -// if (pressed) -// { -// caps_lock = !caps_lock; -// } -// break; -// } -// default: -// { -// keyboard_event_t event = { -// .scan_code = scan_code, -// .pressed = pressed, -// .caps_lock = caps_lock, -// .shift = shift, -// .ascii = scan_code_to_ascii(scan_code), -// }; - -// for (size_t i = 0; i < handler_index; i++) -// { -// keyboard_handlers[i](&event); -// } -// } -// } -// } - -// void register_keypress_handler(const keyboard_handler_t handler) -// { -// // todo(nub31): remove when a memory allocator is implemented and -// // keyboard_handlers is a dynamic list -// if (handler_index >= KEYBOARD_HANDLERS_LENGTH) -// { -// } - -// keyboard_handlers[handler_index] = handler; -// handler_index += 1; -// } - -// void keyboard_init() -// { -// register_irq_handler(1, handle_keyboard); -// } \ No newline at end of file diff --git a/src/arch/x86_64/keyboard.h b/src/arch/x86_64/keyboard.h deleted file mode 100644 index 7d5ad41..0000000 --- a/src/arch/x86_64/keyboard.h +++ /dev/null @@ -1,19 +0,0 @@ -// #pragma once - -// #include -// #include - -// typedef struct -// { -// uint8_t scan_code; -// bool pressed; -// bool shift; -// bool caps_lock; -// char ascii; -// } keyboard_event_t; - -// typedef void (*keyboard_handler_t)(const keyboard_event_t*); - -// void keyboard_init(); -// void register_keypress_handler(keyboard_handler_t handler); -// char scan_code_to_ascii(uint8_t scan_code); \ No newline at end of file diff --git a/src/arch/x86_64/mmap.c b/src/arch/x86_64/memory/mmap.c similarity index 98% rename from src/arch/x86_64/mmap.c rename to src/arch/x86_64/memory/mmap.c index 047870c..2ed8567 100644 --- a/src/arch/x86_64/mmap.c +++ b/src/arch/x86_64/memory/mmap.c @@ -1,5 +1,5 @@ #include "mmap.h" -#include "../arch.h" +#include "../../api.h" #include #include diff --git a/src/arch/x86_64/mmap.h b/src/arch/x86_64/memory/mmap.h similarity index 52% rename from src/arch/x86_64/mmap.h rename to src/arch/x86_64/memory/mmap.h index 838c45c..c5bf237 100644 --- a/src/arch/x86_64/mmap.h +++ b/src/arch/x86_64/memory/mmap.h @@ -1,6 +1,6 @@ #pragma once -#include "../arch.h" -#include "multiboot.h" +#include "../../api.h" +#include "../multiboot.h" void map_memory(multiboot_info_t* mbd); diff --git a/src/arch/x86_64/vga.c b/src/arch/x86_64/vga/vga.c similarity index 100% rename from src/arch/x86_64/vga.c rename to src/arch/x86_64/vga/vga.c diff --git a/src/arch/x86_64/vga.h b/src/arch/x86_64/vga/vga.h similarity index 100% rename from src/arch/x86_64/vga.h rename to src/arch/x86_64/vga/vga.h diff --git a/src/kernel/pmm.c b/src/kernel/pmm.c index f66b8b2..04ac7d5 100644 --- a/src/kernel/pmm.c +++ b/src/kernel/pmm.c @@ -1,5 +1,5 @@ #include "pmm.h" -#include "../arch/arch.h" +#include "../arch/api.h" #include #include #include diff --git a/src/stdlib/stdio.c b/src/stdlib/stdio.c index 06717c0..d3d920e 100644 --- a/src/stdlib/stdio.c +++ b/src/stdlib/stdio.c @@ -1,4 +1,4 @@ -#include "../arch/arch.h" +#include "../arch/api.h" #include #include #include