From 288caae5f82539a2bf664b1aee489b9efd874e7e Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 26 Feb 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-02-26 --- gnot/clock.c | 2 +- gnot/devduart.c | 2 +- gnot/l.s | 1 - gnot/screen.c | 20 --------- gnot/screen.h | 30 ------------- gnot/segment.h | 11 +---- pc/clock.c | 1 + pc/devvga.c | 7 --- pc/kbd.c | 46 +++---------------- pc/screen.h | 30 ------------- port/devbit.c | 116 +++++++++++++++++++++++++++--------------------- port/devscc.c | 35 ++++++++++++++- port/portfns.h | 4 +- port/stlapd.c | 10 +++-- ss/screen.c | 6 --- ss/screen.h | 30 ------------- 16 files changed, 118 insertions(+), 233 deletions(-) diff --git a/gnot/clock.c b/gnot/clock.c index e7860a4912808761071f10d365be755a0a5f1f6c..3e24fad8d5ade847fdcfb87b0a9067de8f7b83a2 100644 --- a/gnot/clock.c +++ b/gnot/clock.c @@ -42,8 +42,8 @@ clock(Ureg *ur) MACHP(0)->load = (MACHP(0)->load*19+nrun)/20; checkalarms(); kbdclock(); - mouseclock(); duartclock(); + mouseclock(); kproftimer(ur->pc); if((ur->sr&SPL(7)) == 0 && p && p->state==Running){ if(anyready()){ diff --git a/gnot/devduart.c b/gnot/devduart.c index 93613003874f95fa3871557a1f9e0a6620367873..f3dda464c979b541ed2083dc31ca90d887eed940 100644 --- a/gnot/devduart.c +++ b/gnot/devduart.c @@ -427,7 +427,7 @@ duartintr(Ureg *ur) * Is it 5? */ if(cause & IM_IPC) - mousebuttons((~duart[0].ipc_acr) & 7); + mousetrack((~duart[0].ipc_acr) & 7, 0, 0); } diff --git a/gnot/l.s b/gnot/l.s index 23437af475e2b581b3ee1816f8ebe211d297dab6..28a01c583b328a029484a714b8d2ec3f29cd26c1 100644 --- a/gnot/l.s +++ b/gnot/l.s @@ -305,7 +305,6 @@ TEXT syncintr(SB), $0 /* level 6 */ BSR clock(SB) /* fall through */ retintr: - BSR mousetry(SB) ADDL $4, A7 MOVL ((8+8)*BY2WD)(A7), A0 MOVL A0, USP diff --git a/gnot/screen.c b/gnot/screen.c index d37307b53af2da2c64e149f72d2eb165690eaa45..e93471c86c0b80e04ea3b064a1c5475897482860 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -158,26 +158,6 @@ hwcursmove(int x, int y) return 0; } -void -mouseclock(void) /* called spl6 */ -{ - ++mouse.clock; -} - -void -mousetry(Ureg *ur) -{ - int s; - - if(mouse.clock && mouse.track && (ur->sr&SPL(7)) == 0 && canlock(&cursor)){ - s = spl1(); - mouseupdate(0); - splx(s); - unlock(&cursor); - wakeup(&mouse.r); - } -} - /* only 1 flavor mouse */ void mousectl(char *x) diff --git a/gnot/screen.h b/gnot/screen.h index ca23d47e4206e948453ca0795685c18068114cfe..21b9dad215e806a783d93d3c028f96c82ebeeb19 100644 --- a/gnot/screen.h +++ b/gnot/screen.h @@ -1,33 +1,3 @@ -typedef struct Mouseinfo Mouseinfo; -typedef struct Cursorinfo Cursorinfo; - -struct Mouseinfo{ - /* - * First three fields are known in some l.s's - */ - int dx; /* interrupt-time delta */ - int dy; - int track; /* update cursor on screen */ - Mouse; - ulong counter; /* increments every update */ - ulong lastcounter; /* value when /dev/mouse read */ - Rendez r; - int newbuttons; /* interrupt time access only */ - int clock; /* check mouse.track on RTE */ -}; - -struct Cursorinfo{ - Cursor; - Lock; - int visible; /* on screen */ - int disable; /* from being used */ - Rectangle r; /* location */ -}; - - -extern Mouseinfo mouse; -extern Cursorinfo cursor; - extern void mouseupdate(int); #define hwscreenwrite(a, b) diff --git a/gnot/segment.h b/gnot/segment.h index 09ba7e51b182f53270c25a3cc599327b4ec75e8e..4e0486de02f37f1d5236c4d74a6a9d5e62d13107 100644 --- a/gnot/segment.h +++ b/gnot/segment.h @@ -2,16 +2,7 @@ * Attach segment types */ -typedef struct Physseg Physseg; -struct Physseg -{ - ulong attr; /* Segment attributes */ - char *name; /* Attach name */ - ulong pa; /* Physical address */ - ulong size; /* Maximum segment size in pages */ - Page *(*pgalloc)(Segment*, ulong); /* Allocation if we need it */ - void (*pgfree)(Page*); -}physseg[] = { +Physseg physseg[] = { { SG_SHARED, "lock", 0, SEGMAXSIZE, 0, 0 }, { SG_SHARED, "shared", 0, SEGMAXSIZE, 0, 0 }, { SG_BSS, "memory", 0, SEGMAXSIZE, 0, 0 }, diff --git a/pc/clock.c b/pc/clock.c index e3ce7b1be26b22a7eaeb8f30da19bfb3482b8a56..88f815a8253ef35d0a464c92fa48c95a4182e64d 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -89,6 +89,7 @@ clock(Ureg *ur) checkalarms(); uartclock(); + mouseclock(); /* * process time accounting diff --git a/pc/devvga.c b/pc/devvga.c index 1bc407339ab3513001c5fd599042dfbf603155e4..8f85b3d40221df3ee0dbc32b5ea0e0298173f67f 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -931,13 +931,6 @@ hwcursmove(int x, int y) return 0; } -void -mouseclock(void) -{ - spllo(); /* so we don't cause lost chars on the uart */ - mouseupdate(1); -} - /* * a fatter than usual cursor for the safari */ diff --git a/pc/kbd.c b/pc/kbd.c index faa37570ded013f8b120d22dbf70594c4180ac71..d3bc85b21f6998f63704c5b2b20e0c0aebe51077 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -10,8 +10,6 @@ #include #include "screen.h" -extern Mouseinfo mouse; - enum { Data= 0x60, /* data port */ @@ -332,6 +330,7 @@ ps2mouseputc(IOQ *q, int c) static short msg[3]; static int nb; static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 }; + int buttons, dx, dy; USED(q); /* not */ /* @@ -348,11 +347,10 @@ ps2mouseputc(IOQ *q, int c) if(msg[0] & 0x20) msg[2] |= 0xFF00; - mouse.newbuttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons; - mouse.dx = msg[1]; - mouse.dy = -msg[2]; - mouse.track = 1; - mouseclock(); + buttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons; + dx = msg[1]; + dy = -msg[2]; + mousetrack(buttons, dx, dy); } return 0; } @@ -414,22 +412,6 @@ mousectl(char *arg) } } -/* - * Ctrl key used as middle button pressed - */ -static void -mbon(int val) -{ - keybuttons |= val; - mousebuttons(keybuttons); -} -static void -mboff(int val) -{ - keybuttons &= ~val; - mousebuttons(keybuttons); -} - /* * keyboard interrupt */ @@ -508,15 +490,6 @@ kbdintr0(void) case Ctrl: ctl = 0; break; - case KF|1: - mboff(Rbutton); - break; - case KF|2: - mboff(Mbutton); - break; - case KF|3: - mboff(Lbutton); - break; } return 0; } @@ -578,15 +551,6 @@ kbdintr0(void) case Ctrl: ctl = 1; return 0; - case KF|1: - mbon(Rbutton); - return 0; - case KF|2: - mbon(Mbutton); - return 0; - case KF|3: - mbon(Lbutton); - return 0; } } kbdputc(&kbdq, c); diff --git a/pc/screen.h b/pc/screen.h index 82777234e53787dc21d125fc0f795464d7ab98cd..1a9a7ed03f590df4842f62ac8c9f8b7ce500af76 100644 --- a/pc/screen.h +++ b/pc/screen.h @@ -1,33 +1,3 @@ -typedef struct Mouseinfo Mouseinfo; -typedef struct Cursorinfo Cursorinfo; - -struct Mouseinfo{ - /* - * First three fields are known in some l.s's - */ - int dx; /* interrupt-time delta */ - int dy; - int track; /* update cursor on screen */ - Mouse; - ulong counter; /* increments every update */ - ulong lastcounter; /* value when /dev/mouse read */ - Rendez r; - int newbuttons; /* interrupt time access only */ - int clock; /* check mouse.track on RTE */ -}; - -struct Cursorinfo{ - Cursor; - Lock; - int visible; /* on screen */ - int disable; /* from being used */ - Rectangle r; /* location */ -}; - - -extern Mouseinfo mouse; -extern Cursorinfo cursor; - extern void mouseupdate(int); #define hwscreenwrite(a, b) diff --git a/port/devbit.c b/port/devbit.c index 6a4c143836b64613ae29420830c4286cf7dffeeb..b403ec80903b4e2cb5c31f2f6d54bdb7a1e8d3f7 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -104,6 +104,31 @@ void bitstring(GBitmap*, Point, GFont*, uchar*, long, Fcode); void bitloadchar(GFont*, int, GSubfont*, int); extern GBitmap gscreen; +typedef struct Mouseinfo Mouseinfo; +typedef struct Cursorinfo Cursorinfo; + +struct Mouseinfo{ + /* + * First three fields are known in some l.s's + */ + int dx; + int dy; + int track; /* l.s has updated dx & dy */ + Mouse; + int redraw; /* update cursor on screen */ + ulong counter; /* increments every update */ + ulong lastcounter; /* value when /dev/mouse read */ + Rendez r; +}; + +struct Cursorinfo{ + Cursor; + Lock; + int visible; /* on screen */ + int disable; /* from being used */ + Rectangle r; /* location */ +}; + Mouseinfo mouse; Cursorinfo cursor; int mouseshifted; @@ -1578,7 +1603,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset) pt1.y = BGLONG(p+5); if(ptinrect(pt1, gscreen.r)){ mouse.xy = pt1; - mouse.track = 1; + mouse.redraw = 1; mouseclock(); } m -= 9; @@ -2027,61 +2052,51 @@ cursoroff(int dolock) unlock(&cursor); } +/* + * called by the clock routine to redraw the cursor + */ void -mousedelta(int b, int dx, int dy) /* called at higher priority */ -{ - mouse.dx += dx; - mouse.dy += dy; - mouse.newbuttons = b; - mouse.track = 1; -} - -void -mousebuttons(int b) /* called at higher priority */ +mouseclock(void) { - /* - * It is possible if you click very fast and get bad luck - * you could miss a button click (down up). Doesn't seem - * likely or important enough to worry about. - */ - mouse.newbuttons = b; - mouse.track = 1; /* aggressive but o.k. */ - mouseclock(); + if(mouse.track){ + mousetrack(mouse.buttons, mouse.dx, mouse.dy); + mouse.track = 0; + mouse.dx = 0; + mouse.dy = 0; + } + if(mouse.redraw && canlock(&cursor)){ + mouse.redraw = 0; + cursoroff(0); + cursoron(0); + mousescreenupdate(); + unlock(&cursor); + } } +/* + * called at interrupt level to update the structure and + * awaken any waiting procs. + */ void -mouseupdate(int dolock) +mousetrack(int b, int dx, int dy) { int x, y; - if(!mouse.track || (dolock && !canlock(&cursor))) - return; - - x = mouse.xy.x + mouse.dx; + x = mouse.xy.x + dx; if(x < gscreen.r.min.x) x = gscreen.r.min.x; if(x >= gscreen.r.max.x) x = gscreen.r.max.x; - y = mouse.xy.y + mouse.dy; + y = mouse.xy.y + dy; if(y < gscreen.r.min.y) y = gscreen.r.min.y; if(y >= gscreen.r.max.y) y = gscreen.r.max.y; - cursoroff(0); - mouse.xy = Pt(x, y); - cursoron(0); - mousescreenupdate(); - mouse.dx = 0; - mouse.dy = 0; - mouse.clock = 0; - mouse.track = 0; - mouse.buttons = mouse.newbuttons; mouse.counter++; - - if(dolock){ - unlock(&cursor); - wakeup(&mouse.r); - } + mouse.xy = Pt(x, y); + mouse.buttons = b; + mouse.redraw = 1; + wakeup(&mouse.r); } /* @@ -2102,6 +2117,7 @@ m3mouseputc(IOQ *q, int c) static int middle; static uchar b[] = { 0, 4, 1, 5, 0, 2, 1, 5 }; short x; + int dx, dy, newbuttons; USED(q); /* @@ -2111,20 +2127,20 @@ m3mouseputc(IOQ *q, int c) if((c&0x40) == 0){ /* an extra byte gets sent for the middle button */ middle = (c&0x20) ? 2 : 0; - mousebuttons((mouse.buttons & ~2) | middle); + newbuttons = (mouse.buttons & ~2) | middle; + mousetrack(newbuttons, 0, 0); return 0; } } msg[nb] = c; if(++nb == 3){ nb = 0; - mouse.newbuttons = middle | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)]; + newbuttons = middle | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)]; x = (msg[0]&0x3)<<14; - mouse.dx = (x>>8) | msg[1]; + dx = (x>>8) | msg[1]; x = (msg[0]&0xc)<<12; - mouse.dy = (x>>8) | msg[2]; - mouse.track = 1; - mouseclock(); + dy = (x>>8) | msg[2]; + mousetrack(newbuttons, dx, dy); } return 0; } @@ -2140,6 +2156,7 @@ mouseputc(IOQ *q, int c) static short msg[5]; static int nb; static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7}; + int dx, dy, newbuttons; USED(q); if((c&0xF0) == 0x80) @@ -2148,11 +2165,10 @@ mouseputc(IOQ *q, int c) if(c & 0x80) msg[nb] |= ~0xFF; /* sign extend */ if(++nb == 5){ - mouse.newbuttons = b[((msg[0]&7)^7) | (mouseshifted ? 8 : 0)]; - mouse.dx = msg[1]+msg[3]; - mouse.dy = -(msg[2]+msg[4]); - mouse.track = 1; - mouseclock(); + newbuttons = b[((msg[0]&7)^7) | (mouseshifted ? 8 : 0)]; + dx = msg[1]+msg[3]; + dy = -(msg[2]+msg[4]); + mousetrack(newbuttons, dx, dy); nb = 0; } return 0; diff --git a/port/devscc.c b/port/devscc.c index 6b4cf19ec387a2cbb6605538b75714a6fb69415d..f08286f44ee063d5e1aa7ed3f5a442a3a4de5beb 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -63,7 +63,9 @@ enum /* wr 11 */ TRxCOutBR= 2, + TxClockTRxC= 1<<3, TxClockBR= 2<<3, + RxClockTRxC= 1<<5, RxClockBR= 2<<5, TRxCOI= 1<<2, @@ -232,6 +234,24 @@ sccbits(SCC *sp, int n) sccwrreg(sp, 5, 0); } +/* + * set/clear external clock mode; the indigo uses the CTS pin, + * so we disable external interrupts. + */ +void +sccextclk(SCC *sp, int n) +{ + if(n){ + sp->sticky[1] &= ~ExtIntEna; + sp->sticky[11] = TxClockTRxC | RxClockTRxC; + }else{ + sp->sticky[1] |= ExtIntEna; + sp->sticky[11] = TxClockBR | RxClockBR | TRxCOutBR; + } + sccwrreg(sp, 1, 0); + sccwrreg(sp, 11, 0); +} + /* * toggle DTR */ @@ -486,6 +506,13 @@ sccspecial(int port, IOQ *oq, IOQ *iq, int baud) { SCC *sp = scc[port]; + /* let output drain */ + if(sp->oq){ + while(cangetc(sp->oq)) + sleep(&sp->oq->r, cangetc, sp->oq); + tsleep(&sp->oq->r, cangetc, sp->oq, 50); + } + sp->special = 1; sp->oq = oq; sp->iq = iq; @@ -585,7 +612,9 @@ sccoput(Queue *q, Block *bp) nexterror(); } if(bp->type == M_CTL){ - while (cangetc(cq)) /* let output drain */ + if(*bp->rptr == '!') /* do it now! */ + ++bp->rptr; + else while(cangetc(cq)) /* else let output drain */ sleep(&cq->r, cangetc, cq); n = strtoul((char *)(bp->rptr+1), 0, 0); switch(*bp->rptr){ @@ -596,6 +625,10 @@ sccoput(Queue *q, Block *bp) else sccsetbaud(sp, n); break; + case 'C': + case 'c': + sccextclk(sp, n); + break; case 'D': case 'd': sccdtr(sp, n); diff --git a/port/portfns.h b/port/portfns.h index ae6c9d40b1e7940e58c73a435d9c3039c7e374ae..bd723dd897321fabf8d97964f21885397eb4eeeb 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -119,9 +119,9 @@ void mmurelease(Proc*); void mntdump(void); int mount(Chan*, Chan*, int); void mountfree(Mount*); -void mousebuttons(int); -void mousectl(char*); void mouseclock(void); +void mousectl(char*); +void mousetrack(int, int, int); int mouseputc(IOQ*, int); void mousescreenupdate(void); int msize(void*); diff --git a/port/stlapd.c b/port/stlapd.c index e42b11ba8a42fa166b280b590984a385725e5440..9b783b9fc51a9ec39888394512d6f6429aa3cd94 100644 --- a/port/stlapd.c +++ b/port/stlapd.c @@ -120,6 +120,7 @@ char *lapderrors[] = { }; Lapd *lapd; +Lapd *lapdN; /* * predeclared @@ -164,7 +165,10 @@ lapderror(Lapd *lp, int code) static void lapdreset(void) { - lapd = xalloc(conf.nlapd*sizeof(Lapd)); + int nlapd = 3; /* formerly conf.nlapd */ + + lapd = xalloc(nlapd*sizeof(Lapd)); + lapdN = lapd + nlapd; } static void @@ -174,13 +178,13 @@ lapdopen(Queue *q, Stream *s) char name[32]; USED(s); - for(lp=lapd; lp<&lapd[conf.nlapd]; lp++){ + for(lp=lapd; lpstate == 0) break; qunlock(lp); } - if(lp>=&lapd[conf.nlapd]) + if(lp>=lapdN) error(Enoifc); /*q->flag |= QDEBUG; diff --git a/ss/screen.c b/ss/screen.c index 90fc155fc8358a04dacc729024a29db408f8917f..ab8c0e6bca2adc2c52d3a80a3ef5df144fe94e84 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -526,12 +526,6 @@ hwcursmove(int x, int y) return 0; } -void -mouseclock(void) /* called splhi */ -{ - mouseupdate(1); -} - /* replicate (from top) value in v (n bits) until it fills a ulong */ static ulong rep(ulong v, int n) diff --git a/ss/screen.h b/ss/screen.h index ca23d47e4206e948453ca0795685c18068114cfe..21b9dad215e806a783d93d3c028f96c82ebeeb19 100644 --- a/ss/screen.h +++ b/ss/screen.h @@ -1,33 +1,3 @@ -typedef struct Mouseinfo Mouseinfo; -typedef struct Cursorinfo Cursorinfo; - -struct Mouseinfo{ - /* - * First three fields are known in some l.s's - */ - int dx; /* interrupt-time delta */ - int dy; - int track; /* update cursor on screen */ - Mouse; - ulong counter; /* increments every update */ - ulong lastcounter; /* value when /dev/mouse read */ - Rendez r; - int newbuttons; /* interrupt time access only */ - int clock; /* check mouse.track on RTE */ -}; - -struct Cursorinfo{ - Cursor; - Lock; - int visible; /* on screen */ - int disable; /* from being used */ - Rectangle r; /* location */ -}; - - -extern Mouseinfo mouse; -extern Cursorinfo cursor; - extern void mouseupdate(int); #define hwscreenwrite(a, b)