diff options
-rw-r--r-- | apps/Makefile | 2 | ||||
-rw-r--r-- | apps/init.c (renamed from apps/root.c) | 2 | ||||
-rwxr-xr-x | run | 1 | ||||
-rw-r--r-- | src/drivers/interrupts.asm | 14 | ||||
-rw-r--r-- | src/drivers/interrupts.c | 40 | ||||
-rw-r--r-- | src/features/fs.c | 2 | ||||
-rw-r--r-- | src/features/load.c | 4 | ||||
-rw-r--r-- | src/features/proc.c | 4 | ||||
-rw-r--r-- | src/features/syscall.c | 2 | ||||
-rw-r--r-- | src/inc/syscall.h | 2 | ||||
-rw-r--r-- | src/main.c | 2 |
11 files changed, 50 insertions, 25 deletions
diff --git a/apps/Makefile b/apps/Makefile index 56e5472..91d7920 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,6 +1,6 @@ # MIT License, Copyright (c) 2020 Marvin Borner -COBJS = a.o b.o root.o +COBJS = a.o b.o init.o CC = ../cross/opt/bin/i686-elf-gcc LD = ../cross/opt/bin/i686-elf-ld OC = ../cross/opt/bin/i686-elf-objcopy diff --git a/apps/root.c b/apps/init.c index 097d0db..bd33033 100644 --- a/apps/root.c +++ b/apps/init.c @@ -42,7 +42,7 @@ void serial_print(const char *data) void main() { - serial_print("root loaded\n"); + serial_print("Init loaded\n"); __asm__ volatile("int $0x80"); while (1) { }; @@ -136,6 +136,7 @@ make_tidy() { make_clean() { rm -rf build/ + make clean } if [ "${mode}" = "cross" ]; then diff --git a/src/drivers/interrupts.asm b/src/drivers/interrupts.asm index 59c323c..8f8afbb 100644 --- a/src/drivers/interrupts.asm +++ b/src/drivers/interrupts.asm @@ -37,13 +37,6 @@ irq_common_stub: push fs push gs - mov ax, 0x10 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - cld - push esp call irq_handler add esp, 4 @@ -120,13 +113,6 @@ isr_common_stub: push fs push gs - mov ax, 0x10 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - cld - push esp call isr_handler add esp, 4 diff --git a/src/drivers/interrupts.c b/src/drivers/interrupts.c index 08f4c15..9ad2529 100644 --- a/src/drivers/interrupts.c +++ b/src/drivers/interrupts.c @@ -118,6 +118,42 @@ void irq_install() void (*isr_routines[256])(struct regs *) = { 0 }; +const char *isr_exceptions[32] = { "Division By Zero", + "Debug", + "Non Maskable Interrupt", + "Breakpoint", + "Into Detected Overflow", + "Out of Bounds", + "Invalid Opcode", + "No Coprocessor", + + "Double Fault", + "Coprocessor Segment Overrun", + "Bad TSS", + "Segment Not Present", + "Stack Fault", + "General Protection Fault", + "Page Fault", + "Unknown Interrupt", + + "Coprocessor Fault", + "Alignment Check", + "Machine Check", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved" }; + void isr_install_handler(int isr, void (*handler)(struct regs *r)) { isr_routines[isr] = handler; @@ -137,9 +173,9 @@ void isr_handler(struct regs *r) if (handler) { handler(r); } else if (r->int_no <= 32) { - printf("\n#%d Exception, halting!\n", r->int_no); - printf("Error code: %d\n", r->err_code); __asm__("cli"); + printf("\n%s Exception, halting!\n", isr_exceptions[r->int_no]); + printf("Error code: %d\n", r->err_code); while (1) { }; } diff --git a/src/features/fs.c b/src/features/fs.c index 1eec30e..ab2a6eb 100644 --- a/src/features/fs.c +++ b/src/features/fs.c @@ -97,8 +97,8 @@ void *read_file(char *path) path++; u32 current_inode = EXT2_ROOT; + int i; while (1) { - int i; for (i = 0; path[i] != '/' && path[i] != '\0'; i++) ; diff --git a/src/features/load.c b/src/features/load.c index 62da8b4..bc56235 100644 --- a/src/features/load.c +++ b/src/features/load.c @@ -11,7 +11,7 @@ void bin_load(char *path, struct proc *proc) char *data = read_file(path); u32 stack = (u32)malloc(0x1000) + 0x1000; - proc->regs.ebp = stack; - proc->regs.esp = stack; + proc->regs.ebp = (u32)stack; + proc->regs.esp = (u32)stack; proc->regs.eip = (u32)data; } diff --git a/src/features/proc.c b/src/features/proc.c index fbf1b5a..7acbf03 100644 --- a/src/features/proc.c +++ b/src/features/proc.c @@ -70,8 +70,9 @@ struct proc *proc_make() void proc_init() { + __asm__ volatile("cli"); current = root = proc_make(); - bin_load("/root", root); + bin_load("/init", root); irq_install_handler(0, scheduler); proc_print(); @@ -80,5 +81,6 @@ void proc_init() *(void **)(&entry) = (u32 *)root->regs.eip; __asm__ volatile("movl %%eax, %%ebp" ::"a"(root->regs.ebp)); __asm__ volatile("movl %%eax, %%esp" ::"a"(root->regs.esp)); + __asm__ volatile("sti"); entry(); } diff --git a/src/features/syscall.c b/src/features/syscall.c index ab1849c..c3a758a 100644 --- a/src/features/syscall.c +++ b/src/features/syscall.c @@ -13,7 +13,7 @@ void syscall_handler(struct regs *r) bin_load("/a", a); } -void syscall_install() +void syscall_init() { isr_install_handler(0x80, syscall_handler); } diff --git a/src/inc/syscall.h b/src/inc/syscall.h index b0de099..3f89365 100644 --- a/src/inc/syscall.h +++ b/src/inc/syscall.h @@ -3,6 +3,6 @@ #ifndef SYSCALL_H #define SYSCALL_H -void syscall_install(); +void syscall_init(); #endif @@ -44,7 +44,7 @@ void kernel_main(struct mem_info *mem_info, struct vid_info *vid_info) gui_term_write("Wake up, " USERNAME "...\n"); - syscall_install(); + syscall_init(); proc_init(); while (1) { |