diff options
author | Frans Kaashoek <[email protected]> | 2019-07-17 05:53:47 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2019-07-17 05:53:47 -0400 |
commit | b924e44f06c9c0882a2cffe6c9215b12c5aee2e6 (patch) | |
tree | b1204b01142d7a5b41988b87a4c06b0aabe8b5c9 /kernel/trap.c | |
parent | ce53416f4970ebb137c8e66dc75488cfefaf084d (diff) | |
parent | ebc39372096280a4a5957d3e3836c859e5d78a79 (diff) | |
download | xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.tar.gz xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.tar.bz2 xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.zip |
Merge branch 'riscv' of g.csail.mit.edu:xv6-dev into riscv
Diffstat (limited to 'kernel/trap.c')
-rw-r--r-- | kernel/trap.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/kernel/trap.c b/kernel/trap.c index 018b7db..ea5799f 100644 --- a/kernel/trap.c +++ b/kernel/trap.c @@ -53,6 +53,9 @@ usertrap(void) if(r_scause() == 8){ // system call + if(p->killed) + exit(); + // sepc points to the ecall instruction, // but we want to return to the next instruction. p->tf->epc += 4; @@ -100,7 +103,7 @@ usertrapret(void) p->tf->kernel_satp = r_satp(); p->tf->kernel_sp = (uint64)p->kstack + PGSIZE; p->tf->kernel_trap = (uint64)usertrap; - p->tf->hartid = r_tp(); + p->tf->kernel_hartid = r_tp(); // set up the registers that trampoline.S's sret will use // to get to user space. @@ -155,6 +158,15 @@ kerneltrap() w_sstatus(sstatus); } +void +clockintr() +{ + acquire(&tickslock); + ticks++; + wakeup(&ticks); + release(&tickslock); +} + // check if it's an external interrupt or software interrupt, // and handle it. // returns 2 if timer interrupt, @@ -179,16 +191,15 @@ devintr() plic_complete(irq); return 1; } else if(scause == 0x8000000000000001){ - // software interrupt from a machine-mode timer interrupt. + // software interrupt from a machine-mode timer interrupt, + // forwarded by machinevec in kernelvec.S. if(cpuid() == 0){ - acquire(&tickslock); - ticks++; - wakeup(&ticks); - release(&tickslock); + clockintr(); } - // acknowledge. + // acknowledge the software interrupt by clearing + // the SSIP bit in sip. w_sip(r_sip() & ~2); return 2; |