From cc1bb63e27b82b8f634283bbdb219c7f0a6cb723 Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 30 Mar 2023 22:40:08 -0700 Subject: [PATCH] Moving components modules to a more proper directory --- .../framebuffer/framebuffer.c | 0 .../framebuffer/framebuffer.h | 0 gdt.c => components/gdt/gdt.c | 0 gdt.h => components/gdt/gdt.h | 5 +- gdt_seg.s => components/gdt/gdt_seg.s | 0 .../interrupts/interrupt_entry.s | 2 +- .../interrupts/interrupts.c | 0 .../interrupts/interrupts.h | 0 kbd.c => components/kbd/kbd.c | 0 kbd.h => components/kbd/kbd.h | 0 mem.c => components/mem/mem.c | 0 mem.h => components/mem/mem.h | 0 pit.c => components/pit/pit.c | 0 pit.h => components/pit/pit.h | 0 ports.h => components/ports/ports.h | 0 ports.s => components/ports/ports.s | 0 components/readme.md | 6 + serial.c => components/serial/serial.c | 0 serial.h => components/serial/serial.h | 0 tests.c => components/tests/tests.c | 0 tests.h => components/tests/tests.h | 0 types.h => components/types/types.h | 0 kernel.c => kernel/kernel.c | 0 kernel.h => kernel/kernel.h | 0 stlio.c | 123 ------------------ stlio.h | 23 ---- 26 files changed, 11 insertions(+), 148 deletions(-) rename framebuffer.c => components/framebuffer/framebuffer.c (100%) rename framebuffer.h => components/framebuffer/framebuffer.h (100%) rename gdt.c => components/gdt/gdt.c (100%) rename gdt.h => components/gdt/gdt.h (94%) rename gdt_seg.s => components/gdt/gdt_seg.s (100%) rename interrupt_entry.s => components/interrupts/interrupt_entry.s (98%) rename interrupts.c => components/interrupts/interrupts.c (100%) rename interrupts.h => components/interrupts/interrupts.h (100%) rename kbd.c => components/kbd/kbd.c (100%) rename kbd.h => components/kbd/kbd.h (100%) rename mem.c => components/mem/mem.c (100%) rename mem.h => components/mem/mem.h (100%) rename pit.c => components/pit/pit.c (100%) rename pit.h => components/pit/pit.h (100%) rename ports.h => components/ports/ports.h (100%) rename ports.s => components/ports/ports.s (100%) create mode 100644 components/readme.md rename serial.c => components/serial/serial.c (100%) rename serial.h => components/serial/serial.h (100%) rename tests.c => components/tests/tests.c (100%) rename tests.h => components/tests/tests.h (100%) rename types.h => components/types/types.h (100%) rename kernel.c => kernel/kernel.c (100%) rename kernel.h => kernel/kernel.h (100%) delete mode 100644 stlio.c delete mode 100644 stlio.h diff --git a/framebuffer.c b/components/framebuffer/framebuffer.c similarity index 100% rename from framebuffer.c rename to components/framebuffer/framebuffer.c diff --git a/framebuffer.h b/components/framebuffer/framebuffer.h similarity index 100% rename from framebuffer.h rename to components/framebuffer/framebuffer.h diff --git a/gdt.c b/components/gdt/gdt.c similarity index 100% rename from gdt.c rename to components/gdt/gdt.c diff --git a/gdt.h b/components/gdt/gdt.h similarity index 94% rename from gdt.h rename to components/gdt/gdt.h index 6e151c3..0b34823 100644 --- a/gdt.h +++ b/components/gdt/gdt.h @@ -1,6 +1,7 @@ +#ifndef GDT_H +#define GDT_H #include "types.h" - #define NO_GDT_ENTRIES 5 struct GDT_Entry { @@ -27,3 +28,5 @@ extern void load_gdt(); void gdt_configure_entry(u32 entry, u32 base, u32 limit, u8 access, u8 gran); void gdt_configure(); + +#endif diff --git a/gdt_seg.s b/components/gdt/gdt_seg.s similarity index 100% rename from gdt_seg.s rename to components/gdt/gdt_seg.s diff --git a/interrupt_entry.s b/components/interrupts/interrupt_entry.s similarity index 98% rename from interrupt_entry.s rename to components/interrupts/interrupt_entry.s index 5987dac..79845f8 100644 --- a/interrupt_entry.s +++ b/components/interrupts/interrupt_entry.s @@ -151,7 +151,7 @@ common_irq_handler: ; Remapped IRQ's for the APIC -# starting from irq 0 -> 15 but remapped to 32 -> 47 +; starting from irq 0 -> 15 but remapped to 32 -> 47 irq 0, 32 irq 1, 33 irq 2, 34 diff --git a/interrupts.c b/components/interrupts/interrupts.c similarity index 100% rename from interrupts.c rename to components/interrupts/interrupts.c diff --git a/interrupts.h b/components/interrupts/interrupts.h similarity index 100% rename from interrupts.h rename to components/interrupts/interrupts.h diff --git a/kbd.c b/components/kbd/kbd.c similarity index 100% rename from kbd.c rename to components/kbd/kbd.c diff --git a/kbd.h b/components/kbd/kbd.h similarity index 100% rename from kbd.h rename to components/kbd/kbd.h diff --git a/mem.c b/components/mem/mem.c similarity index 100% rename from mem.c rename to components/mem/mem.c diff --git a/mem.h b/components/mem/mem.h similarity index 100% rename from mem.h rename to components/mem/mem.h diff --git a/pit.c b/components/pit/pit.c similarity index 100% rename from pit.c rename to components/pit/pit.c diff --git a/pit.h b/components/pit/pit.h similarity index 100% rename from pit.h rename to components/pit/pit.h diff --git a/ports.h b/components/ports/ports.h similarity index 100% rename from ports.h rename to components/ports/ports.h diff --git a/ports.s b/components/ports/ports.s similarity index 100% rename from ports.s rename to components/ports/ports.s diff --git a/components/readme.md b/components/readme.md new file mode 100644 index 0000000..7f6a737 --- /dev/null +++ b/components/readme.md @@ -0,0 +1,6 @@ +# Components Library + +These are the smaller components that give the kernel actual behaviors. +These are pieces that are *practically* required for the OS to function at a +basic level but otherwise are not *technically* required for sheer load-level +operations. \ No newline at end of file diff --git a/serial.c b/components/serial/serial.c similarity index 100% rename from serial.c rename to components/serial/serial.c diff --git a/serial.h b/components/serial/serial.h similarity index 100% rename from serial.h rename to components/serial/serial.h diff --git a/tests.c b/components/tests/tests.c similarity index 100% rename from tests.c rename to components/tests/tests.c diff --git a/tests.h b/components/tests/tests.h similarity index 100% rename from tests.h rename to components/tests/tests.h diff --git a/types.h b/components/types/types.h similarity index 100% rename from types.h rename to components/types/types.h diff --git a/kernel.c b/kernel/kernel.c similarity index 100% rename from kernel.c rename to kernel/kernel.c diff --git a/kernel.h b/kernel/kernel.h similarity index 100% rename from kernel.h rename to kernel/kernel.h diff --git a/stlio.c b/stlio.c deleted file mode 100644 index 67f1c2e..0000000 --- a/stlio.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "types.h" -#include "kbd.h" -#include "stlio.h" -#include "pit.h" - -extern char kbd_key; -extern u8 kbd_state; - -static u8 COLOR_FG = Green; -static u8 COLOR_BG = White; - -#define write_char(c) write_cell_fb(c, COLOR_FG, COLOR_BG) - -// We are assuming null-terminated strings here -u32 strlen(const char* buffer) { - u32 i = 0; - char c = buffer[i]; - while(c != '\0') { - i++; - c = buffer[i]; - } - return i; -} - -u32 strcmp(const char* left, const char* right) { - u32 s = strlen(left); - for(u32 i = 0; i> 28; - putch(_chars[idx]); - } -} - -void putch(const char c) { - if(c == '\n') { - frame_buffer_newline(); - } - else { - write_char(c); - } -} diff --git a/stlio.h b/stlio.h deleted file mode 100644 index dbd257b..0000000 --- a/stlio.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef STLIO_H -#define STLIO_H -#include "types.h" -#include "framebuffer.h" -// Frame buffer driver - -// NOTE: not getting computed at compile time so we always have a call -#define LINE_LENGTH COLUMNS - -u32 strlen(const char*); - -u32 strcmp(const char*, const char*); - -u32 write(const char*, const u32); - -u32 read(char*, u32); - -void printf(const char*); - -void printhex(u32); - -void putch(const char); -#endif