Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb * Move DMA buffer allocation to HC independent c...
details: https://anonhg.NetBSD.org/src/rev/d6815a68ad62
branches: trunk
changeset: 476266:d6815a68ad62
user: augustss <augustss%NetBSD.org@localhost>
date: Sat Sep 11 08:19:26 1999 +0000
description:
* Move DMA buffer allocation to HC independent code.
* Remove (almost) unused definitions USBD_XFER_OUT and USBD_XFER_IN.
diffstat:
sys/dev/usb/TODO | 4 +-
sys/dev/usb/ohci.c | 162 ++++++++++++------------------------------------
sys/dev/usb/uhci.c | 159 +++++++++--------------------------------------
sys/dev/usb/umodem.c | 8 +-
sys/dev/usb/usb.h | 5 +-
sys/dev/usb/usb_mem.c | 9 +-
sys/dev/usb/usb_port.h | 23 ++++++-
sys/dev/usb/usbdi.c | 116 ++++++++++++++++++++++++++++------
sys/dev/usb/usbdi.h | 8 +-
sys/dev/usb/usbdivar.h | 18 +---
10 files changed, 206 insertions(+), 306 deletions(-)
diffs (truncated from 1366 to 300 lines):
diff -r 071466cefb12 -r d6815a68ad62 sys/dev/usb/TODO
--- a/sys/dev/usb/TODO Sat Sep 11 06:27:36 1999 +0000
+++ b/sys/dev/usb/TODO Sat Sep 11 08:19:26 1999 +0000
@@ -14,8 +14,6 @@
Make hub driver notice transition between self and bus powered state.
Handle overcurrent conditions.
-Move memory allocation and copying to HC independent code.
-
Use a TD chain in ohci.c to allow transfers > 8K.
Add an event mechanism to find out about attach and detach.
@@ -40,6 +38,8 @@
implement input
test with more devices
+Preallocate buffer in ulpt.
+
Document device driver API.
Document HC driver API.
diff -r 071466cefb12 -r d6815a68ad62 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Sat Sep 11 06:27:36 1999 +0000
+++ b/sys/dev/usb/ohci.c Sat Sep 11 08:19:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.42 1999/09/09 12:26:44 augustss Exp $ */
+/* $NetBSD: ohci.c,v 1.43 1999/09/11 08:19:26 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -147,6 +147,12 @@
void ohci_device_intr_close __P((usbd_pipe_handle));
void ohci_device_intr_done __P((usbd_request_handle));
+usbd_status ohci_device_isoc_transfer __P((usbd_request_handle));
+usbd_status ohci_device_isoc_start __P((usbd_request_handle));
+void ohci_device_isoc_abort __P((usbd_request_handle));
+void ohci_device_isoc_close __P((usbd_pipe_handle));
+void ohci_device_isoc_done __P((usbd_request_handle));
+
usbd_status ohci_device_setintr __P((ohci_softc_t *sc,
struct ohci_pipe *pipe, int ival));
@@ -191,23 +197,24 @@
union {
/* Control pipe */
struct {
- usb_dma_t datadma;
usb_dma_t reqdma;
u_int length;
ohci_soft_td_t *setup, *xfer, *stat;
} ctl;
/* Interrupt pipe */
struct {
- usb_dma_t datadma;
int nslots;
int pos;
} intr;
/* Bulk pipe */
struct {
- usb_dma_t datadma;
u_int length;
int isread;
} bulk;
+ /* Iso pipe */
+ struct iso {
+ int xxxxx;
+ } iso;
} u;
};
@@ -265,6 +272,17 @@
ohci_device_bulk_done,
};
+#if 0
+struct usbd_pipe_methods ohci_device_isoc_methods = {
+ ohci_device_isoc_transfer,
+ ohci_device_isoc_start,
+ ohci_device_isoc_abort,
+ ohci_device_isoc_close,
+ ohci_noop,
+ ohci_device_isoc_done,
+};
+#endif
+
ohci_soft_ed_t *
ohci_alloc_sed(sc)
ohci_softc_t *sc;
@@ -809,11 +827,6 @@
ohci_device_ctrl_done(reqh)
usbd_request_handle reqh;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
- ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
- u_int len = opipe->u.ctl.length;
- usb_dma_t *dma;
-
DPRINTFN(10,("ohci_ctrl_done: reqh=%p\n", reqh));
#ifdef DIAGNOSTIC
@@ -822,13 +835,6 @@
}
#endif
reqh->hcpriv = 0;
-
- if (len != 0) {
- dma = &opipe->u.ctl.datadma;
- if (reqh->request.bmRequestType & UT_READ)
- memcpy(reqh->buffer, KERNADDR(dma), len);
- usb_freemem(sc->sc_dmatag, dma);
- }
}
void
@@ -837,7 +843,6 @@
{
struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
- usb_dma_t *dma;
ohci_soft_ed_t *sed = opipe->sed;
ohci_soft_td_t *xfer, *tail;
@@ -847,9 +852,6 @@
reqh->hcpriv = 0;
- dma = &opipe->u.intr.datadma;
- memcpy(reqh->buffer, KERNADDR(dma), reqh->actlen);
-
if (reqh->pipe->repeat) {
xfer = opipe->tail;
tail = ohci_alloc_std(sc); /* XXX should reuse TD */
@@ -864,7 +866,7 @@
OHCI_TD_SET_DI(1) | OHCI_TD_TOGGLE_CARRY);
if (reqh->flags & USBD_SHORT_XFER_OK)
xfer->td.td_flags |= LE(OHCI_TD_R);
- xfer->td.td_cbp = LE(DMAADDR(dma));
+ xfer->td.td_cbp = LE(DMAADDR(&reqh->dmabuf));
xfer->nexttd = tail;
xfer->td.td_nexttd = LE(tail->physaddr);
xfer->td.td_be = LE(LE(xfer->td.td_cbp) + reqh->length - 1);
@@ -876,8 +878,6 @@
ohci_hash_add_td(sc, xfer);
sed->ed.ed_tailp = LE(tail->physaddr);
opipe->tail = tail;
- } else {
- usb_freemem(sc->sc_dmatag, dma);
}
}
@@ -885,20 +885,10 @@
ohci_device_bulk_done(reqh)
usbd_request_handle reqh;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
- ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
- u_int len = opipe->u.bulk.length;
- usb_dma_t *dma;
-
DPRINTFN(10,("ohci_bulk_done: reqh=%p, actlen=%d\n",
reqh, reqh->actlen));
reqh->hcpriv = 0;
-
- dma = &opipe->u.bulk.datadma;
- if (opipe->u.bulk.isread)
- memcpy(reqh->buffer, KERNADDR(dma), len);
- usb_freemem(sc->sc_dmatag, dma);
}
void
@@ -924,7 +914,7 @@
pipe = reqh->pipe;
opipe = (struct ohci_pipe *)pipe;
- p = KERNADDR(&opipe->u.intr.datadma);
+ p = KERNADDR(&reqh->dmabuf);
m = min(sc->sc_noport, reqh->length * 8 - 1);
memset(p, 0, reqh->length);
for (i = 1; i <= m; i++) {
@@ -942,13 +932,7 @@
ohci_root_intr_done(reqh)
usbd_request_handle reqh;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
- ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
-
reqh->hcpriv = 0;
-
- if (!reqh->pipe->repeat)
- usb_freemem(sc->sc_dmatag, &opipe->u.intr.datadma);
}
/*
@@ -1009,7 +993,6 @@
int addr = dev->address;
ohci_soft_td_t *setup, *xfer = 0, *stat, *next, *tail;
ohci_soft_ed_t *sed;
- usb_dma_t *dmap;
int isread;
int len;
usbd_status r;
@@ -1038,7 +1021,6 @@
tail->reqh = 0;
sed = opipe->sed;
- dmap = &opipe->u.ctl.datadma;
opipe->u.ctl.length = len;
/* Update device address and length since they may have changed. */
@@ -1055,14 +1037,11 @@
r = USBD_NOMEM;
goto bad3;
}
- r = usb_allocmem(sc->sc_dmatag, len, 0, dmap);
- if (r != USBD_NORMAL_COMPLETION)
- goto bad4;
xfer->td.td_flags = LE(
(isread ? OHCI_TD_IN : OHCI_TD_OUT) | OHCI_TD_NOCC |
OHCI_TD_TOGGLE_1 | OHCI_TD_NOINTR |
(reqh->flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0));
- xfer->td.td_cbp = LE(DMAADDR(dmap));
+ xfer->td.td_cbp = LE(DMAADDR(&reqh->dmabuf));
xfer->nexttd = stat;
xfer->td.td_nexttd = LE(stat->physaddr);
xfer->td.td_be = LE(LE(xfer->td.td_cbp) + len - 1);
@@ -1078,8 +1057,6 @@
}
memcpy(KERNADDR(&opipe->u.ctl.reqdma), req, sizeof *req);
- if (!isread && len != 0)
- memcpy(KERNADDR(dmap), reqh->buffer, len);
setup->td.td_flags = LE(OHCI_TD_SETUP | OHCI_TD_NOCC |
OHCI_TD_TOGGLE_0 | OHCI_TD_NOINTR);
@@ -1137,8 +1114,6 @@
return (USBD_NORMAL_COMPLETION);
- bad4:
- ohci_free_std(sc, xfer);
bad3:
ohci_free_std(sc, tail);
bad2:
@@ -1343,7 +1318,7 @@
return (ohci_device_setintr(sc, opipe, ed->bInterval));
case UE_ISOCHRONOUS:
printf("ohci_open: open iso unimplemented\n");
- return (USBD_XXX);
+ return (USBD_INVAL);
case UE_BULK:
pipe->methods = &ohci_device_bulk_methods;
s = splusb();
@@ -1565,12 +1540,9 @@
ohci_root_ctrl_transfer(reqh)
usbd_request_handle reqh;
{
- int s;
usbd_status r;
- s = splusb();
r = usb_insert_transfer(reqh);
- splx(s);
if (r != USBD_NORMAL_COMPLETION)
return (r);
else
@@ -1597,7 +1569,6 @@
return (USBD_INVAL);
#endif
req = &reqh->request;
- buf = reqh->buffer;
DPRINTFN(4,("ohci_root_ctrl_control type=0x%02x request=%02x\n",
req->bmRequestType, req->bRequest));
@@ -1605,6 +1576,14 @@
len = UGETW(req->wLength);
value = UGETW(req->wValue);
index = UGETW(req->wIndex);
+
+ if (len != 0)
+ buf = KERNADDR(&reqh->dmabuf);
+#ifdef DIAGNOSTIC
+ else
+ buf = 0;
+#endif
+
#define C(x,y) ((x) | ((y) << 8))
switch(C(req->bRequest, req->bmRequestType)) {
case C(UR_CLEAR_FEATURE, UT_WRITE_DEVICE):
@@ -1892,12 +1871,9 @@
ohci_root_intr_transfer(reqh)
usbd_request_handle reqh;
{
- int s;
usbd_status r;
- s = splusb();
r = usb_insert_transfer(reqh);
- splx(s);
Home |
Main Index |
Thread Index |
Old Index