[svn-commits] fjoe: freebsd/trunk r8729 - in /freebsd/trunk: drivers/dahdi/ drivers/dahdi/v...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 1 04:02:16 CDT 2010


Author: fjoe
Date: Tue Jun  1 04:02:14 2010
New Revision: 8729

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8729
Log:
Move DMA allocate/free/map API to the main driver.

Modified:
    freebsd/trunk/drivers/dahdi/voicebus/voicebus.c
    freebsd/trunk/drivers/dahdi/wcfxo.c
    freebsd/trunk/drivers/dahdi/wct4xxp/base.c
    freebsd/trunk/drivers/dahdi/wctdm.c
    freebsd/trunk/drivers/dahdi/wcte11xp.c
    freebsd/trunk/freebsd/dahdi/bsd-compat.c
    freebsd/trunk/include/dahdi/compat/bsd.h
    freebsd/trunk/include/dahdi/dahdi_config.h

Modified: freebsd/trunk/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/drivers/dahdi/voicebus/voicebus.c (original)
+++ freebsd/trunk/drivers/dahdi/voicebus/voicebus.c Tue Jun  1 04:02:14 2010
@@ -121,67 +121,6 @@
 #define DMA_FROM_DEVICE	0
 #define DMA_TO_DEVICE	1
 
-static void
-vb_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-vb_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return (res);
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, vb_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	return (0);
-}
-
-static void
-vb_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
-}
-
 static bus_dma_tag_t vbb_dma_tag;
 
 struct vbb *
@@ -214,7 +153,7 @@
 	int res;
 
 	res = bus_dmamap_load(vbb_dma_tag, vbb->dma_map, vbb->data, sizeof(vbb->data),
-	    vb_dma_map_addr, &vbb->paddr, 0);
+	    dahdi_dma_map_addr, &vbb->paddr, 0);
 	if (res) {
 		if (printk_ratelimit())
 			printf("voicebus: Can't load DMA map\n");
@@ -357,7 +296,7 @@
 	}
 
 #if defined(__FreeBSD__)
