summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2011-03-25 12:00:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2011-03-25 12:00:00 +0100
commit30b175951bdaf3830ff9acc21d2fc7cd649e0f57 (patch)
tree5b81633e24767f4a91359aa6f5f9323c43f0d5dd
parent04b21e5763c53b7986debbcc18f023c9df0200cf (diff)
downloadmbgtools-fbsd-30b175951bdaf3830ff9acc21d2fc7cd649e0f57.tar.gz
mbgtools-fbsd-30b175951bdaf3830ff9acc21d2fc7cd649e0f57.zip
Optional parameter USE_TIMESPECmbgtools-fbsd-dev-2011-03-25
Also update some source files to versions that have initial support for NetBSD.
-rwxr-xr-xMakefile12
-rwxr-xr-xREADME53
-rwxr-xr-xmbgclock/Makefile2
-rwxr-xr-xmbgclock/mbgdrvr.c129
-rwxr-xr-xmbgctrl/mbgctrl.c509
-rwxr-xr-xmbglib/common/gpsdefs.h429
-rwxr-xr-xmbglib/common/macioctl.h95
-rwxr-xr-xmbglib/common/mbg_arch.h12
-rwxr-xr-xmbglib/common/mbg_tgt.h21
-rwxr-xr-xmbglib/common/mbgdevio.c113
-rwxr-xr-xmbglib/common/mbgdevio.h59
-rwxr-xr-xmbglib/common/mbggenio.h109
-rwxr-xr-xmbglib/common/mbgioctl.h17
-rwxr-xr-xmbglib/common/mbgtime.h8
-rwxr-xr-xmbglib/common/mbgutil.h7
-rwxr-xr-xmbglib/common/myutil.h20
-rwxr-xr-xmbglib/common/parmgps.h11
-rwxr-xr-xmbglib/common/parmpcps.h9
-rwxr-xr-xmbglib/common/pcpsdefs.h7
-rwxr-xr-xmbglib/common/pcpsdev.h120
-rwxr-xr-xmbglib/common/pcpsdrvr.c345
-rwxr-xr-xmbglib/common/pcpsdrvr.h70
-rwxr-xr-xmbglib/common/pcpslstr.h33
-rwxr-xr-xmbglib/common/words.h9
-rwxr-xr-xmbgstatus/mbgstatus.c15
-rwxr-xr-xmbgsvcd/mbgsvcd.c178
26 files changed, 1830 insertions, 562 deletions
diff --git a/Makefile b/Makefile
index 44fc7bb..2bdabee 100755
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,17 @@
#########################################################################
#
-# $Id: Makefile 1.1.1.4 2011/02/04 10:09:45 martin TEST $
+# $Id: Makefile 1.1.1.6 2011/03/25 11:05:55 martin TRASH $
#
# Description:
# Makefile for mbgtools which recurses into the subdirectories.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.1.1.6 2011/03/25 11:05:55 martin
+# Optional parameter USE_TIMESPEC.
+# Revision 1.1.1.5 2011/03/21 16:24:12 martin
+# Workaround for recursive make under NetBSD.
# Revision 1.1.1.4 2011/02/04 10:09:45 martin
# Revision 1.1.1.3 2011/02/02 12:33:29 martin
# Revision 1.1.1.2 2011/01/28 09:29:47 martin
@@ -159,7 +163,7 @@ SUBDIRS += mbgclock
all clean distclean install uninstall:
@for dir in $(SUBDIRS); do \
if test -f $$dir/Makefile; then \
- $(MAKE) -C $$dir $@ || exit 1; \
+ /bin/sh -c "cd $$dir; $(MAKE) $@"; \
fi \
done
@@ -217,6 +221,10 @@ CFLAGS += -Wall
CFLAGS += -O2
.endif
+.ifdef USE_TIMESPEC
+ CFLAGS += -DUSE_TIMESPEC=$(USE_TIMESPEC)
+.endif
+
CFLAGS += -I.
CFLAGS += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
#########
diff --git a/README b/README
index dc67692..9067192 100755
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Id: README 1.1 2011/02/04 14:44:01 martin TEST $
+$Id: README 1.1.1.1 2011/02/09 11:47:11 martin TRASH martin $
This is the README file for mbgtools-fbsd-dev-2011-02-04
--------------------------------------------------------
@@ -90,13 +90,13 @@ mbgdcfmod
received longwave signal, e.g. from DCF77.
mbggpscap
- This example program reads time capture events from a card's time
- capture buffer. This works only with cards which provide time capture
- inputs, and the DIP switches on those cards must be set up properly
+ This example program reads time capture events from a card's time
+ capture buffer. This works only with cards which provide time capture
+ inputs, and the DIP switches on those cards must be set up properly
to enable time capturing.
mbghrtime
- This example program checks whether a card supports high-resolution
+ This example program checks whether a card supports high-resolution
time and reads those time stamps from the device, if supported.
mbgfasttstamp
@@ -107,17 +107,17 @@ mbgfasttstamp
mbgxhrtime
This example program also shows how to get time stamps faster than
- shown in mbghrtime. This is not as easy as mbgfasttstamp but can be
- used with every card which can be used with mbghrtime, even if the
- card does not support memory mapped I/O.
- The program starts a polling thread which reads a high resolution
- time stamp from the card once per second, and then uses the CPU's
- time stamp counter to extrapolate the time.
- A limitation of this approach is that the CPU's time stamp counters
+ shown in mbghrtime. This is not as easy as mbgfasttstamp but can be
+ used with every card which can be used with mbghrtime, even if the
+ card does not support memory mapped I/O.
+ The program starts a polling thread which reads a high resolution
+ time stamp from the card once per second, and then uses the CPU's
+ time stamp counter to extrapolate the time.
+ A limitation of this approach is that the CPU's time stamp counters
may return different values on different CPUs. So the program
takes care to have the code executed always on the same CPU. Also,
- power saving mechanisms (Intel Speedstep, or AMD Cool'n'Quiet)
- should be disabled to prevent the extrapolated times from being
+ power saving mechanisms (Intel Speedstep, or AMD Cool'n'Quiet)
+ should be disabled to prevent the extrapolated times from being
messed up.
@@ -151,7 +151,7 @@ simply type
make
to compile the utility programs first, then the kernel module.
-If *any* error or warning messages are displayed then please
+If *any* error or warning messages are displayed then please
report to Meinberg.
@@ -162,21 +162,21 @@ Installation must be done as user root. Type
make install
-to copy the compiled binaries to their target directories. Programs
-which only read the clock to display some information are copied to
-/usr/local/bin, whereas programs which may change the device
+to copy the compiled binaries to their target directories. Programs
+which only read the clock to display some information are copied to
+/usr/local/bin, whereas programs which may change the device
configuration, or set the system time, are copied to /usr/local/sbin.
3.4 Loading the kernel module
-----------------------------
-After the binaries have been installed the module can be loaded
+After the binaries have been installed the module can be loaded
for the first time. The command syntax is:
kldload mbgclock
-When the module is loaded some some startup messages are generated which
+When the module is loaded some some startup messages are generated which
can be checked in the syslog, or using the dmesg command. If the module
was loaded successfully it should be listed if you type
@@ -244,3 +244,16 @@ make install
By default this installs the NTP binaries under /usr/local rather than /usr/sbin,
so be sure the right instance of ntpd is started on reboot or when you run the
"service ntpd start" command.
+
+-----------------------------------------------------------------------------------
+Recompile ntpd with modified configuration (FreeBSD 5.3):
+
+root# cd /usr/ports/net/ntp/
+root# vi Makefile
+
+Add line:
+ CONFIGURE_ARGS+= --enable-MEINBERG
+
+root# make install clean
+
+
diff --git a/mbgclock/Makefile b/mbgclock/Makefile
index 2cb9258..7dd2450 100755
--- a/mbgclock/Makefile
+++ b/mbgclock/Makefile
@@ -1,7 +1,7 @@
#########################################################################
#
-# $Id: Makefile 1.1.1.4 2011/02/03 14:10:39 martin TEST $
+# $Id: Makefile 1.1.1.4 2011/02/03 14:10:39 martin TEST martin $
#
# Description:
# Makefile for mbgclock driver to support Meinberg bus level
diff --git a/mbgclock/mbgdrvr.c b/mbgclock/mbgdrvr.c
index 7a8a9ac..e2f968c 100755
--- a/mbgclock/mbgdrvr.c
+++ b/mbgclock/mbgdrvr.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdrvr.c 1.1.1.11 2011/02/04 14:44:19 martin TEST $
+ * $Id: mbgdrvr.c 1.1.1.11.1.3 2011/03/25 11:06:27 martin TRASH martin $
*
* Description:
* Main file for for mbgclock driver to support Meinberg bus level
@@ -14,6 +14,12 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdrvr.c $
+ * Revision 1.1.1.11.1.3 2011/03/25 11:06:27 martin
+ * Fixed typo.
+ * Revision 1.1.1.11.1.2 2011/03/23 16:49:53 martin
+ * Syntax fix.
+ * Revision 1.1.1.11.1.1 2011/03/22 12:09:16 martin
+ * Started to support NetBSD.
* Revision 1.1.1.11 2011/02/04 14:44:19 martin
* Revision 1.1.1.10 2011/02/02 12:33:52 martin
* Revision 1.1.1.9 2011/02/01 17:11:38 martin
@@ -48,7 +54,10 @@
#include <sys/uio.h> /* uio struct */
#include <sys/malloc.h>
#include <sys/bus.h> /* structs, prototypes for pci bus stuff */
-#include <sys/rman.h>
+
+#if defined( MBG_TGT_FREEBSD )
+ #include <sys/rman.h>
+#endif
#include <dev/pci/pcivar.h> /* For pci_get macros! */
#include <dev/pci/pcireg.h>
@@ -96,17 +105,35 @@ struct mbgclock_softc
/* Function prototypes */
-static d_open_t mbgclock_open;
-static d_close_t mbgclock_close;
-static d_read_t mbgclock_read;
-static d_write_t mbgclock_write;
-static d_ioctl_t mbgclock_ioctl;
+#if defined( MBG_TGT_NETBSD )
+ static int mbgclock_open( dev_t, int, int, struct proc * );
+ static int mbgclock_close( dev_t, int, int, struct proc * );
+ static int mbgclock_read( dev_t dev, struct uio *, int );
+#else // FreeBSD
+ static d_open_t mbgclock_open;
+ static d_close_t mbgclock_close;
+ static d_read_t mbgclock_read;
+ static d_write_t mbgclock_write;
+ static d_ioctl_t mbgclock_ioctl;
+#endif
/* Character device entry points */
static struct cdevsw mbgclock_cdevsw =
{
+#if defined( MBG_TGT_NETBSD )
+
+#if 0 //##+++++++
+ .d_open = mbgclock_open,
+ .d_close = mbgclock_close,
+ .d_read = mbgclock_read,
+ .d_write = mbgclock_write,
+ .d_ioctl = mbgclock_ioctl,
+ .d_name = "mbgclock"
+#endif
+
+#else // FreeBSD
.d_version = D_VERSION,
.d_open = mbgclock_open,
.d_close = mbgclock_close,
@@ -114,6 +141,7 @@ static struct cdevsw mbgclock_cdevsw =
.d_write = mbgclock_write,
.d_ioctl = mbgclock_ioctl,
.d_name = "mbgclock"
+#endif
};
@@ -135,6 +163,17 @@ void set_dev_connected( PCPS_DDEV *pddev, int state )
* of struct cdev. We set this variable to point to our softc in our
* attach routine when we create the /dev entry.
*/
+#if defined( MBG_TGT_NETBSD )
+
+#if 0 //##++++
+int
+mbgclock_open( dev_t, int, int, struct proc * )
+{
+} // mbgclock_open
+#endif
+
+#else // FreeBSD
+
int
mbgclock_open( struct cdev *dev, int oflags, int devtype, d_thread_t *td )
{
@@ -150,7 +189,12 @@ mbgclock_open( struct cdev *dev, int oflags, int devtype, d_thread_t *td )
} // mbgclock_open
+#endif
+
+
+#if defined( MBG_TGT_NETBSD )
+#else // FreeBSD
int
mbgclock_close( struct cdev *dev, int fflag, int devtype, d_thread_t *td )
@@ -167,7 +211,12 @@ mbgclock_close( struct cdev *dev, int fflag, int devtype, d_thread_t *td )
} // mbgclock_close
+#endif
+
+
+#if defined( MBG_TGT_NETBSD )
+#else // FreeBSD
int
mbgclock_read( struct cdev *dev, struct uio *uio, int ioflag )
@@ -185,7 +234,12 @@ mbgclock_read( struct cdev *dev, struct uio *uio, int ioflag )
} // mbgclock_read
+#endif
+
+#if defined( MBG_TGT_NETBSD )
+
+#else // FreeBSD
int
mbgclock_write( struct cdev *dev, struct uio *uio, int ioflag )
@@ -203,13 +257,34 @@ mbgclock_write( struct cdev *dev, struct uio *uio, int ioflag )
} // mbgclock_write
+#endif
+
+
+
+#if defined( MBG_TGT_NETBSD ) //##++++++++++++
+// Below there are some dummy declarations to make the IOCTL handler
+// for FreeBSD *compile* without errors under NetBSD.
+// This is mainly to see if ioctl_switch() compiles without errors.
+
+#define caddr_t void *
+
+struct thread
+{
+ int dummy;
+};
+
+#endif
int
mbgclock_ioctl( struct cdev *dev, u_long cmd, caddr_t data,
int32_t flag, struct thread *td )
{
+#if defined( MBG_TGT_NETBSD )
+ struct mbgclock_softc *psc = NULL; //##++++ dummy, just to avoid build error
+#else // FreeBSD
struct mbgclock_softc *psc = dev->si_drv1;
+#endif
PCPS_DDEV *pddev = psc->pddev;
int rc;
@@ -283,10 +358,14 @@ mbg_deallocate_resource( device_t device, BSD_RSRC_INFO *p_ri, int type )
{
if ( p_ri->res )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
bus_deactivate_resource( device, type,
p_ri->rid, p_ri->res );
bus_release_resource( device, type,
p_ri->rid, p_ri->res );
+#endif
p_ri->res = NULL;
}
@@ -300,6 +379,9 @@ mbg_deallocate_resource( device_t device, BSD_RSRC_INFO *p_ri, int type )
static void
mbg_dealloc_rsrcs( device_t device )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
struct mbgclock_softc *psc = device_get_softc( device );
PCPS_DDEV *pddev = psc->pddev;
PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
@@ -312,6 +394,7 @@ mbg_dealloc_rsrcs( device_t device )
for ( i = 0; i < N_PCPS_PORT_RSRC; i++ )
mbg_deallocate_resource( device, &prsrci->port[i].bsd, SYS_RES_IOPORT );
+#endif
} // mbg_dealloc_rsrcs
@@ -320,6 +403,9 @@ mbg_dealloc_rsrcs( device_t device )
static void
mbg_alloc_rsrc( device_t device, int rid, BSD_RSRC_INFO *p_ri, int type, int flags )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
p_ri->rid = rid;
p_ri->res = bus_alloc_resource_any( device, type, &p_ri->rid, flags );
@@ -329,6 +415,7 @@ mbg_alloc_rsrc( device_t device, int rid, BSD_RSRC_INFO *p_ri, int type, int fla
p_ri->bst = rman_get_bustag( p_ri->res );
p_ri->bsh = rman_get_bushandle( p_ri->res );
}
+#endif
} // mbg_alloc_rsrc
@@ -337,6 +424,9 @@ mbg_alloc_rsrc( device_t device, int rid, BSD_RSRC_INFO *p_ri, int type, int fla
static void
mbg_alloc_rsrcs( device_t device )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
struct mbgclock_softc *psc = device_get_softc( device );
PCPS_DDEV *pddev = psc->pddev;
PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
@@ -377,7 +467,7 @@ mbg_alloc_rsrcs( device_t device )
// single IRQ resource
-#if 0
+#if 0 // currently not used / required
mbg_alloc_rsrc( device, 0, &ri, SYS_RES_IRQ, RF_SHAREABLE | RF_ACTIVE );
if ( ri.res )
@@ -387,6 +477,8 @@ mbg_alloc_rsrcs( device_t device )
}
#endif
+#endif
+
} // mbg_alloc_rsrcs
@@ -398,6 +490,9 @@ mbg_alloc_rsrcs( device_t device )
static int
mbgclock_probe( device_t device )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
uint16_t vend_id = pci_get_vendor( device );
uint16_t dev_id = pci_get_device( device );
PCPS_DEV_TYPE *pdt;
@@ -424,6 +519,8 @@ fail:
pcps_driver_name, vend_id, dev_id );
return ENXIO;
+#endif
+
} // mbgclock_probe
@@ -434,6 +531,9 @@ fail:
static int
mbgclock_attach( device_t device )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
uint16_t dev_id = pci_get_device( device );
struct mbgclock_softc *psc = device_get_softc( device );
int rc;
@@ -510,6 +610,7 @@ fail:
_mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: failed to attach device 0x%04X",
pcps_driver_name, dev_id );
return rc;
+#endif
} // mbgclock_attach
@@ -521,6 +622,9 @@ fail:
static int
mbgclock_detach( device_t device )
{
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
#if defined( DEBUG )
uint16_t dev_id = pci_get_device( device );
#endif
@@ -544,6 +648,7 @@ mbgclock_detach( device_t device )
_mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: device 0x%04X detached",
pcps_driver_name, dev_id );
+#endif
return 0;
@@ -593,6 +698,9 @@ mbgclock_resume( device_t device )
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
static device_method_t mbgclock_methods[] =
{
/* Device interface */
@@ -604,9 +712,14 @@ static device_method_t mbgclock_methods[] =
DEVMETHOD( device_resume, mbgclock_resume ),
{ 0, 0 }
};
+#endif
+#if defined( MBG_TGT_NETBSD )
+ //##++++++
+#else // FreeBSD
static devclass_t mbgclock_devclass;
DEFINE_CLASS_0( mbgclock, mbgclock_driver, mbgclock_methods, sizeof( struct mbgclock_softc ) );
DRIVER_MODULE( mbgclock, pci, mbgclock_driver, mbgclock_devclass, 0, 0 );
+#endif
diff --git a/mbgctrl/mbgctrl.c b/mbgctrl/mbgctrl.c
index 0db595c..d7c6d9f 100755
--- a/mbgctrl/mbgctrl.c
+++ b/mbgctrl/mbgctrl.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgctrl.c 1.22 2009/09/29 14:58:18 martin REL_M $
+ * $Id: mbgctrl.c 1.22.1.5 2011/03/21 08:32:18 martin TRASH $
*
* Description:
* Main file for mbgctrl program which sends commands and
@@ -9,6 +9,16 @@
*
* -----------------------------------------------------------------------
* $Log: mbgctrl.c $
+ * 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
+ * Support configuring PTP roles.
+ * Revision 1.22.1.3 2011/02/18 13:35:59 daniel
+ * Revision 1.22.1.2 2011/02/18 13:35:11 daniel
+ * Revision 1.22.1.1 2011/02/18 11:27:29 daniel
+ * Preliminary support for configuring PTP parameters incl. Unicast
+ * Bugfix: accept parameter keyword only when substring is found at the
+ * start of the parameter string.
* Revision 1.22 2009/09/29 14:58:18 martin
* Unified and simplified parameter evaluation.
* Updated version number to 3.4.0.
@@ -125,6 +135,7 @@ 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
@@ -154,6 +165,18 @@ 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_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*/
@@ -376,6 +399,408 @@ int show_lan_intf( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, const char *info )
static /*HDR*/
+int show_ptp_cfg( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, 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 );
+
+ if ( mbg_ioctl_err( rc, "mbg_get_ptp_cfg_info" ) )
+ return rc;
+
+ supports_unicast = ptp_settings.supported_flags & PTP_CFG_MSK_SUPPORT_PTP_UNICAST;
+
+ printf( "\nPTP configuration:\n");
+
+ supports_unicast ? printf( " PTP Role : %s\n", ptp_roles[ptp_settings.settings.ptp_role] ) :
+ printf( " PTP Role : %s\n", ptp_roles[0] );
+
+ 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 )
+ {
+ 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;
+
+ 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 );
+ }
+
+ return MBG_SUCCESS;
+
+} // show_ptp_cfg
+
+
+
+
+static /*HDR*/
+int set_ptp_cfg( MBG_DEV_HANDLE dh, const char *arg, const PCPS_DEV *p_dev )
+{
+ 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 supports_unicast = 0;
+
+ int rc = mbg_get_ptp_cfg_info( dh, &prv_ptp_settings);
+
+ 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 )
+ {
+ 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;
+ }
+ }
+
+ // 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;
+ }
+ }
+
+ // Domain Number
+ cp = strstr( arg, ptp_name_dom );
+
+ if ( cp != NULL )
+ {
+ 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 );
+ }
+
+ // 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 )
+ {
+
+ // PTP role
+ cp = strstr( arg, "ROLE" );
+
+ if ( cp != NULL )
+ {
+ l = strlen("ROLE");
+
+ 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;
+ }
+
+
+ // 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);
+
+ if ( *(cp+l) != ':' )
+ goto fail; // parameter syntax error: name not followed by colon
+
+ l++;
+
+ if ( str_to_ip4_addr( &ip4addr, cp+l ) != NULL )
+ {
+ char ws[50];
+
+ snprint_ip4_addr( ws, sizeof( ws ), &ip4addr );
+ printf( " GM IP Address: %s\n", ws );
+
+ strcpy( ptp_unicast_settings.gm_host, ws );
+ }
+ }
+
+
+ // 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 ) )
+ {
+ printf("Syntax error in specifying 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");
+ }
+ }
+
+
+ // GM Target Port ID
+ cp = strstr( arg, ptp_name_tp_id );
+
+ if ( cp != NULL )
+ {
+ char* p_tail;
+
+ l = strlen( ptp_name_tp_id );
+
+ if ( *(cp+l) != ':' )
+ goto fail; // parameter syntax error: name not followed by colon
+
+ 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 );
+ }
+
+
+ // 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
+
+ l++;
+
+ ptp_unicast_settings.sync_interval = atoi( cp+l );
+ printf( " setting Sync Int: %i\n", ptp_unicast_settings.sync_interval );
+ }
+
+
+ // 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
+
+ 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 );
+
+ if ( *(cp+l) != ':' )
+ goto fail; // parameter syntax error: name not followed by colon
+
+ l++;
+
+ ptp_unicast_settings.delay_request_interval = atoi( cp+l );
+ printf( " setting DelayReq Int: %i\n", ptp_unicast_settings.delay_request_interval );
+ }
+
+
+ // 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
+
+ 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 );
+
+ if ( mbg_ioctl_err( rc, "mbg_set_ptp_cfg_settings" ) )
+ return rc;
+
+
+ if ( supports_unicast )
+ {
+ rc = mbg_set_ptp_unicast_cfg_settings( dh, &ptp_unicast_settings );
+
+ if ( mbg_ioctl_err( rc, "mbg_set_ptp_unicast_cfg_settings" ) )
+ return rc;
+ }
+
+ return MBG_SUCCESS;
+
+fail:
+
+ printf("Syntax error in argument!\n");
+
+ return MBG_ERR_CFG;
+
+} // set_ptp_cfg
+
+
+
+static /*HDR*/
int ip4_check_parm( const char *s, IP4_INFO *p )
{
int l = strlen( p->name );
@@ -894,7 +1319,9 @@ int save_serial_settings( MBG_DEV_HANDLE dh, unsigned int port_num, const char *
for ( i = 0; i < sizeof( p_ps->parm.framing ); i++ )
{
- if ( !isalnum( *cp ) ) // stop copying if non-alpha and non-digit
+ int c = *cp;
+
+ if ( !isalnum( c ) ) // stop copying if non-alpha and non-digit
break;
p_ps->parm.framing[i] = *cp++;
@@ -1374,7 +1801,7 @@ void usage( MBG_DEV_HANDLE dh, PCPS_DEV *p_dev, RECEIVER_INFO *p_ri,
);
printf( " LAN show board's LAN interface settings\n"
- " LAN=DHCP set LAM interface to be configured via DHCP\n"
+ " LAN=DHCP set LAN interface to be configured via DHCP\n"
" LAN=IP:<ip>[,NM:<nm>][,BA:<ba>][,GW:<gw>] set LAN interface to given static settings\n"
"\n"
" where each of <ip>,<nm>,<ba>,<gw> is an IPv4 address of the form aaa.bbb.ccc.ddd, e.g.:\n"
@@ -1392,7 +1819,37 @@ void usage( MBG_DEV_HANDLE dh, PCPS_DEV *p_dev, RECEIVER_INFO *p_ri,
"\n"
);
- printf( " ANT_CABLE_LEN show the configured antenna cable length\n"
+ printf( " PTP show board's PTP settings\n"
+ " PTP=NP:<np>[,DM:<dm>][,DO:<do>][,HW:<hw>] set general PTP protocol parameters\n"
+ "\n"
+ " where, e.g. :\n"
+ " NP:IP4 specifies UDP/IPv4 (Layer 3) as network protocol\n"
+ " NP:ETH specifies IEEE 802.3 (Layer 2) as network protocol\n"
+ " DM:E2E specifies end-to-end delay mechanism\n"
+ " 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"
+ );
+
+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"
+ "\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"
+ " 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"
" 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"
@@ -1413,7 +1870,12 @@ void usage( MBG_DEV_HANDLE dh, PCPS_DEV *p_dev, RECEIVER_INFO *p_ri,
static /*HDR*/
const char *str_parm_p(const char *s, const char *keyword )
{
- return strstr( s, keyword ) ? &s[strlen( keyword )] : NULL;
+ char *match = strstr( s, keyword );
+
+ if ( match && ( match == s ) )
+ return &s[strlen( keyword )];
+ else
+ return NULL;
} // str_parm_p
@@ -1707,7 +2169,41 @@ int check_cmd_line( int argc, char *argv[], MBG_DEV_HANDLE dh, const PCPS_DEV *p
}
- cp = str_parm_p( argv[i], "ANT_CABLE_LEN" );
+ cp = str_parm_p( argv[i], "PTP" );
+
+ if ( cp )
+ {
+ if ( p_dev )
+ {
+ char *info = "Current";
+
+ if ( !_pcps_has_ptp( p_dev ) )
+ {
+ err_msg( p_dev, no_ptp );
+ continue;
+ }
+
+ if ( *cp == '=' )
+ {
+
+ rc = set_ptp_cfg( dh, ++cp, p_dev );
+
+ if ( rc < 0 )
+ {
+ must_print_usage = 1;
+ continue;
+ }
+
+ info = "New";
+
+ }
+
+ show_ptp_cfg( dh, p_dev, info );
+ }
+ continue;
+ }
+
+ cp = str_parm_p( argv[i], "ANT_CABLE_LEN" );
if ( cp )
{
@@ -1821,7 +2317,6 @@ int main( int argc, char *argv[] )
goto fail;
}
-
// get information about the device
rc = mbg_get_show_dev_info( dh, dev_name, &dev );
diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h
index d7156fd..80a4e1d 100755
--- a/mbglib/common/gpsdefs.h
+++ b/mbglib/common/gpsdefs.h
@@ -1,19 +1,33 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.91 2011/01/31 11:23:56 martin REL_M $
+ * $Id: gpsdefs.h 1.91.1.8 2011/02/23 15:11:23 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
* General definitions to be used with Meinberg clocks.
* These definitions have initially be used with GPS devices only.
- * However, more and more Meinberg non-GPS devices also use some of
+ * However, more and more Meinberg non-GPS devices also use some of
* these definitions.
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
- * Revision 1.91 2011/01/31 11:23:56 martin
+ * 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
+ * Made unused PTP_STATE fields num_clients and num_masters reserved.
+ * Revision 1.91.1.6 2011/02/23 14:47:22 martin
+ * Removed trailing whitespace and hard tabs.
+ * Revision 1.91.1.5 2011/02/23 13:17:06 daniel
+ * Revision 1.91.1.4 2011/02/17 14:39:13Z daniel
+ * Account for different PTP roles.
+ * Revision 1.91.1.3 2011/02/15 14:24:53 martin
+ * Revision 1.91.1.2 2011/02/15 11:30:56 martin
+ * New feature GPS_FEAT_PTP_UNICAST.
+ * Revision 1.91.1.1 2011/02/15 10:54:28 daniel
+ * Started to support configuration for PTP unicast.
+ * Revision 1.91 2011/01/31 11:23:56Z martin
* Added model type name definitions for GPS180PEX and TCR180PEX.
* Introduced synthesizer mode for programmable outputs.
* Added IRIG-RX code TXC-101 DTR-6.
@@ -53,10 +67,10 @@
* Revision 1.81 2009/11/09 09:08:24 martin
* New TM_GPS status bit TM_INVT.
* Added definitions to support VLAN.
- * Changed DEFAULT_PTP_DELAY_MECH_MASK to include also
+ * Changed DEFAULT_PTP_DELAY_MECH_MASK to include also
* PTP_DELAY_MECH_MSK_P2P.
* There is now only one type of TCXO supported which matches the former
- * TCXO HQ, so the default name for TCXO HQ has been changed to TCXO.
+ * TCXO HQ, so the default name for TCXO HQ has been changed to TCXO.
* TCXO LQ and MQ names are still supported for backward compatibility.
* Revision 1.80 2009/09/28 14:55:53 martin
* Support IRIG formats G002/G142 and G006/G146.
@@ -73,7 +87,7 @@
* Added macro _nano_time_negative().
* Revision 1.77 2009/06/08 19:22:32Z daniel
* Added feature GPS_HAS_PTP.
- * Added preliminary structures and definitions for PTP
+ * Added preliminary structures and definitions for PTP
* configuration and state.
* Added IP4_ADDR type.
* Added Bitmask IP4_MSK_DHCP.
@@ -86,7 +100,7 @@
* Revision 1.75 2009/03/19 14:06:39Z martin
* Modified string initializer for unknown oscillator type.
* Revision 1.74 2009/03/18 13:45:53 daniel
- * Added missing commas in
+ * Added missing commas in
* MBG_DEBUG_STATUS_STRS initializer.
* Adjusted some comments for doxygen parser.
* Revision 1.73 2009/03/10 16:55:33Z martin
@@ -162,7 +176,7 @@
* Revision 1.52 2006/12/12 15:47:18 martin
* Added MBG_DEBUG_STATUS type and associated definitions.
* Added definition GPS_HAS_REF_OFFS.
- * Moved PCPS_REF_OFFS and associated definitions from pcpsdefs.h here
+ * Moved PCPS_REF_OFFS and associated definitions from pcpsdefs.h here
* and renamed them to MBG_REF_OFFS, etc.
* Revision 1.51 2006/10/23 15:31:27 martin
* Added definitions for GPS170.
@@ -234,7 +248,7 @@
* Added definitions OSC_DAC_RANGE, OSC_DAC_BIAS.
* Revision 1.27 2004/03/08 14:06:45Z martin
* New model code and name for GPS169PCI.
- * Existing feature GPS_FEAT_IRIG has been
+ * Existing feature GPS_FEAT_IRIG has been
* renamed to GPS_FEAT_IRIG_TX.
* Added feature GPS_FEAT_IRIG_RX.
* Added IPv4 LAN interface feature flags.
@@ -319,7 +333,7 @@
#include <config.h>
#endif
-// CLOCK_MEINBERG is defined in NTP's config.h if configured
+// CLOCK_MEINBERG is defined in NTP's config.h if configured
// to support Meinberg clocks.
#if !defined( CLOCK_MEINBERG )
// avoid having to use these headers in non-Meinberg projects
@@ -382,8 +396,8 @@ typedef uint16_t IOD; /* Issue-Of-Data code */
/**
* @brief The type of a GPS command code
*
- * These command codes can be passed via
- * @ref gps_cmds_serial "serial port" (see @file gpsserio.h), or
+ * These command codes can be passed via
+ * @ref gps_cmds_serial "serial port" (see @file gpsserio.h), or
* @ref gps_cmds_bus "system bus" (see @file pcpsdefs.h).
*/
typedef uint16_t GPS_CMD;
@@ -561,9 +575,9 @@ enum
GPS_MODEL_GPS180PEX,
GPS_MODEL_TCR180PEX,
N_GPS_MODEL
- /* If new model codes are added then care must be taken
- * to update the associated string initializers below
- * accordingly, and to check whether the classification macros
+ /* If new model codes are added then care must be taken
+ * to update the associated string initializers below
+ * accordingly, and to check whether the classification macros
* also cover the new model names. */
};
@@ -657,7 +671,7 @@ enum
/*
* The macros below can be used to classify a receiver,
- * e.g. depending on the time source and/or depending on
+ * e.g. depending on the time source and/or depending on
* whether it's a plug-in card or an external device.
*/
@@ -828,6 +842,7 @@ enum
GPS_FEAT_NAV_ENGINE_SETTINGS, /**< supports navigation engine configuration */
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 */
N_GPS_FEATURE /**< the number of valid features */
};
@@ -852,7 +867,8 @@ enum
"PTP/IEEE1588", \
"Nav. Engine Settings", \
"Raw IRIG Data", \
- "Raw IRIG Time" \
+ "Raw IRIG Time", \
+ "PTP/IEEE1588 Unicast" \
}
@@ -879,6 +895,7 @@ enum
#define GPS_HAS_NAV_ENGINE_SETTINGS ( 1UL << GPS_FEAT_NAV_ENGINE_SETTINGS )
#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_REF_OFFS GPS_HAS_IRIG_RX
@@ -953,7 +970,7 @@ typedef struct
-/**
+/**
Date and time referred to the linear time scale defined by GPS.
GPS time is defined by the number of weeks since midnight from
January 5, 1980 to January 6, 1980 plus the number of seconds of
@@ -1035,7 +1052,7 @@ enum
// Type of an extended TM status which is mainly used by the firmware.
typedef uint32_t TM_STATUS_EXT; // extended status, mainly used by the firmware
-// The lower 16 bits of the TM_STATUS_X type correspond to those defined above,
+// The lower 16 bits of the TM_STATUS_X type correspond to those defined above,
// and the upper bits are defined below:
enum
{
@@ -1072,7 +1089,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
+ This structure is used to transmit information on date and time
*/
typedef struct
{
@@ -1143,31 +1160,31 @@ typedef struct
/**
@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
- base 10 exponent (range). If the effective frequency is less than
- 10 kHz its phase is synchronized corresponding to the variable phase.
- Phase may be in a range from -360 deg to +360 deg with a resolution
- of 0.1 deg, so the resulting numbers to be stored are in a range of
- -3600 to +3600.
+ Synthesizer frequency is expressed as a
+ four digit decimal number (freq) to be multiplied by 0.1 Hz and an
+ base 10 exponent (range). If the effective frequency is less than
+ 10 kHz its phase is synchronized corresponding to the variable phase.
+ Phase may be in a range from -360 deg to +360 deg with a resolution
+ of 0.1 deg, so the resulting numbers to be stored are in a range of
+ -3600 to +3600.
Example:<br>
- Assume the value of freq is 2345 (decimal) and the value of phase is 900.
- If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
- If range == 1 the synthesizer will generate a 2345 Hz output frequency
- and so on.
+ Assume the value of freq is 2345 (decimal) and the value of phase is 900.
+ If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
+ If range == 1 the synthesizer will generate a 2345 Hz output frequency
+ and so on.
Limitations:<br>
- If freq == 0 the synthesizer is disabled. If range == 0 the least
- significant digit of freq is limited to 0, 3, 5 or 6. The resulting
- frequency is shown in the examples below:
- - freq == 1230 --> 123.0 Hz
- - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
- - freq == 1235 --> 123.5 Hz
- - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
-
- If range == MAX_RANGE the value of freq must not exceed 1000, so the
- output frequency is limited to 10 MHz.
+ If freq == 0 the synthesizer is disabled. If range == 0 the least
+ significant digit of freq is limited to 0, 3, 5 or 6. The resulting
+ frequency is shown in the examples below:
+ - freq == 1230 --> 123.0 Hz
+ - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
+ - freq == 1235 --> 123.5 Hz
+ - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
+
+ If range == MAX_RANGE the value of freq must not exceed 1000, so the
+ output frequency is limited to 10 MHz.
@{
*/
@@ -1188,20 +1205,20 @@ typedef struct
#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
+/**
+ The synthesizer phase will only be synchronized if the frequency
is below this limit: */
#define SYNTH_PHASE_SYNC_LIMIT 10000UL /**< 10 kHz */
-/**
- the position of the decimal point if the frequency is
- printed as 4 digit value */
+/**
+ the position of the decimal point if the frequency is
+ printed as 4 digit value */
#define _synth_dp_pos_from_range( _r ) \
( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 )
-/**
- An initializer for commonly displayed synthesizer frequency units
- (N_SYNTH_RANGE strings) */
+/**
+ An initializer for commonly displayed synthesizer frequency units
+ (N_SYNTH_RANGE strings) */
#define DEFAULT_FREQ_RANGES \
{ \
"Hz", \
@@ -1229,7 +1246,7 @@ typedef struct
}
-/**
+/**
The definitions below can be used to query the
current synthesizer state.
*/
@@ -1259,14 +1276,14 @@ typedef struct
@defgroup group_tzdl Time zone/daylight saving parameters
Example: <br>
- For automatic daylight saving enable/disable in Central Europe,
+ For automatic daylight saving enable/disable in Central Europe,
the variables are to be set as shown below: <br>
- - offs = 3600L one hour from UTC
- - offs_dl = 3600L one additional hour if daylight saving enabled
- - tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG )
- - tm_off = first Sunday from October 25, 03:00:00h ( year |= DL_AUTO_FLAG )
- - name[0] == "CET " name if daylight saving not enabled
- - name[1] == "CEST " name if daylight saving is enabled
+ - offs = 3600L one hour from UTC
+ - offs_dl = 3600L one additional hour if daylight saving enabled
+ - tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG )
+ - tm_off = first Sunday from October 25, 03:00:00h ( year |= DL_AUTO_FLAG )
+ - name[0] == "CET " name if daylight saving not enabled
+ - name[1] == "CEST " name if daylight saving is enabled
@{
*/
@@ -1292,8 +1309,8 @@ typedef struct
/**
- If the year in tzdl.tm_on and tzdl.tm_off is or'ed with that constant,
- the receiver automatically generates daylight saving year by year.
+ If the year in tzdl.tm_on and tzdl.tm_off is or'ed with that constant,
+ the receiver automatically generates daylight saving year by year.
*/
#define DL_AUTO_FLAG 0x8000
@@ -1306,8 +1323,8 @@ typedef struct
#define DEFAULt_TZDL_OFFS_DL 3600L /**< usually DST is +1 hour */
-/**
- The symbol below can be used to initialize both the tm_on
+/**
+ The symbol below can be used to initialize both the tm_on
and tm_off fields for time zones which do not switch to DST:
*/
#define DEFAULT_TZDL_TM_ON_OFF_NO_DST \
@@ -1330,7 +1347,7 @@ typedef struct
}
-/**
+/**
The symbols below specify beginning and end of DST for
Central Europe, as constituted by the European Parliament:
*/
@@ -1347,8 +1364,8 @@ typedef struct
#define TZ_INFO_CET_CEST_EN "CET/CEST (Central Europe)"
#define TZ_INFO_CET_CEST_DE "MEZ/MESZ (Mitteleuropa)"
-#define DEFAULT_TZDL_NAMES_CET_CEST_EN { "CET ", "CEST " }
-#define DEFAULT_TZDL_NAMES_CET_CEST_DE { "MEZ ", "MESZ " }
+#define DEFAULT_TZDL_NAMES_CET_CEST_EN { "CET ", "CEST " }
+#define DEFAULT_TZDL_NAMES_CET_CEST_DE { "MEZ ", "MESZ " }
#define DEFAULT_TZDL_OFFS_CET 3600L
@@ -1386,8 +1403,8 @@ typedef struct
#define TZ_INFO_EET_EEST_EN "EET/EEST (East Europe)"
#define TZ_INFO_EET_EEST_DE "OEZ/OEST (Osteuropa)"
-#define DEFAULT_TZDL_NAMES_EET_EEST_EN { "EET ", "EEST " }
-#define DEFAULT_TZDL_NAMES_EET_EEST_DE { "OEZ ", "OESZ " }
+#define DEFAULT_TZDL_NAMES_EET_EEST_EN { "EET ", "EEST " }
+#define DEFAULT_TZDL_NAMES_EET_EEST_DE { "OEZ ", "OESZ " }
#define DEFAULT_TZDL_OFFS_EET 7200L
@@ -1412,7 +1429,7 @@ typedef struct
/** @} */ // endgroup
/**
- * The structure below reflects the status of the antenna,
+ * The structure below reflects the status of the antenna,
* the times of last disconnect/reconnect, and the board's
* clock offset after the disconnection interval.
*/
@@ -1433,8 +1450,8 @@ typedef struct
}
-/**
- The status field may be set to one of the values below:
+/**
+ The status field may be set to one of the values below:
*/
enum
{
@@ -1452,8 +1469,8 @@ enum
#define EF_FREQ_ALL 0x07 /**< all fixed freq. outputs on */
#define EF_SYNTH 0x01 /**< synth. on */
-/**
- The structure holds some flags which let
+/**
+ The structure holds some flags which let
the corresponding outputs be disabled after power-up until
the receiver has synchronized (flag == 0x00, the default) or force
the outputs to be enabled immediately after power-up. The fixed
@@ -1707,7 +1724,7 @@ typedef struct
/*
* The definitions below can be used to mark specific fields of a
- * PORT_SETTINGS structure, e.g. when editing build a mask indicating
+ * PORT_SETTINGS structure, e.g. when editing build a mask indicating
* which of the fields have changed or which are not valid.
*/
enum
@@ -1987,7 +2004,7 @@ enum
The following definitions are used to configure an optional
on-board IRIG input or output. Which frame types are supported
- by a device depends on the device type, and may eventually
+ by a device depends on the device type, and may eventually
depend on the device's firmware version.
All IRIG frames transport the day-of-year number plus the time-of-day,
@@ -2021,7 +2038,7 @@ enum
- \b AFNOR: 100 bps, 1 kHz carrier, SBS, complete date
- <b> AFNOR DC:</b> 100 bps, DCLS, SBS, complete date
- \b IEEE1344: 100 bps, 1 kHz carrier, time-of-year, SBS, IEEE1344 extensions (B120)
- - <b> IEEE1344 DC:</b> 100 bps, DCLS, time-of-year, SBS, IEEE1344 extensions (B000)
+ - <b> IEEE1344 DC:</b> 100 bps, DCLS, time-of-year, SBS, IEEE1344 extensions (B000)
- \b C37.118: like IEEE1344, but UTC offset with reversed sign
- \b C37.118 DC: like IEEE1344 DC, but UTC offset with reversed sign
@@ -2693,14 +2710,14 @@ typedef uint32_t MBG_IRIG_CTRL_BITS;
/**
The buffer below can be used to get the raw data bits
- from the IRIG decoder. A maximum number of RAW_IRIG_SIZE
- bytes can be filled. If less bytes are used then the rest
+ from the IRIG decoder. A maximum number of RAW_IRIG_SIZE
+ bytes can be filled. If less bytes are used then the rest
of the bytes are filled with zeros.
The first IRIG bit received from the transmitter is saved
in the MSB (bit 7) of data_bytes[0], etc.
*/
-typedef struct
+typedef struct
{
uint8_t data_bytes[RAW_IRIG_SIZE];
} MBG_RAW_IRIG_DATA;
@@ -2717,14 +2734,14 @@ typedef struct
-/**
- @defgroup group_scale Time Scale Configuration
+/**
+ @defgroup group_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
- be converted to some local time. However, some applications
- prefer TAI or pure GPS time. This can be configured using the
- structures below if the GPS_HAS_TIME_SCALE flag is set in
+ The structures and defines can be used to configure the GPS receiver's
+ basic time scale. By default this is UTC which can optionally
+ be converted to some local time. However, some applications
+ prefer TAI or pure GPS time. This can be configured using the
+ structures below if the GPS_HAS_TIME_SCALE flag is set in
RECEIVER_INFO::features.
@{
*/
@@ -2754,7 +2771,7 @@ enum
-/**
+/**
The fixed time offset between the GPS and TAI time scales, in seconds
*/
#define GPS_TAI_OFFSET 19 /**< [s], TAI = GPS + GPS_TAI_OFFSET */
@@ -3056,9 +3073,9 @@ typedef struct
/**
The structure below holds the current settings
- for a programmable pulse output, plus additional
- informaton on the output's capabilities.
- This can be read by setup programs to allow setup
+ for a programmable pulse output, plus additional
+ informaton on the output's capabilities.
+ This can be read by setup programs to allow setup
of supported features only.
*/
typedef struct
@@ -3108,8 +3125,8 @@ typedef struct
}
-/*
- * The codes below are used with devices which support multiple
+/*
+ * The codes below are used with devices which support multiple
* ref time sources at the same time. The priorities of the
* supported ref time sources is configurable.
*/
@@ -3122,7 +3139,7 @@ enum
{
MULTI_REF_NONE = -1, // nothing, undefined
MULTI_REF_GPS = 0, // standard GPS
- MULTI_REF_10MHZ, // 10 MHz input frequency
+ 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
@@ -3154,7 +3171,7 @@ enum
/*
- * Bit masks used to indicate supported reference sources
+ * Bit masks used to indicate supported reference sources
*/
#define HAS_MULTI_REF_GPS ( 1UL << MULTI_REF_GPS )
#define HAS_MULTI_REF_10MHZ ( 1UL << MULTI_REF_10MHZ )
@@ -3169,16 +3186,16 @@ enum
/*
- * There are 2 different ways to configure multi ref support
- * provided by some devices.
+ * There are 2 different ways to configure multi ref support
+ * provided by some devices.
*
* Newer devices which have the GPS_FEAT_XMULTI_REF flag set
* in RECEIVER_INFO::features support the newer XMULTI_REF_...
* structures which provide a more flexible interface.
*
- * Older devices which have the GPS_FEAT_MULTI_REF flag set
- * support these MULTI_REF_... structures below where
- * the number of supported input sources and priorities
+ * Older devices which have the GPS_FEAT_MULTI_REF flag set
+ * support these MULTI_REF_... structures below where
+ * the number of supported input sources and priorities
* is limited to N_MULTI_REF_PRIO.
*/
@@ -3221,11 +3238,11 @@ typedef uint16_t MULTI_REF_STATUS; /* flag bits as defined below */
/*
- * The bits and associated bit masks below are used with the
- * MULTI_REF_STATUS type. Each bit is set if the associated
+ * The bits and associated bit masks below are used with the
+ * MULTI_REF_STATUS type. Each bit is set if the associated
* condition is true and is reset if the condition is not true:
*/
-enum
+enum
{
WRN_MODULE_MODE, /* selected input mode was invalid, set to default */
WRN_COLD_BOOT, /* GPS is in cold boot mode */
@@ -3253,16 +3270,16 @@ enum
/*
* If the RECEIVER_INFO::features flag GPS_FEAT_XMULTI_REF is set
- * then the following XMULTI_REF_... data structures must be used
+ * then the following XMULTI_REF_... data structures must be used
* instead of the older MULTI_REF_... structures above.
*
* 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
+ * 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
- * time source for each priority level, and retrieve the status
+ *
+ * The structures below are used to configure the individual
+ * time source for each priority level, and retrieve the status
* of the time source at each priority level.
*/
@@ -3298,7 +3315,7 @@ typedef struct
/*
* The structure below contains the XMULTI_REF configuration
- * for a single priority level, plus information on supported
+ * for a single priority level, plus information on supported
* ref time sources, and the number of supported priority levels.
*/
typedef struct
@@ -3339,7 +3356,7 @@ typedef struct
/*
- * The structure below is used to retrieve the the status information
+ * The structure below is used to retrieve the the status information
* of the time source at a specific priority level.
*/
typedef struct
@@ -3351,9 +3368,9 @@ typedef struct
/*
- * Bits used with XMULTI_REF_STATUS.
+ * Bits used with XMULTI_REF_STATUS.
*/
-enum
+enum
{
XMRS_BIT_NOT_SUPP, /* ref type cfg'd for this level is not supported */
XMRS_BIT_NO_CONN, /* input signal is disconnected */
@@ -3381,8 +3398,8 @@ enum
/*
- * An initializer for a XMULTI_REF_STATUS variable
- * with status invalid / not used
+ * An initializer for a XMULTI_REF_STATUS variable
+ * with status invalid / not used
*/
#define XMULTI_REF_STATUS_INVALID \
{ \
@@ -3397,7 +3414,7 @@ enum
/*------------------------------------------------------------------------*/
/*
- * The types below are not used with all devices:
+ * The types below are not used with all devices:
*/
typedef uint16_t ROM_CSUM; /* The ROM checksum */
@@ -3405,18 +3422,18 @@ typedef uint16_t RCV_TIMEOUT; /* [min] (only if HAS_RCV_TIMEOUT) */
typedef uint16_t IGNORE_LOCK; /* (only if GPS_HAS_IGNORE_LOCK) */
/*
- * Originally IGNORE_LOG above has been a boolean value (equal or
+ * Originally IGNORE_LOG above has been a boolean value (equal or
* not equal 0) which was evaluated the same way for all ports.
*
- * Due to special firmware requirements it has been changed to a
- * bit maskable property in order to be able to specify the behaviour
+ * Due to special firmware requirements it has been changed to a
+ * bit maskable property in order to be able to specify the behaviour
* for individual ports.
*
- * In order to keep compatibility with older versions the LSB is used
- * to specify ignore_lock for all ports. The next higher bits are used
- * to specify ignore_lock for an individual port, where the bit position
+ * In order to keep compatibility with older versions the LSB is used
+ * to specify ignore_lock for all ports. The next higher bits are used
+ * to specify ignore_lock for an individual port, where the bit position
* depends on the port number, e.g. 0x02 for COM0, 0x04 for COM1, etc.
- * The macros below can be used to simplify the code:
+ * The macros below can be used to simplify the code:
*/
/* return a bit mask depending on the port number */
@@ -3437,7 +3454,7 @@ typedef uint16_t IGNORE_LOCK; /* (only if GPS_HAS_IGNORE_LOCK) */
/*------------------------------------------------------------------------*/
/*
- * The structures below are used with the SCU multiplexer board
+ * The structures below are used with the SCU multiplexer board
* in a redundant system:
*/
@@ -3446,13 +3463,13 @@ typedef struct
uint32_t hw_id; // hardware identification
uint32_t fw_id; // firmware identification
uint16_t flags; // reserved currently 0
- uint8_t clk0_info; // reference clock 0 type
- uint8_t clk1_info; // reference clock 1 type
+ uint8_t clk0_info; // reference clock 0 type
+ uint8_t clk1_info; // reference clock 1 type
uint16_t epld_status; // epld status word, see defintions below
uint16_t epld_control; // epld control word, see defintions below
} SCU_STAT_INFO;
-typedef struct
+typedef struct
{
uint16_t epld_control_mask; // control mask, determines which bit is to be changed
uint16_t epld_control_value; // control value, determines value of bits to be changed
@@ -3483,7 +3500,7 @@ typedef struct
* Definitions for clk0_info and clk1_info, can be used to determine
* the reference clock type connected to SCU input channel 0 and 1:
*/
-enum
+enum
{
SCU_CLK_INFO_GPS, // ref. clock is GPS receiver
SCU_CLK_INFO_DCF_PZF, // ref. clock is DCF77 PZF receiver
@@ -3626,7 +3643,7 @@ enum
#define MAX_USED_SATS 32
/*
- The structure below allos to transfer
+ The structure below allos to transfer
SV information from a certain GNSS type.
*/
typedef struct
@@ -3635,7 +3652,7 @@ typedef struct
uint8_t reserved;
uint16_t good_svs;
uint16_t svs_in_view;
- uint8_t svs[MAX_USED_SATS];
+ uint8_t svs[MAX_USED_SATS];
} GNSS_SAT_INFO;
#define _mbg_swab_gnss_sat_info( _p ) \
@@ -3665,7 +3682,7 @@ typedef struct
}
/**
- * The type below is used to configure the length of the
+ * The type below is used to configure the length of the
* antenna cable in [m]:
*/
typedef uint16_t ANT_CABLE_LEN;
@@ -3795,7 +3812,7 @@ typedef struct
/* codes used with LAN_IF_INFO::type: */
-enum
+enum
{
LAN_IF_TYPE_XPORT,
LAN_IF_TYPE_PTP,
@@ -3854,6 +3871,16 @@ enum
}
+#define PTP_NW_PROT_STRS_SHORT \
+{ \
+ "RES", \
+ "IP4", \
+ "IP6", \
+ "ETH", \
+ "DN", \
+ "CN", \
+ "PN" \
+}
enum
{
@@ -4000,6 +4027,25 @@ enum
+enum
+{
+ PTP_ROLE_MULTICAST_SLAVE,
+ PTP_ROLE_UNICAST_SLAVE,
+ PTP_ROLE_MULTICAST_MASTER,
+ PTP_ROLE_UNICAST_MASTER,
+ N_PTP_ROLES
+};
+
+
+#define PTP_ROLE_STRS \
+{ \
+ "Multicast Slave", \
+ "Unicast Slave", \
+ "Multicast Master", \
+ "Unicast Master" \
+}
+
+
/* PTP configuration stuff */
@@ -4008,6 +4054,8 @@ typedef struct
uint8_t b[8];
} PTP_CLOCK_IDENTITY;
+#define _mbg_swab_ptp_clock_identity( _p ) _nop_macro_fnc() // nothing to swap
+
typedef struct
@@ -4027,8 +4075,8 @@ typedef struct
uint8_t clock_class;
uint8_t clock_accuracy; // enum
- uint32_t num_clients;
- uint32_t num_masters;
+ uint32_t reserved_1;
+ uint32_t reserved_2;
uint8_t domain_number;
uint8_t time_source; // enum
@@ -4038,7 +4086,7 @@ typedef struct
int16_t utc_offset;
DAC_VAL osc_dac_cal;
- uint32_t reserved;
+ uint32_t reserved_3;
} PTP_STATE;
#define _mbg_swab_ptp_state( _p ) \
@@ -4049,6 +4097,7 @@ typedef struct
_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_swab16( &(_p)->clock_offset_scaled_log_variance ); \
_mbg_swab32( &(_p)->num_clients ); \
_mbg_swab32( &(_p)->num_masters ); \
@@ -4064,6 +4113,7 @@ enum
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
};
@@ -4072,6 +4122,7 @@ enum
#define PTP_FLAG_MSK_TIMESCALE_IS_PTP ( 1UL << PTP_FLAG_BIT_TIMESCALE_IS_PTP )
#define PTP_FLAG_MSK_LS_ANN ( 1UL << PTP_FLAG_BIT_LS_ANN )
#define PTP_FLAG_MSK_LS_ANN_NEG ( 1UL << PTP_FLAG_BIT_LS_ANN_NEG )
+#define PTP_FLAG_MSK_IS_UNICAST ( 1UL << PTP_FLAG_BIT_IS_UNICAST )
#define PTP_SYNC_INTERVAL_MIN -6
@@ -4080,6 +4131,15 @@ enum
#define PTP_DELAY_REQ_INTERVAL_MIN -6
#define PTP_DELAY_REQ_INTERVAL_MAX 6
+#define PTP_DEFAULT_UNICAST_SYNC_INTERVAL_MIN -4
+#define PTP_DEFAULT_UNICAST_SYNC_INTERVAL_MAX 4
+
+#define PTP_DEFAULT_UNICAST_DELAY_REQ_INTERVAL_MIN -4
+#define PTP_DEFAULT_UNICAST_DELAY_REQ_INTERVAL_MAX 4
+
+#define PTP_DEFAULT_UNICAST_ANNOUNCE_INTERVAL_MIN -4
+#define PTP_DEFAULT_UNICAST_ANNOUNCE_INTERVAL_MAX 4
+
typedef struct
{
@@ -4088,7 +4148,7 @@ typedef struct
uint8_t domain_number; // 0:3
uint8_t delay_mechanism; // 0 (E2E) or 1 (P2P), unless disabled
- uint8_t reserved_0;
+ 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;
@@ -4104,8 +4164,8 @@ typedef struct
int16_t announce_interval; // log 2
int16_t delay_request_interval; // log 2
- 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; // [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 reserved_3; // currently always 0
uint32_t flags; // (see below)
@@ -4170,11 +4230,92 @@ enum
{
PTP_CFG_BIT_TIME_SCALE_IS_PTP, // time scale is PTP/TAI, else arbitrary
PTP_CFG_BIT_V1_HW_COMPAT,
- N_PTP_CFG_BIT
+ PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE,
+ PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER,
+ PTP_CFG_BIT_CAN_BE_UNICAST_MASTER
};
-#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
-#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_BIT_V1_HW_COMPAT )
+#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
+#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_BIT_V1_HW_COMPAT )
+#define PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE ( 1UL << PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE )
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER ( 1UL << PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER )
+#define PTP_CFG_MSK_CAN_BE_UNICAST_MASTER ( 1UL << PTP_CFG_BIT_CAN_BE_UNICAST_MASTER )
+
+
+#define PTP_CFG_MSK_SUPPORT_PTP_ROLES ( PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE | \
+ PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER | \
+ PTP_CFG_MSK_CAN_BE_UNICAST_MASTER )
+
+#define PTP_CFG_MSK_SUPPORT_PTP_UNICAST ( PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE | \
+ PTP_CFG_MSK_CAN_BE_UNICAST_MASTER )
+
+
+// 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.
+typedef char MBG_HOSTNAME[256];
+
+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 ); \
+}
+
+
+
+typedef struct
+{
+ PTP_UNICAST_CFG_SETTINGS settings;
+
+ 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
+
+ uint32_t supported_flags;
+ uint32_t reserved;
+
+} 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 ); \
+}
@@ -4344,7 +4485,7 @@ enum
GPS_PLATFORM_AIRBORNE_4G,
N_GPS_PLATFORMS
};
-
+
#define GPS_PLATFORM_STRS \
{ \
@@ -4365,11 +4506,11 @@ enum
{
TIME_MODE_DISABLED,
TIME_MODE_SURVEY_IN,
- TIME_MODE_FIXED
+ TIME_MODE_FIXED
};
-
+
typedef struct
{
uint32_t time_mode;
@@ -4384,12 +4525,12 @@ typedef struct
} NAV_TIME_MODE_SETTINGS;
-/**
- Navigation Engine settings to set configuration
+/**
+ Navigation Engine settings to set configuration
parameters of a dynamic platform model.
*/
typedef struct
-{
+{
uint8_t dynamic_platform;
uint8_t fix_mode;
int8_t min_elevation;
diff --git a/mbglib/common/macioctl.h b/mbglib/common/macioctl.h
index d46dcf5..fb85639 100755
--- a/mbglib/common/macioctl.h
+++ b/mbglib/common/macioctl.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: macioctl.h 1.33.1.7 2011/01/26 16:37:55 martin TEST $
+ * $Id: macioctl.h 1.33.1.13 2011/03/23 16:50:30 martin TRASH martin $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,21 @@
*
* -----------------------------------------------------------------------
* $Log: macioctl.h $
+ * Revision 1.33.1.13 2011/03/23 16:50:30 martin
+ * Support NetBSD beside FreeBSD.
+ * Revision 1.33.1.12 2011/03/21 16:25:23 martin
+ * Account for modified _pcpc_kfree().
+ * Revision 1.33.1.11 2011/03/02 09:59:50 daniel
+ * Bug fix: Use PCPS_TIME_STAMP with
+ * IOCTL_GET_FAST_HR_TIMESTAMP as output size.
+ * Revision 1.33.1.10 2011/02/15 14:50:39Z martin
+ * In a call to retrieve RECEIVER_INFO don't read from device
+ * but just copy the field from the device info structure.
+ * Revision 1.33.1.9 2011/02/15 11:08:33 daniel
+ * Preliminary support for PTP unicast
+ * Revision 1.33.1.8 2011/02/09 17:08:27Z martin
+ * Specify I/O range number when calling port I/O macros
+ * so they can be used for different ranges under BSD.
* Revision 1.33.1.7 2011/01/26 16:37:55 martin
* Modified inline declarations for gcc.
* Revision 1.33.1.6 2011/01/24 17:08:40 martin
@@ -215,7 +230,7 @@ typedef struct
#define _io_unmap_mapped_mem_address( _pddev, _pin ) \
_nop_macro_fnc()
-#elif defined( MBG_TGT_BSD )
+#elif defined( MBG_TGT_FREEBSD )
#include <sys/malloc.h>
@@ -237,6 +252,36 @@ typedef struct
#define _io_unmap_mapped_mem_address( _pddev, _pin ) \
goto err_inval
+#elif defined( MBG_TGT_NETBSD )
+
+ #include <sys/malloc.h>
+
+ #define _pcps_iob( _type, _s ) _type _s
+ #define _pcps_iob_arr( _type, _s, n ) _type _s[_n]
+
+ int
+ copyin(const void *uaddr, void *kaddr, size_t len); // to from user to kernel
+
+ int
+ copyout(const void *kaddr, void *uaddr, size_t len); // from kernel to user
+
+ #define _pcps_iob_to_pout_size( _type, _iob, _pout, _size ) \
+ if ( copyout( (_type *)(_pout), &(_iob), _size ) ) \
+ goto err_to_user;
+
+ #define _pcps_iob_from_pin_size( _type, _iob, _pin, _size ) \
+ if ( copyin( &(_iob), (_type *) (_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 ) \
+ goto err_inval
+
+ #define _io_unmap_mapped_mem_address( _pddev, _pin ) \
+ goto err_inval
+
#elif defined( MBG_TGT_WIN32 )
#define _pcps_iob( _type, _s ) _type _s
@@ -493,19 +538,19 @@ typedef struct
#define _mbg_dbg_set_bit( _d, _v ) \
{ \
mbg_dbg_data |= (_v); \
- _mbg_outp8( (_d), mbg_dbg_port_mapped, mbg_dbg_data ); \
+ _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
#define _mbg_dbg_clr_bit( _d, _v ) \
{ \
mbg_dbg_data &= ~(_v); \
- _mbg_outp8( (_d), mbg_dbg_port_mapped, mbg_dbg_data ); \
+ _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
#define _mbg_dbg_clr_all( _d ) \
{ \
mbg_dbg_data = 0; \
- _mbg_outp8( (_d), mbg_dbg_port_mapped, mbg_dbg_data ); \
+ _mbg_outp8( (_d), 0, mbg_dbg_port_mapped, mbg_dbg_data ); \
}
@@ -731,7 +776,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
buffer_size );
}
- _pcps_kfree( p_buff );
+ _pcps_kfree( p_buff, buffer_size );
if ( rc != MBG_SUCCESS )
goto err_access;
@@ -762,7 +807,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
(uint8_t) ctl.data_size_in );
_pcps_sem_dec( pddev );
- _pcps_kfree( p_buff );
+ _pcps_kfree( p_buff, buffer_size );
if ( rc != MBG_SUCCESS )
goto err_access;
@@ -797,7 +842,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
buffer_size );
}
- _pcps_kfree( p_buff );
+ _pcps_kfree( p_buff, buffer_size );
if ( rc != MBG_SUCCESS )
goto err_access;
@@ -828,7 +873,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
(uint8_t) ctl.data_size_in );
_pcps_sem_dec( pddev );
- _pcps_kfree( p_buff );
+ _pcps_kfree( p_buff, buffer_size );
if ( rc != MBG_SUCCESS )
goto err_access;
@@ -1099,9 +1144,10 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
case IOCTL_GET_GPS_RECEIVER_INFO:
- _io_read_gps_var_chk( pddev, PC_GPS_RECEIVER_INFO,
- RECEIVER_INFO, pout,
- _pcps_ddev_has_receiver_info( pddev ) );
+ _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 ) );
break;
@@ -1387,7 +1433,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
sizeof( p_buff->ctl ) + ctl.data_size_out );
}
- _pcps_kfree( p_buff );
+ _pcps_kfree( p_buff, buffer_size );
if ( rc != MBG_SUCCESS )
goto err_access;
@@ -1553,7 +1599,7 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
do_get_fast_hr_timestamp_safe( pddev, &_s );
rc = MBG_SUCCESS;
- _pcps_iob_to_pout( PCPS_TIME_STAMP_CYCLES, _s, pout );
+ _pcps_iob_to_pout( PCPS_TIME_STAMP, _s, pout );
}
break;
@@ -1691,6 +1737,25 @@ int ioctl_switch( PCPS_DDEV *pddev, int ioctl_code,
break;
+ case IOCTL_DEV_HAS_PTP_UNICAST:
+ _report_cond( _pcps_ddev_has_ptp_unicast( pddev ), pout );
+ break;
+
+
+ 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;
+
+
+ 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;
+
+
case IOCTL_GET_TIME_INFO_HRT:
{
_pcps_iob( MBG_TIME_INFO_HRT, _s );
@@ -1801,7 +1866,7 @@ err_access:
return rc; // return the rc from the low level routine
-#if defined( MBG_TGT_LINUX )
+#if defined( MBG_TGT_LINUX ) || defined( MBG_TGT_NETBSD )
err_to_user:
return -EFAULT;
diff --git a/mbglib/common/mbg_arch.h b/mbglib/common/mbg_arch.h
index ae42ad7..cdf6f01 100755
--- a/mbglib/common/mbg_arch.h
+++ b/mbglib/common/mbg_arch.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_arch.h 1.3 2009/06/12 13:12:37 martin REL_M $
+ * $Id: mbg_arch.h 1.3.1.2 2011/02/09 15:46:48 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_arch.h $
- * Revision 1.3 2009/06/12 13:12:37 martin
+ * 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
* Fixed compiler warning.
* Revision 1.2 2009/03/19 15:14:15 martin
* Fixed byte swapping of doubles for SPARC architecture.
@@ -24,6 +26,10 @@
#include <mbg_tgt.h>
+#if !defined( MBG_TGT_KERNEL )
+ #include <stdlib.h>
+#endif
+
#if defined( MBG_ARCH_SPARC )
#define MBG_ARCH_BIG_ENDIAN 1
@@ -40,7 +46,7 @@
#include <asm/byteorder.h>
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
#include <asm/unaligned.h>
#define _mbg_put_unaligned( _v, _p ) put_unaligned( _v, _p )
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index edfec15..a3c45d1 100755
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.22.2.8 2011/02/04 10:15:54 martin TEST $
+ * $Id: mbg_tgt.h 1.22.2.11 2011/03/22 10:25:26 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.22.2.8 2011/02/04 10:15:54 martin
+ * Revision 1.22.2.11 2011/03/22 10:25:26 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
+ * Revision 1.22.2.8 2011/02/04 10:15:54Z martin
* Revision 1.22.2.7 2011/02/01 17:11:54 martin
* Revision 1.22.2.6 2011/01/27 16:16:28 martin
* Support wchar_t for BSD.
@@ -163,6 +167,10 @@
#define MBG_TGT_LINUX
#define _GNU_SOURCE 1
+ #if defined( __KERNEL__ )
+ #define MBG_TGT_KERNEL
+ #endif
+
#elif defined( __FreeBSD__ )
// GCC for target FreeBSD
@@ -175,7 +183,7 @@
#elif defined( __OpenBSD__ )
- // GCC for target FreeBSD
+ // GCC for target OpenBSD
#define MBG_TGT_OPENBSD
#elif defined( __QNX__ )
@@ -272,6 +280,11 @@
|| defined( MBG_TGT_NETBSD ) \
|| defined( MBG_TGT_OPENBSD )
#define MBG_TGT_BSD
+
+ #if defined( _KERNEL )
+ #define MBG_TGT_KERNEL
+ #endif
+
#endif
#if defined( MBG_TGT_LINUX ) \
@@ -394,7 +407,7 @@
// However, some functions may be missing (e.g. snwprintf()).
#if !defined( _WCHAR_T ) /* BC3.1 */ \
&& !defined( _WCHAR_T_DEFINED_ ) /* WC11 */
- //##++ #define _WCHAR_T
+ #define _WCHAR_T
#define wchar_t char
#endif
#endif
diff --git a/mbglib/common/mbgdevio.c b/mbglib/common/mbgdevio.c
index c3cafb8..e4f8c8b 100755
--- a/mbglib/common/mbgdevio.c
+++ b/mbglib/common/mbgdevio.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.c 1.35.1.11 2011/02/01 15:08:08 martin TEST $
+ * $Id: mbgdevio.c 1.35.1.15 2011/02/16 10:15:13 martin TRASH martin(2011.02.16.10.15.13) $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.c $
+ * Revision 1.35.1.15 2011/02/16 10:15:13 martin
+ * Revision 1.35.1.14 2011/02/15 14:24:55Z martin
+ * Revision 1.35.1.13 2011/02/15 11:21:47 daniel
+ * Added API calls to support PTP unicast.
+ * Revision 1.35.1.12 2011/02/09 17:08:28Z martin
+ * Specify I/O range number when calling port I/O macros
+ * so they can be used for different ranges under BSD.
* Revision 1.35.1.11 2011/02/01 15:08:08 martin
* Revision 1.35.1.10 2011/01/28 09:33:21 martin
* Modifications to support FreeBSD.
@@ -581,12 +588,20 @@ typedef struct
_mbgdevio_read_var( _dh, -1, _ioctl, _p ); \
return _mbgdevio_ret_val; \
}
+
+ #define _mbgdevio_query_ri_cond _mbgdevio_query_cond
#else
#define _mbgdevio_query_cond( _dh, _cond, _ioctl, _p ) \
{ \
*p = _cond( _dh ); \
return MBG_SUCCESS; \
}
+
+ #define _mbgdevio_query_ri_cond( _dh, _cond, _ioctl, _p ) \
+ { \
+ *p = _cond( &(_dh)->ri ); \
+ return MBG_SUCCESS; \
+ }
#endif
@@ -3357,13 +3372,9 @@ _MBG_API_ATTR int _MBG_API mbg_setup_receiver_info( MBG_DEV_HANDLE dh,
}
if ( _pcps_is_gps( pdev ) )
- { // keep braces due to the macro call!
_setup_default_receiver_info_gps( p );
- }
else
- { // keep braces due to the macro call!
_setup_default_receiver_info_dcf( p, pdev );
- }
check:
// Make sure this program supports at least as many ports as
@@ -3577,7 +3588,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_asic_version( MBG_DEV_HANDLE dh, PCI_ASIC_VER
if ( !_pcps_ddev_has_asic_version( dh ) )
return _mbg_err_to_os( MBG_ERR_NOT_SUPP_BY_DEV );
- *p = _mbg_inp32_to_cpu( dh, _pcps_ddev_io_base_mapped( dh, 0 )
+ *p = _mbg_inp32_to_cpu( dh, 0, _pcps_ddev_io_base_mapped( dh, 0 )
+ offsetof( PCI_ASIC, raw_version ) );
return MBG_SUCCESS;
@@ -3615,7 +3626,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_asic_features( MBG_DEV_HANDLE dh,
return _mbg_err_to_os( MBG_ERR_NOT_SUPP_BY_DEV );
}
- *p = _mbg_inp32_to_cpu( dh, _pcps_ddev_io_base_mapped( dh, 0 )
+ *p = _mbg_inp32_to_cpu( dh, 0, _pcps_ddev_io_base_mapped( dh, 0 )
+ offsetof( PCI_ASIC, features ) );
return MBG_SUCCESS;
@@ -5183,8 +5194,29 @@ _MBG_API_ATTR int _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p )
/*HDR*/
/**
+ Check if a specific device provides PTP Unicast feature/configuration.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_ptp_state()
+ @see mbg_get_ptp_unicast_cfg_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 )
+{
+ _mbgdevio_query_ri_cond( dh, _pcps_has_ri_ptp_unicast, IOCTL_DEV_HAS_PTP_UNICAST, p );
+
+} // mbg_dev_has_ptp_unicast
+
+
+
+/*HDR*/
+/**
Read PTP/IEEE1588 status from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device
@@ -5212,7 +5244,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_ptp_state( MBG_DEV_HANDLE dh, PTP_STATE *p )
/*HDR*/
/**
Read PTP/IEEE1588 config info and current settings from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device
@@ -5240,7 +5272,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_ptp_cfg_info( MBG_DEV_HANDLE dh, PTP_CFG_INFO
/*HDR*/
/**
Write PTP/IEEE1588 configuration settings to a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device.
@@ -5272,6 +5304,67 @@ _MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh,
/*HDR*/
/**
+ Read PTP/IEEE1588 unicast config info and current settings from a card which supports this.
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_UNICAST_CFG_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @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 )
+{
+ _mbgdevio_vars();
+ _mbgdevio_read_gps_var_chk( dh, PC_GPS_PTP_UNICAST_CFG,
+ IOCTL_GET_PTP_UNICAST_CFG_INFO, p,
+ _pcps_has_ri_ptp_unicast( &dh->ri ) );
+ _mbg_swab_ptp_unicast_cfg_info( p );
+ return _mbgdevio_ret_val;
+
+} // mbg_get_ptp_unicast_cfg_info
+
+
+
+/*HDR*/
+/**
+ Write PTP/IEEE1588 unicast configuration settings to a card which supports this.
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p ::PTP_UNICAST_CFG_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp_unicast()
+ @see mbg_get_ptp_state()
+ @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 )
+{
+ _mbgdevio_vars();
+ #if defined( MBG_ARCH_BIG_ENDIAN )
+ PTP_UNICAST_CFG_SETTINGS tmp = *p;
+ _mbg_swab_ptp_unicast_cfg_settings( &tmp );
+ p = &tmp;
+ #endif
+ _mbgdevio_write_gps_var_chk( dh, PC_GPS_PTP_UNICAST_CFG,
+ IOCTL_SET_PTP_UNICAST_CFG_SETTINGS, p,
+ _pcps_ddev_has_ptp_unicast( dh ) );
+ return _mbgdevio_ret_val;
+
+} // mbg_set_ptp_unicast_cfg_settings
+
+
+
+/*HDR*/
+/**
Read system time and card time from the kernel driver. The kernel
driver reads the current system time plus a HR time structure from
a card immediately after each other. The returned info structure also
diff --git a/mbglib/common/mbgdevio.h b/mbglib/common/mbgdevio.h
index 4b4de15..d1910e7 100755
--- a/mbglib/common/mbgdevio.h
+++ b/mbglib/common/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.39.1.11 2011/02/02 12:21:39 martin TEST $
+ * $Id: mbgdevio.h 1.39.1.13 2011/02/15 14:26:22 martin TRASH martin(2011.02.16.09.52.26) $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
- * Revision 1.39.1.11 2011/02/02 12:21:39 martin
+ * Revision 1.39.1.13 2011/02/15 14:26:22 martin
+ * Revision 1.39.1.12 2011/02/15 11:22:29 daniel
+ * Updated function prototypes to support PTP unicast configuration
+ * Revision 1.39.1.11 2011/02/02 12:21:39Z martin
* Fixed a type.
* Revision 1.39.1.10 2011/01/28 09:33:45 martin
* Cosmetics.
@@ -2701,8 +2704,22 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p ) ;
/**
+ Check if a specific device provides PTP Unicast feature/configuration.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_ptp_state()
+ @see mbg_get_ptp_unicast_cfg_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 ) ;
+
+ /**
Read PTP/IEEE1588 status from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device
@@ -2718,7 +2735,7 @@ extern "C" {
/**
Read PTP/IEEE1588 config info and current settings from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device
@@ -2734,7 +2751,7 @@ extern "C" {
/**
Write PTP/IEEE1588 configuration settings to a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
check whether this call is supported by a specific card.
@param dh Valid handle to a Meinberg device.
@@ -2749,6 +2766,38 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p ) ;
/**
+ Read PTP/IEEE1588 unicast config info and current settings from a card which supports this.
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_UNICAST_CFG_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @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 ) ;
+
+ /**
+ Write PTP/IEEE1588 unicast configuration settings to a card which supports this.
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p ::PTP_UNICAST_CFG_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp_unicast()
+ @see mbg_get_ptp_state()
+ @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 ) ;
+
+ /**
Read system time and card time from the kernel driver. The kernel
driver reads the current system time plus a HR time structure from
a card immediately after each other. The returned info structure also
diff --git a/mbglib/common/mbggenio.h b/mbglib/common/mbggenio.h
index a325203..0d6c1ef 100755
--- a/mbglib/common/mbggenio.h
+++ b/mbglib/common/mbggenio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbggenio.h 1.5.1.2 2011/02/01 12:12:18 martin TEST $
+ * $Id: mbggenio.h 1.5.1.3 2011/02/09 17:08:30 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbggenio.h $
+ * Revision 1.5.1.3 2011/02/09 17:08:30 martin
+ * Specify I/O range number when calling port I/O macros
+ * so they can be used for different ranges under BSD.
* Revision 1.5.1.2 2011/02/01 12:12:18 martin
* Revision 1.5.1.1 2011/01/31 17:29:26 martin
* Account for modified resource handling under *BSD.
@@ -51,21 +54,21 @@ extern "C" {
#if defined( MBG_TGT_LINUX )
#if MBG_USE_MM_IO_FOR_PCI
- #define _mbg_inp8( _d, _p ) ( readb( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( readw( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( readl( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( readb( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( readw( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( readl( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) writeb( (_v), (_p) )
- #define _mbg_outp16( _d, _p, _v ) writew( (_v), (_p) )
- #define _mbg_outp32( _d, _p, _v ) writel( (_v), (_p) )
+ #define _mbg_outp8( _d, _i, _p, _v ) writeb( (_v), (_p) )
+ #define _mbg_outp16( _d, _i, _p, _v ) writew( (_v), (_p) )
+ #define _mbg_outp32( _d, _i, _p, _v ) writel( (_v), (_p) )
#else
- #define _mbg_inp8( _d, _p ) ( (uint8_t) inb( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) inw( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) inl( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) inb( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) inw( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) inl( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) outb( (_v), (_p) )
- #define _mbg_outp16( _d, _p, _v ) outw( (_v), (_p) )
- #define _mbg_outp32( _d, _p, _v ) outl( (_v), (_p) )
+ #define _mbg_outp8( _d, _i, _p, _v ) outb( (_v), (_p) )
+ #define _mbg_outp16( _d, _i, _p, _v ) outw( (_v), (_p) )
+ #define _mbg_outp32( _d, _i, _p, _v ) outl( (_v), (_p) )
#endif
#elif defined( MBG_TGT_BSD )
@@ -74,29 +77,29 @@ extern "C" {
#include <sys/bus.h>
#include <machine/bus.h>
- #define _mbg_inp8( _d, _p ) ( (uint8_t) bus_space_read_1( ( (_d)->rsrc_info.port[0].bsd.bst ), \
- ( (_d)->rsrc_info.port[0].bsd.bsh ), (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) bus_space_read_2( ( (_d)->rsrc_info.port[0].bsd.bst ), \
- ( (_d)->rsrc_info.port[0].bsd.bsh ), (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) bus_space_read_4( ( (_d)->rsrc_info.port[0].bsd.bst), \
- ( (_d)->rsrc_info.port[0].bsd.bsh ), (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) bus_space_read_1( ( (_d)->rsrc_info.port[_i].bsd.bst ), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) bus_space_read_2( ( (_d)->rsrc_info.port[_i].bsd.bst ), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) bus_space_read_4( ( (_d)->rsrc_info.port[_i].bsd.bst), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) bus_space_write_1( ( (_d)->rsrc_info.port[0].bsd.bst ), \
- ((_d)->rsrc_info.port[0].bsd.bsh ), (_p), (_v) )
- #define _mbg_outp16( _d, _p, _v ) bus_space_write_2( ( (_d)->rsrc_info.port[0].bsd.bst ), \
- ((_d)->rsrc_info.port[0].bsd.bsh ), (_p), (_v) )
- #define _mbg_outp32( _d, _p, _v ) bus_space_write_4( ( (_d)->rsrc_info.port[0].bsd.bst ), \
- ((_d)->rsrc_info.port[0].bsd.bsh ), (_p), (_v) )
+ #define _mbg_outp8( _d, _i, _p, _v ) bus_space_write_1( ( (_d)->rsrc_info.port[_i].bsd.bst ), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) bus_space_write_2( ( (_d)->rsrc_info.port[_i].bsd.bst ), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) bus_space_write_4( ( (_d)->rsrc_info.port[_i].bsd.bst ), \
+ ( (_d)->rsrc_info.port[_i].bsd.bsh ), (_p), (_v) )
#elif defined( MBG_TGT_WIN32 )
- #define _mbg_inp8( _d, _p ) ( (uint8_t) inp( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) inpw( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) inpd( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) inp( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) inpw( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) inpd( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) outp( (_p), (_v) )
- #define _mbg_outp16( _d, _p, _v ) outpw( (_p), (_v) )
- #define _mbg_outp32( _d, _p, _v ) outpd( (_p), (_v) )
+ #define _mbg_outp8( _d, _i, _p, _v ) outp( (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) outpw( (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) outpd( (_p), (_v) )
#elif defined( MBG_TGT_DOS ) || defined( MBG_TGT_NETWARE ) || defined( MBG_TGT_OS2 )
@@ -106,13 +109,13 @@ extern "C" {
#include <xportio.h>
#endif
- #define _mbg_inp8( _d, _p ) ( (uint8_t) inp( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) inpw( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) inpd( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) inp( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) inpw( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) inpd( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) outp( (_p), (_v) )
- #define _mbg_outp16( _d, _p, _v ) outpw( (_p), (_v) )
- #define _mbg_outp32( _d, _p, _v ) outpd( (_p), (_v) )
+ #define _mbg_outp8( _d, _i, _p, _v ) outp( (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) outpw( (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) outpd( (_p), (_v) )
#elif defined( MBG_TGT_QNX )
@@ -124,13 +127,13 @@ extern "C" {
// to remap the ports, otherwise a segmentation fault will occur if
// the port I/O functions are being called.
- #define _mbg_inp8( _d, _p ) ( (uint8_t) in8( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) in16( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) in32( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) in8( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) in16( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) in32( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) out8( (_p), (_v) )
- #define _mbg_outp16( _d, _p, _v ) out16( (_p), (_v) )
- #define _mbg_outp32( _d, _p, _v ) out32( (_p), (_v) )
+ #define _mbg_outp8( _d, _i, _p, _v ) out8( (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) out16( (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) out32( (_p), (_v) )
#else // compiling for QNX 4
@@ -140,13 +143,13 @@ extern "C" {
// which should match the calls used in the mbglib functions.
#include <conio.h>
- #define _mbg_inp8( _d, _p ) ( (uint8_t) inp( (_p) ) )
- #define _mbg_inp16( _d, _p ) ( (uint16_t) inpw( (_p) ) )
- #define _mbg_inp32( _d, _p ) ( (uint32_t) inpd( (_p) ) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) inp( (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) inpw( (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) inpd( (_p) ) )
- #define _mbg_outp8( _d, _p, _v ) outp( (_p), (_v) )
- #define _mbg_outp16( _d, _p, _v ) outpw( (_p), (_v) )
- #define _mbg_outp32( _d, _p, _v ) outpd( (_p), (_v) )
+ #define _mbg_outp8( _d, _i, _p, _v ) outp( (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) outpw( (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) outpd( (_p), (_v) )
#endif
@@ -156,11 +159,11 @@ extern "C" {
-#define _mbg_inp16_to_cpu( _d, _p ) _mbg16_to_cpu( _mbg_inp16( (_d), (_p) ) )
-#define _mbg_inp32_to_cpu( _d, _p ) _mbg32_to_cpu( _mbg_inp32( (_d), (_p) ) )
+#define _mbg_inp16_to_cpu( _d, _i, _p ) _mbg16_to_cpu( _mbg_inp16( (_d), (_i), (_p) ) )
+#define _mbg_inp32_to_cpu( _d, _i, _p ) _mbg32_to_cpu( _mbg_inp32( (_d), (_i), (_p) ) )
-#define _mbg_outp16_to_mbg( _d, _p, _v ) _mbg_outp16( (_d), (_p), _cpu_to_mbg16( (_v) ) )
-#define _mbg_outp32_to_mbg( _d, _p, _v ) _mbg_outp32( (_d), (_p), _cpu_to_mbg32( (_v) ) )
+#define _mbg_outp16_to_mbg( _d, _i, _p, _v ) _mbg_outp16( (_d), (_i), (_p), _cpu_to_mbg16( (_v) ) )
+#define _mbg_outp32_to_mbg( _d, _i, _p, _v ) _mbg_outp32( (_d), (_i), (_p), _cpu_to_mbg32( (_v) ) )
diff --git a/mbglib/common/mbgioctl.h b/mbglib/common/mbgioctl.h
index c2150e7..e4f94f0 100755
--- a/mbglib/common/mbgioctl.h
+++ b/mbglib/common/mbgioctl.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgioctl.h 1.24 2009/12/15 15:34:59 daniel REL_M $
+ * $Id: mbgioctl.h 1.24.1.2 2011/03/22 11:19:46 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbgioctl.h $
- * Revision 1.24 2009/12/15 15:34:59 daniel
+ * 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
+ * Added ioctls to support PTP unicast configuration
+ * Revision 1.24 2009/12/15 15:34:59Z daniel
* Support reading the raw IRIG data bits for firmware versions
* which support this feature.
* Revision 1.23 2009/09/29 15:08:41Z martin
@@ -123,8 +127,9 @@
#include <sys/ioccom.h>
- // a magic number used to generate IOCTL cmd codes
- #define IOTYPE 'M'
+ // Under NetBSD 'Z' marks passthrough IOCTLs, under FreeBSD the code
+ // does not seem to matter, so we use 'Z' anyway.
+ #define IOTYPE 'Z'
#define _MBG_IO _IO
#define _MBG_IOR _IOR
@@ -384,6 +389,10 @@
#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 )
+
// The codes below are subject to changes without notice. They may be supported
// by some kernel drivers, but usage is restricted to Meinberg software development.
// Unrestricted usage may cause system malfunction !!
diff --git a/mbglib/common/mbgtime.h b/mbglib/common/mbgtime.h
index b2fe544..c7ab670 100755
--- a/mbglib/common/mbgtime.h
+++ b/mbglib/common/mbgtime.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgtime.h 1.17.1.3 2011/01/24 17:09:20 martin TEST $
+ * $Id: mbgtime.h 1.17.1.4 2011/02/09 15:46:48 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,7 @@
*
* -----------------------------------------------------------------------
* $Log: mbgtime.h $
+ * Revision 1.17.1.4 2011/02/09 15:46:48 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,9 +62,8 @@
#include <gpsdefs.h>
#if !defined( MBG_ARCH_ARM ) && \
- !defined( MBG_TGT_BSD ) && \
- !defined( __KERNEL__ )
- #include <time.h>
+ !defined( MBG_TGT_KERNEL )
+ #include <time.h>
#endif
diff --git a/mbglib/common/mbgutil.h b/mbglib/common/mbgutil.h
index 5ae29a8..9d26c62 100755
--- a/mbglib/common/mbgutil.h
+++ b/mbglib/common/mbgutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgutil.h 1.16 2009/08/14 10:11:53 daniel REL_M $
+ * $Id: mbgutil.h 1.16.1.1 2011/02/09 15:27:23 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgutil.h $
- * Revision 1.16 2009/08/14 10:11:53 daniel
+ * Revision 1.16.1.1 2011/02/09 15:27:23 martin
+ * 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
* Rev No. 305
@@ -57,6 +58,8 @@
#include <mbggeo.h>
#include <pci_asic.h>
+#include <stdlib.h>
+
#define MBGUTIL_VERSION 0x0306
diff --git a/mbglib/common/myutil.h b/mbglib/common/myutil.h
index ddec11b..7e6b901 100755
--- a/mbglib/common/myutil.h
+++ b/mbglib/common/myutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: myutil.h 1.13 2010/12/13 15:59:39 martin REL_M $
+ * $Id: myutil.h 1.14 2011/02/16 14:02:35 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: myutil.h $
+ * Revision 1.14 2011/02/16 14:02:35 martin
+ * Added STRINGIFY() macro.
* Revision 1.13 2010/12/13 15:59:39 martin
* Moved definition of macro _frac() here.
* Revision 1.12 2008/01/30 10:28:17Z martin
@@ -68,6 +70,22 @@
#pragma pack( 1 )
#endif
+
+// The two macros below can be used to define a constant string on the
+// compiler's command line, e.g. like -DVERSION_STRING="v1.0 BETA".
+// Source code like
+// const char version_string[] = VERSION_STRING;
+// may not work for every compiler since the double quotes
+// in VERSION_STRING may be removed when the definition is evaluated.
+// A proper solution is to use the STRINGIFY() macro below:
+// const char version_string[] = STRINGIFY( VERSION_STRING );
+// The XSTRINGIFY() macro is simply a helper macro which should not
+// be used alone.
+#define STRINGIFY(x) XSTRINGIFY(x)
+#define XSTRINGIFY(x) #x
+
+
+
#if MBG_TGT_HAS_64BIT_TYPES
#define _frac( _x ) ( ( (_x) == 0.0 ) ? 0.0 : ( (_x) - (double) ( (int64_t) (_x) ) ) )
#else
diff --git a/mbglib/common/parmgps.h b/mbglib/common/parmgps.h
index 5208da9..46d28fc 100755
--- a/mbglib/common/parmgps.h
+++ b/mbglib/common/parmgps.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: parmgps.h 1.6 2008/10/21 10:41:09 martin REL_M $
+ * $Id: parmgps.h 1.7 2011/02/16 10:12:13 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: parmgps.h $
- * Revision 1.6 2008/10/21 10:41:09 martin
+ * Revision 1.7 2011/02/16 10:12:13 martin
+ * Fixed macro syntax for _setup_default_receiver_info_gps().
+ * Revision 1.6 2008/10/21 10:41:09Z martin
* Renamed check_port_info() to check_valid_port_info()
* to avoid naming conflicts.
* Revision 1.5 2008/09/10 16:22:32 martin
@@ -69,7 +71,8 @@ extern "C" {
*
* Parameters: (RECEIVER_INFO *) _p
*/
-#define _setup_default_receiver_info_gps( _p ); \
+#define _setup_default_receiver_info_gps( _p ) \
+do \
{ \
memset( (_p), 0, sizeof( *(_p) ) ); \
\
@@ -77,7 +80,7 @@ extern "C" {
(_p)->n_ucaps = 2; \
(_p)->n_com_ports = DEFAULT_N_COM; \
(_p)->n_str_type = DEFAULT_N_STR_TYPE_GPS; \
-}
+} while ( 0 )
_ext BAUD_RATE mbg_baud_rate[N_MBG_BAUD_RATES]
diff --git a/mbglib/common/parmpcps.h b/mbglib/common/parmpcps.h
index 6bad879..eafe487 100755
--- a/mbglib/common/parmpcps.h
+++ b/mbglib/common/parmpcps.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: parmpcps.h 1.5 2004/11/09 14:24:58 martin REL_M $
+ * $Id: parmpcps.h 1.6 2011/02/16 10:13:12 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: parmpcps.h $
- * Revision 1.5 2004/11/09 14:24:58 martin
+ * Revision 1.6 2011/02/16 10:13:12 martin
+ * Fixed macro syntax for _setup_default_receiver_info_pcps().
+ * Revision 1.5 2004/11/09 14:24:58Z martin
* Updated function prototypes.
* Revision 1.4 2004/05/19 07:52:25Z martin
* Fixed macro setting default number of string types.
@@ -101,6 +103,7 @@ extern "C" {
* Parameters: (RECEIVER_INFO *) _p
*/
#define _setup_default_receiver_info_dcf( _p, _pdev ); \
+do \
{ \
memset( (_p), 0, sizeof( *(_p) ) ); \
\
@@ -109,7 +112,7 @@ extern "C" {
(_p)->n_com_ports = _pcps_has_serial( _pdev ) ? 1 : 0; \
(_p)->n_str_type = ( (_p)->n_com_ports != 0 ) ? \
DEFAULT_N_STR_TYPE_DCF : 0; \
-}
+} while ( 0 )
#define DEFAULT_MAX_STR_TYPE 2 //##++DEFAULT_N_STR_TYPE_GPS
diff --git a/mbglib/common/pcpsdefs.h b/mbglib/common/pcpsdefs.h
index f499e3c..f36b251 100755
--- a/mbglib/common/pcpsdefs.h
+++ b/mbglib/common/pcpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.46 2011/01/13 11:44:29 martin TEST $
+ * $Id: pcpsdefs.h 1.46.1.1 2011/02/15 10:55:28 daniel TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
- * Revision 1.46 2011/01/13 11:44:29 martin
+ * 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
* Moved status port register definitions here.
* Revision 1.45 2010/09/06 07:36:24 martin
* Support GPS180PEX and TCR180PEX.
@@ -1234,6 +1236,7 @@ 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
// GPS data
PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes
diff --git a/mbglib/common/pcpsdev.h b/mbglib/common/pcpsdev.h
index 4250a5a..3c856ed 100755
--- a/mbglib/common/pcpsdev.h
+++ b/mbglib/common/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.49.1.25 2011/02/04 14:44:44 martin TEST $
+ * $Id: pcpsdev.h 1.49.1.32 2011/03/25 11:09:43 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,6 +17,16 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
+ * Revision 1.49.1.32 2011/03/25 11:09:43 martin
+ * Optionally support timespec for sys time (USE_TIMESPEC).
+ * Started to support NetBSD.
+ * Revision 1.49.1.31 2011/02/16 10:10:49 martin
+ * Fixed macro syntax for _pcps_time_set_unread().
+ * Revision 1.49.1.30 2011/02/15 14:24:56Z martin
+ * Revision 1.49.1.29 2011/02/10 13:34:21 martin
+ * Revision 1.49.1.28 2011/02/10 13:21:59 martin
+ * Revision 1.49.1.27 2011/02/10 12:26:17 martin
+ * Revision 1.49.1.26 2011/02/09 15:46:49 martin
* Revision 1.49.1.25 2011/02/04 14:44:44 martin
* Revision 1.49.1.24 2011/02/04 10:10:00 martin
* Revision 1.49.1.23 2011/02/02 12:34:10 martin
@@ -251,10 +261,17 @@
#if defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ )
+ #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 <sys/time.h>
+ #include <sys/sysinfo.h>
#endif
#if defined( MBG_ARCH_IA64 )
@@ -265,7 +282,15 @@
#endif
#if defined( MBG_TGT_BSD )
- #include <machine/clock.h>
+
+ #if !defined( USE_TIMESPEC )
+ #define USE_TIMESPEC 1
+ #endif
+
+ #if defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
+ #include <machine/clock.h> // for symbol 'tsc_freq', not supported e.g. on MBG_TGT_NETBSD
+ #endif
+
#endif
#if defined( MBG_TGT_DOS )
@@ -285,6 +310,10 @@
#endif
+#if !defined( USE_TIMESPEC )
+ #define USE_TIMESPEC 0
+#endif
+
/**
@@ -316,12 +345,6 @@
typedef int64_t MBG_SYS_UPTIME; // [s]
- #if defined( __KERNEL__ )
- #include <linux/time.h>
- #else
- #include <sys/time.h>
- #endif
-
typedef struct timeval MBG_SYS_TIME;
#elif defined( MBG_TGT_BSD )
@@ -333,9 +356,13 @@
typedef int64_t MBG_SYS_UPTIME; // [s]
- typedef struct timeval MBG_SYS_TIME;
+ #if USE_TIMESPEC
+ typedef struct timespec MBG_SYS_TIME;
+ #else
+ typedef struct timeval MBG_SYS_TIME;
+ #endif
- #if defined( _KERNEL )
+ #if defined( MBG_TGT_FREEBSD ) && defined( MBG_TGT_KERNEL )
#include <sys/sysproto.h>
#include <sys/pcpu.h>
#else
@@ -547,7 +574,7 @@ void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
#elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
*p = ( cpu_khz * 1000 );
@@ -568,7 +595,7 @@ void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
#elif defined( MBG_TGT_BSD )
- #if defined( MBG_ARCH_X86 ) && defined( _KERNEL )
+ #if defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
*p = tsc_freq;
@@ -628,7 +655,7 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
#elif defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
do_gettimeofday( p );
#else
gettimeofday( p, NULL );
@@ -636,10 +663,22 @@ void mbg_get_sys_time( MBG_SYS_TIME *p )
#elif defined( MBG_TGT_BSD )
- #if defined( _KERNEL )
- microtime( p );
- #else
- gettimeofday( p, NULL );
+ #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 );
+ #endif
#endif
#else
@@ -691,7 +730,7 @@ void mbg_get_sys_uptime( MBG_SYS_UPTIME *p )
#elif defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
{
// Using a simple 64 bit division may result in a linker error
// in kernel mode due to a missing symbol __udivdi3, so we use
@@ -703,25 +742,34 @@ void mbg_get_sys_uptime( MBG_SYS_UPTIME *p )
*p = tmp;
}
#else
- //##++++ Still need to implement this for Linux user space.
- // A possible way would be to parse the contents
- // of the pseudo-file /proc/uptime.
- *p = -1;
+ {
+ struct sysinfo si;
+ int rc = sysinfo( &si );
+ *p = ( rc == 0 ) ? si.uptime : -1;
+ }
#endif
#elif defined( MBG_TGT_BSD )
- #if defined( _KERNEL )
+ #if defined( MBG_TGT_KERNEL )
{
- struct timeval tv;
+ struct timespec ts;
- getmicrouptime( &tv );
+ getnanouptime( &ts );
- *p = tv.tv_sec;
+ *p = ts.tv_sec;
}
- #else
- //##++++ Still need to implement this for user space.
- *p = -1;
+ #elif defined( MBG_TGT_FREEBSD )
+ {
+ struct timespec ts;
+ // CLOCK_UPTIME_FAST is specific to FreeBSD
+ int rc = clock_gettime( CLOCK_UPTIME_FAST, &ts );
+ *p = ( rc == 0 ) ? ts.tv_sec : -1;
+ }
+ #else // MBG_TGT_NETBSD, ...
+
+ *p = -1; //##++ needs to be implemented
+
#endif
#else
@@ -755,7 +803,7 @@ void mbg_sleep_sec( long sec )
#elif defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
// msleep is not defined in older kernels, so we use this
// only if it is surely supported.
#if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 16 ) ) //##+++++
@@ -1371,7 +1419,12 @@ typedef struct
// Query whether a special feature is supported:
-#define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 )
+#define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 )
+
+// Query whether a special feature is supported according to RECEIVER_INFO:
+#define _pcps_has_ri_feature( _p_ri, _f ) ( ( (_p_ri)->features & (_f) ) != 0 )
+
+
#define _pcps_can_set_time( _d ) _pcps_has_feature( (_d), PCPS_CAN_SET_TIME )
#define _pcps_has_serial( _d ) _pcps_has_feature( (_d), PCPS_HAS_SERIAL )
#define _pcps_has_sync_time( _d ) _pcps_has_feature( (_d), PCPS_HAS_SYNC_TIME )
@@ -1453,6 +1506,7 @@ typedef struct
#define _pcps_has_ptp( _d ) _pcps_has_feature( (_d), PCPS_HAS_PTP )
+#define _pcps_has_ri_ptp_unicast( _p_ri ) _pcps_has_ri_feature( (_p_ri), GPS_HAS_PTP_UNICAST )
#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) \
|| _pcps_is_pci_pex8311( _d ) \
@@ -1530,7 +1584,7 @@ typedef POUT_INFO_IDX ALL_POUT_INFO[MAX_PARM_POUT];
// 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.
-#define _pcps_time_set_unread( _t ); { (_t)->sec = 0xFF; }
+#define _pcps_time_set_unread( _t ) do { (_t)->sec = 0xFF; } while ( 0 )
#define _pcps_time_is_read( _t ) ( (uchar) (_t)->sec != 0xFF )
diff --git a/mbglib/common/pcpsdrvr.c b/mbglib/common/pcpsdrvr.c
index 661f483..4ec7909 100755
--- a/mbglib/common/pcpsdrvr.c
+++ b/mbglib/common/pcpsdrvr.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.c 1.46.2.25 2011/02/07 15:47:28 martin TEST $
+ * $Id: pcpsdrvr.c 1.46.2.35 2011/03/25 11:10:34 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -61,6 +61,23 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.c $
+ * Revision 1.46.2.35 2011/03/25 11:10:34 martin
+ * Optionally support timespec for sys time (USE_TIMESPEC).
+ * Revision 1.46.2.34 2011/03/22 10:25:57 martin
+ * Modifications to support NetBSD.
+ * Revision 1.46.2.33 2011/03/21 16:26:03 martin
+ * Account for modified _pcps_kfree().
+ * Revision 1.46.2.32 2011/02/16 10:14:37 martin
+ * Set up basic default receiver info for devices which don't
+ * support this structure.
+ * Revision 1.46.2.31 2011/02/15 14:24:57Z martin
+ * Revision 1.46.2.30 2011/02/10 09:18:07 martin
+ * Revision 1.46.2.29 2011/02/09 17:08:30Z martin
+ * Specify I/O range number when calling port I/O macros
+ * so they can be used for different ranges under BSD.
+ * Revision 1.46.2.28 2011/02/09 16:42:12 martin
+ * Revision 1.46.2.27 2011/02/09 15:27:49 martin
+ * Revision 1.46.2.26 2011/02/09 14:43:19Z martin
* Revision 1.46.2.25 2011/02/07 15:47:28 martin
* Fixed a potential trap in kernel messages.
* Revision 1.46.2.24 2011/02/04 14:44:45 martin
@@ -299,6 +316,8 @@
#include <pcpsdrvr.h>
#undef _PCPSDRVR
+#include <parmpcps.h>
+#include <parmgps.h>
#include <identdec.h>
#include <mbgddmsg.h>
#include <plxdefs.h>
@@ -319,7 +338,7 @@
#include <assert.h>
#endif
-#if defined( MBG_TGT_BSD )
+#if defined( MBG_TGT_FREEBSD )
#include <sys/rman.h>
#include <sys/libkern.h>
#endif
@@ -439,12 +458,16 @@ 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;
- dt += ( t2->tv_usec - t1->tv_usec ) / 1000;
+ #if USE_TIMESPEC
+ dt += ( t2->tv_nsec - t1->tv_nsec ) / 1000000;
+ #else
+ dt += ( t2->tv_usec - t1->tv_usec ) / 1000;
+ #endif
return dt;
#elif defined( MBG_TGT_WIN32 )
return (long) ( ( t2->QuadPart - t1->QuadPart ) / HNS_PER_MS );
#else
- #error mbg_delta_sys_time_ms not implemented for this target
+ return 0;
#endif
} // mbg_delta_sys_time_ms
@@ -455,17 +478,17 @@ static /*HDR*/
void report_uptime( const MBG_SYS_UPTIME *p_uptime )
{
#if defined( MBG_TGT_LINUX )
- printk( KERN_INFO "%s: system uptime %Lu jiffies -> %Lu s, required %u s\n",
- pcps_driver_name, (uint64_t) get_jiffies_64() - INITIAL_JIFFIES,
- (uint64_t) *p_uptime, MAX_BOOT_TIME_PTP270PEX );
+ printk( KERN_INFO "%s: system uptime %llu jiffies -> %llu s, required %u s\n",
+ pcps_driver_name, (unsigned long long) ( get_jiffies_64() - INITIAL_JIFFIES ),
+ (unsigned long long) *p_uptime, MAX_BOOT_TIME_PTP270PEX );
#elif defined( MBG_TGT_BSD )
- printf( "%s: system uptime %lli s, required %u s\n",
- pcps_driver_name, *p_uptime, MAX_BOOT_TIME_PTP270PEX );
+ printf( "%s: system uptime %llu s, required %u s\n",
+ pcps_driver_name, (unsigned long long) *p_uptime, MAX_BOOT_TIME_PTP270PEX );
#elif defined( MBG_TGT_WIN32 )
WCHAR wcs_msg[120];
swprintf( wcs_msg, L"system uptime: %I64u s, required %u s",
- (uint64_t) *p_uptime, MAX_BOOT_TIME_PTP270PEX );
+ (int64_t) *p_uptime, MAX_BOOT_TIME_PTP270PEX );
_evt_msg( GlbDriverObject, wcs_msg );
#endif
@@ -474,6 +497,65 @@ void report_uptime( const MBG_SYS_UPTIME *p_uptime )
static /*HDR*/
+void check_uptime( void )
+{
+ #if !defined( MBG_TGT_DOS )
+ MBG_SYS_TIME t1;
+ MBG_SYS_TIME t2;
+ MBG_SYS_UPTIME uptime;
+ int delayed = 0;
+
+ mbg_get_sys_time( &t1 );
+
+ for (;;)
+ {
+ mbg_get_sys_uptime( &uptime );
+
+ #if !defined( DEBUG )
+ if ( !delayed )
+ #endif
+ report_uptime( &uptime );
+
+ if ( uptime == 0 )
+ break; // assume uptime not supported
+
+ if ( uptime >= MAX_BOOT_TIME_PTP270PEX )
+ break;
+
+ mbg_sleep_sec( 1 );
+ delayed = 1;
+ }
+
+ if ( delayed )
+ {
+ long dt;
+
+ mbg_get_sys_time( &t2 );
+
+ dt = mbg_delta_sys_time_ms( &t2, &t1 );
+
+ #if defined( MBG_TGT_LINUX )
+ printk( KERN_INFO "PTP270PEX startup delay: %li.%03li s\n",
+ dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
+ #elif defined( MBG_TGT_BSD )
+ printf( "PTP270PEX startup delay: %li.%03li s\n",
+ dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
+ #elif defined( MBG_TGT_WIN32 )
+ {
+ WCHAR wcs_msg[128];
+ swprintf( wcs_msg, L"PTP270PEX startup delay: %li.%03li s",
+ dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
+ _evt_msg( GlbDriverObject, wcs_msg );
+ }
+ #endif
+ }
+ #endif
+
+} // check_uptime
+
+
+
+static /*HDR*/
int pcps_check_pex_irq_unsafe( PCPS_DDEV *pddev, uint16_t req_fw_ver,
uint8_t req_asic_ver_major, uint8_t req_asic_ver_minor )
{
@@ -515,10 +597,14 @@ int map_sys_virtual_address( PCPS_DDEV *pddev )
pddev->mm_addr = ioremap( ( (ulong) pddev->rsrc_info.mem[0].start ), sizeof( *pddev->mm_addr ) );
- #elif defined ( MBG_TGT_BSD )
+ #elif defined ( MBG_TGT_FREEBSD )
pddev->mm_addr = rman_get_virtual( pddev->rsrc_info.mem[0].bsd.res );
+ #elif defined ( MBG_TGT_NETBSD )
+
+ pddev->mm_addr = bus_space_vaddr( pddev->rsrc_info.mem[0].bsd.bst, pddev->rsrc_info.mem[0].bsd.bsh );
+
#else // DOS, ...
pddev->mm_addr = (PCPS_MM_LAYOUT FAR *) pddev->rsrc_info.mem[0].start;
@@ -671,7 +757,7 @@ short pcps_read_std( PCPS_DDEV *pddev, uint8_t cmd,
_pcps_disb_local_irq_save();
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
- _mbg_outp8( pddev, port, cmd );
+ _mbg_outp8( pddev, 0, port, cmd );
_pcps_local_irq_restore();
// wait until BUSY flag goes low or timeout
@@ -682,7 +768,7 @@ short pcps_read_std( PCPS_DDEV *pddev, uint8_t cmd,
// no timeout: read bytes from the board's FIFO
for ( i = 0; i < count; i++ )
{
- *buffer++ = _mbg_inp8( pddev, port );
+ *buffer++ = _mbg_inp8( pddev, 0, port );
#if DEBUG_IO
_mbgddmsg_1( MBG_DBG_DETAIL, "pcps_read_std: %02X", buffer[i] );
@@ -714,15 +800,15 @@ short pcps_read_amcc_s5933( PCPS_DDEV *pddev, uint8_t cmd,
#endif
// reset inbound mailbox and FIFO status
- _mbg_outp8( pddev, port + AMCC_OP_REG_MCSR + 3, 0x0C );
+ _mbg_outp8( pddev, 0, port + AMCC_OP_REG_MCSR + 3, 0x0C );
// set FIFO
- _mbg_outp8( pddev, port + AMCC_OP_REG_INTCSR + 3, 0x3C );
+ _mbg_outp8( pddev, 0, port + AMCC_OP_REG_INTCSR + 3, 0x3C );
_pcps_disb_local_irq_save();
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
- _mbg_outp8( pddev, port + AMCC_OP_REG_OMB1, cmd );
+ _mbg_outp8( pddev, 0, port + AMCC_OP_REG_OMB1, cmd );
_pcps_local_irq_restore();
// wait until BUSY flag goes low or timeout
@@ -733,10 +819,10 @@ short pcps_read_amcc_s5933( PCPS_DDEV *pddev, uint8_t cmd,
// no timeout: read bytes from the board's FIFO
for ( i = 0; i < count; i++ )
{
- if ( _mbg_inp16_to_cpu( pddev, port + AMCC_OP_REG_MCSR ) & 0x20 )
+ if ( _mbg_inp16_to_cpu( pddev, 0, port + AMCC_OP_REG_MCSR ) & 0x20 )
return MBG_ERR_FIFO;
- buffer[i] = _mbg_inp8( pddev, port + AMCC_OP_REG_FIFO + ( i % sizeof( uint32_t) ) );
+ 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] );
@@ -769,13 +855,15 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
#if DEBUG_IO
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: cmd %02X", cmd );
+ _mbgddmsg_3( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: cmd %02X, port: %04lX, data_port: %04lX",
+ cmd, (ulong) _pcps_ddev_io_base_mapped( pddev, 0 ) + AMCC_OP_REG_OMB,
+ (ulong) data_port );
#endif
_pcps_disb_local_irq_save();
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
- _mbg_outp8( pddev, _pcps_ddev_io_base_mapped( pddev, 0 ) + AMCC_OP_REG_OMB, cmd );
+ _mbg_outp8( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 ) + AMCC_OP_REG_OMB, cmd );
_pcps_local_irq_restore();
dt_quot = count / 4;
@@ -795,7 +883,7 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
// first read full 32 bit words
for ( i = 0; i < dt_quot; i++ )
{
- ul = _mbg_inp32_to_cpu( pddev, data_port );
+ ul = _mbg_inp32_to_cpu( pddev, 1, data_port );
#if DEBUG_IO
_mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_amcc_s5920: %08X", ul );
#endif
@@ -806,7 +894,7 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
// then read the remaining bytes, if required
if ( dt_rem )
{
- ul = _mbg_inp32_to_cpu( pddev, data_port );
+ ul = _mbg_inp32_to_cpu( pddev, 1, data_port );
for ( i = 0; i < dt_rem; i++ )
{
@@ -819,7 +907,7 @@ short pcps_read_amcc_s5920( PCPS_DDEV *pddev, uint8_t cmd,
}
}
else
- _mbg_inp32( pddev, data_port ); // do a dummy read
+ _mbg_inp32( pddev, 1, data_port ); // do a dummy read
return MBG_SUCCESS;
@@ -855,7 +943,7 @@ short pcps_read_asic( PCPS_DDEV *pddev, uint8_t cmd,
_pcps_disb_local_irq_save();
mbg_get_pc_cycles( &pddev->acc_cycles );
// write the command byte
- _mbg_outp32( pddev, _pcps_ddev_io_base_mapped( pddev, 0 )
+ _mbg_outp32( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 )
+ offsetof( PCI_ASIC, pci_data ), cmd );
_pcps_local_irq_restore();
@@ -874,7 +962,7 @@ short pcps_read_asic( PCPS_DDEV *pddev, uint8_t cmd,
// first read full 32 bit words
for ( i = 0; i < dt_quot; i++ )
{
- ar.ul = _mbg_inp32_to_cpu( pddev, data_port );
+ ar.ul = _mbg_inp32_to_cpu( pddev, 0, data_port );
#if DEBUG_IO
_mbgddmsg_1( MBG_DBG_INIT_DEV, "pcps_read_asic: %08X", ar.ul );
#endif
@@ -886,7 +974,7 @@ short pcps_read_asic( PCPS_DDEV *pddev, uint8_t cmd,
// then read the remaining bytes, if required
if ( dt_rem )
{
- ar.ul = _mbg_inp32_to_cpu( pddev, data_port );
+ ar.ul = _mbg_inp32_to_cpu( pddev, 0, data_port );
for ( i = 0; i < dt_rem; i++ )
{
@@ -1041,7 +1129,7 @@ short pcps_write( PCPS_DDEV *pddev, uint8_t cmd,
rc = (int8_t) p[0]; // return the rc from the board
}
- _pcps_kfree( p );
+ _pcps_kfree( p, n );
}
else
#endif // _PCPS_USE_USB
@@ -1678,56 +1766,38 @@ int pcps_read_sernum( PCPS_DDEV *pddev )
// Check which way is supported by the clock, and
// read the S/N,
- // Read directly. This is supported by newer DCF77 clocks.
- if ( _pcps_ddev_has_sernum( pddev ) )
+
+ // The S/N is part of the RECEIVER_INFO structure. If this
+ // structure is supported by the device then it should have
+ // already been set up, so we can simply copy the serial number.
+ if ( _pcps_ddev_has_receiver_info( pddev ) )
{
#if DEBUG_SERNUM
- _mbgddmsg_0( MBG_DBG_DETAIL, "getting S/N via PCPS_GIVE_SERNUM cmd" );
+ _mbgddmsg_0( MBG_DBG_DETAIL, "copying S/N from receiver info" );
#endif
- rc = _pcps_read( pddev, PCPS_GIVE_SERNUM, pddev->dev.cfg.sernum, PCPS_FIFO_SIZE );
-
- if ( rc != MBG_SUCCESS )
- {
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "PCPS read SERNUM %X: rc = %i",
- _pcps_ddev_dev_id( pddev ), rc );
- goto fail;
- }
-
+ strncpy( pddev->dev.cfg.sernum, pddev->ri.sernum,
+ sizeof( pddev->dev.cfg.sernum ) );
goto check;
}
- // The S/N is part of the RECEIVER_INFO structure,
- // so use that one, if supported.
- if ( _pcps_ddev_has_receiver_info( pddev ) )
+ // Read directly. This is supported by newer DCF77 clocks.
+ if ( _pcps_ddev_has_sernum( pddev ) )
{
- static_wc RECEIVER_INFO ri;
-
#if DEBUG_SERNUM
- _mbgddmsg_0( MBG_DBG_DETAIL, "getting S/N from receiver info" );
+ _mbgddmsg_0( MBG_DBG_DETAIL, "getting S/N via PCPS_GIVE_SERNUM cmd" );
#endif
- rc = _pcps_read_gps_var( pddev, PC_GPS_RECEIVER_INFO, ri );
+ rc = _pcps_read( pddev, PCPS_GIVE_SERNUM, pddev->dev.cfg.sernum, PCPS_FIFO_SIZE );
if ( rc != MBG_SUCCESS )
{
- _mbgddmsg_2( MBG_DBG_INIT_DEV, "PCPS read GPS receiver info %X: rc = %i",
+ _mbgddmsg_2( MBG_DBG_INIT_DEV, "PCPS read SERNUM %X: rc = %i",
_pcps_ddev_dev_id( pddev ), rc );
goto fail;
}
- _mbg_swab_receiver_info( &ri );
-
- #if DEBUG_IO
- _mbgddmsg_1( MBG_DBG_DETAIL, "ri.sw_rev.code: %04X", ri.sw_rev.code );
- _mbgddmsg_1( MBG_DBG_DETAIL, "ri.model_code: %04X", ri.model_code );
- _mbgddmsg_3( MBG_DBG_DETAIL, "ri.model_name: %-*.*s", (int) sizeof( ri.model_name ), (int) sizeof( ri.model_name ), ri.model_name );
- _mbgddmsg_1( MBG_DBG_DETAIL, "ri.features: %08X", ri.features );
- #endif
-
- strncpy( pddev->dev.cfg.sernum, ri.sernum,
- sizeof( pddev->dev.cfg.sernum ) );
goto check;
}
@@ -2113,7 +2183,7 @@ void pcps_free_ddev( PCPS_DDEV *pddev )
{
#if !_PCPS_STATIC_DEV_LIST
if ( pddev )
- _pcps_kfree( pddev );
+ _pcps_kfree( pddev, sizeof( *pddev ) );
#else
memset( pddev, 0, sizeof( *pddev ) );
@@ -2616,57 +2686,9 @@ chip_setup_done:
}
#endif
- // Make sure a PTP270PEX card has finished booting.
+ // Make sure a PTP270PEX card has finished booting.
if ( _pcps_ddev_dev_id( pddev ) == PCI_DEV_PTP270PEX )
- {
- MBG_SYS_TIME t1;
- MBG_SYS_TIME t2;
- MBG_SYS_UPTIME uptime;
- int delayed = 0;
-
- mbg_get_sys_time( &t1 );
-
- for (;;)
- {
- mbg_get_sys_uptime( &uptime );
-
- #if !defined( DEBUG )
- if ( !delayed )
- #endif
- report_uptime( &uptime );
-
- if ( uptime == 0 )
- break; // assume uptime not supported
-
- if ( uptime >= MAX_BOOT_TIME_PTP270PEX )
- break;
-
- mbg_sleep_sec( 1 );
- delayed = 1;
- }
-
- if ( delayed )
- {
- long dt;
-
- mbg_get_sys_time( &t2 );
-
- dt = mbg_delta_sys_time_ms( &t2, &t1 );
-
- #if defined( MBG_TGT_LINUX )
- printk( KERN_INFO "PTP270PEX startup delay: %li.%03li s\n",
- dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
- #elif defined( MBG_TGT_BSD )
- printf( "PTP270PEX startup delay: %li.%03li s\n",
- dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
- #elif defined( MBG_TGT_WIN32 )
- swprintf( pddev->wcs_msg, L"PTP270PEX startup delay: %li.%03li s",
- dt / 1000, ( ( dt < 0 ) ? -dt : dt ) % 1000 );
- _evt_msg( GlbDriverObject, pddev->wcs_msg );
- #endif
- }
- }
-
+ check_uptime();
// try to read EPROM ID
rc = pcps_get_fw_id( pddev, pddev->dev.cfg.fw_id );
@@ -2719,7 +2741,7 @@ chip_setup_done:
// If no support for MCA has been compiled in, it may even
// be a PS31 which is software compatible with a PC31.
dev_type =
- ( _mbg_inp16_to_cpu( pddev, _pcps_ddev_io_base_mapped( pddev, 0 ) + 2 )
+ ( _mbg_inp16_to_cpu( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 ) + 2 )
== pcps_dev_type[PCPS_TYPE_PC32].dev_id ) ?
PCPS_TYPE_PC32 : PCPS_TYPE_PC31;
}
@@ -2743,7 +2765,7 @@ chip_setup_done:
// If the device has an ASIC or EPLD read the ASIC version number
if ( _pcps_ddev_has_asic_version( pddev ) )
{
- pddev->raw_asic_version = _mbg_inp32_to_cpu( pddev, _pcps_ddev_io_base_mapped( pddev, 0 )
+ pddev->raw_asic_version = _mbg_inp32_to_cpu( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 )
+ offsetof( PCI_ASIC, raw_version ) );
_mbg_swab_asic_version( &pddev->raw_asic_version );
@@ -2905,45 +2927,84 @@ chip_setup_done:
if ( _pcps_ddev_has_receiver_info( pddev ) )
{
- // detect the presence of some optional features at run time
- RECEIVER_INFO rcvr_info;
int rc;
- rc = _pcps_read_gps_var( pddev, PC_GPS_RECEIVER_INFO, rcvr_info );
+ rc = _pcps_read_gps_var( pddev, PC_GPS_RECEIVER_INFO, pddev->ri );
if ( rc == MBG_SUCCESS )
{
_mbg_swab_receiver_info( &rcvr_info );
-
- _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s v%03X RECEIVER_INFO features: 0x%08lX",
- _pcps_ddev_type_name( pddev ), _pcps_ddev_fw_rev_num( pddev ),
- (ulong) rcvr_info.features );
-
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_IRIG_TX, PCPS_HAS_IRIG_TX );
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_IRIG_CTRL_BITS, PCPS_HAS_IRIG_CTRL_BITS );
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_SYNTH, PCPS_HAS_SYNTH );
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_TIME_SCALE, PCPS_HAS_TIME_SCALE );
-
- // Devices which support a configurable time scale do also
- // support reading/writing the GPS UTC parameters via the PC bus.
- // This is not explicitely coded in the rcvr_info structure
- // since the the rcvr_info structure can also be read via
- // the serial port, and reading/writing the GPS UTC parameters
- // via the serial port is supported by all GPS devices anyway.
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_TIME_SCALE, PCPS_HAS_UTC_PARM );
-
- // Devices which support reading raw IRIG data via the PC interface also support
- // reading the raw IRIG time. However, there is no receiver info feature flag
- // since this call is not supported via the serial interface, so we use the
- // GPS_HAS_RAW_IRIG_DATA flag to check both features.
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_RAW_IRIG_DATA, PCPS_HAS_IRIG_TIME );
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_RAW_IRIG_DATA, PCPS_HAS_RAW_IRIG_DATA );
-
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_LAN_IP4, PCPS_HAS_LAN_INTF );
- check_ri_feature( pddev, &rcvr_info, GPS_HAS_PTP, PCPS_HAS_PTP );
+ goto check;
}
}
+ _mbgddmsg_1( MBG_DBG_INIT_DEV, "Setting up default receiver info for dev %X",
+ _pcps_ddev_dev_id( pddev ) );
+
+ if ( _pcps_ddev_is_gps( pddev ) )
+ _setup_default_receiver_info_gps( &pddev->ri );
+ else
+ _setup_default_receiver_info_dcf( &pddev->ri, &pddev->dev );
+
+check:
+ #if DEBUG_IO
+ _mbgddmsg_1( MBG_DBG_DETAIL, "ri.sw_rev.code: %04X", pddev->ri.sw_rev.code );
+ _mbgddmsg_1( MBG_DBG_DETAIL, "ri.model_code: %04X", pddev->ri.model_code );
+ _mbgddmsg_3( MBG_DBG_DETAIL, "ri.model_name: %-*.*s", (int) sizeof( pddev->ri.model_name ),
+ (int) sizeof( pddev->ri.model_name ), pddev->ri.model_name );
+ #endif
+
+
+#if 0 //##+++++++++ check if this is reasonnable
+
+ // Make sure this program supports at least as many ports as
+ // the current clock device.
+ if ( pddev->ri.n_com_ports > MAX_PARM_PORT )
+ {
+ _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s provides %i COM ports, but this driver only supports %i",
+ _pcps_ddev_type_name( pddev ), pddev->ri.n_com_ports, MAX_PARM_PORT );
+ pddev->ri.n_com_ports = MAX_PARM_PORT;
+ }
+
+ // Make sure this program supports at least as many string types
+ // as the current clock device.
+ if ( pddev->ri.n_str_type > MAX_PARM_STR_TYPE )
+ {
+ _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s supports %i serial string formats, but this driver only supports %i",
+ _pcps_ddev_type_name( pddev ), pddev->ri.n_str_type, MAX_PARM_STR_TYPE );
+ pddev->ri.n_str_type = MAX_PARM_STR_TYPE;
+ }
+#endif
+
+
+ // detect the presence of some optional features at run time
+ _mbgddmsg_3( MBG_DBG_INIT_DEV, "%s v%03X RECEIVER_INFO features: 0x%08lX",
+ _pcps_ddev_type_name( pddev ), _pcps_ddev_fw_rev_num( pddev ),
+ (ulong) pddev->ri.features );
+
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_IRIG_TX, PCPS_HAS_IRIG_TX );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_IRIG_CTRL_BITS, PCPS_HAS_IRIG_CTRL_BITS );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_SYNTH, PCPS_HAS_SYNTH );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_TIME_SCALE, PCPS_HAS_TIME_SCALE );
+
+ // Devices which support a configurable time scale do also
+ // support reading/writing the GPS UTC parameters via the PC bus.
+ // This is not explicitely coded in the rcvr_info structure
+ // since the the rcvr_info structure can also be read via
+ // the serial port, and reading/writing the GPS UTC parameters
+ // via the serial port is supported by all GPS devices anyway.
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_TIME_SCALE, PCPS_HAS_UTC_PARM );
+
+ // Devices which support reading raw IRIG data via the PC interface also support
+ // reading the raw IRIG time. However, there is no receiver info feature flag
+ // since this call is not supported via the serial interface, so we use the
+ // GPS_HAS_RAW_IRIG_DATA flag to check both features.
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_RAW_IRIG_DATA, PCPS_HAS_IRIG_TIME );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_RAW_IRIG_DATA, PCPS_HAS_RAW_IRIG_DATA );
+
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_LAN_IP4, PCPS_HAS_LAN_INTF );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_PTP, PCPS_HAS_PTP );
+ check_ri_feature( pddev, &pddev->ri, GPS_HAS_PTP_UNICAST, 0 ); // no equivalent in PCPS_DDEV features
#if !defined( MBG_TGT_OS2 ) && !defined( MBG_TGT_BSD )
// Function strstr may not be supported at kernel level,
@@ -2968,7 +3029,7 @@ chip_setup_done:
if ( _pcps_ddev_has_asic_features( pddev ) )
{
- pddev->asic_features = _mbg_inp32_to_cpu( pddev, _pcps_ddev_io_base_mapped( pddev, 0 )
+ pddev->asic_features = _mbg_inp32_to_cpu( pddev, 0, _pcps_ddev_io_base_mapped( pddev, 0 )
+ offsetof( PCI_ASIC, features ) );
_mbg_swab_asic_features( &pddev->asic_features );
diff --git a/mbglib/common/pcpsdrvr.h b/mbglib/common/pcpsdrvr.h
index 5a5cfa2..720ff81 100755
--- a/mbglib/common/pcpsdrvr.h
+++ b/mbglib/common/pcpsdrvr.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.h 1.41.1.17 2011/02/04 14:44:46 martin TEST $
+ * $Id: pcpsdrvr.h 1.41.1.20 2011/03/25 11:11:44 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.h $
+ * Revision 1.41.1.20 2011/03/25 11:11:44 martin
+ * Optionally support timespec for sys time (USE_TIMESPEC).
+ * Started to support NetBSD.
+ * Revision 1.41.1.19 2011/02/15 14:24:58 martin
+ * Revision 1.41.1.18 2011/02/09 17:08:31 martin
+ * Specify I/O range number when calling port I/O macros
+ * so they can be used for different ranges under BSD.
* Revision 1.41.1.17 2011/02/04 14:44:46 martin
* Revision 1.41.1.16 2011/02/04 10:10:18 martin
* Revision 1.41.1.15 2011/02/02 12:20:42 martin
@@ -371,7 +378,7 @@
#include <use_pack.h>
#include <mbggenio.h>
-#if defined( MBG_TGT_BSD )
+#if defined( MBG_TGT_FREEBSD )
#include <mbg_bsd.h>
#include <sys/malloc.h>
#include <sys/_null.h>
@@ -379,6 +386,9 @@
#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
@@ -445,16 +455,17 @@
#if defined( MBG_TGT_LINUX )
- #define _pcps_kmalloc( _sz ) kmalloc( _sz, GFP_ATOMIC )
- #define _pcps_kfree( _p ) kfree( _p )
+ #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( _spl ) spin_lock( _spl )
- #define _pcps_spin_unlock( _spl ) spin_unlock( _spl )
+ #define MBG_SPINLOCK spinlock_t
+ #define _pcps_spin_lock_init( _spl ) spin_lock_init( _spl )
+ #define _pcps_spin_lock_deinit( _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 MBG_SYS_MUTEX struct semaphore
+ #define _pcps_mutex_init( _pmtx ) sema_init( _pmtx, 1 )
// The special versions of _pcps_sem_inc() and _pcps_sem_dec() below
// are only required to prevent interference with the IRQ handler
@@ -476,15 +487,15 @@
atomic_dec( &(_pddev)->access_in_progress ); \
up( &(_pddev)->dev_mutex )
-#elif defined( MBG_TGT_BSD )
+#elif defined( MBG_TGT_FREEBSD )
// malloc/free in kernel mode require usage of the
// MALLOC_DECLARE() / MALLOC_DEFINE() macros.
// See "man 9 malloc" for details.
MALLOC_DECLARE( M_MBGCLOCK );
- #define _pcps_kmalloc( _sz ) malloc( _sz, M_MBGCLOCK, M_NOWAIT | M_ZERO )
- #define _pcps_kfree( _p ) free( _p, M_MBGCLOCK )
+ #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 )
@@ -496,10 +507,32 @@
#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
+ // used below, see 'man 9 malloc'.
+ #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_deinit( _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 ) mtx_init( _pmtx, MUTEX_DEFAULT, IPL_NONE )
+ #define _pcps_mutex_deinit( _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_kfree( _p ) ExFreePool( _p )
+ #define _pcps_kmalloc( _sz ) ExAllocatePool( PagedPool, _sz )
+ #define _pcps_kfree( _p, , _sz ) ExFreePool( _p )
#define MBG_SPINLOCK KSPIN_LOCK
#define _pcps_spin_lock_init( _spl ) KeInitializeSpinLock( _spl )
@@ -789,6 +822,8 @@ typedef struct PCPS_DDEV_s
// IRQ is possibly unsafe, and whether IRQ has been enabled on the device.
PCPS_IRQ_STAT_INFO irq_stat_info;
+ RECEIVER_INFO ri;
+
#if _PCPS_USE_USB
int n_usb_ep; // number of endpoints supp. by the device
PCPS_USB_EP ep[MBGUSB_MAX_ENDPOINTS];
@@ -1139,6 +1174,9 @@ _ext const char *fw_id_ref[]
#define _pcps_ddev_has_ptp( _p ) \
_pcps_has_ptp( &(_p)->dev )
+#define _pcps_ddev_has_ptp_unicast( _p ) \
+ _pcps_has_ri_ptp_unicast( &(_p)->ri )
+
// The macros below simplify read/write access to the clocks.
@@ -1218,7 +1256,7 @@ _ext const char *fw_id_ref[]
// includes the BUSY flag and the modulation signal of DCF77
// clocks. The macro takes a (PCPS_DDEV *) as argument.
#define _pcps_ddev_read_status_port( _d ) \
- _mbg_inp8( (_d), (_d)->status_port )
+ _mbg_inp8( (_d), 0, (_d)->status_port )
#define _pcps_ddev_status_busy( _d ) \
( _pcps_ddev_read_status_port( pddev ) & PCPS_ST_BUSY )
diff --git a/mbglib/common/pcpslstr.h b/mbglib/common/pcpslstr.h
index 860ce2b..adf4b5e 100755
--- a/mbglib/common/pcpslstr.h
+++ b/mbglib/common/pcpslstr.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpslstr.h 1.27.1.3 2011/01/28 09:34:38 martin TEST $
+ * $Id: pcpslstr.h 1.27.1.5 2011/02/16 09:34:23 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: pcpslstr.h $
+ * Revision 1.27.1.5 2011/02/16 09:34:23 martin
+ * Added menu titles for PTP and PTP Unicast configuration.
+ * Revision 1.27.1.4 2011/02/09 14:43:42Z martin
* Revision 1.27.1.3 2011/01/28 09:34:38 martin
* Fixed build under FreeBSD.
* Revision 1.27.1.2 2010/11/22 15:23:06 martin
@@ -110,7 +113,7 @@
#include <ctrydttm.h>
#include <cnv_wday.h>
-#if defined MBG_TGT_HAS_WCHAR_T
+#if MBG_TGT_HAS_WCHAR_T
#include <wchar.h>
#endif
@@ -728,6 +731,32 @@ typedef struct
+// menu option: PTP configuration
+
+#define DEFAULT_OPT_NAME_PTP_CFG_EN "PTP Configuration"
+#define DEFAULT_OPT_NAME_PTP_CFG_DE "PTP-Konfiguration"
+
+#define DEFAULT_OPT_NAME_PTP_CFG \
+{ \
+ DEFAULT_OPT_NAME_PTP_CFG_EN, \
+ DEFAULT_OPT_NAME_PTP_CFG_DE \
+}
+
+
+
+// menu option: PTP Unicast configuration
+
+#define DEFAULT_OPT_NAME_PTP_UC_CFG_EN "PTP Unicast Configuration"
+#define DEFAULT_OPT_NAME_PTP_UC_CFG_DE "PTP-Unicast-Konfiguration"
+
+#define DEFAULT_OPT_NAME_PTP_UC_CFG \
+{ \
+ DEFAULT_OPT_NAME_PTP_UC_CFG_EN, \
+ DEFAULT_OPT_NAME_PTP_UC_CFG_DE \
+}
+
+
+
/*
* Default initializers for German mode string names.
* English strings are defined in in gpsdefs.h.
diff --git a/mbglib/common/words.h b/mbglib/common/words.h
index 6860911..2593bb2 100755
--- a/mbglib/common/words.h
+++ b/mbglib/common/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.25.1.1 2011/01/25 08:25:49 martin TEST $
+ * $Id: words.h 1.25.1.2 2011/03/22 09:41:32 martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
- * Revision 1.25.1.1 2011/01/25 08:25:49 martin
+ * Revision 1.25.1.2 2011/03/22 09:41:32 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.
* Revision 1.25 2010/11/17 10:23:09 martin
* Define _BIT_REDEFINED if bit type is redefined.
@@ -282,6 +284,9 @@ typedef unsigned long dword;
#define BYTE_OF( _v, _n ) *( ( (uint8_t *) &(_v) ) + (_n) )
#define WORD_OF( _v, _n ) *( ( (uint16_t *) &(_v) ) + (_n) )
+#define FBYTE_OF( _v, _n ) *( ( (uint8_t far *) &(_v) ) + (_n) )
+#define FWORD_OF( _v, _n ) *( ( (uint16_t far *) &(_v) ) + (_n) )
+
// same as above, but taking pointers
#define BYTE_OF_P( _p, _n ) *( ( (uint8_t *) (_p) ) + (_n) )
#define WORD_OF_P( _p, _n ) *( ( (uint16_t *) (_p) ) + (_n) )
diff --git a/mbgstatus/mbgstatus.c b/mbgstatus/mbgstatus.c
index 0e3d1e3..2409c5c 100755
--- a/mbgstatus/mbgstatus.c
+++ b/mbgstatus/mbgstatus.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgstatus.c 1.13.1.7 2011/02/07 12:10:58 martin TEST $
+ * $Id: mbgstatus.c 1.13.1.8 2011/03/03 10:01:23 daniel TRASH $
*
* Description:
* Main file for mbgstatus program which demonstrates how to
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgstatus.c $
+ * 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
* Use mbg_get_ptp_status() API call.
* Revision 1.13.1.6 2010/11/25 14:54:51 martin
@@ -606,20 +608,25 @@ void show_ptp_state( MBG_DEV_HANDLE dh )
const char *cp;
int ptp_state_available;
PTP_STATE ptp_state;
+ PTP_CFG_INFO ptp_info;
int rc = mbg_get_ptp_state( dh, &ptp_state );
if ( mbg_ioctl_err( rc, "mbg_get_ptp_state" ) )
return;
+ rc = mbg_get_ptp_cfg_info( dh, &ptp_info );
- printf( "PTP port status:\n" );
+ if ( mbg_ioctl_err( rc, "mbg_get_ptp_info" ) )
+ return;
- printf( " Port mode: %s\n", ( ptp_state.port_state < N_PTP_PORT_STATE ) ?
- ptp_stat_str[ptp_state.port_state] : "(undefined)" );
+ printf( "PTP port status:\n" );
ptp_state_available = ( ptp_state.port_state == PTP_PORT_STATE_SLAVE );
+ printf( " Port mode: %s%s\n", ( ptp_state_available && ptp_info.settings.ptp_role == PTP_ROLE_UNICAST_SLAVE ) ? "Unicast" : "",
+ ( ptp_state.port_state < N_PTP_PORT_STATE ) ? ptp_stat_str[ptp_state.port_state] : "(undefined)" );
+
cp = ptp_state_available ? ws : str_not_avail;
snprintf( ws, sizeof( ws ), "%02X-%02X-%02X-%02X-%02X-%02X",
diff --git a/mbgsvcd/mbgsvcd.c b/mbgsvcd/mbgsvcd.c
index 54e4410..1a4921e 100755
--- a/mbgsvcd/mbgsvcd.c
+++ b/mbgsvcd/mbgsvcd.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsvcd.c 1.3.1.1 2010/04/26 14:37:41 martin TEST $
+ * $Id: mbgsvcd.c 1.3.1.3 2011/03/25 11:05:24 martin TRASH $
*
* Description:
* Main file for mbgsvcd which compares the system time to a PCI card's
@@ -9,6 +9,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsvcd.c $
+ * Revision 1.3.1.3 2011/03/25 11:05:24 martin
+ * Optionally support timespec for sys time.
+ * Cleanup.
+ * Revision 1.3.1.2 2011/03/23 16:30:40 martin
+ * Use /var/run as directory for the lockfile.
* Revision 1.3.1.1 2010/04/26 14:37:41 martin
* Print PC cycles counter frequency at program start.
* Revision 1.3 2010/03/03 14:59:36 martin
@@ -48,14 +53,14 @@
#define SHM_UNIT 0 /* SHM driver unit number (0..3) */
#define MAX_SHM_REFCLOCKS 4
-#define RUNNING_DIR "/var/run/mbgsvcd"
+#define RUNNING_DIR "/var/run"
#define LOCK_FILE "mbgsvcd.pid"
#define EXEC_TIME_SAMPLES 20
static const char *pname = "mbgsvcd";
-static const char *pversion = "v1.1";
-static const char *pcopyright = "(c) Meinberg 2010";
+static const char *pversion = "v1.2";
+static const char *pcopyright = "(c) Meinberg 2010-2011";
static int sleep_intv = 1;
static int pretend_sync;
@@ -114,37 +119,44 @@ struct shmTime *getShmTime(int unit)
+static /*HDR*/
void ntpshm_init( void )
{
int i = 0;
syslog(LOG_INFO, "Initializing shared memory for ntpd");
- for ( i = 0; i< MAX_SHM_REFCLOCKS; i++)
- shmTime[i] = getShmTime(i);
-}
+ for ( i = 0; i< MAX_SHM_REFCLOCKS; i++ )
+ shmTime[i] = getShmTime( i );
+} // ntpshm_init
+
+static /*HDR*/
int ntpshm_alloc( void )
{
int i;
for ( i = 0; i< MAX_SHM_REFCLOCKS; i++)
{
- if ( shmTime[i] != NULL )
+ struct shmTime *p = shmTime[i];
+
+ if ( p )
{
- memset( (void* ) shmTime[i], 0, sizeof( struct shmTime ) );
+ memset( p, 0, sizeof( *p ) );
- shmTime[i]->mode = 1;
- shmTime[i]->precision = -5; /* initially 0.5 sec */
- shmTime[i]->nsamples = 3; /* stages of median filter */
+ p->mode = 1;
+ p->precision = -5; /* initially 0.5 sec */
+ p->nsamples = 3; /* stages of median filter */
printf( "Shared memory %d initialized\n", i );
}
}
+
return 0;
-}
+
+} // ntpshm_alloc
@@ -203,101 +215,119 @@ int do_mbgsvctasks( void )
for (;;)
{
-
for ( i = 0; i < n_devices; i++ )
{
- double ltcy_us,exec_us;
+ 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;
+ const char *cp;
if ( !_pcps_has_hr_time( &devs[i] ) )
{
printf( "This device does not support HR time stamps.\n" );
continue;
}
- else
- {
- rc = mbg_get_time_info_hrt( dhs[i], &hrti );
- if ( mbg_ioctl_err( rc, "mbg_get_time_info_..." ) )
- continue;
- p_ref_ts = &hrti.ref_hr_time_cycles.t.tstamp;
- p_ref_cyc = &hrti.ref_hr_time_cycles.cycles;
- p_sys_tic = &hrti.sys_time_cycles;
- }
+ rc = mbg_get_time_info_hrt( dhs[i], &hrti );
- mbg_snprint_hr_tstamp( ws, sizeof( ws ), p_ref_ts );
- 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 + (double) p_sys_tic->sys_time.tv_usec / 1e6;
+ if ( mbg_ioctl_err( rc, "mbg_get_time_info_..." ) )
+ continue;
- printf ( "%-9s: %s UTC: %.6f-%.6f: %+.6f s",_pcps_type_name( &devs[i] ),
- ws, d_ref, d_sys, d_ref - d_sys );
- {
- double ltcy_sec,exec_sec;
- MBG_PC_CYCLES ltcy_cyc = mbg_delta_pc_cycles( p_ref_cyc, &p_sys_tic->cyc_after );
- MBG_PC_CYCLES exec_cyc = mbg_delta_pc_cycles( &p_sys_tic->cyc_after, &p_sys_tic->cyc_before );
+ p_ref_ts = &hrti.ref_hr_time_cycles.t.tstamp;
+ p_ref_cyc = &hrti.ref_hr_time_cycles.cycles;
+ p_sys_tic = &hrti.sys_time_cycles;
- ltcy_sec = ( (double) ltcy_cyc ) / (double) cyc_freq;
- exec_sec = ( (double) exec_cyc ) / (double) cyc_freq;
+ d_ref = (double) p_ref_ts->sec + ( (double) p_ref_ts->frac ) / (double) PCPS_HRT_BIN_FRAC_SCALE;
- // compensate latencies between time stamps ->
- // normalize ref time to system time stamp
- d_ref -= ltcy_sec;
+ 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
- ltcy_us = ltcy_sec * 1e6;
- exec_us = exec_sec * 1e6;
+ 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 );
- exec_times[excnt++] = exec_us;
+ ltcy_sec = ( (double) ltcy_cyc ) / (double) cyc_freq;
+ exec_sec = ( (double) exec_cyc ) / (double) cyc_freq;
- if (excnt == EXEC_TIME_SAMPLES)
- {
- exec_limit = 0;
+ // compensate latencies between time stamps ->
+ // normalize ref time to system time stamp
+ d_ref_comp = d_ref - ltcy_sec;
- for ( excnt = 0; excnt < EXEC_TIME_SAMPLES; excnt++)
- exec_limit += exec_times[excnt];
+ ltcy_us = ltcy_sec * 1e6;
+ exec_us = exec_sec * 1e6;
- exec_limit /= ( (double) EXEC_TIME_SAMPLES );
- exec_limit = (exec_limit * 1.7);
- excnt = 0;
- }
+ exec_times[excnt++] = exec_us;
+
+ if ( excnt == EXEC_TIME_SAMPLES )
+ {
+ exec_limit = 0;
- printf( ", ltcy: %.2f us, exec: %.2f us, limit: %.2f us: %+.6f s", ltcy_us, exec_us, exec_limit, d_ref - d_sys );
+ for ( excnt = 0; excnt < EXEC_TIME_SAMPLES; excnt++ )
+ exec_limit += exec_times[excnt];
+
+ exec_limit /= ( (double) EXEC_TIME_SAMPLES );
+ exec_limit *= 1.7;
+ excnt = 0;
}
+
+ 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 ) ) )
{
- printf(" *\n");
+ struct shmTime *p = shmTime[i];
+
+ cp = " *";
// fill SHM structure
- shmTime[i]->count++;
- shmTime[i]->clockTimeStampSec = (time_t) d_ref;
- shmTime[i]->clockTimeStampUSec = (int) ( ( d_ref - shmTime[i]->clockTimeStampSec ) * 1e6 ); // get µs from d_ref
- shmTime[i]->receiveTimeStampSec = (time_t) p_sys_tic->sys_time.tv_sec;
- shmTime[i]->receiveTimeStampUSec = (int) p_sys_tic->sys_time.tv_usec;
+ 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
// patch precision value according to the ref time accuracy
if ( _pcps_is_lwr( &devs[i] ) )
- shmTime[i]->precision = -8;
+ p->precision = -8;
else if (_pcps_is_irig_rx( &devs[i] ) )
{
if ( _pcps_is_usb( &devs[i] ) )
- shmTime[i]->precision = -10;
+ p->precision = -10;
else
- shmTime[i]->precision = -18;
+ p->precision = -18;
}
else
- shmTime[i]->precision = -20;
+ p->precision = -20;
- shmTime[i]->count++;
- shmTime[i]->valid = 1;
+ p->count++;
+ p->valid = 1;
}
- else
- printf("\n");
- usleep(10);
+ 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",
+ _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 );
+
+ usleep( 10 );
}
printf("\n");
@@ -312,7 +342,7 @@ done:
return rc;
-} // do_mbgchksystime
+} // do_mbgsvctasks
@@ -336,6 +366,7 @@ void usage( void )
+static /*HDR*/
void startup_daemon( void )
{
int i,lfp;
@@ -378,14 +409,13 @@ void startup_daemon( void )
/* first instance continues */
sprintf(str,"%d\n",getpid());
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);
-}
-
+} // startup_daemon
@@ -397,6 +427,10 @@ int main( int argc, char *argv[] )
mbg_print_program_info( pname, pversion, pcopyright );
+ #if ( USE_TIMESPEC )
+ printf( "(using nanosecond resolution)\n\n" );
+ #endif
+
// check command line parameters
while ( ( c = getopt( argc, argv, "fps:h?" ) ) != -1 )
{
@@ -405,9 +439,11 @@ int main( int argc, char *argv[] )
case 'f':
foreground = 1;
break;
+
case 'p':
pretend_sync = 1;
break;
+
case 's':
sleep_intv = atoi( optarg );
break;
@@ -428,7 +464,7 @@ int main( int argc, char *argv[] )
if ( foreground == 0 )
startup_daemon();
- syslog(LOG_INFO, "Starting Meinberg Service Daemon %s %s %s", pname, pversion, pcopyright );
+ syslog( LOG_INFO, "Starting Meinberg Service Daemon %s %s %s", pname, pversion, pcopyright );
rc = do_mbgsvctasks();