From 27057bc9b467db64a3de600f27d6fa3239a04c88 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Mon, 20 Jul 2020 06:59:26 -0400 Subject: interrupt-driven uart output, hopefully a nice example for teaching. --- kernel/trap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'kernel/trap.c') diff --git a/kernel/trap.c b/kernel/trap.c index 77ff868..a63249e 100644 --- a/kernel/trap.c +++ b/kernel/trap.c @@ -91,8 +91,9 @@ usertrapret(void) { struct proc *p = myproc(); - // turn off interrupts, since we're switching - // now from kerneltrap() to usertrap(). + // we're about to switch the destination of traps from + // kerneltrap() to usertrap(), so turn off interrupts until + // we're back in user space, where usertrap() is correct. intr_off(); // send syscalls, interrupts, and exceptions to trampoline.S @@ -192,6 +193,9 @@ devintr() printf("unexpected interrupt irq=%d\n", irq); } + // the PLIC allows each device to raise at most one + // interrupt at a time; tell the PLIC the device is + // now allowed to interrupt again. if(irq) plic_complete(irq); -- cgit v1.2.3