[dahdi-commits] fjoe: freebsd/trunk r7532 - in /freebsd/trunk: drivers/dahdi/ freebsd/ freebs...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Sat Nov 7 03:56:00 CST 2009
Author: fjoe
Date: Sat Nov 7 03:55:58 2009
New Revision: 7532
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7532
Log:
Port dahdi_dynamic and dahdi_dynamic_loc.
Added:
freebsd/trunk/freebsd/dahdi_dynamic/
freebsd/trunk/freebsd/dahdi_dynamic/Makefile (with props)
freebsd/trunk/freebsd/dahdi_dynamic_loc/
freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile (with props)
Modified:
freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c
freebsd/trunk/freebsd/Makefile
freebsd/trunk/include/dahdi/compat/bsd.h
Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic.c?view=diff&rev=7532&r1=7531&r2=7532
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic.c Sat Nov 7 03:55:58 2009
@@ -22,6 +22,19 @@
* this program for more details.
*/
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/ioccom.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/syscallsubr.h>
+#include <sys/systm.h>
+#include <sys/taskqueue.h>
+
+#include <machine/stdarg.h>
+#else /* !__FreeBSD__ */
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
@@ -33,8 +46,124 @@
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
#include <linux/moduleparam.h>
+#endif /* !__FreeBSD__ */
#include <dahdi/kernel.h>
+
+#if defined(__FreeBSD__)
+#define LINUX_VERSION_CODE 0
+
+static int
+request_module(const char *fmt, ...)
+{
+ va_list ap;
+ char modname[128];
+ int fileid;
+
+ va_start(ap, fmt);
+ vsnprintf(modname, sizeof(modname), fmt, ap);
+ va_end(ap);
+
+ return kern_kldload(curthread, modname, &fileid);
+}
+
+struct tasklet_struct {
+ struct task task;
+
+ void (*func)(unsigned long);
+ unsigned long data;
+};
+
+static void
+tasklet_run(void *context, int pending)
+{
+ struct tasklet_struct *t = (struct tasklet_struct *) context;
+ t->func(t->data);
+}
+
+static void
+tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data)
+{
+ TASK_INIT(&t->task, 0, tasklet_run, t);
+ t->func = func;
+ t->data = data;
+}
+
+static void
+tasklet_hi_schedule(struct tasklet_struct *t)
+{
+ taskqueue_enqueue_fast(taskqueue_fast, &t->task);
+}
+
+static void
+tasklet_disable(struct tasklet_struct *t)
+{
+ // nothing to do
+}
+
+static void
+tasklet_kill(struct tasklet_struct *t)
+{
+ taskqueue_drain(taskqueue_fast, &t->task);
+}
+
+struct timer_list {
+ struct mtx mtx;
+ struct callout callout;
+
+ unsigned long expires;
+ void (*function)(unsigned long);
+ unsigned long data;
+};
+
+static void
+run_timer(void *arg)
+{
+ struct timer_list *t = (struct timer_list *) arg;
+
+ mtx_lock_spin(&t->mtx);
+ if (callout_pending(&t->callout)) {
+ /* callout was reset */
+ mtx_unlock_spin(&t->mtx);
+ return;
+ }
+ if (!callout_active(&t->callout)) {
+ /* callout was stopped */
+ mtx_unlock_spin(&t->mtx);
+ return;
+ }
+ callout_deactivate(&t->callout);
+
+ t->function(t->data);
+ mtx_unlock_spin(&t->mtx);
+}
+
+static void
+init_timer(struct timer_list *t)
+{
+ mtx_init(&t->mtx, "dahdi_dynamic lock", NULL, MTX_SPIN);
+ callout_init(&t->callout, CALLOUT_MPSAFE);
+ t->expires = 0;
+ t->function = 0;
+ t->data = 0;
+}
+
+static void
+mod_timer(struct timer_list *t, unsigned long expires)
+{
+ callout_reset(&t->callout, expires - jiffies, run_timer, t);
+}
+
+static void
+del_timer(struct timer_list *t)
+{
+ mtx_lock_spin(&t->mtx);
+ callout_stop(&t->callout);
+ mtx_unlock_spin(&t->mtx);
+
+ mtx_destroy(&t->mtx);
+}
+#endif /* __FreeBSD__ */
/*
* Tasklets provide better system interactive response at the cost of the
@@ -847,6 +976,25 @@
printk(KERN_INFO "DAHDI Dynamic Span support unloaded\n");
}
+#if defined(__FreeBSD__)
+static int
+dahdi_dynamic_modevent(module_t mod __unused, int type, void *data __unused)
+{
+ switch (type) {
+ case MOD_LOAD:
+ return ztdynamic_init();
+ case MOD_UNLOAD:
+ ztdynamic_cleanup();
+ return 0;
+ default:
+ return EOPNOTSUPP;
+ }
+}
+
+DEV_MODULE(dahdi_dynamic, dahdi_dynamic_modevent, NULL);
+MODULE_VERSION(dahdi_dynamic, 1);
+MODULE_DEPEND(dahdi_dynamic, dahdi, 1, 1, 1);
+#else /* !__FreeBSD__ */
module_param(debug, int, 0600);
MODULE_DESCRIPTION("DAHDI Dynamic Span Support");
@@ -855,3 +1003,4 @@
module_init(ztdynamic_init);
module_exit(ztdynamic_cleanup);
+#endif /* !__FreeBSD__ */
Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c?view=diff&rev=7532&r1=7531&r2=7532
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c Sat Nov 7 03:55:58 2009
@@ -45,6 +45,16 @@
* this program for more details.
*/
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/module.h>
+#include <sys/systm.h>
+
+#define try_module_get(m) (1)
+#define module_put(m)
+#else /* !__FreeBSD__ */
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
@@ -54,6 +64,7 @@
#include <linux/kmod.h>
#include <linux/netdevice.h>
#include <linux/notifier.h>
+#endif /* !__FreeBSD__ */
#include <dahdi/kernel.h>
@@ -259,7 +270,27 @@
dahdi_dynamic_unregister(&ztd_local);
}
+#if defined(__FreeBSD__)
+static int
+dahdi_dynamic_loc_modevent(module_t mod __unused, int type, void *data __unused)
+{
+ switch (type) {
+ case MOD_LOAD:
+ return ztdlocal_init();
+ case MOD_UNLOAD:
+ ztdlocal_exit();
+ return 0;
+ default:
+ return EOPNOTSUPP;
+ }
+}
+
+DEV_MODULE(dahdi_dynamic_loc, dahdi_dynamic_loc_modevent, NULL);
+MODULE_VERSION(dahdi_dynamic_loc, 1);
+MODULE_DEPEND(dahdi_dynamic_loc, dahdi_dynamic, 1, 1, 1);
+#else /* !__FreeBSD__ */
module_init(ztdlocal_init);
module_exit(ztdlocal_exit);
MODULE_LICENSE("GPL v2");
+#endif /* !__FreeBSD__ */
Modified: freebsd/trunk/freebsd/Makefile
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/Makefile?view=diff&rev=7532&r1=7531&r2=7532
==============================================================================
--- freebsd/trunk/freebsd/Makefile (original)
+++ freebsd/trunk/freebsd/Makefile Sat Nov 7 03:55:58 2009
@@ -3,6 +3,8 @@
SUBDIR=\
dahdi\
dahdi_dummy\
+ dahdi_dynamic\
+ dahdi_dynamic_loc\
dahdi_echocan_jpah\
dahdi_echocan_kb1\
dahdi_echocan_mg2\
Added: freebsd/trunk/freebsd/dahdi_dynamic/Makefile
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi_dynamic/Makefile?view=auto&rev=7532
==============================================================================
--- freebsd/trunk/freebsd/dahdi_dynamic/Makefile (added)
+++ freebsd/trunk/freebsd/dahdi_dynamic/Makefile Sat Nov 7 03:55:58 2009
@@ -1,0 +1,8 @@
+# $Id$
+
+.PATH: ${.CURDIR}/../../drivers/dahdi
+
+KMOD= dahdi_dynamic
+SRCS= dahdi_dynamic.c
+
+.include <bsd.kmod.mk>
Propchange: freebsd/trunk/freebsd/dahdi_dynamic/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: freebsd/trunk/freebsd/dahdi_dynamic/Makefile
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: freebsd/trunk/freebsd/dahdi_dynamic/Makefile
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile?view=auto&rev=7532
==============================================================================
--- freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile (added)
+++ freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile Sat Nov 7 03:55:58 2009
@@ -1,0 +1,8 @@
+# $Id$
+
+.PATH: ${.CURDIR}/../../drivers/dahdi
+
+KMOD= dahdi_dynamic_loc
+SRCS= dahdi_dynamic_loc.c
+
+.include <bsd.kmod.mk>
Propchange: freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: freebsd/trunk/freebsd/dahdi_dynamic_loc/Makefile
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=7532&r1=7531&r2=7532
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Sat Nov 7 03:55:58 2009
@@ -8,6 +8,8 @@
#include <machine/atomic.h>
struct module;
+
+#define EXPORT_SYMBOL(s)
#define KERNEL_VERSION(x, y, z) 0
More information about the dahdi-commits
mailing list