summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2011-07-15 12:00:00 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2011-07-15 12:00:00 +0200
commit8cbbf5d5604c305f9839ce573c49fbfd33f816ab (patch)
treeab7e629dd971e616bd9b119e3c65307ce647ed88
parent8cfbcc7a4f20fa2d0bb34dabf646586830e0f9cc (diff)
downloadmbgtools-nbsd-8cbbf5d5604c305f9839ce573c49fbfd33f816ab.tar.gz
mbgtools-nbsd-8cbbf5d5604c305f9839ce573c49fbfd33f816ab.zip
Update files from mbgtools-nbsd-dev-2011-07-15.tar.gzmbgtools-nbsd-dev-2011-07-15
Add mbgversion.h. Common Makefile usage.
-rwxr-xr-xsrc/external/bsd/meinberg/Makefile6
-rwxr-xr-xsrc/external/bsd/meinberg/Makefile.inc30
-rwxr-xr-xsrc/external/bsd/meinberg/dist/Makefile4
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgctrl/Makefile9
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgctrl/mbgctrl.c1236
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgfasttstamp/mbgfasttstamp.c30
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbggpscap/mbggpscap.c15
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbghrtime/mbghrtime.c14
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgirigcfg/mbgirigcfg.c307
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/ctry.h14
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/gpsdefs.h1363
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/lan_util.c199
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/lan_util.h139
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/macioctl.h1739
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbg_arch.h14
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbg_tgt.h12
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgdevio.c361
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgdevio.h197
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgerror.h23
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbggeo.h14
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgioctl.h499
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgmutex.h265
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgpccyc.h297
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgtime.h13
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/mbgutil.h15
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pci_asic.h92
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pcpsdefs.h367
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pcpsdev.h511
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c237
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.h162
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/pcpsutil.c6
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/toolutil.c45
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/toolutil.h34
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/usbdefs.h20
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbglib/common/words.h13
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgsetsystime/mbgsetsystime.c15
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgshowsignal/mbgshowsignal.c33
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgstatus/Makefile9
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgstatus/mbgstatus.c59
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgsvcd/Makefile6
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgsvcd/mbgsvcd.c301
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgversion.h33
-rwxr-xr-xsrc/external/bsd/meinberg/dist/mbgxhrtime/mbgxhrtime.c15
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/Makefile1
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/Makefile.kmod19
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/files.mbgclock13
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/mbgclock_main.c689
-rw-r--r--src/sys/dev/pci/files.pci.diff16
-rw-r--r--src/sys/dev/pci/pcidevs.diff47
l---------src/sys/external/bsd/meinberg1
50 files changed, 5809 insertions, 3750 deletions
diff --git a/src/external/bsd/meinberg/Makefile b/src/external/bsd/meinberg/Makefile
deleted file mode 100755
index 346d99a..0000000
--- a/src/external/bsd/meinberg/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# $NetBSD: Makefile,v 1.2 2010/08/28 15:42:46 kardel Exp $
-
-SUBDIR+= mbgclock
-SUBDIR+= dist
-
-.include <bsd.subdir.mk>
diff --git a/src/external/bsd/meinberg/Makefile.inc b/src/external/bsd/meinberg/Makefile.inc
deleted file mode 100755
index f169b5c..0000000
--- a/src/external/bsd/meinberg/Makefile.inc
+++ /dev/null
@@ -1,30 +0,0 @@
-# $NetBSD: Makefile.inc,v 1.5 2010/12/04 23:08:32 christos Exp $
-
-.if !defined(MEINBERG_MAKEFILE_INC)
-MEINBERG_MAKEFILE_INC=yes
-
-USE_FORT?= yes # network client/server
-
-# WARNS?= 5
-
-.include <bsd.own.mk>
-
-IDIST= ${NETBSDSRCDIR}/external/bsd/meinberg/dist
-MBG_LIB_COMMON= ${IDIST}/mbglib/common
-MBG_LIB_BSD= ${IDIST}/mbglib/bsd
-
-CPPFLAGS+=-I${MBG_LIB_COMMON} -I${MBG_LIB_BSD}
-
-.if defined(DEBUG)
-CPPFLAGS+=-DDEBUG=${DEBUG}
-.endif
-
-.if defined(MBG_DEBUG)
-CPPFLAGS+=-DMBG_DEBUG=${MBG_DEBUG}
-.endif
-
-.if exists(${.CURDIR}/../../Makefile.inc)
-.include "${.CURDIR}/../../Makefile.inc"
-.endif
-
-.endif
diff --git a/src/external/bsd/meinberg/dist/Makefile b/src/external/bsd/meinberg/dist/Makefile
index 6d9bb49..de11e0e 100755
--- a/src/external/bsd/meinberg/dist/Makefile
+++ b/src/external/bsd/meinberg/dist/Makefile
@@ -1,13 +1,14 @@
#########################################################################
#
-# $Id: Makefile 1.1.1.1 2011/03/29 13:54:39 martin TRASH $
+# $Id: Makefile 1.1.1.2 2011/07/08 12:10:09 martin TRASH $
#
# Description:
# Makefile for mbgtools which recurses into the subdirectories.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.1.1.2 2011/07/08 12:10:09 martin
# Revision 1.1.1.1 2011/03/29 13:54:39 martin
# Revision 1.1.1.6.1.1 2011/03/28 09:36:56 martin
# Kardel: exclude subdir mbgclock under NetBSD
@@ -229,6 +230,7 @@ CFLAGS += -Wall
.endif
CFLAGS += -I.
+CFLAGS += -I$(BASEDIR)
CFLAGS += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
#########
CFLAGS += -I$(BASEDIR)/mbglib/common
diff --git a/src/external/bsd/meinberg/dist/mbgctrl/Makefile b/src/external/bsd/meinberg/dist/mbgctrl/Makefile
index e485fc0..01e3abf 100755
--- a/src/external/bsd/meinberg/dist/mbgctrl/Makefile
+++ b/src/external/bsd/meinberg/dist/mbgctrl/Makefile
@@ -1,13 +1,17 @@
#########################################################################
#
-# $Id: Makefile 1.7.1.2 2010/08/30 09:05:22 martin TEST $
+# $Id: Makefile 1.7.1.2.1.2 2011/04/20 09:34:06 martin TRASH $
#
# Description:
# Makefile for mbgctrl.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.7.1.2.1.2 2011/04/20 09:34:06 martin
+# Added module lan_util.
+# Revision 1.7.1.2.1.1 2010/09/20 12:06:15 stefan
+# Updated for use with latest base Makefile.
# Revision 1.7.1.2 2010/08/30 09:05:22 martin
# Revision 1.7.1.1 2010/08/30 08:20:54 martin
# Revision 1.7 2009/07/24 10:31:16 martin
@@ -27,7 +31,7 @@
#########################################################################
TARGET = mbgctrl
-INST_DIR = /usr/local/sbin
+INST_TO_SBIN = 1
# By default these tools only need a simple set of mbgdevio API
# functions, but here we use all API calls.
@@ -40,6 +44,7 @@ OBJS += gpsutils.o
OBJS += pcpsutil.o
OBJS += parmgps.o
OBJS += parmpcps.o
+OBJS += lan_util.o
BASEDIR := ..
include $(BASEDIR)/Makefile
diff --git a/src/external/bsd/meinberg/dist/mbgctrl/mbgctrl.c b/src/external/bsd/meinberg/dist/mbgctrl/mbgctrl.c
index d7c6d9f..bfd7093 100755
--- a/src/external/bsd/meinberg/dist/mbgctrl/mbgctrl.c
+++ b/src/external/bsd/meinberg/dist/mbgctrl/mbgctrl.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgctrl.c 1.22.1.5 2011/03/21 08:32:18 martin TRASH $
+ * $Id: mbgctrl.c 1.22.1.7.1.22 2011/07/08 11:20:15 martin TRASH $
*
* Description:
* Main file for mbgctrl program which sends commands and
@@ -9,6 +9,40 @@
*
* -----------------------------------------------------------------------
* $Log: mbgctrl.c $
+ * Revision 1.22.1.7.1.22 2011/07/08 11:20:15 martin
+ * More PTP stuff ...
+ * Revision 1.22.1.7.1.21 2011/07/08 09:04:46 martin
+ * More PTP stuff ...
+ * Revision 1.22.1.7.1.20 2011/07/07 15:08:57 martin
+ * Started simulation of PTP configuration.
+ * Revision 1.22.1.7.1.19 2011/07/06 09:48:01 martin
+ * Revision 1.22.1.7.1.18 2011/07/05 15:35:53 martin
+ * Modified version handling.
+ * Revision 1.22.1.7.1.17 2011/07/05 14:35:17 martin
+ * New way to maintain version information.
+ * Revision 1.22.1.7.1.16 2011/06/27 13:03:19 martin
+ * Use O_RDWR flag when opening a device.
+ * Revision 1.22.1.7.1.15 2011/05/04 14:53:18 martin
+ * Fixed compiler warning.
+ * Revision 1.22.1.7.1.14 2011/05/03 15:43:12 martin
+ * Revision 1.22.1.7.1.13 2011/04/21 11:09:42 martin
+ * Revision 1.22.1.7.1.12 2011/04/21 10:16:03 martin
+ * Revision 1.22.1.7.1.11 2011/04/21 08:49:09 martin
+ * Revision 1.22.1.7.1.10 2011/04/21 08:40:19 martin
+ * Revision 1.22.1.7.1.9 2011/04/21 07:51:05 martin
+ * Revision 1.22.1.7.1.8 2011/04/20 16:07:41 martin
+ * Revision 1.22.1.7.1.7 2011/04/20 14:49:31 martin
+ * Revision 1.22.1.7.1.6 2011/04/20 14:43:00 martin
+ * Revision 1.22.1.7.1.5 2011/04/20 14:13:36 martin
+ * Revision 1.22.1.7.1.4 2011/04/20 13:32:52 martin
+ * Revision 1.22.1.7.1.3 2011/04/20 11:34:28 martin
+ * Revision 1.22.1.7.1.2 2011/04/20 11:32:36 martin
+ * Revision 1.22.1.7.1.1 2011/04/19 15:31:31 martin
+ * Started modifications for PTP unicast master cfg.
+ * Revision 1.22.1.7 2011/04/19 10:02:37 martin
+ * Syntax fix.
+ * Revision 1.22.1.6 2011/04/19 09:57:00 martin
+ * Untabbified and removed trailing spaces.
* Revision 1.22.1.5 2011/03/21 08:32:18 martin
* Fixed compiler warning.
* Revision 1.22.1.4 2011/03/03 10:01:00 daniel
@@ -35,9 +69,9 @@
* Revision 1.17 2009/06/19 12:38:51 martin
* Updated version number to 3.2.0.
* Revision 1.16 2009/06/18 15:14:53 martin
- * Added command TZOFFS which can be used to set TZDL to UTC, and then
- * configure the standard TZDL offset to a dedicated number of seconds, to the
- * output time has a configurable UTC offset against the time derived from the
+ * Added command TZOFFS which can be used to set TZDL to UTC, and then
+ * configure the standard TZDL offset to a dedicated number of seconds, to the
+ * output time has a configurable UTC offset against the time derived from the
* input signal.
* Revision 1.15 2009/03/20 11:53:19 martin
* Updated version number to 3.1.0.
@@ -47,7 +81,7 @@
* Updated description, copyright, revision number and string.
* Use unified functions from toolutil module.
* Accept device name(s) on the command line.
- * Don't use printf() without format, which migth produce warnings
+ * Don't use printf() without format, which migth produce warnings
* with newer gcc versions.
* Revision 1.13 2008/11/07 10:25:49 martin
* Support modification of a card's ENABLE_FLAGS.
@@ -87,7 +121,7 @@
*
**************************************************************************/
-// include Meinberg headers
+// include Meinberg headers
#include <mbgdevio.h>
#include <pcpsmktm.h>
#include <pcpsutil.h>
@@ -97,6 +131,7 @@
#include <gpsutils.h>
#include <cnv_wday.h>
#include <toolutil.h>
+#include <lan_util.h>
// include system headers
#include <stdio.h>
@@ -106,37 +141,183 @@
#include <ctype.h>
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbgctrl";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2001-2009";
+
+#define SIM_PTP_CFG ( 0 && DEBUG ) //##+++
static char *dev_name;
+static int err_unicast_nsupp;
+static const char str_unknown[] = "(unknown)";
+
static TZDL tzdl_utc = DEFAULT_TZDL_UTC;
static TZDL tzdl_cet_cest = DEFAULT_TZDL_CET_CEST_EN;
static TZDL tzdl_eet_eest = DEFAULT_TZDL_EET_EEST_EN;
static long max_tzdl_offs = 0x7FFFFFFFL; // max val for int32_t
-static const char *tz_info_utc = TZ_INFO_UTC;
-static const char *tz_info_cet_cest = TZ_INFO_CET_CEST_EN;
-static const char *tz_info_eet_eest = TZ_INFO_EET_EEST_EN;
+static const char tz_info_utc[] = TZ_INFO_UTC;
+static const char tz_info_cet_cest[] = TZ_INFO_CET_CEST_EN;
+static const char tz_info_eet_eest[] = TZ_INFO_EET_EEST_EN;
static const char *mode_names[N_STR_MODE] = DEFAULT_ENG_MODE_NAMES;
static const char *time_scale_name[N_MBG_TIME_SCALE] = MBG_TIME_SCALE_STRS;
#define _get_time_scale_name( _i ) \
- ( ( (_i) < N_MBG_TIME_SCALE ) ? time_scale_name[_i] : "(unknown)" )
+ ( ( (_i) < N_MBG_TIME_SCALE ) ? time_scale_name[_i] : str_unknown )
+
+
+static const char no_gps_cmd[] = "does not support GPS commands";
+static const char no_tzdl[] = "does not support configurable time zone";
+static const char no_tz[] = "does not support time zones";
+static const char no_event_time[] = "does not support event times";
+static const char no_enable_flags[] = "does not support enable flags";
+static const char no_time_scale[] = "does not support a configurable time scale";
+static const char no_lan_intf[] = "does not provide a LAN interface";
+static const char no_ptp[] = "does not provide PTP";
+static const char no_cab_len[] = "does not support antenna signal delay compensation";
+
+#define N_SUPP_UNICAST_MASTER 1
+
+
+#define DEFAULT_MC_SYNC_INTV_MIN -6 // [log2 s]
+#define DEFAULT_MC_SYNC_INTV_MAX 6 // [log2 s]
+
+#define DEFAULT_MC_ANN_INTV_MIN -6 // [log2 s]
+#define DEFAULT_MC_ANN_INTV_MAX 6 // [log2 s]
+
+#define DEFAULT_MC_DELAY_REQ_INTV_MIN -6 // [log2 s]
+#define DEFAULT_MC_DELAY_REQ_INTV_MAX 6 // [log2 s]
+
+
+#define DEFAULT_UC_SYNC_INTV_MIN -6 // [log2 s]
+#define DEFAULT_UC_SYNC_INTV_MAX 6 // [log2 s]
+
+#define DEFAULT_UC_ANN_INTV_MIN -6 // [log2 s]
+#define DEFAULT_UC_ANN_INTV_MAX 6 // [log2 s]
+
+#define DEFAULT_UC_DELAY_REQ_INTV_MIN -6 // [log2 s]
+#define DEFAULT_UC_DELAY_REQ_INTV_MAX 6 // [log2 s]
+
+
+
+#define DEFAULT_MC_SYNC_INTV 0 // [log2 s]
+#define DEFAULT_MC_ANN_INTV 1 // [log2 s]
+#define DEFAULT_MC_DELAY_REQ_INTV 3 // [log2 s]
+
+#define DEFAULT_UC_SYNC_INTV 0 // [log2 s]
+#define DEFAULT_UC_ANN_INTV 1 // [log2 s]
+#define DEFAULT_UC_DELAY_REQ_INTV 3 // [log2 s]
+#define DEFAULT_UC_MSG_DURATION 300 // [s]
+
+
+
+#define DEFAULT_PTP_CFG_SETTINGS \
+{ \
+ PTP_NW_PROT_BIT_UDP_IPV4, /* nw_prot */ \
+ 0, /* profile */ \
+ 0, /* domain_number */ \
+ PTP_DELAY_MECH_BIT_E2E, /* delay_mech */ \
+ PTP_ROLE_MULTICAST_SLAVE, /* ptp_role */ \
+ 128, /* priority_1 */ \
+ 128, /* priority_2 */ \
+ 52, /* dflt_clk_class_unsync_cold */ \
+ 7, /* dflt_clk_class_unsync_warm */ \
+ 6, /* dflt_clk_class_sync_cold */ \
+ 6, /* dflt_clk_class_sync_warm */ \
+ 0, /* reserved_1 */ \
+ 0, /* reserved_2 */ \
+ DEFAULT_MC_SYNC_INTV, /* sync_intv [log2 s]*/ \
+ DEFAULT_MC_ANN_INTV, /* ann_intv [log2 s] */ \
+ DEFAULT_MC_DELAY_REQ_INTV, /* delay_req_intv [log2 s] */ \
+ 0, /* upper_bound, not used */ \
+ 0, /* lower_bound, not used */ \
+ 0, /* reserved_3 */ \
+ 0 /* flags */ \
+}
+
+//##++++++++++
+#define DEFAULT_PTP_SLAVE_SUPP_FLAGS 0
+#define DEFAULT_PTP_SLAVE_SUPP_NW_PROT 0
+#define DEFAULT_PTP_SLAVE_SUPP_PROFILES 0
+#define DEFAULT_PTP_SLAVE_SUPP_DELAY_MECH 0
+
+#define DEFAULT_PTP_CFG_INFO_SLAVE \
+{ \
+ DEFAULT_PTP_CFG_SETTINGS, /* ptp_cfg_settings */ \
+ 2, /* ptp_proto_version */ \
+ 0, /* reserved_1 */ \
+ 0, /* reserved_2 */ \
+ DEFAULT_MC_SYNC_INTV_MIN, /* sync_intv_min */ \
+ DEFAULT_MC_SYNC_INTV_MAX, /* sync_intv_max */ \
+ DEFAULT_MC_ANN_INTV_MIN, /* ann_intv_min */ \
+ DEFAULT_MC_ANN_INTV_MIN, /* ann_intv_max */ \
+ DEFAULT_MC_DELAY_REQ_INTV_MIN, /* delay_req_intv_min */ \
+ DEFAULT_MC_DELAY_REQ_INTV_MIN, /* delay_req_intv_max */ \
+ DEFAULT_PTP_SLAVE_SUPP_FLAGS, /* supp_flags */ \
+ DEFAULT_PTP_SLAVE_SUPP_NW_PROT, /* supp_nw_prot */ \
+ DEFAULT_PTP_SLAVE_SUPP_PROFILES, /* supp_profiles */ \
+ DEFAULT_PTP_SLAVE_SUPP_DELAY_MECH /* supp_delay_mech */ \
+}
+
+#define DEFAULT_PTP_UC_MASTER_CFG_LIMITS \
+{ \
+ 1, /* n_supp_master */ \
+ -6, /* sync_intv_min */ \
+ 6, /* sync_intv_max */ \
+ -6, /* ann_intv_min */ \
+ 6, /* ann_intv_max */ \
+ -6, /* delay_req_intv_min */ \
+ 6, /* delay_req_intv_max */ \
+ 0, /* reserved_0 */ \
+ 0, /* supp_flags */ \
+ 0 /* reserved_1 */ \
+}
+
+
+#define DEFAULT_PTP_UC_MASTER_SETTINGS \
+{ \
+ "0.0.0.0", /* gm_host */ \
+ PTP_CLOCK_ID_WILDCARD, /* gm_clock_id */ \
+ PTP_PORT_ID_WILDCARD, /* gm_port_id */ \
+ DEFAULT_UC_SYNC_INTV, /* sync_intv [log2 s] */ \
+ DEFAULT_UC_ANN_INTV, /* ann_intv [log2 s] */ \
+ DEFAULT_UC_DELAY_REQ_INTV, /* delay_req_intv [log2 s] */ \
+ 0, /* fix_offset, [ns] */ \
+ DEFAULT_UC_MSG_DURATION, /* message_duration [s] */ \
+ 0, /* reserved_1 */ \
+ 0 /* flags */ \
+}
+
+
+#define DEFAULT_PTP_UC_MASTER_INFO \
+{ \
+ DEFAULT_PTP_UC_MASTER_SETTINGS, /* settings */ \
+ 0, /* reserved */ \
+ 0 /* flags */ \
+}
+
+
+
+#if SIM_PTP_CFG
+ static PTP_CFG_INFO sim_ptp_cfg_info = DEFAULT_PTP_CFG_INFO_SLAVE;
+ static PTP_UC_MASTER_CFG_LIMITS sim_ptp_uc_master_cfg_limits = DEFAULT_PTP_UC_MASTER_CFG_LIMITS;
+ static PTP_UC_MASTER_INFO sim_ptp_uc_master_info[N_SUPP_UNICAST_MASTER] = { DEFAULT_PTP_UC_MASTER_INFO };
+#endif
+
+
+
+typedef struct
+{
+ PTP_CFG_INFO ptp_cfg_info;
+ PTP_UC_MASTER_CFG_LIMITS ptp_uc_master_cfg_limits;
+ ALL_PTP_UC_MASTER_INFO all_ptp_uc_master_info;
+} ALL_PTP_CFG_INFO;
-static const char *no_gps_cmd = "does not support GPS commands";
-static const char *no_tzdl = "does not support configurable time zone";
-static const char *no_tz = "does not support time zones";
-static const char *no_event_time = "does not support event times";
-static const char *no_enable_flags = "does not support enable flags";
-static const char *no_time_scale = "does not support a configurable time scale";
-static const char *no_lan_intf = "does not provide a LAN interface";
-static const char *no_ptp = "does not provide PTP";
-static const char *no_cab_len = "does not support antenna signal delay compensation";
typedef struct
{
@@ -147,9 +328,9 @@ typedef struct
#define N_EF_INFO 3
-static const char *ef_name_serial = "SERIAL";
-static const char *ef_name_pulses = "PULSES";
-static const char *ef_name_synth = "SYNTH";
+static const char ef_name_serial[] = "SERIAL";
+static const char ef_name_pulses[] = "PULSES";
+static const char ef_name_synth[] = "SYNTH";
typedef struct
@@ -160,23 +341,43 @@ typedef struct
#define N_IP4_INFO 4
-static const char *ip4_name_ip = "IP";
-static const char *ip4_name_nm = "NM";
-static const char *ip4_name_ba = "BA";
-static const char *ip4_name_gw = "GW";
+static const char ip4_name_ip[] = "IP";
+static const char ip4_name_nm[] = "NM";
+static const char ip4_name_ba[] = "BA";
+static const char ip4_name_gw[] = "GW";
+
+static const char ptp_name_net[] = "NP";
+static const char ptp_name_del[] = "DM";
+static const char ptp_name_dom[] = "DO";
+static const char ptp_name_v1[] = "HW";
+
+static const char ptp_name_role[] = "ROLE";
+
+static const char ptp_name_gmip[] = "GMIP";
+static const char ptp_name_gmid[] = "GMID";
+static const char ptp_name_pid[] = "PID";
+static const char ptp_name_smi[] = "SMI";
+static const char ptp_name_ami[] = "AMI";
+static const char ptp_name_dri[] = "DRI";
+static const char ptp_name_dur[] = "DUR";
+
+//##+++++
+static const char *delay_mech[] = PTP_DELAY_MECH_NAMES;
+static const char *nw_prot[] = PTP_NW_PROT_STRS;
+static const char *nw_prot_short[] = PTP_NW_PROT_STRS_SHORT;
+
+static const char *ptp_roles[] = PTP_ROLE_STRS;
+static const char *ptp_roles_short[] = PTP_ROLE_STRS_SHORT;
+
+// If unicast is not supported for a PTP device then the device is definitely
+// a multicast slave, in which case index 0 returns the correct role name.
+#define _ptp_role_name( _i ) \
+ ( ( (_i) < N_PTP_ROLES ) ? ptp_roles[_i] : str_unknown )
+
+#define _ptp_role_name_short( _i ) \
+ ( ( (_i) < N_PTP_ROLES ) ? ptp_roles_short[_i] : str_unknown )
-static const char *ptp_name_net = "NP";
-static const char *ptp_name_del = "DM";
-static const char *ptp_name_dom = "DO";
-static const char *ptp_name_v1 = "HW";
-static const char *ptp_name_gm_ip = "GMIP";
-static const char *ptp_name_gm_id = "GMID";
-static const char *ptp_name_tp_id = "PID";
-static const char *ptp_name_dur = "DUR";
-static const char *ptp_name_sr = "SR";
-static const char *ptp_name_ar = "AR";
-static const char *ptp_name_dr = "DR";
static /*HDR*/
@@ -295,7 +496,7 @@ int set_tzdl_offs( MBG_DEV_HANDLE dh, const char *s )
if ( labs( tzdl_offs ) > max_tzdl_offs ) // max val for int32_t
{
- fprintf( stderr, "** Time zone offset %li exceeds range (%li..%li)\n",
+ fprintf( stderr, "** Time zone offset %li exceeds range (%li..%li)\n",
tzdl_offs, -max_tzdl_offs, max_tzdl_offs );
return MBG_ERR_CFG;
}
@@ -309,493 +510,625 @@ int set_tzdl_offs( MBG_DEV_HANDLE dh, const char *s )
static /*HDR*/
-int snprint_ip4_addr( char *s, size_t max_len, const IP4_ADDR *addr )
+int show_lan_intf( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info )
{
- int n;
+ IP4_SETTINGS ip4_settings;
+ char ws[256];
- n = snprintf( s, max_len, "%i.%i.%i.%i",
- BYTE_OF( *addr, 3 ),
- BYTE_OF( *addr, 2 ),
- BYTE_OF( *addr, 1 ),
- BYTE_OF( *addr, 0 )
- );
+ int rc = mbg_get_ip4_settings( dh, &ip4_settings );
- return n;
+ if ( mbg_ioctl_err( rc, "mbg_get_ip4_settings" ) )
+ return rc;
+
+ printf( "On-board LAN interface settings:" );
+
+ if ( ip4_settings.flags & IP4_MSK_DHCP )
+ printf( " (DHCP client)\n" );
+ else
+ {
+ printf( "\n" );
+
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.ip_addr, NULL );
+ printf( " IP Address: %s\n", ws );
+
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.netmask, NULL );
+ printf( " Net Mask: %s\n", ws );
+
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.broad_addr, NULL );
+ printf( " Broadcast Addr: %s\n", ws );
-} // snprint_ip4_addr
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.gateway, NULL );
+ printf( " Gateway: %s\n", ws );
+ }
+
+ return MBG_SUCCESS;
+
+} // show_lan_intf
-/*HDR*/
-const char *str_to_ip4_addr( IP4_ADDR *p, const char *s )
+static /*HDR*/
+int mbg_get_all_ptp_cfg_info( MBG_DEV_HANDLE dh, ALL_PTP_CFG_INFO *p )
{
- IP4_ADDR tmp_ip4_addr = 0;
- char *cp;
- int i;
+ int rc = MBG_SUCCESS;
- for ( i = 0, cp = (char *) s; ; )
+ memset( p, 0, sizeof( *p ) );
+
+#if SIM_PTP_CFG
+ p->ptp_cfg_info = sim_ptp_cfg_info;
+#else
+ rc = mbg_get_ptp_cfg_info( dh, &p->ptp_cfg_info );
+#endif
+
+ if ( mbg_ioctl_err( rc, "mbg_get_ptp_cfg_info" ) )
+ goto ret;
+
+
+ if ( p->ptp_cfg_info.supp_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST )
{
- unsigned long ul = strtoul( cp, &cp, 10 );
+ #if SIM_PTP_CFG
+ p->ptp_uc_master_cfg_limits = sim_ptp_uc_master_cfg_limits;
+ #else
+ rc = mbg_get_ptp_uc_master_cfg_limits( dh, &p->ptp_uc_master_cfg_limits );
+ #endif
- if ( ul > 255 ) // invalid number
- return NULL;
+ if ( mbg_ioctl_err( rc, "mbg_get_ptp_uc_master_cfg_limits" ) )
+ goto ret;
- tmp_ip4_addr |= ul << ( 8 * (3 - i) );
- if ( ++i >= 4 )
- break; // done
+ if ( p->ptp_uc_master_cfg_limits.n_supp_master > MAX_PARM_PTP_UC_MASTER )
+ {
+ printf( "The number of PTP unicast masters supported by this device (%i)\n"
+ "exceeds the number of unicast masters supporterd by this driver (%i)\n",
+ p->ptp_uc_master_cfg_limits.n_supp_master, MAX_PARM_PTP_UC_MASTER );
+ rc = MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP;
+ goto ret;
+ }
- if ( *cp != '.' )
- return NULL; // invalid string format, dot expected
- cp++; // skip dot
- }
+ #if SIM_PTP_CFG
+ {
+ int i;
- if ( p )
- *p = tmp_ip4_addr;
+ for ( i = 0; i < p->ptp_uc_master_cfg_limits.n_supp_master; i++ )
+ {
+ PTP_UC_MASTER_INFO_IDX *pi = &p->all_ptp_uc_master_info[i];
+ pi->idx = i;
+ pi->info = sim_ptp_uc_master_info[i];
+ }
+ }
+ #else
+ rc = mbg_get_all_ptp_uc_master_info( dh, p->all_ptp_uc_master_info, &p->ptp_uc_master_cfg_limits );
+ #endif
+ if ( mbg_ioctl_err( rc, "mbg_get_all_ptp_uc_master_info" ) )
+ goto ret;
+ }
- return cp; // success
+ret:
+ return rc;
-} // str_to_ip4_addr
+} // mbg_get_all_ptp_cfg_info
static /*HDR*/
-int show_lan_intf( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info )
+int show_ptp_cfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info )
{
- IP4_SETTINGS ip4_settings;
+ ALL_PTP_CFG_INFO all_ptp_cfg_info;
char ws[256];
+ int unicast_supported;
+ int idx;
- int rc = mbg_get_ip4_settings( dh, &ip4_settings );
+ int rc = mbg_get_all_ptp_cfg_info( dh, &all_ptp_cfg_info );
- if ( mbg_ioctl_err( rc, "mbg_get_ip4_settings" ) )
+ if ( rc < 0 )
return rc;
- printf( "On-board LAN interface settings:" );
+ unicast_supported = ( all_ptp_cfg_info.ptp_cfg_info.supp_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST ) != 0;
- if ( ip4_settings.flags & IP4_MSK_DHCP )
- printf( " (DHCP client)\n" );
- else
+ printf( "\nPTP configuration:\n");
+
+ idx = all_ptp_cfg_info.ptp_cfg_info.settings.ptp_role;
+ printf( " PTP Role : %s (%s)\n", _ptp_role_name_short( idx ), _ptp_role_name( idx ) );
+
+ idx = all_ptp_cfg_info.ptp_cfg_info.settings.nw_prot;
+ printf( " Network Protocol: %s (%s)\n", nw_prot_short[idx], nw_prot[idx] );
+
+ printf( " Delay Mechanism : %s\n", delay_mech[all_ptp_cfg_info.ptp_cfg_info.settings.delay_mech] );
+ printf( " Domain Number : %d\n", all_ptp_cfg_info.ptp_cfg_info.settings.domain_number );
+ printf( " V1 HW Compat. : %d\n", ( all_ptp_cfg_info.ptp_cfg_info.settings.flags & PTP_CFG_MSK_V1_HW_COMPAT ) ? 1 : 0 );
+
+ if ( unicast_supported )
{
- printf( "\n" );
+ PTP_UC_MASTER_CFG_LIMITS *p_uc_limits = &all_ptp_cfg_info.ptp_uc_master_cfg_limits;
+ int i;
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.ip_addr );
- printf( " IP Address: %s\n", ws );
+ for ( i = 0; i < p_uc_limits->n_supp_master; i++ )
+ {
+ PTP_UC_MASTER_SETTINGS *p = &all_ptp_cfg_info.all_ptp_uc_master_info[i].info.settings;
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.netmask );
- printf( " Net Mask: %s\n", ws );
+ printf( "\nPTP unicast master" );
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.broad_addr );
- printf( " Broadcast Addr: %s\n", ws );
+ if ( p_uc_limits->n_supp_master > 1 )
+ printf( " %i", i );
+
+ printf( ":\n");
+
+ printf( " GM Host: %s\n", p->gm_host );
+
+ snprint_octets( ws, sizeof( ws ), p->gm_clock_id.b, sizeof( p->gm_clock_id.b ), MAC_SEP_CHAR, NULL );
+ printf( " GM Clock ID: %s\n", ws );
+
+ printf( " GM Port ID: %d\n\n", p->gm_port_id );
+ printf( " Sync Msg Interval [2^x s]: %i\n", p->sync_intv );
+ printf( " Ann. Msg Interval [2^x s]: %i\n", p->ann_intv );
+ printf( " DelReq Msg Interval [2^x s]: %i\n", p->delay_req_intv );
+ printf( " Message Duration: %i s\n", p->message_duration );
+ }
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.gateway );
- printf( " Gateway: %s\n", ws );
}
return MBG_SUCCESS;
-} // show_lan_intf
+} // show_ptp_cfg
static /*HDR*/
-int show_ptp_cfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info )
+/**
+ * @brief Lookup a string in a string table and return the table index
+ *
+ * @param s The string to be searched for in the string table
+ * @param tbl A table of strings to be searched
+ * @param n_entries The number of strings in the string table
+ * @param supp_mask A string with a given index is only supported if the
+ * corresponding bit is set in this mask.
+ * @param info A descriptive name of the parameter which is to be
+ * set to the index of the searched string
+ *
+ * @return >=0 A valid, supported table index
+ * <0 Unknown or unsupported parameter
+ */
+int get_chk_str_table_idx( const char *s, const char *tbl[], int n_entries,
+ uint32_t supp_mask, const char *info )
{
- PTP_CFG_INFO ptp_settings;
- PTP_UNICAST_CFG_INFO ptp_unicast_settings;
-
- const char* delay_mech[] = PTP_DELAY_MECH_NAMES;
- const char* network_prot[] = PTP_NW_PROT_STRS;
- const char* network_prot_short[] = PTP_NW_PROT_STRS_SHORT;
- const char* ptp_roles[] = PTP_ROLE_STRS;
-
- int supports_unicast = 0;
-
- int rc = mbg_get_ptp_cfg_info( dh, &ptp_settings );
+ int i;
+ const char *cp;
- if ( mbg_ioctl_err( rc, "mbg_get_ptp_cfg_info" ) )
- return rc;
+ for ( i = 0; i < n_entries; i++ )
+ {
+ cp = tbl[i];
- supports_unicast = ptp_settings.supported_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST;
+ if ( strncmp( s, cp, strlen( cp ) ) == 0 )
+ if ( supp_mask & ( 1UL << i ) )
+ return i;
+ }
- printf( "\nPTP configuration:\n");
+ printf( "error: %s %s\n",
+ ( i == n_entries ) ? "unknown" : "unsupported",
+ info );
- supports_unicast ? printf( " PTP Role : %s\n", ptp_roles[ptp_settings.settings.ptp_role] ) :
- printf( " PTP Role : %s\n", ptp_roles[0] );
+ return -3;
+
+} // get_chk_str_table_idx
+
+
+
+static /*HDR*/
+/**
+ * @brief Lookup a parameter in an argument list and check if a colon is appended
+ *
+ * @param arg An argument list of the form: "name:val,name:val,..."
+ * @param s A parameter name searched for in the argument list
+ * @param p A pointer to a (char *) which is set to the beginning
+ * of the value part of a parameter string
+ *
+ * @return <0 Syntax error, i.e. missing colon
+ * 0 No error. If parameter has been found then *p set
+ * to the parameter value, else to NULL.
+ */
+int chk_parm_name( const char *arg, const char *id, char **p )
+{
+ char *cp = strstr( arg, id );
- printf( " Network Protocol: %s (%s)\n", network_prot_short[ptp_settings.settings.network_protocol], network_prot[ptp_settings.settings.network_protocol] );
- printf( " Delay Mechanism : %s\n", delay_mech[ptp_settings.settings.delay_mechanism] );
- printf( " Domain Number : %d\n", ptp_settings.settings.domain_number );
- printf( " V1 HW Compat. : %d\n", ( ptp_settings.settings.flags & PTP_CFG_MSK_V1_HW_COMPAT ) ? 1:0 );
-
- if ( supports_unicast )
+ if ( cp )
{
- int i;
-
- int rc = mbg_get_ptp_unicast_cfg_info( dh, &ptp_unicast_settings);
-
- if ( mbg_ioctl_err( rc, "mbg_get_ptp_unicast_cfg_info" ) )
- return rc;
+ cp += strlen( id );
- printf( "\nPTP Unicast configuration:\n");
- printf( " GM Host: %s\n", ptp_unicast_settings.settings.gm_host);
-
- printf( " GM Clock ID: ");
- for ( i = 0; i < 8; i++ )
- {
- printf( "%02X", ptp_unicast_settings.settings.gm_clock_id.b[i] );
- if ( i < 7 )
- printf(":");
- }
-
- printf("\n");
-
- printf( " GM Port ID: %d\n\n", ptp_unicast_settings.settings.gm_port_id );
- printf( " Sync Msg Interval [2^x s]: %i\n", ptp_unicast_settings.settings.sync_interval );
- printf( " Ann. Msg Interval [2^x s]: %i\n", ptp_unicast_settings.settings.announce_interval );
- printf( " DelReq Msg Interval [2^x s]: %i\n", ptp_unicast_settings.settings.delay_request_interval );
- printf( " Message Duration: %i s\n", ptp_unicast_settings.settings.message_duration );
+ if ( *cp != ':' )
+ return -1;
+
+ cp++;
}
- return MBG_SUCCESS;
+ if ( p )
+ *p = cp; // may be NULL
-} // show_ptp_cfg
+ return 0;
+} // chk_parm_name
static /*HDR*/
-int set_ptp_cfg( MBG_DEV_HANDLE dh, const char *arg, const PCPS_DEV *p_dev )
+/**
+ * @brief Lookup a parameter in an argument list and check if the value string is valid
+ *
+ * This function expects that the parameter value is a known string which can
+ * be found in a table of known strings. A bit mask indicates if a string with
+ * a given table index is supported, or not.
+ *
+ * @param arg An argument list of the form: "name:val,name:val,..."
+ * @param id The name of the argument to be checked.
+ * @param tbl A table of strings with predefined parameter values
+ * @param n_entries The number of strings in the string table
+ * @param supp_mask A string with a given index is only supported if the
+ * corresponding bit is set in this mask.
+ * @param info A descriptive name of the parameter which is to be
+ * set to the index of the searched string
+ *
+ * @return >=0 A valid, supported table index
+ * -1 Parameter not found
+ * -2 Unknown or unsupported parameter, or syntax error
+ */
+int chk_tbl_parm( const char *arg, const char *id, const char *tbl[],
+ int n_entries, uint32_t supp_mask, const char *info )
{
- PTP_CFG_INFO prv_ptp_settings;
- PTP_CFG_SETTINGS ptp_settings;
- PTP_UNICAST_CFG_INFO prv_ptp_unicast_settings;
- PTP_UNICAST_CFG_SETTINGS ptp_unicast_settings;
-
char *cp;
- int l;
+ int rc = chk_parm_name( arg, id, &cp );
- int supports_unicast = 0;
-
- int rc = mbg_get_ptp_cfg_info( dh, &prv_ptp_settings);
+ if ( rc < 0 )
+ return -2;
- if ( mbg_ioctl_err( rc, "mbg_get_ptp_cfg_info" ) )
- return rc;
-
- supports_unicast = prv_ptp_settings.supported_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST;
-
- if ( supports_unicast )
- {
- int rc = mbg_get_ptp_unicast_cfg_info( dh, &prv_ptp_unicast_settings);
-
- if ( mbg_ioctl_err( rc, "mbg_get_ptp_unicast_cfg_info" ) )
- return rc;
-
- memcpy( &ptp_unicast_settings, &prv_ptp_unicast_settings.settings, sizeof(ptp_unicast_settings) );
- }
-
- memcpy( &ptp_settings, &prv_ptp_settings.settings, sizeof(ptp_settings) );
-
-
- // Network protocol
- cp = strstr( arg, ptp_name_net );
-
- if ( cp != NULL )
+ if ( cp == NULL )
+ return -1;
+
+ rc = get_chk_str_table_idx( cp, tbl, n_entries, supp_mask, info );
+
+ if ( rc < 0 )
+ return -2;
+
+ return rc;
+
+} // chk_tbl_parm
+
+
+
+static /*HDR*/
+/**
+ * @brief Lookup an int16_t parameter in an argument list
+ *
+ * Check and save the numeric parameter if in a valid range.
+ *
+ * @param arg An argument list of the form: "name:val,name:val,..."
+ * @param id The name of the argument to be checked.
+ * @param p A pointer to a variable where the parameter value is
+ * saved if valid
+ * @param range_min The minimum allowed value for the parameter
+ * @param range_max The maximum allowed value for the parameter
+ * @param is_supported A flag indicating if the parameter is actually supported
+ * @param info A descriptive name of the parameter
+ *
+ * @return >=0 A valid, supported table index
+ * -1 Parameter not found, or out of range
+ */
+int chk_int16_parm( const char *arg, const char *id, int16_t *p, int16_t range_min,
+ int16_t range_max, int is_supported, const char *info )
+{
+ char *cp;
+ int idx = chk_parm_name( arg, id, &cp );
+
+ if ( idx < 0 ) // parameter error
+ return -1;
+
+ if ( cp ) // parameter found
{
- l = strlen(ptp_name_net);
-
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- if ( strstr( (cp+l) , "IP4" ) != 0 )
- ptp_settings.network_protocol = PTP_NW_PROT_BIT_UDP_IPV4;
- else if ( strstr( (cp+l) , "ETH" ) != 0 )
- ptp_settings.network_protocol = PTP_NW_PROT_BIT_IEEE_802_3;
- else
- {
- printf("error: Invalid or unsupported network protocol type!\n");
- goto fail;
- }
+ if ( !is_supported )
+ err_unicast_nsupp = 1;
+ else
+ {
+ int16_t tmp = atoi( cp );
+
+ if ( ( tmp < range_min ) || ( tmp > range_max ) )
+ {
+ printf( "error: %s %i out of range (%i..%i)\n", info, tmp, range_min, range_max );
+ return -1;
+ }
+
+ *p = tmp;
+ printf( " setting %s: %i\n", info, tmp );
+ }
}
-
+
+ return 0;
+
+} // chk_int16_parm
+
+
+
+static /*HDR*/
+int set_ptp_cfg( MBG_DEV_HANDLE dh, const char *arg, const PCPS_DEV *p_dev )
+{
+ ALL_PTP_CFG_INFO all_ptp_cfg_info;
+ ALL_PTP_CFG_INFO prv_all_ptp_cfg_info;
+ PTP_CFG_INFO *p_info;
+ PTP_CFG_SETTINGS *p_settings;
+ PTP_UC_MASTER_CFG_LIMITS *p_uc_limits;
+ PTP_UC_MASTER_INFO *p_uc_info;
+ PTP_UC_MASTER_SETTINGS *p_uc_settings;
+ uint32_t supp_mask;
+ IP4_ADDR ip4addr;
+ char ws[256];
+ char *cp;
+ int idx;
+ int unicast_supported;
+ int uc_master_idx = 0;
+ int16_t tmp_int16;
+
+ int rc = mbg_get_all_ptp_cfg_info( dh, &all_ptp_cfg_info );
+
+ if ( rc < 0 )
+ return rc; // failed to read current settings and capabilities
+
+
+ err_unicast_nsupp = 0;
+
+ // save a copy of the current settings
+ prv_all_ptp_cfg_info = all_ptp_cfg_info;
+
+ p_info = &all_ptp_cfg_info.ptp_cfg_info;
+ p_settings = &p_info->settings;
+ unicast_supported = ( p_info->supp_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST ) != 0;
+
+ p_uc_limits = &all_ptp_cfg_info.ptp_uc_master_cfg_limits;
+ // The pointers below need to be updated wnenever uc_master_idx is changed
+ p_uc_info = &all_ptp_cfg_info.all_ptp_uc_master_info[uc_master_idx].info;
+ p_uc_settings = &p_uc_info->settings;
+
+
+ // Network protocol
+ idx = chk_tbl_parm( arg, ptp_name_net, nw_prot_short, N_PTP_NW_PROT, p_info->supp_nw_prot, "network protocol type" );
+
+ if ( idx >= 0 ) // valid parameter found
+ p_settings->nw_prot = idx;
+ else
+ if ( idx < -1 )
+ goto fail;
+
+
// Delay Mechanism
- cp = strstr( arg, ptp_name_del );
-
- if ( cp != NULL )
- {
- l = strlen(ptp_name_del);
-
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- if ( strstr( (cp+l) , "E2E" ) != 0 )
- ptp_settings.delay_mechanism = PTP_DELAY_MECH_BIT_E2E;
- else if ( strstr( (cp+l) , "P2P" ) != 0 )
- ptp_settings.delay_mechanism = PTP_DELAY_MECH_BIT_P2P;
- else
- {
- printf("error: Invalid delay mechanism\n");
- goto fail;
- }
- }
-
+ idx = chk_tbl_parm( arg, ptp_name_del, delay_mech, N_PTP_DELAY_MECH, p_info->supp_delay_mech, "delay mechanism" );
+
+ if ( idx >= 0 ) // valid parameter found
+ p_settings->delay_mech = idx;
+ else
+ if ( idx < -1 )
+ goto fail;
+
+
// Domain Number
- cp = strstr( arg, ptp_name_dom );
-
- if ( cp != NULL )
+ idx = chk_parm_name( arg, ptp_name_dom, &cp );
+
+ if ( idx < 0 ) // parameter error
+ goto fail;
+
+ if ( cp ) // parameter found
{
- l = strlen(ptp_name_dom);
-
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- ptp_settings.domain_number = atoi( cp+l );
+ idx = atoi( cp );
+ //##+++++ must check range!!
+ p_settings->domain_number = idx;
}
-
+
+
// V1 Hardware compatibility flag
- cp = strstr( arg, ptp_name_v1 );
-
- if ( cp != NULL )
- {
- l = strlen(ptp_name_v1);
-
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- if( atoi( cp+l) == 1 )
- ptp_settings.flags |= PTP_CFG_MSK_V1_HW_COMPAT;
- else if( atoi( cp+l) == 0 )
- ptp_settings.flags &= ~PTP_CFG_MSK_V1_HW_COMPAT;
- else
- {
- printf("error: No valid V1 HWC settings!\n");
- goto fail;
- }
- }
-
- if ( supports_unicast )
+ idx = chk_parm_name( arg, ptp_name_v1, &cp );
+
+ if ( idx < 0 ) // parameter error
+ goto fail;
+
+ if ( cp ) // parameter found
{
-
- // PTP role
- cp = strstr( arg, "ROLE" );
-
- if ( cp != NULL )
+ idx = atoi( cp );
+
+ switch ( idx )
{
- l = strlen("ROLE");
+ case 0:
+ p_settings->flags &= ~PTP_CFG_MSK_V1_HW_COMPAT;
+ break;
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- if ( strstr( (cp+l) , "UCS" ) != 0 )
- ptp_settings.ptp_role = PTP_ROLE_UNICAST_SLAVE;
- else
- ptp_settings.ptp_role = PTP_ROLE_MULTICAST_SLAVE;
+ case 1:
+ p_settings->flags |= PTP_CFG_MSK_V1_HW_COMPAT;
+ break;
+
+ default:
+ printf( "error: No valid V1 HWC settings!\n" );
+ goto fail;
}
+ }
-
- // GM Host
- // (currently IP addresses accepted only) ##++
- cp = strstr( arg, ptp_name_gm_ip );
-
- if ( cp != NULL )
- {
- IP4_ADDR ip4addr;
- l = strlen(ptp_name_gm_ip);
+ //---- unicast stuff ----
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- if ( str_to_ip4_addr( &ip4addr, cp+l ) != NULL )
+ // PTP role
+ supp_mask = _get_supp_ptp_role_idx_msk( p_info->supp_flags );
+ idx = chk_tbl_parm( arg, ptp_name_role, ptp_roles_short, N_PTP_ROLES, supp_mask, "PTP role" );
+
+ if ( idx >= 0 ) // valid parameter found
+ {
+ if ( !unicast_supported )
+ err_unicast_nsupp = 1;
+ else
+ p_settings->ptp_role = idx;
+ }
+ else
+ if ( idx < -1 ) // parameter error
+ goto fail;
+
+
+ // GM Host
+ idx = chk_parm_name( arg, ptp_name_gmip, &cp );
+
+ if ( idx < 0 ) // parameter error
+ goto fail;
+
+ if ( cp ) // parameter found
+ {
+ if ( !unicast_supported )
+ err_unicast_nsupp = 1;
+ else
+ {
+ // currently IP addresses are accepted only, so check for
+ // a valid IPv4 address
+ if ( str_to_ip4_addr( &ip4addr, cp ) )
{
- char ws[50];
-
- snprint_ip4_addr( ws, sizeof( ws ), &ip4addr );
- printf( " GM IP Address: %s\n", ws );
-
- strcpy( ptp_unicast_settings.gm_host, ws );
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4addr, NULL );
+ printf( " GM IP Address: %s\n", ws );
+
+ memset( p_uc_settings->gm_host, 0, sizeof( p_uc_settings->gm_host ) );
+ strcpy( p_uc_settings->gm_host, ws );
}
+ else
+ goto fail;
}
-
+ }
- // GM Clock ID
- cp = strstr( arg, ptp_name_gm_id );
-
- if ( cp != NULL )
- {
- int i = 0;
- char* p_tail;
-
- l = strlen(ptp_name_gm_id);
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
-
- l++;
-
- for ( i= 0; i < sizeof( ptp_unicast_settings.gm_clock_id ); i++ )
- {
- if ( (*(cp+l+i) == 0) || (*(cp+l+i) == ',') )
- break;
-
- if ( *(cp+l+i) == ':' )
- {
- l++;
- continue;
- }
-
- ptp_unicast_settings.gm_clock_id.b[i] = strtoul( (cp+l+i), &p_tail, 16 );
-
- if ( p_tail == cp ) // no number found
- goto fail;
-
- l+=2;
- }
-
-
- if ( i != sizeof( ptp_unicast_settings.gm_clock_id ) )
+ // GM Clock ID
+ idx = chk_parm_name( arg, ptp_name_gmid, &cp );
+
+ if ( idx < 0 ) // parameter error
+ goto fail;
+
+ if ( cp ) // parameter found
+ {
+ if ( !unicast_supported )
+ err_unicast_nsupp = 1;
+ else
+ {
+ PTP_CLOCK_ID gm_clock_id;
+ idx = str_to_octets( gm_clock_id.b, sizeof( gm_clock_id.b ), cp );
+
+ if ( idx != sizeof( gm_clock_id ) )
{
- printf("Syntax error in specifying GM Clock ID\n");
- goto fail;
+ printf( "Syntax error in specified GM clock ID\n" );
+ goto fail;
}
else
{
- printf( " setting GM Clock ID: ");
-
- for ( i = 0; i < sizeof( ptp_unicast_settings.gm_clock_id ); i++ )
- {
- printf( "%02X", ptp_unicast_settings.gm_clock_id.b[i] );
-
- if ( i < ( sizeof( ptp_unicast_settings.gm_clock_id ) - 1 ) )
- printf(":");
- }
-
- printf("\n");
+ p_uc_settings->gm_clock_id = gm_clock_id;
+
+ snprint_octets( ws, sizeof( ws ), p_uc_settings->gm_clock_id.b,
+ sizeof( p_uc_settings->gm_clock_id.b ), MAC_SEP_CHAR, NULL );
+ printf( " setting GM Clock ID: %s\n", ws );
}
}
+ }
- // GM Target Port ID
- cp = strstr( arg, ptp_name_tp_id );
-
- if ( cp != NULL )
- {
- char* p_tail;
-
- l = strlen( ptp_name_tp_id );
+ // GM Target Port ID
+ idx = chk_parm_name( arg, ptp_name_pid, &cp );
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
+ if ( idx < 0 ) // parameter error
+ goto fail;
- l++;
-
- ptp_unicast_settings.gm_port_id = strtoul( cp+l, &p_tail, 10 );
- printf( " setting GM port id: %d\n", ptp_unicast_settings.gm_port_id );
+ if ( cp ) // parameter found
+ {
+ if ( !unicast_supported )
+ err_unicast_nsupp = 1;
+ else
+ {
+ p_uc_settings->gm_port_id = strtoul( cp, NULL, 0 );
+ printf( " setting GM port id: %d\n", p_uc_settings->gm_port_id );
}
+ }
- // Sync Message Rate
- cp = strstr( arg, ptp_name_sr );
-
- if ( cp != NULL )
- {
- l = strlen( ptp_name_sr );
-
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
+ // Sync Message Rate
+ idx = chk_int16_parm( arg, ptp_name_smi, &p_uc_settings->sync_intv,
+ p_uc_limits->sync_intv_min, p_uc_limits->sync_intv_max,
+ unicast_supported, "sync intv." );
+ if ( idx < 0 )
+ goto fail;
- l++;
-
- ptp_unicast_settings.sync_interval = atoi( cp+l );
- printf( " setting Sync Int: %i\n", ptp_unicast_settings.sync_interval );
- }
+ // Announce Message Rate
+ idx = chk_int16_parm( arg, ptp_name_ami, &p_uc_settings->ann_intv,
+ p_uc_limits->ann_intv_min, p_uc_limits->ann_intv_max,
+ unicast_supported, "ann. intv." );
+ if ( idx < 0 )
+ goto fail;
- // Announce Message Rate
- cp = strstr( arg, ptp_name_ar );
-
- if ( cp != NULL )
- {
- l = strlen( ptp_name_ar );
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
+ // Delay Message Rate
+ idx = chk_int16_parm( arg, ptp_name_dri, &p_uc_settings->delay_req_intv,
+ p_uc_limits->delay_req_intv_min, p_uc_limits->delay_req_intv_max,
+ unicast_supported, "delay req. intv." );
+ if ( idx < 0 )
+ goto fail;
- l++;
-
- ptp_unicast_settings.announce_interval = atoi( cp+l );
- printf( " setting Ann Int: %i\n", ptp_unicast_settings.announce_interval );
- }
-
- // Delay Message Rate
- cp = strstr( arg, ptp_name_dr );
-
- if ( cp != NULL )
- {
- l = strlen( ptp_name_dr );
+ // Message Duration
+ tmp_int16 = p_uc_settings->message_duration;
+ idx = chk_int16_parm( arg, ptp_name_dur, &tmp_int16,
+ PTP_UC_MSG_DURATION_MIN, PTP_UC_MSG_DURATION_MAX,
+ unicast_supported, "msg. duration" );
+ if ( idx < 0 )
+ goto fail;
- if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
+ p_uc_settings->message_duration = tmp_int16;
- l++;
-
- ptp_unicast_settings.delay_request_interval = atoi( cp+l );
- printf( " setting DelayReq Int: %i\n", ptp_unicast_settings.delay_request_interval );
- }
+#if 0 //##++++++++++++
-
- // Message Duration
cp = strstr( arg, ptp_name_dur );
-
+
if ( cp != NULL )
- {
+ {
l = strlen( ptp_name_dur );
if ( *(cp+l) != ':' )
- goto fail; // parameter syntax error: name not followed by colon
+ goto fail; // parameter syntax error: name not followed by colon
l++;
-
+
ptp_unicast_settings.message_duration = atoi( cp+l );
printf( " setting message duration: %i seconds\n", ptp_unicast_settings.message_duration );
}
- }
-
- rc = mbg_set_ptp_cfg_settings( dh, &ptp_settings );
+#endif
+
+
+#if SIM_PTP_CFG
+ sim_ptp_cfg_info.settings = *p_settings;
+ rc = 0;
+#else
+ rc = mbg_set_ptp_cfg_settings( dh, p_settings );
+#endif
if ( mbg_ioctl_err( rc, "mbg_set_ptp_cfg_settings" ) )
return rc;
-
-
- if ( supports_unicast )
+
+
+#if 0 //##+++++++++
+ if ( unicast_supported )
{
+ #if SIM_PTP_CFG
+ #error test
+ rc = MBG_SUCCESS;
+ #else
rc = mbg_set_ptp_unicast_cfg_settings( dh, &ptp_unicast_settings );
-
+ #endif
if ( mbg_ioctl_err( rc, "mbg_set_ptp_unicast_cfg_settings" ) )
return rc;
}
+#endif
return MBG_SUCCESS;
-
-fail:
- printf("Syntax error in argument!\n");
+
+fail:
+ printf( "Syntax error in argument!\n" );
return MBG_ERR_CFG;
-
+
} // set_ptp_cfg
@@ -804,7 +1137,7 @@ static /*HDR*/
int ip4_check_parm( const char *s, IP4_INFO *p )
{
int l = strlen( p->name );
- const char *cp;
+ int n;
if ( strncmp( s, p->name, l ) != 0 )
return 0; // parameter does not match
@@ -814,12 +1147,12 @@ int ip4_check_parm( const char *s, IP4_INFO *p )
l++;
- cp = str_to_ip4_addr( p->addr, &s[l] );
+ n = str_to_ip4_addr( p->addr, &s[l] );
- if ( cp == NULL )
+ if ( n < 0 )
goto fail; // parameter syntax error: failed to convert numeric address
- return cp - s;
+ return n + l; //##++++++ needs to be verified
fail:
return MBG_ERR_CFG;
@@ -911,8 +1244,8 @@ done: // now check static configuration
{
char ws1[40];
char ws2[40];
- snprint_ip4_addr( ws1, sizeof( ws1 ), &ip4_settings.broad_addr );
- snprint_ip4_addr( ws2, sizeof( ws2 ), &default_broad_addr );
+ snprint_ip4_addr( ws1, sizeof( ws1 ), &ip4_settings.broad_addr, NULL );
+ snprint_ip4_addr( ws2, sizeof( ws2 ), &default_broad_addr, NULL );
printf( "*** Warning: Broadcast address %s does not match the default broadcast address %s\n",
ws1, ws2 );
}
@@ -979,7 +1312,7 @@ int set_gps_pos( MBG_DEV_HANDLE dh, const char *gp )
if ( mbg_ioctl_err( rc, "mbg_set_gps_pos_lla" ) )
return rc;
- printf( "The clock's receiver position has been set to lat=%+.4f, lon=%+.4f, alt=%.0fm\n",
+ printf( "The clock's receiver position has been set to lat=%+.4f, lon=%+.4f, alt=%.0fm\n",
new_pos_lla[LAT] * r2d, new_pos_lla[LON] * r2d, new_pos_lla[ALT] );
return rc;
@@ -1009,9 +1342,9 @@ int set_date_time( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev,
unsigned int sec100 = 0;
int rc;
- // Either a date string, a time string, or both
+ // Either a date string, a time string, or both
// may have been passed to this function.
- // If either of them is NULL read the current date/time
+ // If either of them is NULL read the current date/time
// as default values.
if ( sdate == NULL || stime == NULL )
{
@@ -1051,8 +1384,8 @@ int set_date_time( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev,
}
}
- // GPS and non-GPS cards require different API calls which use
- // different structures to set the on-board date and time,
+ // GPS and non-GPS cards require different API calls which use
+ // different structures to set the on-board date and time,
// so we have to distinguish.
if ( _pcps_is_gps( p_dev ) ) // is a GPS card
@@ -1152,11 +1485,11 @@ int set_date_time( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev,
static /*HDR*/
-void check_setup_receiver_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev,
+void check_setup_receiver_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev,
RECEIVER_INFO *p_ri )
{
- // Set up the RECEIVER_INFO structure only if this has not been done
- // before. Check the ticks_per_sec field to see if the structure
+ // Set up the RECEIVER_INFO structure only if this has not been done
+ // before. Check the ticks_per_sec field to see if the structure
// has already been set up or not.
if ( p_ri->ticks_per_sec == 0 )
mbg_setup_receiver_info( dh, p_dev, p_ri );
@@ -1173,10 +1506,10 @@ int check_get_receiver_port_cfg( MBG_DEV_HANDLE dh, RECEIVER_PORT_CFG *p_rpcfg,
check_setup_receiver_info( dh, p_dev, p_ri );
- // Set up the RECEIVER_PORT_CFG structure only if this has not been done
- // before. Check whether the number of ports is > 0 and the first port's
+ // Set up the RECEIVER_PORT_CFG structure only if this has not been done
+ // before. Check whether the number of ports is > 0 and the first port's
// baud rate is still 0 to see if the structure has already been set up.
- if ( ( p_ri->n_com_ports > 0 ) &&
+ if ( ( p_ri->n_com_ports > 0 ) &&
( p_rpcfg->pii[0].port_info.port_settings.parm.baud_rate == 0 ) )
{
rc = mbg_get_serial_settings( dh, p_dev, p_rpcfg, p_ri );
@@ -1191,7 +1524,7 @@ int check_get_receiver_port_cfg( MBG_DEV_HANDLE dh, RECEIVER_PORT_CFG *p_rpcfg,
static /*HDR*/
-int snprint_port_cfg( char *s, int sz, unsigned int port_num,
+int snprint_port_cfg( char *s, int sz, unsigned int port_num,
const RECEIVER_PORT_CFG *p_rpcfg )
{
const PORT_SETTINGS *p_ps = &p_rpcfg->pii[port_num].port_info.port_settings;
@@ -1227,7 +1560,7 @@ void show_serial_settings( MBG_DEV_HANDLE dh, const RECEIVER_PORT_CFG *p_rpcfg,
static /*HDR*/
-void print_port_info_errors( const char *port_name, unsigned int port_num,
+void print_port_info_errors( const char *port_name, unsigned int port_num,
int flags, const RECEIVER_PORT_CFG *p_rpcfg )
{
const char *msg_nsupp_drvr = "is not supported by the driver software";
@@ -1240,7 +1573,7 @@ void print_port_info_errors( const char *port_name, unsigned int port_num,
printf( "** Baud rate %lu %s.\n", (ulong) p_ps->parm.baud_rate, msg_nsupp_drvr );
else
if ( flags & MBG_PS_MSK_BAUD_RATE )
- printf( "** Baud rate %lu is not supported by %s%u.\n",
+ printf( "** Baud rate %lu is not supported by %s%u.\n",
(ulong) p_ps->parm.baud_rate, port_name, port_num );
@@ -1248,7 +1581,7 @@ void print_port_info_errors( const char *port_name, unsigned int port_num,
printf( "** Framing %s %s.\n", p_ps->parm.framing, msg_nsupp_drvr );
else
if ( flags & MBG_PS_MSK_FRAMING )
- printf( "** Framing %s is not supported by %s%u.\n",
+ printf( "** Framing %s is not supported by %s%u.\n",
p_ps->parm.framing, port_name, port_num );
@@ -1256,27 +1589,27 @@ void print_port_info_errors( const char *port_name, unsigned int port_num,
printf( "** Handshake mode %u %s.\n", p_ps->parm.handshake, msg_nsupp_drvr );
else
if ( flags & MBG_PS_MSK_HS )
- printf( "** Handshake mode %u is not supported by %s%u.\n",
+ printf( "** Handshake mode %u is not supported by %s%u.\n",
(unsigned int) p_ps->parm.handshake, port_name, port_num );
if ( flags & MBG_PS_MSK_STR_TYPE_OVR_DEV )
- printf( "** String type index %u exceeds number of string types supp. by device.\n",
+ printf( "** String type index %u exceeds number of string types supp. by device.\n",
p_ps->str_type );
else
if ( flags & MBG_PS_MSK_STR_TYPE )
- printf( "** String type \"%s\" is not supported by %s%u.\n",
+ printf( "** String type \"%s\" is not supported by %s%u.\n",
p_rpcfg->stii[p_ps->str_type].str_type_info.long_name,
port_name, port_num );
if ( flags & MBG_PS_MSK_STR_MODE_OVR_SW )
- printf( "** String mode index %u exceeds number of string modes supported by driver software (%u).\n",
+ printf( "** String mode index %u exceeds number of string modes supported by driver software (%u).\n",
p_ps->mode, N_STR_MODE );
else
if ( flags & MBG_PS_MSK_STR_MODE )
- printf( "** String mode \"%s\" is not supported by string type \"%s\" via %s%u .\n",
- mode_names[p_ps->mode],
+ printf( "** String mode \"%s\" is not supported by string type \"%s\" via %s%u .\n",
+ mode_names[p_ps->mode],
p_rpcfg->stii[p_ps->str_type].str_type_info.long_name,
port_name, port_num );
@@ -1628,7 +1961,7 @@ int show_time_scale( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info
if ( mbg_ioctl_err( rc, "mbg_get_time_scale_info" ) )
return rc;
- printf( "%s time scale index: %u (%s)", info, tsci.settings.scale,
+ printf( "%s time scale index: %u (%s)", info, tsci.settings.scale,
_get_time_scale_name( tsci.settings.scale ) );
printf( "\n" );
@@ -1829,27 +2162,28 @@ void usage( MBG_DEV_HANDLE dh, PCPS_DEV *p_dev, RECEIVER_INFO *p_ri,
" DM:P2P specifies peer-to-peer delay mechanism\n"
" DO:0 specifies PTP domain number [0..255]\n"
" HW:1 specifies if the \"v1 hardware compatibility flag\" shall be set ('1') or disabled ('0')\n"
- "\n"
+ " (this is usually not required)\n"
+ "\n"
);
-
-printf( " If the PTP device supports unicast mode then the following\n"
- " additional parameters can be set:\n"
- " PTP=ROLE:<rl>[,GMIP:<ip>][,GMID:<id>][,PID:<po>][,SR:<sr>][,AR:<ar>][,DR:<dr>][,DUR:<du>] set PTP unicast parameters\n"
+
+ printf( " If the PTP device supports unicast slave mode then the following parameters\n"
+ " can be specified to configure a unicast master to be queried:\n"
+ " PTP=ROLE:<rl>[,GMIP:<ip>][,GMID:<id>][,PID:<po>][,SMI:<sr>][,AMI:<ar>][,DMI:<dr>][,DUR:<du>] set PTP unicast parameters\n"
"\n"
- " where, e.g. :\n"
+ " where, e.g.:\n"
" ROLE:MCS specifies \"Multicast Slave\" PTP role\n"
" ROLE:UCS specifies \"Unicast Slave\" PTP role\n"
" GMIP:192.168.1.115 specifies the IP address of the grandmaster\n"
- " GMID:FF:FF:FF:FF:FF:FF:FF:FF specifies the Clock ID of the grandmaster or FF:FF:... as wildcard\n"
- " PID:1 specifies the target port id of the grandmaster port that shall be used or 65535 as wildcard\n"
- " SR:0 specifies the Sync message rate requested from the grandmaster in 2^x seconds [-6..6]\n"
- " AR:1 specifies the Announce message rate requested from the grandmaster in 2^x seconds [-6..6]\n"
- " DR:1 specifies the DelayRequest message rate requested from the grandmaster in 2^x seconds [-6..6]\n"
+ " GMID:FF:FF:FF:FF:FF:FF:FF:FF specifies the Clock ID of the grandmaster, or '*' as wildcard for all FF\n"
+ " PID:1 specifies the target port ID of the grandmaster port to be used, or '*' for wildcard\n"
+ " SMI:0 specifies the Sync message interval requested from the grandmaster in 2^x seconds [-6..6]\n"
+ " AMI:1 specifies the Announce message interval requested from the grandmaster in 2^x seconds [-6..6]\n"
+ " DMI:1 specifies the DelayRequest message interval requested from the grandmaster in 2^x seconds [-6..6]\n"
" DUR:300 specifies the duration in seconds how long the master shall send messages to the slave until a timeout or renewal occurs\n"
"\n"
);
-printf( " ANT_CABLE_LEN show the configured antenna cable length\n"
+ printf( " ANT_CABLE_LEN show the configured antenna cable length\n"
" ANT_CABLE_LEN=<len> set the antenna cable length to be compensated to <len>, in meters.\n"
"\n"
" Please note note this parameter is only supported with cards which provide\n"
@@ -1868,10 +2202,10 @@ printf( " ANT_CABLE_LEN show the configured antenna cable length\n"
static /*HDR*/
-const char *str_parm_p(const char *s, const char *keyword )
+const char *str_parm_p( const char *s, const char *keyword )
{
char *match = strstr( s, keyword );
-
+
if ( match && ( match == s ) )
return &s[strlen( keyword )];
else
@@ -2185,7 +2519,6 @@ int check_cmd_line( int argc, char *argv[], MBG_DEV_HANDLE dh, const PCPS_DEV *p
if ( *cp == '=' )
{
-
rc = set_ptp_cfg( dh, ++cp, p_dev );
if ( rc < 0 )
@@ -2195,7 +2528,6 @@ int check_cmd_line( int argc, char *argv[], MBG_DEV_HANDLE dh, const PCPS_DEV *p
}
info = "New";
-
}
show_ptp_cfg( dh, p_dev, info );
@@ -2203,7 +2535,7 @@ int check_cmd_line( int argc, char *argv[], MBG_DEV_HANDLE dh, const PCPS_DEV *p
continue;
}
- cp = str_parm_p( argv[i], "ANT_CABLE_LEN" );
+ cp = str_parm_p( argv[i], "ANT_CABLE_LEN" );
if ( cp )
{
@@ -2296,7 +2628,7 @@ int main( int argc, char *argv[] )
MBG_DEV_HANDLE dh = MBG_INVALID_DEV_HANDLE;
int rc;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// If no arguments have been given, just print usage.
if ( argc < 2 )
@@ -2307,12 +2639,16 @@ int main( int argc, char *argv[] )
check_cmd_line( argc, argv, dh, NULL, &ri, &rpcfg );
if ( dev_name )
- dh = open( dev_name, 0 ); // open specific device
+ dh = open( dev_name, O_RDWR ); // open specific device
else
dh = mbg_open_device( 0 ); // open first device found
if ( dh == MBG_INVALID_DEV_HANDLE )
{
+ //##++++++++++++++++++++++
+ if ( dev_name )
+ fprintf( stderr, "%s: ", dev_name );
+
perror( "Unable to open device" );
goto fail;
}
@@ -2326,6 +2662,10 @@ int main( int argc, char *argv[] )
pdev = &dev;
+ #if SIM_PTP_CFG
+ pdev->cfg.features |= PCPS_HAS_PTP;
+ #endif
+
rc = check_cmd_line( argc, argv, dh, pdev, &ri, &rpcfg );
if ( rc < 0 )
diff --git a/src/external/bsd/meinberg/dist/mbgfasttstamp/mbgfasttstamp.c b/src/external/bsd/meinberg/dist/mbgfasttstamp/mbgfasttstamp.c
index 35bad13..f9eefc2 100755
--- a/src/external/bsd/meinberg/dist/mbgfasttstamp/mbgfasttstamp.c
+++ b/src/external/bsd/meinberg/dist/mbgfasttstamp/mbgfasttstamp.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgfasttstamp.c 1.6.1.3 2011/01/28 12:04:07 martin TEST $
+ * $Id: mbgfasttstamp.c 1.6.1.3.1.3 2011/07/05 15:35:54 martin TRASH martin $
*
* Description:
* Main file for mbgfasttstamp program which demonstrates how to access
@@ -9,6 +9,12 @@
*
* -----------------------------------------------------------------------
* $Log: mbgfasttstamp.c $
+ * Revision 1.6.1.3.1.3 2011/07/05 15:35:54 martin
+ * Modified version handling.
+ * Revision 1.6.1.3.1.2 2011/07/05 14:35:17 martin
+ * New way to maintain version information.
+ * Revision 1.6.1.3.1.1 2011/05/13 18:52:12 martin
+ * Started to support signal handler to catch CTRL-C.
* Revision 1.6.1.3 2011/01/28 12:04:07 martin
* Revision 1.6.1.2 2011/01/28 11:51:13 martin
* Revision 1.6.1.1 2011/01/28 11:17:00 martin
@@ -46,9 +52,11 @@
#include <unistd.h>
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2007
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbgfasttstamp";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2007-2009";
#define MAX_TS_BURST 1000
@@ -56,6 +64,20 @@ static const char *pcopyright = "(c) Meinberg 2007-2009";
static int loops;
static int burst_read;
static int read_raw;
+static int exit_requested;
+
+
+
+static /*HDR*/
+void sighandler( int sig )
+{
+ #if defined( DEBUG )
+ printf( "Caught signal %i, exiting.\n", sig );
+ #endif
+
+ exit_requested = 1;
+
+} // sighandler
@@ -207,7 +229,7 @@ int main( int argc, char *argv[] )
int rc;
int c;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "bcn:rh?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbggpscap/mbggpscap.c b/src/external/bsd/meinberg/dist/mbggpscap/mbggpscap.c
index bfa8804..a440f87 100755
--- a/src/external/bsd/meinberg/dist/mbggpscap/mbggpscap.c
+++ b/src/external/bsd/meinberg/dist/mbggpscap/mbggpscap.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbggpscap.c 1.10.1.2 2010/11/12 12:27:17 martin TEST $
+ * $Id: mbggpscap.c 1.10.1.4 2011/07/05 15:35:54 martin TRASH martin $
*
* Description:
* Main file for mbggpscap program which demonstrates how to access
@@ -13,6 +13,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbggpscap.c $
+ * Revision 1.10.1.4 2011/07/05 15:35:54 martin
+ * Modified version handling.
+ * Revision 1.10.1.3 2011/07/05 14:35:18 martin
+ * New way to maintain version information.
* Revision 1.10.1.2 2010/11/12 12:27:17 martin
* Improved reading capture events arriving at a high rate.
* Support validation of capture signals arriving at a constant rate.
@@ -61,9 +65,12 @@
#define USLEEP_INTV 10000 // [microseconds]
+
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbggpscap";
-static const char *pversion = "v3.4.1";
-static const char *pcopyright = "(c) Meinberg 2001-2010";
static int continuous;
@@ -348,7 +355,7 @@ int main( int argc, char *argv[] )
int rc;
int c;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "ci:j:h?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbghrtime/mbghrtime.c b/src/external/bsd/meinberg/dist/mbghrtime/mbghrtime.c
index 86214a2..c209612 100755
--- a/src/external/bsd/meinberg/dist/mbghrtime/mbghrtime.c
+++ b/src/external/bsd/meinberg/dist/mbghrtime/mbghrtime.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbghrtime.c 1.11.1.4 2011/01/28 12:04:08 martin TEST $
+ * $Id: mbghrtime.c 1.11.1.6 2011/07/05 15:35:54 martin TRASH martin $
*
* Description:
* Main file for mbghrtime program which demonstrates how to access
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbghrtime.c $
+ * Revision 1.11.1.6 2011/07/05 15:35:54 martin
+ * Modified version handling.
+ * Revision 1.11.1.5 2011/07/05 14:35:18 martin
+ * New way to maintain version information.
* Revision 1.11.1.4 2011/01/28 12:04:08 martin
* Revision 1.11.1.3 2011/01/28 11:52:51 martin
* Revision 1.11.1.2 2011/01/28 11:51:13 martin
@@ -61,9 +65,11 @@
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbghrtime";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2001-2009";
#define MAX_TS_BURST 1000
@@ -226,7 +232,7 @@ int main( int argc, char *argv[] )
int rc;
int c;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "bcn:rh?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbgirigcfg/mbgirigcfg.c b/src/external/bsd/meinberg/dist/mbgirigcfg/mbgirigcfg.c
index 95f6238..f09d5db 100755
--- a/src/external/bsd/meinberg/dist/mbgirigcfg/mbgirigcfg.c
+++ b/src/external/bsd/meinberg/dist/mbgirigcfg/mbgirigcfg.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgirigcfg.c 1.10.1.4 2011/02/02 12:28:44 martin TEST $
+ * $Id: mbgirigcfg.c 1.10.1.11 2011/07/07 15:08:35 martin TRASH $
*
* Description:
* Main file for the mbgirigcfg program which can be used to configure
@@ -10,6 +10,19 @@
*
* -----------------------------------------------------------------------
* $Log: mbgirigcfg.c $
+ * Revision 1.10.1.11 2011/07/07 15:08:35 martin
+ * Removed obsolete code.
+ * Revision 1.10.1.10 2011/07/06 14:53:50 martin
+ * Revision 1.10.1.9 2011/07/05 15:35:54 martin
+ * Modified version handling.
+ * Revision 1.10.1.8 2011/07/05 14:35:18 martin
+ * New way to maintain version information.
+ * Revision 1.10.1.7 2011/07/05 12:24:58 martin
+ * Revision 1.10.1.6 2011/07/04 10:30:29 martin
+ * Use getopt() for option processing.
+ * Support multiple devices.
+ * Revision 1.10.1.5 2011/07/01 13:49:47 martin
+ * bug fixes.
* Revision 1.10.1.4 2011/02/02 12:28:44 martin
* Revision 1.10.1.3 2010/08/30 08:22:24 martin
* Revision 1.10.1.2 2010/08/19 13:57:42 martin
@@ -60,11 +73,18 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <unistd.h>
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2003
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char pname[] = "mbgirigcfg";
-static const char pversion[] = "v3.4.0";
-static const char pcopyright[] = "(c) Meinberg 2003-2009";
+
+
+static int glb_argc;
+static char **glb_argv;
static const char str_yes[] = "YES";
static const char str_no[] = "NO";
@@ -80,9 +100,14 @@ static IRIG_INFO irig_tx_info;
static MBG_REF_OFFS ref_offs;
static MBG_OPT_INFO opt_info;
-static int cfg_err;
+static int cfg_err_rx;
+static int cfg_err_tx;
static int changed_cfg_rx;
static int changed_cfg_tx;
+static int warned_no_rx;
+static int warned_no_tx;
+
+static int must_print_help_info;
static const char *icode_rx_names[N_ICODE_RX] = DEFAULT_ICODE_RX_NAMES;
static const char *icode_rx_descr[N_ICODE_RX] = DEFAULT_ICODE_RX_DESCRIPTIONS_ENG;
@@ -94,7 +119,7 @@ static int max_ref_offs_h = MBG_REF_OFFS_MAX / MINS_PER_HOUR;
static /*HDR*/
-int get_cfg( MBG_DEV_HANDLE dh, PCPS_DEV *pdev )
+int get_cfg( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev )
{
int rc_rx = MBG_SUCCESS;
int rc_tx = MBG_SUCCESS;
@@ -132,7 +157,7 @@ int get_cfg( MBG_DEV_HANDLE dh, PCPS_DEV *pdev )
static /*HDR*/
-int save_cfg( MBG_DEV_HANDLE dh, PCPS_DEV *pdev )
+int save_cfg( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev )
{
int rc_rx = MBG_SUCCESS;
int rc_tx = MBG_SUCCESS;
@@ -174,7 +199,7 @@ void print_cfg_rx( const char *info, const char *msg )
int idx = irig_rx_info.settings.icode;
int ref_offs_h = ref_offs / MINS_PER_HOUR;
- printf( "%s %s:\n", info, msg );
+ printf( "%s %s configuration:\n", info, msg );
printf( " " DEFAULT_STR_IRIG_FMT_EN ": %s, %s\n",
icode_rx_names[idx],
@@ -206,7 +231,7 @@ void print_cfg_tx( const char *info, const char *msg )
{
int idx = irig_tx_info.settings.icode;
- printf( "%s %s:\n", info, msg );
+ printf( "%s %s configuration:\n", info, msg );
printf( " " DEFAULT_STR_IRIG_FMT_EN ": %s, %s\n",
icode_tx_names[idx],
@@ -227,15 +252,6 @@ void print_cfg_tx( const char *info, const char *msg )
static /*HDR*/
-void err_msg( PCPS_DEV *pdev, const char *msg )
-{
- printf( "The clock device %s %s.\n", _pcps_type_name( pdev ), msg );
-
-} // err_msg
-
-
-
-static /*HDR*/
void set_new_icode_rx( char *s )
{
int idx = atoi( s );
@@ -244,7 +260,7 @@ void set_new_icode_rx( char *s )
{
printf( "** IRIG RX code index %i is out of range (0..%i).\n",
idx, N_ICODE_RX - 1 );
- cfg_err = 1;
+ cfg_err_rx = 1;
return;
}
@@ -257,7 +273,7 @@ void set_new_icode_rx( char *s )
{
printf( "** IRIG RX code \"%s\" not supported by this device.\n",
icode_rx_names[idx] );
- cfg_err = 1;
+ cfg_err_rx = 1;
}
} // set_new_icode_rx
@@ -275,7 +291,7 @@ void set_new_ref_offs( char *s )
{
printf( "** New IRIG time offset %ih exceeds range (%+ih..%+ih).\n",
new_ref_offs_h, -max_ref_offs_h, max_ref_offs_h );
- cfg_err = 1;
+ cfg_err_rx = 1;
}
else
{
@@ -307,7 +323,7 @@ void set_new_str_utc( char *s )
this_cfg_err = 1;
if ( this_cfg_err )
- cfg_err = 1;
+ cfg_err_rx = 1;
else
changed_cfg_rx = 1;
@@ -324,7 +340,7 @@ void set_new_icode_tx( char *s )
{
printf( "** IRIG TX code index %i is out of range (0..%i).\n",
idx, N_ICODE_TX - 1 );
- cfg_err = 1;
+ cfg_err_tx = 1;
return;
}
@@ -337,7 +353,7 @@ void set_new_icode_tx( char *s )
{
printf( "** IRIG TX code \"%s\" not supported by this device.\n",
icode_tx_names[idx] );
- cfg_err = 1;
+ cfg_err_tx = 1;
}
} // set_new_icode_tx
@@ -358,7 +374,7 @@ void set_new_irig_tx_local( char *s )
this_cfg_err = 1;
if ( this_cfg_err )
- cfg_err = 1;
+ cfg_err_tx = 1;
else
changed_cfg_tx = 1;
@@ -367,7 +383,7 @@ void set_new_irig_tx_local( char *s )
static /*HDR*/
-void set_new_tfom_flag( char *s, IRIG_SETTINGS *p, int *changed_flag )
+void set_new_tfom_flag( char *s, IRIG_SETTINGS *p, int *changed_flag, int *err_flag )
{
if ( !(_idx_bit( p->icode ) & MSK_ICODE_TX_HAS_TFOM ) )
return; // not supported
@@ -379,7 +395,10 @@ void set_new_tfom_flag( char *s, IRIG_SETTINGS *p, int *changed_flag )
if ( strcmp( s, "0" ) == 0 )
p->flags &= ~IFLAGS_DISABLE_TFOM;
else
- cfg_err = 1;
+ {
+ *err_flag = 1;
+ return;
+ }
*changed_flag = 1;
@@ -390,14 +409,21 @@ void set_new_tfom_flag( char *s, IRIG_SETTINGS *p, int *changed_flag )
static /*HDR*/
int chk_dev_rx( const PCPS_DEV *pdev )
{
- if ( !_pcps_is_irig_rx( pdev ) )
+ if ( pdev )
{
- printf( "** This device is no IRIG receiver.\n" );
- cfg_err = 1;
- return 0;
+ if ( _pcps_is_irig_rx( pdev ) )
+ return 1;
+
+ if ( !warned_no_rx )
+ {
+ printf( "** This device does not provide an IRIG input.\n" );
+ warned_no_rx = 1;
+ }
+
+ cfg_err_rx = 1;
}
- return 1;
+ return 0;
} // chk_dev_rx
@@ -406,14 +432,21 @@ int chk_dev_rx( const PCPS_DEV *pdev )
static /*HDR*/
int chk_dev_tx( const PCPS_DEV *pdev )
{
- if ( !_pcps_has_irig_tx( pdev ) )
+ if ( pdev )
{
- printf( "** This device has no IRIG transmitter.\n" );
- cfg_err = 1;
- return 0;
+ if ( _pcps_has_irig_tx( pdev ) )
+ return 1;
+
+ if ( !warned_no_tx )
+ {
+ printf( "** This device does not provide an IRIG output.\n" );
+ warned_no_tx = 1;
+ }
+
+ cfg_err_tx = 1;
}
- return 1;
+ return 0;
} // chk_dev_tx
@@ -422,90 +455,62 @@ int chk_dev_tx( const PCPS_DEV *pdev )
static /*HDR*/
void check_cmd_line( int argc, char *argv[], const PCPS_DEV *pdev )
{
- int i;
+ int c;
- for ( i = 1; i < argc; i++ )
+ // force checking all parameters since this may be called several times
+ optind = 1;
+
+ while ( ( c = getopt( argc, argv, "h?" "r:o:u:i:" "t:l:s:" ) ) != -1 )
{
- if ( strcmp( argv[i], "-?" ) == 0 )
+ switch ( c )
{
- must_print_usage = 1;
- continue;
- }
+ case '?':
+ case 'h':
+ must_print_usage = 1;
+ break;
- if ( strcmp( argv[i], "-h" ) == 0 )
- {
- must_print_usage = 1;
- continue;
- }
- if ( strcmp( argv[i], "--help" ) == 0 )
- {
- must_print_usage = 1;
- continue;
- }
+ // IRIG receiver options
- if ( strcmp( argv[i], "-r" ) == 0 ) // IRIG RX code frame
- {
- if ( ++i < argc )
+ case 'r': // IRIG RX code frame
if ( chk_dev_rx( pdev ) )
- set_new_icode_rx( argv[i] );
-
- continue;
- }
+ set_new_icode_rx( optarg );
+ break;
- if ( strcmp( argv[i], "-o" ) == 0 ) // IRIG time offset from UTC
- {
- if ( ++i < argc )
+ case 'o': // incoming time offset from UTC
if ( chk_dev_rx( pdev ) )
- set_new_ref_offs( argv[i] );
+ set_new_ref_offs( optarg );
+ break;
- continue;
- }
-
- if ( strcmp( argv[i], "-u" ) == 0 ) // Option flag: serial output always UTC
- {
- if ( ++i < argc )
+ case 'u': // option flag: serial output is always UTC
if ( chk_dev_rx( pdev ) )
- set_new_str_utc( argv[i] );
+ set_new_str_utc( optarg );
+ break;
- continue;
- }
+ case 'i': // option flag: ignore incoming TFOM flag, alway sync
+ if ( chk_dev_rx( pdev ) )
+ set_new_tfom_flag( optarg, &irig_rx_info.settings, &changed_cfg_rx, &cfg_err_rx );
+ break;
- if ( strcmp( argv[i], "-t" ) == 0 ) // IRIG TX code frame
- {
- if ( ++i < argc )
- if ( chk_dev_tx( pdev ) )
- set_new_icode_tx( argv[i] );
- continue;
- }
+ // IRIG output options
- if ( strcmp( argv[i], "-l" ) == 0 ) // Option flag: transmit local time, not UTC
- {
- if ( ++i < argc )
+ case 't': // IRIG TX code frame
if ( chk_dev_tx( pdev ) )
- set_new_irig_tx_local( argv[i] );
-
- continue;
- }
+ set_new_icode_tx( optarg );
+ break;
- if ( strcmp( argv[i], "-s" ) == 0 ) // Option flag: send TFOM as always "sync"
- {
- if ( ++i < argc )
+ case 'l': // option flag: transmit local time, not UTC
if ( chk_dev_tx( pdev ) )
- set_new_tfom_flag( argv[i], &irig_tx_info.settings, &changed_cfg_tx );
+ set_new_irig_tx_local( optarg );
+ break;
- continue;
- }
+ case 's': // option flag: send TFOM as always "sync"
+ if ( chk_dev_tx( pdev ) )
+ set_new_tfom_flag( optarg, &irig_tx_info.settings, &changed_cfg_tx, &cfg_err_tx );
+ break;
- if ( strcmp( argv[i], "-i" ) == 0 ) // Option flag: ignore incoming TFOM flag, alway sync
- {
- if ( ++i < argc )
- if ( chk_dev_rx( pdev ) )
- set_new_tfom_flag( argv[i], &irig_rx_info.settings, &changed_cfg_rx );
-
- continue;
- }
+ } // switch
}
@@ -526,7 +531,7 @@ void usage( void )
);
printf(
- " -h or --help prints this info\n"
+ " -h or -? prints this info\n"
"\n"
);
@@ -562,6 +567,13 @@ void usage( void )
"\n"
);
+ printf(
+ " -i flag If \"flag\" is set to \"1\" then the TFOM qualifier in the\n"
+ " incoming IRIG signal is ignored, i.e. the receiver even synchronizes\n"
+ " to an input signal if the TFOM codes says the generator is freewheeling.\n"
+ " Please note that most IRIG codes do not support a TFOM qualifier.\n"
+ "\n"
+ );
printf(
"Options supported by IRIG transmitters:\n"
@@ -604,65 +616,23 @@ void usage( void )
static /*HDR*/
-void help_info( void )
-{
- printf( "\nFor help type \"%s -h\"\n", pname );
-
-} // help_info
-
-
-
-static /*HDR*/
int do_mbgirigcfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev )
{
- const char *no_irig = "is not an IRIG code receiver";
- PCPS_DEV dev = { { 0 } };
- int exit_code = 0;
- int rc = 0;
-
- {
- // if success, read the current IRIG configuration
- if ( rc == MBG_SUCCESS )
- rc = get_cfg( dh, &dev );
- }
-
-
-// check_cmd_line( argc, argv, &dev );
-
-
- if ( cfg_err )
- {
- help_info();
- exit_code = 1;
- goto done;
- }
-
-
- // At this point we shall either report or modify the current
- // configuration. If there has been an error accessing the
- // device, or the device is not an IRIG receiver, then we must
- // print a message.
+ int rc;
- if ( dh == MBG_INVALID_DEV_HANDLE )
- {
- printf( "** Error opening the device.\n" );
- exit_code = 3;
- goto done;
- }
+ cfg_err_rx = 0;
+ cfg_err_tx = 0;
+ changed_cfg_rx = 0;
+ changed_cfg_tx = 0;
+ warned_no_rx = 0;
+ warned_no_tx = 0;
- if ( rc != MBG_SUCCESS )
- {
- exit_code = 3;
- goto done;
- }
+ rc = get_cfg( dh, p_dev );
- if ( !_pcps_has_irig( &dev ) )
- {
- err_msg( &dev, no_irig );
- exit_code = 2;
- goto done;
- }
+ check_cmd_line( glb_argc, glb_argv, p_dev );
+ if ( cfg_err_rx || cfg_err_tx )
+ must_print_help_info = 1;
if ( changed_cfg_rx || changed_cfg_tx )
{
@@ -673,29 +643,24 @@ int do_mbgirigcfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev )
if ( changed_cfg_tx )
print_cfg_tx( info_new, msg_tx );
- rc = save_cfg( dh, &dev );
+ rc = save_cfg( dh, p_dev );
if ( mbg_ioctl_err( rc, "save IRIG configuration" ) )
- exit_code = 3;
+ goto done;
}
else
{
- if ( _pcps_is_irig_rx( &dev ) )
+ if ( _pcps_is_irig_rx( p_dev ) )
print_cfg_rx( info_curr, msg_rx );
- if ( _pcps_has_irig_tx( &dev ) )
+ if ( _pcps_has_irig_tx( p_dev ) )
print_cfg_tx( info_curr, msg_tx );
- help_info();
+ must_print_help_info = 1;
}
done:
- printf( "\n" );
-
- if ( dh != MBG_INVALID_DEV_HANDLE )
- mbg_close_device( &dh );
-
- return exit_code;
+ return rc;
} // do_mbgirigcfg
@@ -705,7 +670,7 @@ int main( int argc, char *argv[] )
{
int rc;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
check_cmd_line( argc, argv, NULL );
@@ -716,13 +681,19 @@ int main( int argc, char *argv[] )
}
+ glb_argc = argc;
+ glb_argv = argv;
+
+
// The function below checks which devices have been specified
// on the command, and for each device
// - tries to open the device
// - shows basic device info
// - calls the function passed as last parameter
- //##+++++++++++ rc = mbg_check_devices( argc, argv, optind, do_mbgirigcfg );
- rc = mbg_check_devices( argc, argv, 0, do_mbgirigcfg );
+ rc = mbg_check_devices( glb_argc, glb_argv, optind, do_mbgirigcfg );
+
+ if ( must_print_help_info )
+ printf( "For help type \"%s -h\"\n\n", pname );
return abs( rc );
}
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/ctry.h b/src/external/bsd/meinberg/dist/mbglib/common/ctry.h
index 9c39a28..08d1238 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/ctry.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/ctry.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: ctry.h 1.11 2010/07/15 08:33:41 martin REL_M $
+ * $Id: ctry.h 1.12 2011/06/22 07:37:57 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: ctry.h $
+ * Revision 1.12 2011/06/22 07:37:57 martin
+ * Cleaned up handling of pragma pack().
* Revision 1.11 2010/07/15 08:33:41 martin
* Added some macros implemented by Stefan.
* Updated function prototypes.
@@ -76,8 +78,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -220,8 +223,9 @@ extern CTRY ctry;
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/gpsdefs.h b/src/external/bsd/meinberg/dist/mbglib/common/gpsdefs.h
index 80a4e1d..b638657 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/gpsdefs.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/gpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.91.1.8 2011/02/23 15:11:23 martin TRASH $
+ * $Id: gpsdefs.h 1.91.1.24 2011/07/08 09:04:05 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -13,6 +13,43 @@
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
+ * Revision 1.91.1.24 2011/07/08 09:04:05 martin
+ * Renamed some PTP stuff.
+ * Added some definitions for PTP.
+ * Revision 1.91.1.23 2011/06/29 10:49:47 martin
+ * Updated some comments.
+ * Revision 1.91.1.22 2011/06/29 09:07:50 martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Added MGR180, MSF600, WWVB600, and JJY600.
+ * Revision 1.91.1.21 2011/06/22 08:23:58 andre
+ * Revision 1.91.1.20 2011/06/21 14:11:31Z martin
+ * Support PTP unicast configuration.
+ * Support GPIO configuration.
+ * Support PZF600PEX.
+ * Cleaned up handling of pragma pack().
+ * Fixed a typo.
+ * Revision 1.91.1.19 2011/04/18 13:43:57 martin
+ * Doxygen changes.
+ * Revision 1.91.1.18 2011/04/18 13:00:33 martin
+ * Merged some modified comments from an older branch.
+ * Revision 1.91.1.17 2011/04/13 15:34:07 martin
+ * Added lots of comments in doxygen style.
+ * Revision 1.91.1.16 2011/04/11 09:15:00 andre
+ * Revision 1.91.1.15 2011/04/08 08:29:18Z andre
+ * Revision 1.91.1.14 2011/04/08 08:10:31Z martin
+ * Renamed .._INST_.. to .._INSTC_..
+ * Moved flags XMRS_..._IS_EXTERNAL and XMRS_..._INSTC_EXCEEDED
+ * to definitions for XMULTI_REF_STATUS::status.
+ * Revision 1.91.1.13 2011/04/07 15:50:16 martin
+ * Introduced XMULTI_REF_INSTANCES:
+ * Converted some comments to Doxygen style.
+ * Revision 1.91.1.12 2011/04/07 13:52:04 martin
+ * Revision 1.91.1.11 2011/04/07 13:23:41 martin
+ * Started to add GPIO support and configuration stuff.
+ * Revision 1.91.1.10 2011/04/07 10:38:43 martin
+ * Modified default string for PTP layer 2 protocol.
+ * Revision 1.91.1.9 2011/04/07 10:29:36 martin
+ * Added initializers for PTP timescale names.
* Revision 1.91.1.8 2011/02/23 15:11:23 martin
* New PTP_STATE flags bit PTP_FLAG_MSK_IS_UNICAST.
* Revision 1.91.1.7 2011/02/23 15:05:54 martin
@@ -342,12 +379,13 @@
#endif
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
-#endif
+/* Start of header body */
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
-/* Start of header body */
/* "magic" number */
#define MEINBERG_MAGIC 0x6AAC
@@ -426,7 +464,7 @@ typedef struct
/**
- * @defgroup bvar_stat BVAR_STAT status of buffered GPS data
+ * @defgroup group_bvar_stat BVAR_STAT status of buffered GPS data
*
* Status word, associated bit numbers and bit masks indicating
* whether certain data from the GPS satellites are
@@ -460,15 +498,15 @@ enum
N_BVAR_BIT /**< @brief number of defined ::BVAR_STAT bits */
};
-#define BVAR_CFGH_INVALID ( 1UL << BVAR_BIT_CFGH_INVALID ) /**< @brief ::CFGH not valid*/
-#define BVAR_ALM_NOT_COMPLETE ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ) /**< @brief ::ALM not complete */
+#define BVAR_CFGH_INVALID ( 1UL << BVAR_BIT_CFGH_INVALID ) /**< @brief Configuration and health data (::CFGH) not valid */
+#define BVAR_ALM_NOT_COMPLETE ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ) /**< @brief Almanach data (::ALM) not complete */
#define BVAR_UTC_INVALID ( 1UL << BVAR_BIT_UTC_INVALID ) /**< @brief UTC data not valid */
-#define BVAR_IONO_INVALID ( 1UL << BVAR_BIT_IONO_INVALID ) /**< @brief IONO data not valid */
-#define BVAR_RCVR_POS_INVALID ( 1UL << BVAR_BIT_RCVR_POS_INVALID ) /**< @brief ::POS not valid */
+#define BVAR_IONO_INVALID ( 1UL << BVAR_BIT_IONO_INVALID ) /**< @brief Ionospheric correction data (::IONO) not valid */
+#define BVAR_RCVR_POS_INVALID ( 1UL << BVAR_BIT_RCVR_POS_INVALID ) /**< @brief Receiver position (::POS) not valid */
#define BVAR_MASK ( ( 1UL << N_BVAR_BIT ) - 1 ) /**< @brief Bit mask for all defined bits */
-/** @} */
+/** @} group_bvar_stat */
@@ -574,6 +612,11 @@ enum
GPS_MODEL_GLN170,
GPS_MODEL_GPS180PEX,
GPS_MODEL_TCR180PEX,
+ GPS_MODEL_PZF180PEX,
+ GPS_MODEL_MGR180,
+ GPS_MODEL_MSF600,
+ GPS_MODEL_WWVB600,
+ GPS_MODEL_JJY600,
N_GPS_MODEL
/* If new model codes are added then care must be taken
* to update the associated string initializers below
@@ -622,6 +665,11 @@ enum
#define GPS_MODEL_NAME_GLN170 "GLN170"
#define GPS_MODEL_NAME_GPS180PEX "GPS180PEX"
#define GPS_MODEL_NAME_TCR180PEX "TCR180PEX"
+#define GPS_MODEL_NAME_PZF180PEX "PZF180PEX"
+#define GPS_MODEL_NAME_MGR180 "MGR180"
+#define GPS_MODEL_NAME_MSF600 "MSF600"
+#define GPS_MODEL_NAME_WWVB600 "WWVB600"
+#define GPS_MODEL_NAME_JJY600 "JJY600"
/*
@@ -665,7 +713,12 @@ enum
GPS_MODEL_NAME_GPS180, \
GPS_MODEL_NAME_GLN170, \
GPS_MODEL_NAME_GPS180PEX, \
- GPS_MODEL_NAME_TCR180PEX \
+ GPS_MODEL_NAME_TCR180PEX, \
+ GPS_MODEL_NAME_PZF180PEX, \
+ GPS_MODEL_NAME_MGR180, \
+ GPS_MODEL_NAME_MSF600, \
+ GPS_MODEL_NAME_WWVB600, \
+ GPS_MODEL_NAME_JJY600 \
}
@@ -843,6 +896,7 @@ enum
GPS_FEAT_RAW_IRIG_DATA, /**< supports reading raw IRIG input data */
GPS_FEAT_RAW_IRIG_TIME, /**< supports reading decoded IRIG time */
GPS_FEAT_PTP_UNICAST, /**< has PTP Unicast support */
+ GPS_FEAT_GPIO, /**< has general purpose in/outputs */
N_GPS_FEATURE /**< the number of valid features */
};
@@ -868,7 +922,8 @@ enum
"Nav. Engine Settings", \
"Raw IRIG Data", \
"Raw IRIG Time", \
- "PTP/IEEE1588 Unicast" \
+ "PTP/IEEE1588 Unicast", \
+ "General Purpose I/O" \
}
@@ -896,6 +951,7 @@ enum
#define GPS_HAS_RAW_IRIG_DATA ( 1UL << GPS_FEAT_RAW_IRIG_DATA )
#define GPS_HAS_RAW_IRIG_TIME ( 1UL << GPS_FEAT_RAW_IRIG_TIME )
#define GPS_HAS_PTP_UNICAST ( 1UL << GPS_FEAT_PTP_UNICAST )
+#define GPS_HAS_GPIO ( 1UL << GPS_FEAT_GPIO )
#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
@@ -1089,7 +1145,7 @@ enum
#define TM_MSK_TIME_VALID ( TM_UTC | TM_SCALE_GPS | TM_SCALE_TAI )
/**
- This structure is used to transmit information on date and time
+ * @brief A structure used to transmit information on date and time
*/
typedef struct
{
@@ -1135,7 +1191,7 @@ typedef struct
/* sequence and number of components of a cartesian position */
enum { XP, YP, ZP, N_XYZ };
- /** a type of array holding a cartesian position */
+ /** @brief An array holding a cartesian position */
typedef double XYZ[N_XYZ]; /**< values are in [m] */
#define _XYZ_DEFINED
@@ -1148,7 +1204,7 @@ typedef struct
/* sequence and number of components of a geographic position */
enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
- /** a type of array holding a geographic position */
+ /** @brief An array holding a geographic position */
typedef double LLA[N_LLA]; /**< lon, lat in [rad], alt in [m] */
#define _LLA_DEFINED
@@ -1158,7 +1214,7 @@ typedef struct
/**
- @defgroup group_synth Synthesizer parameters
+ @defgroup group_synth Synthesizer parameters
Synthesizer frequency is expressed as a
four digit decimal number (freq) to be multiplied by 0.1 Hz and an
@@ -1201,13 +1257,11 @@ typedef struct
#define MAX_SYNTH_FREQ_EDIT 9999 /**< max sequence of digits when editing */
-/** The maximum frequency that can be configured for the synthesizer */
+/** @brief The maximum frequency that can be configured for the synthesizer */
#define MAX_SYNTH_FREQ_VAL 10000000UL /**< 10 MHz */
/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */
-/**
- The synthesizer phase will only be synchronized if the frequency
- is below this limit: */
+/** @brief The synthesizer's phase is only be synchronized if the frequency is below this limit */
#define SYNTH_PHASE_SYNC_LIMIT 10000UL /**< 10 kHz */
/**
@@ -1270,7 +1324,7 @@ typedef struct
#define SYNTH_FLAG_PHASE_IGNORED 0x01
-/** @} */ // endgroup
+/** @} group_synth */
/**
@defgroup group_tzdl Time zone/daylight saving parameters
@@ -1426,7 +1480,7 @@ typedef struct
DEFAULT_TZDL_NAMES_EET_EEST_DE /* name[] */ \
}
-/** @} */ // endgroup
+/** @} group_tzdl */
/**
* The structure below reflects the status of the antenna,
@@ -1580,7 +1634,7 @@ enum
/*
* The bit masks below can be used to determine which baud rates
* are supported by a serial port. This may vary between
- * different ports of the same radio clock since different
+ * different ports of the same device since different
* types of UART are used which must not necessarily support
* each baud rate:
*/
@@ -1633,7 +1687,7 @@ enum
/*
* The bit masks below can be used to determine which framings
* are supported by a serial port. This may vary between
- * different ports of the same radio clock since different
+ * different ports of the same device since different
* types of UART are used which must not necessarily support
* each framing type:
*/
@@ -2000,7 +2054,7 @@ enum
/**
- @defgroup group_icode IRIG Codes
+ @defgroup group_icode IRIG codes
The following definitions are used to configure an optional
on-board IRIG input or output. Which frame types are supported
@@ -2049,19 +2103,19 @@ enum
AFNOR codes are based on the french standard AFNOR NF S87-500
IEEE1344 codes are defined in IEEE standard 1344-1995. The code frame is compatible
- with B002/B122 but provides some welldefined extensions in the control field which
+ with B002/B122 but provides some well defined extensions in the control field which
include a quality indicator (time figure of merit, TFOM), year number, DST and leap
second status, and local time offset from UTC.
C37.118 codes are defined in IEEE standard C37.118-2005 which includes a revised version
- of the IEEE1344 standard from 1995. These codes provide the same extensions as IEEE1344
+ of the IEEE 1344 standard from 1995. These codes provide the same extensions as IEEE 1344
but unfortunately define the UTC offset with reversed sign.
- <b>ATTENTION:</b> There are 3rd party IRIG devices out there which apply the UTC offset
- as specified in C37.118, but claim to be compatible with IEEE1344. So if local time is
- transmitted in the IRIG signal then care must be taken that the UTC offset is evaluated
- by the IRIG receiver in the same way as output by the IRIG generator. Otherwise the UTC
- time computed by the receiver may be wrong.
+ @note There are 3rd party IRIG devices out there which apply the UTC offset as specified
+ in C37.118, but claim to be compatible with IEEE 1344. So if local time is transmitted
+ by the IRIG signal then care must be taken that the UTC offset is evaluated by the IRIG
+ receiver in the same way as computed by the IRIG generator. Otherwise the UTC
+ time computed by the receiver may be <b>wrong</b>.
@{
*/
@@ -2515,7 +2569,8 @@ enum
MSK_ICODE_RX_AFNOR_DC \
)
#endif
-/** @} */
+
+/** @} group_icode */
@@ -2537,10 +2592,10 @@ typedef struct
/**
- @defgroup group_irig_flags Bit Masks used with IRIG_SETTINGS::flags
-
- (others are reserved)
-* @{
+ * @defgroup group_irig_flags Bit Masks used with IRIG_SETTINGS::flags
+ *
+ * (others are reserved)
+ * @{
*/
#define IFLAGS_DISABLE_TFOM 0x0001 /**< RX ignore/TX don't gen TFOM */
#define IFLAGS_TX_GEN_LOCAL_TIME 0x0002 /**< gen local time, not UTC */
@@ -2553,7 +2608,7 @@ typedef struct
// this flag. See the comments near the declaration of the _pcps_incoming_tfom_ignored()
// macro in pcpsdev.h for details.
-/** @} */
+/** @} group_irig_flags */
/**
* @brief Current IRIG settings and supported codes
@@ -2735,7 +2790,7 @@ typedef struct
/**
- @defgroup group_scale Time Scale Configuration
+ @defgroup group_time_scale Time Scale Configuration
The structures and defines can be used to configure the GPS receiver's
basic time scale. By default this is UTC which can optionally
@@ -2801,7 +2856,7 @@ typedef struct
_mbg_swab32( &(_p)->supp_scales ); \
}
-/** @} */ // endgroup
+/** @} group_time_scale */
/*
@@ -2832,10 +2887,10 @@ typedef struct
*/
typedef struct
{
- uint8_t hour; /* 0..23 */
- uint8_t min; /* 0..59 */
- uint8_t sec; /* 0..59,60 */
- uint8_t sec100; /* reserved, currently always 0 */
+ uint8_t hour; /**< 0..23 */
+ uint8_t min; /**< 0..59 */
+ uint8_t sec; /**< 0..59,60 */
+ uint8_t sec100; /**< reserved, currently always 0 */
} MBG_TIME;
#define _mbg_swab_mbg_time( _p ) \
@@ -3132,23 +3187,24 @@ typedef struct
*/
-/*
- * All possibly supported ref time sources
+/**
+ * @brief All possibly supported ref time sources
*/
enum
{
- MULTI_REF_NONE = -1, // nothing, undefined
- MULTI_REF_GPS = 0, // standard GPS
- MULTI_REF_10MHZ, // 10 MHz input frequency
- MULTI_REF_PPS, // 1 PPS input signal
- MULTI_REF_10MHZ_PPS, // combined 10 MHz plus PPS
- MULTI_REF_IRIG, // IRIG input
- MULTI_REF_NTP, // Network Time Protocol (NTP)
- MULTI_REF_PTP, // Precision Time Protocol (PTP, IEEE1588)
- MULTI_REF_PTP_E1, // PTP over E1
- MULTI_REF_FREQ, // fixed frequency
- MULTI_REF_PPS_STRING, // 1 PPS in addition to string
- N_MULTI_REF // the number of defined sources
+ MULTI_REF_NONE = -1, /**< nothing, undefined */
+ MULTI_REF_GPS = 0, /**< standard GPS */
+ MULTI_REF_10MHZ, /**< 10 MHz input frequency */
+ MULTI_REF_PPS, /**< 1 PPS input signal */
+ MULTI_REF_10MHZ_PPS, /**< combined 10 MHz plus PPS */
+ MULTI_REF_IRIG, /**< IRIG input */
+ MULTI_REF_NTP, /**< Network Time Protocol (NTP) */
+ MULTI_REF_PTP, /**< Precision Time Protocol (PTP, IEEE1588) */
+ MULTI_REF_PTP_E1, /**< PTP over E1 */
+ MULTI_REF_FREQ, /**< fixed frequency */
+ MULTI_REF_PPS_STRING, /**< PPS in addition to string */
+ MULTI_REF_GPIO, /**< variable input signal via GPIO */
+ N_MULTI_REF /**< the number of defined sources, can not exceed bit number of uint32_t - 1 */
};
@@ -3166,7 +3222,8 @@ enum
"PTP (IEEE1588)", \
"PTP over E1", \
"Fixed Freq. in", \
- "PPS plus string" \
+ "PPS plus string", \
+ "Var. freq. via GPIO" \
}
@@ -3183,6 +3240,7 @@ enum
#define HAS_MULTI_REF_PTP_E1 ( 1UL << MULTI_REF_PTP_E1 )
#define HAS_MULTI_REF_FREQ ( 1UL << MULTI_REF_FREQ )
#define HAS_MULTI_REF_PPS_STRING ( 1UL << MULTI_REF_PPS_STRING )
+#define HAS_MULTI_REF_GPIO ( 1UL << MULTI_REF_GPIO )
/*
@@ -3268,41 +3326,55 @@ enum
-/*
+/**
+ * @defgroup group_xmr_cfg Extended multiref configuration stuff
+ *
* If the RECEIVER_INFO::features flag GPS_FEAT_XMULTI_REF is set
* then the following XMULTI_REF_... data structures must be used
- * instead of the older MULTI_REF_... structures above.
+ * instead of the older MULTI_REF_... structures.
*
* Those devices support a number of priority levels addressed by
* the priority index, starting at 0 for highest priority. A single
* reference time source from the set of supported sources can be
* assigned to each priority level.
*
- * The structures below are used to configure the individual
+ * These structures are used to configure the individual
* time source for each priority level, and retrieve the status
* of the time source at each priority level.
- */
+ *
+ * @{ */
+/**
+ * @brief Identifier for a reference source
+ */
typedef struct
{
- uint8_t type; /* 0..N_MULTI_REF-1 from the enum above */
- uint8_t instance; /* reserved, currently always 0 */
+ uint8_t type; /**< 0..N_MULTI_REF-1 from the enum above */
+ uint8_t instance; /**< instance number, if multiple instances are supported, else 0 */
+
} XMULTI_REF_ID;
+
+
+/**
+ * @brief Reference source configuration settings
+ */
typedef struct
{
- XMULTI_REF_ID id; /* time source identifier */
- uint16_t flags; /* reserved, currently always 0 */
- NANO_TIME bias; /* time bias, e.g. path delay */
- NANO_TIME precision; /* precision of the time source */
- uint32_t fine_limit; /* smooth control if below this limit */
+ XMULTI_REF_ID id; /**< time source identifier */
+ uint16_t flags; /**< reserved, currently always 0 */
+ NANO_TIME bias; /**< time bias, e.g. path delay */
+ NANO_TIME precision; /**< precision of the time source */
+ uint32_t fine_limit; /**< smooth control if below this limit */
+
} XMULTI_REF_SETTINGS;
-/*
- * The structure below is used to retrieve or configure the time source
- * for a specific priority level.
- * After configuring, a structure with idx == 0xFFFF (-1) must be sent
+
+/**
+ * @brief Reference source configuration settings for a specific priority level
+ *
+ * @note After configuring, a structure with idx == 0xFFFF (-1) must be sent
* to let the changes become effective.
*/
typedef struct
@@ -3313,79 +3385,100 @@ typedef struct
} XMULTI_REF_SETTINGS_IDX;
-/*
- * The structure below contains the XMULTI_REF configuration
- * for a single priority level, plus information on supported
- * ref time sources, and the number of supported priority levels.
+
+/**
+ * @brief Reference source configuration settings and capabilities
*/
typedef struct
{
- XMULTI_REF_SETTINGS settings; /* current settings */
- uint32_t supp_ref; /* supp. HAS_MULTI_REF_... codes or'ed */
- uint8_t n_supp_ref; /* number of supported ref time sources */
- uint8_t n_prio; /* number of supported priority levels */
- uint16_t flags; /* reserved, currently 0, e.g. multiple instance support */
+ XMULTI_REF_SETTINGS settings; /**< current settings */
+ uint32_t supp_ref; /**< bit mask of or'ed HAS_MULTI_REF_... codes */
+ uint8_t n_supp_ref; /**< number of supported ref time sources */
+ uint8_t n_prio; /**< number of supported priority levels */
+ uint16_t flags; /**< currently always 0 */
} XMULTI_REF_INFO;
-/*
- * The structure below is used to retrieve the XMULTI_REF configuration
- * information for a specific priority level.
+
+/**
+ * @brief Reference source configuration settings and capabilities for a specific priority level
*/
typedef struct
{
- uint16_t idx; /* the priority level index, highest == 0 */
- XMULTI_REF_INFO info;
+ uint16_t idx; /**< the priority level index, highest == 0 */
+ XMULTI_REF_INFO info; /**< ref source cfg and capabilities */
} XMULTI_REF_INFO_IDX;
-/*
- * The structure below contains status information on a single
- * ref time source.
+
+/**
+ * @brief Status information on a single ref time source
*/
typedef struct
{
- XMULTI_REF_ID id; /* time source identifier */
- uint16_t status; /* flag bits as defined below */
- NANO_TIME offset; /* time offset from main time base */
- uint32_t reserved; /* reserved, currently always 0 */
+ XMULTI_REF_ID id; /**< time source identifier */
+ uint16_t status; /**< flag bits as defined below */
+ NANO_TIME offset; /**< time offset from main time base */
+ uint32_t flags; /**< see flags specified below */
} XMULTI_REF_STATUS;
-/*
- * The structure below is used to retrieve the the status information
- * of the time source at a specific priority level.
+
+/**
+ * @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.
+ */
+enum
+{
+ XMRSF_BIT_MULT_INSTC_SUPP, /**< multiple instances of the same ref type supported */
+ XMRSF_BIT_IS_EXTERNAL, /**< this ref source is on extension card */
+ N_XMRS_FLAGS
+};
+
+#define XMRSF_MSK_MULT_INSTC_SUPP ( 1UL << XMRSF_BIT_MULT_INSTC_SUPP )
+#define XMRSF_MSK_IS_EXTERNAL ( 1UL << XMRSF_BIT_IS_EXTERNAL )
+
+
+
+/**
+ * @brief Status information on a ref time source at a specific priority level
*/
typedef struct
{
- uint16_t idx; /* the priority level index, highest == 0 */
- XMULTI_REF_STATUS status;
+ uint16_t idx; /**< the priority level index, highest == 0 */
+ XMULTI_REF_STATUS status; /**< status information */
} XMULTI_REF_STATUS_IDX;
-/*
- * Bits used with XMULTI_REF_STATUS.
+
+/**
+ * @brief Bits and bit masks used with XMULTI_REF_STATUS::status
+ *
+ * @note Flags XMRS_BIT_MULT_INSTC_SUPP and XMRS_BIT_NUM_SRC_EXC
+ * are set in the status flags for every priority if the associated
+ * condition is met.
*/
enum
{
- XMRS_BIT_NOT_SUPP, /* ref type cfg'd for this level is not supported */
- XMRS_BIT_NO_CONN, /* input signal is disconnected */
- XMRS_BIT_NO_SIGNAL, /* no input signal */
- XMRS_BIT_IS_MASTER, /* reference is master source */
- XMRS_BIT_IS_LOCKED, /* locked to input signal */
- XMRS_BIT_IS_ACCURATE, /* oscillator control has reached full accuracy */
- XMRS_BIT_NOT_SETTLED, /* reference time signal not settled */
- XMRS_BIT_NOT_PHASE_LOCKED, /* oscillator not phase locked to PPS */
- N_XMRS_BITS
+ XMRS_BIT_NOT_SUPP, /**< ref type cfg'd for this level is not supported */
+ XMRS_BIT_NO_CONN, /**< input signal is disconnected */
+ XMRS_BIT_NO_SIGNAL, /**< no input signal */
+ XMRS_BIT_IS_MASTER, /**< reference is master source */
+ XMRS_BIT_IS_LOCKED, /**< locked to input signal */
+ XMRS_BIT_IS_ACCURATE, /**< oscillator control has reached full accuracy */
+ XMRS_BIT_NOT_SETTLED, /**< reference time signal not settled */
+ XMRS_BIT_NOT_PHASE_LOCKED, /**< oscillator not phase locked to PPS */
+ XMRS_BIT_NUM_SRC_EXC, /**< number of available sources exceeds what can be handled */
+ XMRS_BIT_IS_EXTERNAL, /**< this ref source is on extension card */
+ N_XMRS_BITS /**< number of know status bits */
};
-
-/* bit masks corresponding to the flag bits above */
-
#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP )
#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN )
#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL )
@@ -3394,6 +3487,8 @@ enum
#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE )
#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED )
#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED )
+#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC )
+#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL )
@@ -3410,6 +3505,223 @@ 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.
+ */
+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 */
+} XMULTI_REF_INSTANCES;
+
+/** @} group_xmr_cfg */
+
+
+
+/**
+ * @defgroup group_gpio GPIO port configuration stuff
+ *
+ * @{ */
+
+/**
+ * @brief General GPIO config info to be read from a device
+ */
+typedef struct
+{
+ uint32_t num_io; /**< number of supported GPIO ports */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_CFG_LIMITS;
+
+
+
+/**
+ * @brief A structure used to specify a variable frequency
+ */
+typedef struct
+{
+ uint32_t hz; /**< integral number, Hz */
+ uint32_t frac; /**< fractional part, binary */
+
+} MBG_GPIO_FREQ;
+
+
+/**
+ * @brief A structure used to specify a fixed frequency
+ */
+typedef struct
+{
+ uint32_t frq_bit; /**< fixed freq. bit mask ( see enum ) */
+ uint32_t reserved; /**< reserved */
+
+} MBG_GPIO_FIXED_FREQ;
+
+/**
+ * @brief A structure used to configure a GPIO as frequency output
+ */
+typedef struct
+{
+ MBG_GPIO_FREQ freq; /**< frequency */
+ int32_t milli_phase; /**< phase [1/1000 degree units] */
+ uint32_t type; /**< sine, rectangle, etc. */ //##++++++++++++++
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_OUT_SETTINGS;
+
+
+/**
+ * @brief A structure used to configure a GPIO as frequency output
+ */
+
+typedef struct
+{
+ MBG_GPIO_FREQ freq; /**< frequency */
+ uint32_t csc_limit; /**< max. cycle slip [1/1000 cycle units] */
+ uint32_t type; /**< sine, rectangle, etc. */ //##++++++++++++++
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_IN_SETTINGS;
+
+
+
+/**
+ * @brief A structure used to configure a GPIO as fixed frequency output
+ */
+typedef struct
+{
+ MBG_GPIO_FIXED_FREQ freq; /**< frequency */
+ uint32_t reserved_0; /**< supported frequencies bit mask, see enum */
+ uint32_t type; /**< sine, rectangle, etc. */ //##++++++++++++++
+ uint32_t reserved_1; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FIXED_FREQ_OUT_SETTINGS;
+
+
+/**
+ * @brief A structure used to configure a GPIO port
+ */
+typedef struct
+{
+ uint32_t mode; /** frequency out, frequency in, pulse out, etc. */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+ union
+ {
+ MBG_GPIO_FREQ_OUT_SETTINGS freq_out; /** if type is frequency output */
+ MBG_GPIO_FREQ_IN_SETTINGS freq_in; /** if type is frequency input */
+ MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; /** if type is fixed frequency output */
+ } u;
+
+} MBG_GPIO_SETTINGS;
+
+
+/**
+ * @brief A structure used to describe a GPIO ports limiting values
+ */
+typedef struct
+{
+ uint32_t supp_modes; /**< supported modes */
+ uint32_t reserved;
+ uint32_t supp_flags; /**< supported flags */
+
+ union
+ {
+ MBG_GPIO_FREQ_OUT_SETTINGS freq_out; /** max. freq. values for output */
+ MBG_GPIO_FREQ_IN_SETTINGS freq_in; /** max. freq. values for input */
+ MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; /** max. ff values for output */
+ } u;
+
+} MBG_GPIO_LIMITS;
+
+
+
+
+
+/**
+ * @brief A structure used to configure a specific GPIO port
+ */
+typedef struct
+{
+ uint32_t idx; /**< port number, 0..(MBG_GPIO_CFG_LIMITS::num_io - 1) */
+ MBG_GPIO_SETTINGS settings; /**< configuration settings */
+
+} MBG_GPIO_SETTINGS_IDX;
+
+
+
+/**
+ * @brief A structure used query the current GPIO port settings and capabilities
+ */
+typedef struct
+{
+ MBG_GPIO_SETTINGS settings; /**< current configuration */
+ MBG_GPIO_LIMITS limits; /**< supp. and max. values */
+} MBG_GPIO_INFO;
+
+
+
+/**
+ * @brief A structure used to query configuration and capabilities of a specific GPIO port
+ */
+typedef struct
+{
+ uint32_t idx; /**< port number, 0..(MBG_GPIO_CFG_LIMITS::num_io - 1) */
+ MBG_GPIO_INFO info; /**< current settings and capabilities of this GPIO port */
+} MBG_GPIO_INFO_IDX;
+
+
+
+/**
+ * @brief Definitions for MBG_GPIO_SETTINGS::mode
+ */
+enum
+{
+ MBG_GPIO_SIGNAL_TYPE_FREQ_OUT, /**< variable frequency output */
+ MBG_GPIO_SIGNAL_TYPE_FREQ_IN, /**< variable frequency inputs */
+ MBG_GPIO_SIGNAL_TYPE_FIXED_FREQ_OUT, /**< fixed frequency outputs */
+ N_MBG_GPIO_SIGNAL_TYPES /**< number of known modes */
+};
+
+
+
+/**
+ * @brief Definitions for MBG_GPIO_FF_OUT_SETTINGS::frq_bit
+ */
+enum
+{
+ MBG_GPIO_FIXED_FREQ_8kHz, /**< 8kHz */
+ MBG_GPIO_FIXED_FREQ_48kHz, /**< 48kHz */
+ MBG_GPIO_FIXED_FREQ_1MHz, /**< 1MHz */
+ MBG_GPIO_FIXED_FREQ_1544kHz, /**< 1.544MHz */
+ MBG_GPIO_FIXED_FREQ_2048kHz, /**< 2.048MHz */
+ MBG_GPIO_FIXED_FREQ_5MHz, /**< 5MHz */
+ MBG_GPIO_FIXED_FREQ_10MHz, /**< 10MHz */
+ MBG_GPIO_FIXED_FREQ_19440kHz, /**< 19.44MHz */
+ N_MBG_GPIO_FIXED_FREQ /**< number of known frequencies */
+};
+
+/**< Bit Masks to be used with MBG_GPIO_FF_OUT_SETTINGS::frq_bit */
+#define MSK_MBG_GPIO_FIXED_FREQ_8kHz ( 1UL << MBG_GPIO_FIXED_FREQ_8kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_48kHz ( 1UL << MBG_GPIO_FIXED_FREQ_48kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_1MHz ( 1UL << MBG_GPIO_FIXED_FREQ_1MHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_1544kHz ( 1UL << MBG_GPIO_FIXED_FREQ_1544kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_2048kHz ( 1UL << MBG_GPIO_FIXED_FREQ_2048kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_5MHz ( 1UL << MBG_GPIO_FIXED_FREQ_5MHz )
+#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 )
+
+/** @} group_gpio */
+
/*------------------------------------------------------------------------*/
@@ -3512,10 +3824,12 @@ enum
/*------------------------------------------------------------------------*/
-/*
- * GPS receiver modes of operation. Some of the codes combinations
- * are obsolete with recent GPS receivers. However, that doesn't
- * matter since the mode is just read from the receiver:
+/**
+ * @brief Satellite receiver modes of operation.
+ *
+ * @note Some of the code combinations are obsolete with recent
+ * satellite receivers. However, this doesn't matter since the mode
+ * is just read from the receiver.
*/
#define REMOTE 0x10
#define BOOT 0x20
@@ -3539,9 +3853,12 @@ typedef int16_t DAC_VAL;
+/**
+ * @brief Satellite receiver status information
+ */
typedef struct
{
- uint16_t mode; /**< Mode of operation */
+ uint16_t mode; /**< Mode of operation, see predefined codes */
uint16_t good_svs; /**< Numb. of satellites that can currently be received and used */
uint16_t svs_in_view; /**< Numb. of satellites that should be in view according to the almanac data */
DAC_VAL dac_val; /**< Oscillator fine DAC value */
@@ -3563,31 +3880,26 @@ typedef struct
-/*
- The enumeration below lists all
- known satellite navigation systems
-*/
+/**
+ * @brief An enumeration of known satellite navigation systems
+ */
enum
{
- GNSS_TYPE_GPS,
- GNSS_TYPE_GLONASS,
- GNSS_TYPE_BEIDOU,
- GNSS_TYPE_GALILEO,
- N_GNSS_TYPES
+ GNSS_TYPE_GPS, /**< GPS, United States */
+ GNSS_TYPE_GLONASS, /**< GLONASS, Russia */
+ GNSS_TYPE_BEIDOU, /**< BEIDOU, China */
+ GNSS_TYPE_GALILEO, /**< GALILEO, Europe */
+ N_GNSS_TYPES /**< Number of defined codes */
};
-
-
-#define GNSS_TYPE_STRS \
-{ \
- "GPS", \
- "GLONASS", \
- "BEIDOU" , \
- "GALILEO" \
+#define GNSS_TYPE_STRS \
+{ \
+ "GPS", \
+ "GLONASS", \
+ "BEIDOU" , \
+ "GALILEO" \
}
-
-
#define MBG_GNSS_TYPE_MSK_GPS ( 1UL << GNSS_TYPE_GPS )
#define MBG_GNSS_TYPE_MSK_GLONASS ( 1UL << GNSS_TYPE_GLONASS )
#define MBG_GNSS_TYPE_MSK_BEIDOU ( 1UL << GNSS_TYPE_BEIDOU )
@@ -3603,10 +3915,10 @@ typedef struct
uint32_t flags; /**< see below */
} MBG_GNSS_MODE_SETTINGS;
-#define _mbg_swab_mbg_gnss_mode_settings( _p ) \
-{ \
- _mbg_swab32( &(_p)->gnss_set ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_mbg_gnss_mode_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->gnss_set ); \
+ _mbg_swab32( &(_p)->flags ); \
}
@@ -3618,16 +3930,17 @@ typedef struct
uint32_t flags; /**< indicates which of the defined flags are supported by the device */
} MBG_GNSS_MODE_INFO;
-#define _mbg_swab_mbg_gnss_mode_info( _p ) \
-{ \
- _mbg_swab_mbg_gnss_mode_settings( &(_p)->settings ); \
- _mbg_swab32( &(_p)->supp_gnss_types ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_mbg_gnss_mode_info( _p ) \
+{ \
+ _mbg_swab_mbg_gnss_mode_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_gnss_types ); \
+ _mbg_swab32( &(_p)->flags ); \
}
-/* Flags used with MBG_GNSS_MODE_SETTINGS::flags and MBG_GNSS_MODE_INFO::flags: */
-
+/**
+ * @brief Flags used with MBG_GNSS_MODE_SETTINGS::flags and MBG_GNSS_MODE_INFO::flags
+ */
enum
{
MBG_GNSS_FLAG_EXCLUSIVE, /**< (read only) only one of the supported GNSS systems can be used at the same time */
@@ -3642,10 +3955,9 @@ enum
#define MAX_USED_SATS 32
-/*
- The structure below allos to transfer
- SV information from a certain GNSS type.
-*/
+/**
+ * @brief SV information from a certain GNSS type.
+ */
typedef struct
{
uint8_t gnss_type; /**< GNSS type from the enumeration above */
@@ -3655,7 +3967,7 @@ typedef struct
uint8_t svs[MAX_USED_SATS];
} GNSS_SAT_INFO;
-#define _mbg_swab_gnss_sat_info( _p ) \
+#define _mbg_swab_gnss_sat_info( _p ) \
{ \
_mbg_swab16( &(_p)->good_svs ); \
_mbg_swab16( &(_p)->svs_in_view ); \
@@ -3682,8 +3994,7 @@ typedef struct
}
/**
- * The type below is used to configure the length of the
- * antenna cable in [m]:
+ * @brief A data type used to configure the length of an antenna cable [m]
*/
typedef uint16_t ANT_CABLE_LEN;
@@ -3691,29 +4002,36 @@ typedef uint16_t ANT_CABLE_LEN;
-/* Configuration data for an optional LAN interface.
+/**
+ * @defgroup group_ip4_cfg Simple configuration and status
+ * of an optional LAN interface.
*
- * This is only supported if the flag GPS_HAS_LAN_IP4
- * is set in RECEIVER_INFO::features.
- */
-
+ * @note This is only supported if the flag GPS_HAS_LAN_IP4 is set
+ * in RECEIVER_INFO::features.
+ *
+ * @{ */
-/* Basic network settings */
+/**
+ * @brief An IPv4 address
+ */
typedef uint32_t IP4_ADDR;
#define _mbg_swab_ip4_addr( _p ) \
_mbg_swab32( _p );
+/**
+ * @brief Settings of an IPv4 network interface
+ */
typedef struct
{
- IP4_ADDR ip_addr;
- IP4_ADDR netmask;
- IP4_ADDR broad_addr;
- IP4_ADDR gateway;
- uint16_t flags; /* see below */
- uint16_t vlan_cfg; /* see below */
+ IP4_ADDR ip_addr; /**< the IP address */
+ IP4_ADDR netmask; /**< the network mask */
+ IP4_ADDR broad_addr; /**< the broadcast address */
+ IP4_ADDR gateway; /**< the default gateway */
+ uint16_t flags; /**< flags as specified below */
+ uint16_t vlan_cfg; /**< VLAN configuration, see below */
} IP4_SETTINGS;
@@ -3728,30 +4046,34 @@ typedef struct
}
-// IP4_SETTINGS::vlan_cfg contains a combination of
-// a VLAN ID number plus a VLAN priiority code.
-// Definitions used with IP4_SETTINGS::vlan_cfg:
-
-#define VLAN_ID_BITS 12 // number of bits to hold the ID
-#define N_VLAN_ID ( 1 << VLAN_ID_BITS ) // number of ID values
-#define MIN_VLAN_ID 0 // minimum ID value
-#define MAX_VLAN_ID ( N_VLAN_ID - 1 ) // maximum ID value
+/**
+ * @brief Definitions used with IP4_SETTINGS::vlan_cfg
+ *
+ * @note IP4_SETTINGS::vlan_cfg contains a combination of
+ * a VLAN ID number plus a VLAN priority code.
+ */
+#define VLAN_ID_BITS 12 //< number of bits to hold the ID
+#define N_VLAN_ID ( 1 << VLAN_ID_BITS ) //< number of ID values
+#define MIN_VLAN_ID 0 //< minimum ID value
+#define MAX_VLAN_ID ( N_VLAN_ID - 1 ) //< maximum ID value
// vlan_id = ( vlan_cfg >> VLAN_ID_SHIFT ) & VLAN_ID_MSK
#define VLAN_ID_SHIFT 0
#define VLAN_ID_MSK ( ( 1 << VLAN_ID_BITS ) - 1 )
-#define VLAN_PRIORITY_BITS 3 // number of bits to hold priority
-#define N_VLAN_PRIORITY ( 1 << VLAN_PRIORITY_BITS ) // number of priority values
-#define MIN_VLAN_PRIORITY 0 // minimum priority
-#define MAX_VLAN_PRIORITY ( N_VLAN_PRIORITY - 1 ) // maximum priority
+#define VLAN_PRIORITY_BITS 3 //< number of bits to hold priority
+#define N_VLAN_PRIORITY ( 1 << VLAN_PRIORITY_BITS ) //< number of priority values
+#define MIN_VLAN_PRIORITY 0 //< minimum priority
+#define MAX_VLAN_PRIORITY ( N_VLAN_PRIORITY - 1 ) //< maximum priority
// vlan_priority = ( vlan_cfg >> VLAN_PRIORITY_SHIFT ) & VLAN_PRIORITY_MSK
#define VLAN_PRIORITY_SHIFT ( ( 8 * sizeof( uint16_t ) ) - VLAN_PRIORITY_BITS )
#define VLAN_PRIORITY_MSK ( ( 1 << VLAN_PRIORITY_BITS ) - 1 )
-// The macros below can be used to encode/decode packed vlan_cfg variables:
+/**
+ * @brief Macros used to encode/decode packed vlan_cfg variables
+ */
#define _decode_vlan_id( _cfg ) ( ( (_cfg) >> VLAN_ID_SHIFT ) & VLAN_ID_MSK )
#define _decode_vlan_priority( _cfg ) ( ( (_cfg) >> VLAN_PRIORITY_SHIFT ) & VLAN_PRIORITY_MSK )
#define _encode_vlan_cfg( _id, _prty ) ( ( (_id) << VLAN_ID_SHIFT ) | ( (_prty) << VLAN_PRIORITY_SHIFT ) )
@@ -3785,18 +4107,23 @@ typedef struct
-/* LAN interface information */
-
+/**
+ * @brief LAN interface information
+ *
+ * This structure can be retrieved from a device
+ * to check the device's capabilities.
+ */
typedef struct
{
- uint16_t type; /* codes see below */
- uint8_t mac_addr[6]; /* MAC address */
- uint16_t ver_code; /* high byte.low byte, in hex */
- char ver_str[GPS_ID_STR_SIZE];
- char sernum[GPS_ID_STR_SIZE];
- uint32_t rsvd_0; /* reserved, currently always 0 */
- uint16_t flags; /* see below */
- uint16_t rsvd_1; /* reserved, currently always 0 */
+ uint16_t type; //< type of LAN interface, see below
+ uint8_t mac_addr[6]; //< MAC address
+ uint16_t ver_code; //< version number, high byte.low byte, in hex
+ char ver_str[GPS_ID_STR_SIZE]; //< version string
+ char sernum[GPS_ID_STR_SIZE]; //< serial number
+ uint32_t rsvd_0; //< reserved, currently always 0
+ uint16_t flags; //< flags as specified below
+ uint16_t rsvd_1; //< reserved, currently always 0
+
} LAN_IF_INFO;
#define _mbg_swab_lan_if_info( _p ) \
@@ -3810,41 +4137,54 @@ typedef struct
-/* codes used with LAN_IF_INFO::type: */
-
+/**
+ * @brief Codes used with LAN_IF_INFO::type
+ */
enum
{
- LAN_IF_TYPE_XPORT,
- LAN_IF_TYPE_PTP,
- N_LAN_IF_TYPE
+ LAN_IF_TYPE_XPORT, //< LAN interface on an XPORT
+ LAN_IF_TYPE_PTP, //< LAN interface is a special PTP interface
+ N_LAN_IF_TYPE //< number of defined LAN interface types
};
-/* Flags used with IP4_SETTINGS::flags and LAN_IF_INFO::flags: */
-
+/**
+ * @brief Flags used with IP4_SETTINGS::flags and LAN_IF_INFO::flags
+ */
enum
{
- IP4_BIT_DHCP, // DHCP supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
- IP4_BIT_LINK, // used only in IP4_SETTINGS to report link state
- IP4_BIT_VLAN, // VLAN supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
- N_IP4_BIT
+ IP4_BIT_DHCP, //< DHCP supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
+ IP4_BIT_LINK, //< used only in IP4_SETTINGS to report link state
+ IP4_BIT_VLAN, //< VLAN supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
+ N_IP4_BIT //< number of defined flag bits
};
#define IP4_MSK_DHCP ( 1UL << IP4_BIT_DHCP )
#define IP4_MSK_LINK ( 1UL << IP4_BIT_LINK )
#define IP4_MSK_VLAN ( 1UL << IP4_BIT_VLAN )
+/** @} group_ip4_cfg */
+
+
+
+/**
+ * @defgroup group_ptp Definitions used with PTP/IEEE1588
+ *
+ * @{ */
+/**
+ * @brief Enumeration of protocols possibly used with PTP
+ */
enum
{
- PTP_NW_PROT_BIT_RESERVED,
- PTP_NW_PROT_BIT_UDP_IPV4,
- PTP_NW_PROT_BIT_UDP_IPV6,
- PTP_NW_PROT_BIT_IEEE_802_3,
- PTP_NW_PROT_BIT_DEVICE_NET,
- PTP_NW_PROT_BIT_CONTROL_NET,
- PTP_NW_PROT_BIT_PROFINET,
- N_PTP_NW_PROT
+ PTP_NW_PROT_BIT_RESERVED, //< reserved
+ PTP_NW_PROT_BIT_UDP_IPV4, //< IPv4
+ PTP_NW_PROT_BIT_UDP_IPV6, //< IPv6
+ PTP_NW_PROT_BIT_IEEE_802_3, //< Ethernet (raw layer 2)
+ PTP_NW_PROT_BIT_DEVICE_NET, //< DeviceNet
+ PTP_NW_PROT_BIT_CONTROL_NET, //< ControlNet
+ PTP_NW_PROT_BIT_PROFINET, //< ProfiNet
+ N_PTP_NW_PROT //< number of defined protocols
};
#define PTP_NW_PROT_MSK_RESERVED ( 1UL << PTP_NW_PROT_BIT_RESERVED )
@@ -3859,18 +4199,24 @@ enum
#define DEFAULT_PTP_NW_PROT_MASK ( PTP_NW_PROT_MSK_UDP_IPV4 | PTP_NW_PROT_MSK_IEEE_802_3 )
#endif
+/**
+ * @brief Name strings for the protocols possibly used with PTP
+ */
#define PTP_NW_PROT_STRS \
{ \
"Reserved", \
- "UDP/IPv4", \
- "UDP/IPv6", \
- "IEEE 802.3", \
+ "UDP/IPv4 (L3)", \
+ "UDP/IPv6 (L3)", \
+ "IEEE 802.3 (L2)", \
"DeviceNet", \
"ControlNet", \
"PROFINET" \
}
+/**
+ * @brief Short name strings for the protocols possibly used with PTP
+ */
#define PTP_NW_PROT_STRS_SHORT \
{ \
"RES", \
@@ -3882,21 +4228,29 @@ enum
"PN" \
}
+
+/**
+ * @brief Possible states of a PTP port
+ */
enum
{
- PTP_PORT_STATE_UNINITIALIZED,
- PTP_PORT_STATE_INITIALIZING,
- PTP_PORT_STATE_FAULTY,
- PTP_PORT_STATE_DISABLED,
- PTP_PORT_STATE_LISTENING,
- PTP_PORT_STATE_PRE_MASTER,
- PTP_PORT_STATE_MASTER,
- PTP_PORT_STATE_PASSIVE,
- PTP_PORT_STATE_UNCALIBRATED,
- PTP_PORT_STATE_SLAVE,
- N_PTP_PORT_STATE
+ PTP_PORT_STATE_UNINITIALIZED, //< uninitialized
+ PTP_PORT_STATE_INITIALIZING, //< currently initializing
+ PTP_PORT_STATE_FAULTY, //< faulty
+ PTP_PORT_STATE_DISABLED, //< disabled
+ PTP_PORT_STATE_LISTENING, //< listening for PTP packets
+ PTP_PORT_STATE_PRE_MASTER, //< going to become master
+ PTP_PORT_STATE_MASTER, //< master
+ PTP_PORT_STATE_PASSIVE, //< passive
+ PTP_PORT_STATE_UNCALIBRATED, //< uncalibrated
+ PTP_PORT_STATE_SLAVE, //< slave
+ N_PTP_PORT_STATE //< number of defined port states
};
+
+/**
+ * @brief Name strings for the PTP port states
+ */
#define PTP_PORT_STATE_STRS \
{ \
"UNINITIALIZED", \
@@ -3912,18 +4266,28 @@ enum
}
+/**
+ * @brief An entry for a table of parameters which can not be accessed by an enumerated index
+ */
typedef struct
{
- uint8_t value;
- const char *name;
+ uint8_t value; //< the parameter value
+ const char *name; //< the parameter name
} PTP_TABLE;
+/**
+ * @brief An enumeration of PTP delay mechanisms
+ *
+ * @note This is different than the numeric values specified
+ * in the published specs for IEEE1588. In addition, the specs
+ * define 0x14 for "disabled".
+ */
enum
{
- PTP_DELAY_MECH_BIT_E2E, // in PTP2 specs: 0x01
- PTP_DELAY_MECH_BIT_P2P, // in PTP2 specs: 0x02
- N_PTP_DELAY_MECH // additionally the specs define 0xFE for disabled
+ PTP_DELAY_MECH_BIT_E2E, //< End-to-End (in PTP2 specs: 0x01)
+ PTP_DELAY_MECH_BIT_P2P, //< Peer-to-Peer (in PTP2 specs: 0x02)
+ N_PTP_DELAY_MECH //< number of defined delay mechanisms
};
#define PTP_DELAY_MECH_MSK_E2E ( 1UL << PTP_DELAY_MECH_BIT_E2E )
@@ -3933,6 +4297,9 @@ enum
#define DEFAULT_PTP_DELAY_MECH_MASK ( PTP_DELAY_MECH_MSK_E2E | PTP_DELAY_MECH_MSK_P2P )
#endif
+/**
+ * @brief Name strings for the PTP delay mechanisms
+ */
#define PTP_DELAY_MECH_NAMES \
{ \
"E2E", \
@@ -3941,11 +4308,17 @@ enum
-#define PTP_CLOCK_ACCURACY_RESERVED_OFFSET 0x20
+#define PTP_CLOCK_ACCURACY_NUM_BIAS 0x20
+/**
+ * @brief An enumeration of accuracy classes used with PTP
+ *
+ * @note This enumeration does not start at 0 but with a bias
+ * specified by PTP_CLOCK_ACCURACY_NUM_BIAS.
+ */
enum
{
- PTP_CLOCK_ACCURACY_25ns = PTP_CLOCK_ACCURACY_RESERVED_OFFSET,
+ PTP_CLOCK_ACCURACY_25ns = PTP_CLOCK_ACCURACY_NUM_BIAS,
PTP_CLOCK_ACCURACY_100ns,
PTP_CLOCK_ACCURACY_250ns,
PTP_CLOCK_ACCURACY_1us,
@@ -3971,8 +4344,13 @@ enum
};
-// Attention: Substract offset of PTP_CLOCK_ACCURACY_RESERVED_OFFSET when
-// using the enum above as index for the initializer below!
+/**
+ * @brief Name strings for PTP accuracy classes
+ *
+ * @note The enumeration does not start at 0 but with a bias
+ * specified by PTP_CLOCK_ACCURACY_NUM_BIAS, so this bias needs
+ * to be accounted for when accessing a string table.
+ */
#define PTP_CLOCK_ACCURACY_STRS \
{ \
"< 25 ns", \
@@ -4001,6 +4379,9 @@ enum
+/**
+ * @brief Codes to specify the type of a time source used with PTP
+ */
#define PTP_TIME_SOURCE_ATOMIC_CLOCK 0x10
#define PTP_TIME_SOURCE_GPS 0x20
#define PTP_TIME_SOURCE_TERRESTRIAL_RADIO 0x30
@@ -4012,6 +4393,9 @@ enum
+/**
+ * @brief A table of PTP time source codes plus associated name strings
+ */
#define PTP_TIME_SOURCE_TABLE \
{ \
{ PTP_TIME_SOURCE_ATOMIC_CLOCK, "Atomic Clock" }, \
@@ -4026,17 +4410,26 @@ enum
}
-
+/**
+ * @brief An enumeration of roles which can be taken by a PTP node
+ *
+ * @note A role in this context specifies a certain mode of operation.
+ * Depending on its specification a devices may not be able to take
+ * each of the specified roles.
+ */
enum
{
- PTP_ROLE_MULTICAST_SLAVE,
- PTP_ROLE_UNICAST_SLAVE,
- PTP_ROLE_MULTICAST_MASTER,
- PTP_ROLE_UNICAST_MASTER,
- N_PTP_ROLES
+ PTP_ROLE_MULTICAST_SLAVE, //< slave in multicast mode
+ PTP_ROLE_UNICAST_SLAVE, //< slave in unicast mode
+ PTP_ROLE_MULTICAST_MASTER, //< multicast master
+ PTP_ROLE_UNICAST_MASTER, //< unicast master
+ N_PTP_ROLES //< number of defined roles
};
+/**
+ * @brief Name strings for defined PTP roles
+ */
#define PTP_ROLE_STRS \
{ \
"Multicast Slave", \
@@ -4046,75 +4439,161 @@ enum
}
+/**
+ * @brief Short name strings for defined PTP roles
+ */
+#define PTP_ROLE_STRS_SHORT \
+{ \
+ "MCS", \
+ "UCS", \
+ "MCM", \
+ "UCM" \
+}
-/* PTP configuration stuff */
+/**
+ * @brief A PTP clock identity
+ *
+ * @note This usually consists of a 6 byte MAC address with
+ * 2 fixed bytes inserted, or all ones as wildcard.
+ */
typedef struct
{
uint8_t b[8];
-} PTP_CLOCK_IDENTITY;
+} PTP_CLOCK_ID;
-#define _mbg_swab_ptp_clock_identity( _p ) _nop_macro_fnc() // nothing to swap
+#define _mbg_swab_ptp_clock_id( _p ) _nop_macro_fnc() // nothing to swap
+#define PTP_CLOCK_ID_WILDCARD { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
+/**
+ * @brief A PTP port ID
+ *
+ * @note This usually consists of a 6 byte MAC address with
+ * 2 fixed bytes inserted, or all ones as wildcard.
+ */
+typedef uint16_t PTP_PORT_ID;
+
+#define _mbg_swab_ptp_port_id( _p ) _mbg_swab16( _p )
+
+#define PTP_PORT_ID_WILDCARD 0xFFFF
+
+
+/**
+ * @brief An enumeration of time scales used with PTP
+ *
+ * @note The standard time scale used by PTP is TAI, which is a linear time scale.
+ * The protocol provides a UTC offset to be able to convert TAI to compute UTC, which
+ * can observe leap seconds. For the arbitrary time scale the UTC offset is unspecified.
+ */
+enum
+{
+ PTP_TIMESCALE_PTP, /* default */
+ PTP_TIMESCALE_ARB,
+ N_PTP_TIMESCALE
+};
+
+
+/**
+ * @brief Name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAME_PTP "PTP Standard (TAI)"
+#define PTP_TIMESCALE_NAME_ARB "Arbitrary"
+
+/**
+ * @brief Short name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAME_PTP_SHORT "PTP"
+#define PTP_TIMESCALE_NAME_ARB_SHORT "Arb"
+
+
+/**
+ * @brief A table of name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAMES \
+{ \
+ PTP_TIMESCALE_NAME_PTP, \
+ PTP_TIMESCALE_NAME_ARB \
+}
+
+/**
+ * @brief A table of short name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAMES_SHORT \
+{ \
+ PTP_TIMESCALE_NAME_PTP_SHORT, \
+ PTP_TIMESCALE_NAME_ARB_SHORT \
+}
+
+
+
+/**
+ * @brief A structure to used to read the status of the PTP protocol stack
+ */
typedef struct
{
- uint16_t network_protocol; // enum
- uint8_t ptp_proto_version; // PTP v1 or v2
- uint8_t port_state; // enum
- uint32_t flags;
- NANO_TIME offset;
+ //##++++ Do we need a port identifier ??
+ uint16_t nw_prot; /**< one of the enumerated protocols (@see N_PTP_NW_PROT) */
+ uint8_t ptp_prot_version; /**< PTP protocol version, 1, or 2, usually 2 for v2 */
+ uint8_t port_state; /**< one of the enumerated port states (@see N_PTP_PORT_STATE ) */
+ uint32_t flags; /**< bit masks as defined below */
+ NANO_TIME offset; /**< estimated time offset from the upstream time source */
NANO_TIME path_delay;
NANO_TIME mean_path_delay;
NANO_TIME delay_asymmetry;
- PTP_CLOCK_IDENTITY gm_identity;
+ PTP_CLOCK_ID gm_id; /**< identifier ot the upstream time source */
uint16_t clock_offset_scaled_log_variance;
uint8_t clock_class;
- uint8_t clock_accuracy; // enum
+ uint8_t clock_accuracy; /**< one of the enumerated accuracy class codes (@see N_PTP_CLOCK_ACCURACY) */
+
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+ uint32_t reserved_2; /**< reserved, currently always 0 */
- uint32_t reserved_1;
- uint32_t reserved_2;
+ uint8_t domain_number; /**< the PTP clock domain number, 0:3 */
+ uint8_t time_source; /**< one of the defined codes PTP_TIME_SOURCE_... */
+ uint8_t delay_mech; /**< PTP_DELAY_MECH_BIT_E2E or PTP_DELAY_MECH_BIT_P2P */
+ int8_t log_delay_req_intv;
- uint8_t domain_number;
- uint8_t time_source; // enum
- uint8_t delay_mech;
- int8_t log_delay_req_intv;
+ int16_t utc_offset; /**< UTC offset observed against TAI */
+ DAC_VAL osc_dac_cal; /**< disiplination value of the oscillator */
- int16_t utc_offset;
- DAC_VAL osc_dac_cal;
+ uint32_t reserved_3; /**< reserved, currently always 0 */
- uint32_t reserved_3;
} PTP_STATE;
#define _mbg_swab_ptp_state( _p ) \
{ \
- _mbg_swab16( &(_p)->network_protocol ); \
+ _mbg_swab16( &(_p)->nw_prot ); \
_mbg_swab32( &(_p)->flags ); \
_mbg_swab_nano_time( &(_p)->offset ); \
_mbg_swab_nano_time( &(_p)->path_delay ); \
_mbg_swab_nano_time( &(_p)->mean_path_delay ); \
_mbg_swab_nano_time( &(_p)->delay_asymmetry ); \
- _mbg_swab_ptp_clock_identity( &(_p)->gm_identity ); \
+ _mbg_swab_ptp_clock_id( &(_p)->gm_id ); \
_mbg_swab16( &(_p)->clock_offset_scaled_log_variance ); \
- _mbg_swab32( &(_p)->num_clients ); \
- _mbg_swab32( &(_p)->num_masters ); \
- _mbg_swab32( &(_p)->utc_offset ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab16( &(_p)->utc_offset ); \
_mbg_swab_dac_val( &(_p)->osc_dac_cal ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
}
+/**
+ * @brief Flag bits used with PTP_STATE::flags
+ */
enum
{
- PTP_FLAG_BIT_SLAVE_ONLY,
- PTP_FLAG_BIT_IS_SLAVE,
- PTP_FLAG_BIT_TIMESCALE_IS_PTP,
- PTP_FLAG_BIT_LS_ANN,
- PTP_FLAG_BIT_LS_ANN_NEG,
- PTP_FLAG_BIT_IS_UNICAST,
- N_PTP_FLAG_BIT
+ PTP_FLAG_BIT_SLAVE_ONLY, /**< the port can only be slave */
+ PTP_FLAG_BIT_IS_SLAVE, /**< the port is currently slave */
+ PTP_FLAG_BIT_TIMESCALE_IS_PTP, /**< the timescale is PTP standard, not arbitrary */
+ PTP_FLAG_BIT_LS_ANN, /**< a leap second is being announced */
+ PTP_FLAG_BIT_LS_ANN_NEG, /**< the announced leap second is negative */
+ PTP_FLAG_BIT_IS_UNICAST, /**< the port currently operates in unicast mode */
+ N_PTP_FLAG_BIT /**< the number of defined flag bits */
};
#define PTP_FLAG_MSK_SLAVE_ONLY ( 1UL << PTP_FLAG_BIT_SLAVE_ONLY )
@@ -4125,6 +4604,7 @@ enum
#define PTP_FLAG_MSK_IS_UNICAST ( 1UL << PTP_FLAG_BIT_IS_UNICAST )
+
#define PTP_SYNC_INTERVAL_MIN -6
#define PTP_SYNC_INTERVAL_MAX 6
@@ -4140,99 +4620,125 @@ enum
#define PTP_DEFAULT_UNICAST_ANNOUNCE_INTERVAL_MIN -4
#define PTP_DEFAULT_UNICAST_ANNOUNCE_INTERVAL_MAX 4
+/**
+ * @defgroup group_ptp_uc_msg_duration_limits Unicast PTP masters send messages
+ * to a unicast slave only for a given interval as requested by the particular
+ * slave, which is called message duration. These symbols define the minimum and
+ * maximum message duration configured on a slave for a specific unicast master,
+ * i.e. for PTP_UC_MASTER_SETTINGS::message_duration.
+ * @{ */
+
+#define PTP_UC_MSG_DURATION_MIN 10 //< minimum message duration [s]
+#define PTP_UC_MSG_DURATION_MAX 1000 //< maximum message duration [s]
+#define PTP_UC_MSG_DURATION_DEFAULT 60 //< default, though the specs say 300 s
+/** @} group_ptp_uc_msg_duration_limits */
+
+
+
+/**
+ * @brief A structure used to configure a PTP port
+ */
typedef struct
{
- uint16_t network_protocol; // enum, only 1 or 3
- uint8_t profile; // currently only 0 = default
- uint8_t domain_number; // 0:3
+ //##++++ Do we need a port identifier ??
+ uint16_t nw_prot; /**< one of the enumerated and supported protocols (@see N_PTP_NW_PROT) */
+ uint8_t profile; /**< PTP profile, currently only 0 = default */
+ uint8_t domain_number; /**< the PTP clock domain number, 0:3 */
- uint8_t delay_mechanism; // 0 (E2E) or 1 (P2P), unless disabled
- uint8_t ptp_role; // MC_SLAVE/UC_SLAVE/MC_Master/UC_MASTER as defined in enum above
- uint8_t priority_1;
- uint8_t priority_2;
+ uint8_t delay_mech; /**< PTP_DELAY_MECH_BIT_E2E or PTP_DELAY_MECH_BIT_P2P, if supported */
+ uint8_t ptp_role; /**< one of the enumerated PTP roles (@see N_PTP_ROLES) */
+ uint8_t priority_1; /**< priority 1 */
+ uint8_t priority_2; /**< priority 2 */
uint8_t dflt_clk_class_unsync_cold; // 6:255
uint8_t dflt_clk_class_unsync_warm; // 6:255
uint8_t dflt_clk_class_sync_cold; // 6:255
uint8_t dflt_clk_class_sync_warm; // 6:255
- uint8_t reserved_1; // currently always 0
- uint8_t reserved_2; // currently always 0
- int16_t sync_interval; // log 2
+ uint8_t reserved_1; /**< reserved, currently always 0 */
+ uint8_t reserved_2; /**< reserved, currently always 0 */
+ int16_t sync_intv; /**< log2 of the sync interval [s] */
- int16_t announce_interval; // log 2
- int16_t delay_request_interval; // log 2
+ int16_t ann_intv; /**< log2 of the announce interval [s] */
+ int16_t delay_req_intv; /**< log2 of the delay request interval [s] */
- uint32_t upper_bound; // [ns] sync state set to false if above this limit
- uint32_t lower_bound; // [ns] sync state set to true if below this limit
+ uint32_t upper_bound; /**< sync state set to false if above this limit [ns] */
+ uint32_t lower_bound; /**< sync state set to true if below this limit [ns] */
- uint32_t reserved_3; // currently always 0
- uint32_t flags; // (see below)
+ uint32_t reserved_3; /**< reserved, currently always 0 */
+ uint32_t flags; /**< bit masks as defined below */
} PTP_CFG_SETTINGS;
-#define _mbg_swab_ptp_cfg_settings( _p ) \
-{ \
- _mbg_swab16( &(_p)->network_protocol ); \
- _mbg_swab16( &(_p)->sync_interval ); \
- _mbg_swab16( &(_p)->announce_interval ); \
- _mbg_swab16( &(_p)->delay_request_interval ); \
- _mbg_swab32( &(_p)->upper_bound ); \
- _mbg_swab32( &(_p)->lower_bound ); \
- _mbg_swab32( &(_p)->reserved_1 ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_ptp_cfg_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->nw_prot ); \
+ _mbg_swab16( &(_p)->sync_intv ); \
+ _mbg_swab16( &(_p)->ann_intv ); \
+ _mbg_swab16( &(_p)->delay_req_intv ); \
+ _mbg_swab32( &(_p)->upper_bound ); \
+ _mbg_swab32( &(_p)->lower_bound ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->flags ); \
}
+/**
+ * @brief A structure to used to query the current configurration and capabilities of a PTP port
+ */
typedef struct
{
- PTP_CFG_SETTINGS settings;
+ PTP_CFG_SETTINGS settings; /**< the current configuration */
- uint8_t ptp_proto_version; // PTP v1 or v2
- uint8_t reserved_1; // currently always 0
- uint16_t reserved_2; // currently always 0
+ uint8_t ptp_proto_version; /**< PTP protocol version, 1, or 2, usually 2 for v2 */
+ uint8_t reserved_1; /**< reserved, currently always 0 */
+ uint16_t reserved_2; /**< reserved, currently always 0 */
- int16_t sync_interval_min; // log 2
- int16_t sync_interval_max; // log 2
- int16_t announce_interval_min; // log 2
- int16_t announce_interval_max; // log 2
- int16_t delay_request_interval_min; // log 2
- int16_t delay_request_interval_max; // log 2
+ int16_t sync_intv_min; /**< log2 of minimum sync interval [s] */
+ int16_t sync_intv_max; /**< log2 of maximum sync interval [s] */
+ int16_t ann_intv_min; /**< log2 of minimum announce interval [s] */
+ int16_t ann_intv_max; /**< log2 of maximum announce interval [s] */
+ int16_t delay_req_intv_min; /**< log2 of minimum delay request interval [s] */
+ int16_t delay_req_intv_max; /**< log2 of maximum delay request interval [s] */
- uint32_t supported_flags; // (see below)
- uint32_t supported_network_protocols;
- uint32_t supported_profiles;
- uint32_t supported_delay_mechanisms;
+ uint32_t supp_flags; /**< a bit mask of supported features (see below) */
+ uint32_t supp_nw_prot; /**< a bit mask of supported network protocols */
+ uint32_t supp_profiles; /**< a bit mask of supported profiles */
+ uint32_t supp_delay_mech; /**< a bit mask of supported delay mechanisms */
} PTP_CFG_INFO;
-#define _mbg_swab_ptp_cfg_info( _p ) \
-{ \
- _mbg_swab_ptp_cfg_settings( &(_p)->settings ); \
- _mbg_swab16( &(_p)->sync_interval_min ); \
- _mbg_swab16( &(_p)->sync_interval_max ); \
- _mbg_swab16( &(_p)->announce_interval_min ); \
- _mbg_swab16( &(_p)->announce_interval_max ); \
- _mbg_swab16( &(_p)->delay_request_interval_min ); \
- _mbg_swab16( &(_p)->delay_request_interval_max ); \
- _mbg_swab32( &(_p)->supported_flags ); \
- _mbg_swab32( &(_p)->supported_profiles ); \
- _mbg_swab32( &(_p)->supported_delay_mechanisms ); \
+#define _mbg_swab_ptp_cfg_info( _p ) \
+{ \
+ _mbg_swab_ptp_cfg_settings( &(_p)->settings ); \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab16( &(_p)->sync_intv_min ); \
+ _mbg_swab16( &(_p)->sync_intv_max ); \
+ _mbg_swab16( &(_p)->ann_intv_min ); \
+ _mbg_swab16( &(_p)->ann_intv_max ); \
+ _mbg_swab16( &(_p)->delay_req_intv_min ); \
+ _mbg_swab16( &(_p)->delay_req_intv_max ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->supp_nw_prot ); \
+ _mbg_swab32( &(_p)->supp_profiles ); \
+ _mbg_swab32( &(_p)->supp_delay_mech ); \
}
-// flags used with PTP_CFG_SETTINGS::flags and PTP_CFG_INFO::supported_flags:
-// possibly also: can be master (i.e not slave only), v1 hw compat, ...
+/**
+ * @brief Flags used with PTP_CFG_SETTINGS::flags and PTP_CFG_INFO::supp_flags
+ */
enum
{
- PTP_CFG_BIT_TIME_SCALE_IS_PTP, // time scale is PTP/TAI, else arbitrary
- PTP_CFG_BIT_V1_HW_COMPAT,
- PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE,
- PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER,
- PTP_CFG_BIT_CAN_BE_UNICAST_MASTER
+ PTP_CFG_BIT_TIME_SCALE_IS_PTP, /**< time scale is PTP/TAI, else arbitrary */
+ PTP_CFG_BIT_V1_HW_COMPAT, /**< maybe required for certain NIC chips, not used by Meinberg */
+ PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE, /**< the PTP port can take the role of a unicast slave */
+ PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER, /**< the PTP port can take the role of a multicast master */
+ PTP_CFG_BIT_CAN_BE_UNICAST_MASTER, /**< the PTP port can take the role of a unicast master */
+ N_PTP_CFG_BIT /**< the number of defined bits */
};
#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
@@ -4249,75 +4755,159 @@ enum
#define PTP_CFG_MSK_SUPPORT_PTP_UNICAST ( PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE | \
PTP_CFG_MSK_CAN_BE_UNICAST_MASTER )
+/**
+ * @brief Derive a "supported PTP roles" bit mask from PTP_CFG_INFO::supp_flags
+ *
+ * There's no explicite flag to indicate that the role of a multicast slave
+ * is supported, since this role is always supported. The sequence of flags
+ * indicating that a specific optional role is supported matches the enumerated
+ * roles above, but don't start at bit 0. So we compine the optional flag bits
+ * with the LSB always set for the implicite multicast slave role to yield
+ * a bit mask which according to the enumerated roles.
+ */
+#define _get_supp_ptp_role_idx_msk( _f ) \
+ ( 1UL | ( ( (_f) & PTP_CFG_MSK_SUPPORT_PTP_ROLES ) >> ( PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE - 1 ) ) )
+//##+++++++++ #define _get_supp_ptp_roles( _r ) ((((_r) & ~3UL) >> PTP_CFG_BIT_V1_HW_COMPAT ) | 1UL)
-// Set Multicast as default
-#define _get_supp_ptp_roles( _r ) ((((_r) & ~3UL) >> PTP_CFG_BIT_V1_HW_COMPAT ) | 1UL)
-// The MBG_HOSTNAME type can hold a host's fully qualified domain name (FQDN),
-// or the ASCII string of a numeric IP address.
-// In theory each single component (host name, domain name, top level domain name)
-// of a FQDN can have up to 63 characters, but the overall length is limited to
-// 255 characters. We specify one more character for the trailing 0.
+/**
+ * @brief A host's fully qualified domain name (FQDN), or a numeric IP address string
+ *
+ * In theory each single component (host name, domain name, top level domain name)
+ * of a FQDN can have up to 63 characters, but the overall length is limited to
+ * 255 characters. We specify one more character for the trailing 0.
+ */
typedef char MBG_HOSTNAME[256];
+
+/**
+ * @brief Limits to be considered when specifying PTP unicast masters
+ */
typedef struct
{
- MBG_HOSTNAME gm_host; /**< grandmaster's hostname or IP address */
- PTP_CLOCK_IDENTITY gm_clock_id; /**< use clock ID of master port, or FF:FF:FF:FF:FF:FF:FF:FF as wildcard */
- uint16_t gm_port_id; /**< use target port ID of master port (e.g. '1') or 0xFFFF as wildcard */
- int16_t sync_interval; /**< log 2 */
- int16_t announce_interval; /**< log 2 */
- int16_t delay_request_interval; /**< log 2 */
- uint16_t message_duration; /**< time period until master stops sending the messages */
- uint16_t reserved;
- uint32_t flags;
-
-} PTP_UNICAST_CFG_SETTINGS;
-
-#define _mbg_swab_ptp_unicast_cfg_settings( _p ) \
-{ \
- _mbg_swab_ptp_clock_identity( &(_p)->gm_clock_id ); \
- _mbg_swab16( &(_p)->gm_port_id ); \
- _mbg_swab16( &(_p)->sync_interval ); \
- _mbg_swab16( &(_p)->announce_interval ); \
- _mbg_swab16( &(_p)->delay_request_interval ); \
- _mbg_swab16( &(_p)->message_duration ); \
- _mbg_swab16( &(_p)->reserved ); \
- _mbg_swab32( &(_p)->flags ); \
+ uint16_t n_supp_master; /**< number of unicast masters which can be specified */
+ int16_t sync_intv_min; /**< log2 of minimum sync interval [s] */
+ int16_t sync_intv_max; /**< log2 of maximum sync interval [s] */
+ int16_t ann_intv_min; /**< log2 of minimum announce interval [s] */
+ int16_t ann_intv_max; /**< log2 of maximum announce interval [s] */
+ int16_t delay_req_intv_min; /**< log2 of minimum delay request interval [s] */
+ int16_t delay_req_intv_max; /**< log2 of maximum delay request interval [s] */
+ uint16_t reserved_0; /**< reserved, currently always 0 */
+ uint32_t supp_flags; /**< a bit mask indicating which flags are supported */
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+
+} PTP_UC_MASTER_CFG_LIMITS;
+
+#define _mbg_swab_ptp_uc_master_cfg_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->n_supp_master ); \
+ _mbg_swab16( &(_p)->sync_intv_min ); \
+ _mbg_swab16( &(_p)->sync_intv_max ); \
+ _mbg_swab16( &(_p)->ann_intv_min ); \
+ _mbg_swab16( &(_p)->ann_intv_max ); \
+ _mbg_swab16( &(_p)->delay_req_intv_min ); \
+ _mbg_swab16( &(_p)->delay_req_intv_max ); \
+ _mbg_swab16( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
}
+/**
+ * @brief Specification of unicast masters
+ *
+ * This structure is used on a unicast slave to specify the settings of
+ * a unicast master polled by the slave. The number of unicast masters
+ * which can be specified depends on the capabilities of the slave device
+ * and is returned in PTP_UC_MASTER_CFG_LIMITS::n_supp_master.
+ */
+typedef struct
+{
+ MBG_HOSTNAME gm_host; /**< grandmaster's hostname or IP address */
+ PTP_CLOCK_ID gm_clock_id; /**< use clock ID of master port, or PTP_CLOCK_ID_WILDCARD */
+ PTP_PORT_ID gm_port_id; /**< use target port ID of master port (e.g. 135) or PTP_PORT_ID_WILDCARD */
+ int16_t sync_intv; /**< sync interval [log2 s] */
+ int16_t ann_intv; /**< announce interval [log2 s] */
+ int16_t delay_req_intv; /**< delay request interval [log2 s]*/
+ int32_t fix_offset; /**< constant time offset to be compensated [ns] */
+ uint16_t message_duration; /**< time period until master stops sending messages [s] */
+ uint16_t reserved_0; /**< reserved, currently always 0 */
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+ uint32_t flags; /**< bit masks as specified below */
+
+} PTP_UC_MASTER_SETTINGS;
+
+#define _mbg_swab_ptp_uc_master_settings( _p ) \
+{ \
+ _mbg_swab_ptp_clock_id( &(_p)->gm_clock_id ); \
+ _mbg_swab_ptp_port_id( &(_p)->gm_port_id ); \
+ _mbg_swab16( &(_p)->sync_intv ); \
+ _mbg_swab16( &(_p)->ann_intv ); \
+ _mbg_swab16( &(_p)->delay_req_intv ); \
+ _mbg_swab32( &(_p)->fix_offset ); \
+ _mbg_swab16( &(_p)->message_duration ); \
+ _mbg_swab16( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+/**
+ * @brief Specification of a certain unicast master
+ */
typedef struct
{
- PTP_UNICAST_CFG_SETTINGS settings;
+ uint32_t idx; /**< index, 0..(PTP_UC_MASTER_CFG_LIMITS::n_supp_master - 1) */
+ PTP_UC_MASTER_SETTINGS settings; /**< specification for the unicast master with that index */
- int16_t sync_interval_min; // log 2
- int16_t sync_interval_max; // log 2
- int16_t announce_interval_min; // log 2
- int16_t announce_interval_max; // log 2
- int16_t delay_request_interval_min; // log 2
- int16_t delay_request_interval_max; // log 2
+} PTP_UC_MASTER_SETTINGS_IDX;
- uint32_t supported_flags;
- uint32_t reserved;
+#define _mbg_swab_ptp_uc_master_settings_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_ptp_uc_master_settings( &(_p)->settings ); \
+}
-} PTP_UNICAST_CFG_INFO;
-#define _mbg_swab_ptp_unicast_cfg_info( _p ) \
-{ \
- _mbg_swab_ptp_unicast_cfg_settings( &(_p)->settings ); \
- _mbg_swab16( &(_p)->sync_interval_min ); \
- _mbg_swab16( &(_p)->sync_interval_max ); \
- _mbg_swab16( &(_p)->announce_interval_min ); \
- _mbg_swab16( &(_p)->announce_interval_max ); \
- _mbg_swab16( &(_p)->delay_request_interval_min ); \
- _mbg_swab16( &(_p)->delay_request_interval_max ); \
- _mbg_swab32( &(_p)->supported_flags ); \
- _mbg_swab32( &(_p)->reserved ); \
+/**
+ * @brief Capabilities and current settings of a unicast master
+ */
+typedef struct
+{
+ PTP_UC_MASTER_SETTINGS settings; /**< current settings */
+ uint32_t reserved; /**< reserved, currently always 0 */
+ uint32_t flags; /**< reserved, currently always 0 */
+
+} PTP_UC_MASTER_INFO;
+
+#define _mbg_swab_ptp_uc_master_info( _p ) \
+{ \
+ _mbg_swab_ptp_uc_master_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
}
+/**
+ * @brief Capabilities and current settings of a specific unicast master
+ */
+typedef struct
+{
+ uint32_t idx; /**< index, 0..(PTP_UC_MASTER_CFG_LIMITS::n_supp_master - 1) */
+ PTP_UC_MASTER_INFO info; /**< capabilities and current settings */
+
+} PTP_UC_MASTER_INFO_IDX;
+
+#define _mbg_swab_ptp_uc_master_info_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_ptp_uc_master_info( &(_p)->info ); \
+}
+
+
+/** @} group_ptp */
+
+
/*------------------------------------------------------------------------*/
@@ -4411,8 +5001,8 @@ typedef struct
/**
- @brief GPS UTC correction parameters
-*/
+ * @brief GPS UTC correction parameters
+ */
typedef struct
{
CSUM csum; /**< Checksum of the remaining bytes */
@@ -4543,12 +5133,11 @@ typedef struct
} NAV_ENGINE_SETTINGS;
-/* End of header body */
-
-
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
+/* End of header body */
#endif /* _GPSDEFS_H */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/lan_util.c b/src/external/bsd/meinberg/dist/mbglib/common/lan_util.c
new file mode 100755
index 0000000..03734c4
--- /dev/null
+++ b/src/external/bsd/meinberg/dist/mbglib/common/lan_util.c
@@ -0,0 +1,199 @@
+
+/**************************************************************************
+ *
+ * $Id: lan_util.c 1.1.1.3 2011/06/21 15:23:30 martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Utility functions useful for network programming.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: lan_util.c $
+ * Revision 1.1.1.3 2011/06/21 15:23:30 martin
+ * Fixed build under DOS.
+ * Revision 1.1.1.2 2011/04/20 16:08:55Z martin
+ * Revision 1.1.1.1 2011/03/04 10:33:22 martin
+ * Implemented dummy snprintf() function for environments
+ * which don't provide this.
+ * Revision 1.1 2011/03/04 10:01:32Z martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#define _LAN_UTIL
+ #include <lan_util.h>
+#undef _LAN_UTIL
+
+#include <stdio.h>
+
+
+#if defined( __BORLANDC__ ) \
+ && ( __BORLANDC__ <= 0x410 ) // BC3.1 defines 0x410 !
+
+
+#include <stdarg.h>
+
+static /*HDR*/
+int snprintf( char *s, size_t max_len, const char *fmt, ... )
+{
+ int n;
+ va_list arg_list;
+
+ va_start( arg_list, fmt );
+ n = vsprintf( s, fmt, arg_list );
+ va_end( arg_list );
+
+ return n;
+
+} // snprintf
+
+#endif
+
+
+
+/*HDR*/
+/**
+ * @brief Print a MAC ID or similar array of octets to a string.
+ *
+ * @param s The string buffer into which to print
+ * @param max_len Maximum length of the string, i.e. size of the buffer
+ * @param octets An array of octets
+ * @param num_octets The number of octets to be printed from the array
+ * @param sep The separator printed between the bytes, or 0
+ * @param info An optional string which is prepended to the output, or NULL
+ *
+ * @return The overall number of characters printed to the string
+ */
+int snprint_octets( char *s, size_t max_len, const uint8_t *octets,
+ int num_octets, char sep, const char *info )
+{
+ int n = 0;
+ int i;
+
+ if ( info )
+ n += snprintf( s, max_len, "%s", info );
+
+ for ( i = 0; i < num_octets; i++ )
+ {
+ if ( i && sep )
+ n += snprintf( &s[n], max_len - n, "%c", sep );
+
+ n += snprintf( &s[n], max_len - n, "%02X", octets[i] );
+ }
+
+ return n;
+
+} // snprint_octets
+
+
+
+/*HDR*/
+/**
+ * @brief Set a MAC ID or a similar array of bytes from a string.
+ *
+ * @param octets An array of octets to be set up
+ * @param num_octets The number of octets which can be stored
+ * @param s The string to be converted
+ *
+ * @return The overall number of octets decoded from the string
+ */
+int str_to_octets( uint8_t *octets, int num_octets, const char *s )
+{
+ char *cp = (char *) s;
+ int i;
+
+ // don't use strtok() since that functions modifies the original string
+ for ( i = 0; i < num_octets; )
+ {
+ octets[i] = (uint8_t) strtoul( cp, &cp, 16 );
+ i++;
+
+ if ( *cp == 0 )
+ break; // end of string
+
+ if ( ( *cp != MAC_SEP_CHAR ) && ( *cp != MAC_SEP_CHAR_ALT ) )
+ break; // invalid character
+
+ cp++;
+ }
+
+ return i;
+
+} // str_to_octets
+
+
+
+/*HDR*/
+/**
+ * @brief Print an IPv4 address to a dotted quad format string.
+ *
+ * @param s The string buffer into which to print
+ * @param max_len Maximum length of the string, i.e. size of the buffer
+ * @param addr The IPv4 address
+ * @param info An optional string which is prepended to the string, or NULL
+ *
+ * @return The overall number of characters printed to the string
+ */
+int snprint_ip4_addr( char *s, size_t max_len, const IP4_ADDR *addr, const char *info )
+{
+ int n = 0;
+
+ if ( info )
+ n += snprintf( s, max_len, "%s", info );
+
+ n += snprintf( &s[n], max_len - n, "%i.%i.%i.%i",
+ BYTE_OF( *addr, 3 ),
+ BYTE_OF( *addr, 2 ),
+ BYTE_OF( *addr, 1 ),
+ BYTE_OF( *addr, 0 )
+ );
+ return n;
+
+} // snprint_ip4_addr
+
+
+
+/*HDR*/
+/**
+ * @brief Convert a string to an IP4_ADDR.
+ *
+ * @param p Pointer to the IP4_ADDR variable, or NULL, in which case this
+ * function can be used to check if the string is formally correct.
+ * @param s The string to be converted
+ *
+ * @return >= 0 on success, number of characters evaluated from the input string
+ * -1 if invalid number found in string
+ * -2 if separator is not a dot '.'
+ */
+int str_to_ip4_addr( IP4_ADDR *p, const char *s )
+{
+ IP4_ADDR tmp_ip4_addr = 0;
+ char *cp;
+ int i;
+
+ for ( i = 0, cp = (char *) s; ; )
+ {
+ unsigned long ul = strtoul( cp, &cp, 10 );
+
+ if ( ul > 255 ) // invalid number
+ return -1;
+
+ tmp_ip4_addr |= ul << ( 8 * (3 - i) );
+
+ if ( ++i >= 4 )
+ break; // done
+
+ if ( *cp != '.' )
+ return -2; // invalid string format, dot expected
+
+ cp++; // skip dot
+ }
+
+ if ( p )
+ *p = tmp_ip4_addr;
+
+ return cp - (char *) s; // success
+
+} // str_to_ip4_addr
+
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/lan_util.h b/src/external/bsd/meinberg/dist/mbglib/common/lan_util.h
new file mode 100755
index 0000000..2092760
--- /dev/null
+++ b/src/external/bsd/meinberg/dist/mbglib/common/lan_util.h
@@ -0,0 +1,139 @@
+
+/**************************************************************************
+ *
+ * $Id: lan_util.h 1.1.1.2 2011/06/22 07:47:48 martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for lan_util.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: lan_util.h $
+ * Revision 1.1.1.2 2011/06/22 07:47:48 martin
+ * Cleaned up handling of pragma pack().
+ * Revision 1.1.1.1 2011/04/20 16:09:02 martin
+ * Revision 1.1 2011/03/04 10:01:32 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _LAN_UTIL_H
+#define _LAN_UTIL_H
+
+
+/* Other headers to be included */
+
+#include <gpsdefs.h>
+
+#include <stdlib.h>
+
+
+#ifdef _LAN_UTIL
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
+
+
+#if !defined( MAC_SEP_CHAR )
+ #define MAC_SEP_CHAR ':' // character used to separate octets of a MAC ID
+#endif
+
+#if !defined( MAC_SEP_CHAR_ALT )
+ #define MAC_SEP_CHAR_ALT '-' // alternate character
+#endif
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ /**
+ * @brief Print a MAC ID or similar array of octets to a string.
+ *
+ * @param s The string buffer into which to print
+ * @param max_len Maximum length of the string, i.e. size of the buffer
+ * @param octets An array of octets
+ * @param num_octets The number of octets to be printed from the array
+ * @param sep The separator printed between the bytes, or 0
+ * @param info An optional string which is prepended to the output, or NULL
+ *
+ * @return The overall number of characters printed to the string
+ */
+ int snprint_octets( char *s, size_t max_len, const uint8_t *octets, int num_octets, char sep, const char *info ) ;
+
+ /**
+ * @brief Set a MAC ID or a similar array of bytes from a string.
+ *
+ * @param octets An array of octets to be set up
+ * @param num_octets The number of octets which can be stored
+ * @param s The string to be converted
+ *
+ * @return The overall number of octets decoded from the string
+ */
+ int str_to_octets( uint8_t *octets, int num_octets, const char *s ) ;
+
+ /**
+ * @brief Print an IPv4 address to a dotted quad format string.
+ *
+ * @param s The string buffer into which to print
+ * @param max_len Maximum length of the string, i.e. size of the buffer
+ * @param addr The IPv4 address
+ * @param info An optional string which is prepended to the string, or NULL
+ *
+ * @return The overall number of characters printed to the string
+ */
+ int snprint_ip4_addr( char *s, size_t max_len, const IP4_ADDR *addr, const char *info ) ;
+
+ /**
+ * @brief Convert a string to an IP4_ADDR.
+ *
+ * @param p Pointer to the IP4_ADDR variable, or NULL, in which case this
+ * function can be used to check if the string is formally correct.
+ * @param s The string to be converted
+ *
+ * @return >= 0 on success, number of characters evaluated from the input string
+ * -1 if invalid number found in string
+ * -2 if separator is not a dot '.'
+ */
+ int str_to_ip4_addr( IP4_ADDR *p, const char *s ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
+#endif
+
+/* End of header body */
+
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _LAN_UTIL_H */
+
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/macioctl.h b/src/external/bsd/meinberg/dist/mbglib/common/macioctl.h
index c3c8a75..9c09cdc 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/macioctl.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/macioctl.h
@@ -1,22 +1,40 @@
/**************************************************************************
*
- * $Id: macioctl.h 1.33.1.16.1.1 2011/03/31 15:27:06 martin TRASH $
+ * $Id: macioctl.h 1.33.1.23 2011/07/14 14:53:58 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
* Macros used inside the IOCTL handlers of device drivers
- * for Meinberg radio clocks.
+ * for Meinberg PCI and USB devices.
*
* -----------------------------------------------------------------------
* $Log: macioctl.h $
- * Revision 1.33.1.16.1.1 2011/03/31 15:27:06 martin
- * Conditionally trying to read directly to the IOCTL buffer.
+ * Revision 1.33.1.23 2011/07/14 14:53:58 martin
+ * Modified generic IOCTL handling such that for calls requiring variable sizes
+ * a fixed request block containing input and output buffer pointers and sizes is
+ * passed down to the kernel driver. This simplifies implementation under *BSD
+ * and also works for other target systems.
+ * Revision 1.33.1.22 2011/07/06 11:19:19 martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.33.1.21 2011/06/29 10:51:16 martin
+ * Support IOCTL_DEV_HAS_PZF.
+ * Revision 1.33.1.20 2011/05/18 10:08:13 martin
+ * Re-ordered IOCTL evaluation to match ioctl_get_required_privilege()
+ * which also makes sure calls requiring lowest latency are handled first.
+ * Revision 1.33.1.19 2011/05/17 16:05:06 martin
+ * Use a single union type buffer instead of a large number of local
+ * variables in ioctl_switch().
+ * The accumulated size of all local variables required much stack
+ * space which led to problems under Windows.
+ * Revision 1.33.1.18 2011/05/17 09:37:31 martin
+ * Support PTP unicast configuration.
+ * Account for some IOCTL codes renamed to follow common naming conventions.
+ * Revision 1.33.1.17 2011/04/12 15:28:54 martin
+ * Use common mutex primitives from mbgmutex.h.
* Revision 1.33.1.16 2011/03/31 10:57:00 martin
* Revision 1.33.1.15 2011/03/31 07:32:09 martin
- *
- * --- Added comments --- martin [2011/03/31 10:41:58Z]
* This version is the same as 1.33.1.12.
* Revision 1.33.1.14 2011/03/31 07:16:34 martin
* Changes by Frank Kardel: Don't require copyin/copyout under NetBSD.
@@ -105,7 +123,7 @@
* Support mapped I/O resources.
* Revision 1.22 2008/01/17 09:28:49 daniel
* Support for memory mapped I/O under Linux and Windows.
- * Added macros _io_get_mapped_mem_address(),
+ * Added macros _io_get_mapped_mem_address(),
* _io_unmap_mapped_mem_address().
* Account for IOCTL_GET_PCI_ASIC_FEATURES
* Cleanup for PCI ASIC version.
@@ -208,32 +226,26 @@ typedef struct
} XYZs;
-#define USE_DEBUG_PORT !defined( MBG_ARCH_ARM )
-
-// OS dependent definitions
+// OS dependent primitives
#if defined( MBG_TGT_LINUX )
- #define _pcps_iob( _type, _s ) _type _s
- #define _pcps_iob_arr( _type, _s, n ) _type _s[_n]
-
- #define _pcps_iob_to_pout_size( _type, _iob, _pout, _size ) \
- if ( copy_to_user( (_type *)(_pout), &(_iob), _size ) ) \
+ #define _iob_to_pout( _piob, _pout, _size ) \
+ if ( copy_to_user( _pout, _piob, _size ) ) \
goto err_to_user;
- #define _pcps_iob_from_pin_size( _type, _iob, _pin, _size ) \
- if ( copy_from_user( &(_iob), (_type *) (_pin), _size ) ) \
+ #define _iob_from_pin( _piob, _pin, _size ) \
+ if ( copy_from_user( _piob, _pin, _size ) ) \
goto err_from_user;
#define _io_wait_pcps_sec_change( _pddev, _cmd, _type, _pout ) \
goto err_inval
- #define _io_get_mapped_mem_address( _pddev, _pout ) \
- { \
- _pcps_iob( PCPS_MAPPED_MEM, _s ); \
- _s.pfn_offset = ( pddev->rsrc_info.mem[0].start & ~PAGE_MASK ) + sizeof( PCI_ASIC ); \
- _s.len = pddev->rsrc_info.mem[0].len - sizeof( PCI_ASIC ); \
- _pcps_iob_to_pout_size( PCPS_MAPPED_MEM, _s, _pout, sizeof( PCPS_MAPPED_MEM ) ); \
+ #define _io_get_mapped_mem_address( _pddev, _pout ) \
+ { \
+ iob.mapped_mem.pfn_offset = ( pddev->rsrc_info.mem[0].start & ~PAGE_MASK ) + sizeof( PCI_ASIC ); \
+ iob.mapped_mem.len = pddev->rsrc_info.mem[0].len - sizeof( PCI_ASIC ); \
+ _iob_to_pout_var( iob.mapped_mem, _pout ); \
}
#define _io_unmap_mapped_mem_address( _pddev, _pin ) \
@@ -245,14 +257,17 @@ typedef struct
#include <sys/malloc.h>
- #define _pcps_iob( _type, _s ) _type _s
- #define _pcps_iob_arr( _type, _s, n ) _type _s[_n]
+ #define _iob_to_pout( _piob, _pout, _size ) \
+ memcpy( _pout, _piob, _size )
+
+ #define _iob_from_pin( _piob, _pin, _size ) \
+ memcpy( _piob, _pin, _size )
- #define _pcps_iob_to_pout_size( _type, _iob, _pout, _size ) \
- memcpy( (_type *)(_pout), &(_iob), _size )
+ #define _frc_iob_to_pout( _piob, _pout, _size ) \
+ copyout( _piob, _pout, _size )
- #define _pcps_iob_from_pin_size( _type, _iob, _pin, _size ) \
- memcpy( &(_iob), (_type *) (_pin), _size )
+ #define _frc_iob_from_pin( _piob, _pin, _size ) \
+ copyin( _pin, _piob, _size )
#define _io_wait_pcps_sec_change( _pddev, _cmd, _type, _pout ) \
goto err_inval
@@ -265,17 +280,14 @@ typedef struct
#elif defined( MBG_TGT_WIN32 )
- #define _pcps_iob( _type, _s ) _type _s
- #define _pcps_iob_arr( _type, _s, n ) _type _s[_n]
-
- #define _pcps_iob_to_pout_size( _type, _iob, _pout, _size ) \
- { \
- RtlCopyMemory( _pout, &_iob, _size ); \
- *ret_size = _size; \
+ #define _iob_to_pout( _piob, _pout, _size ) \
+ { \
+ RtlCopyMemory( _pout, _piob, _size ); \
+ *ret_size = _size; \
}
- #define _pcps_iob_from_pin_size( _type, _iob, _pin, _size ) \
- RtlCopyMemory( &_iob, _pin, _size );
+ #define _iob_from_pin( _piob, _pin, _size ) \
+ RtlCopyMemory( _piob, _pin, _size );
// The following macros are defined in the OS dependent code:
//
@@ -289,15 +301,25 @@ typedef struct
-#define _pcps_iob_to_pout( _type, _iob, _pout ) \
- _pcps_iob_to_pout_size( _type, _iob, _pout, sizeof( _iob ) )
+#if !defined( _frc_iob_to_pout )
+ #define _frc_iob_to_pout _iob_to_pout
+#endif
+
+#if !defined( _frc_iob_from_pin )
+ #define _frc_iob_from_pin _iob_from_pin
+#endif
+
+
+#define _iob_to_pout_var( _iob, _pout ) \
+ _iob_to_pout( &(_iob), _pout, sizeof( _iob ) )
+
+#define _iob_from_pin_var( _iob, _pin ) \
+ _iob_from_pin( &(_iob), _pin, sizeof( _iob ) )
-#define _pcps_iob_from_pin( _type, _iob, _pin ) \
- _pcps_iob_from_pin_size( _type, _iob, _pin, sizeof( _iob ) )
-// For some cards it may be unsafe to access the card while
-// interrups are enabled for the card since IRQs may during
+// For some cards it may be unsafe to access the card while
+// interrups are enabled for the card since IRQs may during
// access may mess up the interface. The macro below checks
// whether this is the case.
#define _pcps_access_is_unsafe( _pddev ) \
@@ -309,11 +331,12 @@ typedef struct
// preventing the card from being accessed from IRQ handler.
#if defined( MBG_TGT_WIN32 )
- // Under Windows.we need to save a pointer to the current
+ // Under Windows we need to save a pointer to the current
// IRP by default.
#define _pcps_sem_inc_safe( _pddev ) \
if ( _pcps_access_is_unsafe( _pddev ) ) \
goto err_busy_unsafe; \
+ \
_pcps_sem_inc( _pddev ); \
(_pddev)->irp = pIrp
@@ -325,6 +348,7 @@ typedef struct
#define _pcps_sem_inc_safe_no_irp( _pddev ) \
if ( _pcps_access_is_unsafe( _pddev ) ) \
goto err_busy_unsafe; \
+ \
_pcps_sem_inc( _pddev ); \
(_pddev)->irp = NULL
@@ -335,6 +359,7 @@ typedef struct
#define _pcps_sem_inc_safe( _pddev ) \
if ( _pcps_access_is_unsafe( _pddev ) ) \
goto err_busy_unsafe; \
+ \
_pcps_sem_inc( _pddev ); \
#endif
@@ -342,175 +367,131 @@ typedef struct
-
-// Read a data structure from a clock device.
-// Check the return code and if no error occurred,
-// copy the data to the caller's memory space.
-#define _io_read_var( _pddev, _cmd, _type, _pout ) \
-{ \
- _pcps_iob( _type, _s ); \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_read_var( _pddev, _cmd, _s ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
- \
- _pcps_iob_to_pout( _type, _s, _pout ); \
-}
+// Check a condition and go to an error handler
+// if the condition is not true.
+#define _io_chk_cond( _cond ) \
+ if ( !(_cond) ) \
+ goto err_support;
-#if 1 //##+++++
- #define _pcps_iob_x( _type, _s ) _nop_macro_fnc()
- #define _iob_addr( _s, _pout ) _pout
- #define _pcps_iob_to_pout_x( _type, _s, _pout ) _nop_macro_fnc()
-#else
- #define _pcps_iob_x( _type, _s ) _pcps_iob( _type, _s )
- #define _iob_addr( _s, _pout ) &(_s)
- #define _pcps_iob_to_pout_x( _type, _s, _pout ) _pcps_iob_to_pout( _type, _s, _pout )
-#endif
-// Read a data structure from a clock device.
+// Read a data structure from a device.
// Check the return code and if no error occurred,
// copy the data to the caller's memory space.
-#define _io_read_var_x( _pddev, _cmd, _type, _pout ) \
-{ \
- _pcps_iob_x( _type, _s ); \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_read( (_pddev), (_cmd), \
- _iob_addr( _s, _pout ), sizeof( _type ) ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
- \
- _pcps_iob_to_pout_x( _type, _s, _pout ); \
+#define _io_read_var( _pddev, _cmd, _fld, _pout ) \
+{ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = _pcps_read_var( _pddev, _cmd, iob._fld ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
+ \
+ _iob_to_pout_var( iob._fld, _pout ); \
}
-
// Retrieve a data structure from the caller's
-// memory space, write it to a clock device and
+// memory space, write it to the device and
// check the return code.
-#define _io_write_var( _pddev, _cmd, _type, _pin ) \
-{ \
- _pcps_iob( _type, _s ); \
- \
- _pcps_iob_from_pin( _type, _s, _pin ); \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_write_var( _pddev, _cmd, _s ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
+#define _io_write_var( _pddev, _cmd, _fld, _pin ) \
+{ \
+ _iob_from_pin_var( iob._fld, _pin ); \
+ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = _pcps_write_var( _pddev, _cmd, iob._fld ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
}
-// Retrieve a data structure from the caller's
-// memory space, write it to a clock device and
+// Write a command byte to the device and
// check the return code.
-#define _io_write_cmd( _pddev, _cmd ) \
-{ \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_write_byte( _pddev, _cmd ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
+#define _io_write_cmd( _pddev, _cmd ) \
+{ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = _pcps_write_byte( _pddev, _cmd ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
}
-// Check if a clock is a GPS device. If it is,
-// read GPS data with variable size from the device.
+// Check if a device supports large (GPS) data structures.
+// If it does, read GPS data of given size from the device.
// Check the return code and if no error occurred,
// copy the data to the caller's memory space.
-#define _io_read_gps( _pddev, _cmd, _type, _pout, _size ) \
-{ \
- _pcps_iob( _type, _s ); \
- \
- if ( !_pcps_ddev_has_gps_data( _pddev ) ) \
- goto err_support; \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = pcps_read_gps( _pddev, _cmd, (uchar FAR *) &_s, _size ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
- \
- _pcps_iob_to_pout_size( _type, _s, _pout, _size ); \
+#define _io_read_gps( _pddev, _cmd, _fld, _pout, _size ) \
+{ \
+ _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
+ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = pcps_read_gps( _pddev, _cmd, (uchar FAR *) &iob._fld, _size ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
+ \
+ _iob_to_pout( &iob._fld, _pout, _size ); \
}
-// Check if a clock is a GPS device. If it is,
-// read a GPS data structure from the device.
+// Check if a device supports large (GPS) data structures.
+// If it does, read a GPS data structure from the device.
// Check the return code and if no error occurred,
// copy the data to the caller's memory space.
-#define _io_read_gps_var( _pddev, _cmd, _type, _pout ) \
-{ \
- _pcps_iob( _type, _s ); \
- \
- if ( !_pcps_ddev_has_gps_data( _pddev ) ) \
- goto err_support; \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_read_gps_var( _pddev, _cmd, _s ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
- \
- _pcps_iob_to_pout( _type, _s, _pout ); \
+#define _io_read_gps_var( _pddev, _cmd, _fld, _pout ) \
+{ \
+ _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
+ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = _pcps_read_gps_var( _pddev, _cmd, iob._fld ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
+ \
+ _iob_to_pout_var( iob._fld, _pout ); \
}
-// Check if a clock is a GPS device. If it is,
-// retrieve a data structure from the caller's
-// memory space, write it to the clock device and
-// check the return code.
-#define _io_write_gps_var( _pddev, _cmd, _type, _pin ) \
-{ \
- _pcps_iob( _type, _s ); \
- \
- if ( !_pcps_ddev_has_gps_data( _pddev ) ) \
- goto err_support; \
- \
- _pcps_iob_from_pin( _type, _s, _pin ); \
- \
- _pcps_sem_inc_safe( _pddev ); \
- rc = _pcps_write_gps_var( _pddev, _cmd, _s ); \
- _pcps_sem_dec( _pddev ); \
- \
- if ( rc != MBG_SUCCESS ) \
- goto err_access; \
+// Check if a device supports large (GPS) data structures.
+// If it does, retrieve a data structure from the caller's
+// memory space, write it to the device and check
+// the return code.
+#define _io_write_gps_var( _pddev, _cmd, _fld, _pin ) \
+{ \
+ _io_chk_cond( _pcps_ddev_has_gps_data( _pddev ) ); \
+ \
+ _iob_from_pin_var( iob._fld, _pin ); \
+ \
+ _pcps_sem_inc_safe( _pddev ); \
+ rc = _pcps_write_gps_var( _pddev, _cmd, iob._fld ); \
+ _pcps_sem_dec( _pddev ); \
+ \
+ if ( rc != MBG_SUCCESS ) \
+ goto err_access; \
}
-// Check a condition an go to an error handler
-// if the condition is not true.
-#define _io_chk_cond( _cond ) \
- if ( !(_cond) ) \
- goto err_support;
-
-
// The macros below are similar to those defined above except
// that they check if a condition is true before they really
// do anything. This is used for IOCTL calls which may not
-// be supported with any type of clock device.
-#define _io_read_var_chk( _pddev, _cmd, _type, _pout, _cond ) \
-{ \
- _io_chk_cond( _cond ); \
- _io_read_var( _pddev, _cmd, _type, _pout ); \
+// be supported by every device.
+#define _io_read_var_chk( _pddev, _cmd, _fld, _pout, _cond ) \
+{ \
+ _io_chk_cond( _cond ); \
+ _io_read_var( _pddev, _cmd, _fld, _pout ); \
}
-#define _io_write_var_chk( _pddev, _cmd, _type, _pin, _cond ) \
-{ \
- _io_chk_cond( _cond ); \
- _io_write_var( _pddev, _cmd, _type, _pin ); \
+#define _io_write_var_chk( _pddev, _cmd, _fld, _pin, _cond ) \
+{ \
+ _io_chk_cond( _cond ); \
+ _io_write_var( _pddev, _cmd, _fld, _pin ); \
}
#define _io_write_cmd_chk( _pddev, _cmd, _cond ) \
@@ -519,48 +500,48 @@ typedef struct
_io_write_cmd( _pddev, _cmd ); \
}
-#define _io_read_gps_chk( _pddev, _cmd, _type, _pout, _size, _cond ) \
+#define _io_read_gps_chk( _pddev, _cmd, _fld, _pout, _size, _cond ) \
{ \
_io_chk_cond( _cond ); \
- _io_read_gps( _pddev, _cmd, _type, _pout, _size ); \
+ _io_read_gps( _pddev, _cmd, _fld, _pout, _size ); \
}
-#define _io_read_gps_var_chk( _pddev, _cmd, _type, _pout, _cond ) \
-{ \
- _io_chk_cond( _cond ); \
- _io_read_gps_var( _pddev, _cmd, _type, _pout ); \
+#define _io_read_gps_var_chk( _pddev, _cmd, _fld, _pout, _cond ) \
+{ \
+ _io_chk_cond( _cond ); \
+ _io_read_gps_var( _pddev, _cmd, _fld, _pout ); \
}
-#define _io_write_gps_var_chk( _pddev, _cmd, _type, _pin, _cond ) \
-{ \
- _io_chk_cond( _cond ); \
- _io_write_gps_var( _pddev, _cmd, _type, _pin ); \
+#define _io_write_gps_var_chk( _pddev, _cmd, _fld, _pin, _cond ) \
+{ \
+ _io_chk_cond( _cond ); \
+ _io_write_gps_var( _pddev, _cmd, _fld, _pin ); \
}
-#define _report_cond( _cond, _pout ) \
-{ \
- int retval = _cond; \
- _pcps_iob_to_pout( int, retval, _pout ); \
+#define _report_cond( _cond, _pout ) \
+{ \
+ iob.i = _cond; \
+ _iob_to_pout_var( iob.i, _pout ); \
}
-#define _mbg_dbg_set_bit( _d, _v ) \
-{ \
- mbg_dbg_data |= (_v); \
+#define _mbg_dbg_set_bit( _d, _v ) \
+{ \
+ mbg_dbg_data |= (_v); \
_mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
-#define _mbg_dbg_clr_bit( _d, _v ) \
-{ \
- mbg_dbg_data &= ~(_v); \
+#define _mbg_dbg_clr_bit( _d, _v ) \
+{ \
+ mbg_dbg_data &= ~(_v); \
_mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
-#define _mbg_dbg_clr_all( _d ) \
-{ \
- mbg_dbg_data = 0; \
+#define _mbg_dbg_clr_all( _d ) \
+{ \
+ mbg_dbg_data = 0; \
_mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
@@ -575,6 +556,76 @@ typedef struct
#endif
+typedef union
+{
+ PCPS_STATUS_PORT pcps_status_port;
+ PCPS_TIME pcps_time;
+ PCPS_STIME pcps_stime;
+ PCPS_HR_TIME pcps_hr_time;
+ PCPS_TIME_STAMP pcps_time_stamp;
+ PCPS_SERIAL pcps_serial;
+ PCPS_TZCODE pcps_tzcode;
+ PCPS_TZDL pcps_tzdl;
+ MBG_REF_OFFS mbg_ref_offs;
+ MBG_OPT_INFO mbg_opt_info;
+ MBG_OPT_SETTINGS mbg_opt_settings;
+ IRIG_INFO irig_info;
+ IRIG_SETTINGS irig_settings;
+ PCPS_UCAP_ENTRIES pcps_ucap_entries;
+ TZDL tzdl;
+ SW_REV sw_rev;
+ BVAR_STAT bvar_stat;
+ TTM ttm;
+ PORT_PARM port_parm;
+ ANT_INFO ant_info;
+ ENABLE_FLAGS enable_flags;
+ STAT_INFO stat_info;
+ GPS_CMD gps_cmd;
+ IDENT ident;
+ POS pos;
+ XYZs xyzs;
+ LLAs llas;
+ ANT_CABLE_LEN ant_cable_len;
+ PORT_SETTINGS_IDX port_settings_idx;
+ SYNTH synth;
+ SYNTH_STATE synth_state;
+ ALL_POUT_INFO all_pout_info;
+ POUT_SETTINGS_IDX pout_settings_idx;
+ ALL_STR_TYPE_INFO all_str_type_info;
+ ALL_PORT_INFO all_port_info;
+ ALL_PTP_UC_MASTER_INFO all_ptp_uc_master_info;
+ MBG_TIME_SCALE_INFO mbg_time_scale_info;
+ MBG_TIME_SCALE_SETTINGS mbg_time_scale_settings;
+ UTC utc;
+ MBG_IRIG_CTRL_BITS mbg_irig_ctrl_bits;
+ LAN_IF_INFO lan_if_info;
+ IP4_SETTINGS ip4_settings;
+ PTP_STATE ptp_state;
+ PTP_CFG_INFO ptp_cfg_info;
+ PTP_CFG_SETTINGS ptp_cfg_settings;
+ PCPS_IRIG_TIME pcps_irig_time;
+ MBG_RAW_IRIG_DATA mbg_raw_irig_data;
+ PTP_UC_MASTER_CFG_LIMITS ptp_uc_master_cfg_limits;
+ PTP_UC_MASTER_SETTINGS_IDX ptp_uc_master_settings_idx;
+ PCPS_TIME_CYCLES pcps_time_cycles;
+ PCPS_HR_TIME_CYCLES pcps_hr_time_cycles;
+ MBG_DBG_PORT mbg_dbg_port;
+ MBG_DBG_DATA mbg_dbg_data;
+ MBG_PC_CYCLES_FREQUENCY mbg_pc_cycles_frequency;
+ PCPS_TIME_STAMP_CYCLES pcps_time_stamp_cycles;
+ MBG_TIME_INFO_HRT mbg_time_info_hrt;
+ MBG_TIME_INFO_TSTAMP mbg_time_info_tstamp;
+ CORR_INFO corr_info;
+ TR_DISTANCE tr_distance;
+
+ PCPS_MAPPED_MEM mapped_mem;
+ IOCTL_GENERIC_REQ req;
+ int i;
+
+} IOCTL_BUFFER;
+
+
+
#if defined( __GNUC__ )
// Avoid "no previous prototype" with some gcc versions.
__mbg_inline
@@ -621,7 +672,7 @@ void do_get_fast_hr_timestamp_safe( PCPS_DDEV *pddev, PCPS_TIME_STAMP *p_ts )
mbg_get_pc_cycles( &cyc_1 );
#endif
- _pcps_spin_lock( &pddev->mm_lock );
+ _mbg_spin_lock_acquire( &pddev->mm_lock );
#if TEST_MM_ACCESS_64
*( (volatile uint64_t *) p_ts ) = *p;
@@ -643,7 +694,7 @@ void do_get_fast_hr_timestamp_safe( PCPS_DDEV *pddev, PCPS_TIME_STAMP *p_ts )
#endif
#endif
- _pcps_spin_unlock( &pddev->mm_lock );
+ _mbg_spin_lock_release( &pddev->mm_lock );
#if TEST_FRAC_ONLY
p_ts->sec = 0;
@@ -699,1163 +750,1101 @@ void do_get_fast_hr_timestamp_cycles_safe( PCPS_DDEV *pddev, PCPS_TIME_STAMP_CYC
{
volatile uint32_t *p = (volatile uint32_t *) pddev->mm_tstamp_addr;
- _pcps_spin_lock( &pddev->mm_lock );
+ _mbg_spin_lock_acquire( &pddev->mm_lock );
mbg_get_pc_cycles( &p_ts_cyc->cycles );
p_ts_cyc->tstamp.frac = _mbg32_to_cpu( *p++ );
p_ts_cyc->tstamp.sec = _mbg32_to_cpu( *p );
- _pcps_spin_unlock( &pddev->mm_lock );
+ _mbg_spin_lock_release( &pddev->mm_lock );
} // do_get_fast_hr_timestamp_cycles_safe
-
#if defined( __GNUC__ )
// Avoid "no previous prototype" with some gcc versions.
__mbg_inline
-int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
+int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code,
#if defined( MBG_TGT_WIN32 )
IRP *pIrp, int *ret_size, uint16_t pout_size,
#endif
void *pin, void *pout ) __attribute__((always_inline));
#endif
+/**
+ * @brief Decode an handle IOCTL commands.
+ *
+ * This function is called from the OS dependent IOCTL handlers.
+ *
+ * @param pddev Pointer to the device structure
+ * @param ioctl_code The IOCTL code to be handled
+#if defined( MBG_TGT_WIN32 )
+ * @param pIrp The IRP associated to the IOCTL call
+ * @param ret_size The number of bytes to be returned
+ * @param pout_size The size of the output buffer
+#endif
+ * @param pin The input buffer
+ * @param pout The output buffer
+ *
+ * @return MBG_SUCCESS or one of the Meinberg error codes which need to be translated
+ * by the calling function to the OS dependent error code.
+ * @return -1 for unknown IOCTL codes
+ */
__mbg_inline
-int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
+int ioctl_switch( PCPS_DDEV *pddev, unsigned int ioctl_code,
#if defined( MBG_TGT_WIN32 )
IRP *pIrp, int *ret_size, uint16_t pout_size,
#endif
void *pin, void *pout )
{
+ #if USE_DEBUG_PORT
+ MBG_PC_CYCLES cyc;
+ #endif
+ IOCTL_BUFFER iob;
+ void *p_buff_in;
+ void *p_buff_out;
+ uint8_t pcps_cmd;
int rc = MBG_SUCCESS;
+ // To provide best maintainability the sequence of cases here should match
+ // the sequence in ioctl_get_required_privilege(), which also makes sure
+ // commands requiring lowest latency are handled first.
+
switch ( ioctl_code )
{
- case IOCTL_GET_PCPS_DRVR_INFO:
- _pcps_iob_to_pout( PCPS_DRVR_INFO,
- drvr_info, pout );
- break;
+ // Commands requiring lowest latency
-
- case IOCTL_GET_PCPS_DEV:
- _pcps_iob_to_pout( PCPS_DEV, pddev->dev, pout );
+ case IOCTL_GET_FAST_HR_TIMESTAMP:
+ _io_chk_cond( _pcps_ddev_has_fast_hr_timestamp( pddev ) );
+ do_get_fast_hr_timestamp_safe( pddev, &iob.pcps_time_stamp );
+ _iob_to_pout_var( iob.pcps_time_stamp, pout );
+ rc = MBG_SUCCESS;
break;
- #if !defined( OMIT_STATUS_PORT )
- case IOCTL_GET_PCPS_STATUS_PORT:
- {
- if ( _pcps_ddev_is_usb( pddev ) )
- {
- _io_read_var( pddev, PCPS_GET_STATUS_PORT,
- PCPS_STATUS_PORT, pout );
-
- }
- else
- {
- PCPS_STATUS_PORT status =
- _pcps_ddev_read_status_port( pddev );
- _pcps_iob_to_pout( PCPS_STATUS_PORT, status, pout );
- }
+ case IOCTL_GET_PCPS_HR_TIME:
+ _io_read_var_chk( pddev, PCPS_GIVE_HR_TIME, pcps_hr_time, pout,
+ _pcps_ddev_has_hr_time( pddev ) );
break;
- }
- #endif
- case IOCTL_PCPS_GENERIC_READ:
- {
- IOCTL_GENERIC_CTL ctl;
- IOCTL_GENERIC_BUFFER *p_buff;
- int buffer_size;
+ case IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES:
+ _io_chk_cond( _pcps_ddev_has_fast_hr_timestamp( pddev ) );
+ do_get_fast_hr_timestamp_cycles_safe( pddev, &iob.pcps_time_stamp_cycles );
+ _iob_to_pout_var( iob.pcps_time_stamp_cycles, pout );
+ rc = MBG_SUCCESS;
+ break;
- _pcps_iob_from_pin( IOCTL_GENERIC_CTL, ctl, pin );
- buffer_size = sizeof( ctl ) + ctl.data_size_out;
- p_buff = _pcps_kmalloc( buffer_size );
-
- if ( p_buff == NULL )
- goto err_no_mem;
+ case IOCTL_GET_PCPS_HR_TIME_CYCLES:
_pcps_sem_inc_safe( pddev );
- rc = _pcps_read( pddev, (uint8_t) ctl.info,
- p_buff->data,
- (uint8_t) ctl.data_size_out );
+ rc = _pcps_read_var( pddev, PCPS_GIVE_HR_TIME, iob.pcps_hr_time_cycles.t );
+ iob.pcps_hr_time_cycles.cycles = pddev->acc_cycles;
_pcps_sem_dec( pddev );
- if ( rc == MBG_SUCCESS )
- {
- p_buff->ctl = ctl;
- _pcps_iob_to_pout_size( uint8_t, *p_buff, pout,
- buffer_size );
- }
-
- _pcps_kfree( p_buff, buffer_size );
-
if ( rc != MBG_SUCCESS )
goto err_access;
+ _iob_to_pout_var( iob.pcps_hr_time_cycles, pout );
break;
- }
- case IOCTL_PCPS_GENERIC_WRITE:
- {
- IOCTL_GENERIC_CTL ctl;
- IOCTL_GENERIC_BUFFER *p_buff;
- int buffer_size;
+ case IOCTL_GET_PCPS_UCAP_EVENT:
+ _io_read_var_chk( pddev, PCPS_GIVE_UCAP_EVENT, pcps_hr_time,
+ pout, _pcps_ddev_has_ucap( pddev ) );
+ break;
- _pcps_iob_from_pin( IOCTL_GENERIC_CTL, ctl, pin );
- buffer_size = sizeof( ctl ) + ctl.data_size_in;
- p_buff = _pcps_kmalloc( buffer_size );
- if ( p_buff == NULL )
- goto err_no_mem;
+ // Other low latency commands
+
+ case IOCTL_GET_PCPS_TIME:
+ _io_read_var( pddev, PCPS_GIVE_TIME_NOCLEAR, pcps_time, pout );
+ break;
- _pcps_iob_from_pin_size( uint8_t, *p_buff, pin,
- buffer_size );
+ case IOCTL_GET_PCPS_TIME_CYCLES:
_pcps_sem_inc_safe( pddev );
- rc = pcps_write( pddev, (uint8_t) ctl.info,
- p_buff->data,
- (uint8_t) ctl.data_size_in );
+ rc = _pcps_read_var( pddev, PCPS_GIVE_TIME_NOCLEAR, iob.pcps_time_cycles.t );
+ if ( _pcps_ddev_is_usb( pddev ) )
+ iob.pcps_time_cycles.cycles = pddev->acc_cycles;
+ else
+ mbg_get_pc_cycles( &iob.pcps_time_cycles.cycles );
_pcps_sem_dec( pddev );
- _pcps_kfree( p_buff, buffer_size );
-
if ( rc != MBG_SUCCESS )
goto err_access;
+ _iob_to_pout_var( iob.pcps_time_cycles, pout );
break;
- }
-
- case IOCTL_PCPS_GENERIC_READ_GPS:
- {
- IOCTL_GENERIC_CTL ctl;
- IOCTL_GENERIC_BUFFER *p_buff;
- int buffer_size;
-
- _pcps_iob_from_pin( IOCTL_GENERIC_CTL, ctl, pin );
- buffer_size = sizeof( ctl ) + ctl.data_size_out;
- p_buff = _pcps_kmalloc( buffer_size );
-
- if ( p_buff == NULL )
- goto err_no_mem;
-
- _pcps_sem_inc_safe( pddev );
- rc = pcps_read_gps( pddev, (uint8_t) ctl.info,
- p_buff->data,
- (uint16_t) ctl.data_size_out );
- _pcps_sem_dec( pddev );
- if ( rc == MBG_SUCCESS )
+ #if !defined( OMIT_STATUS_PORT )
+ case IOCTL_GET_PCPS_STATUS_PORT:
+ if ( _pcps_ddev_is_usb( pddev ) )
{
- p_buff->ctl = ctl;
- _pcps_iob_to_pout_size( uint8_t, *p_buff, pout,
- buffer_size );
+ _io_read_var( pddev, PCPS_GET_STATUS_PORT, pcps_status_port, pout );
}
+ else
+ {
+ iob.pcps_status_port = _pcps_ddev_read_status_port( pddev );
+ _iob_to_pout_var( iob.pcps_status_port, pout );
+ }
+ break;
+ #endif
- _pcps_kfree( p_buff, buffer_size );
- if ( rc != MBG_SUCCESS )
- goto err_access;
+ case IOCTL_GET_PCPS_TIME_SEC_CHANGE:
+ _io_wait_pcps_sec_change( pddev, PCPS_GIVE_TIME, PCPS_TIME, pout );
+ break;
+
+ case IOCTL_GET_GPS_TIME:
+ _io_read_gps_var( pddev, PC_GPS_TIME, ttm, pout );
break;
- }
- case IOCTL_PCPS_GENERIC_WRITE_GPS:
- {
- IOCTL_GENERIC_CTL ctl;
- IOCTL_GENERIC_BUFFER *p_buff;
- int buffer_size;
+ case IOCTL_GET_GPS_UCAP:
+ _io_read_gps_var( pddev, PC_GPS_UCAP, ttm, pout );
+ break;
- _pcps_iob_from_pin( IOCTL_GENERIC_CTL, ctl, pin );
- buffer_size = sizeof( ctl ) + ctl.data_size_in;
- p_buff = _pcps_kmalloc( buffer_size );
- if ( p_buff == NULL )
- goto err_no_mem;
+ case IOCTL_GET_TIME_INFO_HRT:
+ _io_chk_cond( _pcps_ddev_has_hr_time( pddev ) );
- _pcps_iob_from_pin_size( uint8_t, *p_buff, pin,
- buffer_size );
+ mbg_get_pc_cycles( &iob.mbg_time_info_hrt.sys_time_cycles.cyc_before );
+ mbg_get_sys_time( &iob.mbg_time_info_hrt.sys_time_cycles.sys_time );
+ mbg_get_pc_cycles( &iob.mbg_time_info_hrt.sys_time_cycles.cyc_after );
_pcps_sem_inc_safe( pddev );
- rc = pcps_write_gps( pddev, (uint8_t) ctl.info,
- p_buff->data,
- (uint8_t) ctl.data_size_in );
+ rc = _pcps_read_var( pddev, PCPS_GIVE_HR_TIME, iob.mbg_time_info_hrt.ref_hr_time_cycles.t );
+ iob.mbg_time_info_hrt.ref_hr_time_cycles.cycles = pddev->acc_cycles;
_pcps_sem_dec( pddev );
- _pcps_kfree( p_buff, buffer_size );
-
if ( rc != MBG_SUCCESS )
goto err_access;
+ _iob_to_pout_var( iob.mbg_time_info_hrt, pout );
break;
- }
- case IOCTL_GET_PCPS_TIME:
- _io_read_var_x( pddev, PCPS_GIVE_TIME_NOCLEAR,
- PCPS_TIME, pout );
- break;
+ case IOCTL_GET_TIME_INFO_TSTAMP:
+ _io_chk_cond( _pcps_ddev_has_fast_hr_timestamp( pddev ) );
+ mbg_get_pc_cycles( &iob.mbg_time_info_tstamp.sys_time_cycles.cyc_before );
+ mbg_get_sys_time( &iob.mbg_time_info_tstamp.sys_time_cycles.sys_time );
+ mbg_get_pc_cycles( &iob.mbg_time_info_tstamp.sys_time_cycles.cyc_after );
- case IOCTL_SET_PCPS_TIME:
- _io_write_var_chk( pddev, PCPS_SET_TIME,
- PCPS_STIME, pin,
- _pcps_ddev_can_set_time( pddev ) );
+ do_get_fast_hr_timestamp_cycles_safe( pddev, &iob.mbg_time_info_tstamp.ref_tstamp_cycles );
+ rc = MBG_SUCCESS;
+
+ _iob_to_pout_var( iob.mbg_time_info_tstamp, pout );
break;
- case IOCTL_GET_PCPS_SYNC_TIME:
- _io_read_var_chk( pddev, PCPS_GIVE_SYNC_TIME,
- PCPS_TIME, pout,
- _pcps_ddev_has_sync_time( pddev ) );
+ // Commands returning public status information
+
+ case IOCTL_GET_PCPS_DRVR_INFO:
+ _iob_to_pout_var( drvr_info, pout );
break;
- case IOCTL_GET_PCPS_TIME_SEC_CHANGE:
- _io_wait_pcps_sec_change( pddev, PCPS_GIVE_TIME,
- PCPS_TIME, pout );
+ case IOCTL_GET_PCPS_DEV:
+ _iob_to_pout_var( pddev->dev, pout );
break;
- case IOCTL_GET_PCPS_HR_TIME:
- _io_read_var_chk( pddev, PCPS_GIVE_HR_TIME,
- PCPS_HR_TIME, pout,
- _pcps_ddev_has_hr_time( pddev ) );
+ case IOCTL_GET_PCPS_SYNC_TIME:
+ _io_read_var_chk( pddev, PCPS_GIVE_SYNC_TIME, pcps_time,
+ pout, _pcps_ddev_has_sync_time( pddev ) );
break;
- case IOCTL_SET_PCPS_EVENT_TIME:
- _io_write_var_chk( pddev, PCPS_SET_EVENT_TIME,
- PCPS_TIME_STAMP, pin,
- _pcps_ddev_has_event_time( pddev ) );
+ case IOCTL_GET_GPS_SW_REV:
+ _io_read_gps_var( pddev, PC_GPS_SW_REV, sw_rev, pout );
break;
- case IOCTL_GET_PCPS_SERIAL:
- _io_read_var( pddev, PCPS_GET_SERIAL,
- PCPS_SERIAL, pout );
+ case IOCTL_GET_GPS_BVAR_STAT:
+ _io_read_gps_var( pddev, PC_GPS_BVAR_STAT, bvar_stat, pout );
break;
- case IOCTL_SET_PCPS_SERIAL:
- _io_write_var( pddev, PCPS_SET_SERIAL,
- PCPS_SERIAL, pin );
+ case IOCTL_GET_GPS_ANT_INFO:
+ _io_read_gps_var( pddev, PC_GPS_ANT_INFO, ant_info, pout );
break;
- case IOCTL_GET_PCPS_TZCODE:
- _io_read_var_chk( pddev, PCPS_GET_TZCODE,
- PCPS_TZCODE, pout,
- _pcps_ddev_has_tzcode( pddev ) );
+ case IOCTL_GET_GPS_STAT_INFO:
+ _io_read_gps_var( pddev, PC_GPS_STAT_INFO, stat_info, pout );
break;
- case IOCTL_SET_PCPS_TZCODE:
- _io_write_var_chk( pddev, PCPS_SET_TZCODE,
- PCPS_TZCODE, pin,
- _pcps_ddev_has_tzcode( pddev ) );
+ case IOCTL_GET_GPS_IDENT:
+ _io_read_gps_var( pddev, PC_GPS_IDENT, ident, pout );
break;
- case IOCTL_GET_PCPS_TZDL:
- _io_read_var_chk( pddev, PCPS_GET_PCPS_TZDL,
- PCPS_TZDL, pout,
- _pcps_ddev_has_pcps_tzdl( pddev ) );
+ case IOCTL_GET_GPS_RECEIVER_INFO:
+ _io_chk_cond( _pcps_ddev_has_receiver_info( pddev ) );
+ // Just return the saved RECEIVER_INFO ...
+ _iob_to_pout_var( pddev->ri, pout );
break;
- case IOCTL_SET_PCPS_TZDL:
- _io_write_var_chk( pddev, PCPS_SET_PCPS_TZDL,
- PCPS_TZDL, pin,
- _pcps_ddev_has_pcps_tzdl( pddev ) );
+ case IOCTL_GET_PCI_ASIC_VERSION:
+ _io_chk_cond( _pcps_ddev_has_asic_version( pddev ) );
+ _iob_to_pout_var( pddev->raw_asic_version, pout );
+ rc = MBG_SUCCESS;
break;
- case IOCTL_GET_REF_OFFS:
- _io_read_var_chk( pddev, PCPS_GET_REF_OFFS,
- MBG_REF_OFFS, pout,
- _pcps_ddev_has_ref_offs( pddev ) );
+ case IOCTL_GET_SYNTH_STATE:
+ _io_read_var_chk( pddev, PCPS_GET_SYNTH_STATE, synth_state,
+ pout, _pcps_ddev_has_synth( pddev ) );
break;
- case IOCTL_SET_REF_OFFS:
- _io_write_var_chk( pddev, PCPS_SET_REF_OFFS,
- MBG_REF_OFFS, pin,
- _pcps_ddev_has_ref_offs( pddev ) );
+ case IOCTL_GET_PCPS_UCAP_ENTRIES:
+ _io_read_var_chk( pddev, PCPS_GIVE_UCAP_ENTRIES, pcps_ucap_entries,
+ pout, _pcps_ddev_has_ucap( pddev ) );
break;
- case IOCTL_GET_MBG_OPT_INFO:
- _io_read_var_chk( pddev, PCPS_GET_OPT_INFO,
- MBG_OPT_INFO, pout,
- _pcps_ddev_has_opt_flags( pddev ) );
+ case IOCTL_GET_PCI_ASIC_FEATURES:
+ _io_chk_cond( _pcps_ddev_has_asic_features( pddev ) );
+ _iob_to_pout_var( pddev->asic_features, pout );
+ rc = MBG_SUCCESS;
break;
- case IOCTL_SET_MBG_OPT_SETTINGS:
- _io_write_var_chk( pddev, PCPS_SET_OPT_SETTINGS,
- MBG_OPT_SETTINGS, pin,
- _pcps_ddev_has_opt_flags( pddev ) );
+ case IOCTL_GET_IRQ_STAT_INFO:
+ _iob_to_pout_var( pddev->irq_stat_info, pout );
+ rc = MBG_SUCCESS;
break;
- case IOCTL_GET_PCPS_IRIG_RX_INFO:
- _io_read_var_chk( pddev, PCPS_GET_IRIG_RX_INFO,
- IRIG_INFO, pout,
- _pcps_ddev_is_irig_rx( pddev ) );
+ case IOCTL_GET_CYCLES_FREQUENCY:
+ mbg_get_pc_cycles_frequency( &iob.mbg_pc_cycles_frequency );
+ _iob_to_pout_var( iob.mbg_pc_cycles_frequency, pout );
+ rc = MBG_SUCCESS;
break;
- case IOCTL_SET_PCPS_IRIG_RX_SETTINGS:
- _io_write_var_chk( pddev, PCPS_SET_IRIG_RX_SETTINGS,
- IRIG_SETTINGS, pin,
- _pcps_ddev_is_irig_rx( pddev ) );
+ case IOCTL_GET_IRIG_CTRL_BITS:
+ _io_read_var_chk( pddev, PCPS_GET_IRIG_CTRL_BITS, mbg_irig_ctrl_bits,
+ pout, _pcps_ddev_has_irig_ctrl_bits( pddev ) );
break;
- case IOCTL_PCPS_CLR_UCAP_BUFF:
- _io_write_cmd_chk( pddev, PCPS_CLR_UCAP_BUFF,
- _pcps_ddev_can_clr_ucap_buff( pddev ) );
+ case IOCTL_GET_IP4_STATE:
+ _io_read_gps_var_chk( pddev, PC_GPS_IP4_STATE, ip4_settings,
+ pout, _pcps_ddev_has_lan_intf( pddev ) );
break;
- case IOCTL_GET_PCPS_UCAP_ENTRIES:
- _io_read_var_chk( pddev, PCPS_GIVE_UCAP_ENTRIES,
- PCPS_UCAP_ENTRIES, pout,
- _pcps_ddev_has_ucap( pddev ) );
+ case IOCTL_GET_PTP_STATE:
+ _io_read_gps_var_chk( pddev, PC_GPS_PTP_STATE, ptp_state,
+ pout, _pcps_ddev_has_ptp( pddev ) );
break;
- case IOCTL_GET_PCPS_UCAP_EVENT:
- _io_read_var_chk( pddev, PCPS_GIVE_UCAP_EVENT,
- PCPS_HR_TIME, pout,
- _pcps_ddev_has_ucap( pddev ) );
+ case IOCTL_GET_CORR_INFO:
+ _io_read_var_chk( pddev, PCPS_GET_CORR_INFO, corr_info,
+ pout, _pcps_ddev_has_corr_info( pddev ) );
break;
- /* slow read/write operations with GPS data */
+ // Commands returning device capabilities and features
- case IOCTL_GET_GPS_TZDL:
- _io_read_gps_var( pddev, PC_GPS_TZDL, TZDL, pout );
+ case IOCTL_DEV_IS_GPS:
+ _report_cond( _pcps_ddev_is_gps( pddev ), pout );
break;
- case IOCTL_SET_GPS_TZDL:
- _io_write_gps_var( pddev, PC_GPS_TZDL, TZDL, pin );
+ case IOCTL_DEV_IS_DCF:
+ _report_cond( _pcps_ddev_is_dcf( pddev ), pout );
break;
- case IOCTL_GET_GPS_SW_REV:
- _io_read_gps_var( pddev, PC_GPS_SW_REV,
- SW_REV, pout );
+ case IOCTL_DEV_IS_MSF:
+ _report_cond( _pcps_ddev_is_msf( pddev ), pout );
break;
- case IOCTL_GET_GPS_BVAR_STAT:
- _io_read_gps_var( pddev, PC_GPS_BVAR_STAT,
- BVAR_STAT, pout );
+ case IOCTL_DEV_IS_WWVB:
+ _report_cond( _pcps_ddev_is_wwvb( pddev ), pout );
break;
- case IOCTL_GET_GPS_TIME:
- _io_read_gps_var( pddev, PC_GPS_TIME, TTM, pout );
+ case IOCTL_DEV_IS_LWR:
+ _report_cond( _pcps_ddev_is_lwr( pddev ), pout );
break;
- case IOCTL_SET_GPS_TIME:
- _io_write_gps_var( pddev, PC_GPS_TIME, TTM, pin );
+ case IOCTL_DEV_IS_IRIG_RX:
+ _report_cond( _pcps_ddev_is_irig_rx( pddev ), pout );
break;
- case IOCTL_GET_GPS_PORT_PARM:
- _io_read_gps_var( pddev, PC_GPS_PORT_PARM,
- PORT_PARM, pout );
+ case IOCTL_DEV_HAS_HR_TIME:
+ _report_cond( _pcps_ddev_has_hr_time( pddev ), pout );
break;
- case IOCTL_SET_GPS_PORT_PARM:
- _io_write_gps_var( pddev, PC_GPS_PORT_PARM,
- PORT_PARM, pin );
+ case IOCTL_DEV_HAS_CAB_LEN:
+ _report_cond( _pcps_ddev_has_cab_len( pddev ), pout );
break;
- case IOCTL_GET_GPS_ANT_INFO:
- _io_read_gps_var( pddev, PC_GPS_ANT_INFO,
- ANT_INFO, pout );
+ case IOCTL_DEV_HAS_TZDL:
+ _report_cond( _pcps_ddev_has_tzdl( pddev ), pout );
break;
- case IOCTL_GET_GPS_UCAP:
- _io_read_gps_var( pddev, PC_GPS_UCAP, TTM, pout );
+ case IOCTL_DEV_HAS_PCPS_TZDL:
+ _report_cond( _pcps_ddev_has_pcps_tzdl( pddev ), pout );
break;
- case IOCTL_GET_GPS_ENABLE_FLAGS:
- _io_read_gps_var( pddev, PC_GPS_ENABLE_FLAGS,
- ENABLE_FLAGS, pout );
+ case IOCTL_DEV_HAS_TZCODE:
+ _report_cond( _pcps_ddev_has_tzcode( pddev ), pout );
break;
- case IOCTL_SET_GPS_ENABLE_FLAGS:
- _io_write_gps_var( pddev, PC_GPS_ENABLE_FLAGS,
- ENABLE_FLAGS, pin );
+ case IOCTL_DEV_HAS_TZ:
+ _report_cond( _pcps_ddev_has_tz( pddev ), pout );
break;
- case IOCTL_GET_GPS_STAT_INFO:
- _io_read_gps_var( pddev, PC_GPS_STAT_INFO,
- STAT_INFO, pout );
+ case IOCTL_DEV_HAS_EVENT_TIME:
+ _report_cond( _pcps_ddev_has_event_time( pddev ), pout );
break;
- case IOCTL_SET_GPS_CMD:
- _io_write_gps_var( pddev, PC_GPS_CMD,
- GPS_CMD, pin );
+ case IOCTL_DEV_HAS_RECEIVER_INFO:
+ _report_cond( _pcps_ddev_has_receiver_info( pddev ), pout );
break;
- case IOCTL_GET_GPS_IDENT:
- _io_read_gps_var( pddev, PC_GPS_IDENT,
- IDENT, pout );
+ case IOCTL_DEV_CAN_CLR_UCAP_BUFF:
+ _report_cond( _pcps_ddev_can_clr_ucap_buff( pddev ), pout );
break;
- case IOCTL_GET_GPS_POS:
- _io_read_gps_var( pddev, PC_GPS_POS,
- POS, pout );
+ case IOCTL_DEV_HAS_UCAP:
+ _report_cond( _pcps_ddev_has_ucap( pddev ), pout );
break;
- case IOCTL_SET_GPS_POS_XYZ:
- _io_write_gps_var( pddev, PC_GPS_POS_XYZ,
- XYZs, pin );
+ case IOCTL_DEV_HAS_IRIG_TX:
+ _report_cond( _pcps_ddev_has_irig_tx( pddev ), pout );
break;
- case IOCTL_SET_GPS_POS_LLA:
- _io_write_gps_var( pddev, PC_GPS_POS_LLA,
- LLAs, pin );
+ case IOCTL_DEV_HAS_SERIAL_HS:
+ _report_cond( _pcps_ddev_has_serial_hs( pddev ), pout );
break;
- case IOCTL_GET_GPS_ANT_CABLE_LEN:
- _io_read_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN,
- ANT_CABLE_LEN, pout,
- _pcps_ddev_has_cab_len( pddev ) );
+ case IOCTL_DEV_HAS_SIGNAL:
+ _report_cond( _pcps_ddev_has_signal( pddev ), pout );
break;
- case IOCTL_SET_GPS_ANT_CABLE_LEN:
- _io_write_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN,
- ANT_CABLE_LEN, pin,
- _pcps_ddev_has_cab_len( pddev ) );
+ case IOCTL_DEV_HAS_MOD:
+ _report_cond( _pcps_ddev_has_mod( pddev ), pout );
break;
- case IOCTL_GET_GPS_RECEIVER_INFO:
- _io_chk_cond( _pcps_ddev_has_receiver_info( pddev ) );
- // Just copy the saved RECEIVER_INFO ...
- _pcps_iob_to_pout_size( RECEIVER_INFO, pddev->ri, pout,
- sizeof( RECEIVER_INFO ) );
+ case IOCTL_DEV_HAS_IRIG:
+ _report_cond( _pcps_ddev_has_irig( pddev ), pout );
break;
- #if _MBG_SUPP_VAR_ACC_SIZE
- case IOCTL_GET_GPS_ALL_STR_TYPE_INFO:
- _io_read_gps_chk( pddev, PC_GPS_ALL_STR_TYPE_INFO,
- ALL_STR_TYPE_INFO, pout, pout_size,
- _pcps_ddev_has_receiver_info( pddev ) );
+ case IOCTL_DEV_HAS_REF_OFFS:
+ _report_cond( _pcps_ddev_has_ref_offs( pddev ), pout );
break;
- #endif
- #if _MBG_SUPP_VAR_ACC_SIZE
- case IOCTL_GET_GPS_ALL_PORT_INFO:
- _io_read_gps_chk( pddev, PC_GPS_ALL_PORT_INFO,
- ALL_PORT_INFO, pout, pout_size,
- _pcps_ddev_has_receiver_info( pddev ) );
+ case IOCTL_DEV_HAS_OPT_FLAGS:
+ _report_cond( _pcps_ddev_has_opt_flags( pddev ), pout );
break;
- #endif
- case IOCTL_SET_GPS_PORT_SETTINGS_IDX:
- _io_write_gps_var_chk( pddev, PC_GPS_PORT_SETTINGS_IDX,
- PORT_SETTINGS_IDX, pin,
- _pcps_ddev_has_receiver_info( pddev ) );
+ case IOCTL_DEV_HAS_GPS_DATA:
+ _report_cond( _pcps_ddev_has_gps_data( pddev ), pout );
break;
- case IOCTL_GET_PCI_ASIC_VERSION:
- _io_chk_cond( _pcps_ddev_has_asic_version( pddev ) );
- {
- _pcps_iob( PCI_ASIC_VERSION, _s );
+ case IOCTL_DEV_HAS_SYNTH:
+ _report_cond( _pcps_ddev_has_synth( pddev ), pout );
+ break;
- _s = pddev->raw_asic_version;
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout( PCI_ASIC_VERSION, _s, pout );
- }
+ case IOCTL_DEV_HAS_GENERIC_IO:
+ _report_cond( _pcps_ddev_has_generic_io( pddev ), pout );
break;
- case IOCTL_GET_PCPS_TIME_CYCLES:
- {
- _pcps_iob( PCPS_TIME_CYCLES, _s );
-
- _pcps_sem_inc_safe( pddev );
- rc = _pcps_read_var( pddev, PCPS_GIVE_TIME_NOCLEAR,
- _s.t );
- if ( _pcps_ddev_is_usb( pddev ) )
- _s.cycles =(pddev)->acc_cycles;
- else
- mbg_get_pc_cycles( &(_s).cycles );
- _pcps_sem_dec( pddev );
+ case IOCTL_DEV_HAS_PCI_ASIC_FEATURES:
+ _report_cond( _pcps_ddev_has_asic_features( pddev ), pout );
+ break;
- if ( rc != MBG_SUCCESS )
- goto err_access;
- _pcps_iob_to_pout( PCPS_TIME_CYCLES, _s, pout );
- }
+ case IOCTL_DEV_HAS_PCI_ASIC_VERSION:
+ _report_cond( _pcps_ddev_has_asic_version( pddev ), pout );
break;
- case IOCTL_GET_PCPS_HR_TIME_CYCLES:
- {
- _pcps_iob( PCPS_HR_TIME_CYCLES, _s );
-
- _pcps_sem_inc_safe( pddev );
- rc = _pcps_read_var( pddev, PCPS_GIVE_HR_TIME,
- _s.t );
- _s.cycles =(pddev)->acc_cycles;
- _pcps_sem_dec( pddev );
+ case IOCTL_DEV_HAS_FAST_HR_TIMESTAMP:
+ _report_cond( _pcps_ddev_has_fast_hr_timestamp( pddev ), pout );
+ break;
- if ( rc != MBG_SUCCESS )
- goto err_access;
- _pcps_iob_to_pout( PCPS_HR_TIME_CYCLES, _s, pout );
- }
+ case IOCTL_DEV_HAS_GPS_TIME_SCALE:
+ _report_cond( _pcps_ddev_has_time_scale( pddev ), pout );
break;
- case IOCTL_GET_PCPS_IRIG_TX_INFO:
- {
- /* This is a workaround for GPS169PCIs with early */
- /* firmware versions. See RCS log for details. */
- uint8_t pcps_cmd = PCPS_GET_IRIG_TX_INFO;
+ case IOCTL_DEV_HAS_GPS_UTC_PARM:
+ _report_cond( _pcps_ddev_has_utc_parm( pddev ), pout );
+ break;
- if ( _pcps_ddev_requires_irig_workaround( pddev ) )
- {
- pcps_cmd = PCPS_GET_IRIG_RX_INFO;
- _mbgddmsg_1( MBG_DBG_INFO,
- "%s: workaround for GPS169PCI \"get IRIG TX cfg\"",
- pcps_driver_name );
- }
- _io_read_var_chk( pddev, pcps_cmd, IRIG_INFO, pout,
- _pcps_ddev_has_irig_tx( pddev ) );
- }
+ case IOCTL_DEV_HAS_IRIG_CTRL_BITS:
+ _report_cond( _pcps_ddev_has_irig_ctrl_bits( pddev ), pout );
break;
- case IOCTL_SET_PCPS_IRIG_TX_SETTINGS:
- {
- /* This is a workaround for GPS169PCIs with early */
- /* firmware versions. See RCS log for details. */
- uint8_t pcps_cmd = PCPS_SET_IRIG_TX_SETTINGS;
+ case IOCTL_DEV_HAS_LAN_INTF:
+ _report_cond( _pcps_ddev_has_lan_intf( pddev ), pout );
+ break;
- if ( _pcps_ddev_requires_irig_workaround( pddev ) )
- {
- pcps_cmd = PCPS_SET_IRIG_RX_SETTINGS;
- _mbgddmsg_1( MBG_DBG_INFO,
- "%s: workaround for GPS169PCI \"set IRIG TX cfg\"",
- pcps_driver_name );
- }
- _io_write_var_chk( pddev, pcps_cmd,
- IRIG_SETTINGS, pin,
- _pcps_ddev_has_irig_tx( pddev ) );
- }
+ case IOCTL_DEV_IS_PTP:
+ _report_cond( _pcps_ddev_is_ptp( pddev ), pout );
break;
- case IOCTL_GET_SYNTH:
- _io_read_var_chk( pddev, PCPS_GET_SYNTH,
- SYNTH, pout,
- _pcps_ddev_has_synth( pddev ) );
+ case IOCTL_DEV_HAS_PTP:
+ _report_cond( _pcps_ddev_has_ptp( pddev ), pout );
break;
- case IOCTL_SET_SYNTH:
- _io_write_var_chk( pddev, PCPS_SET_SYNTH,
- SYNTH, pin,
- _pcps_ddev_has_synth( pddev ) );
+ case IOCTL_DEV_HAS_IRIG_TIME:
+ _report_cond( _pcps_ddev_has_irig_time( pddev ), pout );
break;
- case IOCTL_DEV_IS_GPS:
- _report_cond( _pcps_ddev_is_gps( pddev ), pout );
+ case IOCTL_DEV_HAS_RAW_IRIG_DATA:
+ _report_cond( _pcps_ddev_has_raw_irig_data( pddev ), pout );
break;
- case IOCTL_DEV_IS_DCF:
- _report_cond( _pcps_ddev_is_dcf( pddev ), pout );
+ case IOCTL_DEV_HAS_PTP_UNICAST:
+ _report_cond( _pcps_ddev_has_ptp_unicast( pddev ), pout );
break;
- case IOCTL_DEV_IS_IRIG_RX:
- _report_cond( _pcps_ddev_is_irig_rx( pddev ), pout );
+ case IOCTL_DEV_HAS_PZF:
+ _report_cond( _pcps_ddev_has_pzf( pddev ), pout );
break;
- case IOCTL_DEV_HAS_HR_TIME:
- _report_cond( _pcps_ddev_has_hr_time( pddev ), pout );
+ case IOCTL_DEV_HAS_CORR_INFO:
+ _report_cond( _pcps_ddev_has_corr_info( pddev ), pout );
break;
- case IOCTL_DEV_HAS_CAB_LEN:
- _report_cond( _pcps_ddev_has_cab_len( pddev ), pout );
+ case IOCTL_DEV_HAS_TR_DISTANCE:
+ _report_cond( _pcps_ddev_has_tr_distance( pddev ), pout );
break;
- case IOCTL_DEV_HAS_TZDL:
- _report_cond( _pcps_ddev_has_tzdl( pddev ), pout );
+ // 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:
+ _io_write_cmd_chk( pddev, PCPS_CLR_UCAP_BUFF,
+ _pcps_ddev_can_clr_ucap_buff( pddev ) );
break;
- case IOCTL_DEV_HAS_PCPS_TZDL:
- _report_cond( _pcps_ddev_has_pcps_tzdl( pddev ), pout );
+ case IOCTL_SET_PCPS_EVENT_TIME:
+ _io_write_var_chk( pddev, PCPS_SET_EVENT_TIME,
+ pcps_time_stamp, pin,
+ _pcps_ddev_has_event_time( pddev ) );
break;
- case IOCTL_DEV_HAS_TZCODE:
- _report_cond( _pcps_ddev_has_tzcode( pddev ), pout );
+ // Status information which may not be available for everybody
+
+ case IOCTL_GET_GPS_POS:
+ _io_read_gps_var( pddev, PC_GPS_POS, pos, pout );
break;
- case IOCTL_DEV_HAS_TZ:
- _report_cond( _pcps_ddev_has_tz( pddev ), pout );
+ // Codes reading device configuration
+
+ case IOCTL_GET_PCPS_SERIAL:
+ _io_read_var( pddev, PCPS_GET_SERIAL, pcps_serial, pout );
break;
- case IOCTL_DEV_HAS_EVENT_TIME:
- _report_cond( _pcps_ddev_has_event_time( pddev ), pout );
+ case IOCTL_GET_PCPS_TZCODE:
+ _io_read_var_chk( pddev, PCPS_GET_TZCODE, pcps_tzcode, pout,
+ _pcps_ddev_has_tzcode( pddev ) );
break;
- case IOCTL_DEV_HAS_RECEIVER_INFO:
- _report_cond( _pcps_ddev_has_receiver_info( pddev ), pout );
+ case IOCTL_GET_PCPS_TZDL:
+ _io_read_var_chk( pddev, PCPS_GET_PCPS_TZDL, pcps_tzdl, pout,
+ _pcps_ddev_has_pcps_tzdl( pddev ) );
break;
- case IOCTL_DEV_CAN_CLR_UCAP_BUFF:
- _report_cond( _pcps_ddev_can_clr_ucap_buff( pddev ), pout );
+ case IOCTL_GET_REF_OFFS:
+ _io_read_var_chk( pddev, PCPS_GET_REF_OFFS, mbg_ref_offs, pout,
+ _pcps_ddev_has_ref_offs( pddev ) );
break;
- case IOCTL_DEV_HAS_UCAP:
- _report_cond( _pcps_ddev_has_ucap( pddev ), pout );
+ case IOCTL_GET_MBG_OPT_INFO:
+ _io_read_var_chk( pddev, PCPS_GET_OPT_INFO, mbg_opt_info, pout,
+ _pcps_ddev_has_opt_flags( pddev ) );
break;
- case IOCTL_DEV_HAS_IRIG_TX:
- _report_cond( _pcps_ddev_has_irig_tx( pddev ), pout );
+ case IOCTL_GET_PCPS_IRIG_RX_INFO:
+ _io_read_var_chk( pddev, PCPS_GET_IRIG_RX_INFO, irig_info, pout,
+ _pcps_ddev_is_irig_rx( pddev ) );
break;
- case IOCTL_DEV_HAS_SERIAL_HS:
- _report_cond( _pcps_ddev_has_serial_hs( pddev ), pout );
+ case IOCTL_GET_GPS_TZDL:
+ _io_read_gps_var( pddev, PC_GPS_TZDL, tzdl, pout );
break;
- case IOCTL_DEV_HAS_SIGNAL:
- _report_cond( _pcps_ddev_has_signal( pddev ), pout );
+ case IOCTL_GET_GPS_PORT_PARM:
+ _io_read_gps_var( pddev, PC_GPS_PORT_PARM, port_parm, pout );
break;
- case IOCTL_DEV_HAS_MOD:
- _report_cond( _pcps_ddev_has_mod( pddev ), pout );
+ case IOCTL_GET_GPS_ENABLE_FLAGS:
+ _io_read_gps_var( pddev, PC_GPS_ENABLE_FLAGS, enable_flags, pout );
break;
- case IOCTL_DEV_HAS_IRIG:
- _report_cond( _pcps_ddev_has_irig( pddev ), pout );
+ case IOCTL_GET_GPS_ANT_CABLE_LEN:
+ _io_read_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN, ant_cable_len, pout,
+ _pcps_ddev_has_cab_len( pddev ) );
break;
- case IOCTL_DEV_HAS_REF_OFFS:
- _report_cond( _pcps_ddev_has_ref_offs( pddev ), pout );
- break;
+ case IOCTL_GET_PCPS_IRIG_TX_INFO:
+ /* This is a workaround for GPS169PCIs with early */
+ /* firmware versions. See RCS log for details. */
+ pcps_cmd = PCPS_GET_IRIG_TX_INFO;
+ if ( _pcps_ddev_requires_irig_workaround( pddev ) )
+ {
+ pcps_cmd = PCPS_GET_IRIG_RX_INFO;
+ _mbgddmsg_1( MBG_DBG_INFO, "%s: workaround for GPS169PCI \"get IRIG TX cfg\"",
+ pcps_driver_name );
+ }
- case IOCTL_DEV_HAS_OPT_FLAGS:
- _report_cond( _pcps_ddev_has_opt_flags( pddev ), pout );
+ _io_read_var_chk( pddev, pcps_cmd, irig_info, pout,
+ _pcps_ddev_has_irig_tx( pddev ) );
break;
- case IOCTL_DEV_HAS_GPS_DATA:
- _report_cond( _pcps_ddev_has_gps_data( pddev ), pout );
+ case IOCTL_GET_SYNTH:
+ _io_read_var_chk( pddev, PCPS_GET_SYNTH, synth, pout,
+ _pcps_ddev_has_synth( pddev ) );
break;
- case IOCTL_DEV_HAS_SYNTH:
- _report_cond( _pcps_ddev_has_synth( pddev ), pout );
+ case IOCTL_GET_GPS_TIME_SCALE_INFO:
+ _io_read_gps_var_chk( pddev, PC_GPS_TIME_SCALE, mbg_time_scale_info,
+ pout, _pcps_ddev_has_time_scale( pddev ) );
break;
- case IOCTL_DEV_HAS_GENERIC_IO:
- _report_cond( _pcps_ddev_has_generic_io( pddev ), pout );
+ case IOCTL_GET_GPS_UTC_PARM:
+ _io_read_gps_var_chk( pddev, PC_GPS_UTC, utc, pout,
+ _pcps_ddev_has_utc_parm( pddev ) );
break;
- case IOCTL_PCPS_GENERIC_IO:
- {
- IOCTL_GENERIC_CTL ctl;
- IOCTL_GENERIC_BUFFER *p_buff;
- int buffer_size;
+ case IOCTL_GET_LAN_IF_INFO:
+ _io_read_gps_var_chk( pddev, PC_GPS_LAN_IF_INFO, lan_if_info,
+ pout, _pcps_ddev_has_lan_intf( pddev ) );
+ break;
- _io_chk_cond( _pcps_ddev_has_generic_io( pddev ) );
- _pcps_iob_from_pin( IOCTL_GENERIC_CTL, ctl, pin );
- buffer_size = sizeof( ctl ) +
- ( ( ctl.data_size_in > ctl.data_size_out ) ?
- ctl.data_size_in : ctl.data_size_out );
- p_buff = _pcps_kmalloc( buffer_size );
+ case IOCTL_GET_IP4_SETTINGS:
+ _io_read_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS, ip4_settings,
+ pout, _pcps_ddev_has_lan_intf( pddev ) );
+ break;
- if ( p_buff == NULL )
- goto err_no_mem;
- _pcps_iob_from_pin_size( uint8_t, *p_buff, pin,
- sizeof( p_buff->ctl ) + ctl.data_size_in );
+ case IOCTL_GET_PTP_CFG_INFO:
+ _io_read_gps_var_chk( pddev, PC_GPS_PTP_CFG, ptp_cfg_info,
+ pout, _pcps_ddev_has_ptp( pddev ) );
+ break;
- _pcps_sem_inc_safe( pddev );
- rc = pcps_generic_io( pddev, (uint8_t) ctl.info,
- p_buff->data,
- (uint8_t) ctl.data_size_in,
- p_buff->data,
- (uint8_t) ctl.data_size_out );
- _pcps_sem_dec( pddev );
- if ( rc == MBG_SUCCESS )
- {
- p_buff->ctl = ctl;
- _pcps_iob_to_pout_size( uint8_t, *p_buff, pout,
- sizeof( p_buff->ctl ) + ctl.data_size_out );
- }
+ case IOCTL_GET_IRIG_TIME:
+ _io_read_var_chk( pddev, PCPS_GIVE_IRIG_TIME, pcps_irig_time,
+ pout, _pcps_ddev_has_irig_time( pddev ) );
+ break;
- _pcps_kfree( p_buff, buffer_size );
- if ( rc != MBG_SUCCESS )
- goto err_access;
+ case IOCTL_GET_RAW_IRIG_DATA:
+ _io_read_var_chk( pddev, PCPS_GET_RAW_IRIG_DATA, mbg_raw_irig_data,
+ pout, _pcps_ddev_has_raw_irig_data( pddev ) );
+ break;
+
+ case IOCTL_PTP_UC_MASTER_CFG_LIMITS:
+ _io_read_gps_var_chk( pddev, PC_GPS_PTP_UC_MASTER_CFG_LIMITS, ptp_uc_master_cfg_limits,
+ pout, _pcps_ddev_has_ptp_unicast( pddev ) );
break;
- }
- case IOCTL_GET_SYNTH_STATE:
- _io_read_var_chk( pddev, PCPS_GET_SYNTH_STATE,
- SYNTH_STATE, pout,
- _pcps_ddev_has_synth( pddev ) );
+ case IOCTL_GET_TR_DISTANCE:
+ _io_read_var_chk( pddev, PCPS_GET_TR_DISTANCE, tr_distance,
+ pout, _pcps_ddev_has_tr_distance( pddev ) );
break;
#if _MBG_SUPP_VAR_ACC_SIZE
- case IOCTL_GET_GPS_ALL_POUT_INFO:
- _io_read_gps_chk( pddev, PC_GPS_ALL_POUT_INFO,
- ALL_POUT_INFO, pout, pout_size,
- _pcps_ddev_has_receiver_info( pddev ) );
+
+ // These codes are only supported on target systems where a variable size of
+ // the IOCTL buffer can be specified in the IOCTL call. On other systems the
+ // generic IOCTL functions are used instead.
+
+ case IOCTL_GET_GPS_ALL_STR_TYPE_INFO:
+ _io_read_gps_chk( pddev, PC_GPS_ALL_STR_TYPE_INFO, all_str_type_info, pout,
+ pout_size, _pcps_ddev_has_receiver_info( pddev ) );
break;
- #endif
- case IOCTL_SET_GPS_POUT_SETTINGS_IDX:
- _io_write_gps_var_chk( pddev, PC_GPS_POUT_SETTINGS_IDX,
- POUT_SETTINGS_IDX, pin,
- _pcps_ddev_has_receiver_info( pddev ) );
+ case IOCTL_GET_GPS_ALL_PORT_INFO:
+ _io_read_gps_chk( pddev, PC_GPS_ALL_PORT_INFO, all_port_info, pout,
+ pout_size, _pcps_ddev_has_receiver_info( pddev ) );
break;
-#if USE_DEBUG_PORT
- case IOCTL_MBG_DBG_GET_PORT_ADDR:
- {
- _pcps_iob( MBG_DBG_PORT, _s );
- _s = mbg_dbg_port;
- _pcps_iob_to_pout( MBG_DBG_PORT, _s, pout );
+ case IOCTL_GET_GPS_ALL_POUT_INFO:
+ _io_read_gps_chk( pddev, PC_GPS_ALL_POUT_INFO, all_pout_info, pout,
+ pout_size, _pcps_ddev_has_receiver_info( pddev ) );
+ break;
- rc = MBG_SUCCESS;
- }
+
+ case IOCTL_GET_ALL_PTP_UC_MASTER_INFO:
+ _io_read_gps_chk( pddev, PC_GPS_ALL_PTP_UC_MASTER_INFO, all_ptp_uc_master_info,
+ pout, pout_size, _pcps_ddev_has_ptp_unicast( pddev ) );
break;
+ #endif // _MBG_SUPP_VAR_ACC_SIZE
- case IOCTL_MBG_DBG_SET_PORT_ADDR:
- {
- _pcps_iob( MBG_DBG_PORT, _s );
- _pcps_iob_from_pin( MBG_DBG_PORT, _s, pin );
- mbg_dbg_port = _s;
- mbg_dbg_port_mapped = _pcps_ioremap( mbg_dbg_port, sizeof( mbg_dbg_port ) );
+ // Codes writing device configuration
- rc = MBG_SUCCESS;
- }
+ case IOCTL_SET_PCPS_SERIAL:
+ _io_write_var( pddev, PCPS_SET_SERIAL, pcps_serial, pin );
break;
-#endif // USE_DEBUG_PORT
- case IOCTL_GET_MAPPED_MEM_ADDR:
- {
- _io_chk_cond( ( pddev->asic_features & PCI_ASIC_HAS_MM_IO ) );
- _io_get_mapped_mem_address( pddev, pout );
- }
+ case IOCTL_SET_PCPS_TZCODE:
+ _io_write_var_chk( pddev, PCPS_SET_TZCODE, pcps_tzcode, pin,
+ _pcps_ddev_has_tzcode( pddev ) );
break;
- case IOCTL_UNMAP_MAPPED_MEM:
- {
- _io_chk_cond( ( pddev->asic_features & PCI_ASIC_HAS_MM_IO ) );
- _io_unmap_mapped_mem_address( pddev, pin );
- }
+ case IOCTL_SET_PCPS_TZDL:
+ _io_write_var_chk( pddev, PCPS_SET_PCPS_TZDL, pcps_tzdl, pin,
+ _pcps_ddev_has_pcps_tzdl( pddev ) );
break;
- case IOCTL_GET_PCI_ASIC_FEATURES:
- _io_chk_cond( _pcps_ddev_has_asic_features( pddev ) );
- {
- _pcps_iob( PCI_ASIC_FEATURES, _s );
+ case IOCTL_SET_REF_OFFS:
+ _io_write_var_chk( pddev, PCPS_SET_REF_OFFS, mbg_ref_offs, pin,
+ _pcps_ddev_has_ref_offs( pddev ) );
+ break;
- _s = pddev->asic_features;
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout( PCI_ASIC_FEATURES, _s, pout );
- }
+ case IOCTL_SET_MBG_OPT_SETTINGS:
+ _io_write_var_chk( pddev, PCPS_SET_OPT_SETTINGS, mbg_opt_settings,
+ pin, _pcps_ddev_has_opt_flags( pddev ) );
break;
- case IOCTL_HAS_PCI_ASIC_FEATURES:
- _report_cond( _pcps_ddev_has_asic_features( pddev ), pout );
+ case IOCTL_SET_PCPS_IRIG_RX_SETTINGS:
+ _io_write_var_chk( pddev, PCPS_SET_IRIG_RX_SETTINGS,
+ irig_settings, pin,
+ _pcps_ddev_is_irig_rx( pddev ) );
break;
- case IOCTL_HAS_PCI_ASIC_VERSION:
- _report_cond( _pcps_ddev_has_asic_version( pddev ), pout );
+ case IOCTL_SET_GPS_TZDL:
+ _io_write_gps_var( pddev, PC_GPS_TZDL, tzdl, pin );
break;
- case IOCTL_DEV_IS_MSF:
- _report_cond( _pcps_ddev_is_msf( pddev ), pout );
+ case IOCTL_SET_GPS_PORT_PARM:
+ _io_write_gps_var( pddev, PC_GPS_PORT_PARM, port_parm, pin );
break;
- case IOCTL_DEV_IS_WWVB:
- _report_cond( _pcps_ddev_is_wwvb( pddev ), pout );
+ case IOCTL_SET_GPS_ENABLE_FLAGS:
+ _io_write_gps_var( pddev, PC_GPS_ENABLE_FLAGS, enable_flags, pin );
break;
- case IOCTL_DEV_IS_LWR:
- _report_cond( _pcps_ddev_is_lwr( pddev ), pout );
+ case IOCTL_SET_GPS_ANT_CABLE_LEN:
+ _io_write_gps_var_chk( pddev, PC_GPS_ANT_CABLE_LEN, ant_cable_len,
+ pin, _pcps_ddev_has_cab_len( pddev ) );
break;
- case IOCTL_GET_IRQ_STAT_INFO:
- {
- _pcps_iob( PCPS_IRQ_STAT_INFO, _s );
+ case IOCTL_SET_GPS_PORT_SETTINGS_IDX:
+ _io_write_gps_var_chk( pddev, PC_GPS_PORT_SETTINGS_IDX, port_settings_idx,
+ pin, _pcps_ddev_has_receiver_info( pddev ) );
+ break;
- _s = pddev->irq_stat_info;
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout( PCPS_IRQ_STAT_INFO, _s, pout );
+ case IOCTL_SET_PCPS_IRIG_TX_SETTINGS:
+ /* This is a workaround for GPS169PCIs with early */
+ /* firmware versions. See RCS log for details. */
+ pcps_cmd = PCPS_SET_IRIG_TX_SETTINGS;
+
+ if ( _pcps_ddev_requires_irig_workaround( pddev ) )
+ {
+ pcps_cmd = PCPS_SET_IRIG_RX_SETTINGS;
+ _mbgddmsg_1( MBG_DBG_INFO, "%s: workaround for GPS169PCI \"set IRIG TX cfg\"",
+ pcps_driver_name );
}
+
+ _io_write_var_chk( pddev, pcps_cmd, irig_settings, pin,
+ _pcps_ddev_has_irig_tx( pddev ) );
break;
- case IOCTL_GET_CYCLES_FREQUENCY:
- {
- _pcps_iob( MBG_PC_CYCLES_FREQUENCY, _s );
+ case IOCTL_SET_SYNTH:
+ _io_write_var_chk( pddev, PCPS_SET_SYNTH, synth, pin,
+ _pcps_ddev_has_synth( pddev ) );
+ break;
- mbg_get_pc_cycles_frequency( &(_s) );
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout( MBG_PC_CYCLES_FREQUENCY, _s, pout );
- }
+ case IOCTL_SET_GPS_POUT_SETTINGS_IDX:
+ _io_write_gps_var_chk( pddev, PC_GPS_POUT_SETTINGS_IDX, pout_settings_idx,
+ pin, _pcps_ddev_has_receiver_info( pddev ) );
break;
- case IOCTL_HAS_FAST_HR_TIMESTAMP:
- _report_cond( _pcps_ddev_has_fast_hr_timestamp( pddev ), pout );
+ case IOCTL_SET_IP4_SETTINGS:
+ _io_write_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS, ip4_settings,
+ pin, _pcps_ddev_has_lan_intf( pddev ) );
break;
- case IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES:
- {
- _pcps_iob_x( PCPS_TIME_STAMP_CYCLES, b );
+ case IOCTL_SET_PTP_CFG_SETTINGS:
+ _io_write_gps_var_chk( pddev, PC_GPS_PTP_CFG, ptp_cfg_settings,
+ pin, _pcps_ddev_has_ptp( pddev ) );
+ break;
- if ( !_pcps_ddev_has_fast_hr_timestamp( pddev ) )
- goto err_support;
- do_get_fast_hr_timestamp_cycles_safe( pddev, _iob_addr( b, pout ) );
- rc = MBG_SUCCESS;
+ case IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX:
+ _io_write_gps_var_chk( pddev, PC_GPS_PTP_UC_MASTER_SETTINGS_IDX,
+ ptp_uc_master_settings_idx, pin,
+ _pcps_ddev_has_ptp_unicast( pddev ) );
+ break;
- _pcps_iob_to_pout_x( PCPS_TIME_STAMP_CYCLES, b, pout );
- }
+
+ case IOCTL_SET_TR_DISTANCE:
+ _io_write_var_chk( pddev, PCPS_SET_TR_DISTANCE, tr_distance,
+ pin, _pcps_ddev_has_tr_distance( pddev ) );
break;
- case IOCTL_GET_FAST_HR_TIMESTAMP:
- {
- _pcps_iob_x( PCPS_TIME_STAMP, b );
+ // Operations which may severely affect system operation
- if ( !_pcps_ddev_has_fast_hr_timestamp( pddev ) )
- goto err_support;
+ case IOCTL_SET_PCPS_TIME:
+ _io_write_var_chk( pddev, PCPS_SET_TIME, pcps_stime, pin,
+ _pcps_ddev_can_set_time( pddev ) );
+ break;
- do_get_fast_hr_timestamp_safe( pddev, _iob_addr( b, pout ) );
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout_x( PCPS_TIME_STAMP, b, pout );
- }
+ case IOCTL_SET_GPS_TIME:
+ _io_write_gps_var( pddev, PC_GPS_TIME, ttm, pin );
break;
- case IOCTL_DEV_HAS_GPS_TIME_SCALE:
- _report_cond( _pcps_ddev_has_time_scale( pddev ), pout );
+ case IOCTL_SET_GPS_POS_XYZ:
+ _io_write_gps_var( pddev, PC_GPS_POS_XYZ, xyzs, pin );
break;
- case IOCTL_GET_GPS_TIME_SCALE_INFO:
- _io_read_gps_var_chk( pddev, PC_GPS_TIME_SCALE,
- MBG_TIME_SCALE_INFO, pout,
- _pcps_ddev_has_time_scale( pddev ) );
+ case IOCTL_SET_GPS_POS_LLA:
+ _io_write_gps_var( pddev, PC_GPS_POS_LLA, llas, pin );
break;
case IOCTL_SET_GPS_TIME_SCALE_SETTINGS:
- _io_write_gps_var_chk( pddev, PC_GPS_TIME_SCALE,
- MBG_TIME_SCALE_SETTINGS, pin,
- _pcps_ddev_has_time_scale( pddev ) );
+ _io_write_gps_var_chk( pddev, PC_GPS_TIME_SCALE, mbg_time_scale_settings,
+ pin, _pcps_ddev_has_time_scale( pddev ) );
break;
- case IOCTL_DEV_HAS_GPS_UTC_PARM:
- _report_cond( _pcps_ddev_has_utc_parm( pddev ), pout );
+ case IOCTL_SET_GPS_UTC_PARM:
+ _io_write_gps_var_chk( pddev, PC_GPS_UTC, utc, pin,
+ _pcps_ddev_has_utc_parm( pddev ) );
break;
- case IOCTL_GET_GPS_UTC_PARM:
- _io_read_gps_var_chk( pddev, PC_GPS_UTC,
- UTC, pout,
- _pcps_ddev_has_utc_parm( pddev ) );
+ case IOCTL_SET_GPS_CMD:
+ _io_write_gps_var( pddev, PC_GPS_CMD, gps_cmd, pin );
break;
- case IOCTL_SET_GPS_UTC_PARM:
- _io_write_gps_var_chk( pddev, PC_GPS_UTC,
- UTC, pin,
- _pcps_ddev_has_utc_parm( pddev ) );
- break;
+ // Generic read/write operations which can do anything
+ case IOCTL_PCPS_GENERIC_READ:
+ _iob_from_pin_var( iob.req, pin );
+ p_buff_out = _pcps_kmalloc( iob.req.out_sz );
- case IOCTL_DEV_HAS_IRIG_CTRL_BITS:
- _report_cond( _pcps_ddev_has_irig_ctrl_bits( pddev ), pout );
- break;
+ if ( p_buff_out == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for %s, cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.out_sz,
+ "IOCTL_PCPS_GENERIC_READ", (ulong) iob.req.info );
+ goto err_no_mem;
+ }
+ _pcps_sem_inc_safe( pddev );
+ rc = _pcps_read( pddev, (uint8_t) iob.req.info, p_buff_out,
+ (uint8_t) iob.req.out_sz );
+ _pcps_sem_dec( pddev );
- case IOCTL_GET_IRIG_CTRL_BITS:
- _io_read_var_chk( pddev, PCPS_GET_IRIG_CTRL_BITS,
- MBG_IRIG_CTRL_BITS, pout,
- _pcps_ddev_has_irig_ctrl_bits( pddev ) );
- break;
+ if ( rc == MBG_SUCCESS )
+ _frc_iob_to_pout( p_buff_out, iob.req.out_p, iob.req.out_sz );
+ _pcps_kfree( p_buff_out, iob.req.out_sz );
+
+ if ( rc != MBG_SUCCESS )
+ goto err_access;
- case IOCTL_DEV_HAS_LAN_INTF:
- _report_cond( _pcps_ddev_has_lan_intf( pddev ), pout );
break;
- case IOCTL_GET_LAN_IF_INFO:
- _io_read_gps_var_chk( pddev, PC_GPS_LAN_IF_INFO,
- LAN_IF_INFO, pout,
- _pcps_ddev_has_lan_intf( pddev ) );
- break;
+ case IOCTL_PCPS_GENERIC_WRITE:
+ _iob_from_pin_var( iob.req, pin );
+ p_buff_in = _pcps_kmalloc( iob.req.in_sz );
+ if ( p_buff_in == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for %s, cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.in_sz,
+ "IOCTL_PCPS_GENERIC_WRITE", (ulong) iob.req.info );
+ goto err_no_mem;
+ }
- case IOCTL_GET_IP4_STATE:
- _io_read_gps_var_chk( pddev, PC_GPS_IP4_STATE,
- IP4_SETTINGS, pout,
- _pcps_ddev_has_lan_intf( pddev ) );
- break;
+ _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz );
+ _pcps_sem_inc_safe( pddev );
+ rc = pcps_write( pddev, (uint8_t) iob.req.info, p_buff_in,
+ (uint8_t) iob.req.in_sz );
+ _pcps_sem_dec( pddev );
- case IOCTL_GET_IP4_SETTINGS:
- _io_read_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS,
- IP4_SETTINGS, pout,
- _pcps_ddev_has_lan_intf( pddev ) );
- break;
+ _pcps_kfree( p_buff_in, iob.req.in_sz );
+ if ( rc != MBG_SUCCESS )
+ goto err_access;
- case IOCTL_SET_IP4_SETTINGS:
- _io_write_gps_var_chk( pddev, PC_GPS_IP4_SETTINGS,
- IP4_SETTINGS, pin,
- _pcps_ddev_has_lan_intf( pddev ) );
break;
- case IOCTL_DEV_IS_PTP:
- _report_cond( _pcps_ddev_is_ptp( pddev ), pout );
- break;
+ case IOCTL_PCPS_GENERIC_READ_GPS:
+ _iob_from_pin_var( iob.req, pin );
+ p_buff_out = _pcps_kmalloc( iob.req.out_sz );
+ if ( p_buff_out == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for %s, GPS cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.out_sz,
+ "IOCTL_PCPS_GENERIC_READ_GPS", (ulong) iob.req.info );
+ goto err_no_mem;
+ }
- case IOCTL_DEV_HAS_PTP:
- _report_cond( _pcps_ddev_has_ptp( pddev ), pout );
- break;
+ _pcps_sem_inc_safe( pddev );
+ rc = pcps_read_gps( pddev, (uint8_t) iob.req.info, p_buff_out,
+ (uint16_t) iob.req.out_sz );
+ _pcps_sem_dec( pddev );
+ if ( rc == MBG_SUCCESS )
+ _frc_iob_to_pout( p_buff_out, iob.req.out_p, iob.req.out_sz );
- case IOCTL_GET_PTP_STATE:
- _io_read_gps_var_chk( pddev, PC_GPS_PTP_STATE,
- PTP_STATE, pout,
- _pcps_ddev_has_ptp( pddev ) );
- break;
+ _pcps_kfree( p_buff_out, iob.req.out_sz );
+ if ( rc != MBG_SUCCESS )
+ goto err_access;
- case IOCTL_GET_PTP_CFG_INFO:
- _io_read_gps_var_chk( pddev, PC_GPS_PTP_CFG,
- PTP_CFG_INFO, pout,
- _pcps_ddev_has_ptp( pddev ) );
break;
- case IOCTL_SET_PTP_CFG_SETTINGS:
- _io_write_gps_var_chk( pddev, PC_GPS_PTP_CFG,
- PTP_CFG_SETTINGS, pin,
- _pcps_ddev_has_ptp( pddev ) );
- break;
+ case IOCTL_PCPS_GENERIC_WRITE_GPS:
+ _iob_from_pin_var( iob.req, pin );
+ p_buff_in = _pcps_kmalloc( iob.req.in_sz );
+ if ( p_buff_in == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for %s, cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.in_sz,
+ "IOCTL_PCPS_GENERIC_WRITE_GPS", (ulong) iob.req.info );
+ goto err_no_mem;
+ }
- case IOCTL_DEV_HAS_IRIG_TIME:
- _report_cond( _pcps_ddev_has_irig_time( pddev ), pout );
- break;
+ _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz );
+ _pcps_sem_inc_safe( pddev );
+ rc = pcps_write_gps( pddev, (uint8_t) iob.req.info, p_buff_in,
+ (uint16_t) iob.req.in_sz );
+ _pcps_sem_dec( pddev );
- case IOCTL_GET_IRIG_TIME:
- _io_read_var_chk( pddev, PCPS_GIVE_IRIG_TIME,
- PCPS_IRIG_TIME, pout,
- _pcps_ddev_has_irig_time( pddev ) );
- break;
+ _pcps_kfree( p_buff_in, iob.req.in_sz );
+ if ( rc != MBG_SUCCESS )
+ goto err_access;
- case IOCTL_GET_RAW_IRIG_DATA:
- _io_read_var_chk( pddev, PCPS_GET_RAW_IRIG_DATA,
- MBG_RAW_IRIG_DATA, pout,
- _pcps_ddev_has_raw_irig_data( pddev ) );
break;
- case IOCTL_DEV_HAS_PTP_UNICAST:
- _report_cond( _pcps_ddev_has_ptp_unicast( pddev ), pout );
- break;
+ case IOCTL_PCPS_GENERIC_IO:
+ _io_chk_cond( _pcps_ddev_has_generic_io( pddev ) );
+ _iob_from_pin_var( iob.req, pin );
+ if ( iob.req.in_p && iob.req.in_sz )
+ {
+ p_buff_in = _pcps_kmalloc( iob.req.in_sz );
- case IOCTL_GET_PTP_UNICAST_CFG_INFO:
- _io_read_gps_var_chk( pddev, PC_GPS_PTP_UNICAST_CFG,
- PTP_UNICAST_CFG_INFO, pout,
- _pcps_ddev_has_ptp_unicast( pddev ) );
- break;
+ if ( p_buff_in == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for input in %s, cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.in_sz,
+ "IOCTL_PCPS_GENERIC_IO", (ulong) iob.req.info );
+ goto err_no_mem;
+ }
+ _frc_iob_from_pin( p_buff_in, pin, iob.req.in_sz );
+ }
+ else
+ {
+ p_buff_in = NULL;
+ iob.req.in_sz = 0; // just to be sure
+ }
- case IOCTL_SET_PTP_UNICAST_CFG_SETTINGS:
- _io_write_gps_var_chk( pddev, PC_GPS_PTP_UNICAST_CFG,
- PTP_UNICAST_CFG_SETTINGS, pin,
- _pcps_ddev_has_ptp_unicast( pddev ) );
- break;
+ if ( iob.req.out_p && iob.req.out_sz )
+ {
+ p_buff_out = _pcps_kmalloc( iob.req.out_sz );
+ if ( p_buff_out == NULL )
+ {
+ _mbgddmsg_4( MBG_DBG_INFO, "%s: unable to alloc %lu bytes for output in %s, cmd: %02lX",
+ pcps_driver_name, (ulong) iob.req.in_sz,
+ "IOCTL_PCPS_GENERIC_IO", (ulong) iob.req.info );
- case IOCTL_GET_TIME_INFO_HRT:
+ // free the input buffer we already have allocated
+ _pcps_kfree( p_buff_in, iob.req.in_sz );
+ goto err_no_mem;
+ }
+ }
+ else
{
- _pcps_iob( MBG_TIME_INFO_HRT, _s );
+ p_buff_out = NULL;
+ iob.req.out_sz = 0; // just to be sure
+ }
- if ( !_pcps_ddev_has_hr_time( pddev ) )
- goto err_support;
+ _pcps_sem_inc_safe( pddev );
+ rc = pcps_generic_io( pddev, (uint8_t) iob.req.info,
+ p_buff_in, (uint8_t) iob.req.in_sz,
+ p_buff_out, (uint8_t) iob.req.out_sz );
+ _pcps_sem_dec( pddev );
- mbg_get_pc_cycles( &_s.sys_time_cycles.cyc_before );
- mbg_get_sys_time( &_s.sys_time_cycles.sys_time );
- mbg_get_pc_cycles( &_s.sys_time_cycles.cyc_after );
+ if ( rc == MBG_SUCCESS )
+ _frc_iob_to_pout( p_buff_out, iob.req.out_p, iob.req.out_sz );
- _pcps_sem_inc_safe( pddev );
- rc = _pcps_read_var( pddev, PCPS_GIVE_HR_TIME, _s.ref_hr_time_cycles.t );
- _s.ref_hr_time_cycles.cycles =(pddev)->acc_cycles;
- _pcps_sem_dec( pddev );
+ if ( p_buff_in )
+ _pcps_kfree( p_buff_in, iob.req.in_sz );
- if ( rc != MBG_SUCCESS )
- goto err_access;
+ if ( p_buff_out )
+ _pcps_kfree( p_buff_out, iob.req.out_sz );
+
+ if ( rc != MBG_SUCCESS )
+ goto err_access;
- _pcps_iob_to_pout( MBG_TIME_INFO_HRT, _s, pout );
- }
break;
- case IOCTL_GET_TIME_INFO_TSTAMP:
- {
- _pcps_iob( MBG_TIME_INFO_TSTAMP, _s );
+ // The next codes are somewhat special and normally
+ // not used by the driver software:
- if ( !_pcps_ddev_has_fast_hr_timestamp( pddev ) )
- goto err_support;
+ case IOCTL_GET_MAPPED_MEM_ADDR:
+ _io_chk_cond( ( pddev->asic_features & PCI_ASIC_HAS_MM_IO ) );
+ _io_get_mapped_mem_address( pddev, pout );
+ break;
- mbg_get_pc_cycles( &_s.sys_time_cycles.cyc_before );
- mbg_get_sys_time( &_s.sys_time_cycles.sys_time );
- mbg_get_pc_cycles( &_s.sys_time_cycles.cyc_after );
- do_get_fast_hr_timestamp_cycles_safe( pddev, &(_s).ref_tstamp_cycles );
+ case IOCTL_UNMAP_MAPPED_MEM:
+ _io_chk_cond( ( pddev->asic_features & PCI_ASIC_HAS_MM_IO ) );
+ _io_unmap_mapped_mem_address( pddev, pin );
+ break;
- rc = MBG_SUCCESS;
- _pcps_iob_to_pout( MBG_TIME_INFO_TSTAMP, _s, pout );
- }
+ #if USE_DEBUG_PORT
+ // The codes below are used for debugging only.
+ // Unrestricted usage may cause system malfunction !!
+
+ case IOCTL_MBG_DBG_GET_PORT_ADDR:
+ _iob_to_pout_var( mbg_dbg_port, pout );
+ rc = MBG_SUCCESS;
break;
-#if USE_DEBUG_PORT
- case IOCTL_MBG_DBG_SET_BIT:
- {
- _pcps_iob( MBG_DBG_DATA, _s );
- _pcps_iob( MBG_PC_CYCLES, _c );
- _pcps_iob_from_pin( MBG_DBG_DATA, _s, pin );
+ case IOCTL_MBG_DBG_SET_PORT_ADDR:
+ _iob_from_pin_var( mbg_dbg_port, pin );
+ mbg_dbg_port_mapped = _pcps_ioremap( mbg_dbg_port, sizeof( mbg_dbg_port ) );
+ rc = MBG_SUCCESS;
+ break;
- _mbg_dbg_set_bit( pddev, _s );
- mbg_get_pc_cycles( &(_c) );
- _pcps_iob_to_pout( MBG_PC_CYCLES, _c, pout );
- }
+ case IOCTL_MBG_DBG_SET_BIT:
+ _iob_from_pin_var( iob.mbg_dbg_data, pin );
+ _mbg_dbg_set_bit( pddev, iob.mbg_dbg_data );
+ mbg_get_pc_cycles( &cyc );
+ _iob_to_pout_var( cyc, pout );
break;
case IOCTL_MBG_DBG_CLR_BIT:
- {
- _pcps_iob( MBG_DBG_DATA, _s );
- _pcps_iob( MBG_PC_CYCLES, _c );
-
- _pcps_iob_from_pin( MBG_DBG_DATA, _s, pin );
-
- _mbg_dbg_clr_bit( pddev, _s );
- mbg_get_pc_cycles( &(_c) );
-
- _pcps_iob_to_pout( MBG_PC_CYCLES, _c, pout );
- }
+ _iob_from_pin_var( iob.mbg_dbg_data, pin );
+ _mbg_dbg_clr_bit( pddev, iob.mbg_dbg_data );
+ mbg_get_pc_cycles( &cyc );
+ _iob_to_pout_var( cyc, pout );
break;
case IOCTL_MBG_DBG_CLR_ALL:
- {
- _pcps_iob( MBG_PC_CYCLES, _c );
- _mbg_dbg_clr_all( pddev );
- mbg_get_pc_cycles( &(_c) );
-
- _pcps_iob_to_pout( MBG_PC_CYCLES, _c, pout );
- }
+ _mbg_dbg_clr_all( pddev );
+ mbg_get_pc_cycles( &cyc );
+ _iob_to_pout_var( cyc, pout );
break;
-#endif
+
+ #endif // USE_DEBUG_PORT
default:
goto err_inval;
-
}
return rc;
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbg_arch.h b/src/external/bsd/meinberg/dist/mbglib/common/mbg_arch.h
index cdf6f01..ebfe035 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbg_arch.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbg_arch.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_arch.h 1.3.1.2 2011/02/09 15:46:48 martin TRASH $
+ * $Id: mbg_arch.h 1.3.1.4 2011/06/27 16:12:59 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_arch.h $
+ * Revision 1.3.1.4 2011/06/27 16:12:59 martin
+ * Revision 1.3.1.3 2011/04/12 12:55:28 martin
+ * Include words.h.
* Revision 1.3.1.2 2011/02/09 15:46:48 martin
* Revision 1.3.1.1 2011/02/09 15:26:58 martin
* Revision 1.3 2009/06/12 13:12:37Z martin
@@ -25,6 +28,7 @@
#define _MBG_ARCH_H
#include <mbg_tgt.h>
+#include <words.h>
#if !defined( MBG_TGT_KERNEL )
#include <stdlib.h>
@@ -61,12 +65,12 @@
// define some default macros assuming no special handling is required
// to access unaligned data.
-#if !defined( _pcps_put_unaligned )
- #define _pcps_put_unaligned( _v, _p ) ((void)( *(_p) = (_v) ))
+#if !defined( _mbg_put_unaligned )
+ #define _mbg_put_unaligned( _v, _p ) ((void)( *(_p) = (_v) ))
#endif
-#if !defined( _pcps_get_unaligned )
- #define _pcps_get_unaligned( _p ) (*(_p))
+#if !defined( _mbg_get_unaligned )
+ #define _mbg_get_unaligned( _p ) (*(_p))
#endif
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbg_tgt.h b/src/external/bsd/meinberg/dist/mbglib/common/mbg_tgt.h
index a3c45d1..a2eaaa2 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbg_tgt.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.22.2.11 2011/03/22 10:25:26 martin TRASH $
+ * $Id: mbg_tgt.h 1.22.2.13 2011/06/22 07:51:03 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.22.2.11 2011/03/22 10:25:26 martin
+ * Revision 1.22.2.13 2011/06/22 07:51:03 martin
+ * Defined _NO_USE_PACK_INTF for Sparc and IA64.
+ * Revision 1.22.2.12 2011/04/12 15:36:00 martin
+ * Revision 1.22.2.11 2011/03/22 10:25:26Z martin
* Fixed typo in comment.
* Revision 1.22.2.10 2011/02/09 15:46:48 martin
* Revision 1.22.2.9 2011/02/09 15:27:10 martin
@@ -231,11 +234,15 @@
#define MBG_ARCH_IA64
+ #define _NO_USE_PACK_INTF
+
#elif defined( __sparc__ )
#define MBG_ARCH_SPARC
#define MBG_USE_MM_IO_FOR_PCI 1
+ #define _NO_USE_PACK_INTF
+
#elif defined( __arm__ )
#define MBG_ARCH_ARM
@@ -308,6 +315,7 @@
#endif
#if defined( _KDD_ )
+ #define MBG_TGT_KERNEL
#include <ntddk.h>
#else
// This must not be used for kernel drivers.
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.c b/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.c
index e210f22..95fa744 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.c
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.c 1.35.1.16 2011/03/31 13:18:46 martin TRASH $
+ * $Id: mbgdevio.c 1.35.1.24 2011/07/14 14:54:00 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,25 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.c $
+ * Revision 1.35.1.24 2011/07/14 14:54:00 martin
+ * Modified generic IOCTL handling such that for calls requiring variable sizes
+ * a fixed request block containing input and output buffer pointers and sizes is
+ * passed down to the kernel driver. This simplifies implementation under *BSD
+ * and also works for other target systems.
+ * Revision 1.35.1.23 2011/07/08 10:11:00 martin
+ * Fixes for DOS.
+ * Revision 1.35.1.22 2011/07/06 11:19:20Z martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.35.1.21 2011/06/29 11:09:55 martin
+ * Added mbg_dev_has_pzf() function.
+ * Revision 1.35.1.20 2011/06/27 13:02:50 martin
+ * Use O_RDWR flag when opening a device.
+ * Revision 1.35.1.19 2011/06/24 11:13:36 martin
+ * Revision 1.35.1.18 2011/06/22 10:05:45 martin
+ * Support PTP unicast configuration.
+ * Account for some IOCTL codes renamed to follow common naming conventions.
+ * Revision 1.35.1.17 2011/04/12 12:56:20 martin
+ * Renamed mutex stuff to critical sections.
* Revision 1.35.1.16 2011/03/31 13:18:46 martin
* Coding style.
* Revision 1.35.1.15 2011/02/16 10:15:13 martin
@@ -255,6 +274,7 @@
#if defined( MBG_USE_KERNEL_DRIVER )
#include <mbgioctl.h>
+ #include <stddef.h>
#else
@@ -300,17 +320,17 @@ typedef struct
#define _mbgdevio_ret_val \
rc
- #define _do_mbgdevio_io( _dh, _ioctl, _p, _insz, _outsz ) \
- rc = do_mbgdevio_io( _dh, _ioctl, (LPVOID) _p, _insz, _outsz )
+ #define _do_mbgdevio_io( _dh, _ioctl, _p, _in_sz, _out_sz ) \
+ rc = do_mbgdevio_io( _dh, _ioctl, (LPVOID) _p, _in_sz, (LPVOID) _p, _out_sz )
static __mbg_inline
DWORD do_mbgdevio_io( MBG_DEV_HANDLE dh, int ioctl_code,
- LPVOID p, int in_sz, int out_sz )
+ const void *in_p, int in_sz, void *out_p, int out_sz )
{
DWORD ReturnedLength;
if ( !DeviceIoControl( dh, ioctl_code,
- p, in_sz, p, out_sz,
+ (LPVOID) in_p, in_sz, out_p, out_sz,
&ReturnedLength,
NULL
) )
@@ -388,17 +408,17 @@ typedef struct
#if !defined( _MBG_SUPP_VAR_ACC_SIZE )
// If this symbol has not yet been defined then mbgioctl.h has probably
// not yet been included. On target systems where the hardware is accessed
- // directly without a kernel driver variable buffer sizes are supported,
+ // directly without a kernel driver variable buffer sizes are supported,
// so we set the default to 1.
#define _MBG_SUPP_VAR_ACC_SIZE 1
#endif
#if !defined( _mbgdevio_chk_cond )
- // If the macro has not been defined previously then
- // it is not be required for the target environment and
+ // If the macro has not been defined previously then
+ // it may not be required for the target environment and
// is defined as empty string.
- #define _mbgdevio_chk_cond( _cond );
+ #define _mbgdevio_chk_cond( _cond ) _nop_macro_fnc()
#endif
@@ -449,37 +469,34 @@ typedef struct
rc = mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_WRITE_GPS, _p, _sz, NULL, 0 )
- static __mbg_inline
- int mbgdevio_do_gen_io( MBG_DEV_HANDLE dh, int info, int ioctl_code,
- const void *in_p, int in_sz,
+ 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,
void *out_p, int out_sz )
{
- IOCTL_GENERIC_BUFFER *p_buff;
- int buff_size = sizeof( p_buff->ctl )
- + ( ( in_sz > out_sz ) ? in_sz : out_sz );
int rc;
- p_buff = (IOCTL_GENERIC_BUFFER *) malloc( buff_size );
-
- if ( p_buff == NULL )
- return _mbg_err_to_os( MBG_ERR_NO_MEM );
-
- p_buff->ctl.info = info;
- p_buff->ctl.data_size_in = in_sz;
- p_buff->ctl.data_size_out = out_sz;
-
- if ( in_p )
- memcpy( p_buff->data, in_p, in_sz );
-
- _do_mbgdevio_io( dh, ioctl_code,
- p_buff,
- sizeof( IOCTL_GENERIC_CTL ) + in_sz,
- sizeof( IOCTL_GENERIC_CTL ) + out_sz );
-
- if ( out_p && ( rc == MBG_SUCCESS ) )
- memcpy( out_p, p_buff->data, out_sz );
-
- free( p_buff );
+ #if _MBG_SUPP_VAR_ACC_SIZE
+ #if defined( MBG_TGT_WIN32 )
+ rc = do_mbgdevio_io( dh, ioctl_code, in_p, in_sz, out_p, out_sz );
+ #else
+ #error Generic IOCTL for var acc size needs to be defined
+ #endif
+ #else
+ IOCTL_GENERIC_REQ req = { 0 };
+
+ req.info = info;
+ req.in_p = in_p;
+ req.in_sz = in_sz;
+ req.out_p = out_p;
+ req.out_sz = out_sz;
+
+ #if defined( MBG_TGT_UNIX )
+ rc = ioctl( dh, ioctl_code, &req ); //##++++++++++++
+ #else
+ #error Generic IOCTL for fixed acc size needs to be defined
+ #endif
+ #endif
return rc;
@@ -811,7 +828,7 @@ fail:
sprintf( dev_fn, "/dev/mbgclock%d", device_index ); //##++
- dh = open( dev_fn, 0 );
+ dh = open( dev_fn, O_RDWR );
return ( dh < 0 ) ? MBG_INVALID_DEV_HANDLE : dh;
@@ -867,7 +884,7 @@ fail:
MBG_DEV_HANDLE dh = -1;
if ( strlen( hw_id ) > 0 )
- dh = open( hw_id, 0 );
+ dh = open( hw_id, O_RDWR );
return ( dh < 0 ) ? MBG_INVALID_DEV_HANDLE : dh;
@@ -1394,7 +1411,7 @@ fail:
#elif defined ( MBG_TGT_UNIX )
if ( hw_id[0] != '\0' )
- dh = open( hw_id, 0 );
+ dh = open( hw_id, O_RDWR );
else
goto fail;
@@ -2325,7 +2342,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh,
@see mbg_get_raw_irig_data()
@see mbg_get_raw_irig_data_on_sec_change()
*/
-_MBG_API_ATTR int _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p)
+_MBG_API_ATTR int _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p )
{
_mbgdevio_query_cond( dh, _pcps_ddev_has_raw_irig_data, IOCTL_DEV_HAS_RAW_IRIG_DATA, p );
@@ -3236,7 +3253,7 @@ int _MBG_API mbg_get_gps_all_port_info( MBG_DEV_HANDLE dh,
#else
// We check the model_code to see whether the receiver info
// has been read from a device which really supports it, or
- // a dummy structure has been setup.
+ // a dummy structure has been set up.
if ( p_ri && ( p_ri->model_code != GPS_MODEL_UNKNOWN ) )
_mbgdevio_gen_read_gps( dh, PC_GPS_ALL_PORT_INFO, pii,
p_ri->n_com_ports * sizeof( pii[0] ) );
@@ -4184,7 +4201,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_synth_state( MBG_DEV_HANDLE dh, SYNTH_STATE *
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_fast_hr_timestamp( MBG_DEV_HANDLE dh, int *p )
{
- _mbgdevio_query_cond( dh, _pcps_ddev_has_fast_hr_timestamp, IOCTL_HAS_FAST_HR_TIMESTAMP, p );
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_fast_hr_timestamp, IOCTL_DEV_HAS_FAST_HR_TIMESTAMP, p );
} // mbg_dev_has_fast_hr_timestamp
@@ -4847,7 +4864,7 @@ _MBG_API_ATTR int _MBG_API mbg_dev_has_generic_io( MBG_DEV_HANDLE dh, int *p )
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_version( MBG_DEV_HANDLE dh, int *p )
{
- _mbgdevio_query_cond( dh, _pcps_ddev_has_asic_version, IOCTL_HAS_PCI_ASIC_VERSION, p );
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_asic_version, IOCTL_DEV_HAS_PCI_ASIC_VERSION, p );
} // mbg_dev_has_asic_version
@@ -4866,7 +4883,7 @@ _MBG_API_ATTR int _MBG_API mbg_dev_has_asic_version( MBG_DEV_HANDLE dh, int *p )
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_features( MBG_DEV_HANDLE dh, int *p )
{
- _mbgdevio_query_cond( dh, _pcps_ddev_has_asic_features, IOCTL_HAS_PCI_ASIC_FEATURES, p );
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_asic_features, IOCTL_DEV_HAS_PCI_ASIC_FEATURES, p );
} // mbg_dev_has_asic_features
@@ -5204,7 +5221,8 @@ _MBG_API_ATTR int _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p )
@return ::MBG_SUCCESS or error code returned by device I/O control function.
@see mbg_get_ptp_state()
- @see mbg_get_ptp_unicast_cfg_info()
+ @see mbg_get_ptp_uc_master_cfg_limits()
+ @see mbg_get_all_ptp_uc_master_info()
@see mbg_set_ptp_unicast_cfg_settings()
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp_unicast( MBG_DEV_HANDLE dh, int *p )
@@ -5318,16 +5336,75 @@ _MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh,
@see mbg_dev_has_ptp_unicast()
@see mbg_set_ptp_unicast_cfg_settings()
*/
-_MBG_API_ATTR int _MBG_API mbg_get_ptp_unicast_cfg_info( MBG_DEV_HANDLE dh, PTP_UNICAST_CFG_INFO *p )
+_MBG_API_ATTR int _MBG_API mbg_get_ptp_uc_master_cfg_limits( MBG_DEV_HANDLE dh, PTP_UC_MASTER_CFG_LIMITS *p )
{
_mbgdevio_vars();
- _mbgdevio_read_gps_var_chk( dh, PC_GPS_PTP_UNICAST_CFG,
- IOCTL_GET_PTP_UNICAST_CFG_INFO, p,
+ _mbgdevio_read_gps_var_chk( dh, PC_GPS_PTP_UC_MASTER_CFG_LIMITS,
+ IOCTL_PTP_UC_MASTER_CFG_LIMITS, p,
_pcps_has_ri_ptp_unicast( &dh->ri ) );
- _mbg_swab_ptp_unicast_cfg_info( p );
+ _mbg_swab_ptp_uc_master_cfg_limits( p );
+ return _mbgdevio_ret_val;
+
+} // mbg_get_ptp_uc_master_cfg_limits
+
+
+
+/*HDR*/
+/**
+ Read a ::IOCTL_SET_PTP_UNICAST_CFG_SETTINGS array of current settings and configuration
+ options of a card's programmable pulse outputs.
+ The function mbg_setup_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO structure passed to this function.
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out
+ field (i.e. the number of programmable outputs on the board) is not 0.
+
+ The array passed to this function to receive the returned data
+ must be able to hold at least ::RECEIVER_INFO::n_prg_out elements.
+
+ @param dh Valid handle to a Meinberg device.
+ @param pii Pointer to a an array of ::PTP_UC_MASTER_INFO_IDX structures to be filled up
+ @param p_umsl Pointer to a ::PTP_UC_MASTER_CFG_LIMITS structure returned by mbg_get_ptp_uc_master_cfg_limits()
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see //##++++++++++++++++++++++
+ @see
+ @see
+*/
+_MBG_API_ATTR int _MBG_API mbg_get_all_ptp_uc_master_info( MBG_DEV_HANDLE dh,
+ PTP_UC_MASTER_INFO_IDX pii[],
+ const PTP_UC_MASTER_CFG_LIMITS *p_umsl )
+{
+ _mbgdevio_vars();
+
+ #if _MBG_SUPP_VAR_ACC_SIZE
+ _mbgdevio_read_gps_chk( dh, PC_GPS_ALL_PTP_UC_MASTER_INFO,
+ IOCTL_GET_ALL_PTP_UC_MASTER_INFO, pii,
+ p_umsl->n_supp_master * sizeof( pii[0] ),
+ _pcps_ddev_has_ptp_unicast( dh ) );
+ #else
+ if ( p_umsl && p_umsl->n_supp_master )
+ _mbgdevio_gen_read_gps( dh, PC_GPS_ALL_PTP_UC_MASTER_INFO, pii,
+ p_umsl->n_supp_master * sizeof( pii[0] ) );
+ else
+ return _mbg_err_to_os( MBG_ERR_NOT_SUPP_BY_DEV );
+ #endif
+
+ #if defined( MBG_ARCH_BIG_ENDIAN )
+ if ( rc == MBG_SUCCESS )
+ {
+ int i;
+ for ( i = 0; i < p_umsl->n_supp_master; i++ )
+ {
+ PTP_UC_MASTER_INFO_IDX *p = &pii[i];
+ _mbg_swab_ptp_uc_master_info_idx( p );
+ }
+ }
+ #endif
+
return _mbgdevio_ret_val;
-} // mbg_get_ptp_unicast_cfg_info
+} // mbg_get_all_ptp_uc_master_info
@@ -5347,21 +5424,21 @@ _MBG_API_ATTR int _MBG_API mbg_get_ptp_unicast_cfg_info( MBG_DEV_HANDLE dh, PTP_
@see mbg_get_ptp_cfg_info()
@see mbg_get_ptp_unicast_cfg_info()
*/
-_MBG_API_ATTR int _MBG_API mbg_set_ptp_unicast_cfg_settings( MBG_DEV_HANDLE dh,
- const PTP_UNICAST_CFG_SETTINGS *p )
+_MBG_API_ATTR int _MBG_API mbg_set_ptp_uc_master_settings_idx( MBG_DEV_HANDLE dh,
+ const PTP_UC_MASTER_SETTINGS_IDX *p )
{
_mbgdevio_vars();
#if defined( MBG_ARCH_BIG_ENDIAN )
- PTP_UNICAST_CFG_SETTINGS tmp = *p;
- _mbg_swab_ptp_unicast_cfg_settings( &tmp );
+ PTP_UC_MASTER_SETTINGS_IDX tmp = *p;
+ _mbg_swab_ptp_uc_master_settings_idx( &tmp );
p = &tmp;
#endif
- _mbgdevio_write_gps_var_chk( dh, PC_GPS_PTP_UNICAST_CFG,
- IOCTL_SET_PTP_UNICAST_CFG_SETTINGS, p,
+ _mbgdevio_write_gps_var_chk( dh, PC_GPS_PTP_UC_MASTER_SETTINGS_IDX,
+ IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX, p,
_pcps_ddev_has_ptp_unicast( dh ) );
return _mbgdevio_ret_val;
-} // mbg_set_ptp_unicast_cfg_settings
+} // mbg_set_ptp_uc_master_settings_idx
@@ -5439,6 +5516,158 @@ _MBG_API_ATTR int _MBG_API mbg_get_time_info_tstamp( MBG_DEV_HANDLE dh, MBG_TIME
/*HDR*/
/**
+ Check if a specific device supports demodulation of the DCF77 PZF code.
+
+ @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_dev_has_corr_info()
+ @see mbg_dev_has_tr_distance()
+*/
+_MBG_API_ATTR int _MBG_API mbg_dev_has_pzf( MBG_DEV_HANDLE dh, int *p )
+{
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_pzf, IOCTL_DEV_HAS_PZF, p );
+
+} // mbg_dev_has_pzf
+
+
+
+/*HDR*/
+/**
+ Check if a specific device supports reading correlation info.
+
+ @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_dev_has_pzf()
+ @see mbg_get_corr_info()
+*/
+_MBG_API_ATTR int _MBG_API mbg_dev_has_corr_info( MBG_DEV_HANDLE dh, int *p )
+{
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_corr_info, IOCTL_DEV_HAS_CORR_INFO, p );
+
+} // mbg_dev_has_corr_info
+
+
+
+/*HDR*/
+/**
+ Check if a specific device supports configurable distance from transmitter
+ used to compensate RF propagation delay.
+
+ @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_dev_has_pzf()
+ @see mbg_get_tr_distance()
+ @see mbg_set_tr_distance()
+*/
+_MBG_API_ATTR int _MBG_API mbg_dev_has_tr_distance( MBG_DEV_HANDLE dh, int *p )
+{
+ _mbgdevio_query_cond( dh, _pcps_ddev_has_tr_distance, IOCTL_DEV_HAS_TR_DISTANCE, p );
+
+} // mbg_dev_has_tr_distance
+
+
+
+/*HDR*/
+/**
+ Read PZF correlation info from a card which supports this.
+ The macro _pcps_has_corr_info() or the API call mbg_dev_has_corr_info()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::CORR_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_corr_info()
+ */
+_MBG_API_ATTR int _MBG_API mbg_get_corr_info( MBG_DEV_HANDLE dh, CORR_INFO *p )
+{
+ _mbgdevio_vars();
+ _mbgdevio_read_var_chk( dh, PCPS_GET_CORR_INFO,
+ IOCTL_GET_CORR_INFO, p,
+ _pcps_ddev_has_corr_info( dh ) );
+ _mbg_swab_corr_info( p );
+ return _mbgdevio_ret_val;
+
+} // mbg_get_corr_info
+
+
+
+/*HDR*/
+/**
+ Read configurable "distance from transmitter" parameter from a card
+ which supports this. The parameter is used to compensate the RF signal
+ propagation delay.
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_set_tr_distance()
+ */
+_MBG_API_ATTR int _MBG_API mbg_get_tr_distance( MBG_DEV_HANDLE dh, TR_DISTANCE *p )
+{
+ _mbgdevio_vars();
+ _mbgdevio_read_var_chk( dh, PCPS_GET_TR_DISTANCE,
+ IOCTL_GET_TR_DISTANCE, p,
+ _pcps_ddev_has_tr_distance( dh ) );
+ _mbg_swab_tr_distance( p );
+ return _mbgdevio_ret_val;
+
+} // mbg_get_tr_distance
+
+
+
+/*HDR*/
+/**
+ Write configurable "distance from transmitter" parameter to a card
+ which supports this. The parameter is used to compensate the RF signal
+ propagation delay.
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_get_tr_distance()
+ */
+_MBG_API_ATTR int _MBG_API mbg_set_tr_distance( MBG_DEV_HANDLE dh, const TR_DISTANCE *p )
+{
+ _mbgdevio_vars();
+ #if defined( MBG_ARCH_BIG_ENDIAN )
+ TR_DISTANCE tmp = *p;
+ _mbg_swab_tr_distance( &tmp );
+ p = &tmp;
+ #endif
+ _mbgdevio_write_var_chk( dh, PCPS_SET_TR_DISTANCE, IOCTL_SET_TR_DISTANCE,
+ p, _pcps_ddev_has_tr_distance( dh ) );
+ return _mbgdevio_ret_val;
+
+} // mbg_set_tr_distance
+
+
+
+/*HDR*/
+/**
Read the CPU affinity of a process, i.e. on which of the available
CPUs the process can be executed.
@@ -5778,7 +6007,7 @@ MBG_THREAD_FNC_RET_VAL MBG_THREAD_FNC_ATTR mbg_xhrt_poll_thread_fnc( void *p_voi
}
- _mbg_mutex_lock( &p->mutex );
+ _mbg_crit_sect_enter( &p->crit_sect );
if ( rc == MBG_SUCCESS )
{
@@ -5793,7 +6022,7 @@ MBG_THREAD_FNC_RET_VAL MBG_THREAD_FNC_ATTR mbg_xhrt_poll_thread_fnc( void *p_voi
sleep_ms = p->sleep_ms;
- _mbg_mutex_unlock( &p->mutex );
+ _mbg_crit_sect_leave( &p->crit_sect );
if ( rc == MBG_SUCCESS )
@@ -5845,7 +6074,7 @@ _MBG_API_ATTR int _MBG_API mbg_xhrt_poll_thread_create( MBG_POLL_THREAD_INFO *p_
p_pti->xhrt_info.dh = dh;
p_pti->xhrt_info.freq_hz = freq_hz;
p_pti->xhrt_info.sleep_ms = sleep_ms ? sleep_ms : 1000; // sleep 1 second by default
- _mbg_mutex_init( &p_pti->xhrt_info.mutex );
+ _mbg_crit_sect_init( &p_pti->xhrt_info.crit_sect );
rc = mbg_thread_create( &p_pti->ti, mbg_xhrt_poll_thread_fnc, p_pti );
@@ -5875,7 +6104,7 @@ _MBG_API_ATTR int _MBG_API mbg_xhrt_poll_thread_stop( MBG_POLL_THREAD_INFO *p_pt
int rc = mbg_thread_stop( &p_pti->ti );
if ( rc == MBG_SUCCESS )
- _mbg_mutex_deinit( &p_pti->xhrt_info.mutex );
+ _mbg_crit_sect_destroy( &p_pti->xhrt_info.crit_sect );
return rc;
@@ -5894,11 +6123,11 @@ int mbg_get_xhrt_data( MBG_XHRT_INFO *p, uint64_t *tstamp, MBG_XHRT_VARS *vars )
mbg_get_pc_cycles( &cyc_now );
- _mbg_mutex_lock( &p->mutex );
+ _mbg_crit_sect_enter( &p->crit_sect );
xhrt_vars = p->vars;
freq_hz = p->freq_hz;
ioctl_status = p->ioctl_status;
- _mbg_mutex_unlock( &p->mutex );
+ _mbg_crit_sect_leave( &p->crit_sect );
if ( freq_hz && xhrt_vars.pcps_hr_tstamp64 )
{
@@ -6026,10 +6255,10 @@ _MBG_API_ATTR int _MBG_API mbg_get_xhrt_cycles_frequency( MBG_XHRT_INFO *p, MBG_
MBG_PC_CYCLES_FREQUENCY freq_hz;
int ioctl_status;
- _mbg_mutex_lock( &p->mutex );
+ _mbg_crit_sect_enter( &p->crit_sect );
freq_hz = p->freq_hz;
ioctl_status = p->ioctl_status;
- _mbg_mutex_unlock( &p->mutex );
+ _mbg_crit_sect_leave( &p->crit_sect );
if ( p_freq_hz )
*p_freq_hz = freq_hz;
@@ -6055,7 +6284,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_xhrt_cycles_frequency( MBG_XHRT_INFO *p, MBG_
*/
_MBG_API_ATTR int _MBG_API mbg_get_default_cycles_frequency_from_dev( MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p )
{
- #if defined( _MBGIOCTL_H ) && defined( MBG_PC_CYCLES_SUPPORTED )
+ #if defined( _MBGIOCTL_H )
_mbgdevio_vars();
_mbgdevio_read_var( dh, -1, IOCTL_GET_CYCLES_FREQUENCY, p );
// native endianess, no need to swap bytes
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.h
index b79ab8d..9dd3bf4 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.39.1.14 2011/03/31 13:20:55 martin TRASH $
+ * $Id: mbgdevio.h 1.39.1.18 2011/07/06 11:19:24 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,17 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
+ * Revision 1.39.1.18 2011/07/06 11:19:24 martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.39.1.17 2011/06/29 11:10:19 martin
+ * Updated function prototypes.
+ * Revision 1.39.1.16 2011/06/22 10:16:22 martin
+ * Cleaned up handling of pragma pack().
+ * Cleaned up inclusion of header files.
+ * Updated function prototypes.
+ * Revision 1.39.1.15 2011/04/12 12:57:53 martin
+ * Moved mutex definitions to new mbgmutex.h.
+ * Renamed mutex stuff to critical sections.
* Revision 1.39.1.14 2011/03/31 13:20:55 martin
* Updated function prototypes.
* Revision 1.39.1.13 2011/02/15 14:26:22Z martin
@@ -170,10 +181,11 @@
/* Other headers to be included */
-#include <mbggeo.h>
#include <mbg_tgt.h>
#include <mbg_arch.h>
+#include <mbgmutex.h>
#include <mbgerror.h>
+#include <mbggeo.h>
#include <pcpsdev.h>
#include <pcpsutil.h>
#include <pci_asic.h>
@@ -220,6 +232,14 @@
#define MBG_USE_KERNEL_DRIVER 1
#include <fcntl.h>
+ #if !defined( MBG_ARCH_ARM )
+ #include <sched.h>
+
+ #if MBGDEVIO_USE_THREAD_API
+ #include <pthread.h>
+ #endif
+ #endif
+
#elif defined( MBG_TGT_BSD )
#define MBG_USE_KERNEL_DRIVER 1
@@ -265,8 +285,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -306,8 +327,6 @@ typedef char MBG_HW_NAME[PCPS_CLOCK_NAME_SZ + PCPS_SN_SIZE + 1];
#if defined( MBG_TGT_LINUX ) && !defined( MBG_ARCH_ARM )
- #include <sched.h>
-
#define MBG_PROCESS_ID pid_t
#define _mbg_get_current_process() 0
@@ -319,20 +338,12 @@ typedef char MBG_HW_NAME[PCPS_CLOCK_NAME_SZ + PCPS_SN_SIZE + 1];
#if MBGDEVIO_USE_THREAD_API
- #include <pthread.h>
-
#define MBG_THREAD_ID pthread_t
#define _mbg_get_current_thread() 0
#define MBG_THREAD_FNC_ATTR // empty
#define MBG_THREAD_FNC_RET_VAL void *
#define _mbg_thread_exit( _v ) return (void *) (_v)
- #define MBG_MUTEX pthread_mutex_t
- #define _mbg_mutex_init( _pm ) pthread_mutex_init( (_pm), NULL )
- #define _mbg_mutex_deinit( _pm ) _nop_macro_fnc()
- #define _mbg_mutex_lock( _pm ) pthread_mutex_lock( (_pm) )
- #define _mbg_mutex_unlock( _pm ) pthread_mutex_unlock( (_pm) )
-
#endif
#elif defined( MBG_TGT_WIN32 )
@@ -349,12 +360,6 @@ typedef char MBG_HW_NAME[PCPS_CLOCK_NAME_SZ + PCPS_SN_SIZE + 1];
#define MBG_THREAD_FNC_RET_VAL DWORD
#define _mbg_thread_exit( _v ) ExitThread( _v ); return (_v)
- #define MBG_MUTEX CRITICAL_SECTION
- #define _mbg_mutex_init( _pm ) InitializeCriticalSection( (_pm) )
- #define _mbg_mutex_deinit( _pm ) DeleteCriticalSection( (_pm) )
- #define _mbg_mutex_lock( _pm ) EnterCriticalSection( (_pm) )
- #define _mbg_mutex_unlock( _pm ) LeaveCriticalSection( (_pm) )
-
#endif // target specific
@@ -415,26 +420,6 @@ typedef char MBG_HW_NAME[PCPS_CLOCK_NAME_SZ + PCPS_SN_SIZE + 1];
#endif
-#if !defined( MBG_MUTEX )
- #define MBG_MUTEX int
-#endif
-
-#if !defined( _mbg_mutex_init )
- #define _mbg_mutex_init( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_deinit )
- #define _mbg_mutex_deinit( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_lock )
- #define _mbg_mutex_lock( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_unlock )
- #define _mbg_mutex_unlock( _pm ) _nop_macro_fnc()
-#endif
-
typedef struct
{
MBG_THREAD_ID thread_id;
@@ -459,7 +444,7 @@ typedef struct
MBG_PC_CYCLES_FREQUENCY freq_hz;
int ioctl_status;
int sleep_ms;
- MBG_MUTEX mutex;
+ MBG_CRIT_SECT crit_sect;
MBG_DEV_HANDLE dh;
} MBG_XHRT_INFO;
@@ -1177,7 +1162,7 @@ extern "C" {
@see mbg_get_raw_irig_data()
@see mbg_get_raw_irig_data_on_sec_change()
*/
- _MBG_API_ATTR int _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p) ;
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p ) ;
/**
Read a ::MBG_RAW_IRIG_DATA type which contains all data
@@ -2714,7 +2699,8 @@ extern "C" {
@return ::MBG_SUCCESS or error code returned by device I/O control function.
@see mbg_get_ptp_state()
- @see mbg_get_ptp_unicast_cfg_info()
+ @see mbg_get_ptp_uc_master_cfg_limits()
+ @see mbg_get_all_ptp_uc_master_info()
@see mbg_set_ptp_unicast_cfg_settings()
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp_unicast( MBG_DEV_HANDLE dh, int *p ) ;
@@ -2780,7 +2766,30 @@ extern "C" {
@see mbg_dev_has_ptp_unicast()
@see mbg_set_ptp_unicast_cfg_settings()
*/
- _MBG_API_ATTR int _MBG_API mbg_get_ptp_unicast_cfg_info( MBG_DEV_HANDLE dh, PTP_UNICAST_CFG_INFO *p ) ;
+ _MBG_API_ATTR int _MBG_API mbg_get_ptp_uc_master_cfg_limits( MBG_DEV_HANDLE dh, PTP_UC_MASTER_CFG_LIMITS *p ) ;
+
+ /**
+ Read a ::IOCTL_SET_PTP_UNICAST_CFG_SETTINGS array of current settings and configuration
+ options of a card's programmable pulse outputs.
+ The function mbg_setup_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO structure passed to this function.
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out
+ field (i.e. the number of programmable outputs on the board) is not 0.
+
+ The array passed to this function to receive the returned data
+ must be able to hold at least ::RECEIVER_INFO::n_prg_out elements.
+
+ @param dh Valid handle to a Meinberg device.
+ @param pii Pointer to a an array of ::PTP_UC_MASTER_INFO_IDX structures to be filled up
+ @param p_umsl Pointer to a ::PTP_UC_MASTER_CFG_LIMITS structure returned by mbg_get_ptp_uc_master_cfg_limits()
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see //##++++++++++++++++++++++
+ @see
+ @see
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_all_ptp_uc_master_info( MBG_DEV_HANDLE dh, PTP_UC_MASTER_INFO_IDX pii[], const PTP_UC_MASTER_CFG_LIMITS *p_umsl ) ;
/**
Write PTP/IEEE1588 unicast configuration settings to a card which supports this.
@@ -2797,7 +2806,7 @@ extern "C" {
@see mbg_get_ptp_cfg_info()
@see mbg_get_ptp_unicast_cfg_info()
*/
- _MBG_API_ATTR int _MBG_API mbg_set_ptp_unicast_cfg_settings( MBG_DEV_HANDLE dh, const PTP_UNICAST_CFG_SETTINGS *p ) ;
+ _MBG_API_ATTR int _MBG_API mbg_set_ptp_uc_master_settings_idx( MBG_DEV_HANDLE dh, const PTP_UC_MASTER_SETTINGS_IDX *p ) ;
/**
Read system time and card time from the kernel driver. The kernel
@@ -2842,6 +2851,98 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_time_info_tstamp( MBG_DEV_HANDLE dh, MBG_TIME_INFO_TSTAMP *p ) ;
/**
+ Check if a specific device supports demodulation of the DCF77 PZF code.
+
+ @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_dev_has_corr_info()
+ @see mbg_dev_has_tr_distance()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_pzf( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Check if a specific device supports reading correlation info.
+
+ @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_dev_has_pzf()
+ @see mbg_get_corr_info()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_corr_info( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Check if a specific device supports configurable distance from transmitter
+ used to compensate RF propagation delay.
+
+ @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_dev_has_pzf()
+ @see mbg_get_tr_distance()
+ @see mbg_set_tr_distance()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_tr_distance( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read PZF correlation info from a card which supports this.
+ The macro _pcps_has_corr_info() or the API call mbg_dev_has_corr_info()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::CORR_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_corr_info()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_corr_info( MBG_DEV_HANDLE dh, CORR_INFO *p ) ;
+
+ /**
+ Read configurable "distance from transmitter" parameter from a card
+ which supports this. The parameter is used to compensate the RF signal
+ propagation delay.
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_set_tr_distance()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_tr_distance( MBG_DEV_HANDLE dh, TR_DISTANCE *p ) ;
+
+ /**
+ Write configurable "distance from transmitter" parameter to a card
+ which supports this. The parameter is used to compensate the RF signal
+ propagation delay.
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_get_tr_distance()
+ */
+ _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
CPUs the process can be executed.
@@ -3145,9 +3246,9 @@ void uint64_to_pcps_time_stamp( PCPS_TIME_STAMP *ts, uint64_t n )
#endif
-
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgerror.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgerror.h
index 869b7b2..714dd45 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgerror.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgerror.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgerror.h 1.5 2011/03/31 10:56:17 martin TRASH $
+ * $Id: mbgerror.h 1.5.1.1 2011/04/20 16:09:19 martin TRASH martin $
* $Name: $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
@@ -12,6 +12,7 @@
*
* -----------------------------------------------------------------------
* $Log: mbgerror.h $
+ * Revision 1.5.1.1 2011/04/20 16:09:19 martin
* Revision 1.5 2011/03/31 10:56:17 martin
* Added MBG_ERR_COPY_TO_USER and MBG_ERR_COPY_FROM_USER.
* Revision 1.4 2008/12/05 13:28:50 martin
@@ -46,7 +47,7 @@
/* Start of header body */
-/**
+/**
@defgroup group_error_codes Error codes
Error codes used with Meinberg devices and drivers.
@@ -56,13 +57,14 @@
For Windows, these codes are made positive and or'ed with 0xE0000000 afterwards.
Example: Code -19 (#MBG_ERR_GENERIC) will be converted to 0xE0000013 under Windows.
-
+
+ @note Attention:
+ These error codes below must match exactly the corresponding codes that are evaluated in user space.
+ For Windows, they are located in messages.mc/.h in mbgsvctl.dll
+
@{
*/
-// Attention!!
-// These error codes below must fit exactly to the corresponding codes that are evaluated in user space.
-// For Windows, they are located in messages.mc/.h in mbgsvctl.dll
#define MBG_SUCCESS PCPS_SUCCESS /**< 0, no error */
@@ -101,7 +103,8 @@
#define MBG_ERR_N_STR_EXCEEDS_SUPP -37 /**< The number of string formats supported by the device
exceeds the maximum supported by the driver */
#define MBG_ERR_IRQ_UNSAFE -38 /**< The enabled IRQs are unsafe with this firmware/ASIC version */
-
+#define MBG_ERR_N_POUT_EXCEEDS_SUPP -39 /**< The number of programmable outputs provided by the device
+ exceeds the maximum supported by the driver */
// Legacy codes used with DOS TSRs only:
#define MBG_ERR_INV_INTNO -40 /**< Invalid interrupt number */
@@ -112,7 +115,11 @@
#define MBG_ERR_COPY_TO_USER -43 /**< kernel driver failed to copy data from kernel to user space */
#define MBG_ERR_COPY_FROM_USER -44 /**< kernel driver failed to copy data from use to kernel space */
-/** @} */ // endgroup
+// More codes returned by the driver's high level functions:
+
+#define MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP -39 /**< The number of PTP unicast masters supported by the device
+ exceeds the maximum supported by the driver */
+/** @} group_error_codes */
// Depending on the operating system, the codes above have to be converted before
// they are sent up to user space
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbggeo.h b/src/external/bsd/meinberg/dist/mbglib/common/mbggeo.h
index c375570..76cf179 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbggeo.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbggeo.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbggeo.h 1.10 2008/09/03 14:54:28 martin REL_M $
+ * $Id: mbggeo.h 1.11 2011/06/22 10:18:10 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -22,6 +22,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbggeo.h $
+ * Revision 1.11 2011/06/22 10:18:10 martin
+ * Cleaned up handling of pragma pack().
* Revision 1.10 2008/09/03 14:54:28 martin
* Added macros to swap endianess of structures.
* Revision 1.9 2008/01/17 09:31:33 daniel
@@ -62,8 +64,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -284,8 +287,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgioctl.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgioctl.h
index bf9776b..dd1ca4d 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgioctl.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgioctl.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgioctl.h 1.24.1.2 2011/03/22 11:19:46 martin TRASH martin $
+ * $Id: mbgioctl.h 1.24.1.7 2011/07/15 14:50:11 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,25 @@
*
* -----------------------------------------------------------------------
* $Log: mbgioctl.h $
+ * Revision 1.24.1.7 2011/07/15 14:50:11 martin
+ * Revision 1.24.1.6 2011/07/14 14:54:01 martin
+ * Modified generic IOCTL handling such that for calls requiring variable sizes
+ * a fixed request block containing input and output buffer pointers and sizes is
+ * passed down to the kernel driver. This simplifies implementation under *BSD
+ * and also works for other target systems.
+ * Revision 1.24.1.5 2011/07/06 11:19:28 martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.24.1.4 2011/06/29 10:52:00 martin
+ * New code IOCTL_DEV_HAS_PZF.
+ * Revision 1.24.1.3 2011/06/21 15:03:29 martin
+ * Support PTP unicast configuration.
+ * Changed the names of a few IOCTL codes to follow general naming conventions.
+ * Added definitions to support privilege level requirements for IOCTLs.
+ * Use native alignment to avoid problems on Sparc and IA64.
+ * Added definitions to set up a table of all known
+ * IOCTL codes and names.
+ * Use MBG_TGT_KERNEL instead of _KDD_.
+ * Fixed a typo.
* Revision 1.24.1.2 2011/03/22 11:19:46 martin
* Use IOTYPE 'Z' under *BSD since this means passthrough on NetBSD.
* Revision 1.24.1.1 2011/02/15 11:21:21 daniel
@@ -105,9 +124,12 @@
/* Other headers to be included */
#include <mbg_tgt.h>
-#include <pcpsdev.h>
#include <mbggeo.h>
-#include <use_pack.h>
+#include <pcpsdev.h>
+
+
+#define USE_DEBUG_PORT defined( MBG_ARCH_X86 )
+
#if defined( MBG_TGT_LINUX )
@@ -143,7 +165,7 @@
#define _MBG_SUPP_VAR_ACC_SIZE 1
#endif
- #ifndef _KDD_ // must be defined in the KDDs' SOURCES file
+ #if !defined( MBG_TGT_KERNEL )
#include <windows.h>
#include <winioctl.h>
#endif
@@ -201,23 +223,38 @@
#endif
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
-#endif
+/* Start of header body */
+
+// We must use native alignment here!
+
+
+// The structure below is used by the IOCTL_PCPS_GENERIC_... calls.
+
+// This does not yet work properly under Linux/Sparc where the kernel may be 64 bit
+// while user space is 32 bit, which leads to different sizes for pointers and size_t.
+
+typedef struct
+{
+ unsigned long info;
+ const void *in_p;
+ size_t in_sz;
+ void *out_p;
+ size_t out_sz;
+} IOCTL_GENERIC_REQ;
-/* Start of header body */
// read general driver info, device info, and status port
#define IOCTL_GET_PCPS_DRVR_INFO _MBG_IOR( IOTYPE, 0x00, PCPS_DRVR_INFO )
#define IOCTL_GET_PCPS_DEV _MBG_IOR( IOTYPE, 0x01, PCPS_DEV )
#define IOCTL_GET_PCPS_STATUS_PORT _MBG_IOR( IOTYPE, 0x02, PCPS_STATUS_PORT )
-// generic read/write operations (preliminary)
-#define IOCTL_PCPS_GENERIC_READ _MBG_IO( IOTYPE, 0x03 )
-#define IOCTL_PCPS_GENERIC_WRITE _MBG_IO( IOTYPE, 0x04 )
-#define IOCTL_PCPS_GENERIC_READ_GPS _MBG_IO( IOTYPE, 0x05 )
-#define IOCTL_PCPS_GENERIC_WRITE_GPS _MBG_IO( IOTYPE, 0x06 )
+// Generic read/write operations. We define _MBG_IOW codes since these calls
+// eventually pass a generic request structure IOCTL_GENERIC_REQ to the driver.
+#define IOCTL_PCPS_GENERIC_READ _MBG_IOW( IOTYPE, 0x03, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_WRITE _MBG_IOW( IOTYPE, 0x04, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_READ_GPS _MBG_IOW( IOTYPE, 0x05, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_WRITE_GPS _MBG_IOW( IOTYPE, 0x06, IOCTL_GENERIC_REQ )
// normal direct read/write operations
#define IOCTL_GET_PCPS_TIME _MBG_IOR( IOTYPE, 0x10, PCPS_TIME )
@@ -289,8 +326,8 @@
#define IOCTL_SET_GPS_ANT_CABLE_LEN _MBG_IOW( IOTYPE, 0x38, ANT_CABLE_LEN )
#define IOCTL_GET_GPS_RECEIVER_INFO _MBG_IOR( IOTYPE, 0x39, RECEIVER_INFO )
-#define IOCTL_GET_GPS_ALL_STR_TYPE_INFO _MBG_IO( IOTYPE, 0x3A ) // size variable
-#define IOCTL_GET_GPS_ALL_PORT_INFO _MBG_IO( IOTYPE, 0x3B ) // size variable
+#define IOCTL_GET_GPS_ALL_STR_TYPE_INFO _MBG_IOW( IOTYPE, 0x3A, IOCTL_GENERIC_REQ ) // variable size
+#define IOCTL_GET_GPS_ALL_PORT_INFO _MBG_IOW( IOTYPE, 0x3B, IOCTL_GENERIC_REQ ) // variable size
#define IOCTL_SET_GPS_PORT_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x3C, PORT_SETTINGS_IDX )
@@ -331,11 +368,11 @@
#define IOCTL_DEV_HAS_SYNTH _MBG_IOR( IOTYPE, 0x59, int )
#define IOCTL_DEV_HAS_GENERIC_IO _MBG_IOR( IOTYPE, 0x5A, int )
-#define IOCTL_PCPS_GENERIC_IO _MBG_IO( IOTYPE, 0x5B )
+#define IOCTL_PCPS_GENERIC_IO _MBG_IOW( IOTYPE, 0x5B, IOCTL_GENERIC_REQ )
#define IOCTL_GET_SYNTH_STATE _MBG_IOR( IOTYPE, 0x5C, SYNTH_STATE )
-#define IOCTL_GET_GPS_ALL_POUT_INFO _MBG_IO( IOTYPE, 0x5D ) // size variable
+#define IOCTL_GET_GPS_ALL_POUT_INFO _MBG_IOW( IOTYPE, 0x5D, IOCTL_GENERIC_REQ ) // variable size
#define IOCTL_SET_GPS_POUT_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x5E, POUT_SETTINGS_IDX )
#define IOCTL_GET_MAPPED_MEM_ADDR _MBG_IOR( IOTYPE, 0x5F, PCPS_MAPPED_MEM )
@@ -343,8 +380,8 @@
#define IOCTL_GET_PCI_ASIC_FEATURES _MBG_IOR( IOTYPE, 0x61, PCI_ASIC_FEATURES )
-#define IOCTL_HAS_PCI_ASIC_FEATURES _MBG_IOR( IOTYPE, 0x62, int )
-#define IOCTL_HAS_PCI_ASIC_VERSION _MBG_IOR( IOTYPE, 0x63, int )
+#define IOCTL_DEV_HAS_PCI_ASIC_FEATURES _MBG_IOR( IOTYPE, 0x62, int )
+#define IOCTL_DEV_HAS_PCI_ASIC_VERSION _MBG_IOR( IOTYPE, 0x63, int )
#define IOCTL_DEV_IS_MSF _MBG_IOR( IOTYPE, 0x64, int )
#define IOCTL_DEV_IS_LWR _MBG_IOR( IOTYPE, 0x65, int )
@@ -353,7 +390,7 @@
#define IOCTL_GET_IRQ_STAT_INFO _MBG_IOR( IOTYPE, 0x67, PCPS_IRQ_STAT_INFO )
#define IOCTL_GET_CYCLES_FREQUENCY _MBG_IOR( IOTYPE, 0x68, MBG_PC_CYCLES_FREQUENCY )
-#define IOCTL_HAS_FAST_HR_TIMESTAMP _MBG_IOR( IOTYPE, 0x69, int )
+#define IOCTL_DEV_HAS_FAST_HR_TIMESTAMP _MBG_IOR( IOTYPE, 0x69, int )
#define IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES _MBG_IOR( IOTYPE, 0x6A, PCPS_TIME_STAMP_CYCLES )
#define IOCTL_GET_FAST_HR_TIMESTAMP _MBG_IOR( IOTYPE, 0x6B, PCPS_TIME_STAMP )
@@ -389,9 +426,17 @@
#define IOCTL_DEV_HAS_RAW_IRIG_DATA _MBG_IOR( IOTYPE, 0x82, int )
#define IOCTL_GET_RAW_IRIG_DATA _MBG_IOR( IOTYPE, 0x83, MBG_RAW_IRIG_DATA )
-#define IOCTL_DEV_HAS_PTP_UNICAST _MBG_IOR( IOTYPE, 0x84, int )
-#define IOCTL_GET_PTP_UNICAST_CFG_INFO _MBG_IOR( IOTYPE, 0x85, PTP_UNICAST_CFG_INFO )
-#define IOCTL_SET_PTP_UNICAST_CFG_SETTINGS _MBG_IOW( IOTYPE, 0x86, PTP_UNICAST_CFG_SETTINGS )
+#define IOCTL_DEV_HAS_PTP_UNICAST _MBG_IOR( IOTYPE, 0x84, int )
+#define IOCTL_PTP_UC_MASTER_CFG_LIMITS _MBG_IOR( IOTYPE, 0x85, PTP_UC_MASTER_CFG_LIMITS )
+#define IOCTL_GET_ALL_PTP_UC_MASTER_INFO _MBG_IOW( IOTYPE, 0x86, IOCTL_GENERIC_REQ ) // variable size
+#define IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x87, PTP_UC_MASTER_SETTINGS_IDX )
+
+#define IOCTL_DEV_HAS_PZF _MBG_IOR( IOTYPE, 0x88, int )
+#define IOCTL_DEV_HAS_CORR_INFO _MBG_IOR( IOTYPE, 0x89, int )
+#define IOCTL_DEV_HAS_TR_DISTANCE _MBG_IOR( IOTYPE, 0x8A, int )
+#define IOCTL_GET_CORR_INFO _MBG_IOR( IOTYPE, 0x8B, CORR_INFO )
+#define IOCTL_GET_TR_DISTANCE _MBG_IOR( IOTYPE, 0x8C, TR_DISTANCE )
+#define IOCTL_SET_TR_DISTANCE _MBG_IOW( IOTYPE, 0x8D, TR_DISTANCE )
// 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.
@@ -403,26 +448,408 @@
#define IOCTL_MBG_DBG_CLR_ALL _MBG_IO( IOTYPE, 0xF4 )
+
+/**
+ * @brief An element for a table of IOCTL codes and names.
+ */
+typedef struct
+{
+ ulong code;
+ const char *name;
+} MBG_IOCTL_TABLE_ENTRY;
+
+
+/**
+ * @brief An initializer for an array of MBG_IOCTL_TABLE_ENTRY elements.
+ *
+ * This can be useful for debugging.
+ */
+#define MBG_IOCTL_TABLE \
+{ \
+ { IOCTL_GET_PCPS_DRVR_INFO, "IOCTL_GET_PCPS_DRVR_INFO" }, \
+ { IOCTL_GET_PCPS_DEV, "IOCTL_GET_PCPS_DEV" }, \
+ { IOCTL_GET_PCPS_STATUS_PORT, "IOCTL_GET_PCPS_STATUS_PORT" }, \
+ { IOCTL_PCPS_GENERIC_READ, "IOCTL_PCPS_GENERIC_READ" }, \
+ { IOCTL_PCPS_GENERIC_WRITE, "IOCTL_PCPS_GENERIC_WRITE" }, \
+ { IOCTL_PCPS_GENERIC_READ_GPS, "IOCTL_PCPS_GENERIC_READ_GPS" }, \
+ { IOCTL_PCPS_GENERIC_WRITE_GPS, "IOCTL_PCPS_GENERIC_WRITE_GPS" }, \
+ { IOCTL_GET_PCPS_TIME, "IOCTL_GET_PCPS_TIME" }, \
+ { IOCTL_SET_PCPS_TIME, "IOCTL_SET_PCPS_TIME" }, \
+ { IOCTL_GET_PCPS_SYNC_TIME, "IOCTL_GET_PCPS_SYNC_TIME" }, \
+ { IOCTL_GET_PCPS_TIME_SEC_CHANGE, "IOCTL_GET_PCPS_TIME_SEC_CHANGE" }, \
+ { IOCTL_GET_PCPS_HR_TIME, "IOCTL_GET_PCPS_HR_TIME" }, \
+ { IOCTL_SET_PCPS_EVENT_TIME, "IOCTL_SET_PCPS_EVENT_TIME" }, \
+ { IOCTL_GET_PCPS_SERIAL, "IOCTL_GET_PCPS_SERIAL" }, \
+ { IOCTL_SET_PCPS_SERIAL, "IOCTL_SET_PCPS_SERIAL" }, \
+ { IOCTL_GET_PCPS_TZCODE, "IOCTL_GET_PCPS_TZCODE" }, \
+ { IOCTL_SET_PCPS_TZCODE, "IOCTL_SET_PCPS_TZCODE" }, \
+ { IOCTL_GET_PCPS_TZDL, "IOCTL_GET_PCPS_TZDL" }, \
+ { IOCTL_SET_PCPS_TZDL, "IOCTL_SET_PCPS_TZDL" }, \
+ { IOCTL_GET_REF_OFFS, "IOCTL_GET_REF_OFFS" }, \
+ { IOCTL_SET_REF_OFFS, "IOCTL_SET_REF_OFFS" }, \
+ { IOCTL_GET_MBG_OPT_INFO, "IOCTL_GET_MBG_OPT_INFO" }, \
+ { IOCTL_SET_MBG_OPT_SETTINGS, "IOCTL_SET_MBG_OPT_SETTINGS" }, \
+ { IOCTL_GET_PCPS_IRIG_RX_INFO, "IOCTL_GET_PCPS_IRIG_RX_INFO" }, \
+ { IOCTL_SET_PCPS_IRIG_RX_SETTINGS, "IOCTL_SET_PCPS_IRIG_RX_SETTINGS" }, \
+ { IOCTL_PCPS_CLR_UCAP_BUFF, "IOCTL_PCPS_CLR_UCAP_BUFF" }, \
+ { IOCTL_GET_PCPS_UCAP_ENTRIES, "IOCTL_GET_PCPS_UCAP_ENTRIES" }, \
+ { IOCTL_GET_PCPS_UCAP_EVENT, "IOCTL_GET_PCPS_UCAP_EVENT" }, \
+ { IOCTL_GET_GPS_TZDL, "IOCTL_GET_GPS_TZDL" }, \
+ { IOCTL_SET_GPS_TZDL, "IOCTL_SET_GPS_TZDL" }, \
+ { IOCTL_GET_GPS_SW_REV, "IOCTL_GET_GPS_SW_REV" }, \
+ { IOCTL_GET_GPS_BVAR_STAT, "IOCTL_GET_GPS_BVAR_STAT" }, \
+ { IOCTL_GET_GPS_TIME, "IOCTL_GET_GPS_TIME" }, \
+ { IOCTL_SET_GPS_TIME, "IOCTL_SET_GPS_TIME" }, \
+ { IOCTL_GET_GPS_PORT_PARM, "IOCTL_GET_GPS_PORT_PARM" }, \
+ { IOCTL_SET_GPS_PORT_PARM, "IOCTL_SET_GPS_PORT_PARM" }, \
+ { IOCTL_GET_GPS_ANT_INFO, "IOCTL_GET_GPS_ANT_INFO" }, \
+ { IOCTL_GET_GPS_UCAP, "IOCTL_GET_GPS_UCAP" }, \
+ { IOCTL_GET_GPS_ENABLE_FLAGS, "IOCTL_GET_GPS_ENABLE_FLAGS" }, \
+ { IOCTL_SET_GPS_ENABLE_FLAGS, "IOCTL_SET_GPS_ENABLE_FLAGS" }, \
+ { IOCTL_GET_GPS_STAT_INFO, "IOCTL_GET_GPS_STAT_INFO" }, \
+ { IOCTL_SET_GPS_CMD, "IOCTL_SET_GPS_CMD" }, \
+ { IOCTL_GET_GPS_IDENT, "IOCTL_GET_GPS_IDENT" }, \
+ { IOCTL_GET_GPS_POS, "IOCTL_GET_GPS_POS" }, \
+ { IOCTL_SET_GPS_POS_XYZ, "IOCTL_SET_GPS_POS_XYZ" }, \
+ { IOCTL_SET_GPS_POS_LLA, "IOCTL_SET_GPS_POS_LLA" }, \
+ { IOCTL_GET_GPS_ANT_CABLE_LEN, "IOCTL_GET_GPS_ANT_CABLE_LEN" }, \
+ { IOCTL_SET_GPS_ANT_CABLE_LEN, "IOCTL_SET_GPS_ANT_CABLE_LEN" }, \
+ { IOCTL_GET_GPS_RECEIVER_INFO, "IOCTL_GET_GPS_RECEIVER_INFO" }, \
+ { IOCTL_GET_GPS_ALL_STR_TYPE_INFO, "IOCTL_GET_GPS_ALL_STR_TYPE_INFO" }, \
+ { IOCTL_GET_GPS_ALL_PORT_INFO, "IOCTL_GET_GPS_ALL_PORT_INFO" }, \
+ { IOCTL_SET_GPS_PORT_SETTINGS_IDX, "IOCTL_SET_GPS_PORT_SETTINGS_IDX" }, \
+ { IOCTL_GET_PCI_ASIC_VERSION, "IOCTL_GET_PCI_ASIC_VERSION" }, \
+ { IOCTL_GET_PCPS_TIME_CYCLES, "IOCTL_GET_PCPS_TIME_CYCLES" }, \
+ { IOCTL_GET_PCPS_HR_TIME_CYCLES, "IOCTL_GET_PCPS_HR_TIME_CYCLES" }, \
+ { IOCTL_GET_PCPS_IRIG_TX_INFO, "IOCTL_GET_PCPS_IRIG_TX_INFO" }, \
+ { IOCTL_SET_PCPS_IRIG_TX_SETTINGS, "IOCTL_SET_PCPS_IRIG_TX_SETTINGS" }, \
+ { IOCTL_GET_SYNTH, "IOCTL_GET_SYNTH" }, \
+ { IOCTL_SET_SYNTH, "IOCTL_SET_SYNTH" }, \
+ { IOCTL_DEV_IS_GPS, "IOCTL_DEV_IS_GPS" }, \
+ { IOCTL_DEV_IS_DCF, "IOCTL_DEV_IS_DCF" }, \
+ { IOCTL_DEV_IS_IRIG_RX, "IOCTL_DEV_IS_IRIG_RX" }, \
+ { IOCTL_DEV_HAS_HR_TIME, "IOCTL_DEV_HAS_HR_TIME" }, \
+ { IOCTL_DEV_HAS_CAB_LEN, "IOCTL_DEV_HAS_CAB_LEN" }, \
+ { IOCTL_DEV_HAS_TZDL, "IOCTL_DEV_HAS_TZDL" }, \
+ { IOCTL_DEV_HAS_PCPS_TZDL, "IOCTL_DEV_HAS_PCPS_TZDL" }, \
+ { IOCTL_DEV_HAS_TZCODE, "IOCTL_DEV_HAS_TZCODE" }, \
+ { IOCTL_DEV_HAS_TZ, "IOCTL_DEV_HAS_TZ" }, \
+ { IOCTL_DEV_HAS_EVENT_TIME, "IOCTL_DEV_HAS_EVENT_TIME" }, \
+ { IOCTL_DEV_HAS_RECEIVER_INFO, "IOCTL_DEV_HAS_RECEIVER_INFO" }, \
+ { IOCTL_DEV_CAN_CLR_UCAP_BUFF, "IOCTL_DEV_CAN_CLR_UCAP_BUFF" }, \
+ { IOCTL_DEV_HAS_UCAP, "IOCTL_DEV_HAS_UCAP" }, \
+ { IOCTL_DEV_HAS_IRIG_TX, "IOCTL_DEV_HAS_IRIG_TX" }, \
+ { IOCTL_DEV_HAS_SERIAL_HS, "IOCTL_DEV_HAS_SERIAL_HS" }, \
+ { IOCTL_DEV_HAS_SIGNAL, "IOCTL_DEV_HAS_SIGNAL" }, \
+ { IOCTL_DEV_HAS_MOD, "IOCTL_DEV_HAS_MOD" }, \
+ { IOCTL_DEV_HAS_IRIG, "IOCTL_DEV_HAS_IRIG" }, \
+ { IOCTL_DEV_HAS_REF_OFFS, "IOCTL_DEV_HAS_REF_OFFS" }, \
+ { IOCTL_DEV_HAS_OPT_FLAGS, "IOCTL_DEV_HAS_OPT_FLAGS" }, \
+ { IOCTL_DEV_HAS_GPS_DATA, "IOCTL_DEV_HAS_GPS_DATA" }, \
+ { IOCTL_DEV_HAS_SYNTH, "IOCTL_DEV_HAS_SYNTH" }, \
+ { IOCTL_DEV_HAS_GENERIC_IO, "IOCTL_DEV_HAS_GENERIC_IO" }, \
+ { IOCTL_PCPS_GENERIC_IO, "IOCTL_PCPS_GENERIC_IO" }, \
+ { IOCTL_GET_SYNTH_STATE, "IOCTL_GET_SYNTH_STATE" }, \
+ { IOCTL_GET_GPS_ALL_POUT_INFO, "IOCTL_GET_GPS_ALL_POUT_INFO" }, \
+ { IOCTL_SET_GPS_POUT_SETTINGS_IDX, "IOCTL_SET_GPS_POUT_SETTINGS_IDX" }, \
+ { IOCTL_GET_MAPPED_MEM_ADDR, "IOCTL_GET_MAPPED_MEM_ADDR" }, \
+ { IOCTL_UNMAP_MAPPED_MEM, "IOCTL_UNMAP_MAPPED_MEM" }, \
+ { IOCTL_GET_PCI_ASIC_FEATURES, "IOCTL_GET_PCI_ASIC_FEATURES" }, \
+ { IOCTL_DEV_HAS_PCI_ASIC_FEATURES, "IOCTL_DEV_HAS_PCI_ASIC_FEATURES" }, \
+ { IOCTL_DEV_HAS_PCI_ASIC_VERSION, "IOCTL_DEV_HAS_PCI_ASIC_VERSION" }, \
+ { IOCTL_DEV_IS_MSF, "IOCTL_DEV_IS_MSF" }, \
+ { IOCTL_DEV_IS_LWR, "IOCTL_DEV_IS_LWR" }, \
+ { IOCTL_DEV_IS_WWVB, "IOCTL_DEV_IS_WWVB" }, \
+ { IOCTL_GET_IRQ_STAT_INFO, "IOCTL_GET_IRQ_STAT_INFO" }, \
+ { IOCTL_GET_CYCLES_FREQUENCY, "IOCTL_GET_CYCLES_FREQUENCY" }, \
+ { IOCTL_DEV_HAS_FAST_HR_TIMESTAMP, "IOCTL_DEV_HAS_FAST_HR_TIMESTAMP" }, \
+ { IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES, "IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES" }, \
+ { IOCTL_GET_FAST_HR_TIMESTAMP, "IOCTL_GET_FAST_HR_TIMESTAMP" }, \
+ { IOCTL_DEV_HAS_GPS_TIME_SCALE, "IOCTL_DEV_HAS_GPS_TIME_SCALE" }, \
+ { IOCTL_GET_GPS_TIME_SCALE_INFO, "IOCTL_GET_GPS_TIME_SCALE_INFO" }, \
+ { IOCTL_SET_GPS_TIME_SCALE_SETTINGS, "IOCTL_SET_GPS_TIME_SCALE_SETTINGS" }, \
+ { IOCTL_DEV_HAS_GPS_UTC_PARM, "IOCTL_DEV_HAS_GPS_UTC_PARM" }, \
+ { IOCTL_GET_GPS_UTC_PARM, "IOCTL_GET_GPS_UTC_PARM" }, \
+ { IOCTL_SET_GPS_UTC_PARM, "IOCTL_SET_GPS_UTC_PARM" }, \
+ { IOCTL_DEV_HAS_IRIG_CTRL_BITS, "IOCTL_DEV_HAS_IRIG_CTRL_BITS" }, \
+ { IOCTL_GET_IRIG_CTRL_BITS, "IOCTL_GET_IRIG_CTRL_BITS" }, \
+ { IOCTL_DEV_HAS_LAN_INTF, "IOCTL_DEV_HAS_LAN_INTF" }, \
+ { IOCTL_GET_LAN_IF_INFO, "IOCTL_GET_LAN_IF_INFO" }, \
+ { IOCTL_GET_IP4_STATE, "IOCTL_GET_IP4_STATE" }, \
+ { IOCTL_GET_IP4_SETTINGS, "IOCTL_GET_IP4_SETTINGS" }, \
+ { IOCTL_SET_IP4_SETTINGS, "IOCTL_SET_IP4_SETTINGS" }, \
+ { IOCTL_DEV_IS_PTP, "IOCTL_DEV_IS_PTP" }, \
+ { IOCTL_DEV_HAS_PTP, "IOCTL_DEV_HAS_PTP" }, \
+ { IOCTL_GET_PTP_STATE, "IOCTL_GET_PTP_STATE" }, \
+ { IOCTL_GET_PTP_CFG_INFO, "IOCTL_GET_PTP_CFG_INFO" }, \
+ { IOCTL_SET_PTP_CFG_SETTINGS, "IOCTL_SET_PTP_CFG_SETTINGS" }, \
+ { IOCTL_DEV_HAS_IRIG_TIME, "IOCTL_DEV_HAS_IRIG_TIME" }, \
+ { IOCTL_GET_IRIG_TIME, "IOCTL_GET_IRIG_TIME" }, \
+ { IOCTL_GET_TIME_INFO_HRT, "IOCTL_GET_TIME_INFO_HRT" }, \
+ { IOCTL_GET_TIME_INFO_TSTAMP, "IOCTL_GET_TIME_INFO_TSTAMP" }, \
+ { IOCTL_DEV_HAS_RAW_IRIG_DATA, "IOCTL_DEV_HAS_RAW_IRIG_DATA" }, \
+ { IOCTL_GET_RAW_IRIG_DATA, "IOCTL_GET_RAW_IRIG_DATA" }, \
+ { IOCTL_DEV_HAS_PTP_UNICAST, "IOCTL_DEV_HAS_PTP_UNICAST" }, \
+ { IOCTL_PTP_UC_MASTER_CFG_LIMITS, "IOCTL_PTP_UC_MASTER_CFG_LIMITS" }, \
+ { IOCTL_GET_ALL_PTP_UC_MASTER_INFO, "IOCTL_GET_ALL_PTP_UC_MASTER_INFO" }, \
+ { IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX, "IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX" }, \
+ { IOCTL_DEV_HAS_PZF, "IOCTL_DEV_HAS_PZF" }, \
+ { IOCTL_DEV_HAS_CORR_INFO, "IOCTL_DEV_HAS_CORR_INFO" }, \
+ { IOCTL_DEV_HAS_TR_DISTANCE, "IOCTL_DEV_HAS_TR_DISTANCE" }, \
+ { 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_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" }, \
+ { IOCTL_MBG_DBG_CLR_BIT, "IOCTL_MBG_DBG_CLR_BIT" }, \
+ { 0, NULL } \
+}
+
+
#if !defined( _cmd_from_ioctl_code )
#define _cmd_from_ioctl_code( _ioctl_code ) _ioctl_code
#endif
-// The structure below is used by the IOCTL_PCPS_GENERIC_... calls.
-typedef struct
+/**
+ * @brief Privilege levels for IOCTL codes.
+ *
+ * IOCTLs can be used to do different things ranging from simply
+ * reading a timestamp up to forcing a GPS receiver into boot mode
+ * which may completely mess up the time keeping on the PC.
+ *
+ * These codes are used to determine a privilege level required
+ * to execute a specific IOCTL command.
+ *
+ * How to determine if a calling process has sufficient privileges
+ * depends strongly on the rights management features provided
+ * by the underlying OS (e.g simple user/group rights, ACLs,
+ * Linux capabilities, Windows privileges) so this needs to be
+ * implemented in the OS-specific code of a driver.
+ *
+ * Implementation should be done in a way which introduces as low
+ * latency as possible when reading time stamps from a device.
+ */
+enum
{
- uint32_t info;
- uint32_t data_size_in;
- uint32_t data_size_out;
-} IOCTL_GENERIC_CTL;
-
+ MBG_REQ_PRIVL_NONE, //< e.g. read date/time/sync status
+ MBG_REQ_PRIVL_EXT_STATUS, //< e.g. read receiver position
+ MBG_REQ_PRIVL_CFG_READ, //< read device config data
+ MBG_REQ_PRIVL_CFG_WRITE, //< write config data to the device
+ MBG_REQ_PRIVL_SYSTEM, //< operations which may affect system operation
+ N_MBG_REQ_PRIVL //< the number of supported privilege levels
+};
+
+
+#if defined( __GNUC__ )
+// Avoid "no previous prototype" with some gcc versions.
+__mbg_inline
+int ioctl_get_required_privilege( ulong ioctl_code ) __attribute__((always_inline));
+#endif
-typedef struct
+/**
+ * @brief Determine the privilege level required to execute a specific IOCTL command.
+ *
+ * @param ioctl_code The IOCTL code for which to return the privilege level
+ *
+ * @return One of the enumerated privilege levels
+ * @return -1 for unknown IOCTL codes
+ */
+__mbg_inline
+int ioctl_get_required_privilege( ulong ioctl_code )
{
- IOCTL_GENERIC_CTL ctl;
- uint8_t data[1];
-} IOCTL_GENERIC_BUFFER;
+ // To provide best maintainability the sequence of cases in ioctl_switch()
+ // should match the sequence of the cases here, which also makes sure
+ // commands requiring lowest latency are handled first.
+
+ switch ( ioctl_code )
+ {
+ // Commands requiring lowest latency:
+ case IOCTL_GET_FAST_HR_TIMESTAMP:
+ case IOCTL_GET_PCPS_HR_TIME:
+ case IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES:
+ case IOCTL_GET_PCPS_HR_TIME_CYCLES:
+ case IOCTL_GET_PCPS_UCAP_EVENT:
+ // Other low latency commands:
+ case IOCTL_GET_PCPS_TIME:
+ case IOCTL_GET_PCPS_TIME_CYCLES:
+ case IOCTL_GET_PCPS_STATUS_PORT:
+ case IOCTL_GET_PCPS_TIME_SEC_CHANGE:
+ case IOCTL_GET_GPS_TIME:
+ case IOCTL_GET_GPS_UCAP:
+ case IOCTL_GET_TIME_INFO_HRT:
+ case IOCTL_GET_TIME_INFO_TSTAMP:
+ return MBG_REQ_PRIVL_NONE;
+
+ // Commands returning public status information:
+ case IOCTL_GET_PCPS_DRVR_INFO:
+ case IOCTL_GET_PCPS_DEV:
+ case IOCTL_GET_PCPS_SYNC_TIME:
+ case IOCTL_GET_GPS_SW_REV:
+ case IOCTL_GET_GPS_BVAR_STAT:
+ case IOCTL_GET_GPS_ANT_INFO:
+ case IOCTL_GET_GPS_STAT_INFO:
+ case IOCTL_GET_GPS_IDENT:
+ case IOCTL_GET_GPS_RECEIVER_INFO:
+ case IOCTL_GET_PCI_ASIC_VERSION:
+ case IOCTL_GET_SYNTH_STATE:
+ case IOCTL_GET_PCPS_UCAP_ENTRIES:
+ case IOCTL_GET_PCI_ASIC_FEATURES:
+ case IOCTL_GET_IRQ_STAT_INFO:
+ case IOCTL_GET_CYCLES_FREQUENCY:
+ case IOCTL_GET_IRIG_CTRL_BITS:
+ case IOCTL_GET_IP4_STATE:
+ case IOCTL_GET_PTP_STATE:
+ case IOCTL_GET_CORR_INFO:
+ return MBG_REQ_PRIVL_NONE;
+
+ // Commands returning device capabilities and features:
+ case IOCTL_DEV_IS_GPS:
+ case IOCTL_DEV_IS_DCF:
+ case IOCTL_DEV_IS_MSF:
+ case IOCTL_DEV_IS_WWVB:
+ case IOCTL_DEV_IS_LWR:
+ case IOCTL_DEV_IS_IRIG_RX:
+ case IOCTL_DEV_HAS_HR_TIME:
+ case IOCTL_DEV_HAS_CAB_LEN:
+ case IOCTL_DEV_HAS_TZDL:
+ case IOCTL_DEV_HAS_PCPS_TZDL:
+ case IOCTL_DEV_HAS_TZCODE:
+ case IOCTL_DEV_HAS_TZ:
+ case IOCTL_DEV_HAS_EVENT_TIME:
+ case IOCTL_DEV_HAS_RECEIVER_INFO:
+ case IOCTL_DEV_CAN_CLR_UCAP_BUFF:
+ case IOCTL_DEV_HAS_UCAP:
+ case IOCTL_DEV_HAS_IRIG_TX:
+ case IOCTL_DEV_HAS_SERIAL_HS:
+ case IOCTL_DEV_HAS_SIGNAL:
+ case IOCTL_DEV_HAS_MOD:
+ case IOCTL_DEV_HAS_IRIG:
+ case IOCTL_DEV_HAS_REF_OFFS:
+ case IOCTL_DEV_HAS_OPT_FLAGS:
+ case IOCTL_DEV_HAS_GPS_DATA:
+ case IOCTL_DEV_HAS_SYNTH:
+ case IOCTL_DEV_HAS_GENERIC_IO:
+ case IOCTL_DEV_HAS_PCI_ASIC_FEATURES:
+ case IOCTL_DEV_HAS_PCI_ASIC_VERSION:
+ case IOCTL_DEV_HAS_FAST_HR_TIMESTAMP:
+ case IOCTL_DEV_HAS_GPS_TIME_SCALE:
+ case IOCTL_DEV_HAS_GPS_UTC_PARM:
+ case IOCTL_DEV_HAS_IRIG_CTRL_BITS:
+ case IOCTL_DEV_HAS_LAN_INTF:
+ case IOCTL_DEV_IS_PTP:
+ case IOCTL_DEV_HAS_PTP:
+ case IOCTL_DEV_HAS_IRIG_TIME:
+ case IOCTL_DEV_HAS_RAW_IRIG_DATA:
+ case IOCTL_DEV_HAS_PTP_UNICAST:
+ case IOCTL_DEV_HAS_PZF:
+ case IOCTL_DEV_HAS_CORR_INFO:
+ case IOCTL_DEV_HAS_TR_DISTANCE:
+ 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
+ return MBG_REQ_PRIVL_NONE;
+
+ // Status information which may not be available for everybody:
+ case IOCTL_GET_GPS_POS:
+ return MBG_REQ_PRIVL_EXT_STATUS;
+
+ // Reading device configuration:
+ case IOCTL_GET_PCPS_SERIAL:
+ case IOCTL_GET_PCPS_TZCODE:
+ case IOCTL_GET_PCPS_TZDL:
+ case IOCTL_GET_REF_OFFS:
+ case IOCTL_GET_MBG_OPT_INFO:
+ case IOCTL_GET_PCPS_IRIG_RX_INFO:
+ case IOCTL_GET_GPS_TZDL:
+ case IOCTL_GET_GPS_PORT_PARM:
+ case IOCTL_GET_GPS_ENABLE_FLAGS:
+ case IOCTL_GET_GPS_ANT_CABLE_LEN:
+ case IOCTL_GET_PCPS_IRIG_TX_INFO:
+ case IOCTL_GET_SYNTH:
+ case IOCTL_GET_GPS_TIME_SCALE_INFO:
+ case IOCTL_GET_GPS_UTC_PARM:
+ case IOCTL_GET_LAN_IF_INFO:
+ case IOCTL_GET_IP4_SETTINGS:
+ case IOCTL_GET_PTP_CFG_INFO:
+ case IOCTL_GET_IRIG_TIME:
+ case IOCTL_GET_RAW_IRIG_DATA:
+ case IOCTL_PTP_UC_MASTER_CFG_LIMITS:
+ case IOCTL_GET_TR_DISTANCE:
+ #if _MBG_SUPP_VAR_ACC_SIZE
+ // These codes are only supported on target systems where a variable size of
+ // the IOCTL buffer can be specified in the IOCTL call. On other systems the
+ // generic IOCTL functions are used instead.
+ case IOCTL_GET_GPS_ALL_STR_TYPE_INFO:
+ case IOCTL_GET_GPS_ALL_PORT_INFO:
+ case IOCTL_GET_GPS_ALL_POUT_INFO:
+ case IOCTL_GET_ALL_PTP_UC_MASTER_INFO:
+ #endif
+ return MBG_REQ_PRIVL_CFG_READ;
+
+ // Writing device configuration:
+ case IOCTL_SET_PCPS_SERIAL:
+ case IOCTL_SET_PCPS_TZCODE:
+ case IOCTL_SET_PCPS_TZDL:
+ case IOCTL_SET_REF_OFFS:
+ case IOCTL_SET_MBG_OPT_SETTINGS:
+ case IOCTL_SET_PCPS_IRIG_RX_SETTINGS:
+ case IOCTL_SET_GPS_TZDL:
+ case IOCTL_SET_GPS_PORT_PARM:
+ case IOCTL_SET_GPS_ENABLE_FLAGS:
+ case IOCTL_SET_GPS_ANT_CABLE_LEN:
+ case IOCTL_SET_GPS_PORT_SETTINGS_IDX:
+ case IOCTL_SET_PCPS_IRIG_TX_SETTINGS:
+ case IOCTL_SET_SYNTH:
+ case IOCTL_SET_GPS_POUT_SETTINGS_IDX:
+ case IOCTL_SET_IP4_SETTINGS:
+ case IOCTL_SET_PTP_CFG_SETTINGS:
+ case IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX:
+ case IOCTL_SET_TR_DISTANCE:
+ return MBG_REQ_PRIVL_CFG_WRITE;
+
+ // Operations which may severely affect system operation:
+ case IOCTL_SET_PCPS_TIME:
+ case IOCTL_SET_GPS_TIME:
+ case IOCTL_SET_GPS_POS_XYZ:
+ case IOCTL_SET_GPS_POS_LLA:
+ case IOCTL_SET_GPS_TIME_SCALE_SETTINGS:
+ case IOCTL_SET_GPS_UTC_PARM:
+ case IOCTL_SET_GPS_CMD:
+ // generic read/write operations can do anything
+ case IOCTL_PCPS_GENERIC_READ:
+ case IOCTL_PCPS_GENERIC_WRITE:
+ case IOCTL_PCPS_GENERIC_READ_GPS:
+ case IOCTL_PCPS_GENERIC_WRITE_GPS:
+ case IOCTL_PCPS_GENERIC_IO:
+ return MBG_REQ_PRIVL_SYSTEM;
+
+ // The next codes are somewhat special and normally
+ // not used by the driver software:
+ case IOCTL_GET_MAPPED_MEM_ADDR:
+ case IOCTL_UNMAP_MAPPED_MEM:
+ return MBG_REQ_PRIVL_SYSTEM;
+
+ #if USE_DEBUG_PORT
+ // The codes below are used for debugging only.
+ // Unrestricted usage may cause system malfunction !!
+ case IOCTL_MBG_DBG_GET_PORT_ADDR:
+ case IOCTL_MBG_DBG_SET_PORT_ADDR:
+ case IOCTL_MBG_DBG_SET_BIT:
+ case IOCTL_MBG_DBG_CLR_BIT:
+ case IOCTL_MBG_DBG_CLR_ALL:
+ return MBG_REQ_PRIVL_SYSTEM;
+ #endif
+ } // switch
+
+ return -1; // unsupported code, should always be denied
+
+} // ioctl_get_required_privilege
@@ -452,8 +879,4 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack()
-#endif
-
#endif /* _MBGIOCTL_H */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgmutex.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgmutex.h
new file mode 100755
index 0000000..6ef6f2a
--- /dev/null
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgmutex.h
@@ -0,0 +1,265 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgmutex.h 1.1.1.6 2011/05/31 14:19:55 martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Portable macros to deal with spinlocks, mutexes,
+ * and critical sections.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgmutex.h $
+ * 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
+ * if not required/supported on the target OS.
+ * Revision 1.1.1.4 2011/05/06 09:11:16Z martin
+ * Fix for DOS.
+ * Revision 1.1.1.3 2011/05/04 09:24:18Z martin
+ * Revision 1.1.1.2 2011/05/04 08:57:23 martin
+ * Fix for FreeBSD.
+ * Revision 1.1.1.1 2011/05/03 15:46:06 martin
+ * Fix for Linux kernel.
+ * Revision 1.1 2011/04/15 12:26:59 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGMUTEX_H
+#define _MBGMUTEX_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#ifdef _MBGMUTEX
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( MBG_TGT_KERNEL ) // definitions used in kernel space
+
+ #if defined( MBG_TGT_WIN32 ) // Windows kernel space
+
+ typedef KSPIN_LOCK MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) KeInitializeSpinLock( _spl )
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) KeAcquireSpinLockAtDpcLevel( _spl )
+ #define _mbg_spin_lock_release( _spl ) KeReleaseSpinLockFromDpcLevel( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef FAST_MUTEX MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) ExInitializeFastMutex( _pmtx )
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pmtx ) ExAcquireFastMutex( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) ExReleaseFastMutex( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_LINUX ) // Linux kernel space
+
+ #include <linux/spinlock.h>
+ #include <linux/version.h>
+
+ #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 26 ) )
+ #include <linux/semaphore.h>
+ #else
+ #include <asm/semaphore.h>
+ #endif
+
+ typedef spinlock_t MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) spin_lock_init( _spl )
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) spin_lock( _spl )
+ #define _mbg_spin_lock_release( _spl ) spin_unlock( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef struct semaphore MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) sema_init( _pmtx, 1 )
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pmtx ) down_interruptible( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) up( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_FREEBSD ) // FreeBSD kernel space
+
+ #include <sys/lock.h>
+ #include <sys/mutex.h>
+
+ typedef struct mtx MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) mtx_init( _spl, "mbg_spin_lock", NULL, MTX_SPIN )
+ #define _mbg_spin_lock_destroy( _spl ) mtx_destroy( _spl )
+ #define _mbg_spin_lock_acquire( _spl ) mtx_lock_spin( _spl )
+ #define _mbg_spin_lock_release( _spl ) mtx_unlock_spin( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef struct mtx MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) mtx_init( _pmtx, "mbg_mutex", NULL, MTX_DEF )
+ #define _mbg_mutex_destroy( _pmtx ) mtx_destroy( _pmtx )
+ #define _mbg_mutex_acquire( _pmtx ) mtx_lock( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) mtx_unlock( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_NETBSD )
+
+ #include <sys/mutex.h>
+
+ // The API used below has been introduced in NetBSD 5.0
+ // For earlier NetBSD versions see 'man 9 lockinit'.
+
+ typedef kmutex_t MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) mutex_init( _spl, MUTEX_DEFAULT, IPL_HIGH )
+ #define _mbg_spin_lock_destroy( _spl ) mutex_destroy( _spl )
+ #define _mbg_spin_lock_acquire( _spl ) mutex_spin_enter( _spl )
+ #define _mbg_spin_lock_release( _spl ) mutex_spin_exit( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef kmutex_t MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) mutex_init( _pmtx, MUTEX_DEFAULT, IPL_NONE )
+ #define _mbg_mutex_destroy( _spl ) mutex_destroy( _spl )
+ #define _mbg_mutex_acquire( _pmtx ) mutex_enter( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) mutex_exit( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #endif
+
+#else // user space applications
+
+ #if defined( MBG_TGT_WIN32 ) // Windows user space
+
+ #include <windows.h>
+
+ // definitions used with mutexes
+ typedef HANDLE MBG_MUTEX;
+ #define _mbg_mutex_init( _pm ) *(_pm) = CreateMutex( NULL, FALSE, NULL )
+ #define _mbg_mutex_destroy( _pm ) CloseHandle( *(_pm) ); *(_pm) = INVALID_HANDLE_VALUE
+ #define _mbg_mutex_acquire( _pm ) WaitForSingleObject( *(_pm), INFINITE )
+ #define _mbg_mutex_release( _pm ) ReleaseMutex( *(_pm) )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ // definitions used with critical sections
+ typedef CRITICAL_SECTION MBG_CRIT_SECT;
+ #define _mbg_crit_sect_init( _pcs ) InitializeCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_destroy( _pcs ) DeleteCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_enter( _pcs ) EnterCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_leave( _pcs ) LeaveCriticalSection( (_pcs) )
+
+ #define _MBG_CRIT_SECT_DEFINED 1
+
+ #elif defined( MBG_TGT_UNIX ) // Unix user space use pthread library
+
+ #include <pthread.h>
+
+ // Mutex types:
+ // PTHREAD_MUTEX_INITIALIZER /* Fast */
+ // PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP /* Recursive */
+ // PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* Errorcheck */
+ typedef pthread_mutex_t MBG_MUTEX;
+ #define _mbg_mutex_init( _pm ) pthread_mutex_init( (_pm), NULL )
+ #define _mbg_mutex_destroy( _pm ) pthread_mutex_destroy( (_pm) )
+ #define _mbg_mutex_acquire( _pm ) pthread_mutex_lock( (_pm) )
+ #define _mbg_mutex_release( _pm ) pthread_mutex_unlock( (_pm) )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ // For critical sections use defaults specified below
+
+ #elif defined( MBG_TGT_DOS )
+
+ typedef int MBG_MUTEX; // just a dummy declaration
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #endif
+
+#endif
+
+
+#if !defined( _MBG_SPINLOCK_DEFINED )
+
+ #define _mbg_spin_lock_init( _spl ) _nop_macro_fnc()
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) _nop_macro_fnc()
+ #define _mbg_spin_lock_release( _spl ) _nop_macro_fnc()
+
+#endif
+
+
+#if !defined( _MBG_MUTEX_DEFINED )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ typedef MBG_CRIT_SECT MBG_MUTEX;
+
+ #define _mbg_mutex_init( _pm ) _nop_macro_fnc()
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pm ) _nop_macro_fnc()
+ #define _mbg_mutex_release( _pm ) _nop_macro_fnc()
+
+#endif
+
+
+#if !defined( _MBG_CRIT_SECT_DEFINED )
+
+ // use mutex by default, e.g. with the pthread library
+
+ #define _MBG_CRIT_SECT_DEFINED 1
+
+ typedef MBG_MUTEX MBG_CRIT_SECT;
+ #define _mbg_crit_sect_init _mbg_mutex_init
+ #if defined( _mbg_mutex_destroy )
+ #define _mbg_crit_sect_destroy _mbg_mutex_destroy
+ #endif
+ #define _mbg_crit_sect_enter _mbg_mutex_acquire
+ #define _mbg_crit_sect_leave _mbg_mutex_release
+
+#endif
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+/* (no header definitions found) */
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGMUTEX_H */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgpccyc.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgpccyc.h
new file mode 100755
index 0000000..3d8843c
--- /dev/null
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgpccyc.h
@@ -0,0 +1,297 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgpccyc.h 1.1.1.3 2011/07/13 09:44:49 martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Portable macros to get a machine's current cycle count.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgpccyc.h $
+ * Revision 1.1.1.3 2011/07/13 09:44:49 martin
+ * Moved IA64 includes from pcpsdev.h to mbgpccyc.h.
+ * Revision 1.1.1.2 2011/07/06 13:23:36 martin
+ * Revision 1.1.1.1 2011/07/05 12:25:08 martin
+ * Revision 1.1 2011/06/23 15:36:07 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGPCCYC_H
+#define _MBGPCCYC_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#if defined( MBG_TGT_NETBSD )
+ #if defined( MBG_TGT_KERNEL )
+ #include <machine/cpu.h>
+ #include <machine/cpu_counter.h> /* for cycle counter abstraction */
+ #endif
+#endif
+
+#if defined( MBG_TGT_FREEBSD )
+ #if defined( MBG_TGT_KERNEL )
+ #if defined( MBG_ARCH_X86 )
+ #include <machine/clock.h> /* for symbol 'tsc_freq' */
+ #endif
+ #endif
+#endif
+
+#if defined( MBG_TGT_LINUX )
+ #if defined( MBG_ARCH_IA64 )
+ #include <asm/ia64regs.h>
+ #include <asm/intel_intrin.h>
+ #endif
+#endif
+
+
+#ifdef _MBGPCCYC
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+/**
+ * @brief Generic types to hold PC cycle counter values.
+ *
+ * The cycle counter value is usually derived from the PC CPU's TSC or some other
+ * timer hardware on the mainboard.
+ */
+#if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_UNIX )
+
+ typedef int64_t MBG_PC_CYCLES;
+ typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
+
+#else
+
+ typedef uint32_t MBG_PC_CYCLES;
+ typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
+
+#endif
+
+
+// MBG_PC_CYCLES and MBG_PC_CYCLES_FREQUENCY are always read in native
+// machine endianess, so no endianess conversion is required.
+#define _mbg_swab_mbg_pc_cycles( _p ) \
+ _nop_macro_fnc()
+
+#define _mbg_swab_mbg_pc_cycles_frequency( _p ) \
+ _nop_macro_fnc()
+
+
+
+#if ( defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD ) ) && defined( MBG_ARCH_X86 )
+
+ static __mbg_inline unsigned long long int mbg_rdtscll( void )
+ {
+ // The code below is a hack to get around issues with
+ // different versions of gcc.
+ //
+ // Normally the inline asm code could look similar to:
+ //
+ // __asm__ volatile ( "rdtsc" : "=A" (x) )
+ //
+ // which would copy the output regs edx:eax as a 64 bit
+ // number to a variable x.
+ //
+ // The "=A" expression should implicitely tell the compiler
+ // the edx and eax registers have been clobbered. However,
+ // this does not seem to work properly at least with gcc 4.1.2
+ // shipped with Centos 5.
+ //
+ // If optimization level 1 or higher is used then function
+ // parameters are also passed in registers. If the inline
+ // code above is used inside a function then the edx register
+ // is clobbered but the gcc 4.1.2 is not aware of this and
+ // assumes edx is unchanged, which may yield faulty results
+ // or even lead to segmentation faults.
+ //
+ // A possible workaround could be to mark edx explicitely as
+ // being clobbered in the asm inline code, but unfortunately
+ // other gcc versions report an error if a register which is
+ // implicitely (by "=A") known to be clobbered is also listed
+ // explicitely to be clobbered.
+ //
+ // So the code below is a workaround which tells the compiler
+ // implicitely that the eax ("=a") and edx ("=d") registers
+ // are being used and thus clobbered.
+
+ union
+ {
+ struct
+ {
+ uint32_t lo;
+ uint32_t hi;
+ } u32;
+
+ uint64_t u64;
+
+ } tsc_val;
+
+ __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
+
+ return tsc_val.u64;
+
+ } // mbg_rdtscll
+
+#endif
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ *p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
+ #else // user space
+ QueryPerformanceCounter( (LARGE_INTEGER *) p );
+ #endif
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
+
+ *p = mbg_rdtscll();
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_SPARC ) && defined( MBG_TGT_KERNEL )
+
+ *p = get_cycles();
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 )
+
+ unsigned long result = ia64_getreg( _IA64_REG_AR_ITC );
+ ia64_barrier();
+
+ #ifdef CONFIG_ITANIUM
+ while (unlikely((__s32) result == -1)) {
+ result = ia64_getreg(_IA64_REG_AR_ITC);
+ ia64_barrier();
+ }
+ #endif
+
+ *p = result;
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 )
+
+ *p = mbg_rdtscll();
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_NETBSD ) && defined ( MBG_TGT_KERNEL )
+
+ *p = cpu_counter(); //##++ or cpu_counter_serializing()
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #else
+
+ *p = 0;
+
+ #endif
+
+} // mbg_get_pc_cycles
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+ LARGE_INTEGER li;
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ KeQueryPerformanceCounter( &li );
+ #else // user space
+ QueryPerformanceFrequency( &li );
+ #endif
+
+ *p = li.QuadPart;
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
+
+ *p = ( cpu_khz * 1000 );
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 )
+
+ // we probably can use
+ // ia64_sal_freq_base(unsigned long which, unsigned long *ticks_per_second,
+ // unsigned long *drift_info)
+ // However, this is not tested.
+
+ *p = 0;
+
+ #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
+
+ *p = tsc_freq;
+
+ #elif defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL )
+
+ *p = cpu_frequency( curcpu() );
+
+ #else
+
+ *p = 0;
+
+ #endif
+
+} // mbg_get_pc_cycles_frequency
+
+
+
+static __mbg_inline
+MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
+{
+#if 0 && !defined( MBG_PC_CYCLES_SUPPORTED ) //##+++++++++++++++++
+ // Cycle counts not supported on this target platform.
+ // Under SPARC this may even result in bus errors
+ // due to alignment of the underlying data structures.
+ return 0;
+#else
+ return *p1 - *p2;
+#endif
+
+} // mbg_delta_pc_cycles
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+/* (no header definitions found) */
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGPCCYC */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgtime.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgtime.h
index c7ab670..ba6900f 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgtime.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgtime.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgtime.h 1.17.1.4 2011/02/09 15:46:48 martin TRASH $
+ * $Id: mbgtime.h 1.17.1.6 2011/05/06 09:03:12 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbgtime.h $
- * Revision 1.17.1.4 2011/02/09 15:46:48 martin
+ * 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
+ * include <time.h> for WIN32 target and firmware only
+ * Revision 1.17.1.4 2011/02/09 15:46:48Z martin
* Revision 1.17.1.3 2011/01/24 17:09:20 martin
* Fixed build under FreeBSD.
* Revision 1.17.1.2 2010/08/13 11:57:13 martin
@@ -61,8 +65,9 @@
#include <gpsdefs.h>
-#if !defined( MBG_ARCH_ARM ) && \
- !defined( MBG_TGT_KERNEL )
+#if _IS_MBG_FIRMWARE \
+ || defined( MBG_TGT_WIN32 ) \
+ || defined( MBG_TGT_DOS )
#include <time.h>
#endif
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/mbgutil.h b/src/external/bsd/meinberg/dist/mbglib/common/mbgutil.h
index 9d26c62..761db23 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/mbgutil.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/mbgutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgutil.h 1.16.1.1 2011/02/09 15:27:23 martin TRASH $
+ * $Id: mbgutil.h 1.16.1.2 2011/06/22 10:21:57 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgutil.h $
+ * Revision 1.16.1.2 2011/06/22 10:21:57 martin
+ * Cleaned up handling of pragma pack().
* Revision 1.16.1.1 2011/02/09 15:27:23 martin
+ * Include stdlib.h.
* Revision 1.16 2009/08/14 10:11:53Z daniel
* New version code 306, compatibility version still 110.
* Revision 1.15 2009/06/09 08:57:47Z daniel
@@ -95,8 +98,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -169,8 +173,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pci_asic.h b/src/external/bsd/meinberg/dist/mbglib/common/pci_asic.h
index 2feef9b..cc859f4 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pci_asic.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pci_asic.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pci_asic.h 1.16 2010/04/16 11:12:21 martin REL_M $
+ * $Id: pci_asic.h 1.20 2011/06/30 13:52:26 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,17 @@
*
* -----------------------------------------------------------------------
* $Log: pci_asic.h $
- * Revision 1.16 2010/04/16 11:12:21 martin
+ * Revision 1.20 2011/06/30 13:52:26 martin
+ * Updated version info for GPS180PEX.
+ * Revision 1.19 2011/06/29 08:58:32Z martin
+ * Support PZF180PEX.
+ * Cleaned up handling of pragma pack().
+ * Revision 1.18 2011/04/06 12:31:48 martin
+ * Updated minor versions for PTP270PEX and GPS180PEX.
+ * Revision 1.17 2010/09/10 14:03:25Z martin
+ * Support GPS180PEX and TCR180PEX.
+ * New table initializer to simplify EPLD version checking.
+ * Revision 1.16 2010/04/16 11:12:21Z martin
* Updated GPS170PEX ASIC version.
* Revision 1.15 2009/03/27 09:39:15 martin
* Increased current ASIC minor number for TCR170PEX to 0x02.
@@ -67,11 +77,6 @@
#include <words.h>
#include <use_pack.h>
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
-#endif
-
-
#ifdef _PCI_ASIC
#define _ext
#define _DO_INIT
@@ -82,6 +87,11 @@
/* Start of header body */
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
+
typedef struct
{
@@ -263,6 +273,9 @@ enum
PCI_ASIC_MAJOR_PTP270PEX, // PEX EPLD for PTP270PEX
PCI_ASIC_MAJOR_FRC511PEX, // PEX EPLD for FRC511PEX
PCI_ASIC_MAJOR_TCR170PEX, // PEX EPLD for TCR170PEX
+ PCI_ASIC_MAJOR_GPS180PEX, // PEX EPLD for GPS180PEX
+ PCI_ASIC_MAJOR_TCR180PEX, // PEX EPLD for TCR180PEX
+ PCI_ASIC_MAJOR_PZF180PEX, // PEX EPLD for PZF180PEX
N_PCI_ASIC_MAJOR // the number of known codes
};
@@ -274,30 +287,68 @@ enum
*/
#define PCI_ASIC_CURRENT_MINOR_PEX511 0x04
#define PCI_ASIC_REQUIRED_MINOR_PEX511 0x03
-#define PCI_ASIC_FIX_HRT_MINOR_PEX511 0x04 // increases HRT accuracy
-#define PCI_ASIC_FIX_IRQ_MINOR_PEX511 0x03 // fixes IRQ problem
-#define PCI_ASIC_HR_TIME_MINOR_PEX511 0x02 // supports HR time with PEX511
+#define PCI_ASIC_FIX_HRT_MINOR_PEX511 0x04 // increases HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_PEX511 0x03 // fixes IRQ problem
+#define PCI_ASIC_HR_TIME_MINOR_PEX511 0x02 // supports HR time with PEX511
#define PCI_ASIC_CURRENT_MINOR_GPS170PEX 0x05
#define PCI_ASIC_REQUIRED_MINOR_GPS170PEX 0x03
-#define PCI_ASIC_ENH_HRT_MINOR_GPS170PEX 0x05 // enhanced MM HRT accuracy
-#define PCI_ASIC_FIX_HRT_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
-#define PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX 0x03 // fixes IRQ problem
+#define PCI_ASIC_ENH_HRT_MINOR_GPS170PEX 0x05 // enhanced MM HRT accuracy
+#define PCI_ASIC_FIX_HRT_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX 0x03 // fixes IRQ problem
#define PCI_ASIC_CURRENT_MINOR_TCR511PEX 0x04
#define PCI_ASIC_REQUIRED_MINOR_TCR511PEX 0x03
-// 0x04 // EPLD sources shared with PEX511 0x04
-#define PCI_ASIC_FIX_IRQ_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
+// 0x04 // EPLD sources shared with PEX511 0x04
+#define PCI_ASIC_FIX_IRQ_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
-#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x01
+#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x02
#define PCI_ASIC_REQUIRED_MINOR_PTP270PEX 0x01
+// 0x02 // increased accuracy of IRIG DCLS slopes
+// 0x01 // supports inversion of ucap slopes
#define PCI_ASIC_CURRENT_MINOR_FRC511PEX 0x01
#define PCI_ASIC_REQUIRED_MINOR_FRC511PEX 0x01
-#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x02
+#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x03
#define PCI_ASIC_REQUIRED_MINOR_TCR170PEX 0x02
-#define PCI_ASIC_FIX_EE_ACCESS_TCR170PEX 0x02 // fixes EE access problem after reset
+#define PCI_ASIC_FIX_EE_ACCESS_TCR170PEX 0x02 // fixes EE access problem after reset
+#define PCI_ASIC_FIX_FO_IN_LEVEL_TCR170PEX 0x03 // correct polarity for fiber optic input
+
+#define PCI_ASIC_CURRENT_MINOR_GPS180PEX 0x03
+#define PCI_ASIC_REQUIRED_MINOR_GPS180PEX 0x01
+// 0x01 // updated VHDL compiler and associated PCI primitives
+// 0x02 // I/O using 3.3V LVTTL
+// 0x03 // GPS TIC pulse len now 1 sample clock
+
+#define PCI_ASIC_CURRENT_MINOR_TCR180PEX 0x00
+#define PCI_ASIC_REQUIRED_MINOR_TCR180PEX 0x00
+
+#define PCI_ASIC_CURRENT_MINOR_PZF180PEX 0x00
+#define PCI_ASIC_REQUIRED_MINOR_PZF180PEX 0x00
+
+
+typedef struct
+{
+ unsigned int dev_type_num;
+ unsigned int major;
+ unsigned int current_minor;
+ unsigned int required_minor;
+} PCI_ASIC_VERSION_INFO;
+
+#define DEFAULT_PCI_ASIC_VERSION_INFO_TABLE \
+{ \
+ { PCPS_TYPE_PEX511, PCI_ASIC_MAJOR_PEX511, PCI_ASIC_CURRENT_MINOR_PEX511, PCI_ASIC_REQUIRED_MINOR_PEX511 }, \
+ { PCPS_TYPE_GPS170PEX, PCI_ASIC_MAJOR_GPS170PEX, PCI_ASIC_CURRENT_MINOR_GPS170PEX, PCI_ASIC_REQUIRED_MINOR_GPS170PEX }, \
+ { PCPS_TYPE_TCR511PEX, PCI_ASIC_MAJOR_TCR511PEX, PCI_ASIC_CURRENT_MINOR_TCR511PEX, PCI_ASIC_REQUIRED_MINOR_TCR511PEX }, \
+ { PCPS_TYPE_PTP270PEX, PCI_ASIC_MAJOR_PTP270PEX, PCI_ASIC_CURRENT_MINOR_PTP270PEX, PCI_ASIC_REQUIRED_MINOR_PTP270PEX }, \
+ { PCPS_TYPE_FRC511PEX, PCI_ASIC_MAJOR_FRC511PEX, PCI_ASIC_CURRENT_MINOR_FRC511PEX, PCI_ASIC_REQUIRED_MINOR_FRC511PEX }, \
+ { PCPS_TYPE_TCR170PEX, PCI_ASIC_MAJOR_TCR170PEX, PCI_ASIC_CURRENT_MINOR_TCR170PEX, PCI_ASIC_REQUIRED_MINOR_TCR170PEX }, \
+ { PCPS_TYPE_GPS180PEX, PCI_ASIC_MAJOR_GPS180PEX, PCI_ASIC_CURRENT_MINOR_GPS180PEX, PCI_ASIC_REQUIRED_MINOR_GPS180PEX }, \
+ { PCPS_TYPE_TCR180PEX, PCI_ASIC_MAJOR_TCR180PEX, PCI_ASIC_CURRENT_MINOR_TCR180PEX, PCI_ASIC_REQUIRED_MINOR_TCR180PEX }, \
+ { PCPS_TYPE_PZF180PEX, PCI_ASIC_MAJOR_PZF180PEX, PCI_ASIC_CURRENT_MINOR_PZF180PEX, PCI_ASIC_REQUIRED_MINOR_PZF180PEX }, \
+ { 0 } \
+}
/* function prototypes: */
@@ -320,8 +371,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdefs.h b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdefs.h
index f36b251..cd19071 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdefs.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdefs.h
@@ -1,15 +1,41 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.46.1.1 2011/02/15 10:55:28 daniel TRASH $
+ * $Id: pcpsdefs.h 1.46.1.10 2011/07/06 11:21:38 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
- * General definitions for Meinberg plug-in radio clocks
+ * General definitions for Meinberg plug-in devices.
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
+ * 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
+ * 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
* Revision 1.46 2011/01/13 11:44:29Z martin
@@ -211,16 +237,16 @@
#include <use_pack.h>
-/* Start of header body */
+/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
/**
- * The following codes enumerate the ref time sources
- * from which the clocks receive the reference time.
+ * @brief Enumeration of the ref time signal sources used by Meinberg devices
*/
enum
{
@@ -229,7 +255,7 @@ enum
PCPS_REF_GPS, /**< see http://www.meinberg.de/english/info/gps.htm */
PCPS_REF_IRIG, /**< see http://www.meinberg.de/english/info/irig.htm */
PCPS_REF_MSF, /**< MSF Receiver (UK) */
- PCPS_REF_PTP, /**< PTP Timestamp card */
+ PCPS_REF_PTP, /**< PTP/IEEE1588 network protocol */
PCPS_REF_FRC, /**< Free Running Clock */
PCPS_REF_WWVB, /**< WWVB Receiver (US) */
PCPS_REF_JJY, /**< JJY Receiver (Japan) */
@@ -280,9 +306,9 @@ enum
-/**
- PCI vendor ID number (assigned by PCI SIG)
-*/
+/**
+ * @brief Meinberg PCI vendor ID (assigned by PCI SIG)
+ */
#define PCI_VENDOR_MEINBERG 0x1360
/* PCI device ID numbers (assigned by Meinberg) *
@@ -294,6 +320,7 @@ enum
#define PCI_DEV_PCI510 ( ( PCPS_REF_DCF << 8 ) | 0x03 )
#define PCI_DEV_PCI511 ( ( PCPS_REF_DCF << 8 ) | 0x04 )
#define PCI_DEV_PEX511 ( ( PCPS_REF_DCF << 8 ) | 0x05 )
+#define PCI_DEV_PZF180PEX ( ( PCPS_REF_DCF << 8 ) | 0x06 )
#define PCI_DEV_GPS167PCI ( ( PCPS_REF_GPS << 8 ) | 0x01 )
#define PCI_DEV_GPS168PCI ( ( PCPS_REF_GPS << 8 ) | 0x02 )
@@ -317,25 +344,25 @@ enum
// definitions used for the status port register
// (not to be intermixed with PCPS_TIME_STATUS)
-typedef uint8_t PCPS_STATUS_PORT; /**< see \ref group_status_port "Bitmask" */
-
-/** @defgroup group_status_port Bit masks of PCPS_STATUS_PORT
-
- Bit definitions used with the #PCPS_STATUS_PORT register.
-
- The flags #PCPS_ST_SEC and #PCPS_ST_MIN are cleared whenever the clock
- is read, so they are not very reliable in multitasking environments.
+typedef uint8_t PCPS_STATUS_PORT; /**< see @ref group_status_port "Bitmask" */
- <b>NOTE</b>: The PCPS_ST_IRQF flag originates from old ISA cards.
- Some PCI cards also support this, but in case of PCI cards the
- associated flag of the PCI interface chip should be checked to see
- if a certain card has generated an IRQ on the PC bus.
-
- The macro _pcps_ddev_has_gen_irq() cares about this and should be used
- to determine in a portable way whether a card has generated an IRQ.
-
- * @{
- */
+/**
+ * @defgroup group_status_port Bit masks of PCPS_STATUS_PORT
+ *
+ * Bit definitions used with the #PCPS_STATUS_PORT register.
+ *
+ * The flags #PCPS_ST_SEC and #PCPS_ST_MIN are cleared whenever the clock
+ * is read, so they are not very reliable in multitasking environments.
+ *
+ * @note The PCPS_ST_IRQF flag originates from old ISA cards.
+ * Some PCI cards also support this, but in case of PCI cards the
+ * associated flag of the PCI interface chip should be checked to see
+ * if a certain card has generated an IRQ on the PC bus.
+ *
+ * The macro _pcps_ddev_has_gen_irq() cares about this and should be used
+ * to determine in a portable way whether a card has generated an IRQ.
+ *
+ * @{ */
#define PCPS_ST_BUSY 0x01 /**< the clock is busy filling the output FIFO */
#define PCPS_ST_IRQF 0x02 /**< the clock has generated an IRQ on the PC bus (ISA only)*/
@@ -343,21 +370,26 @@ typedef uint8_t PCPS_STATUS_PORT; /**< see \ref group_status_port "Bitmask" */
#define PCPS_ST_SEC 0x40 /**< seconds have changed since last reading */
#define PCPS_ST_MIN 0x80 /**< minutes have changed since last reading */
-/** @} */
+/** @} group_status_port */
+
+/**
+ * A format string to be used with snprintb() which is available on some Unix
+ * systems to print information held in a bit coded variable.
+ */
+#define MBG_PCPS_FMT_STATUS \
+ "\177\20b\0FREER\0b\1DL_ENB\0b\2SYNCD\0b\3DL_ANN\0b\4UTC\0b\5LS_ANN\0b\6IFTM\0b\7INVT" \
+ "\0b\x08LS_ENB\0b\11ANT_FAIL\0b\x0aLS_ANN_NEG\0b\x0bSCALE_GPS\0b\x0cSCALE_TAI\0\0"
/** @defgroup group_cmd_bytes Command bytes used to access the device
- The commands described below can be used to access the Meinberg
- computer peripherals. However, some of the commands have not been
- implemented with older clock models, or firmware versions.
+ The commands described below are used to access computer peripherals
+ manufactured by Meinberg.
- The device driver library contains functions which detect the clocks
- and check which features are supported by a given clock model/firmware
The header files pcpsdev.h and pcpsdrvr.h contain macros which can be
- used to query whether a detected clock supports a feature.
- If checking is required, the name of the macro is given in the
+ used to check if a detected device supports a certain feature or command.
+ If checking is required then the name of the macro is given in the
comments below.
Some commands expect parameters to be passed to the board. In that
@@ -569,15 +601,34 @@ typedef uint8_t PCPS_STATUS_PORT; /**< see \ref group_status_port "Bitmask" */
available then the structure is filled with 0s.
_pcps_has_ucap() checks whether supported.
+ - #PCPS_GET_CORR_INFO<br>
+ Read PZF correlation info using a CORR_INFO
+ structure.
+ _pcps_has_pzf() checks whether supported.
+
+ - #PCPS_GET_TR_DISTANCE<br>
+ #PCPS_SET_TR_DISTANCE<br>
+ Read or write distance from the RF transmitter.
+ This is used to compensate the RF propagation delay
+ for PZF receivers.
+ _pcps_has_tr_distance() checks whether supported.
+
- #PCPS_FORCE_RESET<br>
- Resets the microprocessor on the radio clock
- board. This is for debug purposes only and
- should not be used by standard applications.
+ 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:
- @{
-*/
+
+ @{ */
+
+
+#if _IS_MBG_FIRMWARE //##++
+
+// These group codes are obsolete and should be removed.
+// The explicite command codes defined below should be used instead.
#define PCPS_GIVE_TIME_GROUP 0x00
#define PCPS_SET_TIME_GROUP 0x10
#define PCPS_IRQ_GROUP 0x20
@@ -587,44 +638,39 @@ typedef uint8_t PCPS_STATUS_PORT; /**< see \ref group_status_port "Bitmask" */
#define PCPS_CTRL_GROUP 0x60
#define PCPS_CFG2_GROUP 0x70
+#endif
+
-/* PCPS_GIVE_TIME_GROUP */
-#define PCPS_GIVE_TIME ( PCPS_GIVE_TIME_GROUP | 0x0 )
-#define PCPS_GIVE_TIME_NOCLEAR ( PCPS_GIVE_TIME_GROUP | 0x1 )
-#define PCPS_GIVE_SYNC_TIME ( PCPS_GIVE_TIME_GROUP | 0x2 ) // only supported if _pcps_has_sync_time()
-#define PCPS_GIVE_HR_TIME ( PCPS_GIVE_TIME_GROUP | 0x3 ) // only supported if _pcps_has_hr_time()
-#define PCPS_GIVE_IRIG_TIME ( PCPS_GIVE_TIME_GROUP | 0x4 ) // only supported if _pcps_has_irig_time()
+#define PCPS_GIVE_TIME 0x00
+#define PCPS_GIVE_TIME_NOCLEAR 0x01
+#define PCPS_GIVE_SYNC_TIME 0x02 // only supported if _pcps_has_sync_time()
+#define PCPS_GIVE_HR_TIME 0x03 // only supported if _pcps_has_hr_time()
+#define PCPS_GIVE_IRIG_TIME 0x04 // only supported if _pcps_has_irig_time()
-/* PCPS_SET_TIME_GROUP */
-#define PCPS_SET_TIME ( PCPS_SET_TIME_GROUP | 0x0 )
+#define PCPS_SET_TIME 0x10
/* on error, return PCPS_ERR_STIME */
/* Attention: The code below can be used EXCLUSIVELY */
/* with a GPS167PCI with customized CERN firmware !! */
/* _pcps_has_event_time() checks whether supported. */
-#define PCPS_SET_EVENT_TIME ( PCPS_SET_TIME_GROUP | 0x4 )
-
-
-/* PCPS_IRQ_GROUP */
-#define PCPS_IRQ_NONE ( PCPS_IRQ_GROUP | 0x0 )
-#define PCPS_IRQ_1_SEC ( PCPS_IRQ_GROUP | 0x1 )
-#define PCPS_IRQ_1_MIN ( PCPS_IRQ_GROUP | 0x2 )
-#define PCPS_IRQ_10_MIN ( PCPS_IRQ_GROUP | 0x4 )
-#define PCPS_IRQ_30_MIN ( PCPS_IRQ_GROUP | 0x8 )
+#define PCPS_SET_EVENT_TIME 0x14
+#define PCPS_IRQ_NONE 0x20
+#define PCPS_IRQ_1_SEC 0x21
+#define PCPS_IRQ_1_MIN 0x22
+#define PCPS_IRQ_10_MIN 0x24
+#define PCPS_IRQ_30_MIN 0x28
-/* PCPS_CFG_GROUP */
-
-#define PCPS_GET_SERIAL ( PCPS_CFG_GROUP | 0x0 )
-#define PCPS_SET_SERIAL ( PCPS_CFG_GROUP | 0x1 )
+#define PCPS_GET_SERIAL 0x30
+#define PCPS_SET_SERIAL 0x31
/* on error, return PCPS_ERR_CFG */
typedef uint8_t PCPS_SERIAL;
-#define PCPS_GET_TZCODE ( PCPS_CFG_GROUP | 0x2 )
-#define PCPS_SET_TZCODE ( PCPS_CFG_GROUP | 0x3 )
+#define PCPS_GET_TZCODE 0x32
+#define PCPS_SET_TZCODE 0x33
/* on error, return PCPS_ERR_CFG */
typedef uint8_t PCPS_TZCODE;
@@ -645,10 +691,11 @@ enum
#define PCPS_TZCODE_OEZ PCPS_TZCODE_EET_EEST
-#define PCPS_GET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x4 )
-#define PCPS_SET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x5 )
+#define PCPS_GET_PCPS_TZDL 0x34
+#define PCPS_SET_PCPS_TZDL 0x35
/* on error, return PCPS_ERR_CFG */
+
/**
* The structures below can be used to configure a clock's
* time zone/daylight saving setting. This structure is shorter
@@ -699,68 +746,63 @@ typedef struct
-#define PCPS_GET_REF_OFFS ( PCPS_CFG_GROUP | 0x6 )
-#define PCPS_SET_REF_OFFS ( PCPS_CFG_GROUP | 0x7 )
+#define PCPS_GET_REF_OFFS 0x36
+#define PCPS_SET_REF_OFFS 0x37
/* on error, return PCPS_ERR_CFG */
/* The associated type MBG_REF_OFFS is defined in gpsdefs.h. */
-#define PCPS_GET_OPT_INFO ( PCPS_CFG_GROUP | 0x8 )
-#define PCPS_SET_OPT_SETTINGS ( PCPS_CFG_GROUP | 0x9 )
+#define PCPS_GET_OPT_INFO 0x38
+#define PCPS_SET_OPT_SETTINGS 0x39
/* on error, return PCPS_ERR_CFG */
/* The associated structures MBG_OPT_INFO and MBG_OPT_SETTINGS
are defined in gpsdefs.h. */
-#define PCPS_GET_IRIG_RX_INFO ( PCPS_CFG_GROUP | 0xA )
-#define PCPS_SET_IRIG_RX_SETTINGS ( PCPS_CFG_GROUP | 0xB )
+#define PCPS_GET_IRIG_RX_INFO 0x3A
+#define PCPS_SET_IRIG_RX_SETTINGS 0x3B
/* on error, return PCPS_ERR_CFG */
-#define PCPS_GET_IRIG_TX_INFO ( PCPS_CFG_GROUP | 0xC )
-#define PCPS_SET_IRIG_TX_SETTINGS ( PCPS_CFG_GROUP | 0xD )
+#define PCPS_GET_IRIG_TX_INFO 0x3C
+#define PCPS_SET_IRIG_TX_SETTINGS 0x3D
/* on error, return PCPS_ERR_CFG */
/* The associated structures IRIG_INFO and IRIG_SETTINGS
are defined in gpsdefs.h. */
-#define PCPS_GET_SYNTH ( PCPS_CFG_GROUP | 0xE )
-#define PCPS_SET_SYNTH ( PCPS_CFG_GROUP | 0xF )
+#define PCPS_GET_SYNTH 0x3E
+#define PCPS_SET_SYNTH 0x3F
/* on error, return PCPS_ERR_CFG */
/* 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
-/* PCPS_GIVE_DATA_GROUP */
-#define PCPS_GIVE_FW_ID_1 ( PCPS_GIVE_DATA_GROUP | 0x0 )
-#define PCPS_GIVE_FW_ID_2 ( PCPS_GIVE_DATA_GROUP | 0x1 )
-#define PCPS_GIVE_SERNUM ( PCPS_GIVE_DATA_GROUP | 0x2 )
-#define PCPS_GENERIC_IO ( PCPS_GIVE_DATA_GROUP | 0x3 )
-#define PCPS_GET_SYNTH_STATE ( PCPS_GIVE_DATA_GROUP | 0x4 )
-#define PCPS_GET_IRIG_CTRL_BITS ( PCPS_GIVE_DATA_GROUP | 0x5 )
-#define PCPS_GET_RAW_IRIG_DATA ( PCPS_GIVE_DATA_GROUP | 0x6 )
-
-#define PCPS_GET_STATUS_PORT ( PCPS_GIVE_DATA_GROUP | 0xB )
-#define PCPS_GET_DEBUG_STATUS ( PCPS_GIVE_DATA_GROUP | 0xC )
+#define PCPS_GET_STATUS_PORT 0x4B
+#define PCPS_GET_DEBUG_STATUS 0x4C
// expects sizeof( MBG_DEBUG_STATUS ) chars
-// PCPS_GIVE_DATA_GROUP codes 0x0D, 0x0E, and 0x0F are reserved.
-
+// Command codes 0x4D, 0x4E, and 0x4F are reserved.
-/* PCPS_GPS_DATA_GROUP */
-#define PCPS_READ_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x0 )
-#define PCPS_WRITE_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x1 )
+#define PCPS_READ_GPS_DATA 0x50
+#define PCPS_WRITE_GPS_DATA 0x51
-/* PCPS_CTRL_GROUP */
-#define PCPS_CLR_UCAP_BUFF ( PCPS_CTRL_GROUP | 0x0 )
-#define PCPS_GIVE_UCAP_ENTRIES ( PCPS_CTRL_GROUP | 0x1 )
-#define PCPS_GIVE_UCAP_EVENT ( PCPS_CTRL_GROUP | 0x2 )
+#define PCPS_CLR_UCAP_BUFF 0x60
+#define PCPS_GIVE_UCAP_ENTRIES 0x61
+#define PCPS_GIVE_UCAP_EVENT 0x62
typedef struct
{
@@ -776,18 +818,27 @@ 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()
+
+
+
/**
special -- use with care !
*/
#define PCPS_FORCE_RESET 0x80
-/** @} */
+// Command codes 0xF0 through 0xFF are reserved.
+
+/** @} group_cmd_bytes */
+
/* Codes returned when commands with parameters have been passed */
/* to the board */
#define PCPS_SUCCESS 0 /**< OK, no error */
#define PCPS_ERR_STIME -1 /**< invalid date/time/status passed */
-#define PCPS_ERR_CFG -2 /**< invalid parms with a PCPS_CFG_GROUP cmd */
+#define PCPS_ERR_CFG -2 /**< invalid parms for a cmd writing config parameters */
@@ -796,7 +847,7 @@ typedef struct
#endif
-/** The size of the plug-in radio clock's on-board FIFO: */
+/** The size of the plug-in card's on-board FIFO */
#define PCPS_FIFO_SIZE 16
typedef int8_t PCPS_BUFF[PCPS_FIFO_SIZE];
@@ -991,8 +1042,9 @@ typedef struct PCPS_IRIG_TIME_s
-/* Bit masks used with both PCPS_TIME_STATUS and PCPS_TIME_STATUS_X */
-
+/**
+ * Bit masks used with both PCPS_TIME_STATUS and PCPS_TIME_STATUS_X
+ */
#define PCPS_FREER 0x01 /**< DCF77 clock running on xtal */
/**< GPS receiver has not verified its position */
@@ -1013,20 +1065,29 @@ typedef struct PCPS_IRIG_TIME_s
#define PCPS_INVT 0x80 /**< invalid time because battery was disconn'd */
-/* Bit masks used only with PCPS_TIME_STATUS_X */
-
+/**
+ * Bit masks used only with PCPS_TIME_STATUS_X
+ */
#define PCPS_LS_ENB 0x0100 /**< current second is leap second */
#define PCPS_ANT_FAIL 0x0200 /**< antenna failure */
-#define PCPS_LS_ANN_NEG 0x0400 /**< announced leap second is negative */
+#define PCPS_LS_ANN_NEG 0x0400 /**< announced leap second is negative */
#define PCPS_SCALE_GPS 0x0800 /**< time stamp is GPS scale */
#define PCPS_SCALE_TAI 0x1000 /**< time stamp is TAI scale */
-/* The next two bits are used only if the structure */
-/* PCPS_HR_TIME contains a user capture event */
+/**
+ * Bit masks used only with time stamps representing user capture events
+ */
#define PCPS_UCAP_OVERRUN 0x2000 /**< events interval too short */
#define PCPS_UCAP_BUFFER_FULL 0x4000 /**< events read too slow */
/**
+ * Bit masks used only with time stamps representing the current board time.
+ * A DCF77 PZF receiver can set this bit if it is actually synchronized
+ * using PZF correlation and thus provides higher accuracy than AM receivers.
+ */
+#define PCPS_SYNC_PZF 0x2000 /**< same code as PCPS_UCAP_OVERRUN */
+
+/**
* Immediately after a clock has been accessed, subsequent accesses
* are blocked for up to 1.5 msec to give the clock's microprocessor
* some time to decode the incoming time signal.
@@ -1038,9 +1099,9 @@ typedef struct PCPS_IRIG_TIME_s
*/
#define PCPS_IO_BLOCKED 0x8000
-/**
- This bit mask can be used to extract the time scale information out
- of a PCPS_TIME_STATUS_X value.
+/**
+ * This bit mask can be used to extract the time scale information out
+ * of a PCPS_TIME_STATUS_X value.
*/
#define PCPS_SCALE_MASK ( PCPS_SCALE_TAI | PCPS_SCALE_GPS )
@@ -1130,41 +1191,6 @@ enum
#define PCPS_MOD_SHIFT ( PCPS_BD_BITS + PCPS_FR_BITS )
/* num of bits to shift left */
-/**
- * The fixed-length standard time string being sent on the serial
- * output is described below:
- *
- * \<STX\>D:dd.mm.yy;T:d;U:hh.mm.ss;uvwx\<ETX\>
- *
- * where \<STX\> and \<ETX\> represent the ASCII codes 0x02 and 0x03,
- * 'dd.mm.yy' is the format of the current date, 'd' is the current
- * day of week (1..7, 1 == Monday ) and 'hh.mm.ss' is the format of
- * the current time. The characters 'uvwx' reflect the clock's status:
- *
- * u clock status character:
- * '#' clock has not synchronized after reset
- * ' ' (space, 20h) clock has synchronized after reset
- *
- * v clock status character, different for DCF77 or GPS receivers:
- * '*' DCF77 clock currently runs on XTAL
- * GPS receiver has not checked its position
- * ' ' (space, 20h):
- * DCF77 clock is syncronized with transmitter
- * GPS receiver has determined its position
- *
- * x time zone indicator:
- * 'U' UTC Universal Time, Coordinated
- * ' ' MEZ European Standard Time, daylight saving disabled
- * 'S' MESZ European Summertime, daylight saving enabled
- *
- * y anouncement of discontinuity of time, enabled during last hour
- * before discontinuity comes in effect:
- * '!' announcement of start or end of daylight saving
- * 'A' announcement of leap second insertion
- * ' ' (space, 20h): nothing announced
- */
-
-
/**
* Some definitions used with PZF receivers
@@ -1173,6 +1199,11 @@ enum
/* receiver distance from transmitter [km] */
typedef uint16_t TR_DISTANCE;
+#define _mbg_swab_tr_distance( _p ) \
+ _mbg_swab16( _p )
+
+
+
/* correlation status info */
typedef struct
{
@@ -1182,6 +1213,10 @@ typedef struct
uint8_t signal; /**< signal level, may always be 0 for devices which do not support this */
} CORR_INFO;
+#define _mbg_swab_corr_info( _p ) \
+ _nop_macro_fnc()
+
+
/** Codes used with CORR_INFO::status: */
enum
{
@@ -1192,19 +1227,19 @@ enum
};
-/**
- * @defgroup gps_cmds_bus GPS commands passed via the system bus
- *
- * 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
- * exceeds the size of the devices's I/O buffer and must therefore be
- * accessed in several portions.
- *
- * The structures to be used are defined in gpsdefs.h. Not all structures
- * are supportet, yet. Check the R/W indicators for details.
- */
+/** @defgroup group_gps_cmds_bus GPS commands passed via the system bus
+
+ 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
+ exceeds the size of the devices's I/O buffer and must therefore be
+ accessed in several portions.
+
+ The structures to be used are defined in gpsdefs.h. Not all structures
+ are supportet, yet. Check the R/W indicators for details.
+
+ * @{ */
enum
{ // R/W data type description
// system data -----------------------------------------------
@@ -1236,7 +1271,12 @@ enum
PC_GPS_IP4_SETTINGS, // R/W IP4_SETTINGS LAN interface configuration, only if PCPS_HAS_LAN_INTF
PC_GPS_PTP_STATE, // R/- PTP_STATE, only if PCPS_HAS_PTP
PC_GPS_PTP_CFG, // R/W PTP_CFG_{SETTINGS|INFO}, only if PCPS_HAS_PTP
- PC_GPS_PTP_UNICAST_CFG, // R/W PTP_CFG_UNICAST_{SETTINGS|INFO}, only if PCPS_HAS_PTP
+ PC_GPS_PTP_UC_MASTER_CFG_LIMITS, // R/- PTP_UC_MASTER_CFG_LIMITS, only if can be unicast master
+ PC_GPS_ALL_PTP_UC_MASTER_INFO, // R/- n*PTP_UC_MASTER_INFO_IDX, only if can be unicast master
+ PC_GPS_PTP_UC_MASTER_SETTINGS_IDX, // -/W PTP_UC_MASTER_SETTINGS_IDX, only if can be unicast master
+ PC_GPS_GPIO_CFG_LIMITS, // R/- MBG_GPIO_CFG_LIMITS, only if PCPS_HAS_GPIO
+ PC_GPS_ALL_GPIO_INFO, // R/- n*MBG_GPIO_INFO, all GPIO info, only if PCPS_HAS_GPIO
+ PC_GPS_GPIO_SETTINGS_IDX, // -/W MBG_GPIO_SETTINGS_IDX, GPIO cfg for a specific port, only if PCPS_HAS_GPIO
// GPS data
PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes
@@ -1258,6 +1298,9 @@ enum
N_PC_GPS_CMD /**< no command, just the number of known commands */
};
+/** @} group_gps_cmds_bus */
+
+
// The type below can be used to store an unambiguous command code.
// In case of the standard PCPS_... commands the lower byte contains
// the command code and the upper byte is 0.
@@ -1266,8 +1309,10 @@ enum
// the associated PC_GPS_... type code.
typedef uint16_t PCPS_CMD_INFO;
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdev.h b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdev.h
index 1bf517c..5da8d62 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdev.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.49.1.34 2011/03/29 14:08:45 martin TRASH martin $
+ * $Id: pcpsdev.h 1.49.1.51 2011/07/14 13:29:14 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,6 +17,39 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
+ * Revision 1.49.1.51 2011/07/14 13:29:14 martin
+ * Revision 1.49.1.50 2011/07/13 09:44:53 martin
+ * Moved IA64 includes from pcpsdev.h to mbgpccyc.h.
+ * Revision 1.49.1.49 2011/07/06 13:23:24 martin
+ * Revision 1.49.1.48 2011/07/06 11:22:50 martin
+ * Added macros _pcps_has_corr_info() and _pcps_has_tr_distance().
+ * Revision 1.49.1.47 2011/07/05 12:25:19 martin
+ * Revision 1.49.1.46 2011/07/04 10:29:44 martin
+ * Modified a comment.
+ * Revision 1.49.1.45 2011/06/29 14:06:08 martin
+ * Added support for TCR600USB, MSF600USB, and WVB600USB.
+ * Extended bus flag for USB v2 and macro _pcps_is_usb_v2().
+ * New feature ..._HAS_PZF and macro _pcps_has_pzf().
+ * Revision 1.49.1.44 2011/06/29 09:10:26 martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Revision 1.49.1.43 2011/06/24 10:26:52 martin
+ * Fixed warning under DOS.
+ * Revision 1.49.1.42 2011/06/24 08:07:03Z martin
+ * Moved PC cycles stuff to an new extra header.
+ * Revision 1.49.1.41 2011/06/21 15:17:36 martin
+ * Fixed build under DOS.
+ * Revision 1.49.1.40 2011/06/21 14:23:59Z martin
+ * Cleaned up handling of pragma pack().
+ * Introduced generic MBG_SYS_TIME with nanosecond resolution.
+ * Support struct timespec under Linux, if available.
+ * Revision 1.49.1.39 2011/06/01 09:29:09 martin
+ * Revision 1.49.1.38 2011/05/31 14:20:54 martin
+ * Revision 1.49.1.37 2011/05/16 13:18:38 martin
+ * Use MBG_TGT_KERNEL instead of _KDD_.
+ * Revision 1.49.1.36 2011/05/06 13:47:38Z martin
+ * Support PZF600PEX.
+ * Revision 1.49.1.35 2011/04/19 15:06:24 martin
+ * Added PTP unicast master configuration stuff.
* Revision 1.49.1.34 2011/03/29 14:08:45 martin
* For compatibility use cpu_counter() instead of cpu_counter_serializing() under NetBSD.
* Revision 1.49.1.33 2011/03/28 09:50:18 martin
@@ -256,71 +289,75 @@
#ifndef _PCPSDEV_H
#define _PCPSDEV_H
+#include <mbg_tgt.h>
+#include <mbgtime.h>
+#include <mbgpccyc.h>
#include <pcpsdefs.h>
#include <gpsdefs.h>
#include <usbdefs.h>
-#include <mbg_tgt.h>
-#include <mbgtime.h>
#include <use_pack.h>
#if defined( MBG_TGT_LINUX )
- #if !defined( USE_TIMESPEC )
- #define USE_TIMESPEC 0
- #endif
-
#if defined( MBG_TGT_KERNEL )
#include <linux/delay.h>
#include <linux/time.h>
#else
#include <unistd.h>
+ #include <time.h>
#include <sys/time.h>
#include <sys/sysinfo.h>
#endif
- #if defined( MBG_ARCH_IA64 )
- #include <asm/ia64regs.h>
- #include <asm/intel_intrin.h>
- #endif
+#elif defined( MBG_TGT_FREEBSD )
-#endif
-
-#if defined( MBG_TGT_BSD )
-
- #if !defined( USE_TIMESPEC )
- #define USE_TIMESPEC 1
+ #if defined( MBG_TGT_KERNEL )
+ #include <sys/sysproto.h>
+ #include <sys/pcpu.h>
+ #else
+ #include <sys/time.h>
#endif
- #if defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
- #include <machine/clock.h> /* for symbol 'tsc_freq' */
- #endif
+#elif defined( MBG_TGT_NETBSD )
- #if defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL )
- #include <machine/cpu.h>
- #include <machine/cpu_counter.h> /* for cycle counter abstraction */
+ #if !defined( MBG_TGT_KERNEL )
+ #include <sys/time.h>
#endif
-#endif
+#elif defined( MBG_TGT_DOS )
-#if defined( MBG_TGT_DOS )
#include <dos.h> // for delay()
-#endif
+#endif
/* Start of header body */
-#if defined( MBG_ARCH_SPARC ) || defined( MBG_ARCH_IA64 )
- #undef _USE_PACK // don't pack interface structures
+#if defined( _USE_PACK )
+ #if !defined( _NO_USE_PACK_INTF )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+ #endif
#endif
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+
+#if defined( MBG_TGT_UNIX )
+ #define USE_GENERIC_SYS_TIME 1
+#else
+ #define USE_GENERIC_SYS_TIME 0
#endif
-#if !defined( USE_TIMESPEC )
- #define USE_TIMESPEC 0
+#if USE_GENERIC_SYS_TIME
+
+ typedef struct
+ {
+ uint64_t sec;
+ uint64_t nsec;
+ } NANO_TIME_64;
+
+ typedef NANO_TIME_64 MBG_SYS_TIME;
+
#endif
@@ -337,10 +374,6 @@
#define MBG_TGT_SUPP_MEM_ACC 1
- // used with QueryPerformanceCounter()
- typedef int64_t MBG_PC_CYCLES;
- typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
-
typedef int64_t MBG_SYS_UPTIME; // [s]
typedef LARGE_INTEGER MBG_SYS_TIME;
@@ -349,35 +382,14 @@
#define MBG_TGT_SUPP_MEM_ACC 1
- typedef uint64_t MBG_PC_CYCLES;
- typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
-
typedef int64_t MBG_SYS_UPTIME; // [s]
- typedef struct timeval MBG_SYS_TIME;
-
#elif defined( MBG_TGT_BSD )
#define MBG_TGT_SUPP_MEM_ACC 1
- typedef uint64_t MBG_PC_CYCLES;
- typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
-
typedef int64_t MBG_SYS_UPTIME; // [s]
- #if USE_TIMESPEC
- typedef struct timespec MBG_SYS_TIME;
- #else
- typedef struct timeval MBG_SYS_TIME;
- #endif
-
- #if defined( MBG_TGT_FREEBSD ) && defined( MBG_TGT_KERNEL )
- #include <sys/sysproto.h>
- #include <sys/pcpu.h>
- #else
- #include <sys/time.h>
- #endif
-
#if defined( MBG_TGT_NETBSD )
#ifdef __LP64__
#define MBG_MEM_ADDR uint64_t
@@ -388,17 +400,12 @@
#elif defined( MBG_TGT_OS2 )
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
-
typedef long MBG_SYS_UPTIME; //## dummy
typedef uint32_t MBG_SYS_TIME; //## dummy
#elif defined( MBG_TGT_DOS )
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
#define MBG_MEM_ADDR uint32_t // 64 bit not supported, nor required.
typedef long MBG_SYS_UPTIME; //## dummy
@@ -407,9 +414,6 @@
#else // other target OSs which access the hardware directly
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
-
typedef long MBG_SYS_UPTIME; //## dummy
typedef uint32_t MBG_SYS_TIME; //## dummy
@@ -422,14 +426,8 @@
#endif
-// MBG_PC_CYCLES, MBG_PC_CYCLES_FREQUENCY, and MBG_SYS_TIME are always read
-// in native machine endianess, so no endianess conversion is required.
-#define _mbg_swab_mbg_pc_cycles( _p ) \
- _nop_macro_fnc()
-
-#define _mbg_swab_mbg_pc_cycles_frequency( _p ) \
- _nop_macro_fnc()
-
+// MBG_SYS_TIME is always read in native machine endianess,
+// so no endianess conversion is required.
#define _mbg_swab_mbg_sys_time( _p ) \
_nop_macro_fnc()
@@ -461,253 +459,76 @@ typedef struct
-#if ( defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD ) ) && defined( MBG_ARCH_X86 )
-
- static __mbg_inline unsigned long long int mbg_rdtscll( void )
- {
- // The code below is a hack to get around issues with
- // different versions of gcc.
- //
- // Normally the inline asm code could look similar to:
- //
- // __asm__ volatile ( "rdtsc" : "=A" (x) )
- //
- // which would copy the output regs edx:eax as a 64 bit
- // number to a variable x.
- //
- // The "=A" expression should implicitely tell the compiler
- // the edx and eax registers have been clobbered. However,
- // this does not seem to work properly at least with gcc 4.1.2
- // shipped with Centos 5.
- //
- // If optimization level 1 or higher is used then function
- // parameters are also passed in registers. If the inline
- // code above is used inside a function then the edx register
- // is clobbered but the gcc 4.1.2 is not aware of this and
- // assumes edx is unchanged, which may yield faulty results
- // or even lead to segmentation faults.
- //
- // A possible workaround could be to mark edx explicitely as
- // being clobbered in the asm inline code, but unfortunately
- // other gcc versions report an error if a register which is
- // implicitely (by "=A") known to be clobbered is also listed
- // explicitely to be clobbered.
- //
- // So the code below is a workaround which tells the compiler
- // implicitely that the eax ("=a") and edx ("=d") registers
- // are being used and thus clobbered.
-
- union
- {
- struct
- {
- uint32_t lo;
- uint32_t hi;
- } u32;
-
- uint64_t u64;
-
- } tsc_val;
-
- __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
-
- return tsc_val.u64;
-
- } // mbg_rdtscll
-
-#endif
-
-
-
static __mbg_inline
-void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
+void mbg_get_sys_time( MBG_SYS_TIME *p )
{
#if defined( MBG_TGT_WIN32 )
- #if defined( _KDD_ ) // kernel space
- *p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
- #else // user space
- QueryPerformanceCounter( (LARGE_INTEGER *) p );
- #endif
-
- #define MBG_PC_CYCLES_SUPPORTED 1
-
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
-
- #if 0 && ( defined( CONFIG_X86_TSC ) || defined( CONFIG_M586TSC ) ) //##++++
- #define _pcps_get_cycles( _c ) \
- _c = get_cycles()
- #else
- *p = mbg_rdtscll();
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ KeQuerySystemTime( p );
+ #else // user space
+ {
+ FILETIME ft;
+ GetSystemTimeAsFileTime( &ft );
+ p->LowPart = ft.dwLowDateTime;
+ p->HighPart = ft.dwHighDateTime;
+ }
#endif
- #define MBG_PC_CYCLES_SUPPORTED 1
-
- #elif defined( MBG_TGT_NETBSD ) && defined ( MBG_TGT_KERNEL )
-
- *p = cpu_counter(); //##++ or cpu_counter_serializing()
-
- #define MBG_PC_CYCLES_SUPPORTED 1
-
- #elif defined( MBG_TGT_BSD ) && defined( MBG_ARCH_X86 )
-
- *p = mbg_rdtscll();
+ #elif defined( MBG_TGT_LINUX )
- #define MBG_PC_CYCLES_SUPPORTED 1
+ #if defined( MBG_TGT_KERNEL )
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 )
+ #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 22 ) ) //##+++++++++++++
+ {
+ // getnstimeofday() supported
+ struct timespec ts;
- unsigned long result = ia64_getreg( _IA64_REG_AR_ITC );
- ia64_barrier();
+ getnstimeofday( &ts );
- #ifdef CONFIG_ITANIUM
- while (unlikely((__s32) result == -1)) {
- result = ia64_getreg(_IA64_REG_AR_ITC);
- ia64_barrier();
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
}
- #endif
-
- *p = result;
-
- #define MBG_PC_CYCLES_SUPPORTED 1
-
- #else
-
- *p = 0;
-
- #endif
-
-} // mbg_get_pc_cycles
-
-
-
-static __mbg_inline
-void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
-{
- #if defined( MBG_TGT_WIN32 )
- LARGE_INTEGER li;
-
- #if defined( _KDD_ ) // kernel space
- KeQueryPerformanceCounter( &li );
- #else // user space
- QueryPerformanceFrequency( &li );
- #endif
-
- *p = li.QuadPart;
-
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
+ #else
+ {
+ // getnstimeofday() *not* supported
+ struct timeval tv;
- #if defined( MBG_TGT_KERNEL )
+ do_gettimeofday( &tv );
- *p = ( cpu_khz * 1000 );
+ p->sec = tv.tv_sec;
+ p->nsec = tv.tv_usec * 1000;
+ }
+ #endif
- #else
+ #else // Linux user space
+ {
+ struct timespec ts;
- *p = 0;
+ clock_gettime( CLOCK_REALTIME, &ts );
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
+ }
#endif
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 )
-
- #error A way to get cycles frequency needs to be defined for Linux/IA64.
-
- // we probably can use
- // ia64_sal_freq_base(unsigned long which, unsigned long *ticks_per_second,
- // unsigned long *drift_info)
- // However, this is not tested.
-
#elif defined( MBG_TGT_BSD )
- #if defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
-
- *p = tsc_freq;
-
- #elif defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL )
-
- *p = cpu_frequency( curcpu() );
-
- #else
-
- *p = 0;
-
- #endif
-
- #else
-
- #if MBG_PC_CYCLES_SUPPORTED
-
- #error A way to get cycles frequency needs to be defined for this target.
-
- #else
- *p = 0;
- #endif
-
- #endif
-
-} // mbg_get_pc_cycles_frequency
-
-
-
-static __mbg_inline
-MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
-{
-#if !defined( MBG_PC_CYCLES_SUPPORTED )
- // Cycle counts not supported on this target platform.
- // Under SPARC this may even result in bus errors
- // due to alignment of the underlying data structures.
- return 0;
-#else
- return *p1 - *p2;
-#endif
-
-} // mbg_delta_pc_cycles
-
-
-
-static __mbg_inline
-void mbg_get_sys_time( MBG_SYS_TIME *p )
-{
- #if defined( MBG_TGT_WIN32 )
-
- #if defined( _KDD_ ) // kernel space
- KeQuerySystemTime( p );
- #else // user space
- {
- FILETIME ft;
- GetSystemTimeAsFileTime( &ft );
- p->LowPart = ft.dwLowDateTime;
- p->HighPart = ft.dwHighDateTime;
- }
- #endif
-
- #elif defined( MBG_TGT_LINUX )
+ struct timespec ts;
#if defined( MBG_TGT_KERNEL )
- do_gettimeofday( p );
+ nanotime( &ts );
#else
- gettimeofday( p, NULL );
- #endif
-
- #elif defined( MBG_TGT_BSD )
-
- #if USE_TIMESPEC // use struct timespec
- #if defined( MBG_TGT_KERNEL )
- nanotime( p );
- #else
- #if defined( MBG_TGT_FREEBSD )
- clock_gettime( CLOCK_REALTIME_PRECISE, p );
- #else // MBG_TGT_NETBSD, ...
- clock_gettime( CLOCK_REALTIME, p );
- #endif
- #endif
- #else // use struct timeval
- #if defined( MBG_TGT_KERNEL )
- microtime( p );
- #else
- gettimeofday( p, NULL );
+ #if defined( MBG_TGT_FREEBSD )
+ clock_gettime( CLOCK_REALTIME_PRECISE, &ts );
+ #else // MBG_TGT_NETBSD, ...
+ clock_gettime( CLOCK_REALTIME, &ts );
#endif
#endif
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
+
#else
*p = 0;
@@ -723,7 +544,7 @@ void mbg_get_sys_uptime( MBG_SYS_UPTIME *p )
{
#if defined( MBG_TGT_WIN32 )
- #if defined( _KDD_ ) // kernel space
+ #if defined( MBG_TGT_KERNEL ) // kernel space
ULONGLONG time_increment = KeQueryTimeIncrement();
LARGE_INTEGER tick_count;
@@ -734,7 +555,7 @@ void mbg_get_sys_uptime( MBG_SYS_UPTIME *p )
// but we need seconds
*p = ( tick_count.QuadPart * time_increment ) / HNS_PER_SEC;
- #else // user space
+ #else // user space
DWORD tickCount;
DWORD timeAdjustment;
@@ -814,7 +635,7 @@ void mbg_sleep_sec( long sec )
{
#if defined( MBG_TGT_WIN32 )
- #if defined( _KDD_ ) // kernel space
+ #if defined( MBG_TGT_KERNEL ) // kernel space
LARGE_INTEGER delay;
// we need to pass a negative value to KeDelayExecutionThread()
@@ -823,7 +644,7 @@ void mbg_sleep_sec( long sec )
delay.QuadPart = (LONGLONG) sec * HNS_PER_SEC;
KeDelayExecutionThread( KernelMode, FALSE, &delay );
- #else // user space
+ #else // user space
// Sleep() expects milliseconds
Sleep( sec * 1000 );
#endif
@@ -851,7 +672,7 @@ void mbg_sleep_sec( long sec )
#elif defined( MBG_TGT_DOS )
- delay( sec * 1000 );
+ delay( (unsigned) ( sec * 1000 ) );
#else
@@ -883,26 +704,18 @@ typedef uint16_t MBG_DBG_PORT;
#define PCPS_BUS_PCI 0x0004 // PCI
#define PCPS_BUS_USB 0x0008 // USB
+
// The flags below are or'ed to the PC_BUS_PCI code
// in order to indicate which PCI interface chip is used
// on a PCI card. If no flag is set then the S5933 chip is
// installed which has been used for the first generation
// of Meinberg PCI cards.
+#define PCPS_BUS_PCI_CHIP_S5920 0x8000 // S5920 PCI interface chip.
+#define PCPS_BUS_PCI_CHIP_ASIC 0x4000 // Meinberg's own PCI interface chip.
+#define PCPS_BUS_PCI_CHIP_PEX8311 0x2000 // PEX8311 PCI Express interface chip
+#define PCPS_BUS_PCI_CHIP_MBGPEX 0x1000 // Meinberg's own PCI Express interface chip
-// S5920 PCI interface chip.
-#define PCPS_BUS_PCI_CHIP_S5920 0x8000
-
-// Meinberg's own PCI interface chip.
-#define PCPS_BUS_PCI_CHIP_ASIC 0x4000
-
-// PEX8311 PCI Express interface chip
-#define PCPS_BUS_PCI_CHIP_PEX8311 0x2000
-
-// Meinberg's own PCI Express interface chip
-#define PCPS_BUS_PCI_CHIP_MBGPEX 0x1000
-
-
-// The constant below combines the PCI bus flags.
+// The constants below combine the PCI bus flags:
#define PCPS_BUS_PCI_S5933 ( PCPS_BUS_PCI )
#define PCPS_BUS_PCI_S5920 ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_S5920 )
#define PCPS_BUS_PCI_ASIC ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_ASIC )
@@ -910,6 +723,16 @@ typedef uint16_t MBG_DBG_PORT;
#define PCPS_BUS_PCI_MBGPEX ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_MBGPEX )
+// The flags below are or'ed to the PCPS_BUS_USB code
+// in order to indicate which USB protocol version
+// is supported by the device. If no additional flag is set
+// then the device has a USB v1 interface.
+#define PCPS_BUS_USB_FLAG_V2 0x8000
+
+// The constant below combines the PCI bus flags:
+#define PCPS_BUS_USB_V2 ( PCPS_BUS_USB | PCPS_BUS_USB_FLAG_V2 )
+
+
/** A list of known radio clocks. */
enum PCPS_TYPES
@@ -943,6 +766,10 @@ enum PCPS_TYPES
PCPS_TYPE_GPS180PEX,
PCPS_TYPE_TCR180PEX,
PCPS_TYPE_DCF600USB,
+ PCPS_TYPE_PZF180PEX,
+ PCPS_TYPE_TCR600USB,
+ PCPS_TYPE_MSF600USB,
+ PCPS_TYPE_WVB600USB,
N_PCPS_DEV_TYPE
};
@@ -970,10 +797,10 @@ typedef struct
-#if !defined( MBG_TGT_LINUX ) || defined( MBG_ARCH_X86 )
+#if !defined( MBG_TGT_UNIX ) || defined( MBG_ARCH_X86 )
typedef uint16_t PCPS_PORT_ADDR;
#else
- typedef ulong PCPS_PORT_ADDR;
+ typedef uint64_t PCPS_PORT_ADDR;
#endif
@@ -996,9 +823,11 @@ typedef struct
typedef struct
{
MBG_MEM_ADDR user_virtual_address;
- ulong len;
#if defined( MBG_TGT_LINUX )
- uint32_t pfn_offset;
+ uint64_t len;
+ uint64_t pfn_offset;
+ #else
+ ulong len;
#endif
} PCPS_MAPPED_MEM;
@@ -1064,6 +893,7 @@ enum
PCPS_BIT_HAS_UTC_OFFS,
PCPS_BIT_HAS_HR_TIME,
PCPS_BIT_HAS_SERNUM,
+
PCPS_BIT_HAS_TZCODE,
PCPS_BIT_HAS_CABLE_LEN,
PCPS_BIT_HAS_EVENT_TIME, // custom GPS firmware only
@@ -1072,6 +902,7 @@ enum
PCPS_BIT_HAS_PCPS_TZDL,
PCPS_BIT_HAS_UCAP,
PCPS_BIT_HAS_IRIG_TX,
+
PCPS_BIT_HAS_GPS_DATA_16, // use 16 bit size specifiers
PCPS_BIT_HAS_SYNTH,
PCPS_BIT_HAS_GENERIC_IO,
@@ -1080,10 +911,13 @@ enum
PCPS_BIT_HAS_IRIG_CTRL_BITS,
PCPS_BIT_HAS_LAN_INTF,
PCPS_BIT_HAS_PTP,
+
PCPS_BIT_HAS_IRIG_TIME,
PCPS_BIT_HAS_FAST_HR_TSTAMP,
PCPS_BIT_HAS_RAW_IRIG_DATA,
- N_PCPS_FEATURE
+ PCPS_BIT_HAS_PZF, // can also demodulate DCF77 PZF
+
+ N_PCPS_FEATURE // must not exceed 32 !!
};
@@ -1114,6 +948,7 @@ enum
#define PCPS_HAS_IRIG_TIME ( 1UL << PCPS_BIT_HAS_IRIG_TIME )
#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 )
@@ -1146,6 +981,7 @@ enum
"PCPS_HAS_IRIG_TIME", \
"PCPS_HAS_FAST_HR_TSTAMP", \
"PCPS_HAS_RAW_IRIG_DATA" \
+ "PCPS_HAS_PZF" \
}
/** @} */
@@ -1271,7 +1107,18 @@ enum
#define PCPS_FEAT_DCF600USB ( PCPS_FEAT_USB5131 )
-// Some features of the API used to access Meinberg plug-in radio clocks
+#define PCPS_FEAT_PZF180PEX ( PCPS_FEAT_PEX511 | PCPS_HAS_PZF )
+
+#define PCPS_FEAT_TCR600USB ( PCPS_FEAT_TCR51USB \
+ | PCPS_HAS_IRIG_CTRL_BITS \
+ | PCPS_HAS_IRIG_TIME \
+ | PCPS_HAS_RAW_IRIG_DATA )
+
+#define PCPS_FEAT_MSF600USB ( PCPS_FEAT_MSF51USB )
+
+#define PCPS_FEAT_WVB600USB ( PCPS_FEAT_WWVB51USB )
+
+// Some features of the API used to access Meinberg plug-in devices
// have been implemented starting with the special firmware revision
// numbers defined below.
//
@@ -1406,6 +1253,7 @@ typedef struct
#define _pcps_is_mca( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_MCA )
#define _pcps_is_pci( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_PCI )
#define _pcps_is_usb( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_USB )
+#define _pcps_is_usb_v2( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_USB_V2 )
#define _pcps_is_pci_s5933( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5933 )
#define _pcps_is_pci_s5920( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5920 )
@@ -1438,7 +1286,7 @@ typedef struct
#define _pcps_sernum( _d ) ( (_d)->cfg.sernum )
-// The macros below handle the clock device's err_flags.
+// The macros below handle the device's err_flags.
#define _pcps_err_flags( _d ) ( (_d)->cfg.err_flags )
#define _pcps_chk_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) & (_msk) )
#define _pcps_set_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) |= (_msk) )
@@ -1535,6 +1383,12 @@ typedef struct
#define _pcps_has_ri_ptp_unicast( _p_ri ) _pcps_has_ri_feature( (_p_ri), GPS_HAS_PTP_UNICAST )
+#define _pcps_has_pzf( _d ) _pcps_has_feature( (_d), PCPS_HAS_PZF )
+
+#define _pcps_has_corr_info( _d ) _pcps_has_pzf( _d )
+
+#define _pcps_has_tr_distance( _d ) _pcps_has_pzf( _d )
+
#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) \
|| _pcps_is_pci_pex8311( _d ) \
|| _pcps_is_pci_mbgpex( _d ) )
@@ -1608,6 +1462,18 @@ typedef POUT_INFO_IDX ALL_POUT_INFO[MAX_PARM_POUT];
+/*
+ * The definitions and types below are used to collect
+ * all configuration parameters of PTP device's unicast
+ * master specification:
+ */
+
+#define MAX_PARM_PTP_UC_MASTER 3
+
+typedef PTP_UC_MASTER_INFO_IDX ALL_PTP_UC_MASTER_INFO[MAX_PARM_PTP_UC_MASTER];
+
+
+
// The macros below can be used to mark a PCPS_TIME variable
// as unread, i.e. its contents have not been read from the clock,
// and to check if such a variable is marked as unread.
@@ -1726,8 +1592,9 @@ typedef uint32_t PCPS_IRQ_STAT_INFO;
( (_v) & 0xFF )
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c
index d94d570..a143655 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.c 1.46.2.36 2011/04/01 10:38:00 martin TRASH $
+ * $Id: pcpsdrvr.c 1.46.2.47 2011/07/11 12:49:44 martin TRASH daniel(2011.07.13.13.54.14) $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -20,17 +20,19 @@
* under the different operating systems. If required, each of
* those symbols can be overridden by compiler arguments.
*
- * Basically the following radio clocks are supported:
- * USB: USB5131, TCR51USB, MSF51USB, WWVB51USB, DCF600USB
+ * Basically the following devices are supported:
+ * USB v2: DCF600USB, TCR600USB, MSF600USB, WVB600USB
+ * USB v1: USB5131, TCR51USB, MSF51USB, WWVB51USB
* PCI express: PEX511, TCR511PEX, GPS170PEX, PTP270PEX,
* FRC511PEX, TCR170PEX, GPS180PEX, TCR180PEX
+ * PZF180PEX
* PCI bus 5V/3.3V: PCI510, PCI511, GPS169PCI, GPS170PCI,
* TCR510PCI, TCR167PCI, TCR511PCI
* PCI bus 5V: PCI32, GPS167PCI, PCI509, GPS168PCI
* MCA bus: PS31
* ISA bus: PC31, PC32, GPS167PC
*
- * USB is not supported for some target environments, mainly because
+ * USB is not supported for some target environments, mainly because
* those operating systems don't provide full USB support.
*
* PCI support is possible in two different ways. The preferred
@@ -61,6 +63,37 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.c $
+ * Revision 1.46.2.47 2011/07/11 12:49:44 martin
+ * Revision 1.46.2.46 2011/07/11 11:00:42Z martin
+ * Modified some debug code.
+ * Revision 1.46.2.45 2011/07/05 10:44:22 martin
+ * Fixed build errors under Unix.
+ * Revision 1.46.2.44 2011/07/05 10:18:59 martin
+ * Fixed pcps_start_device() for USBv2 devices.
+ * Added warnings in case a device is not handled
+ * by chip setup or device feature check.
+ * Revision 1.46.2.43 2011/06/29 14:02:49Z martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Added support for TCR600USB, MSF600USB, and WVB600USB.
+ * Modified low level AMCC read functions for SPARC.
+ * Fixed handling of unaligned access for SPARC.
+ * Modified DEBUG_IO code.
+ * Added some debug messages.
+ * Updated some comments.
+ * Revision 1.46.2.42 2011/06/21 15:20:56 martin
+ * Fixed build under DOS.
+ * Revision 1.46.2.41 2011/06/20 16:53:34Z martin
+ * account for generic MBG_SYS_TIME with nanosecond resolution.
+ * Revision 1.46.2.40 2011/05/16 17:41:11 martin
+ * Initialize device semaphores only early at device initializition
+ * if required, otherwise later, since early initialization can lead
+ * to a trap e.g. under Windows.
+ * Revision 1.46.2.39 2011/05/06 13:47:39Z martin
+ * Support PZF600PEX.
+ * Revision 1.46.2.38 2011/04/19 15:06:56 martin
+ * Fixed build error on bigendian target.
+ * Revision 1.46.2.37 2011/04/12 15:28:56 martin
+ * Use common mutex primitives from mbgmutex.h.
* Revision 1.46.2.36 2011/04/01 10:38:00 martin
* Modified mutex/spinlock initialization, and do deinitializaton.
* Fixed compiler warnings.
@@ -364,7 +397,11 @@
#if !defined( DEBUG_IO )
- #define DEBUG_IO ( defined( DEBUG ) && ( DEBUG >= DEBUG_LVL_IO ) )
+ #if defined( MBG_TGT_NETBSD )
+ #define DEBUG_IO ( defined( MBG_DEBUG ) && ( MBG_DEBUG >= DEBUG_LVL_IO ) )
+ #else
+ #define DEBUG_IO ( defined( DEBUG ) && ( DEBUG >= DEBUG_LVL_IO ) )
+ #endif
#endif
#if !defined( DEBUG_PORTS )
@@ -459,12 +496,14 @@ extern const char pcps_driver_name[];
static /*HDR*/
long mbg_delta_sys_time_ms( const MBG_SYS_TIME *t2, const MBG_SYS_TIME *t1 )
{
- #if defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD )
- long dt = ( t2->tv_sec - t1->tv_sec ) * 1000;
- #if USE_TIMESPEC
- dt += ( t2->tv_nsec - t1->tv_nsec ) / 1000000;
+ #if USE_GENERIC_SYS_TIME
+ long dt = ( t2->sec - t1->sec ) * 1000;
+ #if defined ( MBG_TGT_LINUX ) && defined( MBG_TGT_KERNEL )
+ int64_t tmp64 = t2->nsec - t1->nsec;
+ do_div( tmp64, 1000000 );
+ dt += tmp64;
#else
- dt += ( t2->tv_usec - t1->tv_usec ) / 1000;
+ dt += ( t2->nsec - t1->nsec ) / 1000000;
#endif
return dt;
#elif defined( MBG_TGT_WIN32 )
@@ -713,7 +752,7 @@ int pcps_wait_busy( PCPS_DDEV *pddev )
* pcps_read_usb()
*
* Purpose: These functions are used for low level access
- * to Meinberg plug-in radio clocks. The function
+ * to Meinberg plug-in devices. The function
* to be used depends on the clock's bus type and
* interface chip.
*
@@ -812,6 +851,9 @@ short pcps_read_amcc_s5933( PCPS_DDEV *pddev, uint8_t cmd,
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
_mbg_outp8( pddev, 0, port + AMCC_OP_REG_OMB1, cmd );
+ #if defined( MBG_ARCH_SPARC )
+ udelay( 3 );
+ #endif
_pcps_local_irq_restore();
// wait until BUSY flag goes low or timeout
@@ -828,7 +870,10 @@ short pcps_read_amcc_s5933( PCPS_DDEV *pddev, uint8_t cmd,
buffer[i] = _mbg_inp8( pddev, 0, port + AMCC_OP_REG_FIFO + ( i % sizeof( uint32_t) ) );
#if DEBUG_IO
- _mbgddmsg_1( MBG_DBG_DETAIL, "pcps_read_amcc_s5933: %02X", buffer[i] );
+ if ( ( cmd == PCPS_GIVE_FW_ID_1 ) || ( cmd == PCPS_GIVE_FW_ID_2 ) )
+ _mbgddmsg_2( MBG_DBG_DETAIL, "pcps_read_amcc_s5933: %02X '%c'", buffer[i], buffer[i] );
+ else
+ _mbgddmsg_1( MBG_DBG_DETAIL, "pcps_read_amcc_s5933: %02X", buffer[i] );
#endif
}
@@ -858,15 +903,18 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
#if DEBUG_IO
- _mbgddmsg_3( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: cmd %02X, port: %04lX, data_port: %04lX",
+ _mbgddmsg_5( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: cmd %02X, port: %04lX, data_port: %04lX, buffer: %p, count: %u",
cmd, (ulong) _pcps_ddev_io_base_mapped( pddev, 0 ) + AMCC_OP_REG_OMB,
- (ulong) data_port );
+ (ulong) data_port, buffer, count );
#endif
_pcps_disb_local_irq_save();
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
_mbg_outp8( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 ) + AMCC_OP_REG_OMB, cmd );
+ #if defined( MBG_ARCH_SPARC )
+ udelay( 3 );
+ #endif
_pcps_local_irq_restore();
dt_quot = count / 4;
@@ -888,9 +936,15 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
{
ul = _mbg_inp32_to_cpu( pddev, 1, data_port );
#if DEBUG_IO
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: %08X", ul );
+ if ( ( cmd == PCPS_GIVE_FW_ID_1 ) || ( cmd == PCPS_GIVE_FW_ID_2 ) )
+ {
+ _mbgddmsg_5( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: %08X \"%c%c%c%c\"", ul,
+ BYTE_OF( ul, 0 ), BYTE_OF( ul, 1 ), BYTE_OF( ul, 2 ), BYTE_OF( ul, 3 ) );
+ }
+ else
+ _mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: %08X", ul );
#endif
- _pcps_put_unaligned( ul, (uint32_t FAR *) p );
+ _mbg_put_unaligned( ul, (uint32_t FAR *) p );
p += sizeof( ul );
}
@@ -969,7 +1023,7 @@ short pcps_read_asic( PCPS_DDEV *pddev, uint8_t cmd,
#if DEBUG_IO
_mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_asic: %08X", ar.ul );
#endif
- _pcps_put_unaligned( ar.ul, (uint32_t FAR *) p );
+ _mbg_put_unaligned( ar.ul, (uint32_t FAR *) p );
p += sizeof( ar.ul );
data_port += sizeof( ar.ul );
}
@@ -1085,7 +1139,7 @@ short pcps_read_usb( PCPS_DDEV *pddev, uint8_t cmd,
/*--------------------------------------------------------------
* Name: pcps_write()
*
- * Purpose: Write data to the radio clock.
+ * Purpose: Write data to a device.
*
* Input: pddev pointer to the device information
* cmd the address of buffer holding the
@@ -1206,7 +1260,7 @@ done:
/*--------------------------------------------------------------
* Name: pcps_generic_io()
*
- * Purpose: Write data to the radio clock.
+ * Purpose: Write data to and/or read data from a device.
*
* Input: pddev pointer to the device information
* cmd the address of buffer holding the
@@ -1767,7 +1821,7 @@ int pcps_read_sernum( PCPS_DDEV *pddev )
// There are different ways to read the clock's S/N.
// Check which way is supported by the clock, and
- // read the S/N,
+ // read the S/N.
// The S/N is part of the RECEIVER_INFO structure. If this
@@ -1828,7 +1882,7 @@ int pcps_read_sernum( PCPS_DDEV *pddev )
goto fail;
}
- // The ident union must never be swapped due to endianess since we are
+ // The ident union must never be swapped due to endianess since we are
// using it only as an array of characters.
#if DEBUG_SERNUM
@@ -1866,8 +1920,8 @@ fail:
goto done;
#else
- // Remove trailing spaces which may unfortunately
- // be returned by some devices.
+ // Remove trailing spaces or 'F' characters which may
+ // unfortunately be returned by some devices.
for ( i = strlen( pddev->dev.cfg.sernum ); ; )
{
if ( i == 0 )
@@ -1875,8 +1929,8 @@ fail:
--i;
cp = &pddev->dev.cfg.sernum[i];
- if ( *cp > ' ' ) // not a trailing space, done
- break;
+ if ( ( *cp > ' ' ) && ( *cp != 'F' ) )
+ break; // done
*cp = 0;
}
@@ -1886,7 +1940,7 @@ fail:
fail:
- // No valid serial number has been found, though the device
+ // No valid serial number has been found, though the device
// should have one. In order to distinguish from devices which
// don't even support a serial number we return a number of '?'
// rather than "N/A".
@@ -2176,9 +2230,20 @@ PCPS_DDEV *pcps_alloc_ddev( void )
{
memset( pddev, 0, sizeof( *pddev ) );
- _pcps_mutex_init( &pddev->dev_mutex );
- _pcps_spin_lock_init( &pddev->mm_lock );
- _pcps_spin_lock_init( &pddev->irq_lock );
+ // If mutexes or spinlocks need to be destroyed on the target OS
+ // when the driver shuts down then they are initialized now and
+ // destroyed in the complementary function pcps_free_ddev().
+ // However, there are target OSs where those semaphores don't need
+ // to be destroyed, and sometimes even *must not* be initialized
+ // at this early point of driver initialization, e.g. under Windows,
+ // in which case the semaphores will be initialized later.
+ #if defined( _mbg_mutex_destroy )
+ _mbg_mutex_init( &pddev->dev_mutex );
+ #endif
+ #if defined( _mbg_spin_lock_destroy )
+ _mbg_spin_lock_init( &pddev->mm_lock );
+ _mbg_spin_lock_init( &pddev->irq_lock );
+ #endif
}
return pddev;
@@ -2190,25 +2255,25 @@ PCPS_DDEV *pcps_alloc_ddev( void )
/*HDR*/
void pcps_free_ddev( PCPS_DDEV *pddev )
{
- #if !_PCPS_STATIC_DEV_LIST
- if ( pddev )
- {
- _pcps_mutex_destroy( &pddev->dev_mutex );
- _pcps_spin_lock_destroy( &pddev->mm_lock );
- _pcps_spin_lock_destroy( &pddev->irq_lock );
+ if ( pddev )
+ {
+ #if defined( _mbg_mutex_destroy )
+ _mbg_mutex_destroy( &pddev->dev_mutex );
+ #endif
+ #if defined( _mbg_spin_lock_destroy )
+ _mbg_spin_lock_destroy( &pddev->mm_lock );
+ _mbg_spin_lock_destroy( &pddev->irq_lock );
+ #endif
+ #if !_PCPS_STATIC_DEV_LIST
_pcps_kfree( pddev, sizeof( *pddev ) );
- }
- #else
- _pcps_mutex_destroy( &pddev->dev_mutex );
- _pcps_spin_lock_destroy( &pddev->mm_lock );
- _pcps_spin_lock_destroy( &pddev->irq_lock );
-
- memset( pddev, 0, sizeof( *pddev ) );
+ #else
+ memset( pddev, 0, sizeof( *pddev ) );
- if ( n_ddevs )
- n_ddevs--;
- #endif
+ if ( n_ddevs )
+ n_ddevs--;
+ #endif
+ }
} // pcps_free_ddev
@@ -2419,14 +2484,34 @@ int pcps_start_device( PCPS_DDEV *pddev,
goto fail;
}
- // mutexes / spinlocks have already been initialized
- // when the *pddef has been allocated.
+
+ // If mutexes or spinlocks need to be destroyed on the target OS
+ // when the driver shuts down then they have already been initialized
+ // in the device allocation routine and will be destroyed in the
+ // complementary device deallocation routine.
+ // However, there are target OSs where those semaphores don't need
+ // to be destroyed, and sometimes even *must not* be initialized
+ // when the device structure is allocated (e.g under Windows),
+ // in which case the semaphores need to be initialized now.
+ #if !defined( _mbg_mutex_destroy )
+ #if defined( _mbg_mutex_init )
+ _mbg_mutex_init( &pddev->dev_mutex );
+ #endif
+ #endif
+ #if !defined( _mbg_spin_lock_destroy )
+ #if defined( _mbg_spin_lock_init )
+ _mbg_spin_lock_init( &pddev->mm_lock );
+ _mbg_spin_lock_init( &pddev->irq_lock );
+ #endif
+ #endif
+
switch ( _pcps_ddev_bus_flags( pddev ) )
{
#if _PCPS_USE_USB
case PCPS_BUS_USB:
- // No direct port I/O required.
+ case PCPS_BUS_USB_V2:
+ // No direct port I/O possible.
pddev->read = pcps_read_usb;
// In case of an USB device, do some additional
@@ -2546,6 +2631,20 @@ int pcps_start_device( PCPS_DDEV *pddev,
pddev->read = pcps_read_std;
break;
+ default:
+ #if defined( MBG_TGT_LINUX )
+ printk( KERN_ERR "%s: unhandled bus flags %04X for device %s\n",
+ pcps_driver_name, _pcps_ddev_bus_flags( pddev ), _pcps_ddev_type_name( pddev ) );
+ #elif defined( MBG_TGT_BSD )
+ printf( "%s: unhandled bus flags %04X for device %s\n",
+ pcps_driver_name, _pcps_ddev_bus_flags( pddev ), _pcps_ddev_type_name( pddev ) );
+ #elif defined( MBG_TGT_WIN32 )
+ swprintf( pddev->wcs_msg, L"unhandled bus flags %04X for device %S",
+ _pcps_ddev_bus_flags( pddev ), _pcps_ddev_type_name( pddev ) );
+ _evt_msg( GlbDriverObject, pddev->wcs_msg );
+ #endif
+ goto fail;
+
} // switch ( _pcps_ddev_bus_flags( pddev ) )
@@ -2940,6 +3039,36 @@ chip_setup_done:
pddev->dev.cfg.features = PCPS_FEAT_DCF600USB;
break;
+ case PCPS_TYPE_PZF180PEX:
+ pddev->dev.cfg.features = PCPS_FEAT_PZF180PEX;
+ break;
+
+ case PCPS_TYPE_TCR600USB:
+ pddev->dev.cfg.features = PCPS_FEAT_TCR600USB;
+ break;
+
+ case PCPS_TYPE_MSF600USB:
+ pddev->dev.cfg.features = PCPS_FEAT_MSF600USB;
+ break;
+
+ case PCPS_TYPE_WVB600USB:
+ pddev->dev.cfg.features = PCPS_FEAT_WVB600USB;
+ break;
+
+ default:
+ #if defined( MBG_TGT_LINUX )
+ printk( KERN_WARNING "%s: no feature detection for device %s\n",
+ pcps_driver_name, _pcps_ddev_type_name( pddev ) );
+ #elif defined( MBG_TGT_BSD )
+ printf( "%s: no feature detection for device %s\n",
+ pcps_driver_name, _pcps_ddev_type_name( pddev ) );
+ #elif defined( MBG_TGT_WIN32 )
+ swprintf( pddev->wcs_msg, L"no feature detection for device %S",
+ _pcps_ddev_type_name( pddev ) );
+ _evt_msg( GlbDriverObject, pddev->wcs_msg );
+ #endif
+ goto fail_with_cleanup;
+
} // switch
@@ -2949,9 +3078,16 @@ chip_setup_done:
if ( rc == MBG_SUCCESS )
{
- _mbg_swab_receiver_info( &rcvr_info );
+ _mbg_swab_receiver_info( &pddev->ri );
+ _mbgddmsg_1( MBG_DBG_INIT_DEV, "Successfully read receiver info from dev %X",
+ _pcps_ddev_dev_id( pddev ) );
+
goto check;
}
+
+ _mbgddmsg_1( MBG_DBG_INIT_DEV, "Failed to read receiver info from dev %X",
+ _pcps_ddev_dev_id( pddev ) );
+
}
_mbgddmsg_1( MBG_DBG_INIT_DEV, "Setting up default receiver info for dev %X",
@@ -3033,6 +3169,7 @@ check:
#if DEBUG_IO && defined( MBG_TGT_LINUX )
{
PCPS_TIME t = { 0 };
+ printk( KERN_INFO "reading current time as test:\n" );
rc = _pcps_read( pddev, PCPS_GIVE_TIME, &t, sizeof( t ) );
printk( KERN_INFO "read time, sz: %lu, returned %i\n", (ulong) sizeof( t ), rc );
printk( KERN_INFO " sec100 %02X, sec %02X, min %02X hour %02X\n",
@@ -3428,7 +3565,7 @@ void pcps_detect_isa_clocks( PCPS_DDEV_ALLOC_FNC alloc_fnc,
#if !_PCPS_USE_PNP
/*--------------------------------------------------------------
- * Try to detect any plug-in radio clock. If a DOS TSR is
+ * Try to detect any plug-in device. If a DOS TSR is
* installed, be sure it is disabled (BUSY flag set) when
* this function is called.
*-------------------------------------------------------------*/
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.h b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.h
index 42d7526..40983c6 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.h 1.41.1.23 2011/04/01 10:38:42 martin TRASH $
+ * $Id: pcpsdrvr.h 1.41.1.33 2011/07/06 11:23:09 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,28 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.h $
- * Revision 1.41.1.23 2011/04/01 10:38:42 martin
+ * Revision 1.41.1.33 2011/07/06 11:23:09 martin
+ * Added macros _pcps_ddev_has_corr_info() and _pcps_ddev_has_tr_distance().
+ * Revision 1.41.1.32 2011/07/04 10:29:44 martin
+ * Modified a comment.
+ * Revision 1.41.1.31 2011/06/29 14:01:32 martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Added support for TCR600USB, MSF600USB, and WVB600USB.
+ * New macros _pcps_ddev_is_usb_v2() and _pcps_ddev_has_pcf().
+ * Updated some comments.
+ * Revision 1.41.1.30 2011/06/29 09:10:27 martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Revision 1.41.1.29 2011/05/31 14:24:18 martin
+ * Revision 1.41.1.28 2011/05/16 16:39:20 martin
+ * Allocate non-paged memory under Windows.
+ * Revision 1.41.1.27 2011/05/06 13:47:40Z martin
+ * Support PZF600PEX.
+ * Revision 1.41.1.26 2011/04/12 15:50:57 martin
+ * Revision 1.41.1.25 2011/04/12 15:26:10Z martin
+ * Moved mutex definitions to new mbgmutex.h.
+ * Revision 1.41.1.24 2011/04/01 13:32:45 martin
+ * Added missing mutex destroy for Windows.
+ * Revision 1.41.1.23 2011/04/01 10:38:42Z martin
* Support mutex/spinlock destroy.
* Revision 1.41.1.22 2011/03/31 10:35:57 martin
* Fixed a typo.
@@ -378,8 +399,9 @@
/* Other headers to be included */
-#include <pci_asic.h>
#include <pcpsdev.h>
+#include <mbgmutex.h>
+#include <pci_asic.h>
#include <mbgerror.h>
#include <use_pack.h>
#include <mbggenio.h>
@@ -390,11 +412,9 @@
#include <sys/_null.h>
#include <sys/param.h>
#include <sys/lock.h>
- #include <sys/mutex.h>
#include <machine/bus.h>
#elif defined( MBG_TGT_NETBSD )
#include <sys/kmem.h>
- #include <sys/mutex.h>
#else
#include <stddef.h>
#endif
@@ -467,16 +487,7 @@
#define _pcps_kmalloc( _sz ) kmalloc( _sz, GFP_ATOMIC )
#define _pcps_kfree( _p, _sz ) kfree( _p )
- #define MBG_SPINLOCK spinlock_t
- #define _pcps_spin_lock_init( _spl ) spin_lock_init( _spl )
- #define _pcps_spin_lock_destroy( _spl ) _nop_macro_fnc()
- #define _pcps_spin_lock( _spl ) spin_lock( _spl )
- #define _pcps_spin_unlock( _spl ) spin_unlock( _spl )
-
- #define MBG_SYS_MUTEX struct semaphore
- #define _pcps_mutex_init( _pmtx ) sema_init( _pmtx, 1 )
- #define _pcps_mutex_destroy( _pmtx ) _nop_macro_fnc()
-
+ //##+++++++++++++++++++
// The special versions of _pcps_sem_inc() and _pcps_sem_dec() below
// are only required to prevent interference with the IRQ handler
// under Linux which implements the serial port emulation for the
@@ -485,7 +496,7 @@
{ \
ulong flags; \
\
- if ( down_interruptible( &(_pddev)->dev_mutex ) < 0 ) \
+ if ( _mbg_mutex_acquire( &(_pddev)->dev_mutex ) < 0 ) \
return -ERESTARTSYS; \
\
spin_lock_irqsave( &(_pddev)->irq_lock, flags ); \
@@ -495,7 +506,7 @@
#define _pcps_sem_dec( _pddev ) \
atomic_dec( &(_pddev)->access_in_progress ); \
- up( &(_pddev)->dev_mutex )
+ _mbg_mutex_release( &(_pddev)->dev_mutex )
#elif defined( MBG_TGT_FREEBSD )
@@ -507,18 +518,6 @@
#define _pcps_kmalloc( _sz ) malloc( _sz, M_MBGCLOCK, M_NOWAIT | M_ZERO )
#define _pcps_kfree( _p, _sv ) free( _p, M_MBGCLOCK )
- #define MBG_SPINLOCK struct mtx
- #define _pcps_spin_lock_init( _spl ) mtx_init( _spl, "mbgclock_spin", NULL, MTX_SPIN )
- #define _pcps_spin_lock_destroy( _spl ) mtx_destroy( _spl )
- #define _pcps_spin_lock( _spl ) mtx_lock_spin( _spl )
- #define _pcps_spin_unlock( _spl ) mtx_unlock_spin( _spl )
-
- #define MBG_SYS_MUTEX struct mtx
- #define _pcps_mutex_init( _pmtx ) mtx_init( _pmtx, "mbgclock_sema", NULL, MTX_DEF )
- #define _pcps_mutex_destroy( _pmtx ) mtx_destroy( _pmtx )
- #define _pcps_mutex_acquire( _pmtx ) mtx_lock( _pmtx )
- #define _pcps_mutex_release( _pmtx ) mtx_unlock( _pmtx )
-
#elif defined( MBG_TGT_NETBSD )
// For older NetBSD versions which do not suppport the calls
@@ -526,37 +525,11 @@
#define _pcps_kmalloc( _sz ) kmem_alloc( _sz, KM_NOSLEEP )
#define _pcps_kfree( _p, _sz ) kmem_free( _p, _sz )
- // The API used below has been introduced in NetBSD 5.0
- // For earlier NetBSD versions see 'man 9 lockinit'.
-
- #define MBG_SPINLOCK kmutex_t
- #define _pcps_spin_lock_init( _spl ) mutex_init( _spl, MUTEX_DEFAULT, IPL_HIGH )
- #define _pcps_spin_lock_destroy( _spl ) mutex_destroy( _spl )
- #define _pcps_spin_lock( _spl ) mutex_spin_enter( _spl )
- #define _pcps_spin_unlock( _spl ) mutex_spin_exit( _spl )
-
- #define MBG_SYS_MUTEX kmutex_t
- #define _pcps_mutex_init( _pmtx ) mutex_init( _pmtx, MUTEX_DEFAULT, IPL_NONE )
- #define _pcps_mutex_destroy( _spl ) mutex_destroy( _spl )
- #define _pcps_mutex_acquire( _pmtx ) mutex_enter( _pmtx )
- #define _pcps_mutex_release( _pmtx ) mutex_exit( _pmtx )
-
#elif defined( MBG_TGT_WIN32 )
- #define _pcps_kmalloc( _sz ) ExAllocatePool( PagedPool, _sz )
+ #define _pcps_kmalloc( _sz ) ExAllocatePool( NonPagedPool, _sz )
#define _pcps_kfree( _p, _sz ) ExFreePool( _p )
- #define MBG_SPINLOCK KSPIN_LOCK
- #define _pcps_spin_lock_init( _spl ) KeInitializeSpinLock( _spl )
- #define _pcps_spin_lock_destroy( _spl ) _nop_macro_fnc()
- #define _pcps_spin_lock( _spl ) KeAcquireSpinLockAtDpcLevel( _spl )
- #define _pcps_spin_unlock( _spl ) KeReleaseSpinLockFromDpcLevel( _spl )
-
- #define MBG_SYS_MUTEX FAST_MUTEX
- #define _pcps_mutex_init( _pmtx ) ExInitializeFastMutex( _pmtx )
- #define _pcps_mutex_acquire( _pmtx ) ExAcquireFastMutex( _pmtx )
- #define _pcps_mutex_release( _pmtx ) ExReleaseFastMutex( _pmtx )
-
#endif
@@ -572,33 +545,13 @@
// If the macros below have not yet been defined then define some dummies:
-#if !defined( MBG_SPINLOCK )
-
- #define _pcps_spin_lock_init( _spl ) _nop_macro_fnc()
- #define _pcps_spin_lock_destroy( _spl ) _nop_macro_fnc()
- #define _pcps_spin_lock( _spl ) _nop_macro_fnc()
- #define _pcps_spin_unlock( _spl ) _nop_macro_fnc()
-
-#endif
-
-
-#if !defined( MBG_SYS_MUTEX )
-
- #define _pcps_mutex_init( _pmtx ) _nop_macro_fnc()
- #define _pcps_mutex_destroy( _pmtx ) _nop_macro_fnc()
- #define _pcps_mutex_acquire( _pmtx ) _nop_macro_fnc()
- #define _pcps_mutex_release( _pmtx ) _nop_macro_fnc()
-
-#endif
-
-
#if !defined( _pcps_sem_inc ) || !defined( _pcps_sem_dec )
#define _pcps_sem_inc( _pddev ) \
- _pcps_mutex_acquire( &(_pddev)->dev_mutex )
+ _mbg_mutex_acquire( &(_pddev)->dev_mutex )
#define _pcps_sem_dec( _pddev ) \
- _pcps_mutex_release( &(_pddev)->dev_mutex )
+ _mbg_mutex_release( &(_pddev)->dev_mutex )
#endif
@@ -831,14 +784,14 @@ typedef struct PCPS_DDEV_s
MBG_PC_CYCLES acc_cycles;
- #if defined( MBG_SYS_MUTEX )
- MBG_SYS_MUTEX dev_mutex;
+ #if defined( _MBG_MUTEX_DEFINED )
+ MBG_MUTEX dev_mutex;
#endif
PCPS_MM_LAYOUT FAR *mm_addr;
volatile PCPS_TIME_STAMP FAR *mm_tstamp_addr;
- #if defined( MBG_SPINLOCK )
+ #if defined( _MBG_SPINLOCK_DEFINED )
MBG_SPINLOCK mm_lock;
MBG_SPINLOCK irq_lock;
#endif
@@ -961,7 +914,7 @@ typedef struct PCPS_DDEV_s
_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
{ PCPS_TYPE_PC31, "PC31", 0, PCPS_REF_DCF, PCPS_BUS_ISA },
{ PCPS_TYPE_PS31_OLD, "PS31", MCA_ID_PS31_OLD, PCPS_REF_DCF, PCPS_BUS_MCA },
{ PCPS_TYPE_PS31, "PS31", MCA_ID_PS31, PCPS_REF_DCF, PCPS_BUS_MCA },
@@ -990,7 +943,11 @@ _ext PCPS_DEV_TYPE pcps_dev_type[N_PCPS_DEV_TYPE]
{ PCPS_TYPE_WWVB51USB, "WWVB51USB", USB_DEV_WWVB51USB, PCPS_REF_WWVB, PCPS_BUS_USB },
{ PCPS_TYPE_GPS180PEX, "GPS180PEX", PCI_DEV_GPS180PEX, PCPS_REF_GPS, PCPS_BUS_PCI_MBGPEX },
{ PCPS_TYPE_TCR180PEX, "TCR180PEX", PCI_DEV_TCR180PEX, PCPS_REF_IRIG, PCPS_BUS_PCI_MBGPEX },
- { PCPS_TYPE_DCF600USB, "DCF600USB", USB_DEV_DCF600USB, PCPS_REF_DCF, PCPS_BUS_USB }
+ { PCPS_TYPE_DCF600USB, "DCF600USB", USB_DEV_DCF600USB, PCPS_REF_DCF, PCPS_BUS_USB_V2 },
+ { PCPS_TYPE_PZF180PEX, "PZF180PEX", PCI_DEV_PZF180PEX, PCPS_REF_DCF, PCPS_BUS_PCI_MBGPEX },
+ { PCPS_TYPE_TCR600USB, "TCR600USB", USB_DEV_TCR600USB, PCPS_REF_IRIG, PCPS_BUS_USB_V2 },
+ { PCPS_TYPE_MSF600USB, "MSF600USB", USB_DEV_MSF600USB, PCPS_REF_MSF, PCPS_BUS_USB_V2 },
+ { PCPS_TYPE_WVB600USB, "WVB600USB", USB_DEV_WVB600USB, PCPS_REF_WWVB, PCPS_BUS_USB_V2 }
// If a new device is added here, don't forget to add it also
// to the Windows .inf file of supported PCI an USB devices,
@@ -1035,9 +992,10 @@ _ext const char *fw_id_ref[]
"TCR", // TCR510PCI, TCR167PCI, TCR511PCI, TCR511PEX, TCR51USB, TCR170PEX, TCR180PEX
"PEX", // PEX511
"USB", // USB5131
- "MSF", // MSF51USB
- "WWVB", // WWVB51USB
+ "MSF", // MSF51USB, MSF600USB
+ "WWVB", // WWVB51USB, WVB600USB
"DCF", // DCF600USB
+ "PZF", // PZF180PEX
NULL
}
#endif
@@ -1076,6 +1034,7 @@ _ext const char *fw_id_ref[]
#define _pcps_ddev_is_mca( _p ) _pcps_is_mca( &(_p)->dev )
#define _pcps_ddev_is_pci( _p ) _pcps_is_pci( &(_p)->dev )
#define _pcps_ddev_is_usb( _p ) _pcps_is_usb( &(_p)->dev )
+#define _pcps_ddev_is_usb_v2( _p ) _pcps_is_usb_v2( &(_p)->dev )
#define _pcps_ddev_is_pci_s5933( _p ) _pcps_is_pci_s5933( &(_p)->dev )
#define _pcps_ddev_is_pci_s5920( _p ) _pcps_is_pci_s5920( &(_p)->dev )
@@ -1103,7 +1062,7 @@ _ext const char *fw_id_ref[]
#define _pcps_ddev_raw_asic_version( _p ) ( (_p)->raw_asic_version )
#define _pcps_ddev_asic_version( _p ) ( (_p)->asic_version )
-// The macros below handle the clock device's err_flags.
+// The macros below handle the device's err_flags.
#define _pcps_ddev_set_err_flags( _p, _msk ) \
_pcps_set_err_flags( &(_p)->dev, _msk )
@@ -1202,6 +1161,15 @@ _ext const char *fw_id_ref[]
#define _pcps_ddev_has_ptp_unicast( _p ) \
_pcps_has_ri_ptp_unicast( &(_p)->ri )
+#define _pcps_ddev_has_pzf( _p ) \
+ _pcps_has_pzf( &(_p)->dev )
+
+#define _pcps_ddev_has_corr_info( _p ) \
+ _pcps_has_corr_info( &(_p)->dev )
+
+#define _pcps_ddev_has_tr_distance( _p ) \
+ _pcps_has_tr_distance( &(_p)->dev )
+
// The macros below simplify read/write access to the clocks.
@@ -1212,14 +1180,14 @@ _ext const char *fw_id_ref[]
( (_pddev)->read( _pddev, (_cmd), (uchar FAR *)(_p), (_n) ) )
#endif
-// Write a byte _b to the radio clock device. This is typically
-// done by just writing the command byte from inside the read function.
+// Write a byte _b to a device. This is typically done by just writing
+// the command byte from inside the read function.
#if !defined( _pcps_write_byte )
#define _pcps_write_byte( _pddev, _b ) \
_pcps_read( (_pddev), (_b), NULL, 0 )
#endif
-// write a command plus the contents of a data buffer to the device.
+// write a command plus the contents of a data buffer to a device.
// This is typically implemented as a function which uses the
// _pcps_write_byte() macro repeatedly.
#if !defined( _pcps_write )
@@ -1244,13 +1212,13 @@ _ext const char *fw_id_ref[]
// The macros below simplify reading/writing typed variables by
// determining the size automatically from the type of the variable.
-// Read data from the radio clock board to variable _s.
+// Read data from a device to variable _s.
// The number of bytes to read is determined by the size
// of _s. The accepted type of _s depends on the _cmd code.
#define _pcps_read_var( _pddev, _cmd, _s ) \
_pcps_read( (_pddev), (_cmd), &(_s), sizeof( (_s) ) )
-// Write data from variable _s to the radio clock board .
+// Write data from variable _s to a device.
// The number of bytes to write is determined by the size
// of _s. The accepted type of _s depends on the _cmd code.
#define _pcps_write_var( _pddev, _cmd, _s ) \
@@ -1270,16 +1238,16 @@ _ext const char *fw_id_ref[]
_pcps_write_gps( (_pddev), (_cmd), &(_s), sizeof( (_s) ) )
-// Generate a hardware reset on the radio clock board. This
-// macro should be used VERY carefully and should be avoided
-// if possible.
+// Generate a hardware reset on a device. This macro should be used
+// VERY carefully and should be avoided, if possible, since resetting
+// a device could lock up the PC.
#define _pcps_force_reset( _pddev ) \
_pcps_write_byte( (_pddev), PCPS_FORCE_RESET )
-// The macro below reads a radio clock's status port which
-// includes the BUSY flag and the modulation signal of DCF77
-// clocks. The macro takes a (PCPS_DDEV *) as argument.
+// The macro below reads a device's status port which includes
+// the BUSY flag and the modulation signal of DCF77 receivers.
+// The macro takes a (PCPS_DDEV *) as argument.
#define _pcps_ddev_read_status_port( _d ) \
_mbg_inp8( (_d), 0, (_d)->status_port )
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/pcpsutil.c b/src/external/bsd/meinberg/dist/mbglib/common/pcpsutil.c
index e35ea25..0dcf53d 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/pcpsutil.c
+++ b/src/external/bsd/meinberg/dist/mbglib/common/pcpsutil.c
@@ -1,15 +1,17 @@
/**************************************************************************
*
- * $Id: pcpsutil.c 1.13 2009/03/09 13:39:45 martin REL_M $
+ * $Id: pcpsutil.c 1.14 2011/06/29 11:03:44 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
- * Utility functions used with programs for Meinberg radio clocks.
+ * Utility functions used with programs for Meinberg devices.
*
* -----------------------------------------------------------------------
* $Log: pcpsutil.c $
+ * Revision 1.14 2011/06/29 11:03:44 martin
+ * Updated a comment.
* Revision 1.13 2009/03/09 13:39:45 martin
* Made pcps_exp_year() an inline function.
* Revision 1.12 2008/12/10 19:59:48 martin
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/toolutil.c b/src/external/bsd/meinberg/dist/mbglib/common/toolutil.c
index 50a4ad8..717ed89 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/toolutil.c
+++ b/src/external/bsd/meinberg/dist/mbglib/common/toolutil.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: toolutil.c 1.3.2.1 2010/11/05 12:56:02 martin TEST $
+ * $Id: toolutil.c 1.3.2.6 2011/07/08 11:39:00 martin TRASH $
*
* Description:
* Common functions which can be used with Meinberg command line
@@ -9,6 +9,14 @@
*
* -----------------------------------------------------------------------
* $Log: toolutil.c $
+ * Revision 1.3.2.6 2011/07/08 11:39:00 martin
+ * Revision 1.3.2.5 2011/07/06 07:55:32 martin
+ * Revision 1.3.2.4 2011/07/05 15:35:56 martin
+ * Modified version handling.
+ * Revision 1.3.2.3 2011/07/05 14:36:47 martin
+ * New way to maintain version information.
+ * Revision 1.3.2.2 2011/06/27 13:02:11 martin
+ * Open device with O_RDWR flag.
* Revision 1.3.2.1 2010/11/05 12:56:02 martin
* Revision 1.3 2009/06/19 12:12:14 martin
* Added function mbg_print_hr_timestamp().
@@ -35,9 +43,38 @@
/*HDR*/
-void mbg_print_program_info( const char *pname, const char *pversion, const char *pcopyright )
+int mbg_program_info_str( char *s, size_t max_len, const char *pname,
+ int micro_version, int first_year, int last_year )
{
- printf( "\n%s %s %s\n\n", pname, pversion, pcopyright );
+ int n;
+
+ if ( last_year == 0 )
+ last_year = MBG_CURRENT_COPYRIGHT_YEAR;
+
+ n = snprintf( s, max_len, "%s v%i.%i.%i Copyright Meinberg ", pname,
+ MBG_MAJOR_VERSION_CODE, MBG_MINOR_VERSION_CODE, micro_version );
+
+ if ( first_year != last_year )
+ n += snprintf( &s[n], max_len - n, "%04i-", first_year );
+
+ n += snprintf( &s[n], max_len - n, "%04i", last_year );
+
+ return n;
+
+} // mbg_program_info_str
+
+
+
+/*HDR*/
+void mbg_print_program_info( const char *pname, int micro_version, int first_year, int last_year )
+{
+ char ws[256];
+ #if defined( MBG_MICRO_VERSION_CODE_DEV )
+ micro_version = MBG_MICRO_VERSION_CODE_DEV;
+ #endif
+ mbg_program_info_str( ws, sizeof( ws ), pname, micro_version, first_year, last_year );
+
+ printf( "\n%s\n\n", ws );
} // mbg_print_program_info
@@ -268,7 +305,7 @@ int mbg_check_devices( int argc, char *argv[], int optind, int (*fnc)( MBG_DEV_H
// shall be displayed.
const char *fn = ( num_devices > 1 ) ? argv[i] : NULL;
- dh = open( argv[i], 0 );
+ dh = open( argv[i], O_RDWR );
ret_val = mbg_check_device( dh, fn, fnc );
if ( ret_val )
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/toolutil.h b/src/external/bsd/meinberg/dist/mbglib/common/toolutil.h
index 7c69e84..cef7d44 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/toolutil.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/toolutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: toolutil.h 1.2 2009/06/19 12:11:35 martin REL_M $
+ * $Id: toolutil.h 1.2.1.2 2011/07/05 15:35:56 martin TRASH martin $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: toolutil.h $
+ * Revision 1.2.1.2 2011/07/05 15:35:56 martin
+ * Modified version handling.
+ * Revision 1.2.1.1 2011/07/05 14:36:42 martin
+ * New way to maintain version information.
* Revision 1.2 2009/06/19 12:11:35 martin
* Updated function prototypes.
* Revision 1.1 2008/12/17 10:45:14 martin
@@ -26,6 +30,7 @@
/* Other headers to be included */
#include <mbgdevio.h>
+#include <mbgversion.h>
@@ -52,19 +57,20 @@ extern "C" {
/* This section was generated automatically */
/* by MAKEHDR, do not remove the comments. */
-void mbg_print_program_info( const char *pname, const char *pversion, const char *pcopyright );
-void mbg_print_usage_intro( const char *pname, const char *info );
-void mbg_print_help_options( void );
-void mbg_print_opt_info( const char *opt_name, const char *opt_info );
-void mbg_print_device_options( void );
-void mbg_print_default_usage( const char *pname, const char *prog_info );
-int mbg_ioctl_err( int rc, const char *descr ) ;
-int mbg_get_show_dev_info( MBG_DEV_HANDLE dh, const char *dev_name, PCPS_DEV *p_dev );
-int mbg_check_device( MBG_DEV_HANDLE dh, const char *dev_name, int (*fnc)( MBG_DEV_HANDLE, const PCPS_DEV *) );
-int mbg_check_devices( int argc, char *argv[], int optind, int (*fnc)( MBG_DEV_HANDLE, const PCPS_DEV *) );
-int mbg_snprint_hr_tstamp( char *s, int len_s, const PCPS_TIME_STAMP *p );
-int mbg_snprint_hr_time( char *s, int len_s, const PCPS_HR_TIME *p );
-void mbg_print_hr_timestamp( PCPS_TIME_STAMP *p_ts, int32_t hns_latency, PCPS_TIME_STAMP *p_prv_ts, int raw );
+ int mbg_program_info_str( char *s, size_t max_len, const char *pname, int micro_version, int first_year, int last_year ) ;
+ void mbg_print_program_info( const char *pname, int micro_version, int first_year, int last_year ) ;
+ void mbg_print_usage_intro( const char *pname, const char *info ) ;
+ void mbg_print_help_options( void ) ;
+ void mbg_print_opt_info( const char *opt_name, const char *opt_info ) ;
+ void mbg_print_device_options( void ) ;
+ void mbg_print_default_usage( const char *pname, const char *prog_info ) ;
+ int mbg_ioctl_err( int rc, const char *descr ) ;
+ int mbg_get_show_dev_info( MBG_DEV_HANDLE dh, const char *dev_name, PCPS_DEV *p_dev ) ;
+ int mbg_check_device( MBG_DEV_HANDLE dh, const char *dev_name, int (*fnc)( MBG_DEV_HANDLE, const PCPS_DEV *) ) ;
+ int mbg_check_devices( int argc, char *argv[], int optind, int (*fnc)( MBG_DEV_HANDLE, const PCPS_DEV *) ) ;
+ int mbg_snprint_hr_tstamp( char *s, int len_s, const PCPS_TIME_STAMP *p ) ;
+ int mbg_snprint_hr_time( char *s, int len_s, const PCPS_HR_TIME *p ) ;
+ void mbg_print_hr_timestamp( PCPS_TIME_STAMP *p_ts, int32_t hns_latency, PCPS_TIME_STAMP *p_prv_ts, int raw ) ;
/* ----- function prototypes end ----- */
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/usbdefs.h b/src/external/bsd/meinberg/dist/mbglib/common/usbdefs.h
index d853118..30a39e2 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/usbdefs.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/usbdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: usbdefs.h 1.10 2010/11/11 09:16:33 martin REL_M $
+ * $Id: usbdefs.h 1.13 2011/06/29 14:11:23 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,14 @@
*
* -----------------------------------------------------------------------
* $Log: usbdefs.h $
- * Revision 1.10 2010/11/11 09:16:33 martin
+ * Revision 1.13 2011/06/29 14:11:23 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
+ * Revision 1.11 2011/04/13 07:59:11 daniel
+ * New class code and device id for external
+ * synchronization interface device.
+ * Revision 1.10 2010/11/11 09:16:33Z martin
* Added device ID for DCF600USB.
* Revision 1.9 2009/03/13 09:02:24 martin
* Removed definitions for timeout intervals.
@@ -66,6 +73,8 @@ enum
MBG_USB_CLASS_MSF, // MSF Radio Clock
MBG_USB_CLASS_WWVB, // WWVB Radio Clock
MBG_USB_CLASS_SCU, // Meinberg Signal Changeover Unit
+ MBG_USB_CLASS_ESI, // External Synchronization Interface
+ MBG_USB_CLASS_FCU, // Fan Control Unit
N_MBG_USB_CLASS // number of known device class codes
};
@@ -85,13 +94,20 @@ enum
#define USB_DEV_CMC ( ( MBG_USB_CLASS_CMC << 8 ) | 0x01 )
#define USB_DEV_TCR51USB ( ( MBG_USB_CLASS_TCR << 8 ) | 0x01 )
+#define USB_DEV_TCR600USB ( ( MBG_USB_CLASS_TCR << 8 ) | 0x02 )
#define USB_DEV_MSF51USB ( ( MBG_USB_CLASS_MSF << 8 ) | 0x01 )
+#define USB_DEV_MSF600USB ( ( MBG_USB_CLASS_MSF << 8 ) | 0x02 )
#define USB_DEV_WWVB51USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x01 )
+#define USB_DEV_WVB600USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x02 )
#define USB_DEV_SCU_USB ( ( MBG_USB_CLASS_SCU << 8 ) | 0x01 )
+#define USB_DEV_ESI_01 ( ( MBG_USB_CLASS_ESI << 8 ) | 0x01 )
+
+#define USB_DEV_FCU_01 ( ( MBG_USB_CLASS_FCU << 8 ) | 0x01 )
+
enum
{
MBGUSB_EP_IDX_HOST_IN, // transfers from device to host
diff --git a/src/external/bsd/meinberg/dist/mbglib/common/words.h b/src/external/bsd/meinberg/dist/mbglib/common/words.h
index a0b2127..ca272e1 100755
--- a/src/external/bsd/meinberg/dist/mbglib/common/words.h
+++ b/src/external/bsd/meinberg/dist/mbglib/common/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.25.1.3 2011/03/28 09:55:52 martin TRASH $
+ * $Id: words.h 1.26 2011/04/06 10:23:03 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,12 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
- * Revision 1.25.1.3 2011/03/28 09:55:52 martin
- * Modifications for NetBSD from Frank Kardel.
- * Revision 1.25.1.2 2011/03/22 09:41:32 martin
+ * Revision 1.26 2011/04/06 10:23:03 martin
* Added FBYTE_OF() and FWORD_OF() macros.
- * Revision 1.25.1.1 2011/01/25 08:25:49Z martin
- * Avoid build errors under FreeBSD.
+ * Modifications required for *BSD.
* Revision 1.25 2010/11/17 10:23:09 martin
* Define _BIT_REDEFINED if bit type is redefined.
* Revision 1.24 2010/11/17 08:44:56Z martin
@@ -139,9 +136,9 @@
#define _C99_BIT_TYPES_DEFINED 1
- //##++ a workaround for now to avoid inclusion of stdbool.h later
+ // avoid inclusion of stdbool.h later
#define bit int
- #define _BIT_DEFINED
+ #define _BIT_DEFINED 1
#elif defined( MBG_TGT_QNX ) // QNX 4.x or QNX 6.x
diff --git a/src/external/bsd/meinberg/dist/mbgsetsystime/mbgsetsystime.c b/src/external/bsd/meinberg/dist/mbgsetsystime/mbgsetsystime.c
index 6015f12..62b57ac 100755
--- a/src/external/bsd/meinberg/dist/mbgsetsystime/mbgsetsystime.c
+++ b/src/external/bsd/meinberg/dist/mbgsetsystime/mbgsetsystime.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsetsystime.c 1.8 2009/09/29 15:02:15 martin REL_M $
+ * $Id: mbgsetsystime.c 1.8.1.2 2011/07/05 15:35:55 martin TRASH martin $
*
* Description:
* Main file for mbgsetsystime program which reads the current date
@@ -14,6 +14,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsetsystime.c $
+ * Revision 1.8.1.2 2011/07/05 15:35:55 martin
+ * Modified version handling.
+ * Revision 1.8.1.1 2011/07/05 14:36:01 martin
+ * New way to maintain version information.
* Revision 1.8 2009/09/29 15:02:15 martin
* Updated version number to 3.4.0.
* Revision 1.7 2009/07/24 09:50:09 martin
@@ -52,10 +56,11 @@
#include <sys/types.h>
-static const char *pname = "mbgsetsystime";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2001-2009";
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+static const char *pname = "mbgsetsystime";
@@ -142,7 +147,7 @@ int main( int argc, char *argv[] )
int c;
int rc;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "h?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbgshowsignal/mbgshowsignal.c b/src/external/bsd/meinberg/dist/mbgshowsignal/mbgshowsignal.c
index 308fec8..d8f39c1 100755
--- a/src/external/bsd/meinberg/dist/mbgshowsignal/mbgshowsignal.c
+++ b/src/external/bsd/meinberg/dist/mbgshowsignal/mbgshowsignal.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgshowsignal.c 1.8 2009/09/29 15:02:15 martin REL_M $
+ * $Id: mbgshowsignal.c 1.8.1.3 2011/07/05 15:35:55 martin TRASH martin $
*
* Description:
* Main file for mbgshowsignal program which demonstrates how to
@@ -10,6 +10,12 @@
*
* -----------------------------------------------------------------------
* $Log: mbgshowsignal.c $
+ * Revision 1.8.1.3 2011/07/05 15:35:55 martin
+ * Modified version handling.
+ * Revision 1.8.1.2 2011/07/05 14:35:19 martin
+ * New way to maintain version information.
+ * Revision 1.8.1.1 2011/07/04 13:19:04 martin
+ * Update modulation status continuously.
* Revision 1.8 2009/09/29 15:02:15 martin
* Updated version number to 3.4.0.
* Revision 1.7 2009/07/24 09:50:09 martin
@@ -47,9 +53,11 @@
#include <time.h>
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbgshowsignal";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2001-2009";
@@ -58,7 +66,7 @@ int show_modulation( MBG_DEV_HANDLE dh )
{
static time_t prv_sys_t;
time_t sys_t;
- uchar status_port; // current value of the clock's status port
+ PCPS_STATUS_PORT status_port; // current value of the clock's status port
PCPS_TIME t;
int signal;
int rc = mbg_get_status_port( dh, &status_port ); // read status port
@@ -69,16 +77,15 @@ int show_modulation( MBG_DEV_HANDLE dh )
// show signal only once per second
sys_t = time( NULL );
- if ( sys_t == prv_sys_t )
- return 0;
-
- prv_sys_t = sys_t;
-
- rc = mbg_get_time( dh, &t );
+ if ( sys_t != prv_sys_t )
+ {
+ rc = mbg_get_time( dh, &t );
- if ( mbg_ioctl_err( rc, "mbg_get_time" ) )
- return -1;
+ if ( mbg_ioctl_err( rc, "mbg_get_time" ) )
+ return -1;
+ prv_sys_t = sys_t;
+ }
// The current value of the modulation (second mark) is returned
// in a single bit of the status port, so ignore the other bits.
@@ -151,7 +158,7 @@ int main( int argc, char *argv[] )
int c;
int rc;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "h?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbgstatus/Makefile b/src/external/bsd/meinberg/dist/mbgstatus/Makefile
index 3501003..3d86873 100755
--- a/src/external/bsd/meinberg/dist/mbgstatus/Makefile
+++ b/src/external/bsd/meinberg/dist/mbgstatus/Makefile
@@ -1,13 +1,17 @@
#########################################################################
#
-# $Id: Makefile 1.7.1.4 2010/08/30 09:05:24 martin TEST $
+# $Id: Makefile 1.7.1.4.1.2 2011/04/20 09:34:06 martin TRASH $
#
# Description:
# Makefile for mbgstatus.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.7.1.4.1.2 2011/04/20 09:34:06 martin
+# Added module lan_util.
+# Revision 1.7.1.4.1.1 2010/09/20 12:07:06 stefan
+# Updated for use with latest base Makefile.
# Revision 1.7.1.4 2010/08/30 09:05:24 martin
# Revision 1.7.1.3 2010/08/30 08:20:32 martin
# Revision 1.7.1.2 2010/08/24 08:35:11 martin
@@ -32,7 +36,7 @@
#########################################################################
TARGET = mbgstatus
-INST_DIR = /usr/local/bin
+INST_TO_BIN = 1
OBJS := $(TARGET).o
OBJS += mbgdevio.o
@@ -45,6 +49,7 @@ OBJS += parmpcps.o
OBJS += parmgps.o
OBJS += ctrydttm.o
OBJS += ctry.o
+OBJS += lan_util.o
BASEDIR := ..
include $(BASEDIR)/Makefile
diff --git a/src/external/bsd/meinberg/dist/mbgstatus/mbgstatus.c b/src/external/bsd/meinberg/dist/mbgstatus/mbgstatus.c
index 2409c5c..5517eb6 100755
--- a/src/external/bsd/meinberg/dist/mbgstatus/mbgstatus.c
+++ b/src/external/bsd/meinberg/dist/mbgstatus/mbgstatus.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgstatus.c 1.13.1.8 2011/03/03 10:01:23 daniel TRASH $
+ * $Id: mbgstatus.c 1.13.1.12 2011/07/08 11:02:47 martin TRASH $
*
* Description:
* Main file for mbgstatus program which demonstrates how to
@@ -10,6 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: mbgstatus.c $
+ * Revision 1.13.1.12 2011/07/08 11:02:47 martin
+ * Revision 1.13.1.11 2011/07/05 15:35:55 martin
+ * Modified version handling.
+ * Revision 1.13.1.10 2011/07/05 14:35:19 martin
+ * New way to maintain version information.
+ * Revision 1.13.1.9 2011/04/20 16:08:27 martin
+ * Use snprint_ip4_addr() from module lan_util.
* Revision 1.13.1.8 2011/03/03 10:01:23 daniel
* Indicate Unicast role in PTP port state
* Revision 1.13.1.7 2011/02/07 12:10:58 martin
@@ -76,7 +83,7 @@
#include <pcpslstr.h>
#include <pcpsutil.h>
#include <toolutil.h> // common utility functions
-
+#include <lan_util.h>
// include system headers
#include <stdio.h>
@@ -84,9 +91,12 @@
#include <unistd.h>
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2001
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use current year by default
+
static const char *pname = "mbgstatus";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2001-2009";
+
static unsigned int verbose;
@@ -177,24 +187,6 @@ void print_position( const char *s, const POS *p, const char *tail )
-/*HDR*/
-int snprint_ip4_addr( char *s, size_t max_len, const IP4_ADDR *addr )
-{
- int n;
-
- n = snprintf( s, max_len, "%i.%i.%i.%i",
- BYTE_OF( *addr, 3 ),
- BYTE_OF( *addr, 2 ),
- BYTE_OF( *addr, 1 ),
- BYTE_OF( *addr, 0 )
- );
-
- return n;
-
-} // snprint_ip4_addr
-
-
-
static /*HDR*/
void show_time_and_status( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, const char *tail )
{
@@ -581,17 +573,17 @@ void show_lan_intf_state( MBG_DEV_HANDLE dh )
);
printf( " MAC Address: %s\n", ws );
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.ip_addr );
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.ip_addr, NULL );
printf( " IP Address: %s%s\n", ws, ( ip4_settings.flags & IP4_MSK_DHCP ) ?
" (DHCP)" : "" );
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.netmask );
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.netmask, NULL );
printf( " Net Mask: %s\n", ws );
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.broad_addr );
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.broad_addr, NULL );
printf( " Broadcast Addr: %s\n", ws );
- snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.gateway );
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4_settings.gateway, NULL );
printf( " Gateway: %s\n", ws );
printf( " Link detected: %s\n", ( ip4_settings.flags & IP4_MSK_LINK ) ? "YES" : "NO" );
@@ -629,13 +621,14 @@ void show_ptp_state( MBG_DEV_HANDLE dh )
cp = ptp_state_available ? ws : str_not_avail;
+//##++++++++++
snprintf( ws, sizeof( ws ), "%02X-%02X-%02X-%02X-%02X-%02X",
- ptp_state.gm_identity.b[0],
- ptp_state.gm_identity.b[1],
- ptp_state.gm_identity.b[2],
- ptp_state.gm_identity.b[5],
- ptp_state.gm_identity.b[6],
- ptp_state.gm_identity.b[7]
+ ptp_state.gm_id.b[0],
+ ptp_state.gm_id.b[1],
+ ptp_state.gm_id.b[2],
+ ptp_state.gm_id.b[5],
+ ptp_state.gm_id.b[6],
+ ptp_state.gm_id.b[7]
);
printf( " Grandmaster MAC: %s\n", cp );
@@ -778,7 +771,7 @@ int main( int argc, char *argv[] )
ctry.dt_fmt = DT_FMT_YYYYMMDD;
ctry.dt_sep = '-';
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "vh?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/dist/mbgsvcd/Makefile b/src/external/bsd/meinberg/dist/mbgsvcd/Makefile
index d8a8fe8..1e940ae 100755
--- a/src/external/bsd/meinberg/dist/mbgsvcd/Makefile
+++ b/src/external/bsd/meinberg/dist/mbgsvcd/Makefile
@@ -1,13 +1,15 @@
#########################################################################
#
-# $Id: Makefile 1.1.1.2.1.1 2010/09/20 12:07:10 stefan TEST $
+# $Id: Makefile 1.1.1.2.1.2 2011/06/16 10:44:42 martin TRASH $
#
# Description:
# Makefile for mbgsvcd.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.1.1.2.1.2 2011/06/16 10:44:42 martin
+# Install mbgsvcd to sbin.
# Revision 1.1.1.2.1.1 2010/09/20 12:07:10 stefan
# Updated for use with latest base Makefile.
# Revision 1.1.1.2 2010/08/30 09:05:24 martin
@@ -18,7 +20,7 @@
#########################################################################
TARGET = mbgsvcd
-INST_TO_BIN = 1
+INST_TO_SBIN = 1
OBJS = $(TARGET).o
OBJS += mbgdevio.o
diff --git a/src/external/bsd/meinberg/dist/mbgsvcd/mbgsvcd.c b/src/external/bsd/meinberg/dist/mbgsvcd/mbgsvcd.c
index 1a4921e..af0dcab 100755
--- a/src/external/bsd/meinberg/dist/mbgsvcd/mbgsvcd.c
+++ b/src/external/bsd/meinberg/dist/mbgsvcd/mbgsvcd.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsvcd.c 1.3.1.3 2011/03/25 11:05:24 martin TRASH $
+ * $Id: mbgsvcd.c 1.3.1.10 2011/07/14 13:30:57 martin TRASH $
*
* Description:
* Main file for mbgsvcd which compares the system time to a PCI card's
@@ -9,6 +9,22 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsvcd.c $
+ * Revision 1.3.1.10 2011/07/14 13:30:57 martin
+ * Code cleanup.
+ * Eliminated some potential warnings due to ignored function return values.
+ * Revision 1.3.1.9 2011/07/05 15:35:55 martin
+ * Modified version handling.
+ * Revision 1.3.1.8 2011/07/05 14:35:19 martin
+ * New way to maintain version information.
+ * Revision 1.3.1.7 2011/06/23 15:35:40 martin
+ * Skip devices which don't support HR time immediately at startup.
+ * Revision 1.3.1.6 2011/06/23 15:02:55 martin
+ * Compute execution time limit in cycles instead of us so this can also
+ * be done if the cycle counter clock rate can not be determined.
+ * Revision 1.3.1.5 2011/06/23 12:45:37 martin
+ * Workaround in case cycle frequency can not be determined.
+ * Revision 1.3.1.4 2011/06/20 15:10:22 martin
+ * Using generic MBG_SYS_TIME with nanosecond resolution.
* Revision 1.3.1.3 2011/03/25 11:05:24 martin
* Optionally support timespec for sys time.
* Cleanup.
@@ -56,16 +72,50 @@
#define RUNNING_DIR "/var/run"
#define LOCK_FILE "mbgsvcd.pid"
-#define EXEC_TIME_SAMPLES 20
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2011 //##++++ 20101
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
static const char *pname = "mbgsvcd";
-static const char *pversion = "v1.2";
-static const char *pcopyright = "(c) Meinberg 2010-2011";
static int sleep_intv = 1;
static int pretend_sync;
+
+#define MAX_FILTER_ENTRIES 32
+
+typedef struct
+{
+ MBG_PC_CYCLES cyc[MAX_FILTER_ENTRIES];
+ MBG_PC_CYCLES sum;
+ int entries;
+ int index;
+} FILTER;
+
+static FILTER filter;
+
+
+/*HDR*/ static
+MBG_PC_CYCLES do_filter( FILTER *p, MBG_PC_CYCLES cyc )
+{
+ if ( p->entries < MAX_FILTER_ENTRIES )
+ p->entries++;
+
+ if ( ++( p->index ) >= MAX_FILTER_ENTRIES )
+ p->index = 0;
+
+ // update the sum of filter entries
+ p->sum -= p->cyc[p->index]; // subtract oldest sample
+ p->cyc[p->index] = cyc; // save new sample
+ p->sum += cyc; // add new sample
+
+ return p->sum / p->entries; // return mean value
+
+} /* do_filter */
+
+
+
struct shmTime {
int mode; /* 0 - if valid set
* use values,
@@ -172,40 +222,65 @@ int do_mbgsvctasks( void )
double d_ref;
double d_sys;
int rc = 0;
- int n_devices = 0;
- MBG_DEV_HANDLE dhs[4];
- PCPS_DEV devs[4];
- int i,excnt;
- double exec_limit = 30.0;
- double exec_times[EXEC_TIME_SAMPLES];
+ int n_devices_found;
+ int n_devices;
+ MBG_DEV_HANDLE dhs[MAX_SHM_REFCLOCKS];
+ PCPS_DEV devs[MAX_SHM_REFCLOCKS];
+ int i;
+
+ n_devices_found = mbg_find_devices();
- n_devices = mbg_find_devices();
+ for ( i = 0, n_devices = 0; i < n_devices_found; i++ )
+ {
+ MBG_DEV_HANDLE dh = mbg_open_device( i );
+ PCPS_DEV dev_info;
+
+ rc = mbg_get_device_info( dh, &dev_info );
+
+ if ( rc < 0 )
+ {
+ printf( "Failed to read device info from device #%i.\n", i );
+ mbg_close_device( &dh );
+ continue;
+ }
+
+ if ( !_pcps_has_hr_time( &dev_info ) )
+ {
+ printf( "Device %s does not support HR time stamps.\n",
+ _pcps_type_name( &dev_info ) );
+ mbg_close_device( &dh );
+ continue;
+ }
- i = excnt = 0;
+ dhs[n_devices] = dh;
+ devs[n_devices] = dev_info;
+
+ if ( ++n_devices >= MAX_SHM_REFCLOCKS )
+ break;
+ }
if ( n_devices == 0 )
{
- printf("No devices found!\n");
+ printf( "No usable devices found!\n" );
goto done;
}
+
// Search for devices up to the maximum of supported NTP SHM refclocks
if ( n_devices > MAX_SHM_REFCLOCKS )
n_devices = MAX_SHM_REFCLOCKS;
- syslog(LOG_INFO, "Found %d devices for NTPD", n_devices);
-
- for ( i = 0; i < n_devices; i++ )
- {
- dhs[i] = mbg_open_device(i);
- mbg_get_device_info( dhs[i], &devs[i] );
- }
+ syslog( LOG_INFO, "Found %d devices usable for the NTP daemon", n_devices ); //##++++
rc = mbg_get_default_cycles_frequency_from_dev( dhs[0], &cyc_freq );
if ( mbg_ioctl_err( rc, "mbg_get_default_cycles_frequency_from_dev" ) )
goto done;
+
+ if ( cyc_freq == 0 )
+ printf( "*** Warning: " );
+
printf( "PC cycles counter clock frequency: %Lu Hz\n",
(unsigned long long) cyc_freq );
@@ -217,22 +292,14 @@ int do_mbgsvctasks( void )
{
for ( i = 0; i < n_devices; i++ )
{
- double ltcy_us;
- double exec_us;
double ltcy_sec;
- double exec_sec;
double d_ref_comp;
MBG_PC_CYCLES ltcy_cyc;
MBG_PC_CYCLES exec_cyc;
+ MBG_PC_CYCLES exec_cyc_limit;
+ MBG_PC_CYCLES tmp;
const char *cp;
- if ( !_pcps_has_hr_time( &devs[i] ) )
- {
- printf( "This device does not support HR time stamps.\n" );
- continue;
- }
-
-
rc = mbg_get_time_info_hrt( dhs[i], &hrti );
if ( mbg_ioctl_err( rc, "mbg_get_time_info_..." ) )
@@ -244,48 +311,35 @@ int do_mbgsvctasks( void )
p_sys_tic = &hrti.sys_time_cycles;
d_ref = (double) p_ref_ts->sec + ( (double) p_ref_ts->frac ) / (double) PCPS_HRT_BIN_FRAC_SCALE;
-
- d_sys = (double) p_sys_tic->sys_time.tv_sec;
- #if USE_TIMESPEC // use struct timespec
- d_sys += (double) p_sys_tic->sys_time.tv_nsec / 1e9;
- #else // use struct timeval
- d_sys += (double) p_sys_tic->sys_time.tv_usec / 1e6;
- #endif
+ d_sys = (double) p_sys_tic->sys_time.sec + (double) p_sys_tic->sys_time.nsec / 1e9;
ltcy_cyc = mbg_delta_pc_cycles( p_ref_cyc, &p_sys_tic->cyc_after );
exec_cyc = mbg_delta_pc_cycles( &p_sys_tic->cyc_after, &p_sys_tic->cyc_before );
- ltcy_sec = ( (double) ltcy_cyc ) / (double) cyc_freq;
- exec_sec = ( (double) exec_cyc ) / (double) cyc_freq;
+ ltcy_sec = cyc_freq ? ( ( (double) ltcy_cyc ) / (double) cyc_freq ) : 0.0;
- // compensate latencies between time stamps ->
+ // Compensate latencies between time stamps ->
// normalize ref time to system time stamp
d_ref_comp = d_ref - ltcy_sec;
- ltcy_us = ltcy_sec * 1e6;
- exec_us = exec_sec * 1e6;
-
- exec_times[excnt++] = exec_us;
+ exec_cyc_limit = do_filter( &filter, exec_cyc );
- if ( excnt == EXEC_TIME_SAMPLES )
- {
- exec_limit = 0;
-
- for ( excnt = 0; excnt < EXEC_TIME_SAMPLES; excnt++ )
- exec_limit += exec_times[excnt];
+ // Try to set the limit to 1.7 of the mean execution cycles.
+ tmp = ( 7 * exec_cyc_limit ) / 10;
- exec_limit /= ( (double) EXEC_TIME_SAMPLES );
- exec_limit *= 1.7;
- excnt = 0;
- }
+ // If execution takes only a few cycles make sure the limit
+ // is above the mean number of cycles.
+ if ( tmp == 0 )
+ tmp++;
+ exec_cyc_limit += tmp;
cp = "";
// check if refclock is sync and if exec time of the system time call was fast enough
- if ( pretend_sync || ( ( ( hrti.ref_hr_time_cycles.t.status & PCPS_FREER ) == 0 )
- && ( ( hrti.ref_hr_time_cycles.t.status & PCPS_SYNCD ) != 0 )
- && ( exec_us < exec_limit ) ) )
+ if ( ( exec_cyc <= exec_cyc_limit ) && ( pretend_sync || (
+ ( ( hrti.ref_hr_time_cycles.t.status & PCPS_FREER ) == 0 ) &&
+ ( ( hrti.ref_hr_time_cycles.t.status & PCPS_SYNCD ) != 0 ) ) ) )
{
struct shmTime *p = shmTime[i];
@@ -295,25 +349,24 @@ int do_mbgsvctasks( void )
p->count++;
p->clockTimeStampSec = (time_t) d_ref_comp;
p->clockTimeStampUSec = (int) ( ( d_ref_comp - p->clockTimeStampSec ) * 1e6 ); // get µs from d_ref
- p->receiveTimeStampSec = (time_t) p_sys_tic->sys_time.tv_sec;
- #if USE_TIMESPEC // use struct timespec
- p->receiveTimeStampUSec = (int) ( p_sys_tic->sys_time.tv_nsec / 1000 );
- #else // use struct timeval
- p->receiveTimeStampUSec = (int) p_sys_tic->sys_time.tv_usec;
- #endif
+ p->receiveTimeStampSec = (time_t) p_sys_tic->sys_time.sec;
+ p->receiveTimeStampUSec = (int) ( p_sys_tic->sys_time.nsec / 1000 );
// patch precision value according to the ref time accuracy
if ( _pcps_is_lwr( &devs[i] ) )
p->precision = -8;
- else if (_pcps_is_irig_rx( &devs[i] ) )
+ else
{
- if ( _pcps_is_usb( &devs[i] ) )
- p->precision = -10;
+ if ( _pcps_is_irig_rx( &devs[i] ) )
+ {
+ if ( _pcps_is_usb( &devs[i] ) )
+ p->precision = -10;
+ else
+ p->precision = -18;
+ }
else
- p->precision = -18;
+ p->precision = -20;
}
- else
- p->precision = -20;
p->count++;
p->valid = 1;
@@ -321,16 +374,32 @@ int do_mbgsvctasks( void )
mbg_snprint_hr_tstamp( ws, sizeof( ws ), p_ref_ts );
- printf( "%-9s: %s: %.7f-%.7f: %+.7f %+.7f, "
- "ltcy: %.2f us, exec: %.2f us, limit: %.2f us%s\n",
+ printf( "%-9s: %s: %.7f-%.7f: %+.7f %+.7f, ltcy: ",
_pcps_type_name( &devs[i] ), ws, d_ref, d_sys,
- d_ref - d_sys, d_ref_comp - d_sys,
- ltcy_us, exec_us, exec_limit, cp );
+ d_ref - d_sys, d_ref_comp - d_sys );
+
+ if ( cyc_freq != 0 ) // print latency and execution time in microseconds
+ {
+ double exec_sec = (double) exec_cyc / (double) cyc_freq;
+ double exec_sec_limit = (double) exec_cyc_limit / (double) cyc_freq;
+
+ printf( "%.2f us, exec: %.2f us, limit: %.2f us",
+ ltcy_sec * 1e6, exec_sec * 1e6, exec_sec_limit * 1e6 );
+ }
+ else // print latency and execution time in cycles only
+ {
+ printf( "%lli cyc, exec: %lli cyc, limit: %lli cyc",
+ (long long) ltcy_cyc, (long long) exec_cyc,
+ (long long) exec_cyc_limit );
+ }
+
+ printf( "%s\n", cp );
usleep( 10 );
}
- printf("\n");
+ if ( n_devices > 1 )
+ printf("\n");
if ( sleep_intv )
sleep( sleep_intv );
@@ -350,10 +419,12 @@ static /*HDR*/
void usage( void )
{
mbg_print_usage_intro( pname,
- "This deamon reads a time stamp from every refclock together.\n"
- "with an associated system time stamp and transfers it to the SHM\n"
- "refclock driver of NTP.\n"
- "This works only with cards which support high resolution time stamps."
+ "This program periodically reads a reference time stamp and an associated\n"
+ "system time stamp from every mbgclock device, and feeds the time stamp pairs\n"
+ "to the NTP daemon's shared memory refclock driver.\n"
+ "It usually runs as daemon but can also be run in the foreground to monitor the\n"
+ "time stamps and offsets.\n"
+ "This works only for cards supporting high resolution time stamps.\n"
);
mbg_print_help_options();
mbg_print_opt_info( "-f", "run program in foreground" );
@@ -369,51 +440,58 @@ void usage( void )
static /*HDR*/
void startup_daemon( void )
{
- int i,lfp;
+ int i;
+ int lfp;
+ int rc;
char str[1024];
- if (getppid()==1)
+ if ( getppid() == 1 )
return; /* already a daemon */
- printf ("Daemon mode, backgrounding ... \n");
- i=fork();
+ printf( "Daemon mode, backgrounding ... \n" );
+ i = fork();
- if (i<0)
- exit(1); /* fork error */
+ if ( i < 0 )
+ exit( 1 ); /* fork error */
+
+ if ( i > 0 )
+ exit( 0 ); /* parent exits */
- if (i>0)
- exit(0); /* parent exits */
/* child (daemon) continues */
setsid(); /* obtain a new process group */
- for (i=getdtablesize(); i>=0; --i)
- close(i); /* close all descriptors */
- i=open("/dev/null",O_RDWR); dup(i); dup(i); /* handle standart I/O */
+ for ( i = getdtablesize(); i >= 0; --i )
+ close( i ); /* close all descriptors */
+
+ /* handle standard I/O */
+ i = open( "/dev/null", O_RDWR );
+ rc = dup( i );
+ rc = dup( i );
- umask(027); /* set newly created file permissions */
- chdir(RUNNING_DIR); /* change running directory */
+ umask( 027 ); /* set newly created file permissions */
+ rc = chdir( RUNNING_DIR ); /* change running directory */
- lfp = open(LOCK_FILE,O_RDWR|O_CREAT,0640);
+ lfp = open( LOCK_FILE, O_RDWR | O_CREAT, 0640 );
- if (lfp<0)
- exit(1); /* can not open */
+ if ( lfp < 0 )
+ exit( 1 ); /* unable to open lock file */
- if (lockf(lfp,F_TLOCK,0)<0)
+ if ( lockf( lfp, F_TLOCK, 0 ) < 0 )
{
- syslog(LOG_ERR, "Lock file already exists, another instance of this daemon seems to be running");
+ syslog( LOG_ERR, "Lock file already exists, another instance of this daemon seems to be running" );
closelog();
- exit(0); /* can not lock */
+ exit( 0 ); /* can not lock */
}
/* first instance continues */
- sprintf(str,"%d\n",getpid());
- write(lfp,str,strlen(str)); /* record pid to lockfile */
+ snprintf( str, sizeof( str ), "%d\n", getpid() );
+ rc = write( lfp, str, strlen( str ) ); /* record pid to lockfile */
- signal(SIGCHLD,SIG_IGN); /* ignore child */
- signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
- signal(SIGTTOU,SIG_IGN);
- signal(SIGTTIN,SIG_IGN);
+ signal( SIGCHLD, SIG_IGN ); /* ignore child */
+ signal( SIGTSTP, SIG_IGN ); /* ignore tty signals */
+ signal( SIGTTOU, SIG_IGN );
+ signal( SIGTTIN, SIG_IGN );
} // startup_daemon
@@ -425,11 +503,7 @@ int main( int argc, char *argv[] )
int c;
int foreground = 0;
- mbg_print_program_info( pname, pversion, pcopyright );
-
- #if ( USE_TIMESPEC )
- printf( "(using nanosecond resolution)\n\n" );
- #endif
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "fps:h?" ) ) != -1 )
@@ -462,9 +536,16 @@ int main( int argc, char *argv[] )
}
if ( foreground == 0 )
- startup_daemon();
+ {
+ char ws[256];
+
+ mbg_program_info_str( ws, sizeof( ws ), pname, MBG_MICRO_VERSION,
+ MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
- syslog( LOG_INFO, "Starting Meinberg Service Daemon %s %s %s", pname, pversion, pcopyright );
+ syslog( LOG_INFO, "Starting Meinberg Service Daemon %s", ws );
+
+ startup_daemon();
+ }
rc = do_mbgsvctasks();
diff --git a/src/external/bsd/meinberg/dist/mbgversion.h b/src/external/bsd/meinberg/dist/mbgversion.h
new file mode 100755
index 0000000..a3a3300
--- /dev/null
+++ b/src/external/bsd/meinberg/dist/mbgversion.h
@@ -0,0 +1,33 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgversion.h 1.1 2011/07/08 12:09:55 martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Program version definitions for package mbgtools-nbsd.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgversion.h $
+ * Revision 1.1 2011/07/08 12:09:55 martin
+ * Initial revision for pre-release.
+ *
+ **************************************************************************/
+
+#define MBG_CURRENT_COPYRIGHT_YEAR 2011
+#define MBG_CURRENT_COPYRIGHT_YEAR_STR "2011"
+
+#define MBG_MAJOR_VERSION_CODE 0
+#define MBG_MINOR_VERSION_CODE 9
+
+#define MBG_MAIN_VERSION_STR "0.9"
+
+// The codes below should only fe defined in development/pre-release versions
+#define MBG_MICRO_VERSION_CODE_DEV 99
+#define MBG_MICRO_VERSION_STR_DEV "99"
+
+
+#define MBG_MAIN_VERSION_CODE ( ( MBG_MAJOR_VERSION_CODE << 8 ) | MBG_MINOR_VERSION_CODE )
+
+#define MBG_VERSION_CODE( _micro ) ( (uint16_t) ( ( MBG_MAIN_VERSION_CODE << 8 ) | (_micro) ) )
diff --git a/src/external/bsd/meinberg/dist/mbgxhrtime/mbgxhrtime.c b/src/external/bsd/meinberg/dist/mbgxhrtime/mbgxhrtime.c
index bceb331..af26ece 100755
--- a/src/external/bsd/meinberg/dist/mbgxhrtime/mbgxhrtime.c
+++ b/src/external/bsd/meinberg/dist/mbgxhrtime/mbgxhrtime.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgxhrtime.c 1.5 2009/09/29 14:25:07 martin REL_M $
+ * $Id: mbgxhrtime.c 1.5.1.2 2011/07/05 15:35:56 martin TRASH martin $
*
* Description:
* Main file for mbgxhrtime program which demonstrates how to retrieve
@@ -41,6 +41,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgxhrtime.c $
+ * Revision 1.5.1.2 2011/07/05 15:35:56 martin
+ * Modified version handling.
+ * Revision 1.5.1.1 2011/07/05 14:36:11 martin
+ * New way to maintain version information.
* Revision 1.5 2009/09/29 14:25:07 martin
* Display measured and default PC cycles frequency.
* Updated version number to 3.4.0.
@@ -79,9 +83,12 @@
#endif
+#define MBG_MICRO_VERSION 0
+#define MBG_FIRST_COPYRIGHT_YEAR 2008
+#define MBG_LAST_COPYRIGHT_YEAR 0 // use default
+
static const char *pname = "mbgxhrtime";
-static const char *pversion = "v3.4.0";
-static const char *pcopyright = "(c) Meinberg 2008-2009";
+
static int loops;
@@ -290,7 +297,7 @@ int main( int argc, char *argv[] )
int rc;
int c;
- mbg_print_program_info( pname, pversion, pcopyright );
+ mbg_print_program_info( pname, MBG_MICRO_VERSION, MBG_FIRST_COPYRIGHT_YEAR, MBG_LAST_COPYRIGHT_YEAR );
// check command line parameters
while ( ( c = getopt( argc, argv, "cn:h?" ) ) != -1 )
diff --git a/src/external/bsd/meinberg/mbgclock/Makefile b/src/external/bsd/meinberg/mbgclock/Makefile
deleted file mode 100755
index 85ad982..0000000
--- a/src/external/bsd/meinberg/mbgclock/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-.include "Makefile.kmod" \ No newline at end of file
diff --git a/src/external/bsd/meinberg/mbgclock/Makefile.kmod b/src/external/bsd/meinberg/mbgclock/Makefile.kmod
deleted file mode 100755
index 7d64394..0000000
--- a/src/external/bsd/meinberg/mbgclock/Makefile.kmod
+++ /dev/null
@@ -1,19 +0,0 @@
-# $NetBSD: Makefile,v 1.1 2009/02/05 17:32:10 haad Exp $
-
-.include "../Makefile.inc"
-
-.PATH: ${MBG_LIB_COMMON} ${MBG_LIB_BSD}
-
-MKMAN=no
-
-KMOD= mbgclock
-SRCS= mbgclock_main.c
-SRCS+= pcpsdrvr.c
-SRCS+= identdec.c
-SRCS+= rsrc_bsd.c
-
-.if defined(MKMODULAR) && (${MKMODULAR}!="no")
-.include <bsd.kmodule.mk>
-.else
-.include <bsd.kmod.mk>
-.endif
diff --git a/src/external/bsd/meinberg/mbgclock/files.mbgclock b/src/external/bsd/meinberg/mbgclock/files.mbgclock
deleted file mode 100755
index 94310bc..0000000
--- a/src/external/bsd/meinberg/mbgclock/files.mbgclock
+++ /dev/null
@@ -1,13 +0,0 @@
-# $NetBSD: files.drm,v 1.6 2011/02/18 14:26:09 jmcneill Exp $
-
-device mbgclock
-attach mbgclock at pci
-file external/bsd/meinberg/dist/mbglib/bsd/rsrc_bsd.c mbgclock
-file external/bsd/meinberg/dist/mbglib/common/identdec.c mbgclock
-file external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c mbgclock
-file external/bsd/meinberg/mbgclock/mbgclock_main.c mbgclock
-
-makeoptions mbgclock CPPFLAGS+="-I$S/external/bsd/meinberg/dist/mbglib/common"
-makeoptions mbgclock CPPFLAGS+="-I$S/external/bsd/meinberg/dist/mbglib/bsd"
-
-
diff --git a/src/external/bsd/meinberg/mbgclock/mbgclock_main.c b/src/external/bsd/meinberg/mbgclock/mbgclock_main.c
deleted file mode 100755
index ca9c4a3..0000000
--- a/src/external/bsd/meinberg/mbgclock/mbgclock_main.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- * $Header: /repository/clkdrv/bsd/netbsd/soft/mbgtools-nbsd/mbgclock/rcs/mbgclock_main.c 1.1.1.5 2011/04/01 12:54:09 martin TRASH $
- *
- * NetBSD Meinberg mbgclock driver, Frank Kardel
- *
- * $Created: Sat Mar 26 15:03:37 2011 $
- *
- */
-
-#include <sys/param.h>
-#include <sys/lwp.h>
-#include <sys/device.h>
-#include <sys/conf.h>
-#include <dev/pci/pcidevs.h>
-#include <dev/pci/pcivar.h>
-#include <sys/errno.h>
-
-#include <pcpsdrvr.h>
-#include <mbgddmsg.h>
-
-#ifndef PCI_BAR
-#define PCI_BAR(__n) (0x10 + 4 * (__n))
-#endif
-
-#define REV_NUM 0x100
-#define REV_NUM_STR "1.00"
-#define MBG_COPYRIGHT "(c) Meinberg 2011"
-#define MBG_DRVR_NAME "mbgclock"
-
-const char pcps_driver_name[] = MBG_DRVR_NAME;
-
-static MBG_DBG_DATA mbg_dbg_data;
-static MBG_DBG_PORT mbg_dbg_port = 0x378 + 0; //##++
-static PCPS_IO_ADDR_MAPPED mbg_dbg_port_mapped; //##++
-static PCPS_DRVR_INFO drvr_info = { REV_NUM, 0, MBG_DRVR_NAME " radio clock driver" };
-
-#include <macioctl.h>
-
-static dev_type_open(mbgclockopen);
-static dev_type_close(mbgclockclose);
-static dev_type_read(mbgclockread);
-static dev_type_write(mbgclockwrite);
-static dev_type_ioctl(mbgclockioctl);
-static int mbgclock_match(device_t, cfdata_t, void *);
-static void mbgclock_attach(device_t, device_t, void *);
-static int mbgclock_detach(device_t, int);
-
-struct mbgclock_softc
-{
- device_t dev; /* device backling */
- struct pci_attach_args pa; /* attach argument */
- PCPS_DDEV *pddev; /* driver handle */
-};
-
-#define MBG_UNITBITS 6 /* up to 64 devices */
-#define MBG_UNITMASK ((1<<MBG_UNITBITS)-1)
-#define MBG_UNIT(x) (minor(x) & MBG_UNITMASK)
-#define MBG_UNITTYPE(x) (minor(x) >> MBG_UNITBITS)
-
-const struct cdevsw mbgclock_cdevsw = {
- .d_open = mbgclockopen,
- .d_close = mbgclockclose,
- .d_read = mbgclockread,
- .d_write = mbgclockwrite,
- .d_ioctl = mbgclockioctl,
- .d_stop = nostop,
- .d_tty = notty,
- .d_poll = nopoll,
- .d_mmap = nommap,
- .d_kqfilter = nokqfilter,
- D_OTHER|D_MPSAFE
-};
-
-#ifdef CFATTACH_DECL3_NEW
-CFATTACH_DECL3_NEW(mbgclock,
- sizeof(struct mbgclock_softc),
- mbgclock_match,
- mbgclock_attach,
- mbgclock_detach,
- NULL,
- NULL,
- NULL,
- DVF_DETACH_SHUTDOWN);
-#else
-CFATTACH_DECL2_NEW(mbgclock,
- sizeof(struct mbgclock_softc),
- mbgclock_match,
- mbgclock_attach,
- mbgclock_detach,
- NULL,
- NULL,
- NULL);
-#endif
-
-extern struct cfdriver mbgclock_cd;
-
-#if defined( MBG_DEBUG )
-int debug = MBG_DEBUG;
-#endif
-
-#if defined( DEBUG )
-static int mbgclockdebug = ~0;
-#define DB_FOLLOW 0x00000001
-#define DPRINTF(_X_, _Y_) do { \
- if (mbgclockdebug & (_X_)) { \
- printf _Y_; \
- } \
- } \
- while (/*CONST_COND*/0)
-#else
-#define DPRINTF(_X_, _Y_) /* empty */
-#endif
-
-/*----- loadables -----*/
-#if defined (_LKM) || defined(_MODULE)
-
-CFDRIVER_DECL(mbgclock, DV_DULL, NULL);
-
-static int mbgclock_loc[] = { -1, -1 };
-
-static struct cfparent pciparent = {
- "pci", "pci", DVUNIT_ANY
-};
-
-static struct cfdata mbgclock_cfdata[] = {
- {
- .cf_name = "mbgclock",
- .cf_atname = "mbgclock",
- .cf_unit = 0,
- .cf_fstate = FSTATE_STAR,
- .cf_loc = mbgclock_loc,
- .cf_flags = 0,
- .cf_pspec = &pciparent,
- },
- { NULL }
-};
-
-#endif
-
-/*----- module -----*/
-#ifdef _MODULE
-
-#include <sys/module.h>
-
-MODULE(MODULE_CLASS_DRIVER, mbgclock, NULL);
-static int
-mbgclock_modcmd(modcmd_t cmd, void *arg)
-{
- int bmajor = -1, cmajor = -1, error = 0;
-
- switch (cmd) {
- case MODULE_CMD_INIT:
- DPRINTF(DB_FOLLOW, ("%s: MOD_CMD_INIT\n", mbgclock_cd.cd_name));
-
- error = config_cfdriver_attach(&mbgclock_cd);
- if (error)
- break;
-
- error = config_cfattach_attach(mbgclock_cd.cd_name, &mbgclock_ca);
- if (error) {
- config_cfdriver_detach(&mbgclock_cd);
- aprint_error("%s: unable to register cfattach\n",
- mbgclock_cd.cd_name);
- break;
- }
-
- /* s = splaudio(); */
- error = config_cfdata_attach(mbgclock_cfdata, 1);
- /* splx(s); */
-
- if (error == 0)
- {
- error = devsw_attach("mbgclock", NULL, &bmajor,
- &mbgclock_cdevsw, &cmajor);
- }
-
- if (error) {
- config_cfattach_detach(mbgclock_cd.cd_name, &mbgclock_ca);
- config_cfdriver_detach(&mbgclock_cd);
- break;
- } else {
- DPRINTF(DB_FOLLOW, ("%s: registered character major = %d\n",
- mbgclock_cd.cd_name, cmajor));
- }
-
- break;
-
- case MODULE_CMD_FINI:
- DPRINTF(DB_FOLLOW, ("%s: MOD_CMD_FINI\n", mbgclock_cd.cd_name));
- error = config_cfattach_detach(mbgclock_cd.cd_name, &mbgclock_ca);
- if (error)
- break;
- config_cfdriver_detach(&mbgclock_cd);
- devsw_detach(NULL, &mbgclock_cdevsw);
- break;
-
- case MODULE_CMD_STAT:
- return ENOTTY;
-
- default:
- return ENOTTY;
- }
-
- DPRINTF(DB_FOLLOW, ("modcmd rc = %d\n", error));
-
- return error;
-}
-#endif
-
-/*------ LKM -----*/
-#if defined(_LKM) && !defined(_MODULE)
-
-#include <sys/lkm.h>
-
-int mbgclock_lkmentry(struct lkm_table *, int, int);
-
-static struct cfdriver *mbgclock_cfdrivers[] = {
- &mbgclock_cd,
- NULL
-};
-static struct cfattach *mbgclock_cfattachs[] = {
- &mbgclock_ca,
- NULL
-};
-static const struct cfattachlkminit mbgclock_cfattachinit[] = {
- { "mbgclock", mbgclock_cfattachs },
- { NULL }
-};
-
-MOD_DRV("mbgclock",
- mbgclock_cfdrivers,
- mbgclock_cfattachinit,
- mbgclock_cfdata);
-
-static int
-mbgclock_lkmload(struct lkm_table *lkm, int cmd)
-{
- int bmajor = -1;
- int cmajor = -1;
- int error;
-
- error = devsw_attach("mbgclock", NULL, &bmajor,
- &mbgclock_cdevsw, &cmajor);
-
-#ifdef DEBUG
- if (error == 0) {
- DPRINTF(DB_FOLLOW, ("%s: registered character major = %d\n",
- mbgclock_cd.cd_name, cmajor));
- } else {
- DPRINTF(DB_FOLLOW, ("%s: device driver registry failed errno = %d\n",
- mbgclock_cd.cd_name, error));
- }
-#endif
- return error;
-}
-
-static int
-mbgclock_lkmunload(struct lkm_table *lkm, int cmd)
-{
- devsw_detach(NULL, &mbgclock_cdevsw);
- return 0;
-}
-
-int
-mbgclock_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
-{
- DISPATCH(lkmtp, cmd, ver, mbgclock_lkmload, mbgclock_lkmunload, lkm_nofunc);
-}
-#endif
-
-/*----- autoconf -----*/
-
-/* PCI Support Functions */
-
-static void
-mbg_deallocate_resource( BSD_RSRC_INFO *p_ri )
-{
- if ( p_ri->valid )
- {
- bus_space_unmap( p_ri->bst, p_ri->bsh, p_ri->size);
- p_ri->valid = 0;
- }
-}
-
-/*
- * deallocate resources
- */
-static void
-mbg_dealloc_rsrcs( struct mbgclock_softc *psc )
-{
- PCPS_DDEV *pddev = psc->pddev;
-
-/* mbg_deallocate_resource( device, &prsrci->irq.bsd, SYS_RES_IRQ ); */
-
- if ( pddev != NULL )
- {
- PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
- int i;
-
- for ( i = 0; i < N_PCPS_MEM_RSRC; i++ )
- mbg_deallocate_resource( &prsrci->mem[i].bsd );
-
- for ( i = 0; i < N_PCPS_PORT_RSRC; i++ )
- mbg_deallocate_resource( &prsrci->port[i].bsd );
- }
-}
-
-static void
-mbg_alloc_rsrc( struct mbgclock_softc *psc , int reg, BSD_RSRC_INFO *p_ri, int type )
-{
- p_ri->reg = reg;
- p_ri->type = type;
-
- if (!pci_mapreg_map(&psc->pa, reg, type, 0,
- &p_ri->bst, &p_ri->bsh,
- &p_ri->base, &p_ri->size))
- {
- p_ri->valid = 1;
- } else {
- p_ri->valid = 0;
- }
-}
-
-static void
-mbg_alloc_rsrcs( struct mbgclock_softc *psc )
-{
- PCPS_DDEV *pddev = psc->pddev;
- PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
- BSD_RSRC_INFO ri;
- int bar;
-
- /* clear valid flags */
- for ( bar = 0; bar < prsrci->num_rsrc_io; bar ++)
- prsrci->port[bar].bsd.valid = 0;
-
- for ( bar = 0; bar < prsrci->num_rsrc_mem; bar ++)
- prsrci->mem[bar].bsd.valid = 0;
-
- for ( bar = 0; bar < 6; bar ++ )
- {
- int type;
- int reg = PCI_BAR( bar );
-
- _mbgddmsg_4( MBG_DBG_INIT_DEV,
- "%s: alloc I/O range %i: PCI device 0x%04X:0x%04X supported",
- pcps_driver_name, bar, PCI_VENDOR(psc->pa.pa_id),
- PCI_PRODUCT(psc->pa.pa_id) );
-
- switch ((type = pci_mapreg_type(psc->pa.pa_pc, psc->pa.pa_tag, reg)))
- {
- case PCI_MAPREG_TYPE_IO:
- if ( prsrci->num_rsrc_io < N_PCPS_PORT_RSRC )
- {
- mbg_alloc_rsrc( psc, reg, &ri, type );
-
- if ( ri.valid )
- {
- prsrci->port[prsrci->num_rsrc_io].bsd = ri;
- pcps_add_rsrc_io( pddev, ri.base, ri.size );
- continue;
- }
- else
- {
- _mbgddmsg_2( MBG_DBG_INIT_DEV,
- "%s: alloc I/O range %i failed",
- pcps_driver_name, bar );
- }
- }
- break;
-
- case PCI_MAPREG_MEM_TYPE_64BIT:
-#if __LP64__
- /* XXX */
- aprint_error_dev(device,
- "WARNING: ignoring 64-bit BAR @ 0x%02x\n", reg);
- continue;
-#else
- /*FALLTHROUGH*/
-#endif
- case PCI_MAPREG_TYPE_MEM:
- /* case PCI_MAPREG_TYPE_ROM: currently same as above */
- if ( prsrci->num_rsrc_mem < N_PCPS_MEM_RSRC )
- {
- mbg_alloc_rsrc( psc, reg, &ri, type );
-
- if ( ri.valid )
- {
- prsrci->mem[prsrci->num_rsrc_mem].bsd = ri;
- pcps_add_rsrc_mem( pddev,
- (MBG_MEM_ADDR)bus_space_vaddr( ri.bst, ri.bsh),
- ri.size );
- continue;
- }
- }
- break;
-
- default:
- printf("XXX unsupported type from pci_mapreg_type: %d\n", type);
- break;
- }
- }
-
- /* single IRQ resource */
-#if 0 /* currently not used / required */
- mbg_alloc_rsrc( device, 0, &ri, SYS_RES_IRQ, RF_SHAREABLE | RF_ACTIVE );
-
- if ( ri.res )
- {
- prsrci->port[prsrci->num_rsrc_irq].bsd = ri;
- pcps_add_rsrc_irq( pddev, rman_get_start( ri.res ) );
- }
-#endif
-
-}
-
-static int
-mbgclock_match(struct device *parent, struct cfdata *match, void *aux)
-{
- struct pci_attach_args *pa;
- int16_t vend_id;
- int16_t dev_id;
-
- DPRINTF(DB_FOLLOW, ("mbgclock_match(0x%p, 0x%p, 0x%p)\n", parent, match, aux));
-
- pa = aux;
- vend_id = PCI_VENDOR(pa->pa_id);
- dev_id = PCI_PRODUCT(pa->pa_id);
-
- if (vend_id == PCI_VENDOR_MEINBERG)
- {
- PCPS_DEV_TYPE *pdt;
-
- pdt = pcps_get_dev_type( PCPS_BUS_PCI, dev_id );
-
- if (pdt != NULL)
- {
- _mbgddmsg_3( MBG_DBG_INIT_DEV,
- "%s: probe: PCI device 0x%04X:0x%04X supported",
- pcps_driver_name, vend_id, dev_id );
-
- return 1;
- }
- }
-
- _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s: probe: PCI device 0x%04X:0x%04X not supported",
- pcps_driver_name, vend_id, dev_id );
- return 0;
-}
-
-
-static void
-mbgclock_attach(struct device *parent, struct device *self, void *aux)
-{
- int rc = 0;
- char devinfo[256];
- struct mbgclock_softc *psc = device_private(self);
- struct pci_attach_args *pa = aux;
- uint16_t dev_id = PCI_PRODUCT(pa->pa_id);
-
- DPRINTF(DB_FOLLOW, ("mbgclock_attach(0x%p, 0x%p, 0x%p)\n", parent, self, aux));
-
- psc->dev = self;
- psc->pa = *pa;
-
- pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
- aprint_naive("\n");
- aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
- PCI_REVISION(pa->pa_class));
-
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: attach for device 0x%04X",
- pcps_driver_name, dev_id );
-
- psc->pddev = pcps_alloc_ddev();
-
- if ( psc->pddev == NULL )
- {
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: attach device 0x%04X: pcps_alloc_ddev() failed",
- pcps_driver_name, dev_id );
- goto fail;
- }
-
- rc = pcps_init_ddev( psc->pddev, PCPS_BUS_PCI, dev_id );
-
- if ( rc != PCPS_SUCCESS )
- {
- _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s: attach device 0x%04X: pcps_init_ddev() failed, rc: %i",
- pcps_driver_name, dev_id, rc );
- goto fail;
- }
-
- mbg_alloc_rsrcs( psc );
-
- rc = pcps_start_device( psc->pddev, 0, 0 );
-
- if ( rc != PCPS_SUCCESS )
- {
- _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s: attach device 0x%04X: pcps_start_device() failed, rc: %i",
- pcps_driver_name, dev_id, rc );
- goto fail;
- }
-
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: device 0x%04X attached successfully",
- pcps_driver_name, dev_id );
-
- if (!pmf_device_register(self, NULL, NULL))
- aprint_error_dev(self, "couldn't establish power handler\n");
-
- return;
-
-fail:
- mbg_dealloc_rsrcs( psc );
-
- if ( psc->pddev != NULL )
- pcps_free_ddev( psc->pddev );
-
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: failed to attach device 0x%04X",
- pcps_driver_name, dev_id );
- return;
-}
-
-static int
-mbgclock_detach(struct device *self, int flags)
-{
- struct mbgclock_softc *psc = device_private(self);
- uint16_t dev_id;
-
- DPRINTF(DB_FOLLOW, ("mbgclock_detach(0x%p, 0x%x)\n", self, flags));
-
- if (psc == NULL)
- return ENXIO;
-
- dev_id = PCI_PRODUCT(psc->pa.pa_id);
-
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: detach for device 0x%04X",
- pcps_driver_name, dev_id );
-
- /* XXX insure not outstanding requests */
- mbg_dealloc_rsrcs( psc );
-
- if ( psc->pddev != NULL )
- pcps_free_ddev( psc->pddev );
-
- psc->pddev = NULL;
-
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: device 0x%04X detached",
- pcps_driver_name, dev_id );
-
- pmf_device_deregister(self);
-
- return 0;
-}
-
-/*------- driver -------*/
-
-static
-int mbgclockopen(dev_t dev, int flags, int mode, struct lwp *l)
-{
- struct mbgclock_softc *psc = device_lookup_private(&mbgclock_cd, MBG_UNIT(dev));
-
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: open called", pcps_driver_name );
- DPRINTF(DB_FOLLOW, ("mbgclockopen(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l));
-
- if (psc == NULL)
- return ENXIO;
-
- return 0;
-}
-
-static
-int mbgclockclose(dev_t dev, int flags, int mode, struct lwp *l)
-{
- struct mbgclock_softc *psc = device_lookup_private(&mbgclock_cd, MBG_UNIT(dev));
-
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: close called", pcps_driver_name );
- DPRINTF(DB_FOLLOW,("mbgclockclose(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l));
-
- if (psc == NULL)
- return ENXIO;
-
- return 0;
-}
-
-static
-int mbgclockread(dev_t dev, struct uio *uio, int flags)
-{
- struct mbgclock_softc *psc = device_lookup_private(&mbgclock_cd, MBG_UNIT(dev));
-
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: read called", pcps_driver_name );
- DPRINTF(DB_FOLLOW,("mbgclockread(0x%"PRIx64", %p)\n", dev, uio));
-
- if (psc == NULL)
- return ENXIO;
-
- return 0;
-}
-
-static
-int mbgclockwrite(dev_t dev, struct uio *uio, int flags)
-{
- struct mbgclock_softc *psc = device_lookup_private(&mbgclock_cd, MBG_UNIT(dev));
-
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: write called", pcps_driver_name );
- DPRINTF(DB_FOLLOW, ("mbgclockwrite(0x%"PRIx64", %p)\n", dev, uio));
-
- if (psc == NULL)
- return ENXIO;
-
- return 0;
-}
-
-#include <sys/ioctl.h>
-
-static
-int mbgclockioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
-{
- struct mbgclock_softc *psc = device_lookup_private(&mbgclock_cd, MBG_UNIT(dev));
- PCPS_DDEV *pddev;
- int rc;
-
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: ioctl called", pcps_driver_name );
- DPRINTF(DB_FOLLOW, ("mbgclockioctl(0x%"PRIx64", 0x%lx, %p, 0x%x, %p)\n",
- dev, cmd, data, flag, l->l_proc));
-
- if (psc == NULL)
- return ENXIO;
-
- pddev = psc->pddev;
-
- rc = ioctl_switch( pddev, cmd, (void *) data, (void *) data );
-
- /* On success we return quickly.*/
-
- if ( rc == MBG_SUCCESS )
- {
- _mbgddmsg_6( MBG_DBG_INFO, "%s: %d,%d IOCTL 0x%02lX: success, dev %p_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = 0;
- goto out;
- }
-
-
- /* An error has occurred. */
- /* Generate an appropriate debug/error message */
- /* and return an error status. */
-
- switch ( rc )
- {
- case MBG_ERR_INV_DEV_REQUEST:
- _mbgddmsg_7( MBG_DBG_WARN, "%s: %d,%d ioctl 0x%04lX: invalid cmd %04lX, dev %s_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, IOCBASECMD( cmd ),
- _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = EINVAL;
- break;
-
-
- case MBG_ERR_NOT_SUPP_BY_DEV:
- _mbgddmsg_6( MBG_DBG_WARN, "%s: %d,%d ioctl 0x%02lX: not supported by dev %s_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = EIO; /* XXX ENODEV */
- break;
-
-
- case MBG_ERR_NO_MEM:
- _mbgddmsg_6( MBG_DBG_WARN, "%s: %d,%d ioctl 0x%02lX: unable to allocate buffer for dev %s_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = EFAULT; /* XXX ENOMEM */
- break;
-
-
- case MBG_ERR_IRQ_UNSAFE:
- _mbgddmsg_6( MBG_DBG_DETAIL, "%s: %d,%d ioctl 0x%02lX: busy since unsafe IRQ enabled, dev %s_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = EBUSY;
- break;
-
-
- default: /* any access error code returned by the low level routine */
- /* or copying from or to user space */
- _mbgddmsg_7( MBG_DBG_WARN, "%s: %d,%d ioctl 0x%02lX: error %i accessing dev %s_%s",
- pcps_driver_name, major(dev), minor(dev), cmd, rc, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
- rc = EFAULT; /* XXX EFAULT is inappropriate */
-
- }
-
-
-out:
- return rc;
-}
-
diff --git a/src/sys/dev/pci/files.pci.diff b/src/sys/dev/pci/files.pci.diff
deleted file mode 100644
index 3871edb..0000000
--- a/src/sys/dev/pci/files.pci.diff
+++ /dev/null
@@ -1,16 +0,0 @@
-Index: files.pci
-===================================================================
-RCS file: /cvsroot/src/sys/dev/pci/files.pci,v
-retrieving revision 1.339
-diff -u -r1.339 files.pci
---- files.pci 23 Feb 2011 00:35:29 -0000 1.339
-+++ files.pci 27 Mar 2011 16:13:06 -0000
-@@ -1042,3 +1042,8 @@
- device vte: ether, ifnet, arp, mii, mii_phy
- attach vte at pci
- file dev/pci/if_vte.c vte
-+
-+#
-+# Meinberg radio clocks
-+#
-+include "external/bsd/meinberg/mbgclock/files.mbgclock"
diff --git a/src/sys/dev/pci/pcidevs.diff b/src/sys/dev/pci/pcidevs.diff
deleted file mode 100644
index d5ecaff..0000000
--- a/src/sys/dev/pci/pcidevs.diff
+++ /dev/null
@@ -1,47 +0,0 @@
-Index: pcidevs
-===================================================================
-RCS file: /cvsroot/src/sys/dev/pci/pcidevs,v
-retrieving revision 1.1066
-diff -u -r1.1066 pcidevs
---- pcidevs 25 Feb 2011 01:36:18 -0000 1.1066
-+++ pcidevs 27 Mar 2011 16:12:26 -0000
-@@ -546,6 +546,7 @@
- vendor SIIG 0x131f Siig
- vendor DOMEX 0x134a Domex
- vendor QUATECH 0x135c Quatech
-+vendor MEINBERG 0x1360 Meinberg Funkuhren
- vendor LMC 0x1376 LAN Media
- vendor NETGEAR 0x1385 Netgear
- vendor MOXA 0x1393 Moxa Technologies
-@@ -3047,6 +3048,31 @@
- /* KTI products - XXX better descriptions */
- product KTI NE2KETHER 0x3000 Ethernet
-
-+/* Meinberg Funkuhren Products */
-+product MEINBERG PCI32 0x0101 DCF77 PCI32
-+product MEINBERG PCI509 0x0102 DCF77 PCI509
-+product MEINBERG PCI510 0x0103 DCF77 PCI510
-+product MEINBERG PCI511 0x0104 DCF77 PCI511
-+product MEINBERG PEX511 0x0105 DCF77 PEX511
-+
-+product MEINBERG GPS167PCI 0x0201 GPS GPS167PCI
-+product MEINBERG GPS168PCI 0x0202 GPS GPS168PCI
-+product MEINBERG GPS169PCI 0x0203 GPS GPS169PCI
-+product MEINBERG GPS170PCI 0x0204 GPS GPS170PCI
-+product MEINBERG GPS170PEX 0x0205 GPS GPS170PEX
-+product MEINBERG GPS180PEX 0x0206 GPS GPS180PEX
-+
-+product MEINBERG TCR510PCI 0x0301 IRIG TCR510PCI
-+product MEINBERG TCR167PCI 0x0302 IRIG TCR167PCI
-+product MEINBERG TCR511PCI 0x0303 IRIG TCR511PCI
-+product MEINBERG TCR511PEX 0x0304 IRIG TCR511PEX
-+product MEINBERG TCR170PEX 0x0305 IRIG TCR170PEX
-+product MEINBERG TCR180PEX 0x0306 IRIG TCR180PEX
-+
-+product MEINBERG PTP280PEX 0x0501 PTP PTP280PEX
-+
-+product MEINBERG FRC511PEX 0x0601 FRC FRC511PEX
-+
- /* LAN Media */
- product LMC HSSI 0x0003 HSSI Interface
- product LMC DS3 0x0004 DS3 Interface
diff --git a/src/sys/external/bsd/meinberg b/src/sys/external/bsd/meinberg
deleted file mode 120000
index 39b5e46..0000000
--- a/src/sys/external/bsd/meinberg
+++ /dev/null
@@ -1 +0,0 @@
-../../../external/bsd/meinberg \ No newline at end of file