-	i = vb_dma_allocate((sizeof(*d) + dl->padding) * DRING_SIZE,
+	i = dahdi_dma_allocate((sizeof(*d) + dl->padding) * DRING_SIZE,
 	    &dl->dma_tag, &dl->dma_map, (void **) &dl->desc, &dl->desc_dma);
 	if (i) {
 		return i;
@@ -426,7 +365,7 @@
 	}
 
 #if defined(__FreeBSD__)
-	i = vb_dma_allocate((sizeof(*d) + dl->padding) * DRING_SIZE,
+	i = dahdi_dma_allocate((sizeof(*d) + dl->padding) * DRING_SIZE,
 	    &dl->dma_tag, &dl->dma_map, (void **) &dl->desc, &dl->desc_dma);
 	if (i) {
 		return i;
@@ -650,7 +589,7 @@
 	}
 	vb_cleanup_descriptors(vb, dl);
 #if defined(__FreeBSD__)
-	vb_dma_free(&dl->dma_tag, &dl->dma_map, (void **) &dl->desc, &dl->desc_dma);
+	dahdi_dma_free(&dl->dma_tag, &dl->dma_map, (void **) &dl->desc, &dl->desc_dma);
 #else /* !__FreeBSD__ */
 	pci_free_consistent(
 		vb->pdev,
@@ -1329,7 +1268,7 @@
 	spin_lock_destroy(&vb->lock);
 	if (vb->idle_vbb_dma_addr) {
 #if defined(__FreeBSD__)
-		vb_dma_free(&vb->idle_vbb_dma_tag, &vb->idle_vbb_dma_map,
+		dahdi_dma_free(&vb->idle_vbb_dma_tag, &vb->idle_vbb_dma_map,
 		    (void **) &vb->idle_vbb, &vb->idle_vbb_dma_addr);
 #else /* !__FreeBSD__ */
 		dma_free_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
@@ -1859,7 +1798,7 @@
 #endif
 
 #if defined(__FreeBSD__)
-	retval = vb_dma_allocate(VOICEBUS_SFRAME_SIZE,
+	retval = dahdi_dma_allocate(VOICEBUS_SFRAME_SIZE,
 	    &vb->idle_vbb_dma_tag, &vb->idle_vbb_dma_map, (void **) &vb->idle_vbb, &vb->idle_vbb_dma_addr);
 	if (retval) {
 		dev_err(&vb->pdev->dev, "Can't allocate DMA memory\n");
@@ -1960,7 +1899,7 @@
 	}
 #endif
 
-	vb_dma_free(&vb->idle_vbb_dma_tag, &vb->idle_vbb_dma_map,
+	dahdi_dma_free(&vb->idle_vbb_dma_tag, &vb->idle_vbb_dma_map,
 	    (void **) &vb->idle_vbb, &vb->idle_vbb_dma_addr);
 
 	if (vb->mem_res != NULL) {

Modified: freebsd/trunk/drivers/dahdi/wcfxo.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcfxo.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcfxo.c (original)
+++ freebsd/trunk/drivers/dahdi/wcfxo.c Tue Jun  1 04:02:14 2010
@@ -1152,8 +1152,6 @@
 #define MODULE_PARAM_PREFIX "dahdi.wcfxo"
 #define MODULE_PARAM_PARENT _dahdi_wcfxo
 
-static void wcfxo_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
-
 static void
 wcfxo_release_resources(struct wcfxo *wc)
 {
@@ -1169,8 +1167,8 @@
 	}
 
 	/* release DMA resources */
-	wcfxo_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
-	wcfxo_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
+	dahdi_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
+	dahdi_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
 
 	/* release memory window */
 	if (wc->io_res != NULL) {
@@ -1200,67 +1198,6 @@
 	}
 
 	return (0);
-}
-
-static void
-wcfxo_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-wcfxo_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return (res);
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, wcfxo_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	return (0);
-}
-
-static void
-wcfxo_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
 }
 
 static int
@@ -1322,12 +1259,12 @@
 
 	/* allocate enough memory for two zt chunks.  Each sample uses
 	   32 bits.  Allocate an extra set just for control too */
-	res = wcfxo_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->write_dma_tag, &wc->write_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->write_dma_tag, &wc->write_dma_map,
 	    __DECONST(void **, &wc->writechunk), &wc->writedma);
 	if (res)
 		goto err;
 
-	res = wcfxo_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->read_dma_tag, &wc->read_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->read_dma_tag, &wc->read_dma_map,
 	    __DECONST(void **, &wc->readchunk), &wc->readdma);
 	if (res)
 		goto err;

Modified: freebsd/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wct4xxp/base.c Tue Jun  1 04:02:14 2010
@@ -38,12 +38,6 @@
 #include <machine/bus.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
-
-static int
-t4_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
-
-static void
-t4_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
 #else /* !__FreeBSD__ */
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -3400,15 +3394,15 @@
 	bus_dmamap_t    write_dma_map;
 
 	/* allocate DMA resources */
-	res = t4_dma_allocate(numbufs * T4_BASE_SIZE, &write_dma_tag, &write_dma_map,
+	res = dahdi_dma_allocate(numbufs * T4_BASE_SIZE, &write_dma_tag, &write_dma_map,
 	    &writechunk, &writedma);
 	if (res)
 		return -res;
 
-	res = t4_dma_allocate(numbufs * T4_BASE_SIZE, &read_dma_tag, &read_dma_map,
+	res = dahdi_dma_allocate(numbufs * T4_BASE_SIZE, &read_dma_tag, &read_dma_map,
 	    &readchunk, &readdma);
 	if (res) {
-		t4_dma_free(&write_dma_tag, &write_dma_map, &writechunk, &writedma);
+		dahdi_dma_free(&write_dma_tag, &write_dma_map, &writechunk, &writedma);
 		return -res;
 	}
 
@@ -3521,8 +3515,8 @@
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 #if defined(__FreeBSD__)
-	t4_dma_free(&write_dma_tag, &write_dma_map, &writechunk, &writedma);
-	t4_dma_free(&read_dma_tag, &read_dma_map, &readchunk, &readdma);
+	dahdi_dma_free(&write_dma_tag, &write_dma_map, &writechunk, &writedma);
+	dahdi_dma_free(&read_dma_tag, &read_dma_map, &readchunk, &readdma);
 #else
 	pci_free_consistent(wc->dev, T4_BASE_SIZE * oldbufs * 2, (void *)oldalloc, oldaddr);
 #endif
@@ -4566,8 +4560,8 @@
 	}
 
 	/* release DMA resources */
-	t4_dma_free(&wc->write_dma_tag, &wc->write_dma_map, (void **) &wc->writechunk, &wc->writedma);
-	t4_dma_free(&wc->read_dma_tag, &wc->read_dma_map, (void **) &wc->readchunk, &wc->readdma);
+	dahdi_dma_free(&wc->write_dma_tag, &wc->write_dma_map, (void **) &wc->writechunk, &wc->writedma);
+	dahdi_dma_free(&wc->read_dma_tag, &wc->read_dma_map, (void **) &wc->readchunk, &wc->readdma);
 
 	/* release memory window */
 	if (wc->mem_res != NULL) {
@@ -4609,67 +4603,6 @@
 	}
 
 	return (0);
-}
-
-static void
-t4_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-t4_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return (res);
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, t4_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	return (0);
-}
-
-static void
-t4_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
 }
 
 static int

Modified: freebsd/trunk/drivers/dahdi/wctdm.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wctdm.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/drivers/dahdi/wctdm.c (original)
+++ freebsd/trunk/drivers/dahdi/wctdm.c Tue Jun  1 04:02:14 2010
@@ -2889,8 +2889,6 @@
 #define MODULE_PARAM_PREFIX "dahdi.wctdm"
 #define MODULE_PARAM_PARENT _dahdi_wctdm
 
-static void wctdm_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
-
 static void
 wctdm_release_resources(struct wctdm *wc)
 {
@@ -2906,8 +2904,8 @@
 	}
 
 	/* release DMA resources */
-	wctdm_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
-	wctdm_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
+	dahdi_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
+	dahdi_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
 
 	/* release memory window */
 	if (wc->io_res != NULL) {
@@ -2939,67 +2937,6 @@
 	return (0);
 }
 
-static void
-wctdm_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-wctdm_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return (res);
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, wctdm_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	return (0);
-}
-
-static void
-wctdm_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
-}
-
 static int
 wctdm_device_probe(device_t dev)
 {
@@ -3065,12 +3002,12 @@
 
 	/* allocate enough memory for two zt chunks.  Each sample uses
 	   32 bits.  Allocate an extra set just for control too */
-	res = wctdm_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->write_dma_tag, &wc->write_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->write_dma_tag, &wc->write_dma_map,
 	    __DECONST(void **, &wc->writechunk), &wc->writedma);
 	if (res)
 		goto err;
 
