[zaptel-commits] tzafrir: branch 1.2 r3083 - in /branches/1.2: README ztdummy.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Sat Sep 22 15:51:33 CDT 2007


Author: tzafrir
Date: Sat Sep 22 15:51:33 2007
New Revision: 3083

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3083
Log:
Backport support for high-resolution timers from 1.4. Allows 2.6.22
Fedoras to build again.

Modified:
    branches/1.2/README
    branches/1.2/ztdummy.c

Modified: branches/1.2/README
URL: http://svn.digium.com/view/zaptel/branches/1.2/README?view=diff&rev=3083&r1=3082&r2=3083
==============================================================================
--- branches/1.2/README (original)
+++ branches/1.2/README Sat Sep 22 15:51:33 2007
@@ -74,7 +74,7 @@
   kernel image.
   * On Debian Etch and above and any Ubuntu this is
     +++ linux-headers-`uname -r` +++
-  * On Fedora RHEL and compatibles (e.g. CentOS) this is the
+  * On Fedora, RHEL and compatibles (e.g. CentOS) this is the
     kernel-devel package. Or if you run kernel-smp or kernel-xen, you
     need kernel-smp-devel or kernel-xen-devel, respectively.
   * On SUSE you seem to need the package kernel-source .
@@ -97,8 +97,11 @@
   be selected These can be selected from the "Library Routines" submenu 
   during kernel configuration via "make menuconfig".
 - If you don't have any zaptel hardware, you need ztdummy.
-  * ztdummy on i386/amd64 and later kernels (>= 2.6.15) can (and should)
-    use the system's RTC (Real Time Clock).
+  * ztdummy on i386/x86_64 with kernels >= 2.6.22 can (and should) use 
+    high resolution times (CONFIG_HIGH_RES_TIMERS), and (if available, 
+    the system HPET.
+  * ztdummy on i386/x86_64 and later kernels (>= 2.6.15) can use the 
+    system's RTC (Real Time Clock).
   * Alternatives to that for ztdummy are a UHCI USB controller (USB
     controllers made by Intel or VIA) or a kernel that has HZ=1000
     (default on kernels 2.6.0-2.6.12, optional on newer kernels. Not
@@ -136,7 +139,7 @@
   yum install gcc newt-devel libusb-devel
 
 If the following command produces an error, you need to install
-ithe kernel devel package:
+the kernel devel package:
 
   ls /lib/modules/`uname -r`/build/.config
 
@@ -322,6 +325,12 @@
 of how close it was. Also try running it with the option -v for a
 verbose output.
 
+To check the clock source that is built into ztdummy, you can either
+look at title of its span in /proc/zaptel file for a "source:" in the
+description. Or even run:
+
+  strings zaptel.ko | grep source:
+
 
 Spans and Channels
 ------------------

Modified: branches/1.2/ztdummy.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztdummy.c?view=diff&rev=3083&r1=3082&r2=3083
==============================================================================
--- branches/1.2/ztdummy.c (original)
+++ branches/1.2/ztdummy.c Sat Sep 22 15:51:33 2007
@@ -8,6 +8,8 @@
  * Unified by Mark Spencer <markster at digium.com>
  * Converted to use RTC on i386 by Tony Mountifield <tony at softins.co.uk>
  *
+ * Converted to use HighResTimers on i386 by Jeffery Palmer <jeff at triggerinc.com>
+ *
  * Copyright (C) 2002, Hermes Softlab
  * Copyright (C) 2004, Digium, Inc.
  *
@@ -28,6 +30,14 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
+
+/*
+ * To use the high resolution timers, in your kernel CONFIG_HIGH_RES_TIMERS 
+ * needs to be enabled (Processor type and features -> High Resolution 
+ * Timer Support), and optionally HPET (Processor type and features -> 
+ * HPET Timer Support) provides a better clock source.
+ */
+
 #include <linux/version.h>
 
 #ifndef VERSION_CODE
@@ -46,7 +56,12 @@
  */
 #if defined(__i386__) || defined(__x86_64__)
 #if LINUX_VERSION_CODE >= VERSION_CODE(2,6,13)
+/* The symbol hrtimer_forward is only exported as of 2.6.22: */
+#if defined(CONFIG_HIGH_RES_TIMERS) && LINUX_VERSION_CODE >= VERSION_CODE(2,6,22)
+#define USE_HIGHRESTIMER
+#else
 #define USE_RTC
+#endif
 #else
 #if 0
 #define USE_RTC
@@ -70,6 +85,9 @@
 #include <asm/io.h>
 #endif
 #ifdef LINUX26
+#ifdef USE_HIGHRESTIMER
+#include <linux/hrtimer.h>
+#endif
 #ifdef USE_RTC
 #include <linux/rtc.h>
 #endif
@@ -96,8 +114,14 @@
 static int debug = 0;
 
 #ifdef LINUX26
-#ifndef USE_RTC
-/* New 2.6 kernel timer stuff */
+#ifdef USE_HIGHRESTIMER
+#define CLOCK_SRC "HRtimer"
+struct hrtimer zaptimer;
+#elif defined(USE_RTC)
+#define CLOCK_SRC "RTC"
+#else /* Linux 2.6, but no RTC or HRTIMER used */
+#define CLOCK_SRC "Linux26"
+/* 2.6 kernel timer stuff */
 static struct timer_list timer;
 #if HZ != 1000
 #warning This module will not be usable since the kernel HZ setting is not 1000 ticks per second.
@@ -107,6 +131,7 @@
 #if LINUX_VERSION_CODE < VERSION_CODE(2,4,5)
 #  error "This kernel is too old: not supported by this file"
 #endif
+#define CLOCK_SRC "UHCI"
 /* Old UCHI stuff */
 static    uhci_desc_t  *td;
 static    uhci_t *s;
@@ -124,6 +149,15 @@
 extern uhci_t **uhci_devices;
 
 #endif
+
+
+#define ZAPTEL_RATE 1000                     /* zaptel ticks per second */
+#define ZAPTEL_TIME (1000000 / ZAPTEL_RATE)  /* zaptel tick time in us */
+#define ZAPTEL_TIME_NS (ZAPTEL_TIME * 1000)  /* zaptel tick time in ns */
+
+/* Different bits of the debug variable: */
+#define DEBUG_GENERAL (1 << 0)
+#define DEBUG_TICKS   (1 << 1)
 
 
 #ifdef LINUX26
@@ -180,7 +214,7 @@
 {
 	/* Zapata stuff */
 	sprintf(ztd->span.name, "ZTDUMMY/1");
-	sprintf(ztd->span.desc, "%s %d", ztd->span.name, 1);
+	sprintf(ztd->span.desc, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1);
 	sprintf(ztd->chan.name, "ZTDUMMY/%d/%d", 1, 0);
 	ztd->chan.chanpos = 1;
 	ztd->span.chans = &ztd->chan;
@@ -220,12 +254,12 @@
     }
 #endif
 
-#if defined(LINUX26) && !defined(USE_RTC)
+#if defined(LINUX26) && !defined(USE_RTC) && !defined(USE_HIGHRESTIMER)
     if (HZ != 1000) {
 	    printk("ztdummy: This module requires the kernel HZ setting to be 1000 ticks per second\n");
 	    return -ENODEV;
     }
-#endif /* defined(LINUX26) && !defined(USE_RTC) */
+#endif /* defined(LINUX26) && !defined(USE_RTC) && !defined(USE_HIGHRESTIMER)*/
 
     ztd = kmalloc(sizeof(struct ztdummy), GFP_KERNEL);
     if (ztd == NULL) {




More information about the zaptel-commits mailing list