From 38a8227aa8ff14c5c1827652482f8b42293d29bf Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 31 Mar 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-03-31 --- carrera/dat.h | 9 --------- carrera/fns.h | 1 + pc/dat.h | 10 ++++------ pc/devlpt.c | 19 ++++++++++++------- pc/main.c | 5 +++++ port/devproc.c | 2 +- port/portdat.h | 8 ++++++++ port/qio.c | 3 +-- port/qlock.c | 5 ----- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/carrera/dat.h b/carrera/dat.h index 1304bde3b446aa0164a3b85728db04b0de63a325..56b66c70bc65dd348bc923c76754aff755cbaf71 100644 --- a/carrera/dat.h +++ b/carrera/dat.h @@ -85,15 +85,6 @@ struct Notsave #include "../port/portdat.h" -#define NCALLBACK 32 - -typedef struct Callbk Callbk; -struct Callbk -{ - void (*func)(void*); - void* arg; -}; - /* First FOUR members offsets known by l.s */ struct Mach { diff --git a/carrera/fns.h b/carrera/fns.h index ffc0af91a9d53fcc6baf9632a7f90dac7c7a2362..14f48a62d9e9c45da0e7551880c28bb11d1d4cae 100644 --- a/carrera/fns.h +++ b/carrera/fns.h @@ -133,6 +133,7 @@ void audiodmaintr(void); ulong fwblock(void*, void*, ulong); ulong frblock(void*, void*, ulong); void ifree(void*); +void ifflush(void*); Block* iallocb(int); void* ifroute(ulong); ulong ifunroute(ulong); diff --git a/pc/dat.h b/pc/dat.h index 913c52b9469cc100096e9eb39c44a0e6617db45f..7df3c7cff25b9705c944f6db5d23391ed2eca48e 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -114,8 +114,6 @@ struct Notsave * machine dependent definitions not used by ../port/dat.h */ -#define NCALLBACK 32 - struct Mach { int machno; /* physical id of processor */ @@ -129,10 +127,10 @@ struct Mach Schedq hiq; Schedq loq; - void (**cbin)(void); - void (**cbout)(void); - void (**cbend)(void); - void (*calls[NCALLBACK])(void); + Callbk* cbin; + Callbk* cbout; + Callbk* cbend; + Callbk calls[NCALLBACK]; int tlbfault; int tlbpurge; diff --git a/pc/devlpt.c b/pc/devlpt.c index e2c2a87537e757d68ae53a4551d46319060f90a6..49747d6434afccea433c6566407574d706c53f2f 100644 --- a/pc/devlpt.c +++ b/pc/devlpt.c @@ -197,13 +197,18 @@ lptwrite(Chan *c, void *a, long n) static void outch(int base, int c) { - int status = inb(base+Qpsr); - - if(!(status & Fselect) || !(status & Fnoerror)) - error(Eio); - if(!(status & Fnotbusy)){ - outb(base+Qpcr, Finitbar|Fie); - sleep(&lptrendez, lptready, (void *)base); + int status, tries; + + for(tries = 0;; tries++){ + status = inb(base+Qpsr); + if(!(status & Fselect) || !(status & Fnoerror)) + error(Eio); + if(status & Fnotbusy) + break; + if(tries > 1000){ + outb(base+Qpcr, Finitbar|Fie); + tsleep(&lptrendez, lptready, (void *)base, MS2HZ); + } } outb(base+Qdlr, c); outb(base+Qpcr, Finitbar|Fstrobe); diff --git a/pc/main.c b/pc/main.c index 3d39191a2802946b0c79de1b6a8bd742ab910e0b..5ae9a3efa09731e7a949901349f2b222a71b020a 100644 --- a/pc/main.c +++ b/pc/main.c @@ -91,6 +91,11 @@ machinit(void) memset(m, 0, sizeof(Mach)); m->machno = n; m->mmask = 1<machno; + + /* Setup call back ring buffer */ + m->cbin = m->calls; + m->cbout = m->calls; + m->cbend = &m->calls[NCALLBACK]; } void diff --git a/port/devproc.c b/port/devproc.c index 83ef81da72bf33102618c891ebcc49de85c6c5b4..17af5921c1b95864c574894a2fa66dc52c285d7d 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -34,7 +34,7 @@ Dirtab procdir[] = "counters", {Qcounters}, 0, 0444, "ctl", {Qctl}, 0, 0000, "fpregs", {Qfpregs}, sizeof(FPsave), 0000, - "kregs", {Qkregs}, sizeof(Ureg), 0400, + "kregs", {Qkregs}, sizeof(Ureg), 0000, "mem", {Qmem}, 0, 0000, "note", {Qnote}, 0, 0000, "noteid", {Qnoteid}, 0, 0666, diff --git a/port/portdat.h b/port/portdat.h index 289d4c6ed7b51bf6d28af778d38bbd42db8858bb..c80919d9bf99dd2204347df4eb749471fbbe83e3 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -595,6 +595,14 @@ struct Schedq int n; }; +#define NCALLBACK 32 + +typedef struct Callbk Callbk; +struct Callbk +{ + void (*func)(void*); + void* arg; +}; enum { diff --git a/port/qio.c b/port/qio.c index 1b7a24a22533f254fdc32ad3234c0bde5d49dd63..d06a18c7d0c95a5250a51b10b2d4a23ad894614e 100644 --- a/port/qio.c +++ b/port/qio.c @@ -415,8 +415,7 @@ qread(Queue *q, void *vp, int len) q->synclen = len; q->syncbuf = vp; iunlock(q); - while(q->syncbuf != 0) - sleep(&q->rr, filled, q); + sleep(&q->rr, filled, q); len = q->synclen; poperror(); qunlock(&q->rlock); diff --git a/port/qlock.c b/port/qlock.c index 16e83a8e04fdfafec9b2c9efdeebf143655e5892..7b7fbab557decc94227e4225425f5b2d6e409af0 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -10,8 +10,6 @@ qlock(QLock *q) { Proc *p, *mp; -up->qpc = getcallerpc(0); - lock(&q->use); if(!q->locked) { q->locked = 1; @@ -34,7 +32,6 @@ up->qpc = getcallerpc(0); int canqlock(QLock *q) { -up->qpc = getcallerpc(0); if(!canlock(&q->use)) return 0; if(q->locked){ @@ -51,8 +48,6 @@ qunlock(QLock *q) { Proc *p; -if(up==0) { iprint("QUNLOCK at ilevel PC=%lux\n", getcallerpc(0)); for(;;); } - lock(&q->use); p = q->head; if(p) {