From c1738b3b855a1869acc5cd383733d7c6b3401315 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 29 Oct 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-10-29 --- carrera/trap.c | 15 +++++++-------- pc/clock.c | 4 +++- pc/devvga.c | 32 +++++++++++++++----------------- pc/l.s | 10 ++++++++++ pc/trap.c | 24 +++++++++++++++++++----- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/carrera/trap.c b/carrera/trap.c index a2eeac275dd628a0ef46d3389d163c025655ab4f..deab279d5404bee34e31934f8067c472093f8289 100644 --- a/carrera/trap.c +++ b/carrera/trap.c @@ -368,14 +368,6 @@ intr(Ureg *ur) if(cause & INTR4) { devint = IO(uchar, I386ack); - vec = devint&~0x7; - /* reenable the 8259 interrupt */ - if(vec == Int0vec || vec == Int1vec){ - EISAOUTB(Int0ctl, EOI); - if(vec == Int1vec) - EISAOUTB(Int1ctl, EOI); - } - switch(devint) { default: iprint("i386ACK #%lux\n", devint); @@ -390,6 +382,13 @@ intr(Ureg *ur) eisadmaintr(); break; } + /* reenable the 8259 interrupt */ + vec = devint&~0x7; + if(vec == Int0vec || vec == Int1vec){ + EISAOUTB(Int0ctl, EOI); + if(vec == Int1vec) + EISAOUTB(Int1ctl, EOI); + } cause &= ~INTR4; } diff --git a/pc/clock.c b/pc/clock.c index 0122ecc97a8c6ba03ae94a142cfefa31c55fe3b2..68877c361b5f6f7f6fd4557e31dc307edd588503 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -31,6 +31,7 @@ static int cpufreq = 66000000; static int cpumhz = 66; static int cputype = 486; static int loopconst = 100; +ulong cpuidax, cpuiddx; static void clock(Ureg *ur, void *arg) @@ -84,7 +85,8 @@ delay(int l) void printcpufreq(void) { - print("CPU is a %ud MHz (%ud Hz) %d\n", cpumhz, cpufreq, cputype); + print("CPU is a %ud Hz %d (CPUID: AX=0x%8.8lux, DX=0x%8.8lux)\n", + cpufreq, cputype, cpuidax, cpuiddx); } void diff --git a/pc/devvga.c b/pc/devvga.c index 35704cc67dea1e9d9169a4090aa0537cf93c6a9a..d26bdf9ae848c8ee9235f32e914a9054dd8c0652 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -106,7 +106,6 @@ static void cgascreenputc(int); static void cgascreenputs(char*, int); static void screenputc(char*); static void scroll(void); -static ulong xnto32(uchar, int); static void workinit(Bitmap*, int, int); extern void screenload(Rectangle, uchar*, int, int, int); extern void screenunload(Rectangle, uchar*, int, int, int); @@ -585,6 +584,21 @@ setmode(VGAmode *vga) vgaxo(Seqx, 0x01, vga->sequencer[1]); } +static ulong +xnto32(uchar x, int n) +{ + int s; + ulong y; + + x &= (1< 0; s -= n) + y |= x<>(-s); + return y; +} + /* * reconfigure screen shape */ @@ -1046,25 +1060,9 @@ screenputs(char *s, int n) unlock(&screenlock); } - /* * expand n bits of color to 32 */ -static ulong -xnto32(uchar x, int n) -{ - int s; - ulong y; - - x &= (1< 0; s -= n) - y |= x<>(-s); - return y; -} - /* * paging routines for different cards */ diff --git a/pc/l.s b/pc/l.s index 5e4fdeb0934703529325530352f8afd637763a2a..c92e0b8ccfa7c3b994878cf9c3d41686345e4dd7 100644 --- a/pc/l.s +++ b/pc/l.s @@ -406,6 +406,12 @@ TEXT intr16(SB),$0 PUSHL $0 PUSHL $16 JMP intrcommon +TEXT intr17(SB),$0 + PUSHL $17 + JMP intrscommon +TEXT intr18(SB),$0 + PUSHL $16 + JMP intrscommon TEXT intr24(SB),$0 PUSHL $0 PUSHL $24 @@ -585,6 +591,10 @@ TEXT x86(SB),$0 /* CPUID */ BYTE $0x0F BYTE $0xA2 + + MOVL AX, cpuidax(SB) + MOVL DX, cpuiddx(SB) + SHLL $20,AX SHRL $28,AX CMPL AX, $4 diff --git a/pc/trap.c b/pc/trap.c index 0e27bfa0181dd4ba05c538bc1a111d37f97f003b..6e70f7b2bb7bc11a9fa22af2d3e8bccc5779068e 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -13,7 +13,7 @@ void intr0(void), intr1(void), intr2(void), intr3(void); void intr4(void), intr5(void), intr6(void), intr7(void); void intr8(void), intr9(void), intr10(void), intr11(void); void intr12(void), intr13(void), intr14(void), intr15(void); -void intr16(void); +void intr16(void), intr17(void), intr18(void); void intr24(void), intr25(void), intr26(void), intr27(void); void intr28(void), intr29(void), intr30(void), intr31(void); void intr32(void), intr33(void), intr34(void), intr35(void); @@ -143,6 +143,8 @@ trapinit(void) sethvec(14, intr14, SEGIG, 0); /* page fault */ sethvec(15, intr15, SEGIG, 0); sethvec(16, intr16, SEGIG, 0); /* math coprocessor */ + sethvec(17, intr17, SEGIG, 0); + sethvec(18, intr18, SEGIG, 0); /* * device interrupts @@ -227,8 +229,13 @@ char *excname[] = { [14] "page fault", [15] "15 (reserved)", [16] "coprocessor error", + [17] "alignment check", + [18] "something bad happened", }; +Ureg lastur; +Ureg scndlastur; + /* * All traps come here. It is slower to have all traps call trap() rather than * directly vectoring the handler. However, this avoids a lot of code duplication @@ -251,7 +258,7 @@ trap(Ureg *ur) else if(ur->pc <= (ulong)end && *(uchar*)ur->pc == 0xCF) { if(iret_traps++ > 10) panic("iret trap"); - return; + goto out; } iret_traps = 0; @@ -270,16 +277,18 @@ trap(Ureg *ur) if(v>=256 || (h = halloc.ivec[v]) == 0){ /* an old 386 generates these fairly often, no idea why */ if(v == 13) - return; + goto out; /* a processor or coprocessor error */ if(v <= 16){ if(user){ sprint(buf, "sys: trap: %s", excname[v]); postnote(up, 1, buf, NDebug); - return; + goto out; } else { dumpregs(ur); +print("%s pc=0x%lux", excname[v], ur->pc); +for(;;); panic("%s pc=0x%lux", excname[v], ur->pc); } } @@ -294,7 +303,7 @@ trap(Ureg *ur) /* unimplemented traps */ print("illegal trap %d pc=0x%lux\n", v, ur->pc); } - return; + goto out; } /* there may be multiple handlers on one interrupt level */ @@ -309,6 +318,9 @@ trap(Ureg *ur) splhi(); if(v != Syscallvec && user && (up->procctl || up->nnote)) notify(ur); +out: + scndlastur = lastur; + lastur = *ur; } /* @@ -346,6 +358,8 @@ dumpregs(Ureg *ur) x = (ulong*)(ur+1); + dumpregs2(&scndlastur); + dumpregs2(&lastur); dumpregs2(ur); print(" CR0 %8.8lux CR2 %8.8lux\n", getcr0(), getcr2()); print(" magic %lux %lux %lux\n", x[0], x[1], x[2]);