-	res = wctdm_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->read_dma_tag, &wc->read_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 2 * 2 * 4, &wc->read_dma_tag, &wc->read_dma_map,
 	    __DECONST(void **, &wc->readchunk), &wc->readdma);
 	if (res)
 		goto err;

Modified: freebsd/trunk/drivers/dahdi/wcte11xp.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcte11xp.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcte11xp.c (original)
+++ freebsd/trunk/drivers/dahdi/wcte11xp.c Tue Jun  1 04:02:14 2010
@@ -1675,8 +1675,6 @@
 #define MODULE_PARAM_PREFIX "dahdi.wcte11xp"
 #define MODULE_PARAM_PARENT _dahdi_wcte11xp
 
-static void t1xxp_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
-
 static void
 t1xxp_release_resources(struct t1 *wc)
 {
@@ -1692,8 +1690,8 @@
 	}
 
 	/* release DMA resources */
-	t1xxp_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
-	t1xxp_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
+	dahdi_dma_free(&wc->write_dma_tag, &wc->write_dma_map, __DECONST(void **, &wc->writechunk), &wc->writedma);
+	dahdi_dma_free(&wc->read_dma_tag, &wc->read_dma_map, __DECONST(void **, &wc->readchunk), &wc->readdma);
 
 	/* release memory window */
 	if (wc->io_res != NULL) {
@@ -1723,67 +1721,6 @@
 	}
 
 	return (0);
-}
-
-static void
-t1xxp_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-t1xxp_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return (res);
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, t1xxp_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return (res);
-	}
-
-	return (0);
-}
-
-static void
-t1xxp_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
 }
 
 static int
