Update dma memory access API a little.
This commit is contained in:
parent
894da75819
commit
4bc0b333ea
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ehci.c,v 1.29 2001/12/31 12:16:57 augustss Exp $ */
|
||||
/* $NetBSD: ehci.c,v 1.30 2002/05/19 06:24:30 augustss Exp $ */
|
||||
|
||||
/*
|
||||
* TODO
|
||||
@ -52,7 +52,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.29 2001/12/31 12:16:57 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.30 2002/05/19 06:24:30 augustss Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -560,7 +560,7 @@ ehci_pcd(ehci_softc_t *sc, usbd_xfer_handle xfer)
|
||||
pipe = xfer->pipe;
|
||||
epipe = (struct ehci_pipe *)pipe;
|
||||
|
||||
p = KERNADDR(&xfer->dmabuf);
|
||||
p = KERNADDR(&xfer->dmabuf, 0);
|
||||
m = min(sc->sc_noport, xfer->length * 8 - 1);
|
||||
memset(p, 0, xfer->length);
|
||||
for (i = 1; i <= m; i++) {
|
||||
@ -1490,7 +1490,7 @@ ehci_root_ctrl_start(usbd_xfer_handle xfer)
|
||||
index = UGETW(req->wIndex);
|
||||
|
||||
if (len != 0)
|
||||
buf = KERNADDR(&xfer->dmabuf);
|
||||
buf = KERNADDR(&xfer->dmabuf, 0);
|
||||
|
||||
#define C(x,y) ((x) | ((y) << 8))
|
||||
switch(C(req->bRequest, req->bmRequestType)) {
|
||||
@ -1977,7 +1977,7 @@ ehci_alloc_sqh(ehci_softc_t *sc)
|
||||
return (NULL);
|
||||
for(i = 0; i < EHCI_SQH_CHUNK; i++) {
|
||||
offs = i * EHCI_SQH_SIZE;
|
||||
sqh = (ehci_soft_qh_t *)((char *)KERNADDR(&dma) + offs);
|
||||
sqh = KERNADDR(&dma, offs);
|
||||
sqh->physaddr = DMAADDR(&dma) + offs;
|
||||
sqh->next = sc->sc_freeqhs;
|
||||
sc->sc_freeqhs = sqh;
|
||||
@ -2019,7 +2019,7 @@ ehci_alloc_sqtd(ehci_softc_t *sc)
|
||||
s = splusb();
|
||||
for(i = 0; i < EHCI_SQTD_CHUNK; i++) {
|
||||
offs = i * EHCI_SQTD_SIZE;
|
||||
sqtd = (ehci_soft_qtd_t *)((char *)KERNADDR(&dma)+offs);
|
||||
sqtd = KERNADDR(&dma, offs);
|
||||
sqtd->physaddr = DMAADDR(&dma) + offs;
|
||||
sqtd->nextqtd = sc->sc_freeqtds;
|
||||
sc->sc_freeqtds = sqtd;
|
||||
@ -2504,7 +2504,7 @@ ehci_device_request(usbd_xfer_handle xfer)
|
||||
next = stat;
|
||||
}
|
||||
|
||||
memcpy(KERNADDR(&epipe->u.ctl.reqdma), req, sizeof *req);
|
||||
memcpy(KERNADDR(&epipe->u.ctl.reqdma, 0), req, sizeof *req);
|
||||
|
||||
setup->qtd.qtd_status = htole32(
|
||||
EHCI_QTD_ACTIVE |
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ohci.c,v 1.122 2002/03/17 18:02:52 augustss Exp $ */
|
||||
/* $NetBSD: ohci.c,v 1.123 2002/05/19 06:24:31 augustss Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -46,7 +46,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.122 2002/03/17 18:02:52 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.123 2002/05/19 06:24:31 augustss Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -405,7 +405,7 @@ ohci_alloc_sed(ohci_softc_t *sc)
|
||||
return (0);
|
||||
for(i = 0; i < OHCI_SED_CHUNK; i++) {
|
||||
offs = i * OHCI_SED_SIZE;
|
||||
sed = (ohci_soft_ed_t *)((char *)KERNADDR(&dma) +offs);
|
||||
sed = KERNADDR(&dma, offs);
|
||||
sed->physaddr = DMAADDR(&dma) + offs;
|
||||
sed->next = sc->sc_freeeds;
|
||||
sc->sc_freeeds = sed;
|
||||
@ -443,7 +443,7 @@ ohci_alloc_std(ohci_softc_t *sc)
|
||||
s = splusb();
|
||||
for(i = 0; i < OHCI_STD_CHUNK; i++) {
|
||||
offs = i * OHCI_STD_SIZE;
|
||||
std = (ohci_soft_td_t *)((char *)KERNADDR(&dma) +offs);
|
||||
std = KERNADDR(&dma, offs);
|
||||
std->physaddr = DMAADDR(&dma) + offs;
|
||||
std->nexttd = sc->sc_freetds;
|
||||
sc->sc_freetds = std;
|
||||
@ -599,7 +599,7 @@ ohci_alloc_sitd(ohci_softc_t *sc)
|
||||
return (NULL);
|
||||
for(i = 0; i < OHCI_SITD_CHUNK; i++) {
|
||||
offs = i * OHCI_SITD_SIZE;
|
||||
sitd = (ohci_soft_itd_t *)((char *)KERNADDR(&dma)+offs);
|
||||
sitd = KERNADDR(&dma, offs);
|
||||
sitd->physaddr = DMAADDR(&dma) + offs;
|
||||
sitd->nextitd = sc->sc_freeitds;
|
||||
sc->sc_freeitds = sitd;
|
||||
@ -682,7 +682,7 @@ ohci_init(ohci_softc_t *sc)
|
||||
OHCI_HCCA_ALIGN, &sc->sc_hccadma);
|
||||
if (err)
|
||||
return (err);
|
||||
sc->sc_hcca = (struct ohci_hcca *)KERNADDR(&sc->sc_hccadma);
|
||||
sc->sc_hcca = KERNADDR(&sc->sc_hccadma, 0);
|
||||
memset(sc->sc_hcca, 0, OHCI_HCCA_SIZE);
|
||||
|
||||
sc->sc_eintrs = OHCI_NORMAL_INTRS;
|
||||
@ -1502,7 +1502,7 @@ ohci_rhsc(ohci_softc_t *sc, usbd_xfer_handle xfer)
|
||||
pipe = xfer->pipe;
|
||||
opipe = (struct ohci_pipe *)pipe;
|
||||
|
||||
p = KERNADDR(&xfer->dmabuf);
|
||||
p = KERNADDR(&xfer->dmabuf, 0);
|
||||
m = min(sc->sc_noport, xfer->length * 8 - 1);
|
||||
memset(p, 0, xfer->length);
|
||||
for (i = 1; i <= m; i++) {
|
||||
@ -1648,7 +1648,7 @@ ohci_device_request(usbd_xfer_handle xfer)
|
||||
std->td.td_flags |= htole32(OHCI_TD_TOGGLE_1);
|
||||
}
|
||||
|
||||
memcpy(KERNADDR(&opipe->u.ctl.reqdma), req, sizeof *req);
|
||||
memcpy(KERNADDR(&opipe->u.ctl.reqdma, 0), req, sizeof *req);
|
||||
|
||||
setup->td.td_flags = htole32(OHCI_TD_SETUP | OHCI_TD_NOCC |
|
||||
OHCI_TD_TOGGLE_0 | OHCI_TD_NOINTR);
|
||||
@ -2337,7 +2337,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
|
||||
index = UGETW(req->wIndex);
|
||||
|
||||
if (len != 0)
|
||||
buf = KERNADDR(&xfer->dmabuf);
|
||||
buf = KERNADDR(&xfer->dmabuf, 0);
|
||||
|
||||
#define C(x,y) ((x) | ((y) << 8))
|
||||
switch(C(req->bRequest, req->bmRequestType)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uhci.c,v 1.158 2002/03/17 18:02:53 augustss Exp $ */
|
||||
/* $NetBSD: uhci.c,v 1.159 2002/05/19 06:24:32 augustss Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -49,7 +49,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.158 2002/03/17 18:02:53 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.159 2002/05/19 06:24:32 augustss Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -414,7 +414,7 @@ uhci_init(uhci_softc_t *sc)
|
||||
UHCI_FRAMELIST_ALIGN, &sc->sc_dma);
|
||||
if (err)
|
||||
return (err);
|
||||
sc->sc_pframes = KERNADDR(&sc->sc_dma);
|
||||
sc->sc_pframes = KERNADDR(&sc->sc_dma, 0);
|
||||
UWRITE2(sc, UHCI_FRNUM, 0); /* set frame number to 0 */
|
||||
UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma)); /* set frame list*/
|
||||
|
||||
@ -966,7 +966,7 @@ uhci_poll_hub(void *addr)
|
||||
|
||||
usb_callout(sc->sc_poll_handle, sc->sc_ival, uhci_poll_hub, xfer);
|
||||
|
||||
p = KERNADDR(&xfer->dmabuf);
|
||||
p = KERNADDR(&xfer->dmabuf, 0);
|
||||
p[0] = 0;
|
||||
if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC))
|
||||
p[0] |= 1<<1;
|
||||
@ -1614,7 +1614,7 @@ uhci_alloc_std(uhci_softc_t *sc)
|
||||
return (0);
|
||||
for(i = 0; i < UHCI_STD_CHUNK; i++) {
|
||||
offs = i * UHCI_STD_SIZE;
|
||||
std = (uhci_soft_td_t *)((char *)KERNADDR(&dma) +offs);
|
||||
std = KERNADDR(&dma, offs);
|
||||
std->physaddr = DMAADDR(&dma) + offs;
|
||||
std->link.std = sc->sc_freetds;
|
||||
sc->sc_freetds = std;
|
||||
@ -1657,7 +1657,7 @@ uhci_alloc_sqh(uhci_softc_t *sc)
|
||||
return (0);
|
||||
for(i = 0; i < UHCI_SQH_CHUNK; i++) {
|
||||
offs = i * UHCI_SQH_SIZE;
|
||||
sqh = (uhci_soft_qh_t *)((char *)KERNADDR(&dma) +offs);
|
||||
sqh = KERNADDR(&dma, offs);
|
||||
sqh->physaddr = DMAADDR(&dma) + offs;
|
||||
sqh->hlink = sc->sc_freeqhs;
|
||||
sc->sc_freeqhs = sqh;
|
||||
@ -2192,7 +2192,7 @@ uhci_device_request(usbd_xfer_handle xfer)
|
||||
}
|
||||
upipe->u.ctl.length = len;
|
||||
|
||||
memcpy(KERNADDR(&upipe->u.ctl.reqdma), req, sizeof *req);
|
||||
memcpy(KERNADDR(&upipe->u.ctl.reqdma, 0), req, sizeof *req);
|
||||
|
||||
setup->link.std = next;
|
||||
setup->td.td_link = htole32(next->physaddr | UHCI_PTR_VF | UHCI_PTR_TD);
|
||||
@ -3001,7 +3001,7 @@ uhci_root_ctrl_start(usbd_xfer_handle xfer)
|
||||
index = UGETW(req->wIndex);
|
||||
|
||||
if (len != 0)
|
||||
buf = KERNADDR(&xfer->dmabuf);
|
||||
buf = KERNADDR(&xfer->dmabuf, 0);
|
||||
|
||||
#define C(x,y) ((x) | ((y) << 8))
|
||||
switch(C(req->bRequest, req->bmRequestType)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_mem.c,v 1.22 2001/11/13 06:24:56 lukem Exp $ */
|
||||
/* $NetBSD: usb_mem.c,v 1.23 2002/05/19 06:24:33 augustss Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.22 2001/11/13 06:24:56 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.23 2002/05/19 06:24:33 augustss Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -272,7 +272,7 @@ usb_freemem(usbd_bus_handle bus, usb_dma_t *p)
|
||||
usb_block_freemem(p->block);
|
||||
return;
|
||||
}
|
||||
f = KERNADDR(p);
|
||||
f = KERNADDR(p, 0);
|
||||
f->block = p->block;
|
||||
f->offs = p->offs;
|
||||
s = splusb();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_mem.h,v 1.15 2000/06/28 16:39:27 mrg Exp $ */
|
||||
/* $NetBSD: usb_mem.h,v 1.16 2002/05/19 06:24:33 augustss Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -52,7 +52,8 @@ typedef struct usb_dma_block {
|
||||
} usb_dma_block_t;
|
||||
|
||||
#define DMAADDR(dma) ((dma)->block->map->dm_segs[0].ds_addr + (dma)->offs)
|
||||
#define KERNADDR(dma) ((void *)((dma)->block->kaddr + (dma)->offs))
|
||||
#define KERNADDR(dma, o) \
|
||||
((void *)((char *)((dma)->block->kaddr + (dma)->offs) + (o)))
|
||||
|
||||
usbd_status usb_allocmem(usbd_bus_handle,size_t,size_t, usb_dma_t *);
|
||||
void usb_freemem(usbd_bus_handle, usb_dma_t *);
|
||||
@ -81,6 +82,6 @@ void usb_freemem(usbd_bus_handle, usb_dma_t *);
|
||||
#else
|
||||
#define DMAADDR(dma) (vtophys(*(dma)))
|
||||
#endif
|
||||
#define KERNADDR(dma) ((void *) *(dma))
|
||||
#define KERNADDR(dma, o) ((void *) ((char *)*(dma) + (o)))
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usbdi.c,v 1.99 2002/02/28 04:49:16 thorpej Exp $ */
|
||||
/* $NetBSD: usbdi.c,v 1.100 2002/05/19 06:24:33 augustss Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.99 2002/02/28 04:49:16 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.100 2002/05/19 06:24:33 augustss Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -317,7 +317,7 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
/* Copy data if going out. */
|
||||
if (!(xfer->flags & USBD_NO_COPY) && size != 0 &&
|
||||
!usbd_xfer_isread(xfer))
|
||||
memcpy(KERNADDR(dmap), xfer->buffer, size);
|
||||
memcpy(KERNADDR(dmap, 0), xfer->buffer, size);
|
||||
|
||||
err = pipe->methods->transfer(xfer);
|
||||
|
||||
@ -369,7 +369,7 @@ usbd_alloc_buffer(usbd_xfer_handle xfer, u_int32_t size)
|
||||
if (err)
|
||||
return (NULL);
|
||||
xfer->rqflags |= URQ_DEV_DMABUF;
|
||||
return (KERNADDR(&xfer->dmabuf));
|
||||
return (KERNADDR(&xfer->dmabuf, 0));
|
||||
}
|
||||
|
||||
void
|
||||
@ -390,7 +390,7 @@ usbd_get_buffer(usbd_xfer_handle xfer)
|
||||
{
|
||||
if (!(xfer->rqflags & URQ_DEV_DMABUF))
|
||||
return (0);
|
||||
return (KERNADDR(&xfer->dmabuf));
|
||||
return (KERNADDR(&xfer->dmabuf, 0));
|
||||
}
|
||||
|
||||
usbd_xfer_handle
|
||||
@ -795,7 +795,7 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
xfer->actlen = xfer->length;
|
||||
}
|
||||
#endif
|
||||
memcpy(xfer->buffer, KERNADDR(dmap), xfer->actlen);
|
||||
memcpy(xfer->buffer, KERNADDR(dmap, 0), xfer->actlen);
|
||||
}
|
||||
|
||||
/* if we allocated the buffer in usbd_transfer() we free it here. */
|
||||
|
Loading…
Reference in New Issue
Block a user