[svn-commits] fjoe: freebsd/trunk r8728 - in /freebsd/trunk: drivers/dahdi/voicebus/ driver...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 1 03:47:57 CDT 2010


Author: fjoe
Date: Tue Jun  1 03:47:55 2010
New Revision: 8728

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8728
Log:
Initial dahdi_vpmadt032_loader port.

Added:
    freebsd/trunk/freebsd/dahdi_vpmadt032_loader/
    freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile   (with props)
Modified:
    freebsd/trunk/drivers/dahdi/voicebus/voicebus.h
    freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
    freebsd/trunk/freebsd/Makefile

Modified: freebsd/trunk/drivers/dahdi/voicebus/voicebus.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=8728&r1=8727&r2=8728
==============================================================================
--- freebsd/trunk/drivers/dahdi/voicebus/voicebus.h (original)
+++ freebsd/trunk/drivers/dahdi/voicebus/voicebus.h Tue Jun  1 03:47:55 2010
@@ -115,6 +115,7 @@
 	struct pci_dev		*pdev;
 #if defined(__FreeBSD__)
 	struct pci_dev		_dev;
+	void *			ctx;
 
 	struct resource *	irq_res;	/* resource for irq */
 	int			irq_rid;

Modified: freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c?view=diff&rev=8728&r1=8727&r2=8728
==============================================================================
--- freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c (original)
+++ freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c Tue Jun  1 03:47:55 2010
@@ -16,6 +16,18 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
+#if defined(__FreeBSD__)
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <dev/pci/pcivar.h>
+
+#include <machine/stdarg.h>
+#else /* !__FreeBSD__ */
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/module.h>
@@ -23,6 +35,7 @@
 #include <linux/ctype.h>
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
+#endif /* !__FreeBSD__ */
 
 #include <dahdi/kernel.h>
 
@@ -48,7 +61,7 @@
 	va_start(args, format);
 	res = vsnprintf(buf, sizeof(buf), format, args);
 	va_end(args);
-	printk(KERN_INFO "%s" buf);
+	printk(KERN_INFO "%s", buf);
 #endif
 
 	return res;
@@ -77,7 +90,11 @@
 
 static void handle_receive(struct voicebus *vb, struct list_head *buffers)
 {
+#if defined(__FreeBSD__)
+	struct private_context *ctx = (struct private_context *) vb->ctx;
+#else
 	struct private_context *ctx = pci_get_drvdata(vb->pdev);
+#endif
 	struct vbb *vbb;
 	list_for_each_entry(vbb, buffers, entry) {
 		__vpmadt032_receive(ctx->pvt, vbb->data);
@@ -89,7 +106,11 @@
 static void handle_transmit(struct voicebus *vb, struct list_head *buffers)
 {
 	struct vbb *vbb;
+#if defined(__FreeBSD__)
+	struct private_context *ctx = (struct private_context *) vb->ctx;
+#else
 	struct private_context *ctx = pci_get_drvdata(vb->pdev);
+#endif
 	list_for_each_entry(vbb, buffers, entry)
 		__vpmadt032_transmit(ctx->pvt, vbb->data);
 }
@@ -104,7 +125,9 @@
 	int ret = 0;
 	struct private_context *ctx;
 	const struct voicebus_operations *old;
+#if !defined(__FreeBSD__)
 	void *old_drvdata;
+#endif
 	int id;
 	might_sleep();
 	ctx = kzalloc(sizeof(struct private_context), GFP_KERNEL);
@@ -113,22 +136,30 @@
 	init_private_context(ctx);
 	ctx->vb = vb;
 
-	if (0x8007 == vb->pdev->device || 0x8008 == vb->pdev->device)
-		id = vb->pdev->vendor << 16 | 0x2400;
+	if (0x8007 == dahdi_pci_get_device(vb->pdev) || 0x8008 == dahdi_pci_get_device(vb->pdev))
+		id = dahdi_pci_get_vendor(vb->pdev) << 16 | 0x2400;
 	else
-		id = vb->pdev->vendor << 16 | vb->pdev->device;
+		id = dahdi_pci_get_vendor(vb->pdev) << 16 | dahdi_pci_get_device(vb->pdev);
 
 	ret = __vpmadt032_start_load(0, id, &ctx->pvt);
 	if (ret)
 		goto error_exit;
+#if defined(__FreeBSD__)
+	vb->ctx = ctx;
+#else
 	old_drvdata = pci_get_drvdata(vb->pdev);
 	pci_set_drvdata(vb->pdev, ctx);
+#endif
 	old = vb->ops;
 	vb->ops = &loader_operations;
 	if (!wait_for_completion_timeout(&ctx->done, HZ*20))
 		ret = -EIO;
 	vb->ops = old;
+#if defined(__FreeBSD__)
+	vb->ctx = NULL;
+#else
 	pci_set_drvdata(vb->pdev, old_drvdata);
+#endif
 	__vpmadt032_cleanup(ctx->pvt);
 error_exit:
 	kfree(ctx);
@@ -153,10 +184,40 @@
 	return;
 }
 
+#if defined(__FreeBSD__)
+SYSCTL_NODE(_dahdi, OID_AUTO, vpmadt032_loader, CTLFLAG_RW, 0, "DAHDI VPMADT032 Firmware Loader");
+#define MODULE_PARAM_PREFIX "dahdi.vpmadt032_loader"
+#define MODULE_PARAM_PARENT _dahdi_vpmadt032_loader
+
+static int
+dahdi_vpmadt032_loader_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int res;
+
+	switch (type) {
+	case MOD_LOAD:
+		res = vpmadt032_loader_init();
+		return (-res);
+	case MOD_UNLOAD:
+		vpmadt032_loader_exit();
+		return (0);
+	default:
+		return (EOPNOTSUPP);
+	}
+}
+
+DEV_MODULE(dahdi_vpmadt032_loader, dahdi_vpmadt032_loader_modevent, NULL);
+MODULE_VERSION(dahdi_vpmadt032_loader, 1);
+MODULE_DEPEND(dahdi_vpmadt032_loader, voicebus, 1, 1, 1);
+#endif
+
 module_param(debug, int, S_IRUGO | S_IWUSR);
