summaryrefslogtreecommitdiff
path: root/arch/i386/kernel
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2022-01-21 12:10:05 -0600
committerDanny Holman <dholman@gymli.org>2022-01-21 12:10:05 -0600
commit8cd22309667cf3da9c357e5b7dca43e8b6a2f9c0 (patch)
tree05a7e450a702a5fc744b4bd1f96abf1952ece566 /arch/i386/kernel
parentarch: i386: fix coding style issue (diff)
downloadbox-8cd22309667cf3da9c357e5b7dca43e8b6a2f9c0.tar.gz
box-8cd22309667cf3da9c357e5b7dca43e8b6a2f9c0.tar.zst
box-8cd22309667cf3da9c357e5b7dca43e8b6a2f9c0.zip
arch: i386: move non-critial files out of boot
Move all files not needed for the bootstrap process out of boot and into the main x86 source directory. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to '')
-rw-r--r--arch/i386/kernel/pic.c (renamed from arch/i386/boot/pic.c)0
-rw-r--r--arch/i386/kernel/syscall.c42
-rw-r--r--arch/i386/kernel/tty.c (renamed from arch/i386/boot/tty.c)5
3 files changed, 45 insertions, 2 deletions
diff --git a/arch/i386/boot/pic.c b/arch/i386/kernel/pic.c
index 69a0785..69a0785 100644
--- a/arch/i386/boot/pic.c
+++ b/arch/i386/kernel/pic.c
diff --git a/arch/i386/kernel/syscall.c b/arch/i386/kernel/syscall.c
new file mode 100644
index 0000000..570f0de
--- /dev/null
+++ b/arch/i386/kernel/syscall.c
@@ -0,0 +1,42 @@
+#include <kernel/syscall.h>
+#include <kernel/io.h>
+#include <stddef.h>
+
+void *(*syscall_handlers[30])(struct isr_frame *frame);
+
+void syscall_dispatch(struct isr_frame *frame) {
+ if (syscall_handlers[frame->eax] != NULL)
+ syscall_handlers[frame->eax](frame);
+ else
+ kprintf("Error: Invalid system call number: %d\n", frame->eax);
+ __asm__ volatile("cli;hlt");
+}
+
+void register_syscall(void *handler(struct isr_frame*), int num) {
+ syscall_handlers[num] = handler;
+}
+
+void sys_stop(struct isr_frame *frame) {
+ kprintf("SYSTEM CALL: STOP\n");
+ halt_catch_fire(frame);
+}
+
+void sys_status(struct isr_frame *frame) {
+ kprintf("SYSTEM CALL: STATUS\n");
+ dump_reg(frame);
+}
+
+void dump_reg(struct isr_frame *frame) {
+ kprintf("Registers at interrupt:\n");
+ kprintf("\tEAX = %x\n", frame->eax);
+ kprintf("\tEBX = %x\n", frame->ebx);
+ kprintf("\tECX = %x\n", frame->ecx);
+ kprintf("\tEDX = %x\n", frame->edx);
+ kprintf("\tESI = %x\n", frame->esi);
+ kprintf("\tEDI = %x\n", frame->edi);
+ kprintf("\tESP = %x\n", frame->esp);
+ kprintf("\tEBP = %x\n", frame->ebp);
+ kprintf("\tEIP = %x\n", frame->eip);
+ kprintf("\tEFLAGS = %x\n", frame->eflags);
+ kprintf("Current code selector: %d\n", frame->cs);
+}
diff --git a/arch/i386/boot/tty.c b/arch/i386/kernel/tty.c
index aa77736..f929408 100644
--- a/arch/i386/boot/tty.c
+++ b/arch/i386/kernel/tty.c
@@ -1,4 +1,4 @@
-#include "vga.h"
+#include <kernel/vga.h>
#include <kernel/tty.h>
#include <kernel/string.h>
#include <stddef.h>
@@ -6,7 +6,8 @@
static const size_t VGA_WIDTH = 80;
static const size_t VGA_HEIGHT = 25;
-static uint16_t *const VGA_MEMORY = (uint16_t*)0xC03FF000;
+//static uint16_t *const VGA_MEMORY = (uint16_t*)0xC03FF000;
+static uint16_t *const VGA_MEMORY = (uint16_t*)0xB8000;
static size_t terminal_row;
static size_t terminal_column;