37#if defined(__KERNEL__)
38# include <linux/time.h>
85 static unsigned int rate[] = {0, 1, 2, 4, 5, 10, 20, 25, 50, 100, 0};
168#define IRIG_MAX_DT_DIFF 20
169#define IRIG_MIN_DT_DIFF -20
212#define IRIG_IOC_MAGIC 'I'
214#define IRIG_OPEN _IO(IRIG_IOC_MAGIC, 0)
215#define IRIG_CLOSE _IO(IRIG_IOC_MAGIC, 1)
216#define IRIG_GET_STATUS _IOR(IRIG_IOC_MAGIC, 2, struct pc104sg_status)
217#define IRIG_GET_CLOCK _IOR(IRIG_IOC_MAGIC, 3, struct timeval32)
218#define IRIG_SET_CLOCK _IOW(IRIG_IOC_MAGIC, 4, struct timeval32)
219#define IRIG_OVERRIDE_CLOCK _IOW(IRIG_IOC_MAGIC, 5, struct timeval32)
220#define IRIG_GET_CLOCK64 _IOR(IRIG_IOC_MAGIC, 6, int64_t)
221#define IRIG_SET_CLOCK64 _IOW(IRIG_IOC_MAGIC, 7, int64_t)
225#if defined(__KERNEL__)
227#include <linux/ioctl.h>
228#include <linux/wait.h>
259#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
260#define GET_TMSEC_CLOCK \
262 int tmp = smp_load_acquire(&ReadClock);\
266#define GET_TMSEC_CLOCK \
268 int tmp = READ_ONCE(ReadClock);\
269 smp_read_barrier_depends();\
274#define GET_MSEC_CLOCK (GET_TMSEC_CLOCK/10)
290typedef void irig_callback_func(
void* privateData);
295struct irig_callback {
296 struct list_head list;
297 irig_callback_func* callback;
298 irig_callback_func* resyncCallback;
332 irig_callback_func* func,
333 irig_callback_func* resync,
335 void* privateData,
int *errp);
static enum irigClockRates irigClockRateToEnum(unsigned int value)
Convert a rate in Hz to an enumerated value, rounding up to the next highest supported rate,...
Definition irigclock.h:64
#define IRIG_MIN_DT_DIFF
Definition irigclock.h:169
#define IRIG_MAX_DT_DIFF
Limits for how many ticks the 100Hz software clock can disagree with the hardware clock before a rese...
Definition irigclock.h:168
irigClockRates
Enumeration of the callback rates supported by this module.
Definition irigclock.h:52
@ IRIG_1_HZ
Definition irigclock.h:53
@ IRIG_10_HZ
Definition irigclock.h:54
@ IRIG_0_1_HZ
Definition irigclock.h:53
@ IRIG_50_HZ
Definition irigclock.h:54
@ IRIG_4_HZ
Definition irigclock.h:53
@ IRIG_20_HZ
Definition irigclock.h:54
@ IRIG_25_HZ
Definition irigclock.h:54
@ IRIG_5_HZ
Definition irigclock.h:53
@ IRIG_100_HZ
Definition irigclock.h:55
@ IRIG_2_HZ
Definition irigclock.h:53
@ IRIG_ZERO_HZ
Definition irigclock.h:55
@ IRIG_NUM_RATES
Definition irigclock.h:55
static unsigned int irigClockEnumToRate(enum irigClockRates value)
Convert an enumerated value back to a rate in Hz.
Definition irigclock.h:83
int ReadClock
Index into TMsecClock of the value to be read.
Definition pc104sg.c:212
int get_msec_clock_resolution()
Definition pc104sg.c:1455
void irig_clock_gettime(thiskernel_timespec_t *tp)
This function is available for use by external modules.
Definition pc104sg.c:1440
int TMsecClock[2]
A toggle buffer containing the current clock value in tenths of milliseconds since UTC midnight.
Definition pc104sg.c:207
struct irig_callback * register_irig_callback(irig_callback_func *callback, irig_callback_func *resync, enum irigClockRates rate, void *privateData, int *errp)
Module function that allows other modules to register their callback function to be called at the giv...
Definition pc104sg.c:587
int flush_irig_callbacks(void)
Definition pc104sg.c:662
int unregister_irig_callback(struct irig_callback *cb)
Modules call this function to dequeue their callbacks.
Definition pc104sg.c:641
int setRate2Output(int rate)
Definition pc104sg.c:1154
static float rate
Definition sing.cc:53
Definition irigclock.h:105
unsigned char max100HzBacklog
Definition irigclock.h:112
unsigned char clockAdjusts
Definition irigclock.h:111
struct timeval32 unixt
Definition irigclock.h:107
unsigned char seqnum
Definition irigclock.h:109
char end[]
Definition irigclock.h:113
unsigned char syncToggles
Definition irigclock.h:110
unsigned char status
Definition irigclock.h:108
struct timeval32 irigt
Definition irigclock.h:106
Note that a int64_t has the same size, 8 bytes, as a timeval32.
Definition irigclock.h:129
unsigned char max100HzBacklog
Definition irigclock.h:137
unsigned char syncToggles
Definition irigclock.h:135
unsigned char status
Definition irigclock.h:133
int64_t irigt
Definition irigclock.h:130
int64_t unixt
Definition irigclock.h:131
unsigned char dummystatus
Definition irigclock.h:132
char end[]
Definition irigclock.h:138
unsigned char seqnum
Definition irigclock.h:134
unsigned char clockAdjusts
Definition irigclock.h:136
Definition irigclock.h:99
char end[]
Definition irigclock.h:102
unsigned char status
Definition irigclock.h:101
struct timeval32 tval
Definition irigclock.h:100
Definition irigclock.h:148
dsm_sample_time_t timetag
Definition irigclock.h:149
struct dsm_clock_data_2 data
Definition irigclock.h:151
dsm_sample_length_t length
Definition irigclock.h:150
Definition irigclock.h:155
struct dsm_clock_data_3 data
Definition irigclock.h:158
dsm_sample_time_t timetag
Definition irigclock.h:156
dsm_sample_length_t length
Definition irigclock.h:157
Definition irigclock.h:141
dsm_sample_length_t length
Definition irigclock.h:143
dsm_sample_time_t timetag
Definition irigclock.h:142
struct dsm_clock_data data
Definition irigclock.h:144
Definition irigclock.h:171
uint32_t softwareClockResets
Total counts of the number of times that the sofware clock was reset with a step change.
Definition irigclock.h:183
unsigned char statusOR
Value of extended status from PC104SG dual port RAM.
Definition irigclock.h:206
uint32_t syncToggles
Counts of the number of times that the IRIG hardware clock has lost or regained sync.
Definition irigclock.h:177
uint32_t slews[IRIG_MAX_DT_DIFF - IRIG_MIN_DT_DIFF+1]
Counts of the number of times that the software clock was slewed, indexed by the number of delta-Ts i...
Definition irigclock.h:189
Definition irigclock.h:94
int tv_sec
Definition irigclock.h:95
int tv_usec
Definition irigclock.h:96
unsigned int dsm_sample_length_t
length of data portion of sample.
Definition types.h:51
int dsm_sample_time_t
Depending on the module, either tenths of milliseconds, or milliseconds since 00:00 UTC today.
Definition types.h:48