Partial sync with NetBSD:
Replace LE() macro with htole32()/le32toh().
This commit is contained in:
parent
a38a8f75a4
commit
a2036daf1c
@ -100,10 +100,14 @@ int ohcidebug = 1;
|
||||
* The OHCI controller is little endian, so on big endian machines
|
||||
* the data strored in memory needs to be swapped.
|
||||
*/
|
||||
#if defined(__FreeBSD__)
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define LE(x) (bswap32(x))
|
||||
#define htole32(x) (bswap32(x))
|
||||
#define le32toh(x) (bswap32(x))
|
||||
#else
|
||||
#define LE(x) (x)
|
||||
#define htole32(x) (x)
|
||||
#define le32toh(x) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct ohci_pipe;
|
||||
@ -532,11 +536,11 @@ ohci_alloc_std_chain(opipe, sc, len, rd, flags, dma, std, rstd)
|
||||
len -= curlen;
|
||||
|
||||
intr = len == 0 ? OHCI_TD_SET_DI(1) : OHCI_TD_NOINTR;
|
||||
cur->td.td_flags = LE(tdflags | intr);
|
||||
cur->td.td_cbp = LE(dataphys);
|
||||
cur->td.td_flags = htole32(tdflags | intr);
|
||||
cur->td.td_cbp = htole32(dataphys);
|
||||
cur->nexttd = next;
|
||||
cur->td.td_nexttd = LE(next->physaddr);
|
||||
cur->td.td_be = LE(dataphys + curlen - 1);
|
||||
cur->td.td_nexttd = htole32(next->physaddr);
|
||||
cur->td.td_be = htole32(dataphys + curlen - 1);
|
||||
cur->len = curlen;
|
||||
cur->flags = OHCI_ADD_LEN;
|
||||
DPRINTFN(10,("ohci_alloc_std_chain: cbp=0x%08x be=0x%08x\n",
|
||||
@ -554,11 +558,11 @@ ohci_alloc_std_chain(opipe, sc, len, rd, flags, dma, std, rstd)
|
||||
if (next == 0)
|
||||
goto nomem;
|
||||
|
||||
cur->td.td_flags = LE(tdflags | OHCI_TD_SET_DI(1));
|
||||
cur->td.td_flags = htole32(tdflags | OHCI_TD_SET_DI(1));
|
||||
cur->td.td_cbp = 0; /* indicate 0 length packet */
|
||||
cur->nexttd = next;
|
||||
cur->td.td_nexttd = LE(next->physaddr);
|
||||
cur->td.td_be = LE(dataphys - 1);
|
||||
cur->td.td_nexttd = htole32(next->physaddr);
|
||||
cur->td.td_be = htole32(dataphys - 1);
|
||||
cur->len = 0;
|
||||
cur->flags = 0;
|
||||
cur = next;
|
||||
@ -677,7 +681,7 @@ ohci_init(sc)
|
||||
err = USBD_NOMEM;
|
||||
goto bad1;
|
||||
}
|
||||
sc->sc_ctrl_head->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
sc->sc_ctrl_head->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
|
||||
/* Allocate dummy ED that starts the bulk list. */
|
||||
sc->sc_bulk_head = ohci_alloc_sed(sc);
|
||||
@ -685,7 +689,7 @@ ohci_init(sc)
|
||||
err = USBD_NOMEM;
|
||||
goto bad2;
|
||||
}
|
||||
sc->sc_bulk_head->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
sc->sc_bulk_head->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
|
||||
/* Allocate dummy ED that starts the isochronous list. */
|
||||
sc->sc_isoc_head = ohci_alloc_sed(sc);
|
||||
@ -693,7 +697,7 @@ ohci_init(sc)
|
||||
err = USBD_NOMEM;
|
||||
goto bad3;
|
||||
}
|
||||
sc->sc_isoc_head->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
sc->sc_isoc_head->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
|
||||
/* Allocate all the dummy EDs that make up the interrupt tree. */
|
||||
for (i = 0; i < OHCI_NO_EDS; i++) {
|
||||
@ -706,13 +710,13 @@ ohci_init(sc)
|
||||
}
|
||||
/* All ED fields are set to 0. */
|
||||
sc->sc_eds[i] = sed;
|
||||
sed->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
sed->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
if (i != 0)
|
||||
psed = sc->sc_eds[(i-1) / 2];
|
||||
else
|
||||
psed= sc->sc_isoc_head;
|
||||
sed->next = psed;
|
||||
sed->ed.ed_nexted = LE(psed->physaddr);
|
||||
sed->ed.ed_nexted = htole32(psed->physaddr);
|
||||
}
|
||||
/*
|
||||
* Fill HCCA interrupt table. The bit reversal is to get
|
||||
@ -720,7 +724,7 @@ ohci_init(sc)
|
||||
*/
|
||||
for (i = 0; i < OHCI_NO_INTRS; i++)
|
||||
sc->sc_hcca->hcca_interrupt_table[revbits[i]] =
|
||||
LE(sc->sc_eds[OHCI_NO_EDS-OHCI_NO_INTRS+i]->physaddr);
|
||||
htole32(sc->sc_eds[OHCI_NO_EDS-OHCI_NO_INTRS+i]->physaddr);
|
||||
|
||||
/* Determine in what context we are running. */
|
||||
ctl = OREAD4(sc, OHCI_CONTROL);
|
||||
@ -969,8 +973,8 @@ ohci_dumpregs(sc)
|
||||
OREAD4(sc, OHCI_RH_PORT_STATUS(1)),
|
||||
OREAD4(sc, OHCI_RH_PORT_STATUS(2))));
|
||||
DPRINTF((" HCCA: frame_number=0x%04x done_head=0x%08x\n",
|
||||
LE(sc->sc_hcca->hcca_frame_number),
|
||||
LE(sc->sc_hcca->hcca_done_head)));
|
||||
le32toh(sc->sc_hcca->hcca_frame_number),
|
||||
le32toh(sc->sc_hcca->hcca_done_head)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1009,7 +1013,7 @@ ohci_intr1(sc)
|
||||
}
|
||||
|
||||
intrs = 0;
|
||||
done = LE(sc->sc_hcca->hcca_done_head);
|
||||
done = le32toh(sc->sc_hcca->hcca_done_head);
|
||||
|
||||
/* The LSb of done is used to inform the HC Driver that an interrupt
|
||||
* condition exists for both the Done list and for another event
|
||||
@ -1141,8 +1145,8 @@ ohci_process_done(sc, done)
|
||||
|
||||
/* Reverse the done list and store the reversed list in sdone */
|
||||
sdone = NULL;
|
||||
for (; done; done = LE(std->td.td_nexttd)) {
|
||||
std = ohci_hash_find_td(sc, done & LE(OHCI_TAILMASK));
|
||||
for (; done; done = le32toh(std->td.td_nexttd)) {
|
||||
std = ohci_hash_find_td(sc, done & htole32(OHCI_TAILMASK));
|
||||
if (std == NULL) {
|
||||
#ifdef OHCI_DEBUG
|
||||
DPRINTF(("%s: Invalid done queue 0x%08x",
|
||||
@ -1183,7 +1187,7 @@ ohci_process_done(sc, done)
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
cc = OHCI_TD_GET_CC(LE(std->td.td_flags));
|
||||
cc = OHCI_TD_GET_CC(le32toh(std->td.td_flags));
|
||||
usb_untimeout(ohci_timeout, xfer, xfer->timo_handle);
|
||||
if (xfer->status == USBD_CANCELLED ||
|
||||
xfer->status == USBD_TIMEOUT) {
|
||||
@ -1195,8 +1199,8 @@ ohci_process_done(sc, done)
|
||||
xfer));
|
||||
len = std->len;
|
||||
if (std->td.td_cbp != 0)
|
||||
len -= LE(std->td.td_be) -
|
||||
LE(std->td.td_cbp) + 1;
|
||||
len -= le32toh(std->td.td_be) -
|
||||
le32toh(std->td.td_cbp) + 1;
|
||||
if (std->flags & OHCI_ADD_LEN)
|
||||
xfer->actlen += len;
|
||||
if (std->flags & OHCI_CALL_DONE) {
|
||||
@ -1215,8 +1219,8 @@ ohci_process_done(sc, done)
|
||||
(struct ohci_pipe *)xfer->pipe;
|
||||
|
||||
DPRINTF(("ohci_process_done: err cc=%d (%s), xfer=%p\n",
|
||||
OHCI_TD_GET_CC(LE(std->td.td_flags)),
|
||||
ohci_cc_strs[OHCI_TD_GET_CC(LE(std->td.td_flags))],
|
||||
OHCI_TD_GET_CC(le32toh(std->td.td_flags)),
|
||||
ohci_cc_strs[OHCI_TD_GET_CC(le32toh(std->td.td_flags))],
|
||||
xfer));
|
||||
|
||||
/* Mark all the TDs in the done queue for the current
|
||||
@ -1232,7 +1236,7 @@ ohci_process_done(sc, done)
|
||||
n = p->nexttd;
|
||||
ohci_free_std(sc, p);
|
||||
}
|
||||
opipe->sed->ed.ed_headp = LE(p->physaddr);
|
||||
opipe->sed->ed.ed_headp = htole32(p->physaddr);
|
||||
|
||||
/* XXX why is this being done? Why not OHCI_BLF too */
|
||||
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
|
||||
@ -1285,15 +1289,15 @@ ohci_device_intr_done(xfer)
|
||||
}
|
||||
tail->xfer = NULL;
|
||||
|
||||
data->td.td_flags = LE(
|
||||
data->td.td_flags = htole32(
|
||||
OHCI_TD_IN | OHCI_TD_NOCC |
|
||||
OHCI_TD_SET_DI(1) | OHCI_TD_TOGGLE_CARRY);
|
||||
if (xfer->flags & USBD_SHORT_XFER_OK)
|
||||
data->td.td_flags |= LE(OHCI_TD_R);
|
||||
data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->td.td_flags |= htole32(OHCI_TD_R);
|
||||
data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->nexttd = tail;
|
||||
data->td.td_nexttd = LE(tail->physaddr);
|
||||
data->td.td_be = LE(LE(data->td.td_cbp) + xfer->length - 1);
|
||||
data->td.td_nexttd = htole32(tail->physaddr);
|
||||
data->td.td_be = htole32(htole32(data->td.td_cbp) + xfer->length - 1);
|
||||
data->len = xfer->length;
|
||||
data->xfer = xfer;
|
||||
data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
|
||||
@ -1301,7 +1305,7 @@ ohci_device_intr_done(xfer)
|
||||
xfer->actlen = 0;
|
||||
|
||||
ohci_hash_add_td(sc, data);
|
||||
sed->ed.ed_tailp = LE(tail->physaddr);
|
||||
sed->ed.ed_tailp = htole32(tail->physaddr);
|
||||
opipe->tail.td = tail;
|
||||
}
|
||||
}
|
||||
@ -1453,8 +1457,8 @@ ohci_device_request(xfer)
|
||||
|
||||
/* Update device address and length since they may have changed. */
|
||||
/* XXX This only needs to be done once, but it's too early in open. */
|
||||
sed->ed.ed_flags = LE(
|
||||
(LE(sed->ed.ed_flags) & ~(OHCI_ED_ADDRMASK | OHCI_ED_MAXPMASK)) |
|
||||
sed->ed.ed_flags = htole32(
|
||||
(le32toh(sed->ed.ed_flags) & ~(OHCI_ED_ADDRMASK | OHCI_ED_MAXPMASK)) |
|
||||
OHCI_ED_SET_FA(addr) |
|
||||
OHCI_ED_SET_MAXP(UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize)));
|
||||
|
||||
@ -1465,14 +1469,14 @@ ohci_device_request(xfer)
|
||||
err = USBD_NOMEM;
|
||||
goto bad3;
|
||||
}
|
||||
data->td.td_flags = LE(
|
||||
data->td.td_flags = htole32(
|
||||
(isread ? OHCI_TD_IN : OHCI_TD_OUT) | OHCI_TD_NOCC |
|
||||
OHCI_TD_TOGGLE_1 | OHCI_TD_NOINTR |
|
||||
(xfer->flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0));
|
||||
data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->nexttd = stat;
|
||||
data->td.td_nexttd = LE(stat->physaddr);
|
||||
data->td.td_be = LE(LE(data->td.td_cbp) + len - 1);
|
||||
data->td.td_nexttd = htole32(stat->physaddr);
|
||||
data->td.td_be = htole32(le32toh(data->td.td_cbp) + len - 1);
|
||||
data->len = len;
|
||||
data->xfer = xfer;
|
||||
data->flags = OHCI_ADD_LEN;
|
||||
@ -1487,23 +1491,23 @@ ohci_device_request(xfer)
|
||||
|
||||
memcpy(KERNADDR(&opipe->u.ctl.reqdma, 0), req, sizeof *req);
|
||||
|
||||
setup->td.td_flags = LE(OHCI_TD_SETUP | OHCI_TD_NOCC |
|
||||
setup->td.td_flags = htole32(OHCI_TD_SETUP | OHCI_TD_NOCC |
|
||||
OHCI_TD_TOGGLE_0 | OHCI_TD_NOINTR);
|
||||
setup->td.td_cbp = LE(DMAADDR(&opipe->u.ctl.reqdma, 0));
|
||||
setup->td.td_cbp = htole32(DMAADDR(&opipe->u.ctl.reqdma, 0));
|
||||
setup->nexttd = next;
|
||||
setup->td.td_nexttd = LE(next->physaddr);
|
||||
setup->td.td_be = LE(LE(setup->td.td_cbp) + sizeof *req - 1);
|
||||
setup->td.td_nexttd = htole32(next->physaddr);
|
||||
setup->td.td_be = htole32(le32toh(setup->td.td_cbp) + sizeof *req - 1);
|
||||
setup->len = 0; /* XXX The number of byte we count */
|
||||
setup->xfer = xfer;
|
||||
setup->flags = 0;
|
||||
xfer->hcpriv = setup;
|
||||
|
||||
stat->td.td_flags = LE(
|
||||
stat->td.td_flags = htole32(
|
||||
(isread ? OHCI_TD_OUT : OHCI_TD_IN) | OHCI_TD_NOCC |
|
||||
OHCI_TD_TOGGLE_1 | OHCI_TD_SET_DI(1));
|
||||
stat->td.td_cbp = 0;
|
||||
stat->nexttd = tail;
|
||||
stat->td.td_nexttd = LE(tail->physaddr);
|
||||
stat->td.td_nexttd = htole32(tail->physaddr);
|
||||
stat->td.td_be = 0;
|
||||
stat->len = 0;
|
||||
stat->xfer = xfer;
|
||||
@ -1518,7 +1522,7 @@ ohci_device_request(xfer)
|
||||
|
||||
/* Insert ED in schedule */
|
||||
s = splusb();
|
||||
sed->ed.ed_tailp = LE(tail->physaddr);
|
||||
sed->ed.ed_tailp = htole32(tail->physaddr);
|
||||
opipe->tail.td = tail;
|
||||
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
|
||||
if (xfer->timeout && !sc->sc_bus.use_polling) {
|
||||
@ -1559,7 +1563,7 @@ ohci_add_ed(sed, head)
|
||||
sed->next = head->next;
|
||||
sed->ed.ed_nexted = head->ed.ed_nexted;
|
||||
head->next = sed;
|
||||
head->ed.ed_nexted = LE(sed->physaddr);
|
||||
head->ed.ed_nexted = htole32(sed->physaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1676,13 +1680,14 @@ ohci_dump_td(std)
|
||||
DPRINTF(("TD(%p) at %08lx: %b delay=%d ec=%d cc=%d\ncbp=0x%08lx "
|
||||
"nexttd=0x%08lx be=0x%08lx\n",
|
||||
std, (u_long)std->physaddr,
|
||||
(int)LE(std->td.td_flags),
|
||||
(int)le32toh(std->td.td_flags),
|
||||
"\20\23R\24OUT\25IN\31TOG1\32SETTOGGLE",
|
||||
OHCI_TD_GET_DI(LE(std->td.td_flags)),
|
||||
OHCI_TD_GET_EC(LE(std->td.td_flags)),
|
||||
OHCI_TD_GET_CC(LE(std->td.td_flags)),
|
||||
(u_long)LE(std->td.td_cbp),
|
||||
(u_long)LE(std->td.td_nexttd), (u_long)LE(std->td.td_be)));
|
||||
OHCI_TD_GET_DI(le32toh(std->td.td_flags)),
|
||||
OHCI_TD_GET_EC(le32toh(std->td.td_flags)),
|
||||
OHCI_TD_GET_CC(le32toh(std->td.td_flags)),
|
||||
(u_long)le32toh(std->td.td_cbp),
|
||||
(u_long)le32toh(std->td.td_nexttd),
|
||||
(u_long)le32toh(std->td.td_be)));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1692,16 +1697,16 @@ ohci_dump_ed(sed)
|
||||
DPRINTF(("ED(%p) at %08lx: addr=%d endpt=%d maxp=%d %b\n"
|
||||
"tailp=0x%8b headp=0x%8b nexted=0x%08lx\n",
|
||||
sed, (u_long)sed->physaddr,
|
||||
OHCI_ED_GET_FA(LE(sed->ed.ed_flags)),
|
||||
OHCI_ED_GET_EN(LE(sed->ed.ed_flags)),
|
||||
OHCI_ED_GET_MAXP(LE(sed->ed.ed_flags)),
|
||||
(int)LE(sed->ed.ed_flags),
|
||||
OHCI_ED_GET_FA(le32toh(sed->ed.ed_flags)),
|
||||
OHCI_ED_GET_EN(le32toh(sed->ed.ed_flags)),
|
||||
OHCI_ED_GET_MAXP(le32toh(sed->ed.ed_flags)),
|
||||
(int)le32toh(sed->ed.ed_flags),
|
||||
"\20\14OUT\15IN\16LOWSPEED\17SKIP\20ISO",
|
||||
(int)(uintptr_t)LE(sed->ed.ed_tailp),
|
||||
(int)(uintptr_t)le32toh(sed->ed.ed_tailp),
|
||||
"\20\1BIT1\2BIT2",
|
||||
(int)(uintptr_t)LE(sed->ed.ed_headp),
|
||||
(int)(uintptr_t)le32toh(sed->ed.ed_headp),
|
||||
"\20\1HALT\2CARRY",
|
||||
(u_long)LE(sed->ed.ed_nexted)));
|
||||
(u_long)le32toh(sed->ed.ed_nexted)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1749,7 +1754,7 @@ ohci_open(pipe)
|
||||
goto bad1;
|
||||
}
|
||||
opipe->tail.itd = sitd;
|
||||
tdphys = LE(sitd->physaddr);
|
||||
tdphys = sitd->physaddr;
|
||||
fmt = OHCI_ED_FORMAT_ISO;
|
||||
} else {
|
||||
std = ohci_alloc_std(sc);
|
||||
@ -1758,16 +1763,16 @@ ohci_open(pipe)
|
||||
goto bad1;
|
||||
}
|
||||
opipe->tail.td = std;
|
||||
tdphys = LE(std->physaddr);
|
||||
tdphys = std->physaddr;
|
||||
fmt = OHCI_ED_FORMAT_GEN;
|
||||
}
|
||||
sed->ed.ed_flags = LE(
|
||||
sed->ed.ed_flags = htole32(
|
||||
OHCI_ED_SET_FA(addr) |
|
||||
OHCI_ED_SET_EN(ed->bEndpointAddress) |
|
||||
OHCI_ED_DIR_TD |
|
||||
(dev->lowspeed ? OHCI_ED_SPEED : 0) | fmt |
|
||||
OHCI_ED_SET_MAXP(UGETW(ed->wMaxPacketSize)));
|
||||
sed->ed.ed_headp = sed->ed.ed_tailp = tdphys;
|
||||
sed->ed.ed_headp = sed->ed.ed_tailp = htole32(tdphys);
|
||||
|
||||
switch (xfertype) {
|
||||
case UE_CONTROL:
|
||||
@ -1825,9 +1830,9 @@ ohci_close_pipe(pipe, head)
|
||||
|
||||
s = splusb();
|
||||
#ifdef DIAGNOSTIC
|
||||
sed->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
if ((sed->ed.ed_tailp & LE(OHCI_TAILMASK))
|
||||
!= (sed->ed.ed_headp & LE(OHCI_HEADMASK))) {
|
||||
sed->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
if ((le32toh(sed->ed.ed_tailp) & OHCI_TAILMASK)
|
||||
!= (le32toh(sed->ed.ed_headp) & OHCI_HEADMASK)) {
|
||||
ohci_physaddr_t td = sed->ed.ed_headp;
|
||||
ohci_soft_td_t *std;
|
||||
for (std = LIST_FIRST(&sc->sc_hash_tds[HASH(td)]);
|
||||
@ -1837,11 +1842,12 @@ ohci_close_pipe(pipe, head)
|
||||
break;
|
||||
printf("ohci_close_pipe: pipe not empty sed=%p hd=0x%x "
|
||||
"tl=0x%x pipe=%p, std=%p\n", sed,
|
||||
(int)LE(sed->ed.ed_headp), (int)LE(sed->ed.ed_tailp),
|
||||
(int)le32toh(sed->ed.ed_headp),
|
||||
(int)le32toh(sed->ed.ed_tailp),
|
||||
pipe, std);
|
||||
usb_delay_ms(&sc->sc_bus, 2);
|
||||
if ((sed->ed.ed_tailp & LE(OHCI_TAILMASK))
|
||||
!= (sed->ed.ed_headp & LE(OHCI_HEADMASK)))
|
||||
if ((le32toh(sed->ed.ed_tailp) & OHCI_TAILMASK) !=
|
||||
(le32toh(sed->ed.ed_headp) & OHCI_HEADMASK))
|
||||
printf("ohci_close_pipe: pipe still not empty\n");
|
||||
}
|
||||
#endif
|
||||
@ -1875,7 +1881,7 @@ ohci_abort_xfer(xfer, status)
|
||||
usb_untimeout(ohci_timeout, xfer, xfer->timo_handle);
|
||||
|
||||
sed = opipe->sed;
|
||||
sed->ed.ed_flags |= LE(OHCI_ED_SKIP); /* force hardware skip */
|
||||
sed->ed.ed_flags |= htole32(OHCI_ED_SKIP); /* force hardware skip */
|
||||
#ifdef OHCI_DEBUG
|
||||
DPRINTFN(1,("ohci_abort_xfer: stop ed=%p\n", sed));
|
||||
ohci_dump_ed(sed);
|
||||
@ -1927,9 +1933,9 @@ ohci_abort_xfer_end(v)
|
||||
|
||||
sed = opipe->sed;
|
||||
DPRINTFN(2,("ohci_abort_xfer: set hd=%x, tl=%x\n",
|
||||
(int)LE(p->physaddr), (int)LE(sed->ed.ed_tailp)));
|
||||
sed->ed.ed_headp = p->physaddr; /* unlink TDs */
|
||||
sed->ed.ed_flags &= LE(~OHCI_ED_SKIP); /* remove hardware skip */
|
||||
(int)p->physaddr, (int)le32toh(sed->ed.ed_tailp)));
|
||||
sed->ed.ed_headp = htole32(p->physaddr); /* unlink TDs */
|
||||
sed->ed.ed_flags &= htole32(~OHCI_ED_SKIP); /* remove hardware skip */
|
||||
|
||||
usb_transfer_complete(xfer);
|
||||
|
||||
@ -2477,7 +2483,7 @@ ohci_device_clear_toggle(pipe)
|
||||
{
|
||||
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
|
||||
|
||||
opipe->sed->ed.ed_headp &= LE(~OHCI_TOGGLECARRY);
|
||||
opipe->sed->ed.ed_headp &= htole32(~OHCI_TOGGLECARRY);
|
||||
}
|
||||
|
||||
Static void
|
||||
@ -2535,8 +2541,8 @@ ohci_device_bulk_start(xfer)
|
||||
opipe->u.bulk.length = len;
|
||||
|
||||
/* Update device address */
|
||||
sed->ed.ed_flags = LE(
|
||||
(LE(sed->ed.ed_flags) & ~OHCI_ED_ADDRMASK) |
|
||||
sed->ed.ed_flags = htole32(
|
||||
(le32toh(sed->ed.ed_flags) & ~OHCI_ED_ADDRMASK) |
|
||||
OHCI_ED_SET_FA(addr));
|
||||
|
||||
/* Allocate a chain of new TDs (including a new tail). */
|
||||
@ -2551,8 +2557,10 @@ ohci_device_bulk_start(xfer)
|
||||
|
||||
DPRINTFN(4,("ohci_device_bulk_start: ed_flags=0x%08x td_flags=0x%08x "
|
||||
"td_cbp=0x%08x td_be=0x%08x\n",
|
||||
(int)LE(sed->ed.ed_flags), (int)LE(data->td.td_flags),
|
||||
(int)LE(data->td.td_cbp), (int)LE(data->td.td_be)));
|
||||
(int)le32toh(sed->ed.ed_flags),
|
||||
(int)le32toh(data->td.td_flags),
|
||||
(int)le32toh(data->td.td_cbp),
|
||||
(int)le32toh(data->td.td_be)));
|
||||
|
||||
#ifdef OHCI_DEBUG
|
||||
if (ohcidebug > 4) {
|
||||
@ -2567,9 +2575,9 @@ ohci_device_bulk_start(xfer)
|
||||
tdp->xfer = xfer;
|
||||
ohci_hash_add_td(sc, tdp);
|
||||
}
|
||||
sed->ed.ed_tailp = LE(tail->physaddr);
|
||||
sed->ed.ed_tailp = htole32(tail->physaddr);
|
||||
opipe->tail.td = tail;
|
||||
sed->ed.ed_flags &= LE(~OHCI_ED_SKIP);
|
||||
sed->ed.ed_flags &= htole32(~OHCI_ED_SKIP);
|
||||
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_BLF);
|
||||
if (xfer->timeout && !sc->sc_bus.use_polling) {
|
||||
usb_timeout(ohci_timeout, xfer,
|
||||
@ -2661,15 +2669,15 @@ ohci_device_intr_start(xfer)
|
||||
return (USBD_NOMEM);
|
||||
tail->xfer = NULL;
|
||||
|
||||
data->td.td_flags = LE(
|
||||
data->td.td_flags = htole32(
|
||||
OHCI_TD_IN | OHCI_TD_NOCC |
|
||||
OHCI_TD_SET_DI(1) | OHCI_TD_TOGGLE_CARRY);
|
||||
if (xfer->flags & USBD_SHORT_XFER_OK)
|
||||
data->td.td_flags |= LE(OHCI_TD_R);
|
||||
data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->td.td_flags |= htole32(OHCI_TD_R);
|
||||
data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf, 0));
|
||||
data->nexttd = tail;
|
||||
data->td.td_nexttd = LE(tail->physaddr);
|
||||
data->td.td_be = LE(LE(data->td.td_cbp) + len - 1);
|
||||
data->td.td_nexttd = htole32(tail->physaddr);
|
||||
data->td.td_be = htole32(le32toh(data->td.td_cbp) + len - 1);
|
||||
data->len = len;
|
||||
data->xfer = xfer;
|
||||
data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
|
||||
@ -2686,9 +2694,9 @@ ohci_device_intr_start(xfer)
|
||||
/* Insert ED in schedule */
|
||||
s = splusb();
|
||||
ohci_hash_add_td(sc, data);
|
||||
sed->ed.ed_tailp = LE(tail->physaddr);
|
||||
sed->ed.ed_tailp = htole32(tail->physaddr);
|
||||
opipe->tail.td = tail;
|
||||
sed->ed.ed_flags &= LE(~OHCI_ED_SKIP);
|
||||
sed->ed.ed_flags &= htole32(~OHCI_ED_SKIP);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
@ -2737,13 +2745,13 @@ ohci_device_intr_close(pipe)
|
||||
DPRINTFN(1,("ohci_device_intr_close: pipe=%p nslots=%d pos=%d\n",
|
||||
pipe, nslots, pos));
|
||||
s = splusb();
|
||||
sed->ed.ed_flags |= LE(OHCI_ED_SKIP);
|
||||
if ((sed->ed.ed_tailp & LE(OHCI_TAILMASK))
|
||||
!= (sed->ed.ed_headp & LE(OHCI_HEADMASK)))
|
||||
sed->ed.ed_flags |= htole32(OHCI_ED_SKIP);
|
||||
if ((le32toh(sed->ed.ed_tailp) & OHCI_TAILMASK) !=
|
||||
(le32toh(sed->ed.ed_headp) & OHCI_HEADMASK))
|
||||
usb_delay_ms(&sc->sc_bus, 2);
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((sed->ed.ed_tailp & LE(OHCI_TAILMASK))
|
||||
!= (sed->ed.ed_headp & LE(OHCI_HEADMASK)))
|
||||
if ((le32toh(sed->ed.ed_tailp) & OHCI_TAILMASK) !=
|
||||
(le32toh(sed->ed.ed_headp) & OHCI_HEADMASK))
|
||||
panic("%s: Intr pipe %p still has TDs queued\n",
|
||||
USBDEVNAME(sc->sc_bus.bdev), pipe);
|
||||
#endif
|
||||
@ -2818,7 +2826,7 @@ ohci_device_setintr(sc, opipe, ival)
|
||||
sed->next = hsed->next;
|
||||
sed->ed.ed_nexted = hsed->ed.ed_nexted;
|
||||
hsed->next = sed;
|
||||
hsed->ed.ed_nexted = LE(sed->physaddr);
|
||||
hsed->ed.ed_nexted = htole32(sed->physaddr);
|
||||
splx(s);
|
||||
|
||||
for (j = 0; j < nslots; j++)
|
||||
@ -2877,7 +2885,7 @@ ohci_device_isoc_enter(xfer)
|
||||
s = splusb();
|
||||
sitd = opipe->tail.itd;
|
||||
buf = DMAADDR(&xfer->dmabuf, 0);
|
||||
sitd->itd.itd_bp0 = LE(buf & OHCI_ITD_PAGE_MASK);
|
||||
sitd->itd.itd_bp0 = htole32(buf & OHCI_ITD_PAGE_MASK);
|
||||
nframes = xfer->nframes;
|
||||
offs = buf & OHCI_ITD_OFFSET_MASK;
|
||||
for (i = ncur = 0; i < nframes; i++, ncur++) {
|
||||
@ -2891,14 +2899,16 @@ ohci_device_isoc_enter(xfer)
|
||||
return;
|
||||
}
|
||||
sitd->nextitd = nsitd;
|
||||
sitd->itd.itd_nextitd = LE(nsitd->physaddr);
|
||||
sitd->itd.itd_flags = LE(
|
||||
sitd->itd.itd_nextitd = htole32(nsitd->physaddr);
|
||||
sitd->itd.itd_flags = htole32(
|
||||
OHCI_ITD_NOCC |
|
||||
OHCI_ITD_SET_SF(iso->next) |
|
||||
OHCI_ITD_NOINTR |
|
||||
OHCI_ITD_SET_FC(OHCI_ITD_NOFFSET));
|
||||
sitd->itd.itd_be = LE(LE(sitd->itd.itd_bp0) + offs - 1);
|
||||
nsitd->itd.itd_bp0 = LE((buf + offs) & OHCI_ITD_PAGE_MASK);
|
||||
sitd->itd.itd_be = htole32(
|
||||
le32toh(sitd->itd.itd_bp0) + offs - 1);
|
||||
nsitd->itd.itd_bp0 = htole32(
|
||||
(buf + offs) & OHCI_ITD_PAGE_MASK);
|
||||
sitd = nsitd;
|
||||
iso->next = iso->next + ncur;
|
||||
ncur = 0;
|
||||
@ -2917,17 +2927,17 @@ ohci_device_isoc_enter(xfer)
|
||||
return;
|
||||
}
|
||||
sitd->nextitd = nsitd;
|
||||
sitd->itd.itd_nextitd = LE(nsitd->physaddr);
|
||||
sitd->itd.itd_flags = LE(
|
||||
sitd->itd.itd_nextitd = htole32(nsitd->physaddr);
|
||||
sitd->itd.itd_flags = le32toh(
|
||||
OHCI_ITD_NOCC |
|
||||
OHCI_ITD_SET_SF(iso->next) |
|
||||
OHCI_ITD_SET_DI(0) |
|
||||
OHCI_ITD_SET_FC(ncur));
|
||||
sitd->itd.itd_be = LE(LE(sitd->itd.itd_bp0) + offs - 1);
|
||||
sitd->itd.itd_be = htole32(le32toh(sitd->itd.itd_bp0) + offs - 1);
|
||||
iso->next = iso->next + ncur;
|
||||
|
||||
opipe->tail.itd = nsitd;
|
||||
sed->ed.ed_tailp = LE(nsitd->physaddr);
|
||||
sed->ed.ed_tailp = htole32(nsitd->physaddr);
|
||||
/* XXX update ED */
|
||||
splx(s);
|
||||
}
|
||||
|
@ -104,10 +104,14 @@ int uhcidebug = 1;
|
||||
* The UHCI controller is little endian, so on big endian machines
|
||||
* the data strored in memory needs to be swapped.
|
||||
*/
|
||||
#if defined(__FreeBSD__)
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define LE(x) (bswap32(x))
|
||||
#define htole32(x) (bswap32(x))
|
||||
#define le32toh(x) (bswap32(x))
|
||||
#else
|
||||
#define LE(x) (x)
|
||||
#define htole32(x) (x)
|
||||
#define le32toh(x) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct uhci_pipe {
|
||||
@ -370,8 +374,8 @@ uhci_init(uhci_softc_t *sc)
|
||||
bsqh = uhci_alloc_sqh(sc);
|
||||
if (bsqh == NULL)
|
||||
return (USBD_NOMEM);
|
||||
bsqh->qh.qh_hlink = LE(UHCI_PTR_T); /* end of QH chain */
|
||||
bsqh->qh.qh_elink = LE(UHCI_PTR_T);
|
||||
bsqh->qh.qh_hlink = htole32(UHCI_PTR_T); /* end of QH chain */
|
||||
bsqh->qh.qh_elink = htole32(UHCI_PTR_T);
|
||||
sc->sc_bulk_start = sc->sc_bulk_end = bsqh;
|
||||
|
||||
/* Allocate the dummy QH where control traffic will be queued. */
|
||||
@ -379,8 +383,8 @@ uhci_init(uhci_softc_t *sc)
|
||||
if (csqh == NULL)
|
||||
return (USBD_NOMEM);
|
||||
csqh->hlink = bsqh;
|
||||
csqh->qh.qh_hlink = LE(bsqh->physaddr | UHCI_PTR_Q);
|
||||
csqh->qh.qh_elink = LE(UHCI_PTR_T);
|
||||
csqh->qh.qh_hlink = htole32(bsqh->physaddr | UHCI_PTR_Q);
|
||||
csqh->qh.qh_elink = htole32(UHCI_PTR_T);
|
||||
sc->sc_ctl_start = sc->sc_ctl_end = csqh;
|
||||
|
||||
/*
|
||||
@ -394,14 +398,14 @@ uhci_init(uhci_softc_t *sc)
|
||||
if (std == NULL || sqh == NULL)
|
||||
return (USBD_NOMEM);
|
||||
std->link.sqh = sqh;
|
||||
std->td.td_link = LE(sqh->physaddr | UHCI_PTR_Q);
|
||||
std->td.td_status = LE(UHCI_TD_IOS); /* iso, inactive */
|
||||
std->td.td_token = LE(0);
|
||||
std->td.td_buffer = LE(0);
|
||||
std->td.td_link = htole32(sqh->physaddr | UHCI_PTR_Q);
|
||||
std->td.td_status = htole32(UHCI_TD_IOS); /* iso, inactive */
|
||||
std->td.td_token = htole32(0);
|
||||
std->td.td_buffer = htole32(0);
|
||||
sqh->hlink = csqh;
|
||||
sqh->qh.qh_hlink = LE(csqh->physaddr | UHCI_PTR_Q);
|
||||
sqh->qh.qh_hlink = htole32(csqh->physaddr | UHCI_PTR_Q);
|
||||
sqh->elink = 0;
|
||||
sqh->qh.qh_elink = LE(UHCI_PTR_T);
|
||||
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
|
||||
sc->sc_vframes[i].htd = std;
|
||||
sc->sc_vframes[i].etd = std;
|
||||
sc->sc_vframes[i].hqh = sqh;
|
||||
@ -409,7 +413,7 @@ uhci_init(uhci_softc_t *sc)
|
||||
for (j = i;
|
||||
j < UHCI_FRAMELIST_COUNT;
|
||||
j += UHCI_VFRAMELIST_COUNT)
|
||||
sc->sc_pframes[j] = LE(std->physaddr);
|
||||
sc->sc_pframes[j] = htole32(std->physaddr);
|
||||
}
|
||||
|
||||
LIST_INIT(&sc->sc_intrhead);
|
||||
@ -632,31 +636,32 @@ uhci_dump_td(uhci_soft_td_t *p)
|
||||
DPRINTFN(-1,("TD(%p) at %08lx = link=0x%08lx status=0x%08lx "
|
||||
"token=0x%08lx buffer=0x%08lx\n",
|
||||
p, (long)p->physaddr,
|
||||
(long)LE(p->td.td_link),
|
||||
(long)LE(p->td.td_status),
|
||||
(long)LE(p->td.td_token),
|
||||
(long)LE(p->td.td_buffer)));
|
||||
(long)le32toh(p->td.td_link),
|
||||
(long)le32toh(p->td.td_status),
|
||||
(long)le32toh(p->td.td_token),
|
||||
(long)le32toh(p->td.td_buffer)));
|
||||
DPRINTFN(-1,(" %b %b,errcnt=%d,actlen=%d pid=%02x,addr=%d,endpt=%d,"
|
||||
"D=%d,maxlen=%d\n",
|
||||
(int)LE(p->td.td_link),
|
||||
(int)le32toh(p->td.td_link),
|
||||
"\20\1T\2Q\3VF",
|
||||
(int)LE(p->td.td_status),
|
||||
(int)le32toh(p->td.td_status),
|
||||
"\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27"
|
||||
"STALLED\30ACTIVE\31IOC\32ISO\33LS\36SPD",
|
||||
UHCI_TD_GET_ERRCNT(LE(p->td.td_status)),
|
||||
UHCI_TD_GET_ACTLEN(LE(p->td.td_status)),
|
||||
UHCI_TD_GET_PID(LE(p->td.td_token)),
|
||||
UHCI_TD_GET_DEVADDR(LE(p->td.td_token)),
|
||||
UHCI_TD_GET_ENDPT(LE(p->td.td_token)),
|
||||
UHCI_TD_GET_DT(LE(p->td.td_token)),
|
||||
UHCI_TD_GET_MAXLEN(LE(p->td.td_token))));
|
||||
UHCI_TD_GET_ERRCNT(le32toh(p->td.td_status)),
|
||||
UHCI_TD_GET_ACTLEN(le32toh(p->td.td_status)),
|
||||
UHCI_TD_GET_PID(le32toh(p->td.td_token)),
|
||||
UHCI_TD_GET_DEVADDR(le32toh(p->td.td_token)),
|
||||
UHCI_TD_GET_ENDPT(le32toh(p->td.td_token)),
|
||||
UHCI_TD_GET_DT(le32toh(p->td.td_token)),
|
||||
UHCI_TD_GET_MAXLEN(le32toh(p->td.td_token))));
|
||||
}
|
||||
|
||||
void
|
||||
uhci_dump_qh(uhci_soft_qh_t *sqh)
|
||||
{
|
||||
DPRINTFN(-1,("QH(%p) at %08x: hlink=%08x elink=%08x\n", sqh,
|
||||
(int)sqh->physaddr, LE(sqh->qh.qh_hlink), LE(sqh->qh.qh_elink)));
|
||||
(int)sqh->physaddr, le32toh(sqh->qh.qh_hlink),
|
||||
le32toh(sqh->qh.qh_elink)));
|
||||
}
|
||||
|
||||
|
||||
@ -694,12 +699,12 @@ uhci_dump_qhs(uhci_soft_qh_t *sqh)
|
||||
*/
|
||||
|
||||
|
||||
if (sqh->hlink != NULL && !(sqh->qh.qh_hlink & UHCI_PTR_T))
|
||||
if (sqh->hlink != NULL && !(le32toh(sqh->qh.qh_hlink) & UHCI_PTR_T))
|
||||
uhci_dump_qhs(sqh->hlink);
|
||||
else
|
||||
DPRINTF(("No QH\n"));
|
||||
|
||||
if (sqh->elink != NULL && !(sqh->qh.qh_elink & UHCI_PTR_T))
|
||||
if (sqh->elink != NULL && !(le32toh(sqh->qh.qh_elink) & UHCI_PTR_T))
|
||||
uhci_dump_tds(sqh->elink);
|
||||
else
|
||||
DPRINTF(("No TD\n"));
|
||||
@ -718,8 +723,8 @@ uhci_dump_tds(uhci_soft_td_t *std)
|
||||
* printing the free list in case the queue/TD has
|
||||
* already been moved there (seatbelt).
|
||||
*/
|
||||
if (td->td.td_link & UHCI_PTR_T ||
|
||||
td->td.td_link == 0)
|
||||
if (le32toh(td->td.td_link) & UHCI_PTR_T ||
|
||||
le32toh(td->td.td_link) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -833,7 +838,7 @@ uhci_add_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
|
||||
sqh->hlink = eqh->hlink;
|
||||
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
|
||||
eqh->hlink = sqh;
|
||||
eqh->qh.qh_hlink = LE(sqh->physaddr | UHCI_PTR_Q);
|
||||
eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
|
||||
sc->sc_ctl_end = sqh;
|
||||
}
|
||||
|
||||
@ -848,7 +853,7 @@ uhci_remove_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
|
||||
DPRINTFN(10, ("uhci_remove_ctrl: sqh=%p\n", sqh));
|
||||
for (pqh = sc->sc_ctl_start; pqh->hlink != sqh; pqh=pqh->hlink)
|
||||
#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
|
||||
if (LE(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
if (le32toh(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
printf("uhci_remove_ctrl: QH not found\n");
|
||||
return;
|
||||
}
|
||||
@ -874,7 +879,7 @@ uhci_add_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
|
||||
sqh->hlink = eqh->hlink;
|
||||
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
|
||||
eqh->hlink = sqh;
|
||||
eqh->qh.qh_hlink = LE(sqh->physaddr | UHCI_PTR_Q);
|
||||
eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
|
||||
sc->sc_bulk_end = sqh;
|
||||
}
|
||||
|
||||
@ -889,7 +894,7 @@ uhci_remove_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
|
||||
DPRINTFN(10, ("uhci_remove_bulk: sqh=%p\n", sqh));
|
||||
for (pqh = sc->sc_bulk_start; pqh->hlink != sqh; pqh = pqh->hlink)
|
||||
#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
|
||||
if (LE(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
if (le32toh(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
printf("uhci_remove_bulk: QH not found\n");
|
||||
return;
|
||||
}
|
||||
@ -1026,10 +1031,10 @@ uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii)
|
||||
* is a an error somewhere in the middle, or whether there was a
|
||||
* short packet (SPD and not ACTIVE).
|
||||
*/
|
||||
if (LE(lstd->td.td_status) & UHCI_TD_ACTIVE) {
|
||||
if (le32toh(lstd->td.td_status) & UHCI_TD_ACTIVE) {
|
||||
DPRINTFN(15, ("uhci_check_intr: active ii=%p\n", ii));
|
||||
for (std = ii->stdstart; std != lstd; std = std->link.std) {
|
||||
status = LE(std->td.td_status);
|
||||
status = le32toh(std->td.td_status);
|
||||
/* If there's an active TD the xfer isn't done. */
|
||||
if (status & UHCI_TD_ACTIVE)
|
||||
break;
|
||||
@ -1042,7 +1047,7 @@ uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii)
|
||||
*/
|
||||
if ((status & UHCI_TD_SPD) &&
|
||||
UHCI_TD_GET_ACTLEN(status) <
|
||||
UHCI_TD_GET_MAXLEN(LE(std->td.td_token)))
|
||||
UHCI_TD_GET_MAXLEN(le32toh(std->td.td_token)))
|
||||
goto done;
|
||||
}
|
||||
DPRINTFN(15, ("uhci_check_intr: ii=%p std=%p still active\n",
|
||||
@ -1104,7 +1109,7 @@ uhci_idone(uhci_intr_info_t *ii)
|
||||
#endif
|
||||
if (++n >= UHCI_VFRAMELIST_COUNT)
|
||||
n = 0;
|
||||
status = LE(std->td.td_status);
|
||||
status = le32toh(std->td.td_status);
|
||||
actlen += UHCI_TD_GET_ACTLEN(status);
|
||||
}
|
||||
upipe->u.iso.inuse -= nframes;
|
||||
@ -1125,17 +1130,18 @@ uhci_idone(uhci_intr_info_t *ii)
|
||||
/* The transfer is done, compute actual length and status. */
|
||||
actlen = 0;
|
||||
for (std = ii->stdstart; std != NULL; std = std->link.std) {
|
||||
nstatus = LE(std->td.td_status);
|
||||
nstatus = le32toh(std->td.td_status);
|
||||
if (nstatus & UHCI_TD_ACTIVE)
|
||||
break;
|
||||
|
||||
status = nstatus;
|
||||
if (UHCI_TD_GET_PID(LE(std->td.td_token)) != UHCI_TD_PID_SETUP)
|
||||
if (UHCI_TD_GET_PID(le32toh(std->td.td_token)) !=
|
||||
UHCI_TD_PID_SETUP)
|
||||
actlen += UHCI_TD_GET_ACTLEN(status);
|
||||
}
|
||||
/* If there are left over TDs we need to update the toggle. */
|
||||
if (std != NULL)
|
||||
upipe->nexttoggle = UHCI_TD_GET_DT(LE(std->td.td_token));
|
||||
upipe->nexttoggle = UHCI_TD_GET_DT(le32toh(std->td.td_token));
|
||||
|
||||
status &= UHCI_TD_ERROR;
|
||||
DPRINTFN(10, ("uhci_check_intr: actlen=%d, status=0x%x\n",
|
||||
@ -1321,11 +1327,11 @@ uhci_free_std(uhci_softc_t *sc, uhci_soft_td_t *std)
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
#define TD_IS_FREE 0x12345678
|
||||
if (std->td.td_token == LE(TD_IS_FREE)) {
|
||||
if (le32toh(std->td.td_token) == TD_IS_FREE) {
|
||||
printf("uhci_free_std: freeing free TD %p\n", std);
|
||||
return;
|
||||
}
|
||||
std->td.td_token = LE(TD_IS_FREE);
|
||||
std->td.td_token = htole32(TD_IS_FREE);
|
||||
#endif
|
||||
std->link.std = sc->sc_freetds;
|
||||
sc->sc_freetds = std;
|
||||
@ -1440,12 +1446,12 @@ uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc,
|
||||
}
|
||||
p->link.std = lastp;
|
||||
if (lastlink == UHCI_PTR_T)
|
||||
p->td.td_link = LE(lastlink);
|
||||
p->td.td_link = htole32(lastlink);
|
||||
else
|
||||
p->td.td_link = LE(lastlink|UHCI_PTR_VF);
|
||||
p->td.td_link = htole32(lastlink|UHCI_PTR_VF);
|
||||
lastp = p;
|
||||
lastlink = p->physaddr;
|
||||
p->td.td_status = LE(status);
|
||||
p->td.td_status = htole32(status);
|
||||
if (i == ntd) {
|
||||
/* last TD */
|
||||
l = len % maxp;
|
||||
@ -1455,9 +1461,9 @@ uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc,
|
||||
} else
|
||||
l = maxp;
|
||||
p->td.td_token =
|
||||
LE(rd ? UHCI_TD_IN (l, endpt, addr, tog) :
|
||||
htole32(rd ? UHCI_TD_IN (l, endpt, addr, tog) :
|
||||
UHCI_TD_OUT(l, endpt, addr, tog));
|
||||
p->td.td_buffer = LE(DMAADDR(dma, i * maxp));
|
||||
p->td.td_buffer = htole32(DMAADDR(dma, i * maxp));
|
||||
tog ^= 1;
|
||||
}
|
||||
*sp = lastp;
|
||||
@ -1527,7 +1533,7 @@ uhci_device_bulk_start(usbd_xfer_handle xfer)
|
||||
&xfer->dmabuf, &data, &dataend);
|
||||
if (err)
|
||||
return (err);
|
||||
dataend->td.td_status |= LE(UHCI_TD_IOC);
|
||||
dataend->td.td_status |= htole32(UHCI_TD_IOC);
|
||||
|
||||
#ifdef UHCI_DEBUG
|
||||
if (uhcidebug > 8) {
|
||||
@ -1551,7 +1557,7 @@ uhci_device_bulk_start(usbd_xfer_handle xfer)
|
||||
#endif
|
||||
|
||||
sqh->elink = data;
|
||||
sqh->qh.qh_elink = LE(data->physaddr);
|
||||
sqh->qh.qh_elink = htole32(data->physaddr);
|
||||
sqh->intr_info = ii;
|
||||
|
||||
s = splusb();
|
||||
@ -1602,7 +1608,7 @@ uhci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
|
||||
|
||||
/* make hardware ignore it, */
|
||||
for (std = ii->stdstart; std != 0; std = std->link.std)
|
||||
std->td.td_status &= LE(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
|
||||
std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
|
||||
|
||||
xfer->hcpriv = ii;
|
||||
|
||||
@ -1726,7 +1732,7 @@ uhci_device_intr_start(usbd_xfer_handle xfer)
|
||||
&xfer->dmabuf, &data, &dataend);
|
||||
if (err)
|
||||
return (err);
|
||||
dataend->td.td_status |= LE(UHCI_TD_IOC);
|
||||
dataend->td.td_status |= htole32(UHCI_TD_IOC);
|
||||
|
||||
#ifdef UHCI_DEBUG
|
||||
if (uhcidebug > 10) {
|
||||
@ -1756,7 +1762,7 @@ uhci_device_intr_start(usbd_xfer_handle xfer)
|
||||
for (i = 0; i < upipe->u.intr.npoll; i++) {
|
||||
sqh = upipe->u.intr.qhs[i];
|
||||
sqh->elink = data;
|
||||
sqh->qh.qh_elink = LE(data->physaddr);
|
||||
sqh->qh.qh_elink = htole32(data->physaddr);
|
||||
}
|
||||
splx(s);
|
||||
|
||||
@ -1878,7 +1884,7 @@ uhci_device_request(usbd_xfer_handle xfer)
|
||||
return (err);
|
||||
next = data;
|
||||
dataend->link.std = stat;
|
||||
dataend->td.td_link = LE(stat->physaddr | UHCI_PTR_VF);
|
||||
dataend->td.td_link = htole32(stat->physaddr | UHCI_PTR_VF);
|
||||
} else {
|
||||
next = stat;
|
||||
}
|
||||
@ -1887,19 +1893,20 @@ uhci_device_request(usbd_xfer_handle xfer)
|
||||
memcpy(KERNADDR(&upipe->u.ctl.reqdma, 0), req, sizeof *req);
|
||||
|
||||
setup->link.std = next;
|
||||
setup->td.td_link = LE(next->physaddr | UHCI_PTR_VF);
|
||||
setup->td.td_status = LE(UHCI_TD_SET_ERRCNT(3) | ls | UHCI_TD_ACTIVE);
|
||||
setup->td.td_token = LE(UHCI_TD_SETUP(sizeof *req, endpt, addr));
|
||||
setup->td.td_buffer = LE(DMAADDR(&upipe->u.ctl.reqdma, 0));
|
||||
setup->td.td_link = htole32(next->physaddr | UHCI_PTR_VF);
|
||||
setup->td.td_status = htole32(UHCI_TD_SET_ERRCNT(3) | ls |
|
||||
UHCI_TD_ACTIVE);
|
||||
setup->td.td_token = htole32(UHCI_TD_SETUP(sizeof *req, endpt, addr));
|
||||
setup->td.td_buffer = htole32(DMAADDR(&upipe->u.ctl.reqdma, 0));
|
||||
|
||||
stat->link.std = 0;
|
||||
stat->td.td_link = LE(UHCI_PTR_T);
|
||||
stat->td.td_status = LE(UHCI_TD_SET_ERRCNT(3) | ls |
|
||||
stat->td.td_link = htole32(UHCI_PTR_T);
|
||||
stat->td.td_status = htole32(UHCI_TD_SET_ERRCNT(3) | ls |
|
||||
UHCI_TD_ACTIVE | UHCI_TD_IOC);
|
||||
stat->td.td_token =
|
||||
LE(isread ? UHCI_TD_OUT(0, endpt, addr, 1) :
|
||||
htole32(isread ? UHCI_TD_OUT(0, endpt, addr, 1) :
|
||||
UHCI_TD_IN (0, endpt, addr, 1));
|
||||
stat->td.td_buffer = LE(0);
|
||||
stat->td.td_buffer = htole32(0);
|
||||
|
||||
#ifdef UHCI_DEBUG
|
||||
if (uhcidebug > 10) {
|
||||
@ -1923,7 +1930,7 @@ uhci_device_request(usbd_xfer_handle xfer)
|
||||
#endif
|
||||
|
||||
sqh->elink = setup;
|
||||
sqh->qh.qh_elink = LE(setup->physaddr);
|
||||
sqh->qh.qh_elink = htole32(setup->physaddr);
|
||||
sqh->intr_info = ii;
|
||||
|
||||
s = splusb();
|
||||
@ -1940,7 +1947,7 @@ uhci_device_request(usbd_xfer_handle xfer)
|
||||
for (std = sc->sc_vframes[0].htd, link = 0;
|
||||
(link & UHCI_PTR_Q) == 0;
|
||||
std = std->link.std) {
|
||||
link = LE(std->td.td_link);
|
||||
link = le32toh(std->td.td_link);
|
||||
uhci_dump_td(std);
|
||||
}
|
||||
sxqh = (uhci_soft_qh_t *)std;
|
||||
@ -2027,9 +2034,9 @@ uhci_device_isoc_enter(usbd_xfer_handle xfer)
|
||||
xfer->hcprivint = next;
|
||||
|
||||
buf = DMAADDR(&xfer->dmabuf, 0);
|
||||
status = LE(UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(0) |
|
||||
UHCI_TD_ACTIVE |
|
||||
UHCI_TD_IOS));
|
||||
status = UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(0) |
|
||||
UHCI_TD_ACTIVE |
|
||||
UHCI_TD_IOS);
|
||||
nframes = xfer->nframes;
|
||||
s = splusb();
|
||||
for (i = 0; i < nframes; i++) {
|
||||
@ -2037,12 +2044,12 @@ uhci_device_isoc_enter(usbd_xfer_handle xfer)
|
||||
if (++next >= UHCI_VFRAMELIST_COUNT)
|
||||
next = 0;
|
||||
len = xfer->frlengths[i];
|
||||
std->td.td_buffer = LE(buf);
|
||||
std->td.td_buffer = htole32(buf);
|
||||
if (i == nframes - 1)
|
||||
status |= LE(UHCI_TD_IOC);
|
||||
std->td.td_status = status;
|
||||
std->td.td_token &= LE(~UHCI_TD_MAXLEN_MASK);
|
||||
std->td.td_token |= LE(UHCI_TD_SET_MAXLEN(len));
|
||||
status |= UHCI_TD_IOC;
|
||||
std->td.td_status = htole32(status);
|
||||
std->td.td_token &= htole32(~UHCI_TD_MAXLEN_MASK);
|
||||
std->td.td_token |= htole32(UHCI_TD_SET_MAXLEN(len));
|
||||
#ifdef UHCI_DEBUG
|
||||
if (uhcidebug > 5) {
|
||||
DPRINTFN(5,("uhci_device_isoc_enter: TD %d\n", i));
|
||||
@ -2116,7 +2123,7 @@ uhci_device_isoc_abort(usbd_xfer_handle xfer)
|
||||
n = xfer->hcprivint;
|
||||
for (i = 0; i < nframes; i++) {
|
||||
std = stds[n];
|
||||
std->td.td_status &= LE(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
|
||||
std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
|
||||
if (++n >= UHCI_VFRAMELIST_COUNT)
|
||||
n = 0;
|
||||
}
|
||||
@ -2153,7 +2160,7 @@ uhci_device_isoc_close(usbd_pipe_handle pipe)
|
||||
iso = &upipe->u.iso;
|
||||
|
||||
for (i = 0; i < UHCI_VFRAMELIST_COUNT; i++)
|
||||
iso->stds[i]->td.td_status &= LE(~UHCI_TD_ACTIVE);
|
||||
iso->stds[i]->td.td_status &= htole32(~UHCI_TD_ACTIVE);
|
||||
usb_delay_ms(&sc->sc_bus, 2); /* wait for completion */
|
||||
|
||||
uhci_lock_frames(sc);
|
||||
@ -2196,16 +2203,16 @@ uhci_setup_isoc(usbd_pipe_handle pipe)
|
||||
iso->stds = malloc(UHCI_VFRAMELIST_COUNT * sizeof (uhci_soft_td_t *),
|
||||
M_USBHC, M_WAITOK);
|
||||
|
||||
token = LE(rd ? UHCI_TD_IN (0, endpt, addr, 0) :
|
||||
UHCI_TD_OUT(0, endpt, addr, 0));
|
||||
token = rd ? UHCI_TD_IN (0, endpt, addr, 0) :
|
||||
UHCI_TD_OUT(0, endpt, addr, 0);
|
||||
|
||||
/* Allocate the TDs and mark as inactive; */
|
||||
for (i = 0; i < UHCI_VFRAMELIST_COUNT; i++) {
|
||||
std = uhci_alloc_std(sc);
|
||||
if (std == 0)
|
||||
goto bad;
|
||||
std->td.td_status = LE(UHCI_TD_IOS); /* iso, inactive */
|
||||
std->td.td_token = token;
|
||||
std->td.td_status = htole32(UHCI_TD_IOS); /* iso, inactive */
|
||||
std->td.td_token = htole32(token);
|
||||
iso->stds[i] = std;
|
||||
}
|
||||
|
||||
@ -2217,7 +2224,7 @@ uhci_setup_isoc(usbd_pipe_handle pipe)
|
||||
std->link = vstd->link;
|
||||
std->td.td_link = vstd->td.td_link;
|
||||
vstd->link.std = std;
|
||||
vstd->td.td_link = LE(std->physaddr);
|
||||
vstd->td.td_link = htole32(std->physaddr);
|
||||
}
|
||||
uhci_unlock_frames(sc);
|
||||
|
||||
@ -2241,7 +2248,7 @@ uhci_device_isoc_done(usbd_xfer_handle xfer)
|
||||
DPRINTFN(4, ("uhci_isoc_done: length=%d\n", xfer->actlen));
|
||||
|
||||
/* Turn off the interrupt since it is active even if the TD is not. */
|
||||
ii->stdend->td.td_status &= LE(~UHCI_TD_IOC);
|
||||
ii->stdend->td.td_status &= htole32(~UHCI_TD_IOC);
|
||||
|
||||
LIST_REMOVE(ii, list); /* remove from active list */
|
||||
}
|
||||
@ -2261,7 +2268,7 @@ uhci_device_intr_done(usbd_xfer_handle xfer)
|
||||
for(i = 0; i < npoll; i++) {
|
||||
sqh = upipe->u.intr.qhs[i];
|
||||
sqh->elink = 0;
|
||||
sqh->qh.qh_elink = LE(UHCI_PTR_T);
|
||||
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
|
||||
}
|
||||
uhci_free_std_chain(sc, ii->stdstart, 0);
|
||||
|
||||
@ -2272,7 +2279,7 @@ uhci_device_intr_done(usbd_xfer_handle xfer)
|
||||
/* This alloc cannot fail since we freed the chain above. */
|
||||
uhci_alloc_std_chain(upipe, sc, xfer->length, 1, xfer->flags,
|
||||
&xfer->dmabuf, &data, &dataend);
|
||||
dataend->td.td_status |= LE(UHCI_TD_IOC);
|
||||
dataend->td.td_status |= htole32(UHCI_TD_IOC);
|
||||
|
||||
#ifdef UHCI_DEBUG
|
||||
if (uhcidebug > 10) {
|
||||
@ -2296,7 +2303,7 @@ uhci_device_intr_done(usbd_xfer_handle xfer)
|
||||
for (i = 0; i < npoll; i++) {
|
||||
sqh = upipe->u.intr.qhs[i];
|
||||
sqh->elink = data;
|
||||
sqh->qh.qh_elink = LE(data->physaddr);
|
||||
sqh->qh.qh_elink = htole32(data->physaddr);
|
||||
}
|
||||
} else {
|
||||
ii->stdstart = 0; /* mark as inactive */
|
||||
@ -2355,7 +2362,7 @@ uhci_add_intr(uhci_softc_t *sc, int n, uhci_soft_qh_t *sqh)
|
||||
sqh->hlink = eqh->hlink;
|
||||
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
|
||||
eqh->hlink = sqh;
|
||||
eqh->qh.qh_hlink = LE(sqh->physaddr | UHCI_PTR_Q);
|
||||
eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
|
||||
vf->eqh = sqh;
|
||||
vf->bandwidth++;
|
||||
}
|
||||
@ -2371,7 +2378,7 @@ uhci_remove_intr(uhci_softc_t *sc, int n, uhci_soft_qh_t *sqh)
|
||||
|
||||
for (pqh = vf->hqh; pqh->hlink != sqh; pqh = pqh->hlink)
|
||||
#if defined(DIAGNOSTIC) || defined(UHCI_DEBUG)
|
||||
if (LE(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
if (le32toh(pqh->qh.qh_hlink) & UHCI_PTR_T) {
|
||||
DPRINTF(("uhci_remove_intr: QH not found\n"));
|
||||
return;
|
||||
}
|
||||
@ -2426,7 +2433,7 @@ uhci_device_setintr(uhci_softc_t *sc, struct uhci_pipe *upipe, int ival)
|
||||
for(i = 0; i < npoll; i++) {
|
||||
upipe->u.intr.qhs[i] = sqh = uhci_alloc_sqh(sc);
|
||||
sqh->elink = 0;
|
||||
sqh->qh.qh_elink = LE(UHCI_PTR_T);
|
||||
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
|
||||
sqh->pos = MOD(i * ival + bestoffs);
|
||||
sqh->intr_info = upipe->iinfo;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user