diff options
author | Robert Morris <[email protected]> | 2020-07-20 06:59:26 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2020-07-20 06:59:26 -0400 |
commit | 823864099d0d8def9d4bcf9e382cf42e05bd7afa (patch) | |
tree | 51f344b42031f0a5a41fcf08d00694bb13f10997 /kernel/trap.c | |
parent | 3b053f5d58b4914c6389588ad4e556bc887bc99d (diff) | |
download | xv6-labs-823864099d0d8def9d4bcf9e382cf42e05bd7afa.tar.gz xv6-labs-823864099d0d8def9d4bcf9e382cf42e05bd7afa.tar.bz2 xv6-labs-823864099d0d8def9d4bcf9e382cf42e05bd7afa.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); |