From 47572908817de2a1b8a88cc15a0ed9903158a23e Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 3 May 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-05-03 --- pc/fns.h | 1 + pc/mouse.c | 61 ++++++++++++++++------------------------------ pc/sdata.c | 1 + pc/uarti8250.c | 12 +++++++++ port/devrealtime.c | 10 ++++++++ port/devuart.c | 15 ++++++++++++ port/edf.c | 15 ++++++++++-- port/edf.h | 6 +++++ port/portfns.h | 1 + 9 files changed, 80 insertions(+), 42 deletions(-) diff --git a/pc/fns.h b/pc/fns.h index 15af5306e53f6d1bb04d4e4a61b59b06a5dc4704..88b41466e3c7a940cf54d93d999180d82ff768c8 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -39,6 +39,7 @@ void i8042auxenable(void (*)(int, int)); void i8042reset(void); void i8250console(void); void* i8250alloc(int, int, int); +void i8250mouse(char*, int (*)(Queue*, int), int); void i8253init(void); void i8253enable(void); void i8253timerset(uvlong); diff --git a/pc/mouse.c b/pc/mouse.c index bd36239a1ea0efa95b00f970840edebd77d6db08..f218b3e3dd8f795c74cf44ba1eea3930821a31d9 100644 --- a/pc/mouse.c +++ b/pc/mouse.c @@ -21,6 +21,8 @@ enum Mouseserial= 1, MousePS2= 2, }; + +static QLock mousectlqlock; static int mousetype; static int intellimouse; static int packetsize; @@ -54,34 +56,6 @@ static Cmdtab mousectlmsg[] = CMserial, "serial", 0, }; -/* - * setup a serial mouse - */ -static void -serialmouse(int port, char *type, int setspeed) -{ -#ifdef notdef - if(mousetype == Mouseserial) - error(Emouseset); - - if(port >= 3 || port < 0) - error(Ebadarg); - - /* set up /dev/eia? as the mouse */ - if(setspeed) - setspeed = 1200; - if(type && *type == 'M') - uartspecial(port, setspeed, 0, 0, m3mouseputc); - else - uartspecial(port, setspeed, 0, 0, mouseputc); - mousetype = Mouseserial; - packetsize = 3; -#else - error("serial mouse not supported yet"); - USED(port, type, setspeed); -#endif /* notdef */ -} - /* * ps/2 mouse message is three bytes * @@ -275,6 +249,12 @@ mousectl(Cmdbuf *cb) { Cmdtab *ct; + qlock(&mousectlqlock); + if(waserror()){ + qunlock(&mousectlqlock); + nexterror(); + } + ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg)); switch(ct->index){ case CMaccelerated: @@ -309,18 +289,16 @@ mousectl(Cmdbuf *cb) setintellimouse(); break; case CMserial: - switch(cb->nf){ - case 1: - serialmouse(atoi(cb->f[0]+6), 0, 1); - break; - case 2: - serialmouse(atoi(cb->f[1]), 0, 0); - break; - case 3: - default: - serialmouse(atoi(cb->f[1]), cb->f[2], 0); - break; - } + if(mousetype == Mouseserial) + error(Emouseset); + + if(cb->nf > 2 && *cb->f[2] == 'M') + i8250mouse(cb->f[1], m3mouseputc, 0); + else + i8250mouse(cb->f[1], mouseputc, cb->nf == 1); + + mousetype = Mouseserial; + packetsize = 3; break; case CMhwaccel: if(strcmp(cb->f[1], "on")==0) @@ -330,4 +308,7 @@ mousectl(Cmdbuf *cb) else cmderror(cb, "bad mouse control message"); } + + qunlock(&mousectlqlock); + poperror(); } diff --git a/pc/sdata.c b/pc/sdata.c index 856e8ca260bca52e22aa978f1016ef72c196e45b..5aae96b8e7b1344bd58c6ffcb0897258eaef957c 100644 --- a/pc/sdata.c +++ b/pc/sdata.c @@ -1699,6 +1699,7 @@ atapnp(void) pcicfgw32(p, 0x40, r); break; case (0x4D38<<16)|0x105A: /* Promise PDC20262 */ + case (0x4D30<<16)|0x105A: /* Promise PDC202xx */ pi = 0x85; break; case (0x0640<<16)|0x1095: /* CMD 640B */ diff --git a/pc/uarti8250.c b/pc/uarti8250.c index 09c5c71b91c5cac1c2878972b81d35b529ebd918..795c4ffb2e025110349a93590c401ba2c0bba825 100644 --- a/pc/uarti8250.c +++ b/pc/uarti8250.c @@ -671,3 +671,15 @@ i8250console(void) consuart = uart; uart->console = 1; } + +void +i8250mouse(char* which, int (*putc)(Queue*, int), int setb1200) +{ + char *p; + int port; + + port = strtol(which, &p, 0); + if(p == which || port < 0 || port > 1) + error(Ebadarg); + uartmouse(&i8250uart[port], putc, setb1200); +} diff --git a/port/devrealtime.c b/port/devrealtime.c index ba8028503999a0a01e16df8fe4f5127e06abc167..9c2a6e65370c42a9c469c321365a7c8e8d7205ff 100644 --- a/port/devrealtime.c +++ b/port/devrealtime.c @@ -495,6 +495,16 @@ devrtread(Chan *c, void *v, long n, vlong offs) } p = seprint(p, e, "'"); } + if (t->periods) + p = seprint(p, e, " n=%lud", t->periods); + if (t->missed) + p = seprint(p, e, " m=%lud", t->missed); + if (t->preemptions) + p = seprint(p, e, " p=%lud", t->preemptions); + if (t->total) + p = seprint(p, e, " t=%T", ticks2time(t->total)); + if (t->aged) + p = seprint(p, e, " c=%T", ticks2time(t->aged)); seprint(p, e, "\n"); return readstr(offs, v, n, buf); } diff --git a/port/devuart.c b/port/devuart.c index 30456fb420ef1cf4c8c0843d0f11da0b6d62375d..d3e5ad2cc972e88a9a0c985939ef28e7c1aea370 100644 --- a/port/devuart.c +++ b/port/devuart.c @@ -112,6 +112,21 @@ uartdisable(Uart *p) unlock(&uartalloc); } +void +uartmouse(Uart* p, int (*putc)(Queue*, int), int setb1200) +{ + qlock(p); + if(p->opens++ == 0 && uartenable(p) == nil){ + qunlock(p); + error(Enodev); + } + if(setb1200) + uartctl(p, "b1200"); + p->putc = putc; + p->special = 1; + qunlock(p); +} + static void setlength(int i) { diff --git a/port/edf.c b/port/edf.c index 8d307ba9031b4871dc82391769a34cdef5fda17b..0b1263c32cf9569458bf060200b40a61bd5e444d 100644 --- a/port/edf.c +++ b/port/edf.c @@ -252,6 +252,7 @@ static void deadline(Proc *p, SEvent why) { Task *t, *nt; + Ticks used; /* Task has reached its deadline, lock must be held */ DPRINT("%d deadline, %s, %d\n", m->machno, edfstatename[p->task->state], p->task->runq.n); @@ -272,6 +273,11 @@ deadline(Proc *p, SEvent why) timerdel(&deadlinetimer[m->machno]); deadlinetimer[m->machno].when = 0; } + used = now - t->scheduled; + t->S -= used; + t->scheduled = now; + t->total += used; + t->aged = (t->aged*31 + t->C - t->S) >> 5; t->d = now; t->state = EdfDeadline; if(devrt) devrt(t, now, why); @@ -330,6 +336,7 @@ edfadmit(Task *t) t->S = t->C; t->scheduled = now; t->state = EdfRunning; + t->periods++; if(devrt) devrt(t, now, SRun); setdelta(); assert(t->runq.n > 0 || (up && up->task == t)); @@ -457,6 +464,7 @@ edfdeadlineintr(Ureg*, Timer*) used = now - t->scheduled; t->scheduled = now; + t->total += used; if (t->r < now){ if (t->S <= used) @@ -466,8 +474,10 @@ edfdeadlineintr(Ureg*, Timer*) if (t->d <= now || t->S == 0LL){ /* Task has reached its deadline/slice, remove from queue */ - if (t->S > 0LL) + if (t->d <= now){ + t->missed++; misseddeadlines++; + } deadline(up, SSlice); while (t = edfstack[m->machno].head){ if (now < t->d) @@ -728,9 +738,9 @@ edfrunproc(void) edfdequeue(&qreleased); assert(nt->runq.n >= 1); edfpush(nt); - nt->state = EdfRunning; t = nt; t->scheduled = now; + t->periods++; }else{ DPRINT("%d edfrunproc: current\n", m->machno); } @@ -741,6 +751,7 @@ runt: * No need to lock runq, edflock always held to access runq */ t->state = EdfRunning; + t->periods++; p = t->runq.head; if ((t->runq.head = p->rnext) == nil) t->runq.tail = nil; diff --git a/port/edf.h b/port/edf.h index 98b76e51270b1893634af3c82e102a64aef7e961..a8e1f399b5e7369d87783e9eb697b48e0fd7203f 100644 --- a/port/edf.h +++ b/port/edf.h @@ -51,6 +51,12 @@ struct Edf { int testtype; /* Release or Deadline */ Ticks testtime; Task * testnext; + /* statistics gathering */ + ulong periods; /* number of periods */ + ulong missed; /* number of deadlines missed */ + ulong preemptions; + Ticks total; /* total time used */ + Ticks aged; /* aged time used */ /* other */ Edfstate state; }; diff --git a/port/portfns.h b/port/portfns.h index 27aae6fd9fda94e7481dd6ef0c49b90cdb30e5fd..b0cd038bbf254915dfd6fc01f1877d996764fd85 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -340,6 +340,7 @@ void tsleep(Rendez*, int (*)(void*), void*, int); int uartctl(Uart*, char*); int uartgetc(void); void uartkick(void*); +void uartmouse(Uart*, int (*)(Queue*, int), int); void uartputc(int); void uartputs(char*, int); void uartrecv(Uart*, char);