From 272d8c89c21b85e29b56ece28df7532556858576 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 7 May 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-05-07 --- pc/clock.c | 21 ++++++------ pc/devvga.c | 87 +++++++++++++++++--------------------------------- port/portdat.h | 9 ++++-- port/qio.c | 21 ++++++------ port/taslock.c | 2 +- 5 files changed, 58 insertions(+), 82 deletions(-) diff --git a/pc/clock.c b/pc/clock.c index 77a8a26dcf579720d26c9131bb598ea0c3824947..4e625689cae4df7c9209fee3f534fa71daee5862 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -53,7 +53,6 @@ clock(Ureg *ur, void *arg) m->ticks++; checkalarms(); - mouseclock(); hardclock(); uartclock(); @@ -70,16 +69,18 @@ clock(Ureg *ur, void *arg) nrun = (nrdy+nrun)*1000; MACHP(0)->load = (MACHP(0)->load*19+nrun)/20; - if(up == 0 || (ur->cs&0xffff) != UESEL || up->state != Running) - return; - - if(anyready()) - sched(); + if(up && (ur->cs&0xffff) == UESEL && up->state == Running){ + if(anyready()) + sched(); + + /* user profiling clock */ + spllo(); /* in case we fault */ + (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); + splhi(); + } - /* user profiling clock */ - spllo(); /* in case we fault */ - (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); - splhi(); + /* last because it could spllo() */ + mouseclock(); } /* diff --git a/pc/devvga.c b/pc/devvga.c index 4ce7b388d781923daf20f9128f2f509f294fb3e7..9c9db6694c8fd9488f0eba93cd075ebcdc18da08 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -132,9 +132,7 @@ static void cgascreenputc(int); static void cgascreenputs(char*, int); static void screenputc(char*); static void scroll(void); -static ulong x3to32(uchar); -static ulong x6to32(uchar); -static void greyscale(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); @@ -309,8 +307,6 @@ vgawrite(Chan *c, void *buf, long n, ulong offset) cbuf[n] = 0; if(strncmp(cbuf, "hwcursor", 8) == 0) hwcursor = 1; - else if(strncmp(cbuf, "grey", 4) == 0) - greyscale(); break; case Qvgasize: if(offset != 0 || n >= sizeof(cbuf)) @@ -591,13 +587,16 @@ setscreen(int maxx, int maxy, int ldepth) switch(ldepth){ case 3: for(i = 0; i < 256; i++) - setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i|(i<<1))); + setcolor(i, xnto32(i>>5, 3), xnto32(i>>2, 3), xnto32(i<<1, 2)); + setcolor(0x55, xnto32(0x15, 6), xnto32(0x15, 6), xnto32(0x15, 6)); + setcolor(0xaa, xnto32(0x2a, 6), xnto32(0x2a, 6), xnto32(0x2a, 6)); + setcolor(0xff, xnto32(0x3f, 6), xnto32(0x3f, 6), xnto32(0x3f, 6)); break; case 2: case 1: case 0: for(i = 0; i < 16; i++){ - x = x6to32((i*63)/15); + x = xnto32((i*63)/15, 6); setcolor(i, x, x, x); } break; @@ -976,60 +975,22 @@ screenputs(char *s, int n) /* - * expand 3 and 6 bits of color to 32 + * expand n bits of color to 32 */ static ulong -x3to32(uchar x) +xnto32(uchar x, int n) { + int s; ulong y; - x = x&7; - x= (x<<3)|x; - y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); + x &= (1< 0; s -= n) + y |= x<>(-s); return y; } -static ulong -x6to32(uchar x) -{ - ulong y; - - x = x&0x3f; - y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); - return y; -} -static ulong -x8to32(uchar x) -{ - ulong y; - - x = x&0xff; - y = (x<<(32-8))|(x<<(32-16))|(x<<(32-24))|x; - return y; -} -static void -greyscale(void) -{ - int i; - ulong x; - - /* default color map (has to be outside the lock) */ - switch(gscreen.ldepth){ - case 3: - for(i = 0; i < 256; i++){ - x = x8to32(i); - setcolor(i, x, x, x); - } - break; - case 2: - case 1: - case 0: - for(i = 0; i < 16; i++){ - x = x6to32((i*63)/15); - setcolor(i, x, x, x); - } - break; - } -} /* * paging routines for different cards @@ -1364,7 +1325,7 @@ setcursor(ulong *setbits, ulong *clrbits, int offx, int offy) void cursoron(int dolock) { - int xoff, yoff; + int xoff, yoff, s; Rectangle r; uchar *a; struct { @@ -1377,8 +1338,11 @@ cursoron(int dolock) if(cursor.disable) return; - if(dolock) + if(dolock){ + s = 0; /* to avoid compiler warning */ lock(&cursor); + } else + s = spllo(); /* to avoid freezing out the eia ports */ if(hwcursor) (*vgacard->mvcursor)(mousexy()); @@ -1430,21 +1394,30 @@ cursoron(int dolock) if(dolock) unlock(&cursor); + else + splx(s); } void cursoroff(int dolock) { + int s; + if(hwcursor) return; if(cursor.disable) return; - if(dolock) + if(dolock){ + s = 0; /* to avoid a compiler warning */ lock(&cursor); + } else + s = spllo(); /* to avoid freezing out the eia ports */ if(--cursor.visible == 0 && cursor.tl > 0) screenload(cursor.clipr, (uchar*)backbits, cursor.tl, cursor.l, 0); if(dolock) unlock(&cursor); + else + splx(s); } static void diff --git a/port/portdat.h b/port/portdat.h index 5c287bec0719fd5de14ba779b04a09113879870f..91022961b52d859183dda81a7db8a4c6e7c8b64d 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -118,6 +118,12 @@ struct Path char elem[NAMELEN]; }; +enum +{ + BINTR = (1<<0), + BFREE = (1<<1), +}; + struct Block { Block* next; @@ -126,8 +132,7 @@ struct Block uchar* wp; /* first empty byte */ uchar* lim; /* 1 past the end of the buffer */ uchar* base; /* start of the buffer */ - uchar flag; - uchar intr; + ulong flag; }; #define BLEN(s) ((s)->wp - (s)->rp) diff --git a/port/qio.c b/port/qio.c index c5777c96eb412f5d8ee3a47bca847453dea96089..c0e57b5b8dfdf3df1bd1d9933af4cd507c2556a8 100644 --- a/port/qio.c +++ b/port/qio.c @@ -44,14 +44,11 @@ struct Queue enum { - /* Block.flag */ - Bfilled=1, /* block filled */ - /* Queue.state */ - Qstarve= (1<<0), /* consumer starved */ - Qmsg= (1<<1), /* message stream */ - Qclosed= (1<<2), - Qflow= (1<<3), + Qstarve = (1<<0), /* consumer starved */ + Qmsg = (1<<1), /* message stream */ + Qclosed = (1<<2), + Qflow = (1<<3), }; void @@ -80,7 +77,7 @@ iallocb(int size) size = sizeof(Block) + size + (BY2V-1); if(ialloc.bytes > conf.ialloc){ - iprint("ialloc limit exceeded %d/%d\n", ialloc.bytes, conf.ialloc); + iprint("ialloc limit %d/%d\n", ialloc.bytes, conf.ialloc); return 0; } b = mallocz(size, 0); @@ -96,11 +93,11 @@ iallocb(int size) b->rp = b->base; b->wp = b->base; b->lim = ((uchar*)b) + size; - b->intr = 1; + b->flag = BINTR; - lock(&ialloc); + ilock(&ialloc); ialloc.bytes += b->lim - b->base; - unlock(&ialloc); + iunlock(&ialloc); return b; } @@ -108,7 +105,7 @@ iallocb(int size) void freeb(Block *b) { - if(b->intr) { + if(b->flag & BINTR) { ilock(&ialloc); ialloc.bytes -= b->lim - b->base; iunlock(&ialloc); diff --git a/port/taslock.c b/port/taslock.c index 0e1bd45d6d83eb749e8f3f975e403f603323e2ef..6ac49ada61e215e341528ca488e0433f3f9ff351 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -29,7 +29,7 @@ ilock(Lock *l) l->sr = x; return; } - +/* print("ilock loop %lux\n", getcallerpc(0)); */ for(;;){ while(l->key) ;