From: Ben Pfaff Date: Sun, 29 Aug 2004 06:54:14 +0000 (+0000) Subject: Fix wild bit in interrupt gate addresses. Make some things static. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b91fa68c0533450d0f402958fd8e8969f3ab8ff;p=pintos-anon Fix wild bit in interrupt gate addresses. Make some things static. --- diff --git a/src/threads/interrupt.c b/src/threads/interrupt.c index 9058775..0d7b119 100644 --- a/src/threads/interrupt.c +++ b/src/threads/interrupt.c @@ -102,8 +102,8 @@ static const char *intr_names[INTR_CNT]; void intr_handler (struct intr_frame *args); -bool intr_in_progress; -bool yield_on_return; +static bool intr_in_progress; +static bool yield_on_return; const char * intr_name (int vec) @@ -159,25 +159,29 @@ intr_handler_func intr_panic NO_RETURN; intr_handler_func intr_kill NO_RETURN; static uint64_t -make_intr_gate (void (*target) (void), - int dpl) +make_gate (void (*target) (void), int dpl, enum seg_type type) { uint32_t offset = (uint32_t) target; uint32_t e0 = ((offset & 0xffff) /* Offset 15:0. */ | (SEL_KCSEG << 16)); /* Target code segment. */ uint32_t e1 = ((offset & 0xffff0000) /* Offset 31:16. */ | (1 << 15) /* Present. */ - | (dpl << 13) /* Descriptor privilege. */ + | ((uint32_t) dpl << 13) /* Descriptor privilege. */ | (SYS_SYSTEM << 12) /* System. */ - | (TYPE_INT_32 << 8)); /* 32-bit interrupt gate. */ + | ((uint32_t) type << 8)); /* Gate type. */ return e0 | ((uint64_t) e1 << 32); } static uint64_t -make_trap_gate (void (*target) (void), - int dpl) +make_intr_gate (void (*target) (void), int dpl) { - return make_intr_gate (target, dpl) | (1 << 8); + return make_gate (target, dpl, TYPE_INT_32); +} + +static uint64_t +make_trap_gate (void (*target) (void), int dpl) +{ + return make_gate (target, dpl, TYPE_TRAP_32); } /* We don't support nested interrupts generated by external @@ -276,13 +280,14 @@ intr_kill (struct intr_frame *f) thread_current (), f->vec_no, intr_name (f->vec_no)); thread_exit (); - default: - panic ("Interrupt %#04x (%s) in unknown segment %04x", - f->vec_no, intr_name (f->vec_no), f->cs); - case SEL_KCSEG: - printk ("intr_kill -> panic %d\n", f->vec_no); + printk ("Kernel bug - unexpected interrupt in kernel context\n"); intr_panic (f); + + default: + printk ("Interrupt %#04x (%s) in unknown segment %04x\n", + f->vec_no, intr_name (f->vec_no), f->cs); + thread_exit (); } }