From f8bb2b137a8f09ee32a7d97a713e79e77c35e1b0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 9 Oct 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-10-09 --- port/devlance.c | 14 +++++++++----- port/devmouse.c | 51 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/port/devlance.c b/port/devlance.c index 8d1bc3396ed3d8f379e42187bf582dd9dfc35c41..da0ff809785eefa24f81ee96f5d4117872859a9f 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -430,15 +430,16 @@ isoutbuf(void *x) return l.wedged || (MPus(m->flags)&LANCEOWNER) == 0; } -static void +static int etherloop(Etherpkt *p, long n) { - int s; + int s, different; ushort t; Netfile *f, **fp; - if(memcmp(p->d, p->s, sizeof(p->d)) && memcmp(p->d, l.bcast, sizeof(p->d))) - return; + different = memcmp(p->d, p->s, sizeof(p->d)); + if(different && memcmp(p->d, l.bcast, sizeof(p->d))) + return 0; s = splhi(); t = (p->type[0]<<8) | p->type[1]; @@ -450,6 +451,7 @@ etherloop(Etherpkt *p, long n) qproduce(f->in, p->d, n); } splx(s); + return !different; } long @@ -468,13 +470,15 @@ lancewrite(Chan *c, void *buf, long n, ulong offset) return netifwrite(&l, c, buf, n); /* we handle data */ + if(etherloop(buf, n)) + return n; + qlock(&l.tlock); m = &(LANCEMEM->tmr[l.tc]); tsleep(&l.tr, isoutbuf, m, 10000); if(!isoutbuf(m) || l.wedged) print("lance transmitter jammed\n"); else { - etherloop(buf, n); p = &l.tp[l.tc]; memmove(p->d, buf, n); if(n < 60) { diff --git a/port/devmouse.c b/port/devmouse.c index ded43fd7dc83beccb4ed11ec54d3d5d8fe3f1650..f92a7d35c5d23c42fc9070b63f9a5671d5f7b5fa 100644 --- a/port/devmouse.c +++ b/port/devmouse.c @@ -62,6 +62,7 @@ Cursorinfo cursor; int mouseshifted; int mousetype; int hwcurs; +Cursor curs; Cursor arrow = { @@ -116,11 +117,13 @@ int mousechanged(void*); enum{ Qdir, + Qcursor, Qmouse, Qmousectl, }; Dirtab mousedir[]={ + "cursor", {Qcursor}, 0, 0666, "mouse", {Qmouse}, 0, 0666, "mousectl", {Qmousectl}, 0, 0220, }; @@ -141,6 +144,7 @@ mousereset(void) if(r == 0) flipping = 1; flipping = 0; /* howard, why is this necessary to get a black arrow on carrera? */ + curs = arrow; Cursortocursor(&arrow); } @@ -244,6 +248,12 @@ mouseclose(Chan *c) lock(&mouse); if(c->qid.path == Qmouse) mouse.open = 0; + if(--mouse.ref == 0){ + cursoroff(1); + curs = arrow; + Cursortocursor(&arrow); + cursoron(1); + } unlock(&mouse); } } @@ -252,12 +262,28 @@ long mouseread(Chan *c, void *va, long n, ulong offset) { char buf[4*12+1]; + uchar *p; - USED(offset); - if(c->qid.path & CHDIR) + p = va; + switch(c->qid.path){ + case CHDIR: return devdirread(c, va, n, mousedir, NMOUSE, devgen); - if(c->qid.path == Qmouse){ + case Qcursor: + if(offset != 0) + return 0; + if(n < 2*4+2*2*16) + error(Eshort); + n = 2*4+2*2*16; + lock(&cursor); + BPLONG(p+0, curs.offset.x); + BPLONG(p+4, curs.offset.y); + memmove(p+8, curs.clr, 2*16); + memmove(p+40, curs.set, 2*16); + unlock(&cursor); + return n; + + case Qmouse: while(mousechanged(0) == 0) sleep(&mouse.r, mousechanged, 0); lock(&cursor); @@ -281,12 +307,27 @@ mousewrite(Chan *c, void *va, long n, ulong offset) Point pt; char buf[64]; - USED(offset); - + p = va; switch(c->qid.path){ case CHDIR: error(Eisdir); + case Qcursor: + cursoroff(1); + if(n < 2*4+2*2*16){ + curs = arrow; + Cursortocursor(&arrow); + }else{ + n = 2*4+2*2*16; + curs.offset.x = BGLONG(p+0); + curs.offset.y = BGLONG(p+4); + memmove(curs.clr, p+8, 2*16); + memmove(curs.set, p+40, 2*16); + Cursortocursor(&curs); + } + cursoron(1); + return n; + case Qmousectl: if(n >= sizeof(buf)) n = sizeof(buf)-1;