From 5b25835660ca13782c2ecae7548505d2daa8261a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 13 Nov 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-11-13 --- pc/bbmalloc.c | 72 +++++++++------- pc/devfloppy.c | 2 +- pc/kbd.c | 1 - pc/main.c | 6 +- pc/vga.c | 217 ++++++++++++++++++++++++++++++------------------- port/devbit.c | 5 +- 6 files changed, 183 insertions(+), 120 deletions(-) diff --git a/pc/bbmalloc.c b/pc/bbmalloc.c index 9dfffb96a468c70f456d31fe0d5c674d806dce7f..298620e336de09d5f333edd7f5d50c705a4b34fc 100644 --- a/pc/bbmalloc.c +++ b/pc/bbmalloc.c @@ -3,52 +3,66 @@ #include "mem.h" #include "dat.h" #include "fns.h" +#include "io.h" -static char bbarena[10000]; -static char bbused[10]; +/* + * Allocate memory for use in kernel bitblts. + * + * This code will have to be interlocked if we ever get + * a multiprocessor with a bitmapped display. + */ -void* -bbmalloc(int n) +/* a 0->3 bitblt can take 800 longs */ +enum { + narena=2, /* put interrupt time stuff in separate arena */ + nbbarena=4096 /* number of words in an arena */ +}; + +static ulong bbarena[narena][nbbarena]; +static ulong *bbcur[narena] = {&bbarena[0][0], &bbarena[1][0]}; +static ulong *bblast[narena] = {0, 0}; + +#define INTENABLED(v) ((v)&(1<<9)) +void * +bbmalloc(int nbytes) { - char *a; - int s, i; + int nw, a; + int s; + ulong *ans; + nw = nbytes/sizeof(long); s = splhi(); - a = memchr(bbused, 0, sizeof(bbused)); - if(a) { - i = a - bbused; - a = bbarena + i*n; - if(a+n <= bbarena+sizeof(bbarena)) { - bbused[i] = 1; - splx(s); - return a; - } - } + a = INTENABLED(s) ? 0 : 1; + if(bbcur[a] + nw > &bbarena[a][nbbarena]) + ans = bbarena[a]; + else + ans = bbcur[a]; + bbcur[a] = ans + nw; splx(s); - print("too many bbmallocs\n"); - return bbarena; + bblast[a] = ans; + return ans; } void -bbfree(void *va, int n) +bbfree(void *p, int n) { - int s, i; + int a, s; s = splhi(); - i = ((char*)va - bbarena) /n; - if(i >= 0 && i < sizeof(bbused) && bbused[i]){ - bbused[i] = 0; - splx(s); - return; - } + a = INTENABLED(s) ? 0 : 1; + if(p == bblast[a]) + bbcur[a] = (ulong *)(((char *)bblast[a]) + n); splx(s); - print("sanity bbfree\n"); +} + +void +bbdflush(void *p, int n) +{ + USED(p, n); } int bbonstack(void) { - if(u) - return 1; return 0; } diff --git a/pc/devfloppy.c b/pc/devfloppy.c index e95e8e481da221ec1d3ee20d92b2ca0facdb2727..015c275af586ebdb968bb88ff518db3372b3ebd8 100644 --- a/pc/devfloppy.c +++ b/pc/devfloppy.c @@ -266,7 +266,7 @@ floppyreset(void) dp->dt = T1440kb; setdef(dp); dp->cyl = -1; /* because we don't know */ - dp->cache = (uchar*)xspanalloc(dp->t->tsize, BY2PG, 0); + dp->cache = (uchar*)xspanalloc(dp->t->tsize, BY2PG, 64*1024); dp->ccyl = -1; dp->vers = 1; } diff --git a/pc/kbd.c b/pc/kbd.c index 6f0525dadf4c5509b160cab2761d46b846f94ce4..7211cdade856bfa7a8873181017e5dec764f2e3c 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -352,7 +352,6 @@ ps2mouseputc(IOQ *q, int c) mouse.dx = msg[1]; mouse.dy = -msg[2]; mouse.track = 1; - spllo(); /* mouse tracking kills uart0 */ mouseclock(); } return 0; diff --git a/pc/main.c b/pc/main.c index 86cecf94b014eb475772cc6a675d0ecb39a0341d..f95d053b4a771a13fad14acad4be501f4e13090c 100644 --- a/pc/main.c +++ b/pc/main.c @@ -232,7 +232,7 @@ confinit(void) /* * the first 640k is the standard useful memory - * the next 128K is the display + * the next 128K is the display, I/O mem, and BIOS * the last 256k belongs to the roms and other devices */ conf.npage0 = 640/4; @@ -271,8 +271,8 @@ confinit(void) conf.npage1 = (i*MB - conf.base1)/BY2PG; conf.npage = conf.npage0 + conf.npage1; - conf.ldepth = 1; - pcnt = screenbits()-1; /* Calculate % of memory for page pool */ + conf.ldepth = 0; + pcnt = (1<>5), x3to32(i>>2), x3to32(i<<1)); + break; + case 2: + case 1: + case 0: + gscreen.ldepth = 3; + for(i = 0; i < 16; i++){ + x = x6to32((i*63)/15); + setcolor(i, x, x, x); + } + gscreen.ldepth = ldepth; + break; + } } void screeninit(void) { - int i, x; + int i; ulong *l; - setmode(&mode12); - /* * arrow is defined as a big endian */ @@ -315,19 +387,6 @@ screeninit(void) if(conf.maxy == 0) conf.maxy = MAXY; setscreen(conf.maxx, conf.maxy, conf.ldepth); - - /* - * set up color map - */ - lock(&colorlock); - outb(CMWX, 0); - for(i = 0; i < 16; i++){ - x = (i*63)/15; - outb(CM, x); - outb(CM, x); - outb(CM, x); - } - unlock(&colorlock); } /* @@ -344,7 +403,8 @@ mbbrect(Rectangle r) mbb.max.x = r.max.x; if (r.max.y > mbb.max.y) mbb.max.y = r.max.y; - screenupdate(); + if (Dy(mbb) > 32 || Dx(mbb) > 32) + mousescreenupdate(); } void @@ -369,8 +429,8 @@ unlocktseng(void) { /* * copy litte endian soft screen to big endian hard screen */ -void -screenupdate(void) +static void +vgaupdate(void) { uchar *sp, *hp; int y, len, incs, inch, off, page, y2pg, ey; @@ -380,14 +440,6 @@ screenupdate(void) r = mbb; mbb = NULLMBB; - if(nocheck==0 && memcmp(pad1, pad2, 1024)){ - nocheck = 1; - print("b: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); - nocheck = 0; - memset(pad1, 0, 1024); - memset(pad2, 0, 1024); - } - if(Dy(r) < 0) return; @@ -454,6 +506,7 @@ screenupdate(void) y2pg = (64*1024/BY2WD)/gscreen.width; off = (r.min.y % y2pg) * gscreen.width * BY2WD + r.min.x; hp = (uchar*)(vgascreen.base) + off; + off = r.min.y * gscreen.width * BY2WD + r.min.x; sp = (uchar*)(gscreen.base) + off; len = r.max.x - r.min.x; if(len < 1) @@ -475,13 +528,22 @@ screenupdate(void) } break; } +} + +void +screenupdate(void) +{ + lock(&vgalock); + vgaupdate(); + unlock(&vgalock); +} - if(nocheck==0 && memcmp(pad1, pad2, 1024)){ - nocheck = 1; - print("a: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); - nocheck = 0; - memset(pad1, 0, 1024); - memset(pad2, 0, 1024); +void +mousescreenupdate(void) +{ + if(canlock(&vgalock)){ + vgaupdate(); + unlock(&vgalock); } } @@ -497,11 +559,9 @@ screenputnl(void) r = Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height); gbitblt(&gscreen, r.min, &gscreen, r, flipD[0]); mbbrect(r); - screenupdate(); + vgaupdate(); } -Lock screenlock; - void screenputs(char *s, int n) { @@ -541,7 +601,7 @@ screenputs(char *s, int n) } rs.max = Pt(gscreen.r.max.x, out.pos.y+defont0.height); mbbrect(rs); - screenupdate(); + vgaupdate(); } int @@ -551,40 +611,30 @@ screenbits(void) } -void -mousescreenupdate(void) -{ - screenupdate(); -} - -static ulong -expand(uchar x) -{ - return (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24)); -} - void getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) { p &= (1<<(1<>(32-6)); outb(CM, g>>(32-6)); outb(CM, b>>(32-6)); - unlock(&colorlock); + unlock(&vgalock); return ~0; } @@ -605,6 +655,7 @@ hwcursmove(int x, int y) void mouseclock(void) { + spllo(); /* so we don't cause lost chars on the uart */ mouseupdate(1); } diff --git a/port/devbit.c b/port/devbit.c index 76c1697feb04521b65c7e9cf19794e3ce0b55472..493284075c32af6824ff4e5dd4d95815603029b5 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -1602,9 +1602,9 @@ bitwrite(Chan *c, void *va, long n, ulong offset) } poperror(); - screenupdate(); if(isoff) cursoron(1); + screenupdate(); qunlock(&bit); return n; } @@ -1959,7 +1959,6 @@ cursoron(int dolock) gbitblt(&gscreen, cursor.r.min, &set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D); mbbrect(cursor.r); - screenupdate(); } if(dolock) unlock(&cursor); @@ -1975,7 +1974,7 @@ cursoroff(int dolock) if(--cursor.visible == 0) { gbitblt(&gscreen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S); mbbrect(cursor.r); - screenupdate(); + mousescreenupdate(); } if(dolock) unlock(&cursor);