aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2011-04-19 01:38:21 +0800
committerfjoe <fjoe@FreeBSD.org>2011-04-19 01:38:21 +0800
commit9cb6a5a14f10590e8fe654bdaa5b94adee4c2145 (patch)
tree623a1dfd6dc8fba2242a2ceac98c07c70901c7c3
parentc1ec0fcbc3aa80ac72e3552838786c939d498408 (diff)
downloadfreebsd-ports-gnome-9cb6a5a14f10590e8fe654bdaa5b94adee4c2145.tar.gz
freebsd-ports-gnome-9cb6a5a14f10590e8fe654bdaa5b94adee4c2145.tar.zst
freebsd-ports-gnome-9cb6a5a14f10590e8fe654bdaa5b94adee4c2145.zip
Split dahdi port into two parts:
- dahdi - userland libraries and utilities - dahdi-kmod - kernel modules dahdi port can be packaged and this allows asterisk package (that depends on dahdi) to be built as well.
-rw-r--r--misc/Makefile1
-rw-r--r--misc/dahdi-kmod/Makefile35
-rw-r--r--misc/dahdi-kmod/files/patch-freebsd-freebsd-dahdi-Makefile14
-rw-r--r--misc/dahdi-kmod/files/patch-tools-Makefile24
-rw-r--r--misc/dahdi-kmod/pkg-plist24
-rw-r--r--misc/dahdi/Makefile82
-rw-r--r--misc/dahdi/distinfo14
-rw-r--r--misc/dahdi/files/dahdi.in81
-rw-r--r--misc/dahdi/files/patch-bchan170
-rw-r--r--misc/dahdi/files/patch-freebsd-include-dahdi-compat-bsd.h14
-rw-r--r--misc/dahdi/files/patch-oslec29
-rw-r--r--misc/dahdi/files/patch-tools-Makefile4
-rw-r--r--misc/dahdi/files/patch-zaphfc883
-rw-r--r--misc/dahdi/pkg-plist30
14 files changed, 40 insertions, 1365 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 4ddb9b266d7c..ca229297d94c 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -61,6 +61,7 @@
SUBDIR += cuecat
SUBDIR += cwish
SUBDIR += dahdi
+ SUBDIR += dahdi-kmod
SUBDIR += datedif
SUBDIR += ddate
SUBDIR += deco
diff --git a/misc/dahdi-kmod/Makefile b/misc/dahdi-kmod/Makefile
index 1104fda4a577..a9777d06df65 100644
--- a/misc/dahdi-kmod/Makefile
+++ b/misc/dahdi-kmod/Makefile
@@ -5,14 +5,14 @@
# $FreeBSD$
#
-PORTNAME= dahdi
+PORTNAME= dahdi-kmod
PORTVERSION= ${DAHDI_VERSION:S/-//g}
-PORTREVISION= 4
+PORTREVISION= 0
CATEGORIES= misc kld
MASTER_SITES= ${MASTER_SITE_LOCAL}\
http://downloads.digium.com/pub/telephony/firmware/releases/:firmware
MASTER_SITE_SUBDIR= fjoe
-DISTNAME= ${PORTNAME}-freebsd-complete-${DAHDI_VERSION}+${DAHDI_TOOLS_VERSION}
+DISTNAME= dahdi-freebsd-complete-${DAHDI_VERSION}+${DAHDI_TOOLS_VERSION}
DISTFILES= ${DISTNAME}${EXTRACT_SUFX}\
oslec-linux-${OSLEC_VERSION}${EXTRACT_SUFX}\
zaphfc-${ZAPHFC_VERSION}${EXTRACT_SUFX}
@@ -20,8 +20,7 @@ DISTFILES= ${DISTNAME}${EXTRACT_SUFX}\
MAINTAINER= fjoe@FreeBSD.org
COMMENT= Digium/Asterisk Hardware Device Interface
-BUILD_DEPENDS= gmake:${PORTSDIR}/devel/gmake
-LIB_DEPENDS= newt.52:${PORTSDIR}/devel/newt
+RUN_DEPENDS= ${LOCALBASE}/sbin/dahdi_cfg:${PORTSDIR}/misc/dahdi
DAHDI_VERSION= 2.4.0-rc5
DAHDI_TOOLS_VERSION= 2.4.0-rc1
@@ -37,12 +36,11 @@ VPMADT032_NAME= dahdi-fwload-vpmadt032
VPMADT032_DIR= dahdi_vpmadt032_loader
VPMADT032_VERSION= 1.25.0
+WRKSRC= ${WRKDIR}/${DISTNAME}/freebsd
EXTRA_PATCHES= ${WRKDIR}/zaphfc-${ZAPHFC_VERSION}
+PATCH_STRIP= -p1
+MAKEFILE= BSDmakefile
NO_PACKAGE= Should be in sync with the kernel to work correctly
-GNU_CONFIGURE= yes
-CONFIGURE_ARGS= --with-dahdi=../freebsd --sysconfdir=${PREFIX}/etc --with-newt=${LOCALBASE}
-CONFIGURE_ENV= WGET=/usr/bin/fetch
-USE_LDCONFIG= yes
USE_RC_SUBR= dahdi
MAKE_ARGS= ADDITIONAL_DRIVERS="wcb1xxp" NO_FETCH=yes
GROUPS= dahdi
@@ -50,13 +48,6 @@ GROUPS= dahdi
ONLY_FOR_ARCHS= i386 amd64 sparc64
CONFLICTS= zaptel-[0-9]*
-MAN8= dahdi_cfg.8\
- dahdi_monitor.8\
- dahdi_scan.8\
- dahdi_test.8\
- dahdi_tool.8\
- fxotune.8
-
.include <bsd.port.pre.mk>
.if ${OSVERSION} < 703000 || (${OSVERSION} >= 800000 && ${OSVERSION} < 800108)
@@ -85,17 +76,11 @@ pre-everything::
fi
post-extract:
- @${LN} -s ../../../linux-${OSLEC_VERSION}/drivers/staging ${WRKSRC}/freebsd/drivers
- @${REINPLACE_CMD} -E -e 's,(new|old)/,freebsd/,g' ${WRKDIR}/zaphfc-${ZAPHFC_VERSION}
+ @${LN} -s ../../../linux-${OSLEC_VERSION}/drivers/staging ${WRKSRC}/drivers
.for _f in ${FIRMWARES}
- ${CP} ${DISTDIR}/${${_f}_DISTFILE} ${WRKSRC}/freebsd/freebsd/${${_f}_DIR}
+ ${CP} ${DISTDIR}/${${_f}_DISTFILE} ${WRKSRC}/freebsd/${${_f}_DIR}
.endfor
-post-patch:
- @${REINPLACE_CMD} -e 's,/etc,${PREFIX}/etc,g'\
- ${WRKSRC}/tools/dahdi_cfg.c ${WRKSRC}/tools/fxotune.c\
- ${WRKSRC}/tools/doc/dahdi_cfg.8 ${WRKSRC}/tools/doc/fxotune.8
-
pre-su-install:
@${MKDIR} ${PREFIX}/lib/dahdi
@@ -104,7 +89,7 @@ post-install:
fw-versions: extract
.for _v in ${FIRMWARES:=_VERSION}
- @${ECHO_CMD} "${_v}=`${MAKE} -V ${_v} -f ${WRKSRC}/freebsd/firmware.mk`"
+ @${ECHO_CMD} "${_v}=`${MAKE} -V ${_v} -f ${WRKSRC}/firmware.mk`"
.endfor
.include <bsd.port.post.mk>
diff --git a/misc/dahdi-kmod/files/patch-freebsd-freebsd-dahdi-Makefile b/misc/dahdi-kmod/files/patch-freebsd-freebsd-dahdi-Makefile
new file mode 100644
index 000000000000..69250ba41d57
--- /dev/null
+++ b/misc/dahdi-kmod/files/patch-freebsd-freebsd-dahdi-Makefile
@@ -0,0 +1,14 @@
+--- freebsd/freebsd/dahdi/Makefile.orig 2011-04-19 00:31:03.000000000 +0700
++++ freebsd/freebsd/dahdi/Makefile 2011-04-19 00:31:29.000000000 +0700
+@@ -14,11 +14,5 @@
+ @if ! cmp -s ${.TARGET}.tmp ${.TARGET}; then echo "Updating ${.TARGET}"; mv ${.TARGET}.tmp ${.TARGET}; fi
+ @rm -f ${.TARGET}.tmp
+
+-afterinstall:
+- ${MKDIR} ${PREFIX}/include/dahdi/compat
+-.for _h in ${INCS}
+- ${INSTALL_DATA} ${INCLUDEDIR}/dahdi/${_h} ${PREFIX}/include/dahdi/${_h:H}
+-.endfor
+-
+ .include <bsd.kmod.mk>
+ .include <bsd.own.mk>
diff --git a/misc/dahdi-kmod/files/patch-tools-Makefile b/misc/dahdi-kmod/files/patch-tools-Makefile
deleted file mode 100644
index 48028dd64066..000000000000
--- a/misc/dahdi-kmod/files/patch-tools-Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
---- tools/Makefile.orig 2010-04-01 22:45:47.000000000 +0700
-+++ tools/Makefile 2010-06-01 17:18:37.000000000 +0700
-@@ -27,7 +27,7 @@
- endif
-
- SUBDIRS_UTILS_ALL:= ppp
--SUBDIRS_UTILS := xpp
-+#SUBDIRS_UTILS := xpp
-
- OPTFLAGS=-O2
- CFLAGS+=-I. $(OPTFLAGS) -g -fPIC -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
-@@ -229,10 +229,8 @@
- install -d $(DESTDIR)$(MAN_DIR)
- install -m 644 $(MAN_PAGES) $(DESTDIR)$(MAN_DIR)/
- endif
--ifeq (,$(wildcard $(DESTDIR)$(CONFIG_FILE)))
-- $(INSTALL) -d $(DESTDIR)$(CONFIG_DIR)
-- $(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE)
--endif
-+ $(INSTALL) -d -m 755 $(DESTDIR)$(CONFIG_DIR)
-+ $(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE).sample
-
- install-libs: libs
- $(INSTALL) -d -m 755 $(DESTDIR)/$(LIB_DIR)
diff --git a/misc/dahdi-kmod/pkg-plist b/misc/dahdi-kmod/pkg-plist
index 13f5f6ee148b..9c95ae1806c2 100644
--- a/misc/dahdi-kmod/pkg-plist
+++ b/misc/dahdi-kmod/pkg-plist
@@ -1,8 +1,3 @@
-etc/dahdi/system.conf.sample
-include/dahdi/compat/types.h
-include/dahdi/tonezone.h
-include/dahdi/user.h
-include/dahdi/wctdm_user.h
lib/dahdi/dahdi-fw-hx8.bin.ko
lib/dahdi/dahdi-fw-oct6114-064.bin.ko
lib/dahdi/dahdi-fw-oct6114-128.bin.ko
@@ -14,8 +9,8 @@ lib/dahdi/dahdi_dynamic_ethmf.ko
lib/dahdi/dahdi_dynamic_loc.ko
lib/dahdi/dahdi_echocan_jpah.ko
lib/dahdi/dahdi_echocan_kb1.ko
-lib/dahdi/dahdi_echocan_oslec.ko
lib/dahdi/dahdi_echocan_mg2.ko
+lib/dahdi/dahdi_echocan_oslec.ko
lib/dahdi/dahdi_echocan_sec.ko
lib/dahdi/dahdi_echocan_sec2.ko
lib/dahdi/dahdi_transcode.ko
@@ -32,21 +27,4 @@ lib/dahdi/wctdm.ko
lib/dahdi/wctdm24xxp.ko
lib/dahdi/wcte11xp.ko
lib/dahdi/wcte12xp.ko
-lib/libtonezone.a
-lib/libtonezone.so
-lib/libtonezone.so.1
-lib/libtonezone.so.1.0
-lib/libtonezone.so.2
-lib/libtonezone.so.2.0
-sbin/dahdi_cfg
-sbin/dahdi_maint
-sbin/dahdi_monitor
-sbin/dahdi_scan
-sbin/dahdi_speed
-sbin/dahdi_test
-sbin/dahdi_tool
-sbin/fxotune
@dirrm lib/dahdi
-@dirrm include/dahdi/compat
-@dirrm include/dahdi
-@dirrmtry etc/dahdi
diff --git a/misc/dahdi/Makefile b/misc/dahdi/Makefile
index 1104fda4a577..15726b36b7cd 100644
--- a/misc/dahdi/Makefile
+++ b/misc/dahdi/Makefile
@@ -7,47 +7,28 @@
PORTNAME= dahdi
PORTVERSION= ${DAHDI_VERSION:S/-//g}
-PORTREVISION= 4
-CATEGORIES= misc kld
+PORTREVISION= 5
+CATEGORIES= misc
MASTER_SITES= ${MASTER_SITE_LOCAL}\
http://downloads.digium.com/pub/telephony/firmware/releases/:firmware
MASTER_SITE_SUBDIR= fjoe
DISTNAME= ${PORTNAME}-freebsd-complete-${DAHDI_VERSION}+${DAHDI_TOOLS_VERSION}
-DISTFILES= ${DISTNAME}${EXTRACT_SUFX}\
- oslec-linux-${OSLEC_VERSION}${EXTRACT_SUFX}\
- zaphfc-${ZAPHFC_VERSION}${EXTRACT_SUFX}
MAINTAINER= fjoe@FreeBSD.org
-COMMENT= Digium/Asterisk Hardware Device Interface
+COMMENT= DAHDI userland utilities and libraries
-BUILD_DEPENDS= gmake:${PORTSDIR}/devel/gmake
LIB_DEPENDS= newt.52:${PORTSDIR}/devel/newt
DAHDI_VERSION= 2.4.0-rc5
DAHDI_TOOLS_VERSION= 2.4.0-rc1
-OSLEC_VERSION= 2.6.35.4
-ZAPHFC_VERSION= r5
-FIRMWARES= OCT6114_064 OCT6114_128 TC400M HX8 ${_vpmadt032}
-OCT6114_064_VERSION= 1.05.01
-OCT6114_128_VERSION= 1.05.01
-TC400M_VERSION= MR6.12
-HX8_VERSION= 2.06
-VPMADT032_NAME= dahdi-fwload-vpmadt032
-VPMADT032_DIR= dahdi_vpmadt032_loader
-VPMADT032_VERSION= 1.25.0
-
-EXTRA_PATCHES= ${WRKDIR}/zaphfc-${ZAPHFC_VERSION}
-NO_PACKAGE= Should be in sync with the kernel to work correctly
GNU_CONFIGURE= yes
+USE_GMAKE= yes
CONFIGURE_ARGS= --with-dahdi=../freebsd --sysconfdir=${PREFIX}/etc --with-newt=${LOCALBASE}
CONFIGURE_ENV= WGET=/usr/bin/fetch
+WRKSRC= ${WRKDIR}/${DISTNAME}/tools
USE_LDCONFIG= yes
-USE_RC_SUBR= dahdi
-MAKE_ARGS= ADDITIONAL_DRIVERS="wcb1xxp" NO_FETCH=yes
-GROUPS= dahdi
-ONLY_FOR_ARCHS= i386 amd64 sparc64
CONFLICTS= zaptel-[0-9]*
MAN8= dahdi_cfg.8\
@@ -57,54 +38,15 @@ MAN8= dahdi_cfg.8\
dahdi_tool.8\
fxotune.8
-.include <bsd.port.pre.mk>
-
-.if ${OSVERSION} < 703000 || (${OSVERSION} >= 800000 && ${OSVERSION} < 800108)
-IGNORE= requires firmware(9) support for kernel modules with hyphens
-.endif
-
-.if ${ARCH} == "i386" || ${ARCH} == "amd64"
-PLIST_SUB+= X86=""
-_vpmadt032= VPMADT032
-.else
-PLIST_SUB+= X86="@comment "
-.endif
-
-.for _f in ${FIRMWARES}
-${_f}_NAME?= dahdi-fw-${_f:L:S/_/-/g}
-${_f}_DIR?= ${${_f}_NAME}.bin
-${_f}_DISTFILE= ${${_f}_NAME}-${${_f}_VERSION}.tar.gz
-DISTFILES+= ${${_f}_DISTFILE}:firmware
-.endfor
-
-pre-everything::
- @if [ ! -f /usr/src/sys/Makefile ]; then \
- ${ECHO_MSG} ">> The dahdi port needs FreeBSD kernel source code to compile."; \
- ${ECHO_MSG} ">> Please install FreeBSD kernel source code in /usr/src/sys."; \
- ${FALSE}; \
- fi
-
-post-extract:
- @${LN} -s ../../../linux-${OSLEC_VERSION}/drivers/staging ${WRKSRC}/freebsd/drivers
- @${REINPLACE_CMD} -E -e 's,(new|old)/,freebsd/,g' ${WRKDIR}/zaphfc-${ZAPHFC_VERSION}
-.for _f in ${FIRMWARES}
- ${CP} ${DISTDIR}/${${_f}_DISTFILE} ${WRKSRC}/freebsd/freebsd/${${_f}_DIR}
-.endfor
-
post-patch:
@${REINPLACE_CMD} -e 's,/etc,${PREFIX}/etc,g'\
- ${WRKSRC}/tools/dahdi_cfg.c ${WRKSRC}/tools/fxotune.c\
- ${WRKSRC}/tools/doc/dahdi_cfg.8 ${WRKSRC}/tools/doc/fxotune.8
-
-pre-su-install:
- @${MKDIR} ${PREFIX}/lib/dahdi
+ ${WRKSRC}/dahdi_cfg.c ${WRKSRC}/fxotune.c\
+ ${WRKSRC}/doc/dahdi_cfg.8 ${WRKSRC}/doc/fxotune.8
post-install:
- @${TOUCH} ${PREFIX}/lib/dahdi/linker.hints
-
-fw-versions: extract
-.for _v in ${FIRMWARES:=_VERSION}
- @${ECHO_CMD} "${_v}=`${MAKE} -V ${_v} -f ${WRKSRC}/freebsd/firmware.mk`"
-.endfor
+ @${MKDIR} ${PREFIX}/include/dahdi/compat
+ @for i in `${MAKE} -C ${WRKSRC}/../freebsd/freebsd/dahdi -V INCS`; do\
+ ${INSTALL_DATA} ${WRKSRC}/../freebsd/include/dahdi/$$i ${PREFIX}/include/dahdi/$$i;\
+ done
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/misc/dahdi/distinfo b/misc/dahdi/distinfo
index bca62c47438e..9edc54101f1d 100644
--- a/misc/dahdi/distinfo
+++ b/misc/dahdi/distinfo
@@ -1,16 +1,2 @@
SHA256 (dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1.tar.gz) = f364a13d10aa67ac26eb68babfcd4aa2a789f6ce074a923e20192f12fa02e3d2
SIZE (dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1.tar.gz) = 2049189
-SHA256 (oslec-linux-2.6.35.4.tar.gz) = 01cfaa1ca64056c822d1a3ebf4f7b3c81127cd7b308ad5b0738ff4eb2026e261
-SIZE (oslec-linux-2.6.35.4.tar.gz) = 12057
-SHA256 (zaphfc-r5.tar.gz) = 7e809b62dcc2bd3caf2e5a882390051b881eb08d37fea1733d7fb55e80bc6756
-SIZE (zaphfc-r5.tar.gz) = 15639
-SHA256 (dahdi-fw-oct6114-064-1.05.01.tar.gz) = 56bac1f2024c76ecf9b6f40992eeea29a1fbee676bb2a37a058179bacfbb1c91
-SIZE (dahdi-fw-oct6114-064-1.05.01.tar.gz) = 165869
-SHA256 (dahdi-fw-oct6114-128-1.05.01.tar.gz) = e1146749d205c41603b9b76852c3f8104dac233d0025d700db24504d10c99775
-SIZE (dahdi-fw-oct6114-128-1.05.01.tar.gz) = 165849
-SHA256 (dahdi-fw-tc400m-MR6.12.tar.gz) = 11dd8d009809e41fc9a3a36766f59ff73d29075eede5b8724331d9a6e5259774
-SIZE (dahdi-fw-tc400m-MR6.12.tar.gz) = 1750035
-SHA256 (dahdi-fw-hx8-2.06.tar.gz) = 449ab3fd03d55d808e999efb7677cd04de202b92c9fcb039539a7e48a39a80f5
-SIZE (dahdi-fw-hx8-2.06.tar.gz) = 29252
-SHA256 (dahdi-fwload-vpmadt032-1.25.0.tar.gz) = 3ff26cf80555fd7470b43a87c51d03c1db2a75abcd4561d79f69b6c48298e4a1
-SIZE (dahdi-fwload-vpmadt032-1.25.0.tar.gz) = 149360
diff --git a/misc/dahdi/files/dahdi.in b/misc/dahdi/files/dahdi.in
deleted file mode 100644
index 484dd24eeee3..000000000000
--- a/misc/dahdi/files/dahdi.in
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-# PROVIDE: dahdi
-# REQUIRE: NETWORKING
-# KEYWORD: shutdown
-# BEFORE: asterisk
-#
-# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
-# to enable this service:
-#
-# dahdi_enable (bool): YES/NO (default: NO)
-# dahdi_modules (list of strings): dahdi modules to load at boot (default: dahdi)
-#
-# Valid modules are:
-# - dahdi
-# - dahdi_transcode
-# - wcb4xxp
-# - wcfxo
-# - wct4xxp
-# - wctc4xxp
-# - wctdm
-# - wctdm24xxp
-# - wcte11xp
-# - wcte12xp
-#
-# Example:
-#
-# dahdi_enable="YES"
-# dahdi_modules="wct4xxp"
-#
-
-. /etc/rc.subr
-
-name="dahdi"
-rcvar=`set_rcvar`
-
-start_cmd="dahdi_start"
-stop_cmd="dahdi_stop"
-load_rc_config $name
-: ${dahdi_enable="NO"}
-: ${dahdi_modules="dahdi"}
-
-kmod_dir=%%PREFIX%%/lib/dahdi
-# reverse list
-dahdi_modules_unload=""
-for m in ${dahdi_modules}; do
- dahdi_modules_unload="$m ${dahdi_modules_unload}"
-done
-
-dahdi_start()
-{
- echo "Starting ${name}."
-
- # load kernel modules
- kldconfig -mf ${kmod_dir}
- for m in ${dahdi_modules}; do
- kldload $m || exit 1
- done
-
- # configure devfs
- devfs rule apply path 'dahdi/*' mode 0664 user root group dahdi
-
- # run configuration utilities
- %%PREFIX%%/sbin/dahdi_cfg
- if [ -r %%PREFIX%%/etc/fxotune.conf ]; then
- echo "Starting fxotune."
- %%PREFIX%%/sbin/fxotune -s
- fi
-}
-
-dahdi_stop()
-{
- echo -n " ${name}"
- for m in ${dahdi_modules_unload}; do
- kldunload $m
- done
-}
-
-run_rc_command "$1"
diff --git a/misc/dahdi/files/patch-bchan b/misc/dahdi/files/patch-bchan
deleted file mode 100644
index 4aa35a8b8163..000000000000
--- a/misc/dahdi/files/patch-bchan
+++ /dev/null
@@ -1,170 +0,0 @@
-# Translate the D channels to a standard channel data.
-# The HFC chipset provides us the D channel as data, but
-# Zaptel expects it as a standard channel with 1000 samples
-# per second.
-
-Index: freebsd/include/dahdi/dahdi_config.h
-===================================================================
---- freebsd/include/dahdi/dahdi_config.h (revision 8781)
-+++ freebsd/include/dahdi/dahdi_config.h (working copy)
-@@ -180,7 +180,13 @@
- */
- /* #define OPTIMIZE_CHANMUTE */
-
-+/*
-+ * Uncomment the following for BRI D channels
-+ *
-+ */
-+#define CONFIG_DAHDI_BRI_DCHANS
-
-+
- /*
- * Pass DAHDI_AUDIOMODE to channel driver as well
- */
-Index: freebsd/include/dahdi/kernel.h
-===================================================================
---- freebsd/include/dahdi/kernel.h (revision 8781)
-+++ freebsd/include/dahdi/kernel.h (working copy)
-@@ -426,6 +426,13 @@
- int statcount;
- int lastnumbufs;
- #endif
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ int bytes2receive;
-+ int maxbytes2transmit; /* size of the tx buffer in the card driver */
-+ int bytes2transmit;
-+ int eofrx;
-+ int eoftx;
-+#endif
- spinlock_t lock;
- char name[40];
- /* Specified by DAHDI */
-@@ -738,6 +745,9 @@
- DAHDI_FLAGBIT_LOOPED = 18, /*!< Loopback the receive data from the channel to the transmit */
- DAHDI_FLAGBIT_MTP2 = 19, /*!< Repeats last message in buffer and also discards repeating messages sent to us */
- DAHDI_FLAGBIT_HDLC56 = 20, /*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K */
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ DAHDI_FLAGBIT_BRIDCHAN = 21, /*!< hardhdlc-like handling of the D channel */
-+#endif
- };
-
- struct dahdi_count {
-@@ -788,6 +798,7 @@
- #define DAHDI_FLAG_LOOPED DAHDI_FLAG(LOOPED)
- #define DAHDI_FLAG_MTP2 DAHDI_FLAG(MTP2)
- #define DAHDI_FLAG_HDLC56 DAHDI_FLAG(HDLC56)
-+#define DAHDI_FLAG_BRIDCHAN DAHDI_FLAG(BRIDCHAN)
-
- struct dahdi_span {
- spinlock_t lock;
-Index: freebsd/drivers/dahdi/dahdi-base.c
-===================================================================
---- freebsd/drivers/dahdi/dahdi-base.c (revision 8860)
-+++ freebsd/drivers/dahdi/dahdi-base.c (working copy)
-@@ -6884,11 +6881,40 @@
- *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
- }
- bytes -= left;
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ /*
-+ * Let's get this right, we want to transmit complete frames only.
-+ * The card driver will do the dirty HDLC work for us.
-+ * txb (transmit buffer) is supposed to be big enough to store one frame
-+ * we will make this as big as the D fifo (1KB or 2KB)
-+ */
-+
-+ /* there are 'left' bytes in the user buffer left to transmit */
-+ left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
-+ if (left > ms->maxbytes2transmit) {
-+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
-+ ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
-+ txb += ms->maxbytes2transmit;
-+ ms->bytes2transmit = ms->maxbytes2transmit;
-+ ms->eoftx = 0;
-+ } else {
-+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
-+ ms->writeidx[ms->outwritebuf] += left + 2;
-+ txb += left + 2;
-+ ms->bytes2transmit = left;
-+ ms->eoftx = 1;
-+ }
-+ bytes = 0;
-+#endif
- } else {
- memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
- ms->writeidx[ms->outwritebuf]+=left;
- txb += left;
- bytes -= left;
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ ms->bytes2transmit=DAHDI_CHUNKSIZE;
-+#endif
- }
- /* Check buffer status */
- if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
-@@ -6947,6 +6973,17 @@
- /* Transmit a flag if this is an HDLC channel */
- if (ms->flags & DAHDI_FLAG_HDLC)
- fasthdlc_tx_frame_nocheck(&ms->txhdlc);
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ // if (ms->bytes2transmit > 0) {
-+ // txb += 2;
-+ // ms->bytes2transmit -= 2;
-+ bytes=0;
-+ ms->eoftx = 1;
-+// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
-+ // }
-+ }
-+#endif
- #ifdef CONFIG_DAHDI_NET
- if (ms->flags & DAHDI_FLAG_NETDEV)
- netif_wake_queue(ztchan_to_dev(ms));
-@@ -7007,6 +7044,12 @@
- memset(txb, 0xFF, bytes);
- }
- bytes = 0;
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ ms->bytes2transmit = 0;
-+ ms->eoftx = 0;
-+ bytes = 0;
-+#endif
- } else {
- memset(txb, DAHDI_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
- bytes = 0;
-@@ -7905,6 +7948,14 @@
- int left, x;
-
-
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ bytes = ms->bytes2receive;
-+ if (bytes < 1) return;
-+// printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
-+ }
-+#endif
-+
- while(bytes) {
- #if defined(CONFIG_DAHDI_NET) || defined(CONFIG_DAHDI_PPP)
- skb = NULL;
-@@ -7962,6 +8013,19 @@
- }
- }
- }
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
-+ rxb += left;
-+ ms->readidx[ms->inreadbuf] += left;
-+ bytes -= left;
-+ if (ms->eofrx == 1) {
-+ eof=1;
-+ }
-+// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
-+ ms->bytes2receive = 0;
-+ ms->eofrx = 0;
-+#endif
- } else {
- /* Not HDLC */
- memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
diff --git a/misc/dahdi/files/patch-freebsd-include-dahdi-compat-bsd.h b/misc/dahdi/files/patch-freebsd-include-dahdi-compat-bsd.h
deleted file mode 100644
index 0f95e4444217..000000000000
--- a/misc/dahdi/files/patch-freebsd-include-dahdi-compat-bsd.h
+++ /dev/null
@@ -1,14 +0,0 @@
---- freebsd/include/dahdi/compat/bsd.h.orig 2010-10-05 23:41:23.000000000 +0700
-+++ freebsd/include/dahdi/compat/bsd.h 2010-10-05 23:42:01.000000000 +0700
-@@ -66,9 +66,11 @@
- #define __be32 u_int32_t
-
- #if _BYTE_ORDER == _LITTLE_ENDIAN
-+#define __LITTLE_ENDIAN
- #define __LITTLE_ENDIAN_BITFIELD
- #define __constant_htons(x) ((uint16_t) (((uint16_t) (x)) << 8 | ((uint16_t) (x)) >> 8))
- #elif _BYTE_ORDER == _BIG_ENDIAN
-+#define __BIG_ENDIAN
- #define __BIG_ENDIAN_BITFIELD
- #define __constant_htons(x) (x)
- #endif
diff --git a/misc/dahdi/files/patch-oslec b/misc/dahdi/files/patch-oslec
deleted file mode 100644
index 56eb68b89584..000000000000
--- a/misc/dahdi/files/patch-oslec
+++ /dev/null
@@ -1,29 +0,0 @@
-diff -ru freebsd/drivers/staging/echo/echo.c.orig freebsd/drivers/staging/echo/echo.c.orig
---- freebsd/drivers/staging/echo/echo.c.orig 2010-08-27 06:47:12.000000000 +0700
-+++ freebsd/drivers/staging/echo/echo.c 2010-08-31 14:45:48.000000000 +0700
-@@ -102,9 +102,15 @@
- Mark, Pawel, and Pavel.
- */
-
-+#if defined(__FreeBSD__)
-+#include <sys/types.h>
-+#include <sys/libkern.h>
-+#include <dahdi/compat/bsd.h>
-+#else
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/slab.h>
-+#endif /* !__FreeBSD__ */
-
- #include "echo.h"
-
-@@ -656,7 +662,9 @@
- }
- EXPORT_SYMBOL_GPL(oslec_hpf_tx);
-
-+#if !defined(__FreeBSD__)
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("David Rowe");
- MODULE_DESCRIPTION("Open Source Line Echo Canceller");
- MODULE_VERSION("0.3.0");
-+#endif /* !__FreeBSD__ */
diff --git a/misc/dahdi/files/patch-tools-Makefile b/misc/dahdi/files/patch-tools-Makefile
index 48028dd64066..44ce633fbd29 100644
--- a/misc/dahdi/files/patch-tools-Makefile
+++ b/misc/dahdi/files/patch-tools-Makefile
@@ -1,5 +1,5 @@
---- tools/Makefile.orig 2010-04-01 22:45:47.000000000 +0700
-+++ tools/Makefile 2010-06-01 17:18:37.000000000 +0700
+--- Makefile.orig 2010-04-01 22:45:47.000000000 +0700
++++ Makefile 2010-06-01 17:18:37.000000000 +0700
@@ -27,7 +27,7 @@
endif
diff --git a/misc/dahdi/files/patch-zaphfc b/misc/dahdi/files/patch-zaphfc
deleted file mode 100644
index fd8b72d1bca2..000000000000
--- a/misc/dahdi/files/patch-zaphfc
+++ /dev/null
@@ -1,883 +0,0 @@
-diff -ruN freebsd/drivers/dahdi/zaphfc.orig/base.c freebsd/drivers/dahdi/zaphfc/base.c
---- freebsd/drivers/dahdi/zaphfc.orig/base.c 2010-09-01 00:55:30.000000000 +0700
-+++ freebsd/drivers/dahdi/zaphfc/base.c 2010-09-02 19:19:45.000000000 +0700
-@@ -23,6 +23,50 @@
- * Please read the README file for important infos.
- */
-
-+#if defined(__FreeBSD__)
-+#include <sys/types.h>
-+#include <sys/bus.h>
-+#include <sys/module.h>
-+#include <dev/pci/pcireg.h>
-+#include <dev/pci/pcivar.h>
-+
-+#define PCI_VENDOR_ID_CCD 0x1397
-+
-+#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
-+#define PCI_DEVICE_ID_CCD_B000 0xb000
-+#define PCI_DEVICE_ID_CCD_B006 0xb006
-+#define PCI_DEVICE_ID_CCD_B007 0xb007
-+#define PCI_DEVICE_ID_CCD_B008 0xb008
-+#define PCI_DEVICE_ID_CCD_B009 0xb009
-+#define PCI_DEVICE_ID_CCD_B00A 0xb00a
-+#define PCI_DEVICE_ID_CCD_B00B 0xb00b
-+#define PCI_DEVICE_ID_CCD_B00C 0xb00c
-+#define PCI_DEVICE_ID_CCD_B100 0xb100
-+
-+#define PCI_VENDOR_ID_ABOCOM 0x13D1
-+#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1
-+
-+#define PCI_VENDOR_ID_ANIGMA 0x1051
-+#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100
-+
-+#define PCI_VENDOR_ID_ASUSTEK 0x1043
-+#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675
-+
-+#define PCI_VENDOR_ID_BERKOM 0x0871
-+#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1
-+#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2
-+
-+#define PCI_VENDOR_ID_DIGI 0x114f
-+#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070
-+#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
-+#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
-+#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073
-+
-+#define PCI_VENDOR_ID_ZOLTRIX 0x15b0
-+#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
-+
-+#define set_current_state(x)
-+#else /* !__FreeBSD__ */
- #include <linux/spinlock.h>
- #include <linux/init.h>
- #include <linux/pci.h>
-@@ -34,14 +78,13 @@
- #include <linux/delay.h>
- #include <linux/proc_fs.h>
- #include <linux/if_arp.h>
-+#endif /* !__FreeBSD__ */
-
- #include <dahdi/kernel.h>
-
- #include "zaphfc.h"
- #include "fifo.h"
-
--#if CONFIG_PCI
--
- #define DAHDI_B1 0
- #define DAHDI_B2 1
- #define DAHDI_D 2
-@@ -57,7 +100,9 @@
- static int nt_modes[hfc_MAX_BOARDS];
- static int nt_modes_count;
- static int force_l1_up;
-+#if !defined(__FreeBSD__)
- static struct proc_dir_entry *hfc_proc_zaphfc_dir;
-+#endif
-
- #ifdef DEBUG
- int debug_level;
-@@ -122,6 +167,31 @@
- {0,}
- };
-
-+#if defined(__FreeBSD__)
-+static void
-+hfc_release_resources(struct hfc_card *card)
-+{
-+ /* disconnect the interrupt handler */
-+ if (card->irq_handle != NULL) {
-+ bus_teardown_intr(card->pcidev->dev, card->irq_res, card->irq_handle);
-+ card->irq_handle = NULL;
-+ }
-+
-+ if (card->irq_res != NULL) {
-+ bus_release_resource(card->pcidev->dev, SYS_RES_IRQ, card->irq_rid, card->irq_res);
-+ card->irq_res = NULL;
-+ }
-+
-+ /* release DMA resources */
-+ dahdi_dma_free(&card->dma_tag, &card->dma_map, (void **) &card->fifos, &card->dma_addr);
-+
-+ /* release I/O range */
-+ if (card->mem_res != NULL) {
-+ bus_release_resource(card->pcidev->dev, SYS_RES_MEMORY, card->mem_rid, card->mem_res);
-+ card->mem_res = NULL;
-+ }
-+}
-+#else
- MODULE_DEVICE_TABLE(pci, hfc_pci_ids);
-
- static int __devinit hfc_probe(struct pci_dev *dev
-@@ -134,6 +204,7 @@
- .probe = hfc_probe,
- .remove = hfc_remove,
- };
-+#endif /* !__FreeBSD__ */
-
- /******************************************
- * HW routines
-@@ -418,7 +489,7 @@
-
- switch (chan->number) {
- case D:
-- if (chan->status != free &&
-+ if (chan->status != chan_free &&
- chan->status != open_framed) {
- spin_unlock(&chan->lock);
- return -EBUSY;
-@@ -428,7 +499,7 @@
-
- case B1:
- case B2:
-- if (chan->status != free) {
-+ if (chan->status != chan_free) {
- spin_unlock(&chan->lock);
- return -EBUSY;
- }
-@@ -437,7 +508,6 @@
- }
-
- chan->open_by_zaptel = TRUE;
-- try_module_get(THIS_MODULE);
- spin_unlock(&chan->lock);
-
- switch (chan->number) {
-@@ -484,7 +554,13 @@
- hfc_outb(card, hfc_SCTRL, card->regs.sctrl);
- hfc_outb(card, hfc_SCTRL_R, card->regs.sctrl_r);
-
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_update_fifo_state(card);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
-
- printk(KERN_INFO hfc_DRIVER_PREFIX
- "card %d: "
-@@ -509,12 +585,12 @@
-
- spin_lock(&chan->lock);
-
-- if (chan->status == free) {
-+ if (chan->status == chan_free) {
- spin_unlock(&chan->lock);
- return -EINVAL;
- }
-
-- chan->status = free;
-+ chan->status = chan_free;
- chan->open_by_zaptel = FALSE;
-
- spin_unlock(&chan->lock);
-@@ -538,8 +614,8 @@
- break;
- }
-
-- if (card->chans[B1].status == free &&
-- card->chans[B2].status == free)
-+ if (card->chans[B1].status == chan_free &&
-+ card->chans[B2].status == chan_free)
- card->regs.m2 &= ~hfc_M2_PROC_TRANS;
-
- hfc_outb(card, hfc_INT_M2, card->regs.m2);
-@@ -548,9 +624,13 @@
- hfc_outb(card, hfc_SCTRL, card->regs.sctrl);
- hfc_outb(card, hfc_SCTRL_R, card->regs.sctrl_r);
-
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_update_fifo_state(card);
--
-- module_put(THIS_MODULE);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
-
- printk(KERN_INFO hfc_DRIVER_PREFIX
- "card %d: "
-@@ -591,7 +671,7 @@
-
- static int hfc_zap_startup(struct dahdi_span *span)
- {
-- struct dahdi_hfc *zthfc = span->pvt;
-+ struct dahdi_hfc *zthfc = container_of(span, struct dahdi_hfc, span);
- struct hfc_card *hfctmp = zthfc->card;
- int alreadyrunning;
-
-@@ -642,6 +722,20 @@
- return 0;
- }
-
-+static const struct dahdi_span_ops hfc_zap_span_ops = {
-+ .owner = THIS_MODULE,
-+ .startup = hfc_zap_startup,
-+ .shutdown = hfc_zap_shutdown,
-+ .rbsbits = hfc_zap_rbsbits,
-+ .maint = hfc_zap_maint,
-+ .open = hfc_zap_open,
-+ .close = hfc_zap_close,
-+ .spanconfig = hfc_zap_spanconfig,
-+ .chanconfig = hfc_zap_chanconfig,
-+ .ioctl = hfc_zap_ioctl,
-+ .hdlc_hard_xmit = hfc_hdlc_hard_xmit,
-+};
-+
- static int hfc_zap_initialize(struct dahdi_hfc *hfccard)
- {
- struct hfc_card *hfctmp = hfccard->card;
-@@ -655,23 +749,14 @@
- hfctmp->nt_mode ? "NT" : "TE");
- hfccard->span.spantype = hfctmp->nt_mode ? "NT" : "TE";
- hfccard->span.manufacturer = "Cologne Chips";
-- hfccard->span.spanconfig = hfc_zap_spanconfig;
-- hfccard->span.chanconfig = hfc_zap_chanconfig;
-- hfccard->span.startup = hfc_zap_startup;
-- hfccard->span.shutdown = hfc_zap_shutdown;
-- hfccard->span.maint = hfc_zap_maint;
-- hfccard->span.rbsbits = hfc_zap_rbsbits;
-- hfccard->span.open = hfc_zap_open;
-- hfccard->span.close = hfc_zap_close;
-- hfccard->span.ioctl = hfc_zap_ioctl;
-- hfccard->span.hdlc_hard_xmit = hfc_hdlc_hard_xmit;
-+ hfccard->span.ops = &hfc_zap_span_ops;
- hfccard->span.flags = 0;
-- hfccard->span.irq = hfctmp->pcidev->irq;
-+ hfccard->span.irq = dahdi_pci_get_irq(hfctmp->pcidev);
- dahdi_copy_string(hfccard->span.devicetype, "HFC-S PCI-A ISDN",
- sizeof(hfccard->span.devicetype));
- sprintf(hfccard->span.location, "PCI Bus %02d Slot %02d",
-- hfctmp->pcidev->bus->number,
-- PCI_SLOT(hfctmp->pcidev->devfn) + 1);
-+ dahdi_pci_get_bus(hfctmp->pcidev),
-+ dahdi_pci_get_slot(hfctmp->pcidev));
- hfccard->span.chans = hfccard->_chans;
- hfccard->span.channels = 3;
- for (i = 0; i < hfccard->span.channels; i++)
-@@ -680,7 +765,6 @@
- hfccard->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS;
- hfccard->span.offset = 0;
- init_waitqueue_head(&hfccard->span.maintq);
-- hfccard->span.pvt = hfccard;
-
- for (i = 0; i < hfccard->span.channels; i++) {
- memset(&hfccard->chans[i], 0x0, sizeof(struct dahdi_chan));
-@@ -760,22 +844,20 @@
- static void hfc_frame_arrived(struct hfc_chan_duplex *chan);
- static void hfc_handle_voice(struct hfc_card *card);
-
--#if (KERNEL_VERSION(2, 6, 24) < LINUX_VERSION_CODE)
--static irqreturn_t hfc_interrupt(int irq, void *dev_id)
--#else
--static irqreturn_t hfc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
--#endif
-+DAHDI_IRQ_HANDLER(hfc_interrupt)
- {
- struct hfc_card *card = dev_id;
- unsigned long flags;
- u8 status, s1, s2;
-
-+#if !defined(__FreeBSD__)
- if (!card) {
- printk(KERN_CRIT hfc_DRIVER_PREFIX
- "spurious interrupt (IRQ %d)\n",
- irq);
- return IRQ_NONE;
- }
-+#endif /* !__FreeBSD__ */
-
- spin_lock_irqsave(&card->lock, flags);
- status = hfc_inb(card, hfc_STATUS);
-@@ -832,21 +914,40 @@
- /*
- * D chan RX (bit 5)
- */
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_frame_arrived(&card->chans[D]);
-+
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
-
- if (s1 & hfc_INTS_B1REC) {
- /*
- * B1 chan RX (bit 3)
- */
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_frame_arrived(&card->chans[B1]);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
-
- if (s1 & hfc_INTS_B2REC) {
- /*
- * B2 chan RX (bit 4)
- */
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_frame_arrived(&card->chans[B2]);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
-
- if (s1 & hfc_INTS_DTRANS) {
-@@ -940,7 +1041,13 @@
- card->regs.ctmt &= ~hfc_CTMT_TIMER_MASK;
- hfc_outb(card, hfc_CTMT, card->regs.ctmt);
-
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_resume_fifo(card);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
- }
-
-@@ -971,11 +1078,17 @@
- hfc_outb(card, hfc_STATES, hfc_STATES_LOAD_STATE | 3);
- }
-
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- if (new_state == 3 && card->l1_state != 3)
- hfc_resume_fifo(card);
-
- if (new_state != 3 && card->l1_state == 3)
- hfc_suspend_fifo(card);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
-
- } else {
- if (new_state == 3) {
-@@ -1015,7 +1128,13 @@
- /*
- * TE has become inactive, disable FIFO
- */
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- hfc_suspend_fifo(card);
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
- }
-
-@@ -1040,6 +1159,9 @@
- available_bytes >= DAHDI_CHUNKSIZE + hfc_RX_FIFO_PRELOAD) {
- card->ticks = 0;
-
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_POSTREAD);
-+#endif
- if (available_bytes > DAHDI_CHUNKSIZE*2 + hfc_RX_FIFO_PRELOAD) {
- card->late_irqs++;
- /*
-@@ -1064,6 +1186,9 @@
- } else {
- hfc_handle_voice(card);
- }
-+#if defined(__FreeBSD__)
-+ bus_dmamap_sync(card->dma_tag, card->dma_map, BUS_DMASYNC_PREWRITE);
-+#endif
- }
-
- card->ticks++;
-@@ -1179,7 +1304,9 @@
- {
- struct hfc_card *card = chan->card;
- int antiloop = 16;
-+#if !defined(__FreeBSD__)
- struct sk_buff *skb;
-+#endif
-
- while (hfc_fifo_has_frames(&chan->rx) && --antiloop) {
- int frame_size = hfc_fifo_get_frame_size(&chan->rx);
-@@ -1229,6 +1356,7 @@
- break;
- }
-
-+#if !defined(__FreeBSD__)
- skb = dev_alloc_skb(frame_size - 3);
-
- if (!skb) {
-@@ -1254,6 +1382,7 @@
- #else
- skb->ip_summed = CHECKSUM_HW;
- #endif
-+#endif /* !__FreeBSD__ */
-
- if (chan->open_by_zaptel) {
- card->chans[D].rx.ugly_framebuf_size = frame_size - 1;
-@@ -1261,20 +1390,26 @@
- if (hfc_fifo_get_frame(&card->chans[D].rx,
- card->chans[D].rx.ugly_framebuf,
- frame_size - 1) == -1) {
-+#if !defined(__FreeBSD__)
- dev_kfree_skb(skb);
-+#endif
- continue;
- }
-
-+#if !defined(__FreeBSD__)
- memcpy(skb_put(skb, frame_size - 3),
- card->chans[D].rx.ugly_framebuf,
- frame_size - 3);
-+#endif
- } else {
-+#if !defined(__FreeBSD__)
- if (hfc_fifo_get_frame(&chan->rx,
- skb_put(skb, frame_size - 3),
- frame_size - 3) == -1) {
- dev_kfree_skb(skb);
- continue;
- }
-+#endif
- }
- }
-
-@@ -1289,8 +1424,12 @@
- * Module initialization and cleanup
- ******************************************/
-
-+#if defined(__FreeBSD__)
-+static int hfc_probe(device_t dev)
-+#else
- static int __devinit hfc_probe(struct pci_dev *pci_dev,
- const struct pci_device_id *ent)
-+#endif
- {
- static int cardnum;
- int err;
-@@ -1298,6 +1437,12 @@
-
- struct hfc_card *card = NULL;
- struct dahdi_hfc *zthfc = NULL;
-+
-+#if defined(__FreeBSD__)
-+ card = device_get_softc(dev);
-+ card->pcidev = &card->_dev;
-+ card->pcidev->dev = dev;
-+#else
- card = kmalloc(sizeof(struct hfc_card), GFP_KERNEL);
- if (!card) {
- printk(KERN_CRIT hfc_DRIVER_PREFIX
-@@ -1307,10 +1452,48 @@
- }
-
- memset(card, 0x00, sizeof(struct hfc_card));
-- card->cardnum = cardnum;
- card->pcidev = pci_dev;
-+#endif /* !__FreeBSD__ */
-+ card->cardnum = cardnum;
- spin_lock_init(&card->lock);
-
-+#if defined(__FreeBSD__)
-+ /* allocate IO resource */
-+ card->mem_rid = PCIR_BAR(1);
-+ card->mem_res = bus_alloc_resource_any(card->pcidev->dev, SYS_RES_MEMORY, &card->mem_rid, RF_ACTIVE);
-+ if (card->mem_res == NULL) {
-+ device_printf(dev, "Can't allocate memory resource\n");
-+ err = -ENXIO;
-+ goto err_pci_request_regions;
-+ }
-+
-+ /* enable bus mastering */
-+ pci_enable_busmaster(dev);
-+
-+ /* allocate DMA memory */
-+ err = dahdi_dma_allocate(card->pcidev->dev, hfc_FIFO_SIZE, &card->dma_tag, &card->dma_map,
-+ (void **) &card->fifos, &card->dma_addr);
-+ if (err)
-+ goto err_alloc_fifo;
-+
-+ /* setup interrupt */
-+ card->irq_res = bus_alloc_resource_any(
-+ card->pcidev->dev, SYS_RES_IRQ, &card->irq_rid, RF_SHAREABLE | RF_ACTIVE);
-+ if (card->irq_res == NULL) {
-+ device_printf(card->pcidev->dev, "Can't allocate irq resource\n");
-+ err = -ENXIO;
-+ goto err_request_irq;
-+ }
-+
-+ err = bus_setup_intr(
-+ card->pcidev->dev, card->irq_res, INTR_TYPE_CLK | INTR_MPSAFE,
-+ hfc_interrupt, NULL, card, &card->irq_handle);
-+ if (err) {
-+ device_printf(card->pcidev->dev, "Can't setup interrupt handler (error %d)\n", err);
-+ err = -ENXIO;
-+ goto err_request_irq;
-+ }
-+#else
- pci_set_drvdata(pci_dev, card);
-
- err = pci_enable_device(pci_dev);
-@@ -1403,6 +1586,7 @@
- card->cardnum);
- goto err_request_irq;
- }
-+#endif /* !__FreeBSD__ */
-
- card->nt_mode = FALSE;
-
-@@ -1419,7 +1603,7 @@
- */
- card->chans[D].card = card;
- card->chans[D].name = "D";
-- card->chans[D].status = free;
-+ card->chans[D].status = chan_free;
- card->chans[D].number = D;
- spin_lock_init(&card->chans[D].lock);
-
-@@ -1460,7 +1644,7 @@
- */
- card->chans[B1].card = card;
- card->chans[B1].name = "B1";
-- card->chans[B1].status = free;
-+ card->chans[B1].status = chan_free;
- card->chans[B1].number = B1;
- card->chans[B1].protocol = 0;
- spin_lock_init(&card->chans[B1].lock);
-@@ -1502,7 +1686,7 @@
- */
- card->chans[B2].card = card;
- card->chans[B2].name = "B2";
-- card->chans[B2].status = free;
-+ card->chans[B2].status = chan_free;
- card->chans[B2].number = B2;
- card->chans[B2].protocol = 0;
- spin_lock_init(&card->chans[B2].lock);
-@@ -1555,14 +1739,17 @@
- hfc_zap_initialize(zthfc);
- card->ztdev = zthfc;
-
-+#if !defined(__FreeBSD__)
- snprintf(card->proc_dir_name,
- sizeof(card->proc_dir_name),
- "%d", card->cardnum);
- card->proc_dir = proc_mkdir(card->proc_dir_name, hfc_proc_zaphfc_dir);
- SET_PROC_DIRENTRY_OWNER(card->proc_dir);
-+#endif /* !__FreeBSD__ */
-
- hfc_resetCard(card);
-
-+#if !defined(__FreeBSD__)
- printk(KERN_INFO hfc_DRIVER_PREFIX
- "card %d configured for %s mode at mem %#lx (0x%p) IRQ %u\n",
- card->cardnum,
-@@ -1570,28 +1757,106 @@
- card->io_bus_mem,
- card->io_mem,
- card->pcidev->irq);
-+#endif /* !__FreeBSD__ */
-
- cardnum++;
-
- return 0;
-
- err_request_irq:
-+#if !defined(__FreeBSD__)
- pci_free_consistent(pci_dev, hfc_FIFO_SIZE,
- card->fifo_mem, card->fifo_bus_mem);
-+#endif
- err_alloc_fifo:
-+#if !defined(__FreeBSD__)
- iounmap(card->io_mem);
- err_ioremap:
- err_noiobase:
- err_noirq:
- pci_release_regions(pci_dev);
-+#endif
- err_pci_request_regions:
-+#if defined(__FreeBSD__)
-+ hfc_release_resources(card);
-+#else
- err_pci_set_dma_mask:
- err_pci_enable_device:
- kfree(card);
- err_alloc_hfccard:
-+#endif
- return err;
- }
-
-+#if defined(__FreeBSD__)
-+SYSCTL_NODE(_dahdi, OID_AUTO, wcb1xxp, CTLFLAG_RW, 0, "DAHDI wcb1xxp");
-+#define MODULE_PARAM_PREFIX "dahdi.wcb1xxp"
-+#define MODULE_PARAM_PARENT _dahdi_wcb1xxp
-+
-+static int
-+wcb1xxp_device_probe(device_t dev)
-+{
-+ struct pci_device_id *id;
-+
-+ id = dahdi_pci_device_id_lookup(dev, hfc_pci_ids);
-+ if (id == NULL)
-+ return (ENXIO);
-+
-+ /* found device */
-+ device_printf(dev, "vendor=%x device=%x subvendor=%x\n",
-+ id->vendor, id->device, id->subvendor);
-+ device_set_desc(dev, "CCD HFC-S");
-+ return (0);
-+}
-+
-+static int
-+wcb1xxp_device_attach(device_t dev)
-+{
-+ int res;
-+ struct pci_device_id *id;
-+
-+ id = dahdi_pci_device_id_lookup(dev, hfc_pci_ids);
-+ if (id == NULL)
-+ return (ENXIO);
-+
-+ res = hfc_probe(dev);
-+ return (-res);
-+}
-+
-+static int
-+wcb1xxp_device_detach(device_t dev)
-+{
-+ struct hfc_card *card = device_get_softc(dev);
-+
-+ if (dahdi_module_usecount(THIS_MODULE) > 0)
-+ return (EBUSY);
-+
-+ hfc_softreset(card);
-+ dahdi_unregister(&card->ztdev->span);
-+ hfc_release_resources(card);
-+
-+ return (0);
-+}
-+
-+static device_method_t wcb1xxp_methods[] = {
-+ DEVMETHOD(device_probe, wcb1xxp_device_probe),
-+ DEVMETHOD(device_attach, wcb1xxp_device_attach),
-+ DEVMETHOD(device_detach, wcb1xxp_device_detach),
-+ { 0, 0 }
-+};
-+
-+static driver_t wcb1xxp_pci_driver = {
-+ "wcb1xxp",
-+ wcb1xxp_methods,
-+ sizeof(struct hfc_card)
-+};
-+
-+static devclass_t wcb1xxp_devclass;
-+
-+DAHDI_DRIVER_MODULE(wcb1xxp, pci, wcb1xxp_pci_driver, wcb1xxp_devclass);
-+MODULE_DEPEND(wcb1xxp, pci, 1, 1, 1);
-+MODULE_DEPEND(wcb1xxp, dahdi, 1, 1, 1);
-+#else
- static void __devexit hfc_remove(struct pci_dev *pci_dev)
- {
- struct hfc_card *card = pci_get_drvdata(pci_dev);
-@@ -1671,8 +1936,6 @@
-
- module_exit(hfc_module_exit);
-
--#endif
--
- MODULE_DESCRIPTION(hfc_DRIVER_DESCR);
- MODULE_AUTHOR("Jens Wilke <jw_vzaphfc@headissue.com>, "
- "Daniele (Vihai) Orlandi <daniele@orlandi.com>, "
-@@ -1681,15 +1944,18 @@
- #ifdef MODULE_LICENSE
- MODULE_LICENSE("GPL");
- #endif
-+#endif /* !__FreeBSD__ */
-
-
- module_param(modes, int, 0444);
-
-+#if !defined(__FreeBSD__)
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
- module_param_array(nt_modes, int, &nt_modes_count, 0444);
- #else
- module_param_array(nt_modes, int, nt_modes_count, 0444);
- #endif
-+#endif /* !__FreeBSD__ */
-
- module_param(force_l1_up, int, 0444);
- #ifdef DEBUG
-diff -ruN freebsd/drivers/dahdi/zaphfc.orig/fifo.c freebsd/drivers/dahdi/zaphfc/fifo.c
---- freebsd/drivers/dahdi/zaphfc.orig/fifo.c 2010-09-01 00:55:30.000000000 +0700
-+++ freebsd/drivers/dahdi/zaphfc/fifo.c 2010-09-01 01:09:07.000000000 +0700
-@@ -13,7 +13,9 @@
- *
- */
-
-+#if !defined(__FreeBSD__)
- #include <linux/kernel.h>
-+#endif
-
- #include <dahdi/kernel.h>
-
-@@ -36,7 +38,7 @@
- chan->z_base + z_start,
- bytes_to_boundary);
-
-- memcpy(data + bytes_to_boundary,
-+ memcpy((char *) data + bytes_to_boundary,
- chan->fifo_base,
- size - bytes_to_boundary);
- }
-@@ -60,7 +62,7 @@
- bytes_to_boundary);
-
- memcpy(chan->fifo_base,
-- data + bytes_to_boundary,
-+ (char *) data + bytes_to_boundary,
- size - bytes_to_boundary);
- }
- }
-diff -ruN freebsd/drivers/dahdi/zaphfc.orig/fifo.h freebsd/drivers/dahdi/zaphfc/fifo.h
---- freebsd/drivers/dahdi/zaphfc.orig/fifo.h 2010-09-01 00:55:30.000000000 +0700
-+++ freebsd/drivers/dahdi/zaphfc/fifo.h 2010-07-07 04:24:55.000000000 +0700
-@@ -21,22 +21,22 @@
-
- static inline u16 *Z1_F1(struct hfc_chan_simplex *chan)
- {
-- return chan->z1_base + (*chan->f1 * 4);
-+ return (u16 *) (chan->z1_base + (*chan->f1 * 4));
- }
-
- static inline u16 *Z2_F1(struct hfc_chan_simplex *chan)
- {
-- return chan->z2_base + (*chan->f1 * 4);
-+ return (u16 *) (chan->z2_base + (*chan->f1 * 4));
- }
-
- static inline u16 *Z1_F2(struct hfc_chan_simplex *chan)
- {
-- return chan->z1_base + (*chan->f2 * 4);
-+ return (u16 *) (chan->z1_base + (*chan->f2 * 4));
- }
-
- static inline u16 *Z2_F2(struct hfc_chan_simplex *chan)
- {
-- return chan->z2_base + (*chan->f2 * 4);
-+ return (u16 *) (chan->z2_base + (*chan->f2 * 4));
- }
-
- static inline u16 Z_inc(struct hfc_chan_simplex *chan, u16 z, u16 inc)
-diff -ruN freebsd/drivers/dahdi/zaphfc.orig/zaphfc.h freebsd/drivers/dahdi/zaphfc/zaphfc.h
---- freebsd/drivers/dahdi/zaphfc.orig/zaphfc.h 2010-09-01 00:55:30.000000000 +0700
-+++ freebsd/drivers/dahdi/zaphfc/zaphfc.h 2010-08-31 23:57:30.000000000 +0700
-@@ -24,7 +24,12 @@
- #ifndef _HFC_ZAPHFC_H
- #define _HFC_ZAPHFC_H
-
-+#if defined(__FreeBSD__)
-+#include <sys/rman.h>
-+#include <machine/bus.h>
-+#else
- #include <asm/io.h>
-+#endif
-
- #define hfc_DRIVER_NAME "vzaphfc"
- #define hfc_DRIVER_PREFIX hfc_DRIVER_NAME ": "
-@@ -273,9 +278,9 @@
- int ugly_framebuf_size;
- u16 ugly_framebuf_off;
-
-- void *z1_base, *z2_base;
-+ char *z1_base, *z2_base;
- void *fifo_base;
-- void *z_base;
-+ char *z_base;
- u16 z_min;
- u16 z_max;
- u16 fifo_size;
-@@ -293,7 +298,7 @@
- };
-
- enum hfc_chan_status {
-- free,
-+ chan_free,
- open_framed,
- open_voice,
- sniff_aux,
-@@ -330,12 +335,27 @@
- struct proc_dir_entry *proc_fifos;
- struct proc_dir_entry *proc_bufs;
-
-+#if defined(__FreeBSD__)
-+ struct pci_dev _dev;
-+
-+ struct resource *mem_res; /* resource for I/O range */
-+ int mem_rid;
-+
-+ struct resource *irq_res; /* resource for irq */
-+ int irq_rid;
-+ void *irq_handle;
-+
-+ uint32_t dma_addr;
-+ bus_dma_tag_t dma_tag;
-+ bus_dmamap_t dma_map;
-+#else
- unsigned long io_bus_mem;
- void __iomem *io_mem;
-
- dma_addr_t fifo_bus_mem;
-+#endif /* !__FreeBSD__ */
- void *fifo_mem;
-- void *fifos;
-+ char *fifos;
-
- int nt_mode;
- int sync_loss_reported;
-@@ -403,12 +423,24 @@
-
- static inline u8 hfc_inb(struct hfc_card *card, int offset)
- {
-+#if defined(__FreeBSD__)
-+ return bus_space_read_1(
-+ rman_get_bustag(card->mem_res), rman_get_bushandle(card->mem_res),
-+ offset);
-+#else
- return readb(card->io_mem + offset);
-+#endif
- }
-
- static inline void hfc_outb(struct hfc_card *card, int offset, u8 value)
- {
-+#if defined(__FreeBSD__)
-+ bus_space_write_1(
-+ rman_get_bustag(card->mem_res), rman_get_bushandle(card->mem_res),
-+ offset, value);
-+#else
- writeb(value, card->io_mem + offset);
-+#endif
- }
-
- #endif
-diff -ruN freebsd/freebsd/wcb1xxp.orig/Makefile freebsd/freebsd/wcb1xxp/Makefile
---- freebsd/freebsd/wcb1xxp.orig/Makefile 1970-01-01 07:00:00.000000000 +0700
-+++ freebsd/freebsd/wcb1xxp/Makefile 2010-09-01 01:00:49.000000000 +0700
-@@ -0,0 +1,9 @@
-+# $Id: Makefile 7432 2009-10-28 21:34:15Z fjoe $
-+
-+.PATH: ${.CURDIR}/../../drivers/dahdi/zaphfc
-+
-+KMOD= wcb1xxp
-+SRCS= base.c fifo.c
-+SRCS+= device_if.h bus_if.h pci_if.h
-+
-+.include <bsd.kmod.mk>
diff --git a/misc/dahdi/pkg-plist b/misc/dahdi/pkg-plist
index 13f5f6ee148b..94f6d782db49 100644
--- a/misc/dahdi/pkg-plist
+++ b/misc/dahdi/pkg-plist
@@ -3,35 +3,6 @@ include/dahdi/compat/types.h
include/dahdi/tonezone.h
include/dahdi/user.h
include/dahdi/wctdm_user.h
-lib/dahdi/dahdi-fw-hx8.bin.ko
-lib/dahdi/dahdi-fw-oct6114-064.bin.ko
-lib/dahdi/dahdi-fw-oct6114-128.bin.ko
-lib/dahdi/dahdi-fw-tc400m.bin.ko
-lib/dahdi/dahdi.ko
-lib/dahdi/dahdi_dynamic.ko
-lib/dahdi/dahdi_dynamic_eth.ko
-lib/dahdi/dahdi_dynamic_ethmf.ko
-lib/dahdi/dahdi_dynamic_loc.ko
-lib/dahdi/dahdi_echocan_jpah.ko
-lib/dahdi/dahdi_echocan_kb1.ko
-lib/dahdi/dahdi_echocan_oslec.ko
-lib/dahdi/dahdi_echocan_mg2.ko
-lib/dahdi/dahdi_echocan_sec.ko
-lib/dahdi/dahdi_echocan_sec2.ko
-lib/dahdi/dahdi_transcode.ko
-lib/dahdi/dahdi_voicebus.ko
-%%X86%%lib/dahdi/dahdi_vpmadt032_loader.ko
-lib/dahdi/linker.hints
-lib/dahdi/ng_dahdi_netdev.ko
-lib/dahdi/wcb1xxp.ko
-lib/dahdi/wcb4xxp.ko
-lib/dahdi/wcfxo.ko
-lib/dahdi/wct4xxp.ko
-lib/dahdi/wctc4xxp.ko
-lib/dahdi/wctdm.ko
-lib/dahdi/wctdm24xxp.ko
-lib/dahdi/wcte11xp.ko
-lib/dahdi/wcte12xp.ko
lib/libtonezone.a
lib/libtonezone.so
lib/libtonezone.so.1
@@ -46,7 +17,6 @@ sbin/dahdi_speed
sbin/dahdi_test
sbin/dahdi_tool
sbin/fxotune
-@dirrm lib/dahdi
@dirrm include/dahdi/compat
@dirrm include/dahdi
@dirrmtry etc/dahdi