aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2021-03-19 23:09:54 +0100
committerMarvin Borner2021-03-19 23:09:54 +0100
commitc97a50ba7baa70b40431594f410ca18e14af3b76 (patch)
tree12366515d6989dcfc79ec3250558e381e29fb4eb /kernel
parent63ed037fdbb04a4855531f5ce980d8517752f640 (diff)
Some things
Diffstat (limited to 'kernel')
-rw-r--r--kernel/drivers/interrupts.c1
-rw-r--r--kernel/features/mm.c2
-rw-r--r--kernel/features/proc.c7
-rw-r--r--kernel/features/syscall.c1
-rw-r--r--kernel/main.c6
5 files changed, 8 insertions, 9 deletions
diff --git a/kernel/drivers/interrupts.c b/kernel/drivers/interrupts.c
index 2e1444f..255f976 100644
--- a/kernel/drivers/interrupts.c
+++ b/kernel/drivers/interrupts.c
@@ -179,6 +179,7 @@ void isr_panic(struct regs *r)
printf("\t-> Exception occurred in %s at addr 0x%x\n", proc->name,
r->eip - proc->entry);
proc_exit(proc, 1);
+ proc_yield(r);
} else {
__asm__ volatile("cli\nhlt");
}
diff --git a/kernel/features/mm.c b/kernel/features/mm.c
index af5e070..01e21e7 100644
--- a/kernel/features/mm.c
+++ b/kernel/features/mm.c
@@ -34,6 +34,8 @@ extern void paging_invalidate_tlb(void);
void page_fault_handler(struct regs *r)
{
+ print("--- PAGE FAULT! ---\n");
+
// Check error code
const char *type = (r->err_code & 1) ? "present" : "non-present";
const char *operation = (r->err_code & 2) ? "write" : "read";
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 5c38fff..aa595ff 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -59,7 +59,7 @@ void scheduler(struct regs *regs)
}
memory_switch_dir(((struct proc *)current->data)->page_dir);
- memcpy(regs, &((struct proc *)current->data)->regs, sizeof(struct regs));
+ memcpy(regs, &((struct proc *)current->data)->regs, sizeof(*regs));
if (regs->cs != GDT_USER_CODE_OFFSET) {
regs->gs = GDT_USER_DATA_OFFSET;
@@ -145,9 +145,10 @@ void proc_exit(struct proc *proc, int status)
printf("Process %s exited with status %d (%s)\n", proc->name, status,
status == 0 ? "success" : "error");
+ virtual_destroy_dir(proc->page_dir);
proc_clear_quantum(); // TODO: Add quantum to each process struct?
- sti();
- hlt();
+
+ // The caller has to yield itself
}
void proc_yield(struct regs *r)
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 2796372..2334947 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -82,6 +82,7 @@ static void syscall_handler(struct regs *r)
}
case SYS_EXIT: {
proc_exit(proc_current(), (int)r->ebx);
+ proc_yield(r);
break;
}
case SYS_BOOT: { // TODO: Move
diff --git a/kernel/main.c b/kernel/main.c
index d1afc01..5c5299e 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -18,15 +18,9 @@
#include <syscall.h>
#include <timer.h>
-#include <print.h>
-
void kernel_main(struct mem_info *mem_info, struct vid_info *vid_info); // Decl
void kernel_main(struct mem_info *mem_info, struct vid_info *vid_info)
{
- // Clear stack
- for (u32 i = 0; i < STACK_SIZE; i++)
- ((u8 *)STACK_START)[-i] = 0;
-
// Serial connection
serial_install();
serial_print("\nKernel was compiled at " __TIME__ " on " __DATE__ "\n");