@@ -1838,12 +1775,12 @@
 	if (res)
 		goto err;
 
-	res = t1xxp_dma_allocate(DAHDI_MAX_CHUNKSIZE * 32 * 2, &wc->write_dma_tag, &wc->write_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 32 * 2, &wc->write_dma_tag, &wc->write_dma_map,
 	    __DECONST(void **, &wc->writechunk), &wc->writedma);
 	if (res)
 		goto err;
 
-	res = t1xxp_dma_allocate(DAHDI_MAX_CHUNKSIZE * 32 * 2, &wc->read_dma_tag, &wc->read_dma_map,
+	res = dahdi_dma_allocate(DAHDI_MAX_CHUNKSIZE * 32 * 2, &wc->read_dma_tag, &wc->read_dma_map,
 	    __DECONST(void **, &wc->readchunk), &wc->readdma);
 	if (res)
 		goto err;

Modified: freebsd/trunk/freebsd/dahdi/bsd-compat.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi/bsd-compat.c?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/freebsd/dahdi/bsd-compat.c (original)
+++ freebsd/trunk/freebsd/dahdi/bsd-compat.c Tue Jun  1 04:02:14 2010
@@ -375,7 +375,6 @@
 	firmware_put(firmware, FIRMWARE_UNLOAD);
 }
 
-
 /*
  * PCI device API
  */
@@ -425,3 +424,67 @@
 	}
 	return (dst);
 }
+
+/*
+ * DMA API
+ */
+void
+dahdi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+	uint32_t *paddr = arg;
+	*paddr = segs->ds_addr;
+}
+
+int
+dahdi_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
+{
+	int res;
+
+	res = bus_dma_tag_create(NULL, 8, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
+	if (res)
+		return (res);
+
+	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
+	if (res) {
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+		return (res);
+	}
+
+	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, dahdi_dma_map_addr, ppaddr, 0);
+	if (res) {
+		bus_dmamem_free(*ptag, *pvaddr, *pmap);
+		*pvaddr = NULL;
+
+		bus_dmamap_destroy(*ptag, *pmap);
+		*pmap = NULL;
+
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+		return (res);
+	}
+
+	return (0);
+}
+
+void
+dahdi_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
+{
+	if (*ppaddr != 0) {
+		bus_dmamap_unload(*ptag, *pmap);
+		*ppaddr = 0;
+	}
+	if (*pvaddr != NULL) {
+		bus_dmamem_free(*ptag, *pvaddr, *pmap);
+		*pvaddr = NULL;
+
+		bus_dmamap_destroy(*ptag, *pmap);
+		*pmap = NULL;
+	}
+	if (*ptag != NULL) {
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+	}
+}

Modified: freebsd/trunk/include/dahdi/compat/bsd.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/bsd.h?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Tue Jun  1 04:02:14 2010
@@ -12,6 +12,7 @@
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 #include <machine/atomic.h>
+#include <machine/bus.h>
 
 #define LINUX_VERSION_CODE	-1
 #define KERNEL_VERSION(x, y, z)	0
@@ -449,4 +450,16 @@
 
 extern u_short fcstab[256];
 
+/*
+ * DMA API
+ */
+void
+dahdi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error);
+
+int
+dahdi_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
+
+void
+dahdi_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
+
 #endif /* _DAHDI_COMPAT_BSD_H_ */

Modified: freebsd/trunk/include/dahdi/dahdi_config.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/dahdi_config.h?view=diff&rev=8729&r1=8728&r2=8729
==============================================================================
--- freebsd/trunk/include/dahdi/dahdi_config.h (original)
+++ freebsd/trunk/include/dahdi/dahdi_config.h Tue Jun  1 04:02:14 2010
@@ -119,7 +119,7 @@
  * Define CONFIG_DAHDI_CORE_TIMER if you would like dahdi to always provide a
  * timing source regardless of which spans / drivers are configured.
  */
-#define CONFIG_DAHDI_CORE_TIMER
+/* #define CONFIG_DAHDI_CORE_TIMER */
 
 /*
  * Define CONFIG_DAHDI_NO_ECHOCAN_DISABLE to prevent the 2100Hz tone detector




More information about the svn-commits mailing list