Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Replace LE() macro with le32toh()/le32toh().
details: https://anonhg.NetBSD.org/src/rev/f076b4ab0736
branches: trunk
changeset: 483705:f076b4ab0736
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Mar 16 12:40:51 2000 +0000
description:
Replace LE() macro with le32toh()/le32toh().
diffstat:
sys/dev/usb/ohci.c | 221 +++++++++++++++++++++++++++-------------------------
sys/dev/usb/uhci.c | 189 +++++++++++++++++++++++---------------------
2 files changed, 214 insertions(+), 196 deletions(-)
diffs (truncated from 1122 to 300 lines):
diff -r 548de162f3fa -r f076b4ab0736 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Thu Mar 16 10:37:00 2000 +0000
+++ b/sys/dev/usb/ohci.c Thu Mar 16 12:40:51 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.75 2000/03/16 00:41:50 augustss Exp $ */
+/* $NetBSD: ohci.c,v 1.76 2000/03/16 12:40:51 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
/*
@@ -101,10 +101,14 @@
* 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;
@@ -510,11 +514,11 @@
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",
@@ -529,17 +533,17 @@
alen % UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize) == 0) {
/* Force a 0 length transfer at the end. */
- cur->td.td_flags = LE(tdflags | OHCI_TD_NOINTR);
+ cur->td.td_flags = htole32(tdflags | OHCI_TD_NOINTR);
cur = next;
next = ohci_alloc_std(sc);
if (next == NULL)
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_nexttd = htole32(next->physaddr);
cur->td.td_be = ~0;
cur->len = 0;
cur->flags = 0;
@@ -659,7 +663,7 @@
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);
@@ -667,7 +671,7 @@
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);
@@ -675,7 +679,7 @@
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++) {
@@ -688,13 +692,13 @@
}
/* 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
@@ -702,7 +706,7 @@
*/
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);
#ifdef OHCI_DEBUG
if (ohcidebug > 15) {
@@ -965,8 +969,8 @@
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
@@ -1005,7 +1009,7 @@
}
intrs = 0;
- done = LE(sc->sc_hcca->hcca_done_head);
+ done = le32toh(sc->sc_hcca->hcca_done_head);
if (done != 0) {
if (done & ~OHCI_DONE_INTRS)
intrs = OHCI_WDH;
@@ -1044,9 +1048,9 @@
ohci_soft_td_t *std;
for (ldone = sc->sc_done; ldone != 0;
- ldone = LE(std->td.td_nexttd))
+ ldone = le32toh(std->td.td_nexttd))
std = ohci_hash_find_td(sc, ldone);
- std->td.td_nexttd = LE(done);
+ std->td.td_nexttd = htole32(done);
}
sc->sc_hcca->hcca_done_head = 0;
usb_schedsoftintr(&sc->sc_bus);
@@ -1138,7 +1142,7 @@
DPRINTFN(10,("ohci_process_done: done=0x%08lx\n", (u_long)done));
/* Reverse the done list. */
- for (sdone = NULL; done != 0; done = LE(std->td.td_nexttd)) {
+ for (sdone = NULL; done != 0; done = le32toh(std->td.td_nexttd)) {
std = ohci_hash_find_td(sc, done);
std->dnext = sdone;
sdone = std;
@@ -1163,7 +1167,7 @@
*/
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) {
@@ -1173,8 +1177,8 @@
} else if (cc == OHCI_CC_NO_ERROR) {
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;
DPRINTFN(10, ("ohci_process_done: len=%d, flags=0x%x\n",
len, std->flags));
if (std->flags & OHCI_ADD_LEN)
@@ -1195,8 +1199,8 @@
(struct ohci_pipe *)xfer->pipe;
DPRINTFN(15,("ohci_process_done: error cc=%d (%s)\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))]));
/* remove TDs */
for (p = std; p->xfer == xfer; p = n) {
@@ -1205,7 +1209,7 @@
}
/* clear halt */
- opipe->sed->ed.ed_headp = LE(p->physaddr);
+ opipe->sed->ed.ed_headp = htole32(p->physaddr);
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
if (cc == OHCI_CC_STALL)
@@ -1257,22 +1261,23 @@
}
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));
+ data->td.td_flags |= htole32(OHCI_TD_R);
+ data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf));
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(le32toh(data->td.td_cbp) +
+ xfer->length - 1);
data->len = xfer->length;
data->xfer = xfer;
data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
xfer->hcpriv = data;
xfer->actlen = 0;
- sed->ed.ed_tailp = LE(tail->physaddr);
+ sed->ed.ed_tailp = htole32(tail->physaddr);
opipe->tail.td = tail;
}
}
@@ -1428,8 +1433,8 @@
/* 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)));
@@ -1440,14 +1445,14 @@
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));
+ data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf));
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;
@@ -1462,23 +1467,23 @@
memcpy(KERNADDR(&opipe->u.ctl.reqdma), req, sizeof *req);
- setup->td.td_flags = LE(OHCI_TD_SETUP | OHCI_TD_NOCC |
- OHCI_TD_TOGGLE_0 | OHCI_TD_NOINTR);
- setup->td.td_cbp = LE(DMAADDR(&opipe->u.ctl.reqdma));
+ setup->td.td_flags = htole32(OHCI_TD_SETUP | OHCI_TD_NOCC |
+ OHCI_TD_TOGGLE_0 | OHCI_TD_NOINTR);
+ setup->td.td_cbp = htole32(DMAADDR(&opipe->u.ctl.reqdma));
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;
@@ -1493,7 +1498,7 @@
/* 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) {
@@ -1534,7 +1539,7 @@
sed->next = head->next;
sed->ed.ed_nexted = head->ed.ed_nexted;
head->next = sed;
Home |
Main Index |
Thread Index |
Old Index