usbohci: virtual box fix from richard miller

This commit is contained in:
cinap_lenrek 2011-09-02 14:11:23 +02:00
parent 3cf8b41f8b
commit 9e65fced98

View file

@ -1146,10 +1146,10 @@ qhinterrupt(Ctlr *, Ep *ep, Qio *io, Td *td, int)
switch(err){ switch(err){
case Tddataovr: /* Overrun is not an error */ case Tddataovr: /* Overrun is not an error */
case Tdok: case Tdok:
/* can't make this assertion in virtualbox */ /* virtualbox doesn't always report underflow on short packets */
// if(td->cbp != 0) if(td->cbp == 0)
// panic("ohci: full packet but cbp != 0"); break;
break; /* fall through */
case Tddataund: case Tddataund:
/* short input packets are ok */ /* short input packets are ok */
if(mode == OREAD){ if(mode == OREAD){
@ -1338,12 +1338,16 @@ epgettd(Ep *ep, Qio *io, Td **dtdp, int flags, void *a, int count)
Td *td, *dtd; Td *td, *dtd;
Block *bp; Block *bp;
if(ep->maxpkt > 0x2000) if(count <= BY2PG)
panic("ohci: max packet > two pages"); bp = allocb(count);
if(ep->maxpkt < count) else{
error("maxpkt too short"); if(count > 2*BY2PG)
bp = allocb(ep->maxpkt); /* panics if no mem */ panic("ohci: transfer > two pages");
assert(bp != nil); /* maximum of one physical page crossing allowed */
bp = allocb(count+BY2PG);
bp->rp = (uchar*)PGROUND((uintptr)bp->rp);
bp->wp = bp->rp;
}
dtd = *dtdp; dtd = *dtdp;
td = dtd; td = dtd;
td->bp = bp; td->bp = bp;
@ -1494,7 +1498,7 @@ epio(Ep *ep, Qio *io, void *a, long count, int mustlock)
ltd = td0 = ed->tds; ltd = td0 = ed->tds;
load = tot = 0; load = tot = 0;
do{ do{
n = ep->maxpkt; n = 2*BY2PG;
if(count-tot < n) if(count-tot < n)
n = count-tot; n = count-tot;
if(c != nil && io->tok != Tdtokin) if(c != nil && io->tok != Tdtokin)