Add basic trap handlers

This commit is contained in:
Danila Fedorin 2019-04-23 14:26:02 -07:00
parent 667f2df4cc
commit 6ab267bb9b
1 changed files with 6 additions and 1 deletions

View File

@ -100,7 +100,7 @@ trap_init(void)
SETGATE(idt[T_DIVIDE], 0, GD_KT, t_divide, 0);
SETGATE(idt[T_DEBUG], 0, GD_KT, t_debug, 0);
SETGATE(idt[T_NMI], 0, GD_KT, t_nmi, 0);
SETGATE(idt[T_BRKPT], 0, GD_KT, t_brkpt, 0);
SETGATE(idt[T_BRKPT], 0, GD_KT, t_brkpt, 3);
SETGATE(idt[T_OFLOW], 0, GD_KT, t_oflow, 0);
SETGATE(idt[T_BOUND], 0, GD_KT, t_bound, 0);
SETGATE(idt[T_ILLOP], 0, GD_KT, t_illop, 0);
@ -196,6 +196,11 @@ trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
if (tf->tf_trapno == T_PGFLT) {
page_fault_handler(tf);
} else if (tf->tf_trapno == T_BRKPT) {
monitor(tf);
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);