summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1997-04-17 03:44:53 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1997-04-17 03:44:53 +0000
commit9caf1446e5026d25eae3db39219e81c52b01e6a2 (patch)
treedfe8884cb204cae843b5f61b35f61ca7f919376b
parent97987029292f8c61ef09b7d10f0d8d9f1b3fa820 (diff)
Do interrupt time accounting by running interrupt handlers with a seperate
code segment selector (otherwise identical to the standard kernel code selector); idea by Dave Richards <richards@zso.dec.com>
-rw-r--r--sys/arch/i386/i386/machdep.c51
-rw-r--r--sys/arch/i386/include/segments.h11
-rw-r--r--sys/arch/i386/isa/isa_machdep.c4
-rw-r--r--sys/arch/i386/isa/npx.c6
4 files changed, 37 insertions, 35 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index ab1953a6c8d..2e7d9ba5eb5 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.44 1997/04/04 16:14:09 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.45 1997/04/17 03:44:50 tholo Exp $ */
/* $NetBSD: machdep.c,v 1.202 1996/05/18 15:54:59 christos Exp $ */
/*-
@@ -1100,14 +1100,14 @@ struct gate_descriptor idt[NIDT];
extern struct user *proc0paddr;
void
-setgate(gd, func, args, type, dpl)
+setgate(gd, func, args, type, dpl, seg)
struct gate_descriptor *gd;
void *func;
- int args, type, dpl;
+ int args, type, dpl, seg;
{
gd->gd_looffset = (int)func;
- gd->gd_selector = GSEL(GCODE_SEL, SEL_KPL);
+ gd->gd_selector = GSEL(seg, SEL_KPL);
gd->gd_stkcpy = args;
gd->gd_xx = 0;
gd->gd_type = type;
@@ -1188,6 +1188,7 @@ init386(first_avail)
/* make gdt gates and memory segments */
setsegment(&gdt[GCODE_SEL].sd, 0, 0xfffff, SDT_MEMERA, SEL_KPL, 1, 1);
+ setsegment(&gdt[GICODE_SEL].sd, 0, 0xfffff, SDT_MEMERA, SEL_KPL, 1, 1);
setsegment(&gdt[GDATA_SEL].sd, 0, 0xfffff, SDT_MEMRWA, SEL_KPL, 1, 1);
setsegment(&gdt[GLDT_SEL].sd, ldt, sizeof(ldt) - 1, SDT_SYSLDT, SEL_KPL,
0, 0);
@@ -1198,33 +1199,33 @@ init386(first_avail)
/* make ldt gates and memory segments */
setgate(&ldt[LSYS5CALLS_SEL].gd, &IDTVEC(osyscall), 1, SDT_SYS386CGT,
- SEL_UPL);
+ SEL_UPL, GCODE_SEL);
ldt[LUCODE_SEL] = gdt[GUCODE_SEL];
ldt[LUDATA_SEL] = gdt[GUDATA_SEL];
ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
/* exceptions */
for (x = 0; x < NIDT; x++)
- setgate(&idt[x], &IDTVEC(rsvd), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 0], &IDTVEC(div), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 1], &IDTVEC(dbg), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 2], &IDTVEC(nmi), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 3], &IDTVEC(bpt), 0, SDT_SYS386TGT, SEL_UPL);
- setgate(&idt[ 4], &IDTVEC(ofl), 0, SDT_SYS386TGT, SEL_UPL);
- setgate(&idt[ 5], &IDTVEC(bnd), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 6], &IDTVEC(ill), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 7], &IDTVEC(dna), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 8], &IDTVEC(dble), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 9], &IDTVEC(fpusegm), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 10], &IDTVEC(tss), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 11], &IDTVEC(missing), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 12], &IDTVEC(stk), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 13], &IDTVEC(prot), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 14], &IDTVEC(page), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 16], &IDTVEC(fpu), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 17], &IDTVEC(align), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[ 18], &IDTVEC(rsvd), 0, SDT_SYS386TGT, SEL_KPL);
- setgate(&idt[128], &IDTVEC(syscall), 0, SDT_SYS386TGT, SEL_UPL);
+ setgate(&idt[x], &IDTVEC(rsvd), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 0], &IDTVEC(div), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 1], &IDTVEC(dbg), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 2], &IDTVEC(nmi), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 3], &IDTVEC(bpt), 0, SDT_SYS386TGT, SEL_UPL, GCODE_SEL);
+ setgate(&idt[ 4], &IDTVEC(ofl), 0, SDT_SYS386TGT, SEL_UPL, GCODE_SEL);
+ setgate(&idt[ 5], &IDTVEC(bnd), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 6], &IDTVEC(ill), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 7], &IDTVEC(dna), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 8], &IDTVEC(dble), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 9], &IDTVEC(fpusegm), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 10], &IDTVEC(tss), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 11], &IDTVEC(missing), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 12], &IDTVEC(stk), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 13], &IDTVEC(prot), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 14], &IDTVEC(page), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 16], &IDTVEC(fpu), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 17], &IDTVEC(align), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[ 18], &IDTVEC(rsvd), 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
+ setgate(&idt[128], &IDTVEC(syscall), 0, SDT_SYS386TGT, SEL_UPL, GCODE_SEL);
setregion(&region, gdt, sizeof(gdt) - 1);
lgdt(&region);
diff --git a/sys/arch/i386/include/segments.h b/sys/arch/i386/include/segments.h
index 4558ccce6aa..4aa542dc009 100644
--- a/sys/arch/i386/include/segments.h
+++ b/sys/arch/i386/include/segments.h
@@ -130,7 +130,7 @@ struct region_descriptor {
extern union descriptor gdt[], ldt[];
extern struct gate_descriptor idt[];
-void setgate __P((struct gate_descriptor *, void *, int, int, int));
+void setgate __P((struct gate_descriptor *, void *, int, int, int, int));
void setregion __P((struct region_descriptor *, void *, size_t));
void setsegment __P((struct segment_descriptor *, void *, size_t, int, int,
int, int));
@@ -217,10 +217,11 @@ void setsegment __P((struct segment_descriptor *, void *, size_t, int, int,
#define GLDT_SEL 3 /* Default LDT descriptor */
#define GUCODE_SEL 4 /* User code descriptor */
#define GUDATA_SEL 5 /* User data descriptor */
-#define GAPM32CODE_SEL 6
-#define GAPM16CODE_SEL 7
-#define GAPMDATA_SEL 8
-#define NGDT 9
+#define GAPM32CODE_SEL 6 /* 32 bit APM code descriptor */
+#define GAPM16CODE_SEL 7 /* 16 bit APM code descriptor */
+#define GAPMDATA_SEL 8 /* APM data descriptor */
+#define GICODE_SEL 9 /* Interrupt code descriptor (same as Kernel code) */
+#define NGDT 10
/*
* Entries in the Local Descriptor Table (LDT)
diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c
index d83ece85148..2fbbc0dc0ce 100644
--- a/sys/arch/i386/isa/isa_machdep.c
+++ b/sys/arch/i386/isa/isa_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isa_machdep.c,v 1.19 1997/01/04 14:05:50 niklas Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.20 1997/04/17 03:44:52 tholo Exp $ */
/* $NetBSD: isa_machdep.c,v 1.14 1996/05/12 23:06:18 mycroft Exp $ */
/*-
@@ -84,7 +84,7 @@ isa_defaultirq()
/* icu vectors */
for (i = 0; i < ICU_LEN; i++)
setgate(&idt[ICU_OFFSET + i], IDTVEC(intr)[i], 0, SDT_SYS386IGT,
- SEL_KPL);
+ SEL_KPL, GICODE_SEL);
/* initialize 8259's */
outb(IO_ICU1, 0x11); /* reset; program device, four bytes */
diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c
index 37d8d28a0ee..ec871cad0e3 100644
--- a/sys/arch/i386/isa/npx.c
+++ b/sys/arch/i386/isa/npx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npx.c,v 1.13 1997/02/08 23:36:58 tholo Exp $ */
+/* $OpenBSD: npx.c,v 1.14 1997/04/17 03:44:52 tholo Exp $ */
/* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
#if 0
@@ -269,8 +269,8 @@ npxprobe(parent, match, aux)
disable_intr();
save_idt_npxintr = idt[irq];
save_idt_npxtrap = idt[16];
- setgate(&idt[irq], probeintr, 0, SDT_SYS386IGT, SEL_KPL);
- setgate(&idt[16], probetrap, 0, SDT_SYS386TGT, SEL_KPL);
+ setgate(&idt[irq], probeintr, 0, SDT_SYS386IGT, SEL_KPL, GICODE_SEL);
+ setgate(&idt[16], probetrap, 0, SDT_SYS386TGT, SEL_KPL, GCODE_SEL);
save_imen = imen;
imen = ~((1 << IRQ_SLAVE) | (1 << ia->ia_irq));
SET_ICUS();