From 0e6574bea31bf3602752c2d9d541d2762f9c1dbb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 12 May 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-05-12 --- pc/clock.c | 28 +++++++++++++++++++++++----- pc/kbd.c | 8 ++++++-- pc/trap.c | 23 ++++------------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/pc/clock.c b/pc/clock.c index 1b982170f145ca67ee5eea1d367b8860c590ed02..027e59c773f7332b2622eeb284c40aee3cdece3e 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -22,6 +22,7 @@ enum /* modes */ Square= 0x36, /* perioic square wave */ + Trigger= 0x30, /* interrupt on terminal count */ Freq= 1193182, /* Real clock frequency */ }; @@ -47,10 +48,18 @@ clock(Ureg *ur, void *arg) { Proc *p; int nrun = 0; + int islow = 0; extern int hwcursor; USED(arg); + /* + * set clock for 1/HZ seconds + */ + outb(Tmode, Load0|Trigger); + outb(T0cntr, (Freq/HZ)); /* low byte */ + outb(T0cntr, (Freq/HZ)>>8); /* high byte */ + m->ticks++; uartclock(); @@ -75,19 +84,28 @@ clock(Ureg *ur, void *arg) sched(); /* user profiling clock */ + islow = 1; spllo(); /* in case we fault */ (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); - splhi(); } + /* + * anything from here down can be running spllo() + */ + /* last because it could spllo() */ if(hwcursor) mouseclock(); else { - spllo(); + if(!islow){ + islow = 1; + spllo(); + } mouseclock(); - splhi(); } + + if(islow) + splhi(); } /* @@ -131,9 +149,9 @@ clockinit(void) setvec(Clockvec, clock, 0); /* - * make clock output a square wave with a 1/HZ period + * set clock for 1/HZ seconds */ - outb(Tmode, Load0|Square); + outb(Tmode, Load0|Trigger); outb(T0cntr, (Freq/HZ)); /* low byte */ outb(T0cntr, (Freq/HZ)>>8); /* high byte */ diff --git a/pc/kbd.c b/pc/kbd.c index 892e08aacd330cb516f51ef8d186b7e926ac2e5a..8f3e1820207fe009cace0b841f140c531359a528 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -217,7 +217,7 @@ i8042reset(void) * this works for dhog */ outready(); - outb(Cmd, 0xFE); /* pulse reset line */ + outb(Cmd, 0xFE); /* pulse reset line (means resend on AT&T machines) */ outready(); /* * this is the old IBM way @@ -225,9 +225,13 @@ i8042reset(void) outready(); outb(Cmd, 0xD1); outready(); - delay(100); outb(Data, 0xDE); /* set reset line high */ outready(); + delay(100); + outb(Cmd, 0xD1); + outready(); + outb(Data, 0xDF); /* set reset line low */ + outready(); } /* diff --git a/pc/trap.c b/pc/trap.c index 784bb1c9c4e4ac796a8864d83f649e0a63709475..1c14896e76da7f51299f83419ba37c0bdb9e7f6c 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -183,8 +183,8 @@ trapinit(void) * Set the 8259 as master with edge triggered * input with fully nested interrupts. */ - outb(Int0ctl, 0x11); /* ICW1 - edge triggered, master, - ICW4 will be sent */ + outb(Int0ctl, (1<<4)|(1<<3)|(1<<0)); /* ICW1 - master, level triggered, + ICW4 will be sent */ outb(Int0aux, Int0vec); /* ICW2 - interrupt vector offset */ outb(Int0aux, 0x04); /* ICW3 - have slave on level 2 */ outb(Int0aux, 0x01); /* ICW4 - 8086 mode, not buffered */ @@ -195,8 +195,8 @@ trapinit(void) * Set the 8259 as master with edge triggered * input with fully nested interrupts. */ - outb(Int1ctl, 0x11); /* ICW1 - edge triggered, master, - ICW4 will be sent */ + outb(Int1ctl, (1<<4)|(1<<3)|(1<<0)); /* ICW1 - master, level triggered, + ICW4 will be sent */ outb(Int1aux, Int1vec); /* ICW2 - interrupt vector offset */ outb(Int1aux, 0x02); /* ICW3 - I am a slave on level 2 */ outb(Int1aux, 0x01); /* ICW4 - 8086 mode, not buffered */ @@ -222,9 +222,6 @@ char *excname[] = [13] "general protection violation", }; -Ureg lasttrap, *lastur; -Proc *lastup; - /* * All traps come here. It is slower to have all traps call trap() rather than @@ -265,9 +262,6 @@ trap(Ureg *ur) } if(v>=256 || (h = halloc.ivec[v]) == 0){ -lasttrap = *ur; -lastur = ur; -lastup = up; /* an old 386 generates these fairly often, no idea why */ if(v == 13) return; @@ -307,10 +301,6 @@ lastup = up; splhi(); if(user && (up->procctl || up->nnote)) notify(ur); - -lastup = up; -lasttrap = *ur; -lastur = ur; } /* @@ -349,11 +339,6 @@ dumpregs(Ureg *ur) dumpregs2(ur); print(" magic %lux %lux %lux\n", x[0], x[1], x[2]); print(" ur %lux up %lux\n", ur, up); - dumpregs2(&lasttrap); - print(" lastur %lux lastup %lux\n", lastur); -splhi(); -dumpstack(); -for(;;); } void