diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/boot/syscall.c | 21 | ||||
-rw-r--r-- | arch/i386/boot/tss.c | 26 | ||||
-rw-r--r-- | arch/i386/boot/tss.h | 39 | ||||
-rw-r--r-- | arch/i386/include/kernel/syscall.h (renamed from arch/i386/boot/syscall.h) | 4 | ||||
-rw-r--r-- | arch/i386/include/kernel/vga.h (renamed from arch/i386/boot/vga.h) | 0 | ||||
-rw-r--r-- | arch/i386/kernel/pic.c (renamed from arch/i386/boot/pic.c) | 0 | ||||
-rw-r--r-- | arch/i386/kernel/syscall.c | 42 | ||||
-rw-r--r-- | arch/i386/kernel/tty.c (renamed from arch/i386/boot/tty.c) | 5 | ||||
-rw-r--r-- | arch/i386/make.config | 6 |
9 files changed, 52 insertions, 91 deletions
diff --git a/arch/i386/boot/syscall.c b/arch/i386/boot/syscall.c deleted file mode 100644 index fb613b3..0000000 --- a/arch/i386/boot/syscall.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "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 print_hello(struct isr_frame *frame) { - kprintf("Hello syscall\n"); -} diff --git a/arch/i386/boot/tss.c b/arch/i386/boot/tss.c deleted file mode 100644 index 2edfa76..0000000 --- a/arch/i386/boot/tss.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "tss.h" -#include <kernel/string.h> - -struct tss tss_entry; - -uint64_t create_tss_entry(uint16_t ss0, uint32_t esp0) { - uint32_t base = (uint32_t)&tss_entry; - uint32_t limit = base + sizeof(&tss_entry); - uint64_t ret = create_gdt_entry(base, limit, 0xE9); - - memset(&tss_entry, 0, sizeof(struct tss)); - tss_entry.ss0 = ss0; - tss_entry.esp0 = esp0; - tss_entry.cs = 0x08; - tss_entry.ss = 0x13; - tss_entry.ds = 0x13; - tss_entry.es = 0x13; - tss_entry.fs = 0x13; - tss_entry.gs = 0x13; - tss_entry.io_offset = sizeof(struct tss) & 0xFFFF; - return ret; -} - -void set_kernel_stack(uint32_t stack) { - tss_entry.esp0 = stack; -} diff --git a/arch/i386/boot/tss.h b/arch/i386/boot/tss.h deleted file mode 100644 index 28bae6e..0000000 --- a/arch/i386/boot/tss.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef I386_TSS_H -#define I386_TSS_H - -#include <stdint.h> - -struct tss { - uint32_t link; - uint32_t esp0; - uint32_t ss0; - uint32_t esp1; - uint32_t ss2; - uint32_t cr3; - uint32_t eip; - uint32_t eflags; - uint32_t eax; - uint32_t ecx; - uint32_t edx; - uint32_t ebx; - uint32_t esp; - uint32_t ebp; - uint32_t esi; - uint32_t edi; - uint32_t es; - uint32_t cs; - uint32_t ss; - uint32_t ds; - uint32_t fs; - uint32_t gs; - uint32_t ldtr; - uint32_t io_offset; -}__attribute__((packed)); - -void flush_tss(void); - -uint64_t create_gdt_entry(uint32_t base, uint32_t limit, uint16_t flag); -uint64_t create_tss_entry(uint16_t ss0, uint32_t esp0); -void set_kernel_stack(uint32_t stack); - -#endif diff --git a/arch/i386/boot/syscall.h b/arch/i386/include/kernel/syscall.h index 376fb7c..cded732 100644 --- a/arch/i386/boot/syscall.h +++ b/arch/i386/include/kernel/syscall.h @@ -5,5 +5,9 @@ void syscall_dispatch(struct isr_frame *frame); void register_syscall(void *handler(struct isr_frame*), int num); +void sys_stop(struct isr_frame *frame); +void sys_status(struct isr_frame *frame); + +void dump_reg(struct isr_frame *frame); #endif diff --git a/arch/i386/boot/vga.h b/arch/i386/include/kernel/vga.h index e89f202..e89f202 100644 --- a/arch/i386/boot/vga.h +++ b/arch/i386/include/kernel/vga.h 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; diff --git a/arch/i386/make.config b/arch/i386/make.config index 82e8faf..ec9c631 100644 --- a/arch/i386/make.config +++ b/arch/i386/make.config @@ -5,9 +5,9 @@ KERNEL_ARCH_LIBS= KERNEL_ARCH_OBJS=$(ARCHDIR)/boot/boot.o \ $(ARCHDIR)/boot/isr.o \ - $(ARCHDIR)/boot/tty.o \ - $(ARCHDIR)/boot/pic.o \ $(ARCHDIR)/boot/idt.o \ - $(ARCHDIR)/boot/syscall.o \ $(ARCHDIR)/boot/gdt.o \ + $(ARCHDIR)/kernel/tty.o \ $(ARCHDIR)/kernel/serial.o \ + $(ARCHDIR)/kernel/pic.o \ + $(ARCHDIR)/kernel/syscall.o \ |