diff --git a/src/drv/gpstime/.gitignore b/src/drv/gpstime/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..18a1a62703a7690ad6d8e2ef6a0fc0707347c238 --- /dev/null +++ b/src/drv/gpstime/.gitignore @@ -0,0 +1,5 @@ +*.cmd +*.mod +*.mod.c +*.symvers +*.d diff --git a/src/drv/gpstime/gpstime.c b/src/drv/gpstime/gpstime.c index 08c4813e0dca9f61795218f80ad4e1027e84ad97..b4349cab908a99036ea3db2b7f88ea33bb39aa29 100644 --- a/src/drv/gpstime/gpstime.c +++ b/src/drv/gpstime/gpstime.c @@ -30,13 +30,11 @@ #endif #include <asm/io.h> #include "gpstime.h" +#include "gpstime_kernel.h" + #include "../../include/drv/cdsHardware.h" #include "../../include/proc.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) -#error "This kernel version is no longer supported" -#endif - CDS_HARDWARE cdsPciModules; #define IN_LIGO_GPS_KERNEL_DRIVER 1 @@ -65,7 +63,7 @@ static struct class* gpstime_class = NULL; static struct device* gpstime_device = NULL; static struct cdev symmetricom_cdev; static int card_present; -static int card_type; /* 0 - symmetricom; 1 - spectracom */ +static int card_type; /* 0 - symmetricom; 1 - spectracom; 2 - LIGO PCI */ /* methods of the character device */ static int symmetricom_open(struct inode *inode, struct file *filp); @@ -93,21 +91,6 @@ static int symmetricom_release(struct inode *inode, struct file *filp) return 0; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) -#define LIGO_TIMESPEC struct timespec - -static inline void ligo_get_current_kernel_time(LIGO_TIMESPEC *t) -{ - *t = current_kernel_time(); -} -#else -#define LIGO_TIMESPEC struct timespec64 - -static inline void ligo_get_current_kernel_time(LIGO_TIMESPEC* t) -{ - ktime_get_coarse_real_ts64(t); -} -#endif // Read current GPS time from the card int get_cur_time(unsigned long *req) { @@ -118,14 +101,14 @@ int get_cur_time(unsigned long *req) { offset = atomic64_read(&gps_offset); - if (card_present && card_type == 1) { + if (card_present && card_type == GPSTIME_SPECTRACOM_CARD) { sync = getGpsTimeTsync(&timeSec, &timeUsec); req[0] = timeSec; req[1] = timeUsec; req[2] = 0; - } else if (card_present && card_type == 0) { + } else if (card_present && card_type == GPSTIME_SYMMETRICOM_CARD) { lockGpsTime(); sync = getGpsTime(&timeSec, &timeUsec); req[0] = timeSec; req[1] = timeUsec; req[2] = 0; - } else if (card_present && card_type == 2) { // Ligo PCIe timing card + } else if (card_present && card_type == GPSTIME_LIGO_PCI_CARD) { sync = lptc_get_gps_time(&cdsPciModules, &timeSec, &timeUsec); req[0] = timeSec; req[1] = timeUsec; req[2] = 0; } else { @@ -283,7 +266,7 @@ static ssize_t gpstime_sysfs_gps_offset_store(struct kobject *kobj, struct kobj_ memset(localbuf, 0, CDS_LOCAL_GPS_BUFFER_SIZE+1); // The symmetricom driver doesn't need a tweak on the timing, so don't allow non-zero tweaks - if (card_present && card_type == 0) { + if (card_present && card_type == GPSTIME_SYMMETRICOM_CARD) { printk("gpstime_sysfs_gps_offset_store called when a symmetricom card is present, ignoring the value"); return full_count; } @@ -309,7 +292,7 @@ static ssize_t gpstime_sysfs_status_show(struct kobject *kobj, struct kobj_attri { unsigned long req[3]; int status; - if(card_type == 2) //LPTC + if(card_type == GPSTIME_LIGO_PCI_CARD) { status = lptc_get_lptc_status(&cdsPciModules); } @@ -354,6 +337,47 @@ long ligo_get_gps_driver_offset(void) return atomic64_read(&gps_offset); } +int ligo_gpstime_get_ts(LIGO_TIMESPEC * ts) +{ + long offset = 0; + unsigned int timeSec = 0; + unsigned int timeUsec = 0, save = 0; + int sync = 0; + + offset = atomic64_read(&gps_offset); + + // + // If we don't have a GPS card we return the system time + if( !card_present ) + { + ligo_get_current_kernel_time(ts); + ts->tv_sec += offset; + return 1; + } + + + switch (card_type) + { + case GPSTIME_SPECTRACOM_CARD: + sync = getGpsTimeTsync(&timeSec, &timeUsec); + save = timeUsec; + break; + case GPSTIME_SYMMETRICOM_CARD: + lockGpsTime(); + sync = getGpsTime(&timeSec, &timeUsec); + break; + case GPSTIME_LIGO_PCI_CARD: + sync = lptc_get_gps_time(&cdsPciModules, &timeSec, &timeUsec); + break; + default: + break; + } + + ts->tv_sec = timeSec; + ts->tv_nsec = timeUsec*1000; + ts->tv_sec += offset; + return sync; +} /* sysfs related structures */ static struct kobject *gpstime_sysfs_dir = NULL; @@ -442,7 +466,7 @@ static int __init symmetricom_init(void) symdev->bus->number, PCI_SLOT( symdev->devfn ) ); card_present = 1; - card_type = 2; + card_type = GPSTIME_LIGO_PCI_CARD; if( add_lptc_sys_files(gpstime_sysfs_dir) ) { @@ -458,7 +482,7 @@ static int __init symmetricom_init(void) symdev->bus->number, PCI_SLOT( symdev->devfn ) ); card_present = 1; - card_type = 0; + card_type = GPSTIME_SYMMETRICOM_CARD; } else { @@ -477,7 +501,7 @@ static int __init symmetricom_init(void) symdev->bus->number, PCI_SLOT( symdev->devfn ) ); card_present = 1; - card_type = 1; + card_type = GPSTIME_SPECTRACOM_CARD; } else { @@ -492,13 +516,13 @@ static int __init symmetricom_init(void) if (!card_present) { printk("Symmetricom/Spectracom GPS card not found\n"); gps_module_sync_type = STATUS_SYMMETRICOM_LOCALTIME_SYNC; - } else if (card_type == 1) { + } else if (card_type == GPSTIME_SPECTRACOM_CARD) { spectracomGpsInitCheckSync(&cdsPciModules, symdev, &card_needs_sync); gps_module_sync_type = ( card_needs_sync ? STATUS_SYMMETRICOM_YEAR_SYNC : STATUS_SYMMETRICOM_NO_SYNC); - } else if (card_type == 0) { + } else if (card_type == GPSTIME_SYMMETRICOM_CARD) { symmetricomGpsInit(&cdsPciModules, symdev); gps_module_sync_type = STATUS_SYMMETRICOM_NO_SYNC; - } else if (card_type == 2) { + } else if (card_type == GPSTIME_LIGO_PCI_CARD) { lptcInit(&cdsPciModules, symdev); gps_module_sync_type = STATUS_SYMMETRICOM_NO_SYNC; } @@ -536,6 +560,7 @@ static void __exit symmetricom_exit(void) } EXPORT_SYMBOL(ligo_get_gps_driver_offset); +EXPORT_SYMBOL(ligo_gpstime_get_ts); module_init(symmetricom_init); module_exit(symmetricom_exit); MODULE_DESCRIPTION("LIGO GPS time driver. Contains support for using Symmetricom/Spectricom cards and system time."); diff --git a/src/drv/gpstime/gpstime.h b/src/drv/gpstime/gpstime.h index 72ca215bbe522298b1eac9d2ef0db3a442f0c436..dd2dfa10e63849a9de32e2c35abe202cf8b914a3 100644 --- a/src/drv/gpstime/gpstime.h +++ b/src/drv/gpstime/gpstime.h @@ -1,3 +1,6 @@ +#ifndef LIGO_GPSTIME_H +#define LIGO_GPSTIME_H + // Get GPS card status (locked or unlocked) #define IOCTL_SYMMETRICOM_STATUS 0 @@ -11,3 +14,6 @@ #define STATUS_SYMMETRICOM_YEAR_SYNC 1 #define STATUS_SYMMETRICOM_LOCALTIME_SYNC 2 + + +#endif diff --git a/src/drv/gpstime/gpstime_kernel.h b/src/drv/gpstime/gpstime_kernel.h new file mode 100644 index 0000000000000000000000000000000000000000..f350f3038a430c251011c1aff37114a17ab35b19 --- /dev/null +++ b/src/drv/gpstime/gpstime_kernel.h @@ -0,0 +1,45 @@ +#ifndef LIGO_GPSTIME_KERNEL_H +#define LIGO_GPSTIME_KERNEL_H + +#include <linux/version.h> +#include <linux/time.h> + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +#error "This kernel version is no longer supported by the gpstime module" +#endif + +enum GPSTIME_CARD_TYPE +{ + GPSTIME_NO_CARD = -1, + GPSTIME_SYMMETRICOM_CARD = 0, + GPSTIME_SPECTRACOM_CARD = 1, + GPSTIME_LIGO_PCI_CARD = 2 +}; + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#define LIGO_TIMESPEC struct timespec + +static inline void ligo_get_current_kernel_time(LIGO_TIMESPEC *t) +{ + *t = current_kernel_time(); +} +#else +#define LIGO_TIMESPEC struct timespec64 + +static inline void ligo_get_current_kernel_time(LIGO_TIMESPEC* t) +{ + ktime_get_coarse_real_ts64(t); +} +#endif + +// +// Exported From the gpstime kernel module, for use by other +// kernel space modules +// +long ligo_get_gps_driver_offset( void ); +int ligo_gpstime_get_ts(LIGO_TIMESPEC * ts); + + +#endif diff --git a/src/drv/gpstime/lptc_sysfs.c b/src/drv/gpstime/lptc_sysfs.c index e7feb108d8ad51c53e6a20425ba2e32678c5c064..be7e4969f782db02a36d6b88e25f781fb40e33e3 100644 --- a/src/drv/gpstime/lptc_sysfs.c +++ b/src/drv/gpstime/lptc_sysfs.c @@ -125,7 +125,7 @@ static ssize_t lptc_sysfs_temp_show(struct kobject *kobj, struct kobj_attribute static ssize_t lptc_sysfs_internal_pwr_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - int i, numc; + int numc; u32 ips[2]; lptc_get_internal_pwr(&cdsPciModules, ips); numc = sysfs_emit(buf, "0x%x,0x%x", ips[0], ips[1]); @@ -315,4 +315,4 @@ add_lptc_sys_files(struct kobject *parent) } return 0; -} \ No newline at end of file +} diff --git a/src/drv/gpstime/tests/stress_and_verify/Makefile b/src/drv/gpstime/tests/stress_and_verify/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..1cf0d4dd3407f729454eab24209e58bdcecd025e --- /dev/null +++ b/src/drv/gpstime/tests/stress_and_verify/Makefile @@ -0,0 +1,31 @@ +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MKFILE_DIR := $(dir $(MKFILE_PATH)) + +# obj-m specifie we're a kernel module. +obj-m += gpstime_stress_and_verify.o +gpstime_stress_and_verify-objs := src/test.o + +ccflags-y := -I$(src)/../../ + +# Set the path to the Kernel build utils. +KBUILD=/lib/modules/$(shell uname -r)/build/ + + +GPSTIME_DIR_SYMFILE ?= $(MKFILE_DIR)/../../Module.symvers +ifneq ("$(wildcard $(GPSTIME_DIR_SYMFILE))","") +$(info Using symvers file at $(GPSTIME_DIR_SYMFILE)) +else +$(error You need to build the gpstime module in source, or set the GPSTIME_DIR_SYMFILE env var to point at the gpstime's Module.symvers file before building this module) +endif + +KBUILD_EXTRA_SYMBOLS := $(GPSTIME_DIR_SYMFILE) + +default: + $(MAKE) -C $(KBUILD) M=$(PWD) modules + +clean: + $(MAKE) -C $(KBUILD) M=$(PWD) clean + +menuconfig: + $(MAKE) -C $(KBUILD) M=$(PWD) menuconfig + diff --git a/src/drv/gpstime/tests/stress_and_verify/README.md b/src/drv/gpstime/tests/stress_and_verify/README.md new file mode 100644 index 0000000000000000000000000000000000000000..edf7b172d9ddca2844c1a0b253cbf697ec0a6326 --- /dev/null +++ b/src/drv/gpstime/tests/stress_and_verify/README.md @@ -0,0 +1,28 @@ +# gpstime_stress_and_verify +This is a module that stress tests and does some verification of the ligo_gpstime_get_ts() function provided by the gpstime module. The verification it does is a check to make sure the times returned are monotonic. This can catch issues were the wrong time is returned, or second rollover issues. + +## Running +Just load and unload the module with the `gpstime` module running. + +``` +sudo insmod gpstime_stress_and_verify.ko && sudo rmmod gpstime_stress_and_verify.ko +``` + +## Example Output +Output is printed to dmesg, tail with `sudo dmesg -w` + +### Run With Errors Detected +``` +[130876.840680] gpstime_stress_and_verify: module loaded at 0x000000005573f216 +[130876.840690] gpstime_stress_and_verify: Error time queried after a later time, run index 0, last_ts : {1328822227, 346717000}, new_ts: {1328822227, 175438000} +[130878.665299] gpstime_stress_and_verify: Error time queried after a later time, run index 244647, last_ts : {1328822229, 999999000}, new_ts: {1328822229, 3000} +[130884.297727] gpstime_stress_and_verify: Test Complete +[130884.297728] gpstime_stress_and_verify: module unloaded from 0x0000000025dcef09 +``` + +### Run With No Errors Detected +``` +[135009.635944] gpstime_stress_and_verify: module loaded at 0x0000000083050067 +[135017.095052] gpstime_stress_and_verify: Test Complete +[135017.095054] gpstime_stress_and_verify: module unloaded from 0x000000001aeac45b +``` diff --git a/src/drv/gpstime/tests/stress_and_verify/src/test.c b/src/drv/gpstime/tests/stress_and_verify/src/test.c new file mode 100644 index 0000000000000000000000000000000000000000..a966932bea043c102f673bf8829ba9317b5554e0 --- /dev/null +++ b/src/drv/gpstime/tests/stress_and_verify/src/test.c @@ -0,0 +1,59 @@ +#include <linux/module.h> +#include <linux/init.h> + +#include "gpstime_kernel.h" + +// Define the module metadata. +#define MODULE_NAME "gpstime_stress_and_verify" +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_DESCRIPTION("A module to stress test the ligo_gpstime_get_ts() function in the gpstime module"); +MODULE_VERSION("1.0"); + +int MP_NUM_REQS = 1e6; +module_param(MP_NUM_REQS, int, S_IRUSR); + +static int __init greeter_init(void) +{ + int i = 0; + pr_info("%s: module loaded at 0x%p\n", MODULE_NAME, greeter_init); + + LIGO_TIMESPEC new_ts, last_ts; + +/* + for(i = 0; i < MP_NUM_REQS; ++i) + { + ligo_gpstime_get_ts(&last_ts, force_sys_time); + pr_info("%s: gpstime is %lld, %lu\n", MODULE_NAME, last_ts.tv_sec, last_ts.tv_nsec); + }*/ + + + + ligo_gpstime_get_ts(&last_ts); + + for(i = 0; i < MP_NUM_REQS; ++i) + { + ligo_gpstime_get_ts(&new_ts); + if( timespec64_compare(&new_ts, &last_ts) < 0 ) + { + pr_info("%s: Error time queried after a later time, run index %d, last_ts : {%lld, %lu}, new_ts: {%lld, %lu}\n", + MODULE_NAME, + i, + last_ts.tv_sec, + last_ts.tv_nsec, + new_ts.tv_sec, + new_ts.tv_nsec); + } + ligo_gpstime_get_ts(&last_ts); + } + + return 0; +} + +static void __exit greeter_exit(void) +{ + pr_info("%s: Test Complete\n", MODULE_NAME); + pr_info("%s: module unloaded from 0x%p\n", MODULE_NAME, greeter_exit); +} + +module_init(greeter_init); +module_exit(greeter_exit); diff --git a/src/include/drv/ligoPcieTiming.c b/src/include/drv/ligoPcieTiming.c index 43c0785d475427e088db5c30c6121e3ceb56ee3a..10e848844f30e10545f42d2093826ae6ed8daef7 100644 --- a/src/include/drv/ligoPcieTiming.c +++ b/src/include/drv/ligoPcieTiming.c @@ -9,7 +9,7 @@ lptc_enable_all_slots( CDS_HARDWARE* pCds ) { unsigned int regval; int ii, jj; - LPTC_REGISTER* lptcPtr; + volatile LPTC_REGISTER* lptcPtr; for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { @@ -57,7 +57,7 @@ int lptc_start_clock( CDS_HARDWARE* pCds ) { int ii, jj; - LPTC_REGISTER* lptcPtr; + volatile LPTC_REGISTER* lptcPtr; for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { @@ -86,7 +86,7 @@ lptc_status_update( CDS_HARDWARE* pCds ) { int ii; - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; // Update lptc status to epics for ( ii = 0; ii < LPTC_IOC_SLOTS; ii++ ) pLocalEpics->epicsOutput.lptMon[ ii ] = @@ -106,7 +106,7 @@ int lptc_stop_clock( CDS_HARDWARE* pCds ) { int jj; - LPTC_REGISTER* lptcPtr; + volatile LPTC_REGISTER* lptcPtr; for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { @@ -121,7 +121,7 @@ lptc_stop_clock( CDS_HARDWARE* pCds ) void lptc_dac_duotone( CDS_HARDWARE* pCds, int setting ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; if ( setting ) { lptcPtr->slot_info[ 0 ].config |= LPTC_SCR_DAC_DT_ENABLE; @@ -141,7 +141,7 @@ lptc_slot_clk_set( CDS_HARDWARE* pCds, int slot, int enable ) for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; if ( enable ) lptcPtr->slot_info[ slot ].config |= LPTC_SCR_CLK_ENABLE; else @@ -157,7 +157,7 @@ lptc_slot_clk_disable_all( CDS_HARDWARE* pCds ) for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ jj ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ jj ]; for ( slot = 0; slot < LPTC_IOC_SLOTS; slot++ ) lptcPtr->slot_info[ slot ].config &= ~( LPTC_SCR_CLK_ENABLE ); } @@ -171,7 +171,7 @@ lptc_slot_clk_enable_all( CDS_HARDWARE* pCds ) for ( jj = 0; jj < pCds->card_count[ LPTC ]; jj++ ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ jj ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ jj ]; for ( slot = 0; slot < LPTC_IOC_SLOTS; slot++ ) lptcPtr->slot_info[ slot ].config |= LPTC_SCR_CLK_ENABLE; } diff --git a/src/include/drv/ligoPcieTiming.h b/src/include/drv/ligoPcieTiming.h index ae1a84ea8561e2d0edf9029a0559d8233165315d..8cb27c5fdfd6a91a745b2e914d4c0f99d8e2958a 100644 --- a/src/include/drv/ligoPcieTiming.h +++ b/src/include/drv/ligoPcieTiming.h @@ -64,7 +64,7 @@ void lptc_slot_clk_enable_all( CDS_HARDWARE* ); #define LPTC_BP_SLOTS 10 - +#define LPTC_OBF_EPS_REGS 8 typedef struct SLOT_CONFIG { @@ -93,7 +93,7 @@ typedef struct LPTC_OBF_REGISTER { u32 xadc_status; // 0x018c u32 tips1; // 0x0190 u32 ips2; // 0x0194 - u32 eps[8]; // 0x0198 + u32 eps[LPTC_OBF_EPS_REGS]; // 0x0198 }LPTC_OBF_REGISTER; // Data read from LPTC at 0x1000 offset diff --git a/src/include/drv/ligoPcieTiming_core.c b/src/include/drv/ligoPcieTiming_core.c index 4e8b5129a8cadbeb43425a9bd6fef536ba15d63c..7566af6be488f1c0ab450e7599953c91e35fe1d5 100644 --- a/src/include/drv/ligoPcieTiming_core.c +++ b/src/include/drv/ligoPcieTiming_core.c @@ -20,7 +20,7 @@ lptcInit( CDS_HARDWARE* pCds, struct pci_dev* lptcdev ) static unsigned int pci_io_addr; int status = 0; char* addr; - LPTC_REGISTER* lptcPtr; + volatile LPTC_REGISTER* lptcPtr; uint32_t usec, sec; unsigned int regval; int card = 0; @@ -90,7 +90,7 @@ lptc_get_gps_time( CDS_HARDWARE* pCds, uint32_t* sec, uint32_t* usec ) { volatile u64 regval; - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; regval = lptcPtr->gps_time; //*usec = (regval & 0xffffffff) * LPTC_USEC_CONVERT; *sec = (regval >> 32) & 0xffffffff; @@ -104,7 +104,7 @@ lptc_get_gps_usec( CDS_HARDWARE* pCds ) uint32_t timeval; volatile u64 regval; - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; regval = lptcPtr->gps_time; //timeval = (regval & 0xffffffff) * LPTC_USEC_CONVERT; timeval = lptc_usec_convert_int((uint32_t)(regval & 0xffffffff)); @@ -117,7 +117,7 @@ lptc_get_gps_sec( CDS_HARDWARE* pCds ) volatile u64 regval; unsigned int sec; - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; regval = lptcPtr->gps_time; sec = (regval >> 32) & 0xffffffff; return sec; @@ -127,42 +127,42 @@ lptc_get_gps_sec( CDS_HARDWARE* pCds ) int lptc_get_lptc_status( CDS_HARDWARE* pCds ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return lptcPtr->status; } int lptc_get_bp_status( CDS_HARDWARE* pCds ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return lptcPtr->bp_status; } int lptc_get_bp_config( CDS_HARDWARE* pCds ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return lptcPtr->bp_config; } int lptc_get_slot_config( CDS_HARDWARE* pCds, int slot ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return ( lptcPtr->slot_info[ slot ].config & 0xffffff ); } int lptc_get_slot_status( CDS_HARDWARE* pCds, int slot ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return ( lptcPtr->slot_info[ slot ].status & 0xffffff ); } int lptc_get_slot_phase( CDS_HARDWARE* pCds, int slot ) { - LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER* lptcPtr = (LPTC_REGISTER*)pCds->lptc[ 0 ]; return ( lptcPtr->slot_info[ slot ].phase); } @@ -170,28 +170,28 @@ lptc_get_slot_phase( CDS_HARDWARE* pCds, int slot ) int lptc_get_board_id( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.board_id; } int lptc_get_board_sn( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.board_sn; } int lptc_get_software_id( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.sftware_id; } int lptc_get_software_rev( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.sftware_rev; } @@ -199,14 +199,14 @@ lptc_get_software_rev( CDS_HARDWARE* pCds ) int lptc_get_gps_sec_diag( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.gps_seconds; } int lptc_get_mod_address( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.mod_address; } @@ -214,14 +214,14 @@ lptc_get_mod_address( CDS_HARDWARE* pCds ) int lptc_get_board_status( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.board_status; } int lptc_get_board_config( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.board_config; } @@ -229,56 +229,56 @@ lptc_get_board_config( CDS_HARDWARE* pCds ) int lptc_get_ocxo_controls( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.ocxo_controls; } int lptc_get_ocxo_error( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.ocxo_error; } int lptc_get_uplink_1pps_delay( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.uplink_1pps_delay; } int lptc_get_external_1pps_delay( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.external_1pps_delay; } int lptc_get_gps_1pps_delay( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE *)pCds->lptc[ 0 ]; return lptcPtr->diag_info.gps_1pps_delay; } int lptc_get_fanout_up_loss( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->diag_info.external_1pps_delay; } int lptc_get_fanout_missing_delay_error( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->diag_info.fanout_missing_delay_error; } int lptc_get_leaps_and_error( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->diag_info.leaps_and_error; } @@ -286,28 +286,28 @@ lptc_get_leaps_and_error( CDS_HARDWARE* pCds ) int lptc_get_brd_synch_factors( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->obf_registers.brd_config; } int lptc_get_xadc_config( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->obf_registers.xadc_config; } int lptc_get_board_and_powersupply_status( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->obf_registers.bps_status; } int lptc_get_xadc_status( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->obf_registers.xadc_status; } @@ -315,7 +315,7 @@ lptc_get_xadc_status( CDS_HARDWARE* pCds ) int lptc_get_temp( CDS_HARDWARE* pCds ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; return lptcPtr->obf_registers.tips1 & 0xffff; } @@ -323,7 +323,7 @@ lptc_get_temp( CDS_HARDWARE* pCds ) void lptc_get_internal_pwr( CDS_HARDWARE* pCds, u32 *output ) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; output[0] = lptcPtr->obf_registers.tips1 & 0xffff0000; output[1] = lptcPtr->obf_registers.ips2; } @@ -332,12 +332,16 @@ lptc_get_internal_pwr( CDS_HARDWARE* pCds, u32 *output ) // LPTC_OBF_REGISTER:EPS void lptc_get_external_pwr( CDS_HARDWARE* pCds, u32 *output) { - LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; + int i; + volatile LPTC_REGISTER_SPACE* lptcPtr = (LPTC_REGISTER_SPACE*)pCds->lptc[ 0 ]; if(NULL != output) { - memcpy(output, lptcPtr->obf_registers.eps, sizeof(lptcPtr->obf_registers.eps)); + for(i = 0; i < LPTC_OBF_EPS_REGS; ++i) + { + output[i] = lptcPtr->obf_registers.eps[i]; + } } } -#endif /* LIGO_PCIE_TIMING_CORE_IMPL */ \ No newline at end of file +#endif /* LIGO_PCIE_TIMING_CORE_IMPL */ diff --git a/src/include/drv/spectracomGPS.c b/src/include/drv/spectracomGPS.c index 7aa0af2b5836822fb297798bb90b30f8ed779155..d8226a096a315560528b945524058682c36945be 100644 --- a/src/include/drv/spectracomGPS.c +++ b/src/include/drv/spectracomGPS.c @@ -29,7 +29,7 @@ spectracomGpsInitCheckSync( CDS_HARDWARE* pHardware, int pedStatus; unsigned int days, hours, min, sec, msec, usec, nanosec, tsync; unsigned char* addr1; - TSYNC_REGISTER* myTime; + volatile TSYNC_REGISTER* myTime; void* TSYNC_FIFO; /// @param *TSYNC_FIFO Pointer to board uP FIFO int sync_dummy = 0; @@ -186,7 +186,7 @@ spectracomGpsInit( CDS_HARDWARE* pHardware, struct pci_dev* gpsdev ) inline int getGpsTimeTsync( unsigned int* tsyncSec, unsigned int* tsyncUsec ) { - TSYNC_REGISTER* timeRead; + volatile TSYNC_REGISTER* timeRead; unsigned int timeSec, timeNsec, sync; if ( cdsPciModules.gps ) @@ -209,7 +209,7 @@ getGpsTimeTsync( unsigned int* tsyncSec, unsigned int* tsyncUsec ) inline unsigned int getGpsSecTsync( void ) { - TSYNC_REGISTER* timeRead; + volatile TSYNC_REGISTER* timeRead; unsigned int timeSec; if ( cdsPciModules.gps ) @@ -230,7 +230,7 @@ getGpsSecTsync( void ) inline int getGpsuSecTsync( unsigned int* tsyncUsec ) { - TSYNC_REGISTER* timeRead; + volatile TSYNC_REGISTER* timeRead; unsigned int timeNsec, sync; if ( cdsPciModules.gps ) diff --git a/src/include/drv/symmetricomGps.c b/src/include/drv/symmetricomGps.c index 911ef1868932cdc2ade2ad5e547ce2895dff7861..345b94b06d22e793289ba091feb208e9f30a8f63 100644 --- a/src/include/drv/symmetricomGps.c +++ b/src/include/drv/symmetricomGps.c @@ -15,7 +15,7 @@ symmetricomGpsInit( CDS_HARDWARE* pHardware, struct pci_dev* gpsdev ) unsigned int* cmd; unsigned int* dramRead; unsigned int time0; - SYMCOM_REGISTER* timeReg; + volatile SYMCOM_REGISTER* timeReg; pedStatus = pci_enable_device( gpsdev ); pci_read_config_dword( gpsdev, PCI_BASE_ADDRESS_2, &pci_io_addr ); @@ -138,7 +138,7 @@ symmetricomGpsInit( CDS_HARDWARE* pHardware, struct pci_dev* gpsdev ) inline void lockGpsTime( void ) { - SYMCOM_REGISTER* timeRead; + volatile SYMCOM_REGISTER* timeRead; timeRead = (SYMCOM_REGISTER*)cdsPciModules.gps; timeRead->TIMEREQ = 1; // Trigger module to capture time } @@ -149,7 +149,7 @@ lockGpsTime( void ) inline int getGpsTime( unsigned int* tsyncSec, unsigned int* tsyncUsec ) { - SYMCOM_REGISTER* timeRead; + volatile SYMCOM_REGISTER* timeRead; unsigned int timeSec, timeNsec, sync; if ( cdsPciModules.gps )