diff options
author | Robert Morris <[email protected]> | 2020-07-20 06:59:26 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2020-08-10 11:19:10 -0400 |
commit | 27057bc9b467db64a3de600f27d6fa3239a04c88 (patch) | |
tree | 51f344b42031f0a5a41fcf08d00694bb13f10997 /kernel/trap.c | |
parent | 1e72d5ca087985938589ce509ace4914039860d3 (diff) | |
download | xv6-labs-27057bc9b467db64a3de600f27d6fa3239a04c88.tar.gz xv6-labs-27057bc9b467db64a3de600f27d6fa3239a04c88.tar.bz2 xv6-labs-27057bc9b467db64a3de600f27d6fa3239a04c88.zip |
interrupt-driven uart output, hopefully a nice example for teaching.
Diffstat (limited to 'kernel/trap.c')
-rw-r--r-- | kernel/trap.c | 8 |
1 files changed, 6 insertions, 2 deletions
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); |