+
+#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("DAHDI VPMADT032 (Hardware Echo Canceller) Firmware Loader");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_LICENSE("Digium Commercial");
 
 module_init(vpmadt032_loader_init);
 module_exit(vpmadt032_loader_exit);
+#endif

Modified: freebsd/trunk/freebsd/Makefile
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/Makefile?view=diff&rev=8728&r1=8727&r2=8728
==============================================================================
--- freebsd/trunk/freebsd/Makefile (original)
+++ freebsd/trunk/freebsd/Makefile Tue Jun  1 03:47:55 2010
@@ -24,9 +24,14 @@
 # the following drivers are ported but not tested on real HW
 .if defined(WITH_EXPERIMENTAL)
 SUBDIR+=\
+	${_dahdi_vpmadt032_loader}\
 	wctdm\
 	wcte11xp\
 	wcte12xp
 .endif
 
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
+_dahdi_vpmadt032_loader=	dahdi_vpmadt032_loader
+.endif
+
 .include <bsd.subdir.mk>

Added: freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile?view=auto&rev=8728
==============================================================================
--- freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile (added)
+++ freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile Tue Jun  1 03:47:55 2010
@@ -1,0 +1,37 @@
+# $Id$
+
+.PATH: ${.CURDIR}/../../drivers/dahdi/vpmadt032_loader
+
+KMOD=		dahdi_vpmadt032_loader
+SRCS=		dahdi_vpmadt032_loader.c
+SRCS+=		device_if.h bus_if.h pci_if.h
+SRCS+=		vpmadt032_loader.h
+OBJS=		vpmadt032_${VPMADT032_ARCH}.o
+CFLAGS=		-I${.CURDIR}/../../drivers/dahdi
+CLEANFILES=	vpmadt032_loader.h vpmadt032_${VPMADT032_ARCH}.o dahdi-fwload-vpmadt032-${VPMADT032_VERSION}.tar.gz
+CLEANDIRS=	drivers
+
+.if ${MACHINE_ARCH} == "i386"
+VPMADT032_ARCH=	x86_32
+.elif ${MACHINE_ARCH} == "amd64"
+VPMADT032_ARCH=	x86_64
+.else
+.error "vpmadt032 is not supported on this architecture (${MACHINE_ARCH})"
+.endif
+
+.include "../../firmware.mk"
+
+vpmadt032_loader.h: ${.OBJDIR}/drivers/dahdi/vpmadt032_loader/vpmadt032_loader.h
+	${CP} ${.ALLSRC} ${.TARGET}
+
+vpmadt032_${VPMADT032_ARCH}.o: ${.OBJDIR}/drivers/dahdi/vpmadt032_loader/vpmadt032_${VPMADT032_ARCH}.o_shipped
+	${CP} ${.ALLSRC:M*.o_shipped} ${.TARGET}
+
+${.OBJDIR}/drivers/dahdi/vpmadt032_loader/vpmadt032_${VPMADT032_ARCH}.o_shipped: dahdi-fwload-vpmadt032-${VPMADT032_VERSION}.tar.gz
+	${TAR} xvfz ${.ALLSRC}
+	${TOUCH} ${.TARGET}
+
+dahdi-fwload-vpmadt032-${VPMADT032_VERSION}.tar.gz:
+	${FETCH} ${FIRMWARE_URL}/${.TARGET}
+
+.include <bsd.kmod.mk>

Propchange: freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: freebsd/trunk/freebsd/dahdi_vpmadt032_loader/Makefile
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list