This commit is contained in:
Robert Morris 2019-10-27 08:03:19 -04:00
parent f2ab0eb644
commit d9160fb4b9
6 changed files with 12 additions and 10 deletions

View file

@ -104,7 +104,7 @@ $U/_forktest: $U/forktest.o $(ULIB)
$(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $U/_forktest $U/forktest.o $U/ulib.o $U/usys.o $(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $U/_forktest $U/forktest.o $U/ulib.o $U/usys.o
$(OBJDUMP) -S $U/_forktest > $U/forktest.asm $(OBJDUMP) -S $U/_forktest > $U/forktest.asm
mkfs/mkfs: mkfs/mkfs.c $K/fs.h mkfs/mkfs: mkfs/mkfs.c $K/fs.h $K/param.h
gcc -Werror -Wall -I. -o mkfs/mkfs mkfs/mkfs.c gcc -Werror -Wall -I. -o mkfs/mkfs mkfs/mkfs.c
# Prevent deletion of intermediate files, e.g. cat.o, after first build, so # Prevent deletion of intermediate files, e.g. cat.o, after first build, so

View file

@ -261,7 +261,6 @@ r_time()
static inline void static inline void
intr_on() intr_on()
{ {
w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
w_sstatus(r_sstatus() | SSTATUS_SIE); w_sstatus(r_sstatus() | SSTATUS_SIE);
} }

View file

@ -72,13 +72,12 @@ release(struct spinlock *lk)
} }
// Check whether this cpu is holding the lock. // Check whether this cpu is holding the lock.
// Interrupts must be off.
int int
holding(struct spinlock *lk) holding(struct spinlock *lk)
{ {
int r; int r;
push_off();
r = (lk->locked && lk->cpu == mycpu()); r = (lk->locked && lk->cpu == mycpu());
pop_off();
return r; return r;
} }
@ -103,9 +102,9 @@ pop_off(void)
struct cpu *c = mycpu(); struct cpu *c = mycpu();
if(intr_get()) if(intr_get())
panic("pop_off - interruptible"); panic("pop_off - interruptible");
c->noff -= 1; if(c->noff < 1)
if(c->noff < 0)
panic("pop_off"); panic("pop_off");
c->noff -= 1;
if(c->noff == 0 && c->intena) if(c->noff == 0 && c->intena)
intr_on(); intr_on();
} }

View file

@ -36,6 +36,7 @@ start()
// delegate all interrupts and exceptions to supervisor mode. // delegate all interrupts and exceptions to supervisor mode.
w_medeleg(0xffff); w_medeleg(0xffff);
w_mideleg(0xffff); w_mideleg(0xffff);
w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
// ask for clock interrupts. // ask for clock interrupts.
timerinit(); timerinit();

View file

@ -129,7 +129,6 @@ usertrapret(void)
// interrupts and exceptions from kernel code go here via kernelvec, // interrupts and exceptions from kernel code go here via kernelvec,
// on whatever the current kernel stack is. // on whatever the current kernel stack is.
// must be 4-byte aligned to fit in stvec.
void void
kerneltrap() kerneltrap()
{ {
@ -189,9 +188,13 @@ devintr()
uartintr(); uartintr();
} else if(irq == VIRTIO0_IRQ){ } else if(irq == VIRTIO0_IRQ){
virtio_disk_intr(); virtio_disk_intr();
} else if(irq){
printf("unexpected interrupt irq=%d\n", irq);
} }
if(irq)
plic_complete(irq); plic_complete(irq);
return 1; return 1;
} else if(scause == 0x8000000000000001L){ } else if(scause == 0x8000000000000001L){
// software interrupt from a machine-mode timer interrupt, // software interrupt from a machine-mode timer interrupt,

View file

@ -2105,9 +2105,9 @@ run(void f(char *), char *s) {
} else { } else {
wait(&xstatus); wait(&xstatus);
if(xstatus != 0) if(xstatus != 0)
printf("FAILED\n", s); printf("FAILED\n");
else else
printf("OK\n", s); printf("OK\n");
return xstatus == 0; return xstatus == 0;
} }
} }