From 2a97836549bd45c0699808e80901ca8866583b63 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 1 Nov 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-11-01 --- bitsy/clock.c | 2 +- bitsy/devpenmouse.c | 8 +++--- "bitsy/dev\302\265c.c" | 23 ++++++++-------- bitsy/l.s | 15 ++++++++-- bitsy/random.c | 2 +- bitsy/screen.c | 20 +++++++------- bitsy/trap.c | 4 ++- port/devcons.c | 62 ++++++++++++++++++++++++++---------------- port/taslock.c | 10 +++++++ 9 files changed, 92 insertions(+), 54 deletions(-) diff --git a/bitsy/clock.c b/bitsy/clock.c index a8097cc305ff511d79139fb401abd22716036ba0..d4d74df0eeaa39e3416566f8e94435f0cd3d7878 100644 --- a/bitsy/clock.c +++ b/bitsy/clock.c @@ -95,7 +95,7 @@ clockintr(Ureg *ureg, void*) accounttime(); if(kproftimer != nil) - kproftimer(ureg->pc); + (*kproftimer)(ureg->pc); checkalarms(); ilock(&clock0lock); diff --git a/bitsy/devpenmouse.c b/bitsy/devpenmouse.c index 4762cadf658c5feee9283a174d1c6914927cb1ba..e5904d82250018b3153ccb37cc929078a8e684cf 100644 --- a/bitsy/devpenmouse.c +++ b/bitsy/devpenmouse.c @@ -92,8 +92,8 @@ pentrackxy(int x, int y) { /* pen up. associate with button 1, 2, 3 up */ mouse.buttons &= ~0x7; } else { - x = (x<<16)/calibration.scalex + calibration.transx; - y = (y<<16)/calibration.scaley + calibration.transy; + x = ((x*calibration.scalex)>>16) + calibration.transx; + y = ((y*calibration.scaley)>>16) + calibration.transy; if ((mouse.buttons & 0x7) == 0) mouse.buttons |= 0x1; } @@ -325,8 +325,8 @@ penmousewrite(Chan *c, void *va, long n, vlong) } else if(strcmp(field[0], "calibrate") == 0){ if (nf == 1) { - calibration.scalex = 1; - calibration.scaley = 1; + calibration.scalex = 1<<16; + calibration.scaley = 1<<16; calibration.transx = 0; calibration.transy = 0; } else if (nf == 5) { diff --git "a/bitsy/dev\302\265c.c" "b/bitsy/dev\302\265c.c" index b2a61260b69db191e7c20e2aca8411717e27b9d5..96d1ce473d987ece32cb37b09aa0d84f38efbde1 100644 --- "a/bitsy/dev\302\265c.c" +++ "b/bitsy/dev\302\265c.c" @@ -312,8 +312,17 @@ static long int i, j; Rune r; - if(off != 0) - error(Ebadarg); + if(c->qid.path == Qkbdin){ + if(n >= sizeof(str)) + n = sizeof(str)-1; + memmove(str, a, n); + str[n] = 0; + for(i = 0; i < n; i += j){ + j = chartorune(&r, &str[i]); + kbdcr2nl(nil, r); + } + return n; + } cmd = parsecmd(a, n); if(cmd->nf > 15) @@ -322,16 +331,6 @@ static long data[i] = atoi(cmd->f[i]); switch(c->qid.path){ - case Qkbdin: - if(n >= sizeof(str)) - n = sizeof(str)-1; - memmove(str, a, n); - str[n] = 0; - for(i = 0; i < n; i += j){ - j = chartorune(&r, &str[i]); - kbdputc(nil, r); - } - break; case Qled: sendmsgwithack(BLled, data, cmd->nf); break; diff --git a/bitsy/l.s b/bitsy/l.s index dbe3ae1ccae6a261ec2641a704679a099ab88307..0f17917b07f22da8559ff806eeb4fb95a60c24bd 100644 --- a/bitsy/l.s +++ b/bitsy/l.s @@ -144,13 +144,13 @@ TEXT putttb(SB), $-4 */ TEXT mmuenable(SB), $-4 MRC CpMMU, 0, R0, C(CpControl), C(0x0) - ORR $(CpCmmuena|CpCdcache|CpCwb), R0 + ORR $(CpCmmuena|CpCdcache|CpCicache|CpCwb), R0 MCR CpMMU, 0, R0, C(CpControl), C(0x0) RET TEXT mmudisable(SB), $-4 MRC CpMMU, 0, R0, C(CpControl), C(0x0) - BIC $(CpCmmuena|CpCdcache|CpCwb|CpCvivec), R0 + BIC $(CpCmmuena|CpCdcache|CpCicache|CpCwb|CpCvivec), R0 MCR CpMMU, 0, R0, C(CpControl), C(0x0) RET @@ -360,6 +360,10 @@ TEXT forkret(SB),$-4 RFE /* MOVM.IA.S.W (R13), [R15] */ TEXT splhi(SB), $-4 + /* save caller pc in Mach */ + MOVW $(MACHADDR+0x04),R2 + MOVW R14,0(R2) + /* turn off interrupts */ MOVW CPSR, R0 ORR $(PsrDfiq|PsrDirq), R0, R1 MOVW R1, CPSR @@ -372,6 +376,10 @@ TEXT spllo(SB), $-4 RET TEXT splx(SB), $-4 + /* save caller pc in Mach */ + MOVW $(MACHADDR+0x04),R2 + MOVW R14,0(R2) + /* reset interrupt level */ MOVW R0, R1 MOVW CPSR, R0 MOVW R1, CPSR @@ -383,6 +391,9 @@ TEXT splxpc(SB), $-4 /* for iunlock */ MOVW R1, CPSR RET +TEXT spldone(SB), $0 + RET + TEXT islo(SB), $-4 MOVW CPSR, R0 AND $(PsrDfiq|PsrDirq), R0 diff --git a/bitsy/random.c b/bitsy/random.c index 282e8c99a29b625dc7be4b2b37f564c2ed8bf11b..9523148eab27346dcef7e785c6480d53b021f012 100644 --- a/bitsy/random.c +++ b/bitsy/random.c @@ -12,7 +12,7 @@ struct Rb Rendez producer; Rendez consumer; ulong randomcount; - uchar buf[1024]; + uchar buf[128]; uchar *ep; uchar *rp; uchar *wp; diff --git a/bitsy/screen.c b/bitsy/screen.c index bc45541952000a0e5f7674a9d08f79149654673e..f39f68f67689007c2dbd1b5f5388c42ab7ff2d68 100644 --- a/bitsy/screen.c +++ b/bitsy/screen.c @@ -286,33 +286,33 @@ screenwin(void) { Point p, q; char *greet; - Memimage *grey; + Memimage *orange; memsetchan(gscreen, RGB16); back = memwhite; conscol = memblack; - /* a lot of work to get a grey color */ - grey = allocmemimage(Rect(0,0,1,1), RGB16); - grey->flags |= Frepl; - grey->clipr = gscreen->r; - grey->data->bdata[0] = 0x40; - grey->data->bdata[1] = 0xfd; + /* a lot of work to get a orange color */ + orange = allocmemimage(Rect(0,0,1,1), RGB16); + orange->flags |= Frepl; + orange->clipr = gscreen->r; + orange->data->bdata[0] = 0x40; + orange->data->bdata[1] = 0xfd; w = memdefont->info[' '].width; h = memdefont->height; window.min = Pt(4, 4); - window.max = addpt(window.min, Pt(4+w*33, 4+h*15)); + window.max = addpt(window.min, Pt(4+w*33, 4+h*12)); memimagedraw(gscreen, window, memblack, ZP, memopaque, ZP); window = insetrect(window, 4); memimagedraw(gscreen, window, memwhite, ZP, memopaque, ZP); memimagedraw(gscreen, Rect(window.min.x, window.min.y, - window.max.x, window.min.y+h+5+6), grey, ZP, nil, ZP); - freememimage(grey); + window.max.x, window.min.y+h+5+6), orange, ZP, nil, ZP); + freememimage(orange); window = insetrect(window, 5); greet = " Plan 9 Console "; diff --git a/bitsy/trap.c b/bitsy/trap.c index 0167b9f0f865ef116351fbfb3f0b42775783d9b2..b8408a953d0c6da272830ca7da5f036e8dff320a 100644 --- a/bitsy/trap.c +++ b/bitsy/trap.c @@ -644,8 +644,10 @@ _dumpstack(Ureg *ureg) if(KTZERO < v && v < (ulong)&etext && (v&3)==0){ v -= 4; p = (ulong*)v; - if((*p & 0x0f000000) == 0x0b000000) + if((*p & 0x0f000000) == 0x0b000000){ print("%.8lux=%.8lux ", l, v); + i++; + } } if(i == 4){ i = 0; diff --git a/port/devcons.c b/port/devcons.c index 942ef6540a83eac053d586edbe0ce7ea4ad8fd01..faafaa8edcc68a7c31f30f2d10c9549b9df65a3f 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -26,7 +26,7 @@ static struct /* someplace to save up characters at interrupt time before dumping them in the q */ Lock lockputc; - char istage[128]; + char istage[512]; char *iw; char *ir; char *ie; @@ -61,8 +61,12 @@ consactive(void) void prflush(void) { + ulong now; + + now = m->ticks; while(consactive()) - ; + if(m->ticks - now >= HZ) + break; } /* @@ -76,7 +80,6 @@ putstrn0(char *str, int n, int usewrite) { int m; char *t; - char buf[PRINTSIZE+2]; /* * if there's an attached bit mapped display, @@ -95,17 +98,17 @@ putstrn0(char *str, int n, int usewrite) while(n > 0) { t = memchr(str, '\n', n); - if(t) { - m = t - str; - memmove(buf, str, m); - buf[m] = '\r'; - buf[m+1] = '\n'; - if(usewrite) - qwrite(printq, buf, m+2); - else - qiwrite(printq, buf, m+2); - str = t + 1; - n -= m + 1; + if(t && !kbd.raw) { + m = t-str; + if(usewrite){ + qwrite(printq, str, m); + qwrite(printq, "\r\n", 2); + } else { + qiwrite(printq, str, m); + qiwrite(printq, "\r\n", 2); + } + n -= m+1; + str = t+1; } else { if(usewrite) qwrite(printq, str, n); @@ -211,9 +214,9 @@ panic(char *fmt, ...) serialputs(buf, n+1); if(consdebug) consdebug(); - putstrn(buf, n+1); spllo(); prflush(); + putstrn(buf, n+1); dumpstack(); exit(1); @@ -320,6 +323,10 @@ echo(char *buf, int n) int x; char *e, *p; + if(kbd.raw){ + qproduce(kbdq, buf, n); + return; + } e = buf+n; for(p = buf; p < e; p++){ switch(*p){ @@ -382,9 +389,6 @@ echo(char *buf, int n) } qproduce(kbdq, buf, n); - if(kbd.raw) - return; - echoscreen(buf, n); if(printq) echoprintq(buf, n); @@ -393,14 +397,26 @@ echo(char *buf, int n) /* * Called by a uart interrupt for console input. * - * turn '\r' into '\n' before putting it into the queue. + * turn '\r' into '\n' before putting it into the queue. we + * can't type runs on alternate consoles, so don't worry about it. */ int -kbdcr2nl(Queue *q, int ch) +kbdcr2nl(Queue*, int ch) { - if(ch == '\r') + char *next; + + ilock(&kbd.lockputc); /* just a mutex */ + if(ch == '\r' && !kbd.raw) ch = '\n'; - return kbdputc(q, ch); + next = kbd.iw+1; + if(next >= kbd.ie) + next = kbd.istage; + if(next != kbd.ir){ + *kbd.iw = ch; + kbd.iw = next; + } + iunlock(&kbd.lockputc); + return 0; } /* @@ -824,7 +840,7 @@ conswrite(Chan *c, void *va, long n, vlong off) if(bp > sizeof buf) bp = sizeof buf; memmove(buf, a, bp); - putstrn0(a, bp, 1); + putstrn0(buf, bp, 1); a += bp; l -= bp; } diff --git a/port/taslock.c b/port/taslock.c index e4d9f3081cc66ab5c3e9cb7a960d313ac7c6c99a..751972d38bb542754d50d96f3246dc1d12adca26 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -17,6 +17,16 @@ lockloop(Lock *l, ulong pc) Proc *p; p = l->p; +{ +ulong x = (ulong)p; +uchar *cp; +int i; +if(x < KTZERO) { + cp = (uchar*)l; + for(i = 0; i < 64; i++) print("%2.2ux ", cp[i]); + print("\n"); +} +} print("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux proc %lud\n", l->key, pc, l->pc, p ? p->pid : 0); dumpaproc(up);