37 #if defined(__KERNEL__)
38 # include <linux/time.h>
41 # include <sys/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)
290 typedef void irig_callback_func(
void* privateData);
295 struct 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);
Definition: irigclock.h:53
Definition: irigclock.h:55
int ReadClock
Index into TMsecClock of the value to be read.
Definition: pc104sg.c:212
int setRate2Output(int rate)
Definition: pc104sg.c:1154
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
unsigned char status
Definition: irigclock.h:108
char end[]
Definition: irigclock.h:102
Definition: irigclock.h:105
unsigned char seqnum
Definition: irigclock.h:134
#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
Definition: irigclock.h:148
Definition: irigclock.h:54
Definition: irigclock.h:53
Definition: irigclock.h:171
Definition: irigclock.h:53
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
unsigned char status
Definition: irigclock.h:101
static unsigned int irigClockEnumToRate(enum irigClockRates value)
Convert an enumerated value back to a rate in Hz.
Definition: irigclock.h:83
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
struct dsm_clock_data_2 data
Definition: irigclock.h:151
unsigned char max100HzBacklog
Definition: irigclock.h:137
Definition: irigclock.h:54
int64_t unixt
Definition: irigclock.h:131
unsigned char status
Definition: irigclock.h:133
dsm_sample_time_t timetag
Definition: irigclock.h:142
int dsm_sample_time_t
Depending on the module, either tenths of milliseconds, or milliseconds since 00:00 UTC today...
Definition: types.h:48
dsm_sample_time_t timetag
Definition: irigclock.h:149
int unregister_irig_callback(struct irig_callback *cb)
Modules call this function to dequeue their callbacks.
Definition: pc104sg.c:641
Definition: irigclock.h:155
char end[]
Definition: irigclock.h:113
int tv_usec
Definition: irigclock.h:96
uint32_t syncToggles
Counts of the number of times that the IRIG hardware clock has lost or regained sync.
Definition: irigclock.h:177
Definition: irigclock.h:94
Definition: irigclock.h:53
struct timeval32 irigt
Definition: irigclock.h:106
Definition: irigclock.h:54
unsigned char max100HzBacklog
Definition: irigclock.h:112
unsigned char syncToggles
Definition: irigclock.h:135
Definition: irigclock.h:141
struct dsm_clock_data_3 data
Definition: irigclock.h:158
int flush_irig_callbacks(void)
Definition: pc104sg.c:662
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
dsm_sample_length_t length
Definition: irigclock.h:143
unsigned char clockAdjusts
Definition: irigclock.h:136
unsigned char seqnum
Definition: irigclock.h:109
unsigned char statusOR
Value of extended status from PC104SG dual port RAM.
Definition: irigclock.h:206
dsm_sample_length_t length
Definition: irigclock.h:157
static float rate
Definition: sing.cc:53
int tv_sec
Definition: irigclock.h:95
Definition: irigclock.h:55
unsigned char clockAdjusts
Definition: irigclock.h:111
Note that a int64_t has the same size, 8 bytes, as a timeval32.
Definition: irigclock.h:129
Definition: irigclock.h:99
Definition: irigclock.h:54
struct dsm_clock_data data
Definition: irigclock.h:144
dsm_sample_time_t timetag
Definition: irigclock.h:156
#define IRIG_MIN_DT_DIFF
Definition: irigclock.h:169
unsigned int dsm_sample_length_t
length of data portion of sample.
Definition: types.h:51
dsm_sample_length_t length
Definition: irigclock.h:150
struct timeval32 tval
Definition: irigclock.h:100
unsigned char dummystatus
Definition: irigclock.h:132
Definition: irigclock.h:55
int get_msec_clock_resolution()
Definition: pc104sg.c:1455
irigClockRates
Enumeration of the callback rates supported by this module.
Definition: irigclock.h:52
unsigned char syncToggles
Definition: irigclock.h:110
struct timeval32 unixt
Definition: irigclock.h:107
int64_t irigt
Definition: irigclock.h:130
Definition: irigclock.h:53
uint32_t softwareClockResets
Total counts of the number of times that the sofware clock was reset with a step change.
Definition: irigclock.h:183
char end[]
Definition: irigclock.h:138