svn commit: r245216 - in projects/physbio/sys: arm/arm conf ia64/ia64 kern mips/mips powerpc/powerpc sparc64/include sparc64/sparc64 sys x86/x86
Jeff Roberson
jeff at FreeBSD.org
Wed Jan 9 05:16:06 UTC 2013
Author: jeff
Date: Wed Jan 9 05:16:03 2013
New Revision: 245216
URL: http://svnweb.freebsd.org/changeset/base/245216
Log:
- Call bus_dma_memory memdesc instead to make it more generic. Place it in
its own header for now.
- Move subr_busdma.c to subr_bus_dma.c for marcel.
Sponsored by: EMC / Isilon Storage Division
Added:
projects/physbio/sys/kern/subr_bus_dma.c
- copied, changed from r244877, projects/physbio/sys/kern/subr_busdma.c
projects/physbio/sys/sys/memdesc.h
Deleted:
projects/physbio/sys/kern/subr_busdma.c
Modified:
projects/physbio/sys/arm/arm/busdma_machdep-v6.c
projects/physbio/sys/arm/arm/busdma_machdep.c
projects/physbio/sys/conf/files
projects/physbio/sys/ia64/ia64/busdma_machdep.c
projects/physbio/sys/mips/mips/busdma_machdep.c
projects/physbio/sys/powerpc/powerpc/busdma_machdep.c
projects/physbio/sys/sparc64/include/bus_dma.h
projects/physbio/sys/sparc64/sparc64/bus_machdep.c
projects/physbio/sys/sparc64/sparc64/iommu.c
projects/physbio/sys/sys/bus_dma.h
projects/physbio/sys/x86/x86/busdma_machdep.c
Modified: projects/physbio/sys/arm/arm/busdma_machdep-v6.c
==============================================================================
--- projects/physbio/sys/arm/arm/busdma_machdep-v6.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/arm/arm/busdma_machdep-v6.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
+#include <sys/memdesc.h>
#include <sys/proc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
@@ -155,7 +156,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc mem;
pmap_t pmap;
bus_dmamap_callback_t *callback;
void *callback_arg;
@@ -1037,11 +1038,11 @@ cleanup:
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg)
{
- map->mem = mem;
+ map->mem = *mem;
map->dmat = dmat;
map->callback = callback;
map->callback_arg = callback_arg;
Modified: projects/physbio/sys/arm/arm/busdma_machdep.c
==============================================================================
--- projects/physbio/sys/arm/arm/busdma_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/arm/arm/busdma_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/interrupt.h>
#include <sys/lock.h>
#include <sys/proc.h>
+#include <sys/memdesc.h>
#include <sys/mutex.h>
#include <sys/ktr.h>
#include <sys/kernel.h>
@@ -172,7 +173,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc mem;
int flags;
STAILQ_ENTRY(bus_dmamap) links;
bus_dmamap_callback_t *callback;
@@ -1107,13 +1108,13 @@ cleanup:
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg)
{
KASSERT(dmat != NULL, ("dmatag is NULL"));
KASSERT(map != NULL, ("dmamap is NULL"));
- map->mem = mem;
+ map->mem = *mem;
map->callback = callback;
map->callback_arg = callback_arg;
}
Modified: projects/physbio/sys/conf/files
==============================================================================
--- projects/physbio/sys/conf/files Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/conf/files Wed Jan 9 05:16:03 2013 (r245216)
@@ -2671,7 +2671,7 @@ kern/subr_acl_posix1e.c optional ufs_ac
kern/subr_autoconf.c standard
kern/subr_blist.c standard
kern/subr_bus.c standard
-kern/subr_busdma.c standard
+kern/subr_bus_dma.c standard
kern/subr_bufring.c standard
kern/subr_clock.c standard
kern/subr_devstat.c standard
Modified: projects/physbio/sys/ia64/ia64/busdma_machdep.c
==============================================================================
--- projects/physbio/sys/ia64/ia64/busdma_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/ia64/ia64/busdma_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
+#include <sys/memdesc.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -107,7 +108,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc mem;
bus_dmamap_callback_t *callback;
void *callback_arg;
STAILQ_ENTRY(bus_dmamap) links;
@@ -728,11 +729,11 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback, void *callback_arg)
+ struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
{
if (map != NULL) {
map->dmat = dmat;
- map->mem = mem;
+ map->mem = *mem;
map->callback = callback;
map->callback_arg = callback_arg;
}
Copied and modified: projects/physbio/sys/kern/subr_bus_dma.c (from r244877, projects/physbio/sys/kern/subr_busdma.c)
==============================================================================
--- projects/physbio/sys/kern/subr_busdma.c Mon Dec 31 01:13:41 2012 (r244877, copy source)
+++ projects/physbio/sys/kern/subr_bus_dma.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/mbuf.h>
+#include <sys/memdesc.h>
#include <sys/proc.h>
#include <sys/uio.h>
@@ -248,12 +249,14 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_
void *callback_arg, int flags)
{
bus_dma_segment_t *segs;
+ struct memdesc mem;
int error;
int nsegs;
- if ((flags & BUS_DMA_NOWAIT) == 0)
- _bus_dmamap_waitok(dmat, map, dma_mem_vaddr(buf, buflen),
- callback, callback_arg);
+ if ((flags & BUS_DMA_NOWAIT) == 0) {
+ mem = memdesc_vaddr(buf, buflen);
+ _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg);
+ }
nsegs = -1;
error = _bus_dmamap_load_buffer(dmat, map, buf, buflen, kernel_pmap,
@@ -349,6 +352,7 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat,
{
bus_dma_segment_t *segs;
struct ccb_hdr *ccb_h;
+ struct memdesc mem;
int error;
int nsegs;
@@ -357,9 +361,10 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat,
callback(callback_arg, NULL, 0, 0);
return (0);
}
- if ((flags & BUS_DMA_NOWAIT) == 0)
- _bus_dmamap_waitok(dmat, map, dma_mem_ccb(ccb), callback,
- callback_arg);
+ if ((flags & BUS_DMA_NOWAIT) == 0) {
+ mem = memdesc_ccb(ccb);
+ _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg);
+ }
nsegs = -1;
error = _bus_dmamap_load_ccb(dmat, map, ccb, &nsegs, flags);
nsegs++;
@@ -383,7 +388,7 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat,
int
bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t *mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg, int flags)
{
bus_dma_segment_t *segs;
@@ -391,41 +396,41 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat,
int nsegs;
if ((flags & BUS_DMA_NOWAIT) == 0)
- _bus_dmamap_waitok(dmat, map, *mem, callback, callback_arg);
+ _bus_dmamap_waitok(dmat, map, mem, callback, callback_arg);
nsegs = -1;
error = 0;
- switch (mem->dm_type) {
- case BUS_DMAMEM_VADDR:
- error = _bus_dmamap_load_buffer(dmat, map, mem->u.dm_vaddr,
- mem->dm_opaque, kernel_pmap, flags, NULL, &nsegs);
- break;
- case BUS_DMAMEM_PADDR:
- error = _bus_dmamap_load_phys(dmat, map, mem->u.dm_paddr,
- mem->dm_opaque, flags, NULL, &nsegs);
- break;
- case BUS_DMAMEM_VLIST:
- error = _bus_dmamap_load_vlist(dmat, map, mem->u.dm_list,
- mem->dm_opaque, kernel_pmap, &nsegs, flags);
- break;
- case BUS_DMAMEM_PLIST:
- error = _bus_dmamap_load_plist(dmat, map, mem->u.dm_list,
- mem->dm_opaque, &nsegs, flags);
+ switch (mem->md_type) {
+ case MEMDESC_VADDR:
+ error = _bus_dmamap_load_buffer(dmat, map, mem->u.md_vaddr,
+ mem->md_opaque, kernel_pmap, flags, NULL, &nsegs);
+ break;
+ case MEMDESC_PADDR:
+ error = _bus_dmamap_load_phys(dmat, map, mem->u.md_paddr,
+ mem->md_opaque, flags, NULL, &nsegs);
+ break;
+ case MEMDESC_VLIST:
+ error = _bus_dmamap_load_vlist(dmat, map, mem->u.md_list,
+ mem->md_opaque, kernel_pmap, &nsegs, flags);
+ break;
+ case MEMDESC_PLIST:
+ error = _bus_dmamap_load_plist(dmat, map, mem->u.md_list,
+ mem->md_opaque, &nsegs, flags);
break;
- case BUS_DMAMEM_BIO:
- error = _bus_dmamap_load_bio(dmat, map, mem->u.dm_bio,
+ case MEMDESC_BIO:
+ error = _bus_dmamap_load_bio(dmat, map, mem->u.md_bio,
&nsegs, flags);
break;
- case BUS_DMAMEM_UIO:
- error = _bus_dmamap_load_uio(dmat, map, mem->u.dm_uio,
+ case MEMDESC_UIO:
+ error = _bus_dmamap_load_uio(dmat, map, mem->u.md_uio,
&nsegs, flags);
break;
- case BUS_DMAMEM_MBUF:
- error = _bus_dmamap_load_mbuf_sg(dmat, map, mem->u.dm_mbuf,
+ case MEMDESC_MBUF:
+ error = _bus_dmamap_load_mbuf_sg(dmat, map, mem->u.md_mbuf,
NULL, &nsegs, flags);
break;
- case BUS_DMAMEM_CCB:
- error = _bus_dmamap_load_ccb(dmat, map, mem->u.dm_ccb, &nsegs,
+ case MEMDESC_CCB:
+ error = _bus_dmamap_load_ccb(dmat, map, mem->u.md_ccb, &nsegs,
flags);
break;
}
Modified: projects/physbio/sys/mips/mips/busdma_machdep.c
==============================================================================
--- projects/physbio/sys/mips/mips/busdma_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/mips/mips/busdma_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/interrupt.h>
#include <sys/lock.h>
#include <sys/proc.h>
+#include <sys/memdesc.h>
#include <sys/mutex.h>
#include <sys/ktr.h>
#include <sys/kernel.h>
@@ -137,7 +138,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc *mem;
int flags;
void *origbuffer;
void *allocbuffer;
@@ -965,12 +966,12 @@ cleanup:
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback, void *callback_arg)
+ struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
{
KASSERT(dmat != NULL, ("dmatag is NULL"));
KASSERT(map != NULL, ("dmamap is NULL"));
- map->mem = mem;
+ map->mem = *mem;
map->callback = callback;
map->callback_arg = callback_arg;
}
Modified: projects/physbio/sys/powerpc/powerpc/busdma_machdep.c
==============================================================================
--- projects/physbio/sys/powerpc/powerpc/busdma_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/powerpc/powerpc/busdma_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/proc.h>
+#include <sys/memdesc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -125,7 +126,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc *mem;
bus_dma_segment_t *segments;
int nsegs;
bus_dmamap_callback_t *callback;
@@ -826,13 +827,13 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg)
{
if (dmat->flags & BUS_DMA_COULD_BOUNCE) {
map->dmat = dmat;
- map->mem = mem;
+ map->mem = *mem;
map->callback = callback;
map->callback_arg = callback_arg;
}
Modified: projects/physbio/sys/sparc64/include/bus_dma.h
==============================================================================
--- projects/physbio/sys/sparc64/include/bus_dma.h Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/sparc64/include/bus_dma.h Wed Jan 9 05:16:03 2013 (r245216)
@@ -85,7 +85,7 @@ struct bus_dma_methods {
void *buf, bus_size_t buflen, struct pmap *pmap, int flags,
bus_dma_segment_t *segs, int *segp);
void (*dm_dmamap_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg);
bus_dma_segment_t *(*dm_dmamap_complete)(bus_dma_tag_t dmat,
bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, int error);
Modified: projects/physbio/sys/sparc64/sparc64/bus_machdep.c
==============================================================================
--- projects/physbio/sys/sparc64/sparc64/bus_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/sparc64/sparc64/bus_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -451,7 +451,7 @@ nexus_dmamap_load_buffer(bus_dma_tag_t d
static void
nexus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback, void *callback_arg)
+ struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
{
}
Modified: projects/physbio/sys/sparc64/sparc64/iommu.c
==============================================================================
--- projects/physbio/sys/sparc64/sparc64/iommu.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/sparc64/sparc64/iommu.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -1087,7 +1087,7 @@ iommu_dvmamap_load_buffer(bus_dma_tag_t
static void
iommu_dvmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback, void *callback_arg)
+ struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
{
}
Modified: projects/physbio/sys/sys/bus_dma.h
==============================================================================
--- projects/physbio/sys/sys/bus_dma.h Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/sys/bus_dma.h Wed Jan 9 05:16:03 2013 (r245216)
@@ -110,11 +110,12 @@
#define BUS_DMA_KEEP_PG_OFFSET 0x400
/* Forwards needed by prototypes below. */
-struct pmap;
+union ccb;
+struct bio;
struct mbuf;
+struct memdesc;
+struct pmap;
struct uio;
-struct bio;
-union ccb;
/*
* Operations performed by bus_dmamap_sync().
@@ -136,128 +137,6 @@ typedef struct bus_dma_segment {
} bus_dma_segment_t;
/*
- * bus_dma_memory_t
- *
- * Encapsulates various memory descriptors that devices may DMA
- * to or from.
- */
-
-typedef struct bus_dma_memory {
- union {
- void *dm_vaddr;
- vm_paddr_t dm_paddr;
- bus_dma_segment_t *dm_list;
- struct bio *dm_bio;
- struct uio *dm_uio;
- struct mbuf *dm_mbuf;
- union ccb *dm_ccb;
- } u;
- bus_size_t dm_opaque; /* type specific data. */
- uint32_t dm_type; /* Type of memory. */
-} bus_dma_memory_t;
-
-#define BUS_DMAMEM_VADDR 1 /* Contiguous virtual address. */
-#define BUS_DMAMEM_PADDR 2 /* Contiguous physical address. */
-#define BUS_DMAMEM_VLIST 3 /* sglist of kva. */
-#define BUS_DMAMEM_PLIST 4 /* sglist of physical addresses. */
-#define BUS_DMAMEM_BIO 5 /* Pointer to a bio (block io). */
-#define BUS_DMAMEM_UIO 6 /* Pointer to a uio (any io). */
-#define BUS_DMAMEM_MBUF 7 /* Pointer to a mbuf (network io). */
-#define BUS_DMAMEM_CCB 8 /* Cam control block. (scsi/ata io). */
-
-static inline bus_dma_memory_t
-dma_mem_vaddr(void *vaddr, bus_size_t len)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_vaddr = vaddr;
- mem.dm_opaque = len;
- mem.dm_type = BUS_DMAMEM_VADDR;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_paddr(vm_paddr_t paddr, bus_size_t len)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_paddr = paddr;
- mem.dm_opaque = len;
- mem.dm_type = BUS_DMAMEM_PADDR;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_vlist(bus_dma_segment_t *vlist, int sglist_cnt)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_list = vlist;
- mem.dm_opaque = sglist_cnt;
- mem.dm_type = BUS_DMAMEM_VLIST;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_plist(bus_dma_segment_t *plist, int sglist_cnt)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_list = plist;
- mem.dm_opaque = sglist_cnt;
- mem.dm_type = BUS_DMAMEM_PLIST;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_bio(struct bio *bio)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_bio = bio;
- mem.dm_type = BUS_DMAMEM_BIO;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_uio(struct uio *uio)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_uio = uio;
- mem.dm_type = BUS_DMAMEM_UIO;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_mbuf(struct mbuf *mbuf)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_mbuf = mbuf;
- mem.dm_type = BUS_DMAMEM_MBUF;
-
- return (mem);
-}
-
-static inline bus_dma_memory_t
-dma_mem_ccb(union ccb *ccb)
-{
- bus_dma_memory_t mem;
-
- mem.u.dm_ccb = ccb;
- mem.dm_type = BUS_DMAMEM_CCB;
-
- return (mem);
-}
-
-/*
* A function that returns 1 if the address cannot be accessed by
* a device and 0 if it can be.
*/
@@ -355,7 +234,7 @@ int bus_dmamap_load_ccb(bus_dma_tag_t dm
* Loads any memory descriptor.
*/
int bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t *mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg, int flags);
/*
@@ -417,7 +296,7 @@ void _bus_dmamap_unload(bus_dma_tag_t dm
* software.
*/
void __bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem,
+ struct memdesc *mem,
bus_dmamap_callback_t *callback,
void *callback_arg);
Added: projects/physbio/sys/sys/memdesc.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/physbio/sys/sys/memdesc.h Wed Jan 9 05:16:03 2013 (r245216)
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 2012 EMC Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_MEMDESC_H_
+#define _SYS_MEMDESC_H_
+
+struct bio;
+struct bus_dma_segment;
+struct uio;
+struct mbuf;
+union ccb;
+
+/*
+ * struct memdesc encapsulates various memory descriptors and provides
+ * abstract access to them.
+ */
+struct memdesc {
+ union {
+ void *md_vaddr;
+ vm_paddr_t md_paddr;
+ struct bus_dma_segment *md_list;
+ struct bio *md_bio;
+ struct uio *md_uio;
+ struct mbuf *md_mbuf;
+ union ccb *md_ccb;
+ } u;
+ size_t md_opaque; /* type specific data. */
+ uint32_t md_type; /* Type of memory. */
+};
+
+#define MEMDESC_VADDR 1 /* Contiguous virtual address. */
+#define MEMDESC_PADDR 2 /* Contiguous physical address. */
+#define MEMDESC_VLIST 3 /* scatter/gather list of kva addresses. */
+#define MEMDESC_PLIST 4 /* scatter/gather list of physical addresses. */
+#define MEMDESC_BIO 5 /* Pointer to a bio (block io). */
+#define MEMDESC_UIO 6 /* Pointer to a uio (any io). */
+#define MEMDESC_MBUF 7 /* Pointer to a mbuf (network io). */
+#define MEMDESC_CCB 8 /* Cam control block. (scsi/ata io). */
+
+static inline struct memdesc
+memdesc_vaddr(void *vaddr, size_t len)
+{
+ struct memdesc mem;
+
+ mem.u.md_vaddr = vaddr;
+ mem.md_opaque = len;
+ mem.md_type = MEMDESC_VADDR;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_paddr(vm_paddr_t paddr, size_t len)
+{
+ struct memdesc mem;
+
+ mem.u.md_paddr = paddr;
+ mem.md_opaque = len;
+ mem.md_type = MEMDESC_PADDR;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_vlist(struct bus_dma_segment *vlist, int sglist_cnt)
+{
+ struct memdesc mem;
+
+ mem.u.md_list = vlist;
+ mem.md_opaque = sglist_cnt;
+ mem.md_type = MEMDESC_VLIST;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_plist(struct bus_dma_segment *plist, int sglist_cnt)
+{
+ struct memdesc mem;
+
+ mem.u.md_list = plist;
+ mem.md_opaque = sglist_cnt;
+ mem.md_type = MEMDESC_PLIST;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_bio(struct bio *bio)
+{
+ struct memdesc mem;
+
+ mem.u.md_bio = bio;
+ mem.md_type = MEMDESC_BIO;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_uio(struct uio *uio)
+{
+ struct memdesc mem;
+
+ mem.u.md_uio = uio;
+ mem.md_type = MEMDESC_UIO;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_mbuf(struct mbuf *mbuf)
+{
+ struct memdesc mem;
+
+ mem.u.md_mbuf = mbuf;
+ mem.md_type = MEMDESC_MBUF;
+
+ return (mem);
+}
+
+static inline struct memdesc
+memdesc_ccb(union ccb *ccb)
+{
+ struct memdesc mem;
+
+ mem.u.md_ccb = ccb;
+ mem.md_type = MEMDESC_CCB;
+
+ return (mem);
+}
+#endif /* _SYS_MEMDESC_H_ */
Modified: projects/physbio/sys/x86/x86/busdma_machdep.c
==============================================================================
--- projects/physbio/sys/x86/x86/busdma_machdep.c Wed Jan 9 05:04:13 2013 (r245215)
+++ projects/physbio/sys/x86/x86/busdma_machdep.c Wed Jan 9 05:16:03 2013 (r245216)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/proc.h>
+#include <sys/memdesc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -124,7 +125,7 @@ struct bus_dmamap {
int pagesneeded;
int pagesreserved;
bus_dma_tag_t dmat;
- bus_dma_memory_t mem;
+ struct memdesc mem;
bus_dmamap_callback_t *callback;
void *callback_arg;
STAILQ_ENTRY(bus_dmamap) links;
@@ -850,11 +851,11 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
- bus_dma_memory_t mem, bus_dmamap_callback_t *callback,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
void *callback_arg)
{
if (map != NULL) {
- map->mem = mem;
+ map->mem = *mem;
map->dmat = dmat;
map->callback = callback;
map->callback_arg = callback_arg;
More information about the svn-src-projects
mailing list