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)
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
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 ();
}
}