M pc/devlpt.c => pc/devlpt.c +6 -6
@@ 10,8 10,8 @@
/* base addresses */
static int lptbase[] = {
- 0x3bc, /* lpt1 */
- 0x378, /* lpt2 (sic) */
+ 0x378, /* lpt1 */
+ 0x3bc, /* lpt2 */
0x278 /* lpt3 (sic) */
};
#define NDEV (sizeof lptbase/sizeof lptbase[0])
@@ 41,7 41,7 @@ enum
static int lptready(void*);
static void outch(int, int);
-static void lptintr(Ureg*);
+static void lptintr(Ureg*, void*);
static Rendez lptrendez;
@@ 89,7 89,7 @@ lptattach(char *spec)
if(!set){
set = 1;
- setvec(Parallelvec, lptintr);
+ setvec(Parallelvec, lptintr, 0);
}
if(i < 1 || i > NDEV)
error(Ebadarg);
@@ 217,8 217,8 @@ lptready(void *base)
}
static void
-lptintr(Ureg *ur)
+lptintr(Ureg *ur, void *arg)
{
- USED(ur);
+ USED(ur, arg);
wakeup(&lptrendez);
}
M port/portfns.h => port/portfns.h +1 -1
@@ 16,7 16,7 @@ void buzz(int, int);
void cachedel(Image*, ulong);
void cachepage(Page*, Image*);
void callbacks(void);
-void newcallback(void (*)(void));
+int newcallback(void (*)(void));
int cangetc(void*);
int canlock(Lock*);
int canpage(Proc*);
M port/proc.c => port/proc.c +6 -1
@@ 107,12 107,17 @@ anyready(void)
return m->hiq.head != 0 || m->loq.head != 0;
}
-void
+int
newcallback(void (*func)(void))
{
*m->cbin = func;
if(++m->cbin >= m->cbend)
m->cbin = m->calls;
+
+ if(m->hiq.head == 0 && m->loq.head == 0)
+ return 1;
+
+ return 0;
}
void
M port/qio.c => port/qio.c +10 -5
@@ 223,14 223,14 @@ qpass(Queue *q, Block *b)
memmove(q->syncbuf, b->rp, i);
q->syncbuf = 0; /* tell reader buffer is full */
len -= i;
- if(len <= 0 || (q->state & Qmsg)){
+ if(len <= 0 || (q->state & Qmsg)) {
iunlock(q);
wakeup(&q->rr);
freeb(b);
return i;
}
- /* queue anything that's left */
dowakeup = 1;
+ /* queue anything that's left */
b->rp += i;
}
@@ 243,6 243,9 @@ qpass(Queue *q, Block *b)
q->len += len;
checkb(b, "qpass");
+ if(q->len >= q->limit)
+ q->state |= Qflow;
+
if(q->state & Qstarve){
q->state &= ~Qstarve;
dowakeup = 1;
@@ 265,7 268,6 @@ qproduce(Queue *q, void *vp, int len)
int i, dowakeup;
uchar *p = vp;
-if(debuging) print("qproduce %d\n", len);
/* sync with qread */
dowakeup = 0;
lock(q);
@@ 433,7 435,7 @@ checkb(b, "qread 1");
q->len -= n;
/* if writer flow controlled, restart */
- if((q->state & Qflow) && q->len < q->limit/2){
+ if((q->state & Qflow) && q->len < q->limit){
q->state &= ~Qflow;
dowakeup = 1;
} else
@@ 459,8 461,11 @@ checkb(b, "qread 2");
}
/* wakeup flow controlled writers (with a bit of histeresis) */
- if(dowakeup)
+ if(dowakeup){
+ if(q->kick)
+ (*q->kick)(q->arg);
wakeup(&q->wr);
+ }
poperror();
qunlock(&q->rlock);