From a12614456ed8cb841daee7ce7536a127ca341304 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 4 Nov 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-11-04 --- gnot/screen.c | 6 ---- gnot/screen.h | 5 +++ pc/devhard.c | 2 +- pc/screen.h | 5 +++ pc/vga.c | 6 ---- port/devbit.c | 92 +++++++++++++------------------------------------- port/devproc.c | 17 +++++++++- port/devscc.c | 2 +- port/portfns.h | 8 +++-- port/segment.c | 9 +++-- port/sysproc.c | 4 +-- ss/screen.c | 6 ---- ss/screen.h | 5 +++ 13 files changed, 71 insertions(+), 96 deletions(-) diff --git a/gnot/screen.c b/gnot/screen.c index b045ec0886689671171b3ffaf37ecb245b557585..d37307b53af2da2c64e149f72d2eb165690eaa45 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -184,9 +184,3 @@ mousectl(char *x) { USED(x); } - -void -screenupdate(Rectangle r) -{ - USED(r); -} diff --git a/gnot/screen.h b/gnot/screen.h index a3dd699a525856e050fc5a74688ba926b93df537..04fd048b804c96347861a49ecae322422183ad7f 100644 --- a/gnot/screen.h +++ b/gnot/screen.h @@ -29,3 +29,8 @@ extern Cursorinfo cursor; extern void mouseupdate(int); #define hwscreenwrite(a, b) + +#define mbbpt(x) +#define mbbrect(x) +#define screenupdate() +#define mousescreenupdate() diff --git a/pc/devhard.c b/pc/devhard.c index ede02e079a5fcba25e9e6cc769cc8f333561783d..268c92ae645b8ea7950987d4c42ef1aa4d79acad 100644 --- a/pc/devhard.c +++ b/pc/devhard.c @@ -982,7 +982,7 @@ hardintr(Ureg *ur) cp->cmd = 0; break; default: - print("weird disk interrupt, cmd=%02x, status=%02x\n", + print("weird disk interrupt, cmd=%.2ux, status=%.2ux\n", cp->cmd, cp->status); break; } diff --git a/pc/screen.h b/pc/screen.h index a3dd699a525856e050fc5a74688ba926b93df537..04fd048b804c96347861a49ecae322422183ad7f 100644 --- a/pc/screen.h +++ b/pc/screen.h @@ -29,3 +29,8 @@ extern Cursorinfo cursor; extern void mouseupdate(int); #define hwscreenwrite(a, b) + +#define mbbpt(x) +#define mbbrect(x) +#define screenupdate() +#define mousescreenupdate() diff --git a/pc/vga.c b/pc/vga.c index f875741302b1ad39ab7f6b5f994b808ef6d12c04..00a51b2e74d3d223db1052c610faf3db45798f33 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -381,9 +381,3 @@ bigcursor(void) memmove(&arrow, &fatarrow, sizeof(fatarrow)); } - -void -screenupdate(Rectangle r) -{ - USED(r); -} diff --git a/port/devbit.c b/port/devbit.c index cb80f0ee12003bdaaa6422344023640dbf850dca..9b85297f400c6e3bee9613096def4aba488cc979 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -106,10 +106,8 @@ extern GBitmap gscreen; Mouseinfo mouse; Cursorinfo cursor; -Rendez lcdmouse; int mouseshifted; int mousetype; -int islcd; Cursor arrow = { @@ -164,8 +162,6 @@ void cursoron(int); void cursoroff(int); int mousechanged(void*); -static Rectangle mbb = {10000, 10000, -10000, -10000}; - enum{ Qdir, Qbitblt, @@ -185,6 +181,19 @@ Dirtab bitdir[]={ #define NINFO 8192 /* max chars per subfont; sanity check only */ #define HDR 3 +void +lockedupdate(void) +{ + qlock(&bit); + if(waserror()){ + qunlock(&bit); + return; + } + screenupdate(); + qunlock(&bit); + poperror(); +} + void bitfreeup(void) { @@ -252,27 +261,6 @@ bitdebug(void) print("%d subfonts\n", l); } -/* - * need a process to do scsi transactions to update mouse on LCD - */ -void -lcdmousep(void *a) -{ - USED(a); - for(;;){ - sleep(&lcdmouse, return0, 0); - qlock(&bit); - if(waserror()){ - qunlock(&bit); - continue; - } - screenupdate(mbb); - mbb = Rect(10000, 10000, -10000, -10000); - qunlock(&bit); - poperror(); - } -} - void bitreset(void) { @@ -332,8 +320,6 @@ bitinit(void) cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5; } cursoron(1); - if(islcd) - kproc("lcdmouse", lcdmousep, 0); } Chan* @@ -777,32 +763,6 @@ bitread(Chan *c, void *va, long n, ulong offset) return n; } -static void -mbbrect(Rectangle r) -{ - if (r.min.x < mbb.min.x) - mbb.min.x = r.min.x; - if (r.min.y < mbb.min.y) - mbb.min.y = r.min.y; - if (r.max.x > mbb.max.x) - mbb.max.x = r.max.x; - if (r.max.y > mbb.max.y) - mbb.max.y = r.max.y; -} - -static void -mbbpt(Point p) -{ - if (p.x < mbb.min.x) - mbb.min.x = p.x; - if (p.y < mbb.min.y) - mbb.min.y = p.y; - if (p.x >= mbb.max.x) - mbb.max.x = p.x+1; - if (p.y >= mbb.max.y) - mbb.max.y = p.y+1; -} - Point bitstrsize(GFont *f, uchar *p, int l) { @@ -945,7 +905,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) isoff = 1; } gbitblt(dst, pt, src, rect, fc); - if(islcd && dst->base < endscreen) + if(dst->base < endscreen) mbbrect(Rpt(pt, add(pt, sub(rect.max, rect.min)))); m -= 31; p += 31; @@ -1180,7 +1140,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) isoff = 1; } gsegment(dst, pt1, pt2, t, fc); - if(islcd && dst->base < endscreen) { + if(dst->base < endscreen) { mbbpt(pt1); mbbpt(pt2); } @@ -1283,7 +1243,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) isoff = 1; } gpoint(dst, pt1, t, fc); - if(islcd && dst->base < endscreen) + if(dst->base < endscreen) mbbpt(pt1); m -= 14; p += 14; @@ -1375,7 +1335,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) isoff = 1; } bitstring(dst, pt, ff, p, l, fc); - if(islcd && dst->base < endscreen) + if(dst->base < endscreen) mbbrect(Rpt(pt, add(pt, bitstrsize(ff, p, l)))); m -= l; p += l; @@ -1414,7 +1374,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) isoff = 1; } gtexture(dst, rect, src, fc); - if(islcd && dst->base < endscreen) + if(dst->base < endscreen) mbbrect(rect); m -= 23; p += 23; @@ -1494,7 +1454,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) t = (t/ws)*ws; l = (t+dst->r.max.x+ws-1)/ws; } - if(islcd && dst->base < endscreen) + if(dst->base < endscreen) mbbrect(Rect(dst->r.min.x, miny, dst->r.max.x, maxy)); p += 11; m -= 11; @@ -1607,10 +1567,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) poperror(); if(isoff) cursoron(1); - if(islcd) { - screenupdate(mbb); - mbb = Rect(10000, 10000, -10000, -10000); - } + screenupdate(); qunlock(&bit); return n; } @@ -1962,8 +1919,7 @@ cursoron(int dolock) &clr, Rect(0, 0, 16, 16), flipping? flipD[D&~S] : D&~S); gbitblt(&gscreen, cursor.r.min, &set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D); - if(islcd) - mbbrect(cursor.r); + mbbrect(cursor.r); } if(dolock) unlock(&cursor); @@ -1976,8 +1932,7 @@ cursoroff(int dolock) lock(&cursor); if(--cursor.visible == 0) { gbitblt(&gscreen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S); - if(islcd) - mbbrect(cursor.r); + mbbrect(cursor.r); } if(dolock) unlock(&cursor); @@ -2026,8 +1981,7 @@ mouseupdate(int dolock) cursoroff(0); mouse.xy = Pt(x, y); cursoron(0); - if(islcd) - wakeup(&lcdmouse); + mousescreenupdate(); mouse.dx = 0; mouse.dy = 0; mouse.clock = 0; diff --git a/port/devproc.c b/port/devproc.c index dc16b0eaffa175a7231866802d92c1c89c535aa3..6fb94dd752b3f1a9a75f57f0906fcec4e95c6333 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -669,7 +669,7 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read) return n; } -Segment * +Segment* txt2data(Proc *p, Segment *s) { int i; @@ -695,3 +695,18 @@ txt2data(Proc *p, Segment *s) return ps; } + +Segment* +data2txt(Segment *s) +{ + Segment *ps; + + ps = newseg(SG_TEXT, s->base, s->size); + ps->image = s->image; + incref(ps->image); + ps->fstart = s->fstart; + ps->flen = s->flen; + ps->flushme = 1; + + return ps; +} diff --git a/port/devscc.c b/port/devscc.c index fab9363c599740896f177b95bb58276f0c1933c3..9a77aa7f810593b00d825a4062a910305f2e56d6 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -284,7 +284,7 @@ sccsetup0(SCC *sp, int brsource) * turn on baud rate generator and set rate to 9600 baud. * use 1 stop bit. */ - sp->sticky[14] = BRSource; + sp->sticky[14] = brsource ? BRSource : 0; sccwrreg(sp, 14, 0); sccsetbaud(sp, 9600); sp->sticky[4] = Rx1stop | X16; diff --git a/port/portfns.h b/port/portfns.h index 82687cbe8a06cb65b3010dd012841fae16fd523f..146dd854f72cc4272c1d5abc02ffddfcdeb1674d 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -31,6 +31,7 @@ int consactive(void); void consdebug(void); Block* copyb(Block*, int); void copypage(Page*, Page*); +Segment* data2txt(Segment*); int decref(Ref*); int decrypt(void*, void*, int); void delay(int); @@ -107,6 +108,8 @@ int m3mouseputc(IOQ*, int); void machinit(void); void* malloc(ulong); void mapstack(Proc*); +void mbbpt(Point); +void mbbrect(Rectangle); void mfreeseg(Segment*, ulong, int); void mmurelease(Proc*); void mntdump(void); @@ -116,6 +119,7 @@ void mousebuttons(int); void mousectl(char*); void mouseclock(void); int mouseputc(IOQ*, int); +void mousescreenupdate(void); int msize(void*); Chan* namec(char*, int, int, ulong); void nameok(char*); @@ -200,7 +204,7 @@ void sccspecial(int, IOQ*, IOQ*, int); void sched(void); void schedinit(void); int screenbits(void); -void screenupdate(Rectangle); +void screenupdate(void); Scsibuf* scsialloc(ulong); int scsibread(int, Scsibuf*, long, long, long); Scsibuf* scsibuf(void); @@ -266,5 +270,5 @@ void xhole(ulong, ulong); void xinit(void); void* xspanalloc(ulong, int, ulong); void xsummary(void); -Segment* dupseg(Segment*, int); +Segment* dupseg(Segment**, int, int); Segment* seg(Proc*, ulong, int); diff --git a/port/segment.c b/port/segment.c index 183817488e732682567de4fe339b9147f4d7bcb5..d82591f0b28c3901aae1c57b0ef1aa74ca09ac07 100644 --- a/port/segment.c +++ b/port/segment.c @@ -103,13 +103,15 @@ relocateseg(Segment *s, ulong offset) } Segment* -dupseg(Segment *s, int share) +dupseg(Segment **seg, int segno, int share) { int i; Pte *pte; - Segment *n; + Segment *n, *s; SET(n); + s = seg[segno]; + switch(s->type&SG_TYPE) { case SG_TEXT: /* New segment shares pte set */ case SG_SHARED: @@ -135,6 +137,9 @@ dupseg(Segment *s, int share) break; case SG_DATA: /* Copy on write plus demand load info */ + if(segno == TSEG) + return data2txt(s); + qlock(&s->lk); if(share && s->ref == 1) { s->type = (s->type&~SG_TYPE)|SG_SHDATA; diff --git a/port/sysproc.c b/port/sysproc.c index f00e4414f4669845a52e413a3a992f4e2752e419..bb40ec5b63e484ec3977c76b143d2823459c0cfd 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -102,8 +102,8 @@ sysrfork(ulong *arg) n = flag & RFMEM; for(i = 0; i < NSEG; i++) if(parent->seg[i]) - p->seg[i] = dupseg(parent->seg[i], n); - + p->seg[i] = dupseg(parent->seg, i, n); + /* Refs */ incref(u->dot); diff --git a/ss/screen.c b/ss/screen.c index dc4b29732b43ae758cdd7d87d6b1ded9aa58bca4..5847d5892d361aabf3fcf6cce8e967682b40280a 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -553,9 +553,3 @@ mousectl(char *arg) { USED(arg); } - -void -screenupdate(Rectangle r) -{ - USED(r); -} diff --git a/ss/screen.h b/ss/screen.h index a3dd699a525856e050fc5a74688ba926b93df537..04fd048b804c96347861a49ecae322422183ad7f 100644 --- a/ss/screen.h +++ b/ss/screen.h @@ -29,3 +29,8 @@ extern Cursorinfo cursor; extern void mouseupdate(int); #define hwscreenwrite(a, b) + +#define mbbpt(x) +#define mbbrect(x) +#define screenupdate() +#define mousescreenupdate()