M carrera/trap.c => carrera/trap.c +7 -8
@@ 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;
}
M pc/clock.c => pc/clock.c +3 -1
@@ 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
M pc/devvga.c => pc/devvga.c +15 -17
@@ 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<<n)-1;
+ y = 0;
+ for(s = 32 - n; s > 0; s -= n)
+ y |= x<<s;
+ if(s < 0)
+ 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<<n)-1;
- y = 0;
- for(s = 32 - n; s > 0; s -= n)
- y |= x<<s;
- if(s < 0)
- y |= x>>(-s);
- return y;
-}
-
/*
* paging routines for different cards
*/
M pc/l.s => pc/l.s +10 -0
@@ 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
M pc/trap.c => pc/trap.c +19 -5
@@ 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]);