M pc/usbuhci.c => pc/usbuhci.c +26 -23
@@ 934,24 934,6 @@ portinfo(Usbhost *uh, char *s, char *se)
}
static void
-init(Usbhost* uh)
-{
- Ctlr *ctlr;
-
- ctlr = uh->ctlr;
- ilock(ctlr);
- outl(ctlr->io+Flbaseadd, PCIWADDR(ctlr->frames));
- OUT(Frnum, 0);
- OUT(Usbintr, 0xF); /* enable all interrupts */
- XPRINT("cmd 0x%x sofmod 0x%x\n", IN(Cmd), inb(ctlr->io+SOFMod));
- XPRINT("sc0 0x%x sc1 0x%x\n", IN(Portsc0), IN(Portsc1));
- if((IN(Cmd)&1)==0)
- OUT(Cmd, 1); /* run */
-// pprint("at: c=%x s=%x c0=%x\n", IN(Cmd), IN(Status), IN(Portsc0));
- iunlock(ctlr);
-}
-
-static void
cleaniso(Endpt *e, int frnum)
{
TD *td;
@@ 965,9 947,8 @@ cleaniso(Endpt *e, int frnum)
return;
id = (e->x<<7)|(e->dev->x&0x7F);
do {
-//shut up!
-// if (td->status & AnyError)
-// iprint("usbisoerror 0x%lux\n", td->status);
+ if (td->status & AnyError)
+ XPRINT("usbisoerror 0x%lux\n", td->status);
n = (td->status + 1) & 0x3ff;
e->nbytes += n;
if ((td->flags & IsoClean) == 0)
@@ 1354,6 1335,24 @@ XPRINT("qh %s: q=%p first=%p last=%p entries=%.8lux\n",
}
static void
+init(Usbhost* uh)
+{
+ Ctlr *ctlr;
+
+ ctlr = uh->ctlr;
+ ilock(ctlr);
+ outl(ctlr->io+Flbaseadd, PCIWADDR(ctlr->frames));
+ OUT(Frnum, 0);
+ OUT(Usbintr, 0xF); /* enable all interrupts */
+ XPRINT("cmd 0x%x sofmod 0x%x\n", IN(Cmd), inb(ctlr->io+SOFMod));
+ XPRINT("sc0 0x%x sc1 0x%x\n", IN(Portsc0), IN(Portsc1));
+ if((IN(Cmd)&1)==0)
+ OUT(Cmd, 1); /* run */
+// pprint("at: c=%x s=%x c0=%x\n", IN(Cmd), IN(Status), IN(Portsc0));
+ iunlock(ctlr);
+}
+
+static void
scanpci(void)
{
int io;
@@ 1407,6 1406,7 @@ reset(Usbhost *uh)
TD *t;
ulong io;
Ctlr *ctlr;
+ Pcidev *p;
scanpci();
@@ 1425,10 1425,13 @@ reset(Usbhost *uh)
if(ctlr == nil)
return -1;
+ p = ctlr->pcidev;
+ pcicfgw16(p, 0xc0, 0x2000); /* legacy support register: turn off lunacy mode */
+
uh->ctlr = ctlr;
uh->port = ctlr->io;
- uh->irq = ctlr->pcidev->intl;
- uh->tbdf = ctlr->pcidev->tbdf;
+ uh->irq = p->intl;
+ uh->tbdf = p->tbdf;
io = ctlr->io;
i = inb(io+SOFMod);
M port/chan.c => port/chan.c +3 -2
@@ 1114,9 1114,10 @@ namec(char *aname, int amode, int omode, ulong perm)
len = prefix+e.off[npath];
strcpy(tmperrbuf, up->errstr);
if(len < ERRMAX/3 || (name=memrchr(aname, '/', len))==nil || name==aname)
- snprint(up->errstr, ERRMAX, "\"%.*s\" %s", len, aname, tmperrbuf);
+ snprint(up->genbuf, sizeof up->genbuf, "%.*s", len, aname);
else
- snprint(up->errstr, ERRMAX, "\"...%.*s\" %s", (int)(len-(name-aname)), name, tmperrbuf);
+ snprint(up->genbuf, sizeof up->genbuf, "...%.*s", (int)(len-(name-aname)), name);
+ snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, tmperrbuf);
nexterror();
}
M port/devpnp.c => port/devpnp.c +3 -3
@@ 549,10 549,10 @@ pnpread(Chan *c, void *va, long n, vlong offset)
p = pcimatchtbdf(tbdf);
if(p == nil)
error(Egreg);
- if(offset > 128)
+ if(offset > 256)
return 0;
- if(n+offset > 128)
- n = 128-offset;
+ if(n+offset > 256)
+ n = 256-offset;
if(offset%4)
error(Ebadarg);
r = offset;
M port/devrealtime.c => port/devrealtime.c +4 -0
@@ 729,6 729,8 @@ devrtwrite(Chan *c, void *va, long n, vlong)
t->T += ticks;
break;
}
+ if (t->T < time2ticks(10000000/HZ))
+ error("period too short");
}else if (strcmp(a, "D") == 0){
if (e=parsetime(&time, v))
error(e);
@@ 767,6 769,8 @@ devrtwrite(Chan *c, void *va, long n, vlong)
t->C += ticks;
break;
}
+ if (t->C < time2ticks(10000000/HZ))
+ error("cost too small");
}else if (strcmp(a, "resources") == 0){
if (v == nil)
error("resources: value missing");
M port/portclock.c => port/portclock.c +0 -8
@@ 118,8 118,6 @@ hzclock(Ureg *ur)
checkalarms();
- m->inclockintr = 0;
-
if(up == 0 || up->state != Running)
return;
@@ 144,10 142,6 @@ timerintr(Ureg *u, uvlong)
uvlong when, now;
int callhzclock;
- if(m->inclockintr)
- return;
- m->inclockintr = 1;
-
intrcount[m->machno]++;
callhzclock = 0;
tt = &timers[m->machno];
@@ 160,7 154,6 @@ timerintr(Ureg *u, uvlong)
timerset(when);
if(callhzclock)
hzclock(u);
- m->inclockintr = 0;
return;
}
tt->head = t->next;
@@ 178,7 171,6 @@ timerintr(Ureg *u, uvlong)
}
}
iunlock(tt);
- m->inclockintr = 0;
}
uvlong hzperiod;
M port/proc.c => port/proc.c +1 -0
@@ 89,6 89,7 @@ sched(void)
{
if(up){
if(up->state == Running && up->nlocks){
+ up->delaysched = 1;
delayedscheds++;
return;
}
M port/taslock.c => port/taslock.c +7 -2
@@ 164,8 164,13 @@ unlock(Lock *l)
l->key = 0;
coherence();
- if(up)
- --up->nlocks;
+ /* give up the processor if ... */
+ if(up && --up->nlocks == 0 /* we've closed the last nexted lock */
+ && up->delaysched /* we delayed scheduling because of the lock */
+ && up->state == Running){ /* we're in running state */
+ up->delaysched = 0;
+ sched();
+ }
}
void