LinuxPPS core (Version 1): the PPS Linux implementation.
Subsystems (2)
This patch adds the PPS core support into Linux.
Currently I just propose the "core" so after inclusion we can add all other related stuff as suggested by several people in this list. :)
PPS means "pulse per second" and its API is specified by RFC 2783 (Pulse-Per-Second API for UNIX-like Operating Systems, Version 1.0).
The code has been tested with the NTPD program
(http://www.eecis.udel.edu/~mills/ntp/html/index.html) and several GPS antennae.
Changelog
=========
Version [full patchset] -> 1
----------------------------
* stupid filenames removed.
* kernel-doc documentation of exported symbols.
* old BKL-locked ioctl removed.
* !uarg checks in the ioctls removed.
* pps.h revisited but not splitted, since several stuff are shared between kernel and user land (I hope this will not stop inclusion...)
Rodolfo
PATCH 1/1 LinuxPPS core support.
This patch adds the kernel side of the PPS support currently named "LinuxPPS".
PPS means "pulse per second" and a PPS source is just a device which provides a high precision signal each second so that an application can use it to adjust system clock time.
Common use is the combination of the NTPD as userland program with a GPS receiver as PPS source to obtain a wallclock-time with sub-millisecond synchronisation to UTC.
To obtain this goal the userland programs shoud use the PPS API specification (RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems, Version 1.0) which in part is implemented by this patch. It provides a set of chars devices, one per PPS source, which can be used to get the time signal. The RFC's functions can be implemented by accessing to these char devices.
--- Documentation/ABI/testing/sysfs-pps | 73 ++++++++ Documentation/ioctl/ioctl-number.txt | 2 + Documentation/pps/pps.txt | 172 ++++++++++++++++++ MAINTAINERS | 7 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/pps/Kconfig | 33 ++++ drivers/pps/Makefile | 8 + drivers/pps/kapi.c | 317 +++++++++++++++++++++++++++++++++ drivers/pps/pps.c | 322 ++++++++++++++++++++++++++++++++++ drivers/pps/sysfs.c | 104 +++++++++++ include/linux/Kbuild | 1 + include/linux/pps.h | 195 ++++++++++++++++++++ 13 files changed, 1237 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-pps create mode 100644 Documentation/pps/pps.txt create mode 100644 drivers/pps/Kconfig create mode 100644 drivers/pps/Makefile create mode 100644 drivers/pps/kapi.c create mode 100644 drivers/pps/pps.c create mode 100644 drivers/pps/sysfs.c create mode 100644 include/linux/pps.h
Documentation/ABI/testing/sysfs-pps new file +73 -0
@@ -0,0 +1,73 @@ +What: /sys/class/pps/ +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ directory will contain files and + directories that will provide a unified interface to + the PPS sources. + +What: /sys/class/pps/ppsX/ +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/ directory is related to X-th + PPS source into the system. Each directory will + contain files to manage and control its PPS source. + +What: /sys/class/pps/ppsX/assert +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/assert file reports the assert events + and the assert sequence number of the X-th source in the form: + + <secs>.<nsec>#<sequence> + + If the source has no assert events the content of this file + is empty. + +What: /sys/class/pps/ppsX/clear +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/clear file reports the clear events + and the clear sequence number of the X-th source in the form: + + <secs>.<nsec>#<sequence> + + If the source has no clear events the content of this file + is empty. + +What: /sys/class/pps/ppsX/mode +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/mode file reports the functioning + mode of the X-th source in hexadecimal encoding. + + Please, refer to linux/include/linux/pps.h for further + info. + +What: /sys/class/pps/ppsX/echo +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/echo file reports if the X-th does + or does not support an "echo" function. + +What: /sys/class/pps/ppsX/name +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/name file reports the name of the + X-th source. + +What: /sys/class/pps/ppsX/path +Date: February 2008 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/pps/ppsX/path file reports the path name of + the device connected with the X-th source. + + If the source is not connected with any device the content + of this file is empty.
Documentation/ioctl/ioctl-number.txt +2 -0
@@ -151,6 +151,8 @@ Code Seq# Include File Comments 'p' 40-7F linux/nvram.h 'p' 80-9F user-space parport <mailto:[email protected]> +'p' a0-a4 linux/pps.h LinuxPPS + <mailto:[email protected]> 'q' 00-1F linux/serio.h 'q' 80-FF Internet PhoneJACK, Internet LineJACK <http://www.quicknet.net>
Documentation/pps/pps.txt new file +172 -0
172 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -3464,6 +3464,13 @@ P: James Chapman M: [email protected] S: Maintained +PPS SUPPORT +P: Rodolfo Giometti +M: [email protected] +W: http://wiki.enneenne.com/index.php/LinuxPPS_support +L: [email protected] (subscribers-only) +S: Maintained + PREEMPTIBLE KERNEL P: Robert Love M: [email protected]
drivers/Kconfig +2 -0
@@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig" source "drivers/spi/Kconfig" +source "drivers/pps/Kconfig" + source "drivers/gpio/Kconfig" source "drivers/w1/Kconfig"
drivers/Makefile +1 -0
@@ -71,6 +71,7 @@ obj-$(CONFIG_INPUT) += input/ obj-$(CONFIG_I2O) += message/ obj-$(CONFIG_RTC_LIB) += rtc/ obj-y += i2c/ +obj-$(CONFIG_PPS) += pps/ obj-$(CONFIG_W1) += w1/ obj-$(CONFIG_POWER_SUPPLY) += power/ obj-$(CONFIG_HWMON) += hwmon/
drivers/pps/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +# +# PPS support configuration +# + +menu "PPS support" + +config PPS + tristate "PPS support" + depends on EXPERIMENTAL + ---help--- + PPS (Pulse Per Second) is a special pulse provided by some GPS + antennae. Userland can use it to get a high-precision time + reference. + + Some antennae's PPS signals are connected with the CD (Carrier + Detect) pin of the serial line they use to communicate with the + host. In this case use the SERIAL_LINE client support. + + Some antennae's PPS signals are connected with some special host + inputs so you have to enable the corresponding client support. + + To compile this driver as a module, choose M here: the module + will be called pps_core.ko. + +config PPS_DEBUG + bool "PPS debugging messages" + depends on PPS + help + Say Y here if you want the PPS support to produce a bunch of debug + messages to the system log. Select this if you are having a + problem with PPS support and want to see more of what is going on. + +endmenu
drivers/pps/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for the PPS core. +# + +pps_core-y := pps.o kapi.o sysfs.o +obj-$(CONFIG_PPS) := pps_core.o + +ccflags-$(CONFIG_PPS_DEBUG) := -DDEBUG
drivers/pps/kapi.c new file +317 -0
317 lines not on this page · raw message
drivers/pps/pps.c new file +322 -0
322 lines not on this page · raw message
drivers/pps/sysfs.c new file +104 -0
104 lines not on this page · raw message
include/linux/Kbuild +1 -0
@@ -304,6 +304,7 @@ unifdef-y += pmu.h unifdef-y += poll.h unifdef-y += ppp_defs.h unifdef-y += ppp-comp.h +unifdef-y += pps.h unifdef-y += ptrace.h unifdef-y += qnx4_fs.h unifdef-y += quota.h
include/linux/pps.h new file +195 -0
195 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Re: [PATCH 1/1] LinuxPPS core support.
Quoted 7 lines
drivers/pps/pps.c new file +7
-0+static long pps_cdev_ioctl (struct file *file, +unsigned int cmd,unsigned long arg) +{ +struct pps_device *pps = file->private_data; +struct pps_kparams params; +struct pps_fdata fdata; +unsigned long ticks;
drivers/pps/pps.c line 75
Quoted 10 lines
drivers/pps/pps.c new file +10
-0+void __user *uarg = (void __user *) arg; +int __user *iuarg = (int __user *) arg; +int err; + +switch (cmd) { +case PPS_CHECK : + +/* This does nothing but signal we are a PPS source... */ + +return 0 ;
I think this one is superflous. Just doing a PPS_GETPARAMS: should get your the same information..
Quoted 16 lines
drivers/pps/pps.c new file +16
-0+case PPS_GETPARAMS : +pr_debug ("PPS_GETPARAMS: source %d\n" , pps->id); + +/* Return current parameters */ + err =copy_to_user (uarg, &pps->params, +sizeof (struct pps_kparams )); +if (err) +return -EFAULT ; + +break ; + +case PPS_SETPARAMS : +pr_debug ("PPS_SETPARAMS: source %d\n" , pps->id); + +/* Check the capabilities */ +if (!capable (CAP_SYS_TIME ))
drivers/pps/pps.c line 102
Quoted 10 lines
drivers/pps/pps.c new file +10
-0+return -EPERM ; + + err =copy_from_user (¶ms, uarg,sizeof (struct pps_kparams )); +if (err) +return -EFAULT ; +if (!(params.mode & (PPS_CAPTUREASSERT |PPS_CAPTURECLEAR ))) { +pr_debug ("capture mode unspecified (%x)\n" , + params.mode); +return -EINVAL ; + }
Note that splitting out any non-trivial ioctl into it's own small helper function gives generally much cleaner code.
drivers/pps/pps.c line 283
Quoted 2 lines
drivers/pps/pps.c new file +2
-0+if (pps_devt) +unregister_chrdev_region (pps_devt,PPS_MAX_SOURCES );
Given that you have proper error handling in pps_init this can't ever be zero.
drivers/pps/pps.c line 285
Quoted 2 lines
drivers/pps/pps.c new file +2
-0+ +pr_info ("LinuxPPS API ver. %d removed\n" ,PPS_API_VERS );
Printing stuff on exit is rather noisy and should be avoided
Quoted 2 lines · Rodolfo Giometti
*
pps.hrevisited but not splitted, since several stuff are shared between kernel and user land (I hope this will not stop inclusion...)
I really think the bits under ifdef __KERNEL__ should be split into a pps_kernel.h. Not enough to block inclusion, but a very strong recommendation. Headers containing ABIs and kernel-internal bits get messy over time.