diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2011-12-02 12:00:00 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2011-12-02 12:00:00 +0100 |
commit | 72685dddea57d0546d59ce869b3d2adabd25c370 (patch) | |
tree | f02e12519be7dba6eec4f5584ce6e047c1386fb5 | |
parent | 014f1d176c48687acca32199f653ae78a861beab (diff) | |
download | mbgtools-fbsd-72685dddea57d0546d59ce869b3d2adabd25c370.tar.gz mbgtools-fbsd-72685dddea57d0546d59ce869b3d2adabd25c370.zip |
Update some files to current versionsmbgtools-fbsd-dev-2011-12-02
Remove obsolete files mbglib/common/extiohlp.{c,h}.
-rwxr-xr-x | Makefile | 13 | ||||
-rwxr-xr-x | mbgclock/mbgclock_main.c | 7 | ||||
-rwxr-xr-x | mbgfasttstamp/Makefile | 5 | ||||
-rwxr-xr-x | mbgfasttstamp/mbgfasttstamp.c | 2 | ||||
-rwxr-xr-x | mbglib/common/extiohlp.c | 119 | ||||
-rwxr-xr-x | mbglib/common/extiohlp.h | 114 | ||||
-rwxr-xr-x | mbglib/common/gpsdefs.h | 433 | ||||
-rwxr-xr-x | mbglib/common/macioctl.h | 56 | ||||
-rwxr-xr-x | mbglib/common/mbg_tgt.h | 2 | ||||
-rwxr-xr-x | mbglib/common/mbgddmsg.h | 8 | ||||
-rwxr-xr-x | mbglib/common/mbgdevio.c | 214 | ||||
-rwxr-xr-x | mbglib/common/mbgdevio.h | 187 | ||||
-rwxr-xr-x | mbglib/common/mbggeo.h | 2 | ||||
-rwxr-xr-x | mbglib/common/mbgioctl.h | 31 | ||||
-rwxr-xr-x | mbglib/common/mbgmutex.h | 6 | ||||
-rwxr-xr-x | mbglib/common/mbgtime.h | 7 | ||||
-rwxr-xr-x | mbglib/common/mbgutil.c | 10 | ||||
-rwxr-xr-x | mbglib/common/parmgps.h | 2 | ||||
-rwxr-xr-x | mbglib/common/pcpsdefs.h | 113 | ||||
-rwxr-xr-x | mbglib/common/pcpsdev.h | 115 | ||||
-rwxr-xr-x | mbglib/common/pcpsdrvr.c | 402 | ||||
-rwxr-xr-x | mbglib/common/pcpsdrvr.h | 33 | ||||
-rwxr-xr-x | mbglib/common/toolutil.c | 11 | ||||
-rwxr-xr-x | mbglib/common/usbdefs.h | 16 | ||||
-rwxr-xr-x | mbgstatus/mbgstatus.c | 47 | ||||
-rwxr-xr-x | mbgsvcd/Makefile | 2 | ||||
-rwxr-xr-x | mbgsvcd/mbgsvcd.c | 85 |
27 files changed, 1565 insertions, 477 deletions
@@ -1,13 +1,14 @@ ######################################################################### # -# $Id: Makefile 1.1.1.7 2011/07/06 13:25:06 martin TEST $ +# $Id: Makefile 1.1.1.8 2011/11/24 11:25:00 martin TRASH $ # # Description: # Makefile for mbgtools which recurses into the subdirectories. # # ----------------------------------------------------------------------- # $Log: Makefile $ +# Revision 1.1.1.8 2011/11/24 11:25:00 martin # Revision 1.1.1.7 2011/07/06 13:25:06 martin # Revision 1.1.1.6 2011/03/25 11:05:55 martin # Optional parameter USE_TIMESPEC. @@ -117,6 +118,7 @@ chk_subdir = $(shell test -f $(strip $(1))/Makefile && echo "$(1)" ) SUBDIRS += $(call chk_subdir, "mbgfasttstamp" ) SUBDIRS += $(call chk_subdir, "mbgsvcd" ) SUBDIRS += $(call chk_subdir, "mbgxhrtime" ) + SUBDIRS += $(call chk_subdir, "test/mbgtestcalrec" ) SUBDIRS += $(call chk_subdir, "test/mbgtestio" ) SUBDIRS += $(call chk_subdir, "test/mbgtestmmio" ) SUBDIRS += $(call chk_subdir, "test/mbgtestxhrt" ) @@ -154,10 +156,11 @@ SUBDIRS += mbggpscap SUBDIRS += mbghrtime SUBDIRS += mbgfasttstamp # SUBDIRS += mbgxhrtime ## not yet tested -SUBDIRS += test/mbgtestio -SUBDIRS += test/mbgtestmmio -SUBDIRS += test/mbgtestxhrt -SUBDIRS += test/mbgchksystime +SUBDIRS += test/mbgtestcalrec +# SUBDIRS += test/mbgtestio +# SUBDIRS += test/mbgtestmmio +# SUBDIRS += test/mbgtestxhrt +# SUBDIRS += test/mbgchksystime SUBDIRS += mbgclock .PHONY: all clean distclean install uninstall diff --git a/mbgclock/mbgclock_main.c b/mbgclock/mbgclock_main.c index 5bfe8c7..7eced2c 100755 --- a/mbgclock/mbgclock_main.c +++ b/mbgclock/mbgclock_main.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgclock_main.c 1.1.1.12 2011/10/05 10:38:06 martin TEST $ + * $Id: mbgclock_main.c 1.1.1.13 2011/11/01 09:08:33 martin TRASH $ * * Description: * Main file for for mbgclock driver to support Meinberg bus level @@ -14,6 +14,7 @@ * * ----------------------------------------------------------------------- * $Log: mbgclock_main.c $ + * Revision 1.1.1.13 2011/11/01 09:08:33 martin * Revision 1.1.1.12 2011/10/05 10:38:06 martin * Unified handling of program version information. * Started to support privilege checking for IOCTL. @@ -78,10 +79,6 @@ static PCPS_IO_ADDR_MAPPED mbg_dbg_port_mapped; //##++ static PCPS_DRVR_INFO drvr_info = { MBG_VERSION_CODE( MBG_MICRO_VERSION_CODE ), 0, MBG_DRVR_NAME " radio clock driver" }; -#if defined( DEBUG ) -int debug = DEBUG; -#endif - MALLOC_DEFINE( M_MBGCLOCK, "short desc", "long desc" ); #include <macioctl.h> diff --git a/mbgfasttstamp/Makefile b/mbgfasttstamp/Makefile index 92cfa46..e46181a 100755 --- a/mbgfasttstamp/Makefile +++ b/mbgfasttstamp/Makefile @@ -1,13 +1,14 @@ ######################################################################### # -# $Id: Makefile 1.2.1.2 2010/08/30 09:05:23 martin TEST $ +# $Id: Makefile 1.2.1.3 2011/11/23 17:58:59 martin TRASH $ # # Description: # Makefile for mbgfasttstamp. # # ----------------------------------------------------------------------- # $Log: Makefile $ +# Revision 1.2.1.3 2011/11/23 17:58:59 martin # Revision 1.2.1.2 2010/08/30 09:05:23 martin # Revision 1.2.1.1 2010/08/30 08:21:01 martin # Revision 1.2 2009/07/24 10:31:16 martin @@ -18,7 +19,7 @@ ######################################################################### TARGET = mbgfasttstamp -INST_DIR = /usr/local/bin +INST_TO_BIN = 1 OBJS = $(TARGET).o OBJS += mbgdevio.o diff --git a/mbgfasttstamp/mbgfasttstamp.c b/mbgfasttstamp/mbgfasttstamp.c index 4388591..360d5dc 100755 --- a/mbgfasttstamp/mbgfasttstamp.c +++ b/mbgfasttstamp/mbgfasttstamp.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgfasttstamp.c 1.6.1.4 2011/09/26 16:00:51 martin TEST $ + * $Id: mbgfasttstamp.c 1.6.1.4 2011/09/26 16:00:51 martin TEST martin $ * * Description: * Main file for mbgfasttstamp program which demonstrates how to access diff --git a/mbglib/common/extiohlp.c b/mbglib/common/extiohlp.c deleted file mode 100755 index ffcd1e2..0000000 --- a/mbglib/common/extiohlp.c +++ /dev/null @@ -1,119 +0,0 @@ - -/************************************************************************** - * - * $Id: extiohlp.c 1.1 2011/09/21 15:59:59 martin TEST $ - * - * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany - * - * Description: - * Device configuration helper functions. This is an extension to - * mbgextio.c providing useful functions to simplify reading/writing - * complex device configuration structure sets. - * - * Warning: - * These functions should not be implemented in a DLL / shared library - * since the parameter sizes might vary with different versions - * of the API calls, which which would make different versions of - * precompiled libraries incompatible to each other. - * - * ----------------------------------------------------------------------- - * $Log: extiohlp.c $ - * Revision 1.1 2011/09/21 15:59:59 martin - * Initial revision. - * - **************************************************************************/ - -#define _EXTIOHLP - #include <extiohlp.h> -#undef _EXTIOHLP - -#include <mbgerror.h> //##++ Do we need this ?? - -/*HDR*/ -/** - Read all serial port settings and supported configuration parameters. - from a non bus level device - - The function mbgextio_get_receiver_info() - must have been called before, and the returned ::RECEIVER_INFO - structures must be passed to this function. - - The complementary function mbgextio_save_serial_settings() should be used - to write the modified serial port configuration via serial connection back to the board. - - @param dh Valid handle to a Meinberg device. - @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure to be filled up. - @param *p_ri Pointer to a ::RECEIVER_INFO structure. - - @return ::MBG_SUCCESS or error code returned by device I/O control function. - - @see mbgextio_get_receiver_info() - @see mbgextio_save_serial_settings() -*/ -int mbgextio_get_serial_settings( MBG_MSG_CTL *dh, RECEIVER_PORT_CFG *pcfg, const RECEIVER_INFO *p_ri ) -{ - int rc; - uint16_t i; - - memset( pcfg, 0, sizeof( *pcfg ) ); - - for ( i = 0; i < p_ri->n_com_ports; i++ ) - { - rc = mbgextio_get_port_info_idx( dh, &pcfg->pii[i], i ); - if ( rc < 0 ) - return rc; - } - for ( i = 0; i < p_ri->n_str_type; i++ ) - { - rc = mbgextio_get_str_type_info_idx( dh, &pcfg->stii[i], i ); - if ( rc < 0 ) - return rc; - } - - return TR_COMPLETE; // success -> mbgextio -> TR_COMPLETE = 2 //##+++++ marvin -} - - - -/*HDR*/ -/** - Write the configuration settings for a single serial port via serial connection to the board. - - Modifications to the serial port configuration should be made only - after mbgextio_get_serial_settings() had been called to read all serial port - settings and supported configuration parameters. - This function has finally to be called once for every serial port - the configuration of which has been modified. - - As also required by mbgextio_get_serial_settings(), the function - mbgextio_get_receiver_info() must have been - called before, and the returned ::RECEIVER_INFO structure - must be passed to this function. - - @param dh Valid handle to a Meinberg device via serial connection - @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure - @param port_num Index of the ::serial port to be saved - - @return ::MBG_SUCCESS or error code returned by device I/O control function. - - @see mbgextio_get_serial_settings() - @see mbgextio_get_receiver_info() -*/ -int mbgextio_save_serial_settings( MBG_MSG_CTL *dh, RECEIVER_PORT_CFG *pcfg, int port_num ) -{ - int rc; - - rc = mbgextio_set_port_settings_idx( dh, &pcfg->pii[port_num].port_info.port_settings, port_num ); - - if ( rc != 0 ) //##++++++++++++++++++ - return !MBG_SUCCESS; - -/* rc = mbgextio_get_str_type_info_idx( dh, &pcfg->stii[i], i ); - if(rc != 0) - return !MBG_SUCCESS; - */ - - return 0; // success - -} //mbgextio_save_serial_settings - diff --git a/mbglib/common/extiohlp.h b/mbglib/common/extiohlp.h deleted file mode 100755 index c0c707a..0000000 --- a/mbglib/common/extiohlp.h +++ /dev/null @@ -1,114 +0,0 @@ - -/************************************************************************** - * - * $Id: extiohlp.h 1.1 2011/09/21 15:59:59 martin TEST $ - * - * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany - * - * Description: - * Definitions and prototypes for extiohlp.c. - * - * ----------------------------------------------------------------------- - * $Log: extiohlp.h $ - * Revision 1.1 2011/09/21 15:59:59 martin - * Initial revision. - * - **************************************************************************/ - -#ifndef _EXTIOHLP_H -#define _EXTIOHLP_H - - -/* Other headers to be included */ - -#include <mbgextio.h> - -#include <cfg_hlp.h> - - -#ifdef _EXTIOHLP - #define _ext - #define _DO_INIT -#else - #define _ext extern -#endif - - -/* Start of header body */ - -#ifdef __cplusplus -extern "C" { -#endif - - - - - -/* function prototypes: */ - -/* ----- function prototypes begin ----- */ - -/* This section was generated automatically */ -/* by MAKEHDR, do not remove the comments. */ - - /** - Read all serial port settings and supported configuration parameters. - from a non bus level device - - The function mbgextio_get_receiver_info() - must have been called before, and the returned ::RECEIVER_INFO - structures must be passed to this function. - - The complementary function mbgextio_save_serial_settings() should be used - to write the modified serial port configuration via serial connection back to the board. - - @param dh Valid handle to a Meinberg device. - @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure to be filled up. - @param *p_ri Pointer to a ::RECEIVER_INFO structure. - - @return ::MBG_SUCCESS or error code returned by device I/O control function. - - @see mbgextio_get_receiver_info() - @see mbgextio_save_serial_settings() -*/ - int mbgextio_get_serial_settings( MBG_MSG_CTL *dh, RECEIVER_PORT_CFG *pcfg, const RECEIVER_INFO *p_ri ) ; - - /** - Write the configuration settings for a single serial port via serial connection to the board. - - Modifications to the serial port configuration should be made only - after mbgextio_get_serial_settings() had been called to read all serial port - settings and supported configuration parameters. - This function has finally to be called once for every serial port - the configuration of which has been modified. - - As also required by mbgextio_get_serial_settings(), the function - mbgextio_get_receiver_info() must have been - called before, and the returned ::RECEIVER_INFO structure - must be passed to this function. - - @param dh Valid handle to a Meinberg device via serial connection - @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure - @param port_num Index of the ::serial port to be saved - - @return ::MBG_SUCCESS or error code returned by device I/O control function. - - @see mbgextio_get_serial_settings() - @see mbgextio_get_receiver_info() -*/ - int mbgextio_save_serial_settings( MBG_MSG_CTL *dh, RECEIVER_PORT_CFG *pcfg, int port_num ) ; - - -/* ----- function prototypes end ----- */ - -#ifdef __cplusplus -} -#endif - - -/* End of header body */ - -#undef _ext -#undef _DO_INIT - -#endif /* _EXTIOHLP_H */ diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h index 77797c3..5c1d023 100755 --- a/mbglib/common/gpsdefs.h +++ b/mbglib/common/gpsdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: gpsdefs.h 1.95 2011/10/04 09:35:41 martin REL_M $ + * $Id: gpsdefs.h 1.98 2011/11/25 14:58:34 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -13,7 +13,19 @@ * * ----------------------------------------------------------------------- * $Log: gpsdefs.h $ - * Revision 1.95 2011/10/04 09:35:41 martin + * Revision 1.98 2011/11/25 14:58:34 martin + * Renamed some evt_log definitions. + * Revision 1.97 2011/11/25 10:11:17 martin + * Initializers for XMRS status bit strings added by gregoire. + * New feature GPS_FEAT_EVT_LOG. + * Added definitions used with event logs. + * Moved cal_reg and gen_io stuff here. + * Added macro _mbg_swab_debug_status(). + * Updated some comments. + * Revision 1.96 2011/10/11 13:40:46Z andre + * changed reserved field into slot_id in XMULTI_REF_INSTANCES + * Revision 1.95.1.1 2011/10/07 09:31:58Z andre + * Revision 1.95 2011/10/04 09:35:41Z martin * Added support for ESI180. * Changed RECEIVER_INFO::flags bit GPS_10MHZ_DISBD to a RECEIVER_INFO::features bit. * Support MULTI_REF_INTERNAL, MULTI_REF_LWR and MULTI_REF_PZF. @@ -600,6 +612,7 @@ enum GPS_MODEL_GPS180HS, GPS_MODEL_GPS180AMC, GPS_MODEL_ESI180, + GPS_MODEL_CPE180, N_GPS_MODEL /* If new model codes are added then care must be taken * to update the associated string initializers below @@ -656,7 +669,7 @@ enum #define GPS_MODEL_NAME_GPS180HS "GPS180HS" #define GPS_MODEL_NAME_GPS180AMC "GPS180AMC" #define GPS_MODEL_NAME_ESI180 "ESI180" - +#define GPS_MODEL_NAME_CPE180 "CPE180" /* * The definition below can be used to initialize @@ -707,7 +720,8 @@ enum GPS_MODEL_NAME_JJY600, \ GPS_MODEL_NAME_GPS180HS, \ GPS_MODEL_NAME_GPS180AMC, \ - GPS_MODEL_NAME_ESI180 \ + GPS_MODEL_NAME_ESI180, \ + GPS_MODEL_NAME_CPE180 \ } @@ -889,6 +903,7 @@ enum GPS_FEAT_GPIO, /**< has general purpose in/outputs */ GPS_FEAT_XMRS_MULT_INSTC, /**< multiple XMRS instances of the same ref type supported, @see XMRSF_BIT_MULT_INSTC_SUPP */ GPS_FEAT_10MHZ_DISBD, /**< 10 MHz output is always disabled */ + GPS_FEAT_EVT_LOG, /**< Event logging supported */ N_GPS_FEATURE /**< the number of valid features */ }; @@ -917,8 +932,9 @@ enum "Raw IRIG Time", \ "PTP/IEEE1588 Unicast", \ "General Purpose I/O", \ - "Multiple XMRS instances", \ - "10 MHz Output Disabled" \ + "Multiple XMRS Instances", \ + "10 MHz Output Disabled", \ + "Event Logging" \ } @@ -949,6 +965,7 @@ enum #define GPS_HAS_GPIO ( 1UL << GPS_FEAT_GPIO ) #define GPS_HAS_XMRS_MULT_INSTC ( 1UL << GPS_FEAT_XMRS_MULT_INSTC ) #define GPS_HAS_10MHZ_DISBD ( 1UL << GPS_FEAT_10MHZ_DISBD ) +#define GPS_HAS_EVT_LOG ( 1UL << GPS_FEAT_EVT_LOG ) #define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX @@ -2640,10 +2657,126 @@ typedef struct } +/** + * @defgroup group_irig_comp IRIG input delay compensation + * + * These definitions are used with IRIG RX delay compensation + * which is supported by some IRIG receivers. Delay compensation + * depends on the basic frame type, so there are different records + * required for the different frame type groups. + * @{ */ + +/** + * The number of coefficients of a compensation record + * for a single frame type group, and the structure + * which contains those coefficients + */ +#define N_IRIG_RX_COMP_VAL 4 + +/** @brief A structure which stores compensation values. */ +typedef struct +{ + int16_t c[N_IRIG_RX_COMP_VAL]; /**< compensation values [100 ns units] */ +} IRIG_RX_COMP; + +#define _mbg_swab_irig_rx_comp( _p ) \ +{ \ + int i; \ + for ( i = 0; i < N_IRIG_RX_COMP_VAL; i++ ) \ + _mbg_swab16( &(_p)->c[i] ); \ +} + + +/** @brief Structure used to retrieve the number of calibration records. */ +typedef struct +{ + uint16_t num; /**< number of records supported by the device, */ + uint16_t rec_size; /**< size of one record, in bytes */ +} CAL_REC_INFO; + +#define _mbg_swab_cal_rec_info( _p ) \ +{ \ + _mbg_swab16( &(_p)->num ); \ + _mbg_swab16( &(_p)->rec_size ); \ +} + + +/** @brief Structure used to retrieve the number of records for a given type */ +typedef struct +{ + uint16_t type; /**< record type */ + uint16_t idx; /**< index if several records of same type are supported */ +} CAL_REC_HDR; + +#define _mbg_swab_cal_rec_hdr( _p ) \ +{ \ + _mbg_swab16( &(_p)->type ); \ + _mbg_swab16( &(_p)->idx ); \ +} + + +/** @brief Types to be used with CAL_REC_HDR::type */ +enum +{ + CAL_REC_TYPE_UNDEF, /**< undefined */ + CAL_REC_TYPE_IRIG_RX_COMP, /**< IRIG receiver delay compensation */ + N_CAL_REC_TYPE /**< number of known types */ +}; + + +/** + * @brief Types to be used with CAL_REC_HDR::idx + * + * IRIG frame type groups to be distinguished for delay compensation. + */ +enum +{ + IRIG_RX_COMP_B1, /**< codes B1xx, AFNOR, IEEE1344 */ + IRIG_RX_COMP_A1, /**< code A1xx */ + IRIG_RX_COMP_B0, /**< codes B0xx, AFNOR DC, IEEE1344 DC */ + IRIG_RX_COMP_A0, /**< code A0xx */ + N_IRIG_RX_COMP /**< number of compensation values */ +}; + + +/** @brief Initializers for format name strings. */ +#define DEFAULT_IRIG_RX_COMP_NAMES \ +{ \ + "B1xx/AFNOR/IEEE1344", \ + "A1xx", \ + "B0xx/AFNOR DC/IEEE1344 DC", \ + "A0xx", \ +} + + + +/** @brief Structure used to transfer calibration records. */ +typedef struct +{ + CAL_REC_HDR hdr; + IRIG_RX_COMP comp_data; /**< IRIG receiver delay compensation */ + +} CAL_REC_IRIG_RX_COMP; + +#define _mbg_swab_cal_rec_irig_rx_comp( _p ) \ +{ \ + _mbg_swab_cal_rec_hdr( &(_p)->hdr ); \ + _mbg_swab_irig_rx_comp( &(_p)->comp_datam ); \ +} + +/** @} group_irig_comp */ + + + // The type below is used to read the board's debug status // which also include IRIG decoder status: typedef uint32_t MBG_DEBUG_STATUS; +#define _mbg_swab_debug_status( _p ) \ + _mbg_swab32( _p ) + + + // The debug status is bit coded as defined below: enum { @@ -3452,8 +3585,8 @@ typedef struct /** * @brief Bits and masks used with XMULTI_REF_STATUS::flags * - * @note If XMRS_FLAG_MULT_INSTC_SUPP is set then the API calls to read - * XMULTI_REF_INSTANCES is supported, otherwise it is not. + * @note This API is only supported if bit GPS_HAS_XMRS_MULT_INSTC + * is set in RECEIVER_INFO::features. */ enum { @@ -3512,6 +3645,22 @@ enum #define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC ) #define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL ) +/* + * Initializers for XMRS status bit strings. + */ +#define MBG_XMRS_STATUS_STRS \ +{ \ + "Ref type not supported", \ + "No connection", \ + "No signal", \ + "Is Master", \ + "Is locked", \ + "Is accuracte", \ + "Not settled", \ + "Phase not locked", \ + "Number sources exceeds limit", \ + "Is external" \ +} /* @@ -3530,15 +3679,16 @@ enum /** * @brief The number of supported instances of each ref source type * - * @note This structure is only supported if bit XMRS_FLAG_MULT_INSTC_SUPP - * is set in XMULTI_REF_STATUS::flags. + * @note This structure is only supported if bit GPS_HAS_XMRS_MULT_INSTC + * is set in RECEIVER_INFO::features. */ typedef struct { uint32_t flags; /**< currently always 0 */ uint16_t n_xmr_settings; /**< number of configurable multi ref settings */ - uint16_t reserved; /**< number of configurable multi ref settings */ - uint8_t n_inst[32]; /**< N_MULTI_REF entries used, but can not exceed bit number of uint32_t - 1 */ + uint8_t slot_id; /**< current slot ID of board ( 0..15 ) */ + uint8_t reserved; /**< reserved */ + uint8_t n_inst[32]; /**< N_MULTI_REF entries used, but can not exceed bit number of uint32_t - 1 */ } XMULTI_REF_INSTANCES; /** @} group_xmr_cfg */ @@ -3643,23 +3793,27 @@ typedef struct * @brief A structure used to configure a GPIO as BITS module */ -typedef struct { +typedef struct +{ MBG_GPIO_BITS bits; /**< DS Settings for building integrated timing supply */ uint32_t csc_limit; /**< max. cycle slip [1/1000 cycle units] */ - - union { - struct { + + union + { + struct + { uint8_t ssm; /**< minimum E1 SSM ( 0...15 ) for acceptance */ uint8_t sa_bits; /**< Sa Bits group ( 4...8 ) carrying SSM */ uint16_t reserve; } e1; - - struct { + + struct + { uint8_t min_boc; uint8_t reserve_0; uint16_t reserve_1; - } t1; - + } t1; + uint32_t u32; } quality; @@ -3709,8 +3863,6 @@ typedef struct - - /** * @brief A structure used to configure a specific GPIO port */ @@ -3787,6 +3939,20 @@ enum #define MSK_MBG_GPIO_FIXED_FREQ_10MHz ( 1UL << MBG_GPIO_FIXED_FREQ_10MHz ) #define MSK_MBG_GPIO_FIXED_FREQ_19440kHz ( 1UL << MBG_GPIO_FIXED_FREQ_19440kHz ) +/* + * Initializers for GPIO fixed frequency strings. + */ +#define MBG_GPIO_FIXED_FREQ_STRS \ +{ \ + "8kHz", \ + "48kHz", \ + "1MHz", \ + "1544kHz", \ + "2048kHz", \ + "5MHz", \ + "10MHz", \ + "19440kHz" \ +} /** @@ -3824,6 +3990,229 @@ enum /** @} group_gpio */ +/** + * @defgroup group_evt_log Event logging support + * + * @note This is only available if GPS_HAS_EVT_LOG is set in RECEIVER_INFO::features. + * + * @{ */ + +/** @brief Number of event log entries that can be stored and yet have been saved */ +typedef struct +{ + uint32_t used; /**< current number of saved log entries */ + uint32_t max; /**< max number of log entries which can be saved */ +} MBG_NUM_EVT_LOG_ENTRIES; + +#define _mbg_swab_mbg_num_evt_log_entries( _p ) \ +{ \ + _mbg_swab32( &(_p)->used ); \ + _mbg_swab32( &(_p)->max ); \ +} + + +typedef uint16_t MBG_EVT_CODE; +#define _mbg_swab_evt_code( _p ) _mbg_swab16( _p ); + +typedef uint16_t MBG_EVT_INFO; +#define _mbg_swab_evt_info( _p ) _mbg_swab16( _p ); + +/** @brief An event log entry */ + typedef struct + { + uint32_t time; /**< like time_t, seconds since 1970 */ + MBG_EVT_CODE code; /**< event ID or'ed with severity level */ + MBG_EVT_INFO info; /**< optional event info, depending on event ID */ + } MBG_EVT_LOG_ENTRY; + +#define _mbg_swab_mbg_evt_log_entry( _p ) \ +{ \ + _mbg_swab32( &(_p)->time ); \ + _mbg_swab_evt_code( &(_p)->code ); \ + _mbg_swab_evt_info( &(_p)->info ); \ +} + + +// MBG_EVT_LOG_ENTRY::code is a combination of some bits used for the ID, +// plus some bits used for the severity/level. The sum of bits must not +// exceed (8 * sizeof MBG_EVT_LOG_ENTRY::code): + +#define MBG_EVT_ID_BITS 13 +#define MBG_EVT_LVL_BITS 3 + +#define MBG_EVT_ID_MASK ( ( 1UL << MBG_EVT_ID_BITS ) - 1 ) +#define MBG_EVT_LVL_MASK ( ( 1UL << MBG_EVT_LVL_BITS ) - 1 ) + + +// Combine an ID and Level to a code which can be stored +// in the code field: +#define _mbg_mk_evt_code( _id, _lvl ) \ + ( (MBG_EVT_CODE) ( (MBG_EVT_CODE)(_id) | ( (MBG_EVT_CODE)(_lvl) << MBG_EVT_ID_BITS ) ) ) + +// Extract the event ID from the code field: +#define _mbg_get_evt_id( _code ) \ + ( (_code) & MBG_EVT_ID_MASK ) + +// Extract the severity level from the code field: +#define _mbg_get_evt_lvl( _code ) \ + ( ( (_code) >> MBG_EVT_ID_BITS ) & MBG_EVT_LVL_MASK ) + + +/** @brief Enumeration of event IDs */ +enum +{ + MBG_EVT_ID_NONE, /**< no event (empty entry) */ + MBG_EVT_ID_POW_UP_RES, /**< power up reset */ + MBG_EVT_ID_WDOG_RES, /**< watchdog reset */ + MBG_EVT_ID_COLD_BOOT, /**< entering cold boot mode */ + MBG_EVT_ID_WARM_BOOT, /**< entering warm boot mode */ + MBG_EVT_ID_NORMAL_OP, /**< entering normal operation */ + MBG_EVT_ID_ANT_DISCONN, /**< antenna disconnect detected */ + MBG_EVT_ID_ANT_SHORT, /**< antenna short circuit detected */ + MBG_EVT_ID_ANT_OK, /**< antenna OK after failure */ + MBG_EVT_ID_LOW_SATS, /**< no satellites can be received though antenna not failing */ + N_MBG_EVT_ID +}; + + +#define ENG_EVT_ID_NAME_NONE "No event" +#define ENG_EVT_ID_NAME_POW_UP_RES "Power Up Reset" +#define ENG_EVT_ID_NAME_WDOG_RES "Watchdog Reset" +#define ENG_EVT_ID_NAME_COLD_BOOT "Cold Boot" +#define ENG_EVT_ID_NAME_WARM_BOOT "Warm Boot" +#define ENG_EVT_ID_NAME_NORMAL_OP "Normal Operation" +#define ENG_EVT_ID_NAME_ANT_DISCONN "Antenna Disconn." +#define ENG_EVT_ID_NAME_ANT_SHORT "Ant. Short-Circ." +#define ENG_EVT_ID_NAME_ANT_OK "Antenna OK" +#define ENG_EVT_ID_NAME_LOW_SATS "Few Sats Only" + + +#define MBG_EVT_ID_NAMES_ENG \ +{ \ + ENG_EVT_ID_NAME_NONE, \ + ENG_EVT_ID_NAME_POW_UP_RES, \ + ENG_EVT_ID_NAME_WDOG_RES, \ + ENG_EVT_ID_NAME_COLD_BOOT, \ + ENG_EVT_ID_NAME_WARM_BOOT, \ + ENG_EVT_ID_NAME_NORMAL_OP, \ + ENG_EVT_ID_NAME_ANT_DISCONN, \ + ENG_EVT_ID_NAME_ANT_SHORT, \ + ENG_EVT_ID_NAME_ANT_OK, \ + ENG_EVT_ID_NAME_LOW_SATS \ +} + + + +/** @brief Enumeration of event severity levels */ +enum +{ + MBG_EVT_LVL_NONE, + MBG_EVT_LVL_DEBUG, + MBG_EVT_LVL_INFO, + MBG_EVT_LVL_WARN, + MBG_EVT_LVL_ERR, + MBG_EVT_LVL_CRIT, + N_MBG_EVT_LVL +}; + + +#define ENG_EVT_LVL_NAME_NONE "None" +#define ENG_EVT_LVL_NAME_DEBUG "Debug" +#define ENG_EVT_LVL_NAME_INFO "Info" +#define ENG_EVT_LVL_NAME_WARN "Warn" +#define ENG_EVT_LVL_NAME_ERR "Err" +#define ENG_EVT_LVL_NAME_CRIT "Crit." + + +#define MBG_EVT_LVL_NAMES_ENG \ +{ \ + ENG_EVT_LVL_NAME_NONE, \ + ENG_EVT_LVL_NAME_DEBUG, \ + ENG_EVT_LVL_NAME_INFO, \ + ENG_EVT_LVL_NAME_WARN, \ + ENG_EVT_LVL_NAME_ERR, \ + ENG_EVT_LVL_NAME_CRIT \ +} + + +/** @brief Predefined event codes with associated severity levels */ + +#define MBG_EVT_NONE _mbg_mk_evt_code( MBG_EVT_ID_NONE, MBG_EVT_LVL_NONE ) +#define MBG_EVT_POW_UP_RES _mbg_mk_evt_code( MBG_EVT_ID_POW_UP_RES, MBG_EVT_LVL_WARN ) +#define MBG_EVT_WDOG_RES _mbg_mk_evt_code( MBG_EVT_ID_WDOG_RES, MBG_EVT_LVL_CRIT ) +#define MBG_EVT_COLD_BOOT _mbg_mk_evt_code( MBG_EVT_ID_COLD_BOOT, MBG_EVT_LVL_ERR ) +#define MBG_EVT_WARM_BOOT _mbg_mk_evt_code( MBG_EVT_ID_WARM_BOOT, MBG_EVT_LVL_ERR ) +#define MBG_EVT_NORMAL_OP _mbg_mk_evt_code( MBG_EVT_ID_NORMAL_OP, MBG_EVT_LVL_INFO ) +#define MBG_EVT_ANT_DISCONN _mbg_mk_evt_code( MBG_EVT_ID_ANT_DISCONN, MBG_EVT_LVL_CRIT ) +#define MBG_EVT_ANT_SHORT _mbg_mk_evt_code( MBG_EVT_ID_ANT_SHORT, MBG_EVT_LVL_CRIT ) +#define MBG_EVT_ANT_OK _mbg_mk_evt_code( MBG_EVT_ID_ANT_OK, MBG_EVT_LVL_INFO ) +#define MBG_EVT_LOW_SATS _mbg_mk_evt_code( MBG_EVT_ID_LOW_SATS, MBG_EVT_LVL_WARN ) + + +/** @} group_evt_log */ + + +/** + * @defgroup group_generic_io Generic I/O support. + * + * The definitions below are used with the GENERIC_IO API. + * + * This API is <b>NOT</b> supported by all devices, it depends on + * the type of the device, and the firmware version. The macro + * _pcps_has_generic_io() or the corresponding function + * mbg_dev_has_generic_io() should be used by applications to + * check whether a particular bus-level device supports this. + * @{ */ + + +typedef uint16_t GEN_IO_INFO_TYPE; + +#define _mbg_swab_gen_io_info_type( _p ) \ + _mbg_swab16( _p ) + + + +/** + * @brief The data structure used with the PCPS_GEN_IO_GET_INFO command + * + * type specifier in order to query from a device which of the other + * specified types is supported, and how many data sets are being + * used by the device. The GEN_IO_INFO_TYPE must be passed to the + * call which returns a GEN_IO_INFO structure filled by the device. + */ +typedef struct +{ + GEN_IO_INFO_TYPE type; // a PCPS_GEN_IO_GET_INFO type from the enum above + uint16_t num; // supported number of data sets of the specified type + +} GEN_IO_INFO; + +#define _mbg_swab_gen_io_info( _p ) \ +{ \ + _mbg_swab_gen_io_info_type( &(_p)->type ); \ + _mbg_swab16( &(_p)->num ); \ +} + + + +/** + * @brief Data types used with GEN_IO_INFO::type + * + * The first type specifier, PCPS_GEN_IO_GET_INFO, can + * be used to find out which of the other data types are + * supported, and how many data sets of the specified type + * are supported by a device. + */ +enum +{ + PCPS_GEN_IO_GET_INFO, /**< GEN_IO_INFO (read only) */ + PCPS_GEN_IO_CAL_REC_IRIG_RX_COMP, /**< CAL_REC_IRIG_RX_COMP (read/write) */ + N_PCPS_GEN_IO_TYPE /**< number of known types */ +}; + +/** @} group_generic_io */ + + /*------------------------------------------------------------------------*/ /* diff --git a/mbglib/common/macioctl.h b/mbglib/common/macioctl.h index 994f7ff..40b89ac 100755 --- a/mbglib/common/macioctl.h +++ b/mbglib/common/macioctl.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: macioctl.h 1.33.1.28 2011/10/05 09:00:14 martin TEST $ + * $Id: macioctl.h 1.33.1.31 2011/11/25 15:03:17 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,12 @@ * * ----------------------------------------------------------------------- * $Log: macioctl.h $ + * Revision 1.33.1.31 2011/11/25 15:03:17 martin + * Support on-board event logs. + * Revision 1.33.1.30 2011/11/24 08:24:54 martin + * Revision 1.33.1.29 2011/11/23 16:49:06 martin + * Fixed a bug in IOCTL_PCPS_GENERIC_IO handler. + * Support debug status. * Revision 1.33.1.28 2011/10/05 09:00:14 martin * Made inline functions static. * Revision 1.33.1.27 2011/09/21 16:01:54 martin @@ -628,6 +634,9 @@ typedef union MBG_TIME_INFO_TSTAMP mbg_time_info_tstamp; CORR_INFO corr_info; TR_DISTANCE tr_distance; + MBG_DEBUG_STATUS debug_status; + MBG_NUM_EVT_LOG_ENTRIES num_evt_log_entries; + MBG_EVT_LOG_ENTRY evt_log_entry; PCPS_MAPPED_MEM mapped_mem; @@ -1077,6 +1086,30 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, break; + case IOCTL_GET_DEBUG_STATUS: + _io_read_var_chk( pddev, PCPS_GET_DEBUG_STATUS, debug_status, + pout, _pcps_ddev_has_debug_status( pddev ) ); + break; + + + case IOCTL_GET_NUM_EVT_LOG_ENTRIES: + _io_read_var_chk( pddev, PCPS_NUM_EVT_LOG_ENTRIES, num_evt_log_entries, + pout, _pcps_ddev_has_evt_log( pddev ) ); + break; + + + case IOCTL_GET_FIRST_EVT_LOG_ENTRY: + _io_read_var_chk( pddev, PCPS_FIRST_EVT_LOG_ENTRY, evt_log_entry, + pout, _pcps_ddev_has_evt_log( pddev ) ); + break; + + + case IOCTL_GET_NEXT_EVT_LOG_ENTRY: + _io_read_var_chk( pddev, PCPS_NEXT_EVT_LOG_ENTRY, evt_log_entry, + pout, _pcps_ddev_has_evt_log( pddev ) ); + break; + + // Commands returning device capabilities and features case IOCTL_DEV_IS_GPS: @@ -1284,6 +1317,16 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, break; + case IOCTL_DEV_HAS_DEBUG_STATUS: + _report_cond( _pcps_ddev_has_debug_status( pddev ), pout ); + break; + + + case IOCTL_DEV_HAS_EVT_LOG: + _report_cond( _pcps_ddev_has_evt_log( pddev ), pout ); + break; + + // The next codes are somewhat special since they change something // on the board but do not affect basic operation @@ -1300,6 +1343,11 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, break; + case IOCTL_CLR_EVT_LOG: + _io_write_cmd_chk( pddev, PCPS_CLR_EVT_LOG, _pcps_ddev_has_evt_log( pddev ) ); + break; + + // Status information which may not be available for everybody case IOCTL_GET_GPS_POS: @@ -1703,7 +1751,7 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, goto err_no_mem; } - _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz ); + _frc_iob_from_pin( p_buff_in, iob.req.in_p, iob.req.in_sz ); _pcps_sem_inc_safe( pddev ); rc = pcps_write( pddev, (uint8_t) iob.req.info, p_buff_in, @@ -1808,7 +1856,7 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, goto err_no_mem; } - _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz ); + _frc_iob_from_pin( p_buff_in, iob.req.in_p, iob.req.in_sz ); _pcps_sem_inc_safe( pddev ); rc = pcps_write_gps( pddev, (uint8_t) iob.req.info, p_buff_in, @@ -1862,7 +1910,7 @@ int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code, goto err_no_mem; } - _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz ); + _frc_iob_from_pin( p_buff_in, iob.req.in_p, iob.req.in_sz ); } else { diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h index f5ede60..fa4d71f 100755 --- a/mbglib/common/mbg_tgt.h +++ b/mbglib/common/mbg_tgt.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_tgt.h 1.24 2011/08/23 10:21:23 martin TEST $ + * $Id: mbg_tgt.h 1.24 2011/08/23 10:21:23 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * diff --git a/mbglib/common/mbgddmsg.h b/mbglib/common/mbgddmsg.h index d1aa8ae..7540a57 100755 --- a/mbglib/common/mbgddmsg.h +++ b/mbglib/common/mbgddmsg.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgddmsg.h 1.9 2011/01/26 18:13:49 martin REL_M $ + * $Id: mbgddmsg.h 1.9.1.2 2011/11/01 09:08:48 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,9 @@ * * ----------------------------------------------------------------------- * $Log: mbgddmsg.h $ + * Revision 1.9.1.2 2011/11/01 09:08:48 martin + * Revision 1.9.1.1 2011/03/29 13:55:19 martin + * Also enable debug msgs if MBG_DEBUG is defined. * Revision 1.9 2011/01/26 18:13:49 martin * Support for *BSD. * Revision 1.8 2009/04/22 09:54:55 martin @@ -38,7 +41,7 @@ #include <mbg_tgt.h> -#if defined( DEBUG ) || ( defined( DBG ) && DBG ) +#if defined( DEBUG ) || ( defined( DBG ) && DBG ) || defined( MBG_DEBUG ) enum { @@ -52,7 +55,6 @@ enum N_MBG_DBG_LVL }; -extern int debug; #define _chk_lvl( _lvl ) ( (_lvl) < debug ) diff --git a/mbglib/common/mbgdevio.c b/mbglib/common/mbgdevio.c index fa5b6b2..53a6ca3 100755 --- a/mbglib/common/mbgdevio.c +++ b/mbglib/common/mbgdevio.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgdevio.c 1.35.1.26 2011/09/26 13:58:54 martin TEST $ + * $Id: mbgdevio.c 1.35.1.29 2011/11/25 15:03:19 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,13 @@ * * ----------------------------------------------------------------------- * $Log: mbgdevio.c $ + * Revision 1.35.1.29 2011/11/25 15:03:19 martin + * Support on-board event logs. + * Revision 1.35.1.28 2011/11/23 18:18:50 martin + * Fixed build under DOS. + * Revision 1.35.1.27 2011/11/23 16:41:14Z martin + * New functions mbg_dev_has_debug_status() and + * mbg_get_debug_status(). * Revision 1.35.1.26 2011/09/26 13:58:54 martin * Added a workaround to make mbgmon (BC) build under Windows. * In mbg_get_serial_settings() return an error if the number of provided @@ -1534,7 +1541,7 @@ _MBG_API_ATTR int _MBG_API mbg_generic_io( MBG_DEV_HANDLE dh, int type, _mbgdevio_chk_cond( _pcps_ddev_has_generic_io( dh ) ); #endif - // No type information available, so endianess must be + // No type information available, so endianess must be // converted by the caller, if required. rc = _mbgdevio_gen_io( dh, type, in_p, in_sz, out_p, out_sz ); return _mbgdevio_ret_val; @@ -5328,7 +5335,208 @@ _MBG_API_ATTR int _MBG_API mbg_set_tr_distance( MBG_DEV_HANDLE dh, const TR_DIST /*HDR*/ /** - Read the CPU affinity of a process, i.e. on which of the available + Check if a specific device provides a debug status word to be read. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to an int which is set 0 or != 0 unless the call fails. + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_get_debug_status() +*/ +_MBG_API_ATTR int _MBG_API mbg_dev_has_debug_status( MBG_DEV_HANDLE dh, int *p ) +{ + _mbgdevio_query_cond( dh, _pcps_ddev_has_debug_status, IOCTL_DEV_HAS_DEBUG_STATUS, p ); + +} // mbg_dev_has_debug_status + + + +/*HDR*/ +/** + Read a debug status word from a card. This is mainly supported + by IRIG timecode receiver cards, and the status word is intended + to provide more detailed information why a card might not synchronize + to the incoming timecode signal. + + The macro _pcps_has_debug_status() or the API call mbg_dev_has_debug_status() + check whether this call is supported by a specific card. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_DEBUG_STATUS variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_debug_status() + */ +_MBG_API_ATTR int _MBG_API mbg_get_debug_status( MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p ) +{ + _mbgdevio_vars(); + _mbgdevio_read_var_chk( dh, PCPS_GET_DEBUG_STATUS, + IOCTL_GET_DEBUG_STATUS, p, + _pcps_ddev_has_debug_status( dh ) ); + _mbg_swab_debug_status( p ); + return _mbgdevio_ret_val; + +} // mbg_get_debug_status + + + +/*HDR*/ +/** + Check if a specific device provides an on-board event log. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to an int which is set 0 or != 0 unless the call fails. + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() +*/ +_MBG_API_ATTR int _MBG_API mbg_dev_has_evt_log( MBG_DEV_HANDLE dh, int *p ) +{ + _mbgdevio_query_cond( dh, _pcps_ddev_has_evt_log, IOCTL_DEV_HAS_EVT_LOG, p ); + +} // mbg_dev_has_evt_log + + + +/*HDR*/ +/** + Clear the card's on-board event log. + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + @param dh Valid handle to a Meinberg device + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() + */ +_MBG_API_ATTR int _MBG_API mbg_clr_evt_log( MBG_DEV_HANDLE dh ) +{ + _mbgdevio_vars(); + _mbgdevio_write_cmd_chk( dh, PCPS_CLR_EVT_LOG, IOCTL_CLR_EVT_LOG, + _pcps_ddev_has_evt_log( dh ) ); + return _mbgdevio_ret_val; + +} // mbg_clr_evt_log + + + +/*HDR*/ +/** + Read max number of num event log entries which can + be saved on the board, and how many entries actually + have been saved. + _pcps_has_evt_log() checks whether supported. + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_NUM_EVT_LOG_ENTRIES variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() + */ +_MBG_API_ATTR int _MBG_API mbg_get_num_evt_log_entries( MBG_DEV_HANDLE dh, MBG_NUM_EVT_LOG_ENTRIES *p ) +{ + _mbgdevio_vars(); + _mbgdevio_read_var_chk( dh, PCPS_NUM_EVT_LOG_ENTRIES, + IOCTL_GET_NUM_EVT_LOG_ENTRIES, p, + _pcps_ddev_has_evt_log( dh ) ); + _mbg_swab_mbg_num_evt_log_entries( p ); + return _mbgdevio_ret_val; + +} // mbg_get_num_evt_log_entries + + + +/*HDR*/ +/** + Read the first (oldest) event log entry from a device. + + @note Subsequent reads should be made using mbg_get_next_evt_log_entry(). + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + If no (more) event log entry is available on the device then + the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_next_evt_log_entry() + */ +_MBG_API_ATTR int _MBG_API mbg_get_first_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) +{ + _mbgdevio_vars(); + _mbgdevio_read_var_chk( dh, PCPS_FIRST_EVT_LOG_ENTRY, + IOCTL_GET_FIRST_EVT_LOG_ENTRY, p, + _pcps_ddev_has_evt_log( dh ) ); + _mbg_swab_mbg_evt_log_entry( p ); + return _mbgdevio_ret_val; + +} // mbg_get_first_evt_log_entry + + + +/*HDR*/ +/** + Read the next event log entry from a device. + + @note The first read should be made using mbg_get_first_evt_log_entry() + to set the on-board read index to the oldest entry. + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + If no (more) event log entry is available on the device then + the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + */ +_MBG_API_ATTR int _MBG_API mbg_get_next_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) +{ + _mbgdevio_vars(); + _mbgdevio_read_var_chk( dh, PCPS_NEXT_EVT_LOG_ENTRY, + IOCTL_GET_NEXT_EVT_LOG_ENTRY, p, + _pcps_ddev_has_evt_log( dh ) ); + _mbg_swab_mbg_evt_log_entry( p ); + return _mbgdevio_ret_val; + +} // mbg_get_next_evt_log_entry + + + +/*HDR*/ +/** + Read the CPU affinity of a process, i.e. on which of the available CPUs the process can be executed. @param pid The process ID. diff --git a/mbglib/common/mbgdevio.h b/mbglib/common/mbgdevio.h index e192114..4a6aadb 100755 --- a/mbglib/common/mbgdevio.h +++ b/mbglib/common/mbgdevio.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgdevio.h 1.39.1.21 2011/09/26 14:03:21 martin TEST $ + * $Id: mbgdevio.h 1.39.1.25 2011/11/25 15:03:22 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,24 @@ * * ----------------------------------------------------------------------- * $Log: mbgdevio.h $ + * Revision 1.39.1.25 2011/11/25 15:03:22 martin + * Support on-board event logs. + * Revision 1.39.1.24 2011/11/23 16:42:03 martin + * Updated function prototypes. + * Added some comments. + * Revision 1.39.1.23.1.4 2011/11/23 16:37:24 martin + * Removed tmp. debug code. + * Revision 1.39.1.23.1.3 2011/11/23 16:32:53 martin + * Modified tmp. debug code. + * Revision 1.39.1.23.1.2 2011/11/22 15:13:14 martin + * Updated function prototypes. + * Revision 1.39.1.23.1.1 2011/11/21 14:16:33 martin + * Tmp. debug generic I/O. + * Revision 1.39.1.23 2011/11/16 10:09:28 martin + * Fixed a bug which caused a crash when generic I/O calls + * were used under Windows. + * Revision 1.39.1.22 2011/10/21 14:08:28Z martin + * Changes for QNX. * Revision 1.39.1.21 2011/09/26 14:03:21 martin * Workaround to make mbgmon (BC) build under Windows. * See diff for details. @@ -260,6 +278,14 @@ #define MBG_USE_KERNEL_DRIVER 1 +#elif defined( MBG_TGT_QNX_NTO ) + + #include <sys/types.h> + #include <sys/stat.h> + #include <fcntl.h> + + #include <pcpsdrvr.h> + #elif defined( MBG_TGT_DOS ) #if !defined( MBG_USE_DOS_TSR ) @@ -2958,7 +2984,136 @@ extern "C" { _MBG_API_ATTR int _MBG_API mbg_set_tr_distance( MBG_DEV_HANDLE dh, const TR_DISTANCE *p ) ; /** - Read the CPU affinity of a process, i.e. on which of the available + Check if a specific device provides a debug status word to be read. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to an int which is set 0 or != 0 unless the call fails. + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_get_debug_status() +*/ + _MBG_API_ATTR int _MBG_API mbg_dev_has_debug_status( MBG_DEV_HANDLE dh, int *p ) ; + + /** + Read a debug status word from a card. This is mainly supported + by IRIG timecode receiver cards, and the status word is intended + to provide more detailed information why a card might not synchronize + to the incoming timecode signal. + + The macro _pcps_has_debug_status() or the API call mbg_dev_has_debug_status() + check whether this call is supported by a specific card. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_DEBUG_STATUS variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_debug_status() + */ + _MBG_API_ATTR int _MBG_API mbg_get_debug_status( MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p ) ; + + /** + Check if a specific device provides an on-board event log. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to an int which is set 0 or != 0 unless the call fails. + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() +*/ + _MBG_API_ATTR int _MBG_API mbg_dev_has_evt_log( MBG_DEV_HANDLE dh, int *p ) ; + + /** + Clear the card's on-board event log. + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + @param dh Valid handle to a Meinberg device + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() + */ + _MBG_API_ATTR int _MBG_API mbg_clr_evt_log( MBG_DEV_HANDLE dh ) ; + + /** + Read max number of num event log entries which can + be saved on the board, and how many entries actually + have been saved. + _pcps_has_evt_log() checks whether supported. + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_NUM_EVT_LOG_ENTRIES variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_first_evt_log_entry() + @see mbg_get_next_evt_log_entry() + */ + _MBG_API_ATTR int _MBG_API mbg_get_num_evt_log_entries( MBG_DEV_HANDLE dh, MBG_NUM_EVT_LOG_ENTRIES *p ) ; + + /** + Read the first (oldest) event log entry from a device. + + @note Subsequent reads should be made using mbg_get_next_evt_log_entry(). + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + If no (more) event log entry is available on the device then + the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_next_evt_log_entry() + */ + _MBG_API_ATTR int _MBG_API mbg_get_first_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) ; + + /** + Read the next event log entry from a device. + + @note The first read should be made using mbg_get_first_evt_log_entry() + to set the on-board read index to the oldest entry. + + The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log() + check whether this call is supported by a specific device. + + If no (more) event log entry is available on the device then + the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE. + + @param dh Valid handle to a Meinberg device + @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up + + @return ::MBG_SUCCESS or error code returned by device I/O control function. + + @see mbg_dev_has_evt_log() + @see mbg_clr_evt_log() + @see mbg_get_num_evt_log_entries() + @see mbg_get_first_evt_log_entry() + */ + _MBG_API_ATTR int _MBG_API mbg_get_next_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) ; + + /** + Read the CPU affinity of a process, i.e. on which of the available CPUs the process can be executed. @param pid The process ID. @@ -3244,6 +3399,22 @@ MBGDEVIO_RET_VAL do_mbg_ioctl( MBG_DEV_HANDLE dh, int ioctl_code, #if defined( _MBGIOCTL_H ) // using IOCTL to access device driver +/** + @brief Send a generic IOCTL command to the driver. + + @param dh Valid handle to a Meinberg device + @param info Additional information for the kernel driver depending on + the IOCTL code, i.e. the low level function to be called: <br> + one of the PCPS_... commands with IOCTL_PCPS_GENERIC_{READ|WRITE}<br> + one of the PC_GPS_... commands with IOCTL_PCPS_GENERIC_{READ|WRITE}_GPS<br> + one of the PCPS_GEN_IO_... enumeration codes with IOCTL_PCPS_GENERIC_IO + @param ioctl One of the IOCTL_GENERIC_... codes telling the kernel driver + which low level function to use, e.g. normal read or write, + large (GPS) data read or write, or generic I/O. + @param *p Pointer to an int which is set 0 or != 0 unless the call fails. + + @return ::MBG_SUCCESS or error code returned by device I/O control function. +*/ static __mbg_inline int mbgdevio_do_gen_io( MBG_DEV_HANDLE dh, int info, unsigned int ioctl_code, const void *in_p, int in_sz, @@ -3251,12 +3422,14 @@ MBGDEVIO_RET_VAL do_mbg_ioctl( MBG_DEV_HANDLE dh, int ioctl_code, { _mbgdevio_vars(); - #if _MBG_SUPP_VAR_ACC_SIZE - info; // avoid "unused" warning - - rc = do_mbg_ioctl( dh, ioctl_code, in_p, in_sz, out_p, out_sz ); //##++++ in_p / out_p vs. _do_mbg_ioctl() + // Generic IOCTL calls always need to pass some info beside + // the I/O buffers down to the driver, which usually is + // the command code for the device. + // Thus we must always use one of the control structures + // IOCTL_GENERIC_REQ or IOCTL_GENERIC_BUFFER, whichever + // is appropriate for the target OS. - #elif USE_IOCTL_GENERIC_REQ + #if USE_IOCTL_GENERIC_REQ IOCTL_GENERIC_REQ req = { 0 }; diff --git a/mbglib/common/mbggeo.h b/mbglib/common/mbggeo.h index 9ffaebe..415064a 100755 --- a/mbglib/common/mbggeo.h +++ b/mbglib/common/mbggeo.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbggeo.h 1.11 2011/06/22 10:18:10 martin TEST $ + * $Id: mbggeo.h 1.11 2011/06/22 10:18:10 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * diff --git a/mbglib/common/mbgioctl.h b/mbglib/common/mbgioctl.h index 566c846..75afd00 100755 --- a/mbglib/common/mbgioctl.h +++ b/mbglib/common/mbgioctl.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgioctl.h 1.24.1.10 2011/07/20 15:49:00 martin TEST $ + * $Id: mbgioctl.h 1.24.1.12 2011/11/25 15:03:23 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,10 @@ * * ----------------------------------------------------------------------- * $Log: mbgioctl.h $ + * Revision 1.24.1.12 2011/11/25 15:03:23 martin + * Support on-board event logs. + * Revision 1.24.1.11 2011/11/22 15:47:27 martin + * Support debug status. * Revision 1.24.1.10 2011/07/20 15:49:00 martin * Conditionally use older IOCTL request buffer structures. * Revision 1.24.1.9 2011/07/19 12:31:59 martin @@ -480,6 +484,16 @@ typedef struct #define IOCTL_GET_TR_DISTANCE _MBG_IOR( IOTYPE, 0x8C, TR_DISTANCE ) #define IOCTL_SET_TR_DISTANCE _MBG_IOW( IOTYPE, 0x8D, TR_DISTANCE ) +#define IOCTL_DEV_HAS_DEBUG_STATUS _MBG_IOR( IOTYPE, 0x8E, int ) +#define IOCTL_GET_DEBUG_STATUS _MBG_IOR( IOTYPE, 0x8F, MBG_DEBUG_STATUS ) + +#define IOCTL_DEV_HAS_EVT_LOG _MBG_IOR( IOTYPE, 0x90, int ) +#define IOCTL_CLR_EVT_LOG _MBG_IO( IOTYPE, 0x91 ) +#define IOCTL_GET_NUM_EVT_LOG_ENTRIES _MBG_IOR( IOTYPE, 0x92, MBG_NUM_EVT_LOG_ENTRIES ) +#define IOCTL_GET_FIRST_EVT_LOG_ENTRY _MBG_IOR( IOTYPE, 0x93, MBG_EVT_LOG_ENTRY ) +#define IOCTL_GET_NEXT_EVT_LOG_ENTRY _MBG_IOR( IOTYPE, 0x94, MBG_EVT_LOG_ENTRY ) + + // The codes below are subject to changes without notice. They may be supported // by some kernel drivers, but usage is restricted to Meinberg software development. // Unrestricted usage may cause system malfunction !! @@ -632,6 +646,14 @@ typedef struct { IOCTL_GET_CORR_INFO, "IOCTL_GET_CORR_INFO" }, \ { IOCTL_GET_TR_DISTANCE, "IOCTL_GET_TR_DISTANCE" }, \ { IOCTL_SET_TR_DISTANCE, "IOCTL_SET_TR_DISTANCE" }, \ + { IOCTL_DEV_HAS_DEBUG_STATUS, "IOCTL_DEV_HAS_DEBUG_STATUS" }, \ + { IOCTL_GET_DEBUG_STATUS, "IOCTL_GET_DEBUG_STATUS" }, \ + { IOCTL_DEV_HAS_EVT_LOG, "IOCTL_DEV_HAS_EVT_LOG" }, \ + { IOCTL_CLR_EVT_LOG, "IOCTL_CLR_EVT_LOG" }, \ + { IOCTL_GET_NUM_EVT_LOG_ENTRIES, "IOCTL_GET_NUM_EVT_LOG_ENTRIES" }, \ + { IOCTL_GET_FIRST_EVT_LOG_ENTRY, "IOCTL_GET_FIRST_EVT_LOG_ENTRY" }, \ + { IOCTL_GET_NEXT_EVT_LOG_ENTRY, "IOCTL_GET_NEXT_EVT_LOG_ENTRY" }, \ + \ { IOCTL_MBG_DBG_GET_PORT_ADDR, "IOCTL_MBG_DBG_GET_PORT_ADDR" }, \ { IOCTL_MBG_DBG_SET_PORT_ADDR, "IOCTL_MBG_DBG_SET_PORT_ADDR" }, \ { IOCTL_MBG_DBG_SET_BIT, "IOCTL_MBG_DBG_SET_BIT" }, \ @@ -736,6 +758,10 @@ int ioctl_get_required_privilege( ulong ioctl_code ) case IOCTL_GET_IP4_STATE: case IOCTL_GET_PTP_STATE: case IOCTL_GET_CORR_INFO: + case IOCTL_GET_DEBUG_STATUS: + case IOCTL_GET_NUM_EVT_LOG_ENTRIES: + case IOCTL_GET_FIRST_EVT_LOG_ENTRY: + case IOCTL_GET_NEXT_EVT_LOG_ENTRY: return MBG_REQ_PRIVL_NONE; // Commands returning device capabilities and features: @@ -780,12 +806,15 @@ int ioctl_get_required_privilege( ulong ioctl_code ) case IOCTL_DEV_HAS_PZF: case IOCTL_DEV_HAS_CORR_INFO: case IOCTL_DEV_HAS_TR_DISTANCE: + case IOCTL_DEV_HAS_DEBUG_STATUS: + case IOCTL_DEV_HAS_EVT_LOG: return MBG_REQ_PRIVL_NONE; // The next codes are somewhat special since they change something // on the board but do not affect basic operation: case IOCTL_PCPS_CLR_UCAP_BUFF: case IOCTL_SET_PCPS_EVENT_TIME: // supported by some customized firmware only + case IOCTL_CLR_EVT_LOG: return MBG_REQ_PRIVL_NONE; // Status information which may not be available for everybody: diff --git a/mbglib/common/mbgmutex.h b/mbglib/common/mbgmutex.h index 67b048a..d64f74f 100755 --- a/mbglib/common/mbgmutex.h +++ b/mbglib/common/mbgmutex.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgmutex.h 1.1.1.6 2011/05/31 14:19:55 martin TEST $ + * $Id: mbgmutex.h 1.1.1.7 2011/10/21 14:08:30 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgmutex.h $ + * Revision 1.1.1.7 2011/10/21 14:08:30 martin + * Changes for QNX. * Revision 1.1.1.6 2011/05/31 14:19:55 martin * Revision 1.1.1.5 2011/05/16 17:39:41 martin * Don't define macros for semaphore destroy functions @@ -185,7 +187,7 @@ // For critical sections use defaults specified below - #elif defined( MBG_TGT_DOS ) + #elif defined( MBG_TGT_DOS ) || defined( MBG_TGT_QNX ) typedef int MBG_MUTEX; // just a dummy declaration diff --git a/mbglib/common/mbgtime.h b/mbglib/common/mbgtime.h index d1ae02b..5ee780c 100755 --- a/mbglib/common/mbgtime.h +++ b/mbglib/common/mbgtime.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgtime.h 1.17.1.6 2011/05/06 09:03:12 martin TEST $ + * $Id: mbgtime.h 1.17.1.7 2011/10/21 14:07:52 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgtime.h $ + * Revision 1.17.1.7 2011/10/21 14:07:52 martin + * Changes for QNX. * Revision 1.17.1.6 2011/05/06 09:03:12 martin * Fix for DOS. * Revision 1.17.1.5 2011/05/06 08:07:58Z daniel @@ -67,7 +69,8 @@ #if _IS_MBG_FIRMWARE \ || defined( MBG_TGT_WIN32 ) \ - || defined( MBG_TGT_DOS ) + || defined( MBG_TGT_DOS ) \ + || defined( MBG_TGT_QNX_NTO ) #include <time.h> #endif diff --git a/mbglib/common/mbgutil.c b/mbglib/common/mbgutil.c index 8ae735d..3342939 100755 --- a/mbglib/common/mbgutil.c +++ b/mbglib/common/mbgutil.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgutil.c 1.5.2.2 2011/09/21 16:01:18 martin TEST $ + * $Id: mbgutil.c 1.5.2.3 2011/11/28 14:24:44 daniel TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,9 @@ * * ----------------------------------------------------------------------- * $Log: mbgutil.c $ - * Revision 1.5.2.2 2011/09/21 16:01:18 martin + * Revision 1.5.2.3 2011/11/28 14:24:44 daniel + * Fixed firmware and asic version string + * Revision 1.5.2.2 2011/09/21 16:01:18Z martin * Revision 1.5.2.1 2010/07/15 13:06:59 martin * Revision 1.5 2009/03/19 09:09:55Z daniel * Fixed ambiguous syntax in mbg_str_dev_name(). @@ -583,11 +585,11 @@ _MBG_API_ATTR int _MBG_API mbg_str_dev_name( char *s, int max_len, const char *s n = mbg_snprintf( s, max_len, "%s, S/N %s", model_code, sernum ); if ( fw_rev_num > 0 ) - n += mbg_snprintf( &s[n], max_len," (FW v%X.%02X", fw_rev_num>>8, fw_rev_num & 0x00FF ); + n += mbg_snprintf( &s[n], max_len," (FW v%d.%02d", fw_rev_num>>8, fw_rev_num & 0x00FF ); if ( asic_version_num > 0 ) { - mbg_snprintf( &s[n], max_len," / ASIC v%X.%02X)", _convert_asic_version_number( asic_version_num ) >> 8, + mbg_snprintf( &s[n], max_len," / ASIC v%d.%02d)", _convert_asic_version_number( asic_version_num ) >> 8, ( _convert_asic_version_number( asic_version_num ) ) & 0xFF ); } else diff --git a/mbglib/common/parmgps.h b/mbglib/common/parmgps.h index 46d28fc..0b5dbf8 100755 --- a/mbglib/common/parmgps.h +++ b/mbglib/common/parmgps.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: parmgps.h 1.7 2011/02/16 10:12:13 martin TEST $ + * $Id: parmgps.h 1.7 2011/02/16 10:12:13 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * diff --git a/mbglib/common/pcpsdefs.h b/mbglib/common/pcpsdefs.h index 094ff03..46af1db 100755 --- a/mbglib/common/pcpsdefs.h +++ b/mbglib/common/pcpsdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: pcpsdefs.h 1.46.1.13 2011/10/05 15:10:31 martin TEST $ + * $Id: pcpsdefs.h 1.48 2011/11/25 15:02:28 martin TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,40 +10,20 @@ * * ----------------------------------------------------------------------- * $Log: pcpsdefs.h $ - * Revision 1.46.1.13 2011/10/05 15:10:31 martin - * Added string initializers for PZF correlation state. - * Revision 1.46.1.12 2011/08/05 11:03:21 martin - * Fixed typos. - * Revision 1.46.1.11 2011/07/18 10:19:28 martin - * Added an initializer for a table of GPS command code/names. - * Revision 1.46.1.10 2011/07/06 11:21:38 martin - * Added commands to read CORR_INFO, and read/write TR_DISTANCE. - * Added swab macros for CORR_INFO and TR_DISTANCE. - * Modified some comments. - * Revision 1.46.1.9 2011/07/05 08:27:00 martin - * Comments only. - * Revision 1.46.1.8 2011/07/04 15:27:52 martin + * Revision 1.48 2011/11/25 15:02:28 martin + * Support on-board event logs. + * Revision 1.47 2011/11/25 10:22:44 martin + * Modified handling of pragma pack(). * Made command group codes obsolete. They are still supported * when building firmware, though. - * Revision 1.46.1.7 2011/07/04 14:53:46 martin - * Added definitions MBG_PCPS_FMT_STATUS and PCPS_SYNC_PZF. - * Modified some comments. - * Revision 1.46.1.6 2011/06/29 14:08:28 martin - * Updated some comments. - * Revision 1.46.1.5 2011/06/29 09:10:25 martin - * Renamed PZF600PEX to PZF180PEX. - * Revision 1.46.1.4 2011/06/21 13:45:14 martin - * Support PZF600PEX. - * Renamed *_GPIO_CFG_INFO to *_GPIO_CFG_LIMITS - * to follow common naming conventions. * Support PTP unicast configuration. - * Modified handling of pragma pack(). - * Revision 1.46.1.3 2011/04/18 13:29:39 martin - * Doxygen changes. - * Revision 1.46.1.2 2011/04/07 15:56:25 martin * Support GPIO configuration. - * Revision 1.46.1.1 2011/02/15 10:55:28 daniel - * New command PC_GPS_PTP_UNICAST_CFG + * Support PZF180PEX. + * Added commands to read CORR_INFO, read/write TR_DISTANCE, + * PCPS_SYNC_PZF status, and associated structures. + * Added an initializer for a table of GPS command code/names. + * Added definitions MBG_PCPS_FMT_STATUS. + * Updated some comments. * Revision 1.46 2011/01/13 11:44:29Z martin * Moved status port register definitions here. * Revision 1.45 2010/09/06 07:36:24 martin @@ -619,14 +599,28 @@ typedef uint8_t PCPS_STATUS_PORT; /**< see @ref group_status_port "Bitmask" */ for PZF receivers. _pcps_has_tr_distance() checks whether supported. + - #PCPS_CLR_EVT_LOG<br> + Clear on-board event log. + _pcps_has_evt_log() checks whether supported. + + - #PCPS_NUM_EVT_LOG_ENTRIES<br> + Read max number of num event log entries which can + be saved on the board, and how many entries actually + have been saved. + _pcps_has_evt_log() checks whether supported. + + - #PCPS_FIRST_EVT_LOG_ENTRY<br> + - #PCPS_NEXT_EVT_LOG_ENTRY<br> + Read first (oldest) or next event log entry. + _pcps_has_evt_log() checks whether supported. + - #PCPS_FORCE_RESET<br> Resets the microprocessor on the device. This is for special test scenarios only and should not be used by standard applications since this may lock up the PC. - The command codes listed above are defined below. The commands are - grouped for bytes having the same high nibble: + The command codes listed above are defined below. @{ */ @@ -786,29 +780,29 @@ typedef struct /* The associated structure SYNTH is defined in gpsdefs.h. */ -#define PCPS_GIVE_FW_ID_1 0x40 -#define PCPS_GIVE_FW_ID_2 0x41 -#define PCPS_GIVE_SERNUM 0x42 -#define PCPS_GENERIC_IO 0x43 -#define PCPS_GET_SYNTH_STATE 0x44 -#define PCPS_GET_IRIG_CTRL_BITS 0x45 -#define PCPS_GET_RAW_IRIG_DATA 0x46 +#define PCPS_GIVE_FW_ID_1 0x40 +#define PCPS_GIVE_FW_ID_2 0x41 +#define PCPS_GIVE_SERNUM 0x42 +#define PCPS_GENERIC_IO 0x43 +#define PCPS_GET_SYNTH_STATE 0x44 +#define PCPS_GET_IRIG_CTRL_BITS 0x45 +#define PCPS_GET_RAW_IRIG_DATA 0x46 -#define PCPS_GET_STATUS_PORT 0x4B -#define PCPS_GET_DEBUG_STATUS 0x4C +#define PCPS_GET_STATUS_PORT 0x4B +#define PCPS_GET_DEBUG_STATUS 0x4C // expects sizeof( MBG_DEBUG_STATUS ) chars // Command codes 0x4D, 0x4E, and 0x4F are reserved. -#define PCPS_READ_GPS_DATA 0x50 -#define PCPS_WRITE_GPS_DATA 0x51 +#define PCPS_READ_GPS_DATA 0x50 +#define PCPS_WRITE_GPS_DATA 0x51 -#define PCPS_CLR_UCAP_BUFF 0x60 -#define PCPS_GIVE_UCAP_ENTRIES 0x61 -#define PCPS_GIVE_UCAP_EVENT 0x62 +#define PCPS_CLR_UCAP_BUFF 0x60 +#define PCPS_GIVE_UCAP_ENTRIES 0x61 +#define PCPS_GIVE_UCAP_EVENT 0x62 typedef struct { @@ -824,16 +818,21 @@ typedef struct -#define PCPS_GET_CORR_INFO 0x63 // read CORR_INFO structure, only if _pcps_has_pzf() -#define PCPS_GET_TR_DISTANCE 0x64 // read TR_DISTANCE, only if _pcps_has_tr_distance() -#define PCPS_SET_TR_DISTANCE 0x65 // write TR_DISTANCE, only if _pcps_has_tr_distance() +#define PCPS_GET_CORR_INFO 0x63 // read CORR_INFO structure, only if _pcps_has_pzf() +#define PCPS_GET_TR_DISTANCE 0x64 // read TR_DISTANCE, only if _pcps_has_tr_distance() +#define PCPS_SET_TR_DISTANCE 0x65 // write TR_DISTANCE, only if _pcps_has_tr_distance() + +#define PCPS_CLR_EVT_LOG 0x66 // clear on-board event log, only if _pcps_has_evt_log() +#define PCPS_NUM_EVT_LOG_ENTRIES 0x67 // read num event log entries, only if _pcps_has_evt_log() +#define PCPS_FIRST_EVT_LOG_ENTRY 0x68 // read first (oldest) event log entry, only if _pcps_has_evt_log() +#define PCPS_NEXT_EVT_LOG_ENTRY 0x69 // read next event log entry, only if _pcps_has_evt_log() /** special -- use with care ! */ -#define PCPS_FORCE_RESET 0x80 +#define PCPS_FORCE_RESET 0x80 // Command codes 0xF0 through 0xFF are reserved. @@ -1234,12 +1233,12 @@ enum #define PZF_CORR_STATE_NAME_RAW_ENG "Searching" -#define PZF_CORR_STATE_NAME_CHECK_ENG "Checking" -#define PZF_CORR_STATE_NAME_FINE_ENG "Synchronized" +#define PZF_CORR_STATE_NAME_CHECK_ENG "Correlating" +#define PZF_CORR_STATE_NAME_FINE_ENG "Locked" #define PZF_CORR_STATE_NAME_RAW_GER "suchen" -#define PZF_CORR_STATE_NAME_CHECK_GER "eingerastet" -#define PZF_CORR_STATE_NAME_FINE_GER "synchron" +#define PZF_CORR_STATE_NAME_CHECK_GER "korrelieren" +#define PZF_CORR_STATE_NAME_FINE_GER "eingerastet" #define PZF_CORR_STATE_NAMES_ENG \ @@ -1263,8 +1262,8 @@ enum This enumeration defines the various types of data that can be read from or written to Meinberg bus level devices which support this. - Access should be done using the functions ::pcps_read_gps_data() - and ::pcps_write_gps_data() since the size of some of the structures + Access should be done using the functions pcps_read_gps_data() + and pcps_write_gps_data() since the size of some of the structures exceeds the size of the device's I/O buffer and must therefore be accessed in several blocks. diff --git a/mbglib/common/pcpsdev.h b/mbglib/common/pcpsdev.h index 63c5ce7..41d9dc8 100755 --- a/mbglib/common/pcpsdev.h +++ b/mbglib/common/pcpsdev.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: pcpsdev.h 1.49.1.57 2011/09/21 16:03:04 martin TEST $ + * $Id: pcpsdev.h 1.49.1.68 2011/11/28 10:04:39 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -17,6 +17,23 @@ * * ----------------------------------------------------------------------- * $Log: pcpsdev.h $ + * Revision 1.49.1.68 2011/11/28 10:04:39 martin + * PZF180PEX doesn't support TIME_SCALE by default. + * Revision 1.49.1.67 2011/11/25 15:03:23 martin + * Support on-board event logs. + * Revision 1.49.1.66 2011/11/24 14:01:45 martin + * Added kernel uptime/sleep for NetBSD. + * Revision 1.49.1.65 2011/11/24 08:54:53 martin + * Moved macro _must_do_fw_workaround_20ms() here. + * Revision 1.49.1.64 2011/11/22 16:27:25 martin + * New macro _pcps_has_debug_status(). + * Revision 1.49.1.63 2011/11/01 12:20:00 martin + * Revision 1.49.1.62 2011/11/01 12:14:33 martin + * Revision 1.49.1.61 2011/11/01 09:13:05 martin + * Revision 1.49.1.60 2011/10/31 08:55:05 martin + * Revision 1.49.1.59 2011/10/28 13:51:15 martin + * Added some macros to test if specific stat_info stuff is supported. + * Revision 1.49.1.58 2011/10/21 14:07:27 martin * Revision 1.49.1.57 2011/09/21 16:03:04 martin * Moved some definitions useful for configuration tools to new file cfg_hlp.h. * Revision 1.49.1.56 2011/09/20 08:31:22 martin @@ -323,16 +340,28 @@ #if defined( MBG_TGT_KERNEL ) #include <sys/sysproto.h> #include <sys/pcpu.h> + #include <sys/param.h> + #include <sys/systm.h> + #include <sys/proc.h> #else + #include <unistd.h> #include <sys/time.h> #endif #elif defined( MBG_TGT_NETBSD ) - #if !defined( MBG_TGT_KERNEL ) + #if defined( MBG_TGT_KERNEL ) + #include <sys/param.h> // mstohz + #include <sys/kernel.h> // hz + #else + #include <unistd.h> #include <sys/time.h> #endif +#elif defined( MBG_TGT_QNX_NTO ) + + #include <unistd.h> + #elif defined( MBG_TGT_DOS ) #include <dos.h> // for delay() @@ -611,9 +640,25 @@ void mbg_get_sys_uptime( MBG_SYS_UPTIME *p ) #if defined( MBG_TGT_KERNEL ) { struct timespec ts; + #if 0 //##+++++++ + { + struct bintime bt; + + binuptime( &bt ); + #if defined( DEBUG ) + printf( "binuptime: %lli.%09lli\n", + (long long) bt.sec, + (long long) bt.frac ); + #endif + } + #endif - getnanouptime( &ts ); - + nanouptime( &ts ); + #if defined( DEBUG ) + printf( "nanouptime: %lli.%09lli\n", + (long long) ts.tv_sec, + (long long) ts.tv_nsec ); + #endif *p = ts.tv_sec; } #elif defined( MBG_TGT_FREEBSD ) @@ -677,7 +722,34 @@ void mbg_sleep_sec( long sec ) #elif defined( MBG_TGT_BSD ) - //##+++++++++++++++++++ needs to be defined + #if defined( MBG_TGT_KERNEL ) + #if defined( MBG_TGT_FREEBSD ) + struct timeval tv = { 0 }; + int ticks; + tv.tv_sec = sec; + ticks = tvtohz( &tv ); + #if defined( DEBUG ) + printf( "pause: %lli.%06lli (%i ticks)\n", + (long long) tv.tv_sec, + (long long) tv.tv_usec, + ticks ); + #endif + pause( "pause", ticks ); + #elif defined( MBG_TGT_NETBSD ) + int timeo = mstohz( sec * 1000 ); + #if defined( DEBUG ) + printf( "kpause: %i s (%i ticks)\n", sec, timeo ); + #endif + kpause( "pause", 1, timeo, NULL ); + #endif + #else + sleep( sec ); + #endif + + #elif defined( MBG_TGT_QNX_NTO ) + + // Actually only tested under Neutrino. + sleep( sec ); #elif defined( MBG_TGT_DOS ) @@ -925,6 +997,7 @@ enum PCPS_BIT_HAS_FAST_HR_TSTAMP, PCPS_BIT_HAS_RAW_IRIG_DATA, PCPS_BIT_HAS_PZF, // can also demodulate DCF77 PZF + PCPS_BIT_HAS_EVT_LOG, N_PCPS_FEATURE // must not exceed 32 !! }; @@ -958,6 +1031,7 @@ enum #define PCPS_HAS_FAST_HR_TSTAMP ( 1UL << PCPS_BIT_HAS_FAST_HR_TSTAMP ) #define PCPS_HAS_RAW_IRIG_DATA ( 1UL << PCPS_BIT_HAS_RAW_IRIG_DATA ) #define PCPS_HAS_PZF ( 1UL << PCPS_BIT_HAS_PZF ) +#define PCPS_HAS_EVT_LOG ( 1UL << PCPS_BIT_HAS_EVT_LOG ) @@ -990,7 +1064,8 @@ enum "PCPS_HAS_IRIG_TIME", \ "PCPS_HAS_FAST_HR_TSTAMP", \ "PCPS_HAS_RAW_IRIG_DATA", \ - "PCPS_HAS_PZF" \ + "PCPS_HAS_PZF", \ + "PCPS_HAS_EVT_LOG" \ } /** @} */ @@ -1125,7 +1200,6 @@ enum | PCPS_HAS_UCAP \ | PCPS_HAS_GPS_DATA_16 \ | PCPS_HAS_GENERIC_IO \ - | PCPS_HAS_TIME_SCALE \ | PCPS_HAS_UTC_PARM \ | PCPS_HAS_PZF ) @@ -1416,6 +1490,17 @@ typedef struct #define _pcps_has_tr_distance( _d ) _pcps_has_pzf( _d ) +#define _pcps_has_evt_log( _d ) _pcps_has_feature( (_d), PCPS_HAS_EVT_LOG ) + +#define _pcps_has_debug_status( _d ) _pcps_is_irig_rx( _d ) + +#define _pcps_has_stat_info( _d ) ( _pcps_is_gps( _d ) || _pcps_has_pzf( _d ) ) + +#define _pcps_has_stat_info_mode( _d ) _pcps_is_gps( _d ) + +#define _pcps_has_stat_info_svs( _d ) _pcps_is_gps( _d ) + + // There are some versions of IRIG receiver cards which ignore the TFOM code // of an incoming IRIG signal even if an IRIG code has been configured which @@ -1450,6 +1535,22 @@ typedef struct +// There are some versions of GPS PCI firmware which may occasionally return +// a HR time stamp which is wrong by 20 milliseconds, if the HR time is read +// right after some GPS data. As a workaround for that bug an application +// must wait at least 1.5 ms and then just read the PCPS_TIME structure +// in order to re-initialize the software interface state. +// This has been fixed in more recent versions of the affected firmware, +// but this macro can be used to let an application determine whether it +// must account for this bug with a given card and firmware version. +#define _must_do_fw_workaround_20ms( _d ) \ +( \ + ( _pcps_type_num( _d ) == PCPS_TYPE_GPS168PCI && _pcps_fw_rev_num( _d ) < 0x0102 ) || \ + ( _pcps_type_num( _d ) == PCPS_TYPE_GPS167PCI && _pcps_fw_rev_num( _d ) < 0x0420 ) \ +) + + + /** The structure is used to return info on the device driver.*/ diff --git a/mbglib/common/pcpsdrvr.c b/mbglib/common/pcpsdrvr.c index ff71feb..a67084d 100755 --- a/mbglib/common/pcpsdrvr.c +++ b/mbglib/common/pcpsdrvr.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: pcpsdrvr.c 1.46.2.53 2011/10/06 13:35:06 martin TEST $ + * $Id: pcpsdrvr.c 1.46.2.59 2011/11/25 15:13:01 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -63,6 +63,15 @@ * * ----------------------------------------------------------------------- * $Log: pcpsdrvr.c $ + * Revision 1.46.2.59 2011/11/25 15:13:01 martin + * Support on-board event log. + * Revision 1.46.2.58 2011/11/23 17:47:33 martin + * Conditional code to test MM I/O for new PCI cards. + * Added debug messages for generic I/O. + * Revision 1.46.2.57 2011/11/18 10:15:33 martin + * Revision 1.46.2.56 2011/11/02 14:09:48 martin + * Revision 1.46.2.55 2011/11/01 09:10:59Z martin + * Revision 1.46.2.54 2011/10/21 14:07:28 martin * Revision 1.46.2.53 2011/10/06 13:35:06 martin * Revision 1.46.2.52 2011/10/06 13:29:13 martin * Temp. don't delay for PTP270PEX under FreeBSD. @@ -422,6 +431,9 @@ #define DEBUG_SERNUM ( defined( DEBUG ) && ( DEBUG >= DEBUG_LVL_SERNUM ) ) #endif +#define _PCPS_USE_MM_IO ( 0 && MBG_TGT_SUPP_MEM_ACC && !MBG_USE_MM_IO_FOR_PCI ) + + extern const char pcps_driver_name[]; @@ -502,8 +514,23 @@ extern const char pcps_driver_name[]; #endif +#if defined( MBG_TGT_DOS ) || \ + defined( MBG_TGT_QNX ) + #define CHECK_UPTIME 0 +#elif defined( MBG_TGT_FREEBSD ) + // Under FreeBSD (at least 8.2) the kernel calls to read uptime always + // return 1 when this driver is loaded automatically, so the system + // locks up if we wait util uptime has reached a certain value. + #define CHECK_UPTIME 0 +#else + #define CHECK_UPTIME 1 +#endif + + + + -#if !defined( MBG_TGT_FREEBSD ) +#if CHECK_UPTIME static /*HDR*/ long mbg_delta_sys_time_ms( const MBG_SYS_TIME *t2, const MBG_SYS_TIME *t1 ) @@ -553,57 +580,62 @@ void report_uptime( const MBG_SYS_UPTIME *p_uptime ) static /*HDR*/ void check_uptime( void ) { - #if !defined( MBG_TGT_DOS ) - MBG_SYS_TIME t1; - MBG_SYS_TIME t2; - MBG_SYS_UPTIME uptime; - int delayed = 0; + MBG_SYS_TIME t1; + MBG_SYS_TIME t2; + MBG_SYS_UPTIME uptime; + int delayed = 0; + int i = 0; - mbg_get_sys_time( &t1 ); + mbg_get_sys_time( &t1 ); - for (;;) - { - mbg_get_sys_uptime( &uptime ); + for (;;) + { + mbg_get_sys_uptime( &uptime ); - #if !defined( DEBUG ) - if ( !delayed ) - #endif - report_uptime( &uptime ); + #if !defined( DEBUG ) + if ( !delayed ) + #endif + report_uptime( &uptime ); - if ( uptime == 0 ) - break; // assume uptime not supported + if ( uptime == 0 ) + break; // assume uptime not supported - if ( uptime >= MAX_BOOT_TIME_PTP270PEX ) - break; + if ( uptime >= MAX_BOOT_TIME_PTP270PEX ) + break; + + mbg_sleep_sec( 1 ); + delayed = 1; - mbg_sleep_sec( 1 ); + if ( ++i >= MAX_BOOT_TIME_PTP270PEX ) + { delayed = 1; + break; } + } - if ( delayed ) - { - long dt; + if ( delayed ) + { + long dt; - mbg_get_sys_time( &t2 ); + mbg_get_sys_time( &t2 ); - dt = mbg_delta_sys_time_ms( &t2, &t1 ); + dt = mbg_delta_sys_time_ms( &t2, &t1 ); - #if defined( MBG_TGT_LINUX ) - printk( KERN_INFO "PTP270PEX startup delay: %li.%03li s\n", - dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 ); - #elif defined( MBG_TGT_BSD ) - printf( "PTP270PEX startup delay: %li.%03li s\n", - dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 ); - #elif defined( MBG_TGT_WIN32 ) - { - WCHAR wcs_msg[128]; - swprintf( wcs_msg, L"PTP270PEX startup delay: %li.%03li s", + #if defined( MBG_TGT_LINUX ) + printk( KERN_INFO "PTP270PEX startup delay: %li.%03li s\n", + dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 ); + #elif defined( MBG_TGT_BSD ) + printf( "PTP270PEX startup delay: %li.%03li s\n", + dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 ); + #elif defined( MBG_TGT_WIN32 ) + { + WCHAR wcs_msg[128]; + swprintf( wcs_msg, L"PTP270PEX startup delay: %li.%03li s", dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 ); - _evt_msg( GlbDriverObject, wcs_msg ); - } - #endif + _evt_msg( GlbDriverObject, wcs_msg ); } - #endif + #endif + } } // check_uptime @@ -638,6 +670,15 @@ int pcps_check_pex_irq_unsafe( PCPS_DDEV *pddev, uint16_t req_fw_ver, #if MBG_TGT_SUPP_MEM_ACC static __mbg_inline /*HDR*/ +int has_mapped_sys_virtual_address( PCPS_DDEV *pddev ) +{ + return pddev->mm_addr != NULL; + +} // has_mapped_sys_virtual_address + + + +static __mbg_inline /*HDR*/ int map_sys_virtual_address( PCPS_DDEV *pddev ) { pddev->mm_tstamp_addr = NULL; // unless configured below @@ -689,7 +730,8 @@ int map_sys_virtual_address( PCPS_DDEV *pddev ) static __mbg_inline /*HDR*/ void unmap_sys_virtual_address( PCPS_DDEV *pddev ) { - if ( pddev->mm_addr ) + + if ( has_mapped_sys_virtual_address( pddev ) ) { #if defined ( MBG_TGT_WIN32 ) MmUnmapIoSpace( pddev->mm_addr, sizeof( *pddev->mm_addr ) ); @@ -709,6 +751,32 @@ void unmap_sys_virtual_address( PCPS_DDEV *pddev ) +#if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + +#if 0 //##++++ +static inline +long _cyc_to_us( long long cyc ) +{ + cyc *= 1000; + do_div( cyc, cpu_khz ); + + return (long) cyc; +} +#endif + +static inline +long _cyc_to_ns( long long cyc ) +{ + cyc *= 1000000; + do_div( cyc, cpu_khz ); + + return (long) cyc; +} + +#endif + + + #if defined( __GNUC__ ) // Avoid "no previous prototype" with some gcc versions. __mbg_inline @@ -718,7 +786,32 @@ int pcps_wait_busy( PCPS_DDEV *pddev ) __attribute__((always_inline)); __mbg_inline /*HDR*/ int pcps_wait_busy( PCPS_DDEV *pddev ) { +#if _PCPS_USE_MM_IO + +#if 0 +#define _pcps_ddev_read_status_port( _d ) \ + ( _pcps_ddev_is_pci_mbgpex( _d ) ? \ + ( (_d)->mm_addr->mbgpex.asic.status_port ) : \ + _mbg_inp8( (_d), 0, (_d)->status_port ) ) +#elif 0 + uint32_t st = _pcps_ddev_is_pci_mbgpex( pddev ) ? + pddev->mm_addr->mbgpex.asic.status_port : + _pcps_ddev_read_status_port( pddev ); + + if ( st & PCPS_ST_BUSY ) +#else + uint32_t st; + if ( _pcps_ddev_is_pci_mbgpex( pddev ) ) + st = pddev->mm_addr->mbgpex.asic.status_port.ul; + else + st = _pcps_ddev_read_status_port( pddev ); + + if ( st & PCPS_ST_BUSY ) +#endif + +#else if ( _pcps_ddev_status_busy( pddev ) ) +#endif { #if defined( MBG_TGT_BSD ) struct timeval tv_start; @@ -1065,7 +1158,125 @@ short pcps_read_asic( PCPS_DDEV *pddev, uint8_t cmd, } // pcps_read_asic -#endif /* _PCPS_USE_PCI */ + + +#if _PCPS_USE_MM_IO + +// The function below must be used to access a clock with +// PCI bus and Meinberg PCI interface ASIC. + +static /*HDR*/ /* type: PCPS_READ_FNC */ +short pcps_read_asic_mm( PCPS_DDEV *pddev, uint8_t cmd, + void FAR *buffer, uint16_t count ) +{ + short ret_val = MBG_SUCCESS; + uint8_t FAR *p = (uint8_t FAR *) buffer; + volatile uint32_t *p_data_reg; + PCI_ASIC_REG ar; + int i; + int dt_quot; + int dt_rem; + _pcps_irq_flags + #if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + MBG_PC_CYCLES t_after_cmd = 0; + MBG_PC_CYCLES t_after_busy = 0; + MBG_PC_CYCLES t_done = 0; + volatile uint32_t *p_cmd_reg; + #endif + + + #if DEBUG_IO + _mbgddmsg_3( MBG_DBG_INIT_DEV, "pcps_read_asic_mm: cmd: 0x%02X (0x%08X), cnt: %u", + cmd, _cpu_to_mbg32( cmd ), count ); + #endif + + _pcps_disb_local_irq_save(); + + // write the command byte + #if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + p_cmd_reg = &pddev->mm_addr->mbgpex.asic.pci_data.ul; + mbg_get_pc_cycles( &pddev->acc_cycles ); + *p_cmd_reg = cmd; + #else + mbg_get_pc_cycles( &pddev->acc_cycles ); + pddev->mm_addr->mbgpex.asic.pci_data.ul = cmd; + #endif + + #if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + mbg_get_pc_cycles( &t_after_cmd ); + #endif + + _pcps_local_irq_restore(); + + p_data_reg = &pddev->mm_addr->mbgpex.asic.addon_data.ul[0]; + dt_quot = count / 4; + dt_rem = count % 4; + + // wait until BUSY flag goes low or timeout + if ( pcps_wait_busy( pddev ) < 0 ) + { + ret_val = MBG_ERR_TIMEOUT; + goto done; + } + + + #if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + mbg_get_pc_cycles( &t_after_busy ); + #endif + + // no timeout: read bytes from the board's FIFO + + // first read full 32 bit words + for ( i = 0; i < dt_quot; i++ ) + { + ar.ul = *p_data_reg; + #if DEBUG_IO + _mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_asic_mm: %08X", ar.ul ); + #endif + _mbg_put_unaligned( ar.ul, (uint32_t FAR *) p ); + p += sizeof( ar.ul ); + p_data_reg++; + } + + // then read the remaining bytes, if required + if ( dt_rem ) + { + ar.ul = *p_data_reg; + + for ( i = 0; i < dt_rem; i++ ) + { + #if DEBUG_IO + #endif + + *p++ = ar.b[i]; + } + } + +done: + #if defined( DEBUG ) && defined( MBG_TGT_LINUX ) + { + long read_time; + mbg_get_pc_cycles( &t_done ); + + read_time = _cyc_to_ns( t_done - t_after_busy ); + + printk( KERN_ERR "mm cmd: 0x%02X (%u), write %li ns, busy: %li ns, read: %li/%li ns\n", + cmd, count, + _cyc_to_ns( t_after_cmd - pddev->acc_cycles ), + _cyc_to_ns( t_after_busy - t_after_cmd ), + read_time, + count ? ( read_time / count ) : 0 + ); + } + #endif + + return ret_val; + +} // pcps_read_asic_mm + +#endif // _PCPS_USE_MM_IO + +#endif // _PCPS_USE_PCI @@ -1308,6 +1519,17 @@ short pcps_generic_io( PCPS_DDEV *pddev, uint8_t type, int8_t data_read[PCPS_FIFO_SIZE]; uint8_t bytes_to_read; + #if DEBUG_IO + #if defined( MBG_TGT_DOS ) + #define FP_FMT "%Fp" + #else + #define FP_FMT "%p" + #endif + _mbgddmsg_5( MBG_DBG_DETAIL, "pcps_generic_io: type 0x%02X, in_buff: " FP_FMT + " (%u), out_buf " FP_FMT " (%u)", + type, in_buff, in_cnt, out_buff, out_cnt ); + #endif + // Write the command and read one byte which will contain // the number of data bytes that must follow. rc = _pcps_read_var( pddev, PCPS_GENERIC_IO, tmp_byte ); @@ -1321,6 +1543,11 @@ short pcps_generic_io( PCPS_DDEV *pddev, uint8_t type, return MBG_ERR_NBYTES; + #if DEBUG_IO + _mbgddmsg_3( MBG_DBG_DETAIL, "pcps_generic_io: going to write type 0x%02X, in_sz %u, out_sz %u", + type, in_cnt, out_cnt ); + #endif + // Write the 3 bytes which are expected: rc = _pcps_write_byte( pddev, type ); @@ -1345,6 +1572,10 @@ short pcps_generic_io( PCPS_DDEV *pddev, uint8_t type, // Write the input parameters + #if DEBUG_IO + _mbgddmsg_0( MBG_DBG_DETAIL, "pcps_generic_io: going to write input bytes" ); + #endif + p = (const uint8_t FAR *) in_buff; tmp_byte = in_cnt - 1; @@ -2677,14 +2908,18 @@ int pcps_start_device( PCPS_DDEV *pddev, } // switch ( _pcps_ddev_bus_flags( pddev ) ) - - // check if all required resources have been assigned - if ( pddev->rsrc_info.num_rsrc_io < port_ranges_required ) + #if _PCPS_USE_MM_IO + if ( !_pcps_ddev_is_pci_mbgpex( pddev ) ) + #endif { - _mbgddmsg_3( MBG_DBG_INIT_DEV, "PCPS start device %X fails: port ranges (%u) less than required (%u)", - _pcps_ddev_dev_id( pddev ), pddev->rsrc_info.num_rsrc_io, port_ranges_required ); - _pcps_ddev_set_err_flags( pddev, PCPS_EF_IO_INIT ); - goto fail; + // check if all required resources have been assigned + if ( pddev->rsrc_info.num_rsrc_io < port_ranges_required ) + { + _mbgddmsg_3( MBG_DBG_INIT_DEV, "PCPS start device %X fails: port ranges (%u) less than required (%u)", + _pcps_ddev_dev_id( pddev ), pddev->rsrc_info.num_rsrc_io, port_ranges_required ); + _pcps_ddev_set_err_flags( pddev, PCPS_EF_IO_INIT ); + goto fail; + } } if ( _pcps_ddev_is_pci_mbgpex( pddev ) ) @@ -2696,6 +2931,29 @@ int pcps_start_device( PCPS_DDEV *pddev, pddev->irq_ack_port = pddev->irq_enb_disb_port; pddev->irq_ack_mask = PCI_ASIC_PCI_IRQF; + + #if _PCPS_USE_MM_IO + _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: pcps_start_device: interface is MBGPEX", + pcps_driver_name ); + if ( map_sys_virtual_address( pddev ) < 0 ) + goto fail_with_cleanup; + + #if 1 && DEBUG_IO && defined( MBG_TGT_LINUX ) //##+++++++++++++++ + printk( KERN_ERR "io_addr: 0x%llX, cmd: 0x%llX\n", + (unsigned long long) _pcps_ddev_io_base_mapped( pddev, 0 ), + (unsigned long long) _pcps_ddev_io_base_mapped( pddev, 0 ) + offsetof( PCI_ASIC, pci_data ) + ); + + printk( KERN_ERR "mm_addr: %p, cmd: %p, tstamp: %p\n", + pddev->mm_addr, + &pddev->mm_addr->mbgpex.asic.pci_data.ul, + pddev->mm_tstamp_addr + ); + #endif + + pddev->read = pcps_read_asic_mm; + #endif // _PCPS_USE_MM_IO + goto chip_setup_done; } @@ -2851,13 +3109,24 @@ chip_setup_done: #endif } -#if !defined( MBG_TGT_FREEBSD ) // need to check how to delay execution - // Make sure a PTP270PEX card has finished booting. - if ( _pcps_ddev_is_pci( pddev ) && ( _pcps_ddev_dev_id( pddev ) == PCI_DEV_PTP270PEX ) ) - check_uptime(); -#endif - // try to read EPROM ID + #if 0 && DEBUG //##++++++++++++++ + { + MBG_SYS_UPTIME uptime; + mbg_get_sys_uptime( &uptime ); + mbg_sleep_sec( 1 ); + mbg_get_sys_uptime( &uptime ); + } + #endif + + #if CHECK_UPTIME + // Make sure a PTP270PEX card has finished booting. + if ( _pcps_ddev_is_pci( pddev ) && ( _pcps_ddev_dev_id( pddev ) == PCI_DEV_PTP270PEX ) ) + check_uptime(); + #endif + + + // try to read firmware ID rc = pcps_get_fw_id( pddev, pddev->dev.cfg.fw_id ); if ( rc < 0 ) @@ -2932,8 +3201,17 @@ chip_setup_done: // If the device has an ASIC or EPLD read the ASIC version number if ( _pcps_ddev_has_asic_version( pddev ) ) { - pddev->raw_asic_version = _mbg_inp32_to_cpu( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 ) - + offsetof( PCI_ASIC, raw_version ) ); + #if _PCPS_USE_MM_IO + if ( _pcps_ddev_bus_flags( pddev ) == PCPS_BUS_PCI_MBGPEX ) + { + _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: pcps_start_device: MM reading ASIC version", + pcps_driver_name ); + pddev->raw_asic_version = pddev->mm_addr->mbgpex.asic.raw_version; + } + else + #endif // _PCPS_USE_MM_IO + pddev->raw_asic_version = _mbg_inp32_to_cpu( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 ) + + offsetof( PCI_ASIC, raw_version ) ); _mbg_swab_asic_version( &pddev->raw_asic_version ); @@ -3208,6 +3486,7 @@ check: check_ri_feature( pddev, &pddev->ri, GPS_HAS_LAN_IP4, PCPS_HAS_LAN_INTF ); check_ri_feature( pddev, &pddev->ri, GPS_HAS_PTP, PCPS_HAS_PTP ); // check_ri_feature( pddev, &pddev->ri, GPS_HAS_PTP_UNICAST, 0 ); // no equivalent in PCPS_DDEV features + check_ri_feature( pddev, &pddev->ri, GPS_HAS_EVT_LOG, PCPS_HAS_EVT_LOG ); #if !defined( MBG_TGT_OS2 ) && !defined( MBG_TGT_BSD ) // Function strstr may not be supported at kernel level, @@ -3250,10 +3529,10 @@ check: "Warning: ASIC features don't reflect memory mapped time stamp support." ); } - if ( pddev->dev.cfg.features & PCPS_HAS_FAST_HR_TSTAMP ) - if ( map_sys_virtual_address( pddev ) < 0 ) - goto fail_with_cleanup; - + if ( !has_mapped_sys_virtual_address( pddev ) ) + if ( pddev->dev.cfg.features & PCPS_HAS_FAST_HR_TSTAMP ) + if ( map_sys_virtual_address( pddev ) < 0 ) + goto fail_with_cleanup; #endif } @@ -3491,6 +3770,9 @@ void pcps_detect_pci_clocks( PCPS_DDEV_ALLOC_FNC alloc_fnc, void *alloc_arg, break; // go to try next device ID + _mbgddmsg_2( MBG_DBG_INIT_DEV, "Found PCI device %s (0x%04X)", + p->name, p->dev_id ); + // New device found, try to add to list. pddev = alloc_fnc(); diff --git a/mbglib/common/pcpsdrvr.h b/mbglib/common/pcpsdrvr.h index 77ce4b0..744f82e 100755 --- a/mbglib/common/pcpsdrvr.h +++ b/mbglib/common/pcpsdrvr.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: pcpsdrvr.h 1.41.1.35 2011/09/09 12:47:13 martin TEST $ + * $Id: pcpsdrvr.h 1.41.1.39 2011/11/25 15:03:24 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,13 @@ * * ----------------------------------------------------------------------- * $Log: pcpsdrvr.h $ + * Revision 1.41.1.39 2011/11/25 15:03:24 martin + * Support on-board event logs. + * Revision 1.41.1.38 2011/11/22 16:27:47 martin + * New macro _pcps_ddev_has_debug_status(). + * Revision 1.41.1.37 2011/10/28 13:51:15 martin + * Added some macros to test if specific stat_info stuff is supported. + * Revision 1.41.1.36 2011/10/21 14:07:29 martin * Revision 1.41.1.35 2011/09/09 12:47:13 martin * Fixes for DOS. * Revision 1.41.1.34 2011/07/19 12:48:39Z martin @@ -938,6 +945,15 @@ typedef struct PCPS_DDEV_s /* ------ common definitions -------------------------- */ +#if defined( DEBUG ) + _ext int debug + #ifdef _DO_INIT + = DEBUG + #endif + ; +#endif + + _ext PCPS_DEV_TYPE pcps_dev_type[N_PCPS_DEV_TYPE] #ifdef _DO_INIT = { // attention, the name is limited to PCPS_CLOCK_NAME_SZ, including terminating 0 @@ -1199,6 +1215,21 @@ _ext const char *fw_id_ref[] #define _pcps_ddev_has_tr_distance( _p ) \ _pcps_has_tr_distance( &(_p)->dev ) +#define _pcps_ddev_has_evt_log( _p ) \ + _pcps_has_evt_log( &(_p)->dev ) + +#define _pcps_ddev_has_debug_status( _p ) \ + _pcps_has_debug_status( &(_p)->dev ) + +#define _pcps_ddev_has_stat_info( _p ) \ + _pcps_has_stat_info( &(_p)->dev ) + +#define _pcps_ddev_has_stat_info_mode( _p ) \ + _pcps_has_stat_info_mode( &(_p)->dev ) \ + +#define _pcps_ddev_has_stat_info_svs( _p ) \ + _pcps_has_stat_info_svs( &(_p)->dev ) \ + #define _pcps_ddev_incoming_tfom_ignored( _p ) \ _pcps_incoming_tfom_ignored( &(_p)->dev ) diff --git a/mbglib/common/toolutil.c b/mbglib/common/toolutil.c index 535a485..e6e3f75 100755 --- a/mbglib/common/toolutil.c +++ b/mbglib/common/toolutil.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: toolutil.c 1.3.2.10 2011/10/05 15:08:28 martin TEST $ + * $Id: toolutil.c 1.3.2.12 2011/11/03 08:54:08 martin TRASH $ * * Description: * Common functions which can be used with Meinberg command line @@ -9,6 +9,8 @@ * * ----------------------------------------------------------------------- * $Log: toolutil.c $ + * Revision 1.3.2.12 2011/11/03 08:54:08 martin + * Revision 1.3.2.11 2011/10/31 08:48:52 martin * Revision 1.3.2.10 2011/10/05 15:08:28 martin * Added function to show PZF correlation. * Revision 1.3.2.9 2011/09/29 16:31:53 martin @@ -205,7 +207,7 @@ int mbg_get_show_dev_info( MBG_DEV_HANDLE dh, const char *dev_name, PCPS_DEV *p_ { av = _convert_asic_version_number( av ); - printf( ", ASIC %X.%02X", + printf( ", ASIC %u.%02u", _pcps_asic_version_major( av ), _pcps_asic_version_minor( av ) ); @@ -501,8 +503,9 @@ int mbg_show_pzf_corr_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, int show_c printf( "PZF correlation: %u%%, status: %s", ci.val, cp ); if ( show_corr_step ) - printf( " %c", ci.corr_dir ); - + if ( ci.corr_dir != ' ' ) + printf( " Shift: %c", ci.corr_dir ); + return MBG_SUCCESS; } // mbg_show_pzf_corr_info diff --git a/mbglib/common/usbdefs.h b/mbglib/common/usbdefs.h index 32b0dba..e900bbb 100755 --- a/mbglib/common/usbdefs.h +++ b/mbglib/common/usbdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: usbdefs.h 1.13 2011/06/29 14:11:23 martin REL_M $ + * $Id: usbdefs.h 1.15 2011/10/11 06:21:04 andre REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,11 @@ * * ----------------------------------------------------------------------- * $Log: usbdefs.h $ - * Revision 1.13 2011/06/29 14:11:23 martin + * Revision 1.15 2011/10/11 06:21:04 andre + * added class code for GPS180 + * Revision 1.14 2011/10/07 10:13:25Z daniel + * New class code and device id for CPE + * Revision 1.13 2011/06/29 14:11:23Z martin * Added device IDs for TCR600USB, MSF600USB, and WVB600USB. * Revision 1.12 2011/05/11 07:20:37 daniel * New class code and device id for fan control unit @@ -75,6 +79,8 @@ enum MBG_USB_CLASS_SCU, // Meinberg Signal Changeover Unit MBG_USB_CLASS_ESI, // External Synchronization Interface MBG_USB_CLASS_FCU, // Fan Control Unit + MBG_USB_CLASS_CPE, // Configurable Port Expander + MBG_USB_CLASS_GPS, // GPS Receiver N_MBG_USB_CLASS // number of known device class codes }; @@ -108,6 +114,12 @@ enum #define USB_DEV_FCU_01 ( ( MBG_USB_CLASS_FCU << 8 ) | 0x01 ) +#define USB_DEV_CPE_01 ( ( MBG_USB_CLASS_CPE << 8 ) | 0x01 ) + +#define USB_DEV_GPS180 ( ( MBG_USB_CLASS_GPS << 8 ) | 0x01 ) + + + enum { MBGUSB_EP_IDX_HOST_IN, // transfers from device to host diff --git a/mbgstatus/mbgstatus.c b/mbgstatus/mbgstatus.c index a78cdcb..f04a263 100755 --- a/mbgstatus/mbgstatus.c +++ b/mbgstatus/mbgstatus.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgstatus.c 1.13.1.17 2011/10/05 15:10:56 martin TEST $ + * $Id: mbgstatus.c 1.13.1.19 2011/10/28 13:46:14 martin TRASH $ * * Description: * Main file for mbgstatus program which demonstrates how to @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgstatus.c $ + * Revision 1.13.1.19 2011/10/28 13:46:14 martin + * Revision 1.13.1.18 2011/10/28 13:05:03 martin * Revision 1.13.1.17 2011/10/05 15:10:56 martin * Show PZF correlation state. * Revision 1.13.1.16 2011/10/05 13:03:34 martin @@ -380,39 +382,46 @@ void show_ext_stat_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *t int rc = mbg_setup_receiver_info( dh, p_dev, &ri ); - if ( mbg_ioctl_err( rc, "mbg_get_gps_stat_info" ) ) + if ( mbg_ioctl_err( rc, "mbg_setup_receiver_info" ) ) return; - rc = mbg_get_gps_stat_info( dh, &si ); + if ( _pcps_has_stat_info( p_dev ) ) + { + rc = mbg_get_gps_stat_info( dh, &si ); - if ( mbg_ioctl_err( rc, "mbg_get_gps_stat_info" ) ) - return; + if ( mbg_ioctl_err( rc, "mbg_get_gps_stat_info" ) ) + return; - if ( _pcps_is_gps( p_dev ) ) - { - switch ( si.mode ) + if ( _pcps_has_stat_info_mode( p_dev ) ) { - case AUTO_166: mode_name = "Normal Operation"; break; - case WARM_166: mode_name = "Warm Boot"; break; - case COLD_166: mode_name = "Cold Boot"; break; + switch ( si.mode ) + { + case AUTO_166: mode_name = "Normal Operation"; break; + case WARM_166: mode_name = "Warm Boot"; break; + case COLD_166: mode_name = "Cold Boot"; break; - default: // This should never happen! - sprintf( ws, "Unknown mode of operation: %02Xh", si.mode ); - mode_name = ws; + default: // This should never happen! + sprintf( ws, "Unknown mode of operation: %02Xh", si.mode ); + mode_name = ws; - } // switch + } // switch + } - printf( "%s, %i sats in view, %i sats used\n", mode_name, si.svs_in_view, si.good_svs ); + if ( _pcps_has_stat_info_svs( p_dev ) ) + printf( "%s, %i sats in view, %i sats used\n", mode_name, si.svs_in_view, si.good_svs ); } if ( verbose ) { printf( "Osc type: %s", osc_name[( ri.osc_type < N_GPS_OSC ) ? ri.osc_type : GPS_OSC_UNKNOWN] ); - printf( ", DAC cal: %+i, fine: %+i", - (int) ( si.dac_cal - OSC_DAC_BIAS ), - (int) ( si.dac_val - OSC_DAC_BIAS ) ); + if ( _pcps_has_stat_info( p_dev ) ) + { + printf( ", DAC cal: %+i, fine: %+i", + (int) ( si.dac_cal - OSC_DAC_BIAS ), + (int) ( si.dac_val - OSC_DAC_BIAS ) ); + } puts( "" ); } diff --git a/mbgsvcd/Makefile b/mbgsvcd/Makefile index 0da8003..404db32 100755 --- a/mbgsvcd/Makefile +++ b/mbgsvcd/Makefile @@ -1,7 +1,7 @@ ######################################################################### # -# $Id: Makefile 1.1.1.3 2011/09/26 16:07:31 martin TEST martin $ +# $Id: Makefile 1.1.1.3 2011/09/26 16:07:31 martin TEST $ # # Description: # Makefile for mbgsvcd. diff --git a/mbgsvcd/mbgsvcd.c b/mbgsvcd/mbgsvcd.c index d58c95b..5685a29 100755 --- a/mbgsvcd/mbgsvcd.c +++ b/mbgsvcd/mbgsvcd.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgsvcd.c 1.3.1.13 2011/10/06 13:03:46 martin TEST $ + * $Id: mbgsvcd.c 1.3.1.14 2011/11/17 10:07:08 martin TRASH daniel $ * * Description: * Main file for mbgsvcd which compares the system time to a PCI card's @@ -9,6 +9,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgsvcd.c $ + * Revision 1.3.1.14 2011/11/17 10:07:08 martin + * Added leap second support. * Revision 1.3.1.13 2011/10/06 13:03:46 martin * Combined printf() and syslog() to mbg_log(). * Cleanup. @@ -74,9 +76,6 @@ #include <sys/ipc.h> #include <sys/shm.h> -#define NTPD_BASE 0x4e545030 /* "NTP0" */ -#define MAX_SHM_REFCLOCKS 4 - #define RUNNING_DIR "/var/run" #define LOCK_FILE "mbgsvcd.pid" @@ -90,6 +89,51 @@ static int sleep_intv = 1; static int pretend_sync; +/** + * @defgroup group_ntp_defs NTP interface definitions + * + * @Note These definitions have been copied from the NTP source code (http://www.ntp.org) + * + * @{ */ + +/** @brief Structure of NTP's shared memory segment */ +struct shmTime { + int mode; /* 0 - if valid set + * use values, + * clear valid + * 1 - if valid set + * if count before and after read of + * values is equal, + * use values + * clear valid + */ + int count; + time_t clockTimeStampSec; /* external clock */ + int clockTimeStampUSec; /* external clock */ + time_t receiveTimeStampSec; /* internal clock, when external value was received */ + int receiveTimeStampUSec; /* internal clock, when external value was received */ + int leap; + int precision; + int nsamples; + int valid; + int dummy[10]; +}; + +/** @brief codes used with struct shmTime::leap */ +#define LEAP_NOWARNING 0x0 /**< normal, no leap second warning */ +#define LEAP_ADDSECOND 0x1 /**< last minute of day has 61 seconds */ +#define LEAP_DELSECOND 0x2 /**< last minute of day has 59 seconds */ +#define LEAP_NOTINSYNC 0x3 /**< overload, clock is free running */ + +#define NTPD_BASE 0x4e545030 /* "NTP0" */ + +#define MAX_SHM_REFCLOCKS 4 + +/** @} group_ntp_defs */ + +static struct shmTime *shmTime[MAX_SHM_REFCLOCKS]; + + #define MAX_FILTER_ENTRIES 32 @@ -142,31 +186,6 @@ MBG_PC_CYCLES do_filter( FILTER *p, MBG_PC_CYCLES cyc ) -struct shmTime { - int mode; /* 0 - if valid set - * use values, - * clear valid - * 1 - if valid set - * if count before and after read of - * values is equal, - * use values - * clear valid - */ - int count; - time_t clockTimeStampSec; /* external clock */ - int clockTimeStampUSec; /* external clock */ - time_t receiveTimeStampSec; /* internal clock, when external value was received */ - int receiveTimeStampUSec; /* internal clock, when external value was received */ - int leap; - int precision; - int nsamples; - int valid; - int dummy[10]; -}; - -static struct shmTime *shmTime[MAX_SHM_REFCLOCKS]; - - static struct shmTime *getShmTime( int unit ) { @@ -386,6 +405,14 @@ int do_mbgsvctasks( void ) p->precision = -20; } + if ( hrti.ref_hr_time_cycles.t.status & PCPS_LS_ANN_NEG ) + p->leap = LEAP_DELSECOND; + else + if ( hrti.ref_hr_time_cycles.t.status & PCPS_LS_ANN ) + p->leap = LEAP_ADDSECOND; + else + p->leap = LEAP_NOWARNING; + p->count++; p->valid = 1; } |