From a353e14e75d7c7e0a2735c27c64dac45a6fd2564 Mon Sep 17 00:00:00 2001 From: Josef Karthauser Date: Sun, 20 Jan 2002 12:08:09 +0000 Subject: [PATCH] Merge from NetBSD: uchireg.h: -r1.12 uchi.c: -r1.121 date: 2000/07/23 19:43:38; author: augustss; state: Exp; Be a little more explicit and careful about setting links in TDs and QHs. --- sys/dev/usb/uhci.c | 36 ++++++++++++++++++------------------ sys/dev/usb/uhcireg.h | 9 +++++---- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 51c2fa7465f5..fcee10578e24 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -385,7 +385,9 @@ uhci_init(uhci_softc_t *sc) bsqh = uhci_alloc_sqh(sc); if (bsqh == NULL) return (USBD_NOMEM); + bsqh->hlink = NULL; bsqh->qh.qh_hlink = htole32(UHCI_PTR_T); /* end of QH chain */ + bsqh->elink = NULL; bsqh->qh.qh_elink = htole32(UHCI_PTR_T); sc->sc_bulk_start = sc->sc_bulk_end = bsqh; @@ -394,7 +396,8 @@ uhci_init(uhci_softc_t *sc) if (csqh == NULL) return (USBD_NOMEM); csqh->hlink = bsqh; - csqh->qh.qh_hlink = htole32(bsqh->physaddr | UHCI_PTR_Q); + csqh->qh.qh_hlink = htole32(bsqh->physaddr | UHCI_PTR_QH); + csqh->elink = NULL; csqh->qh.qh_elink = htole32(UHCI_PTR_T); sc->sc_ctl_start = sc->sc_ctl_end = csqh; @@ -409,12 +412,12 @@ uhci_init(uhci_softc_t *sc) if (std == NULL || sqh == NULL) return (USBD_NOMEM); std->link.sqh = sqh; - std->td.td_link = htole32(sqh->physaddr | UHCI_PTR_Q); + std->td.td_link = htole32(sqh->physaddr | UHCI_PTR_QH); 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 = htole32(csqh->physaddr | UHCI_PTR_Q); + sqh->qh.qh_hlink = htole32(csqh->physaddr | UHCI_PTR_QH); sqh->elink = NULL; sqh->qh.qh_elink = htole32(UHCI_PTR_T); sc->sc_vframes[i].htd = std; @@ -854,7 +857,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 = htole32(sqh->physaddr | UHCI_PTR_Q); + eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); sc->sc_ctl_end = sqh; } @@ -895,7 +898,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 = htole32(sqh->physaddr | UHCI_PTR_Q); + eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); sc->sc_bulk_end = sqh; } @@ -1473,10 +1476,7 @@ uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc, int len, return (USBD_NOMEM); } p->link.std = lastp; - if (lastlink == UHCI_PTR_T) - p->td.td_link = htole32(lastlink); - else - p->td.td_link = htole32(lastlink|UHCI_PTR_VF); + p->td.td_link = htole32(lastlink | UHCI_PTR_VF | UHCI_PTR_TD); lastp = p; lastlink = p->physaddr; p->td.td_status = htole32(status); @@ -1586,7 +1586,7 @@ uhci_device_bulk_start(usbd_xfer_handle xfer) #endif sqh->elink = data; - sqh->qh.qh_elink = htole32(data->physaddr); + sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD); sqh->intr_info = ii; s = splusb(); @@ -1792,7 +1792,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 = htole32(data->physaddr); + sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD); } splx(s); @@ -1914,7 +1914,7 @@ uhci_device_request(usbd_xfer_handle xfer) return (err); next = data; dataend->link.std = stat; - dataend->td.td_link = htole32(stat->physaddr | UHCI_PTR_VF); + dataend->td.td_link = htole32(stat->physaddr | UHCI_PTR_VF | UHCI_PTR_TD); } else { next = stat; } @@ -1923,7 +1923,7 @@ 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 = htole32(next->physaddr | UHCI_PTR_VF); + setup->td.td_link = htole32(next->physaddr | UHCI_PTR_VF | UHCI_PTR_TD); 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)); @@ -1960,7 +1960,7 @@ uhci_device_request(usbd_xfer_handle xfer) #endif sqh->elink = setup; - sqh->qh.qh_elink = htole32(setup->physaddr); + sqh->qh.qh_elink = htole32(setup->physaddr | UHCI_PTR_TD); sqh->intr_info = ii; s = splusb(); @@ -1975,7 +1975,7 @@ uhci_device_request(usbd_xfer_handle xfer) uhci_physaddr_t link; DPRINTF(("uhci_enter_ctl_q: follow from [0]\n")); for (std = sc->sc_vframes[0].htd, link = 0; - (link & UHCI_PTR_Q) == 0; + (link & UHCI_PTR_QH) == 0; std = std->link.std) { link = le32toh(std->td.td_link); uhci_dump_td(std); @@ -2263,7 +2263,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 = htole32(std->physaddr); + vstd->td.td_link = htole32(std->physaddr | UHCI_PTR_TD); } uhci_unlock_frames(sc); @@ -2355,7 +2355,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 = htole32(data->physaddr); + sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD); } } else { ii->stdstart = 0; /* mark as inactive */ @@ -2415,7 +2415,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 = htole32(sqh->physaddr | UHCI_PTR_Q); + eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH); vf->eqh = sqh; vf->bandwidth++; } diff --git a/sys/dev/usb/uhcireg.h b/sys/dev/usb/uhcireg.h index 57556168028e..ab3c9e75afbd 100644 --- a/sys/dev/usb/uhcireg.h +++ b/sys/dev/usb/uhcireg.h @@ -1,4 +1,4 @@ -/* $NetBSD: uhcireg.h,v 1.9 1999/11/20 00:57:09 augustss Exp $ */ +/* $NetBSD: usb/uhcireg.h,v 1.12 2000/07/23 19:43:38 augustss Exp $ */ /* $FreeBSD$ */ /* @@ -117,12 +117,13 @@ typedef u_int32_t uhci_physaddr_t; #define UHCI_PTR_T 0x00000001 -#define UHCI_PTR_Q 0x00000002 +#define UHCI_PTR_TD 0x00000000 +#define UHCI_PTR_QH 0x00000002 #define UHCI_PTR_VF 0x00000004 /* - * The Queue Heads and Transfer Descriptors and accessed - * by both the CPU and the USB controller which runs + * The Queue Heads and Transfer Descriptors are accessed + * by both the CPU and the USB controller which run * concurrently. This means that they have to be accessed * with great care. As long as the data structures are * not linked into the controller's frame list they cannot