kernel: fix usb after changing OREAD/OWRITE values
OREAD and OWRITE are used as array indexes assuming that OREAD was zero and OWRITE was one. Thus each related allocation reserved just 2 slot and even Ep struct in usb.h reserved just 2 int for toggles. Since OREAD is now 1 and OWRITE is 2 we have to allocate/reserve 3 slot as long as we use them as array indexes (which we could change in the future). Unfortunately this means we waste the index zero in those arrays that will always be unused. This also means that, to loop in such arrays we must begin with OREAD as index zero is always empty. PRO-MEMORIA: if/when we introduce the walk() syscall, OSTAT might turn useless. In that case we might remove it and thus consider to move back OREAD/OWRITE to 0/1 respectively (which might or might not be a good idea, to be analyzed).
This commit is contained in:
parent
c1eb65b35e
commit
890f126abc
|
@ -2059,7 +2059,7 @@ epopen(Ep *ep)
|
|||
ep->pollival = 1; /* assume this; doesn't really matter */
|
||||
/* and fall... */
|
||||
case Tintr:
|
||||
io = ep->aux = smalloc(sizeof(Qio)*2);
|
||||
io = ep->aux = smalloc(sizeof(Qio)*3);
|
||||
io[OREAD].debug = io[OWRITE].debug = ep->debug;
|
||||
usbid = (ep->nb&Epmax)<<7 | (ep->dev->nb&Devmax);
|
||||
if(ep->mode != OREAD){
|
||||
|
|
|
@ -1785,7 +1785,7 @@ epopen(Ep *ep)
|
|||
break;
|
||||
case Tbulk:
|
||||
case Tintr:
|
||||
io = ep->aux = smalloc(sizeof(Qio)*2);
|
||||
io = ep->aux = smalloc(sizeof(Qio)*3); // allocate 3 Qio because OREAD == 1 and OWRITE == 2; index 0 is wasted; TODO: fix this
|
||||
io[OREAD].debug = io[OWRITE].debug = ep->debug;
|
||||
usbid = ((ep->nb&Epmax)<<7)|(ep->dev->nb&Devmax);
|
||||
if(ep->mode != OREAD){
|
||||
|
|
|
@ -144,9 +144,9 @@ static Dirtab usbdir[] =
|
|||
|
||||
char *usbmodename[] =
|
||||
{
|
||||
[OREAD] "r",
|
||||
[OREAD] "r",
|
||||
[OWRITE] "w",
|
||||
[ORDWR] "rw",
|
||||
[ORDWR] "rw",
|
||||
};
|
||||
|
||||
static char *ttname[] =
|
||||
|
@ -223,7 +223,7 @@ name2mode(char *mode)
|
|||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < nelem(usbmodename); i++)
|
||||
for(i = OREAD; i < nelem(usbmodename); i++)
|
||||
if(strcmp(mode, usbmodename[i]) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
|
@ -821,7 +821,7 @@ usbopen(Chan *c, unsigned long omode)
|
|||
{
|
||||
int q;
|
||||
Ep *ep;
|
||||
int mode;
|
||||
unsigned long mode;
|
||||
|
||||
mode = openmode(omode);
|
||||
q = QID(c->qid);
|
||||
|
|
|
@ -163,8 +163,9 @@ struct Ep
|
|||
uint32_t load; /* in microseconds, for a fransfer of maxpkt bytes */
|
||||
void* aux; /* for controller specific info */
|
||||
int rhrepl; /* fake root hub replies */
|
||||
int toggle[2]; /* saved toggles (while ep is not in use) */
|
||||
int32_t pollival; /* poll interval ([µ]frames; intr/iso) */
|
||||
int toggle[3]; /* saved toggles (while ep is not in use)
|
||||
NOTE: 3 because OREAD == 1 and OWRITE == 2; index 0 is wasted; TODO fix this */
|
||||
int32_t pollival; /* poll interval ([µ]frames; intr/iso) */
|
||||
int32_t hz; /* poll frequency (iso) */
|
||||
int32_t samplesz; /* sample size (iso) */
|
||||
int ntds; /* nb. of Tds per µframe */
|
||||
|
|
|
@ -2923,7 +2923,7 @@ epopen(Ep *ep)
|
|||
ep->pollival = 1; /* assume this; doesn't really matter */
|
||||
/* and fall... */
|
||||
case Tintr:
|
||||
io = ep->aux = smalloc(sizeof(Qio)*2);
|
||||
io = ep->aux = smalloc(sizeof(Qio)*3);
|
||||
io[OREAD].debug = io[OWRITE].debug = ep->debug;
|
||||
usbid = (ep->nb&Epmax) << 7 | ep->dev->nb &Devmax;
|
||||
assert(ep->pollival != 0);
|
||||
|
|
Loading…
Reference in New Issue