diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-09-22 20:51:33 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-09-22 20:51:33 +0000 |
commit | 362b77d3ae9a9ec208086fc014e90158bc1bc22a (patch) | |
tree | 98d44a7c8766a52095ab13bbe36d05832b4f848c | |
parent | d8408feade6cd16368f04f7b1f40b3448853c709 (diff) |
Backport support for high-resolution timers from 1.4. Allows 2.6.22
Fedoras to build again.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3083 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r-- | README | 17 | ||||
-rw-r--r-- | ztdummy.c | 44 |
2 files changed, 52 insertions, 9 deletions
@@ -74,7 +74,7 @@ Kernel Source / "Headers" 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 @@ If you build a custom kernel, note the following configuration items: 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 @@ You need the following non-kernel-related packages: 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 @@ first cycle. Eitherwise it will just give you in each cycle the percent 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 ------------------ @@ -8,6 +8,8 @@ * Unified by Mark Spencer <markster@digium.com> * Converted to use RTC on i386 by Tony Mountifield <tony@softins.co.uk> * + * Converted to use HighResTimers on i386 by Jeffery Palmer <jeff@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 struct ztdummy *ztd; 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 @@ static struct timer_list timer; #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; @@ -126,6 +151,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 #ifdef USE_RTC /* rtc_interrupt - called at 1024Hz from hook in RTC handler */ @@ -180,7 +214,7 @@ static int ztdummy_initialize(struct ztdummy *ztd) { /* 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 @@ int init_module(void) } #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) { |