@@ 1827,21 1827,24 @@ isoio(Endpt *e, void *a, long n, ulong offset, int w)
if (e->psize > e->maxpkt)
panic("packet size > maximum");
}
+ if((i = n) >= e->psize)
+ i = e->psize;
+ if (w)
+ e->buffered += i;
+ else{
+ e->buffered -= i;
+ if (e->buffered < 0)
+ e->buffered = 0;
+ }
+ isolock = 0;
+ iunlock(&activends);
td->flags &= ~IsoClean;
bp = e->bp0 + (td - e->td0) * e->maxpkt / e->pollms;
q = bp + e->off;
- if((i = n) >= e->psize)
- i = e->psize;
if (w){
memmove(q, p, i);
- e->buffered += i;
}else{
memmove(p, q, i);
- e->buffered -= i;
- if (e->buffered < 0){
- XPRINT("e->buffered %d?\n", e->buffered);
- e->buffered = 0;
- }
}
p += i;
n -= i;
@@ 1860,11 1863,9 @@ isoio(Endpt *e, void *a, long n, ulong offset, int w)
} while(n > 0);
n = p-(uchar*)a;
e->foffset += n;
- if (isolock){
- isolock = 0;
- iunlock(&activends);
- }
poperror();
+ if (isolock)
+ iunlock(&activends);
qunlock(&e->rlock);
return n;
}
@@ 116,7 116,6 @@ struct Udev
int state;
int id;
uchar port; /* port number on connecting hub */
- uchar root;
ulong csp;
int ls;
int npt;
@@ 125,14 124,19 @@ struct Udev
Udev* next; /* next device on this hub */
};
+/*
+ * One of these per active Host Controller Interface (HCI)
+ */
struct Usbhost
{
- ISAConf; /* hardware info */
+ ISAConf; /* hardware info */
+ int tbdf; /* type+busno+devno+funcno */
- int ctlrno;
- int tbdf; /* type+busno+devno+funcno */
+ QLock; /* protects namespace state */
+ int idgen; /* version number to distinguish new connections */
+ Udev* dev[MaxUsbDev]; /* device endpoints managed by this HCI */
- void (*init)(Usbhost*); /* filled in by reset routine */
+ void (*init)(Usbhost*);
void (*interrupt)(Ureg*, void*);
void (*portinfo)(Usbhost*, char*, char*);
@@ 151,4 155,4 @@ struct Usbhost
void *ctlr;
};
-extern void addusbhost(char*, int(*)(Usbhost*));
+extern void addusbtype(char*, int(*)(Usbhost*));
@@ 80,14 80,14 @@ static struct
}
portstatus[] =
{
- { Suspend, "Suspend", },
- { PortReset, "PortReset", },
- { SlowDevice, "SlowDevice", },
- { ResumeDetect, "ResumeDetect", },
- { PortChange, "PortChange", },
- { PortEnable, "PortEnable", },
- { StatusChange, "StatusChange", },
- { DevicePresent, "DevicePresent", },
+ { Suspend, "suspend", },
+ { PortReset, "reset", },
+ { SlowDevice, "lowspeed", },
+ { ResumeDetect, "resume", },
+ { PortChange, "portchange", },
+ { PortEnable, "enable", },
+ { StatusChange, "statuschange", },
+ { DevicePresent, "present", },
};
typedef struct Ctlr Ctlr;
@@ 396,9 396,8 @@ cleantd(Ctlr *ctlr, TD *t, int discard)
err = t->status & (AnyError&~NAKed);
/* TO DO: on t->status&AnyError, q->entries will not have advanced */
if (err) {
-// XPRINT("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer);
- print("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer);
-print("real maxlen %d\n", t->ep->maxpkt);
+ XPRINT("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer);
+// print("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer);
}
switch(t->dev&0xFF){
case TokIN:
@@ 1527,5 1526,5 @@ reset(Usbhost *uh)
void
usbuhcilink(void)
{
- addusbhost("uhci", reset);
+ addusbtype("uhci", reset);
}