summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2017-08-11 12:01:00 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2017-08-11 12:01:00 +0200
commit5321b64b41aa3d070eb7f028a0adfb2d488404f4 (patch)
tree66a8e232d6bd816ef23b720bb97c68d7dbb76b74
parent3743722bf58ea2819f6c81974d75baa295562572 (diff)
downloadmbgtools-nbsd-5321b64b41aa3d070eb7f028a0adfb2d488404f4.tar.gz
mbgtools-nbsd-5321b64b41aa3d070eb7f028a0adfb2d488404f4.zip
Update files from mbgtools-nbsd-dev-2017-08-11.tar.gzmbgtools-nbsd-dev-2017-08-11
Also remove some more obsolete files.
-rwxr-xr-xMakefile110
-rwxr-xr-xmbgclock/Makefile27
-rwxr-xr-xmbgclock/mbgclock_main.c153
-rwxr-xr-xmbglib/common/mbg_tgt.h16
-rwxr-xr-xmbglib/common/mbgddmsg.h9
-rwxr-xr-xmbglib/common/mbggenio.h30
-rwxr-xr-xmbglib/common/mbgsystm.h5
-rwxr-xr-xmbglib/common/pcpsdrvr.c31
-rwxr-xr-xmbglib/common/pcpsdrvr.h45
-rwxr-xr-xsrc/external/bsd/meinberg/Makefile6
-rwxr-xr-xsrc/external/bsd/meinberg/Makefile.inc30
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/Makefile.kmod20
-rwxr-xr-xsrc/external/bsd/meinberg/mbgclock/files.mbgclock13
13 files changed, 282 insertions, 213 deletions
diff --git a/Makefile b/Makefile
index e1a79f8..9406799 100755
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,21 @@
#########################################################################
#
-# $Id: Makefile 1.1.1.4 2017/07/26 14:31:06 martin TEST $
+# $Id: Makefile 1.1.1.8 2017/08/11 10:32:21 martin TEST $
#
# Description:
# Makefile for mbgtools which recurses into the subdirectories.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.1.1.8 2017/08/11 10:32:21 martin
+# Cleaned up CPPFLAGS.
+# Revision 1.1.1.7 2017/08/10 15:40:25 martin
+# Cleanup.
+# Revision 1.1.1.6 2017/08/10 15:15:02 martin
+# Merged common kernel module stuff.
+# Revision 1.1.1.5 2017/08/02 12:13:19 martin
+# Re-added mbgclock to SUBDIRS.
# Revision 1.1.1.4 2017/07/26 14:31:06 martin
# Removed trailing spaces.
# Revision 1.1.1.3 2011/11/24 13:59:58 martin
@@ -166,7 +174,7 @@ SUBDIRS += test/mbgtestcalrec
# SUBDIRS += test/mbgtestmmio
# SUBDIRS += test/mbgtestxhrt
# SUBDIRS += test/mbgchksystime
-## SUBDIRS += mbgclock #out of tree in this project
+SUBDIRS += mbgclock
.PHONY: all clean distclean install uninstall
all clean distclean install uninstall:
@@ -190,12 +198,23 @@ cleanreload: clean all install reload
# This section is evaluated only if this makefile is included from
# a subproject's makefile.
-
.ifndef MBGLIB
MBGLIB := $(BASEDIR)/mbglib
.endif
-MBGLIB_DIRS += common linux
+## MBGLIB_DIRS += common linux
+
+MBGLIB_COMMON = ${MBGLIB}/common
+MBGLIB_BSD = ${MBGLIB}/bsd
+
+INCLUDES += -I.
+INCLUDES += -I$(BASEDIR)
+
+## INCLUDES += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
+
+INCLUDES += -I$(MBGLIB_COMMON)
+INCLUDES += -I$(MBGLIB_BSD)
+
# Macros useful to run individual commands as root:
.ifndef CALLED_FROM_SPEC
@@ -216,38 +235,23 @@ MBGLIB_DIRS += common linux
run_as_root = $(shell echo "$(SUDO) $(1) || $(SU) -c \"$(1)\"" )
make_as_root = $(call run_as_root, make $(1))
-.ifndef MODULE_OBJS #===========================================================
-
-# not building a kernel module
-
-CFLAGS += -Wall
-## CFLAGS += -W
-
.ifdef DEBUG
- CFLAGS += -DDEBUG=$(DEBUG)
- CFLAGS += -g
-.else
- CFLAGS += -O2
+ CPPFLAGS += -DDEBUG=$(DEBUG)
+ CPPFLAGS += -g
.endif
-.ifdef USE_TIMESPEC
- CFLAGS += -DUSE_TIMESPEC=$(USE_TIMESPEC)
-.endif
-
-CFLAGS += -I.
-CFLAGS += -I$(BASEDIR)
-CFLAGS += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
-#########
-CFLAGS += -I$(BASEDIR)/mbglib/common
-CFLAGS += -I$(BASEDIR)/mbglib/bsd
+.ifndef KMOD #===========================================================
+# not building a kernel module
-# Use all CFLAGS defined above also for C++ files.
-CXXFLAGS += $(CFLAGS)
+CPPFLAGS += -Wall
+## CPPFLAGS += -W
-# Additional C++-only compiler flags.
-## CXXFLAGS += -Wno-deprecated
+.ifdef USE_TIMESPEC
+ CPPFLAGS += -DUSE_TIMESPEC=$(USE_TIMESPEC)
+.endif
+CPPFLAGS += $(INCLUDES)
LDFLAGS += $(foreach dir,$(SO_SUBDIRS),-L $(BASEDIR)/$(dir) )
@@ -269,8 +273,8 @@ SO_MINOR_VERSION = 0
CLEAN_FILES += $(SO_TARGET_LIBNAME)
- CFLAGS += -fPIC
- CFLAGS += -c
+ CPPFLAGS += -fPIC
+ CPPFLAGS += -c
LDFLAGS += -shared
LDFLAGS += -lc
@@ -286,15 +290,15 @@ SO_MINOR_VERSION = 0
.PHONY: all
all: $(TARGET)
-#### VPATH += $(foreach dir,$(MBGLIB_DIRS),$(MBGLIB)/$(dir))
-VPATH = $(BASEDIR)/mbglib/common:$(BASEDIR)/mbglib/bsd
+## VPATH += $(foreach dir,$(MBGLIB_DIRS),$(MBGLIB)/$(dir))
+VPATH = $(MBGLIB_COMMON):$(MBGLIB_BSD)
.ifndef MBGDEVIO_SIMPLE
MBGDEVIO_SIMPLE = 1
.endif
.ifdef MBGDEVIO_SIMPLE
- CFLAGS += -DMBGDEVIO_SIMPLE=$(MBGDEVIO_SIMPLE)
+ CPPFLAGS += -DMBGDEVIO_SIMPLE=$(MBGDEVIO_SIMPLE)
.endif
@@ -321,14 +325,14 @@ VPATH = $(BASEDIR)/mbglib/common:$(BASEDIR)/mbglib/bsd
USE_THREAD_AFFINITY=0
.else
#if supported via nptl add the associated search paths
- CFLAGS += -I /usr/include/nptl -L /usr/lib/nptl
+ CPPFLAGS += -I /usr/include/nptl -L /usr/lib/nptl
.endif
.endif
# May want to use the result for our program
- ## CFLAGS += -DUSE_THREAD_AFFINITY=$(USE_THREAD_AFFINITY)
+ ## CPPFLAGS += -DUSE_THREAD_AFFINITY=$(USE_THREAD_AFFINITY)
- CFLAGS += -DMBGDEVIO_USE_THREAD_API=1
+ CPPFLAGS += -DMBGDEVIO_USE_THREAD_API=1
#LDFLAGS += -lpthread
LDFLAGS += -pthread
@@ -356,8 +360,8 @@ VPATH = $(BASEDIR)/mbglib/common:$(BASEDIR)/mbglib/bsd
.endif
-## $(warning $(INFO) CFLAGS=$(CFLAGS))
-## $(warning $(INFO) EXTRA_CFLAGS=$(EXTRA_CFLAGS))
+## $(warning $(INFO) CPPFLAGS=$(CPPFLAGS))
+## $(warning $(INFO) EXTRA_CPPFLAGS=$(EXTRA_CPPFLAGS))
## $(warning $(INFO) MAKECMDGOALS = $(MAKECMDGOALS))
$(TARGET): $(OBJS)
@@ -454,7 +458,33 @@ clean:
.else
-# ===== Building module for kernel 2.6 =============================================
+# ===== Building a kernel module =============================================
+
+USE_FORT?= yes # network client/server
+
+# WARNS?= 5
+
+.include <bsd.own.mk>
+
+CPPFLAGS += ${INCLUDES}
+
+## .if defined(DEBUG)
+## CPPFLAGS += -DDEBUG=${DEBUG}
+## .endif
+
+.if defined(MBG_DEBUG)
+CPPFLAGS += -DMBG_DEBUG=${MBG_DEBUG}
+.endif
+
+.PATH: ${MBGLIB_COMMON} ${MBGLIB_BSD}
+
+MKMAN=no
+
+.if !defined (MKMODULAR) || ( defined(MKMODULAR) && (${MKMODULAR}!="no") )
+.include <bsd.kmodule.mk>
+.else
+.include <bsd.kmod.mk>
+.endif
.endif # building kernel module
#==================================================================================
diff --git a/mbgclock/Makefile b/mbgclock/Makefile
index 85ad982..32fce7d 100755
--- a/mbgclock/Makefile
+++ b/mbgclock/Makefile
@@ -1 +1,26 @@
-.include "Makefile.kmod" \ No newline at end of file
+
+#########################################################################
+#
+# $Id: Makefile 1.1.1.2 2017/08/10 15:10:19 martin TEST $
+#
+# Description:
+# Makefile for NetBSD kernel driver mbgclock.
+#
+# -----------------------------------------------------------------------
+# $Log: Makefile $
+# Revision 1.1.1.2 2017/08/10 15:10:19 martin
+# *** empty log message ***
+#
+#########################################################################
+
+# CPPFLAGS += -D_HAVE_PPS_REF_EVENT -DPPS_SYNC
+
+KMOD = mbgclock
+
+SRCS = mbgclock_main.c
+SRCS += pcpsdrvr.c
+SRCS += identdec.c
+SRCS += rsrc_bsd.c
+
+BASEDIR := ..
+include $(BASEDIR)/Makefile
diff --git a/mbgclock/mbgclock_main.c b/mbgclock/mbgclock_main.c
index 1eafb29..cd4adc4 100755
--- a/mbgclock/mbgclock_main.c
+++ b/mbgclock/mbgclock_main.c
@@ -1,11 +1,55 @@
-/*
- * $Header: /repository/clkdrv/bsd/netbsd/soft/mbgtools-nbsd/mbgclock/RCS/mbgclock_main.c 1.1.1.13 2017/07/26 15:25:56 martin TEST $
+
+/**************************************************************************
*
- * NetBSD Meinberg mbgclock driver, Frank Kardel
+ * $Id: mbgclock_main.c 1.3.1.1 2017/08/11 10:18:36 martin TEST $
*
- * $Created: Sat Mar 26 15:03:37 2011 $
+ * Description:
+ * Main file for for mbgclock driver to support Meinberg bus level
+ * devices under NetBSD.
*
- */
+ * The binary is a loadable module called mbgclock which implements
+ * /dev/mbgclock* devices.
+ *
+ * Copyright (c) 2011-2017 Frank Kardel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgclock_main.c $
+ * Revision 1.3.1.1 2017/08/11 10:18:36 martin
+ * Re-added LKM support.
+ * Removed obsolete debug stuff.
+ * Revision 1.3 2017/08/10 16:06:38 martin
+ * String 'pcps_driver_name' is now defined in pcpsdrvr.h.
+ * Account for unified extended resource properties handling.
+ * Account for renamed library symbols.
+ * Revision 1.2 2017/08/10 16:04:28 martin
+ * Updates submitted by Frank Kardel.
+ * Revision 1.1 2011/01/26 13:56:32 martin
+ * Initial revision submitted by Frank Kardel.
+ *
+ **************************************************************************/
#include <sys/param.h>
#include <sys/lwp.h>
@@ -22,10 +66,6 @@
#include <sys/errno.h>
#include <sys/atomic.h>
-#ifdef MBG_DEBUG
- #define DEBUG MBG_DEBUG
-#endif
-
#include <pcpsdrvr.h>
#include <mbgddmsg.h>
@@ -33,23 +73,17 @@
#define PCI_BAR(__n) (0x10 + 4 * (__n))
#endif
-#define REV_NUM 0x100
-#define REV_NUM_STR "1.00"
-#define MBG_COPYRIGHT "(c) Meinberg 2011"
+#define REV_NUM 0x101
+#define REV_NUM_STR "1.01"
+#define MBG_COPYRIGHT "(c) Meinberg 2011, Frank Kardel 2011-2017"
#define MBG_DRVR_NAME "mbgclock"
#define MBG_VENDOR "Meinberg Funkuhren"
-const char pcps_driver_name[] = MBG_DRVR_NAME;
-
static MBG_DBG_DATA mbg_dbg_data;
static MBG_DBG_PORT mbg_dbg_port = 0x378 + 0; //##++
static PCPS_IO_ADDR_MAPPED mbg_dbg_port_mapped; //##++
static PCPS_DRVR_INFO drvr_info = { REV_NUM, 0, MBG_DRVR_NAME " radio clock driver" };
-#ifndef MBG_PCPS_FMT_STATUS
-#define MBG_PCPS_FMT_STATUS "\177\20b\0FREER\0b\1DL_ENB\0b\2SYNCD\0b\3DL_ANN\0b\4UTC\0b\5LS_ANN\0b\6IFTM\0b\7INVT\0b\x08LS_ENB\0b\11ANT_FAIL\0b\x0aLS_ANN_NEG\0b\x0bSCALE_GPS\0b\x0cSCALE_TAI\0\0"
-#endif
-
#include <macioctl.h>
static dev_type_open(mbgclockopen);
@@ -92,7 +126,7 @@ const struct cdevsw mbgclock_cdevsw = {
.d_poll = nopoll,
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
- D_OTHER|D_MPSAFE
+ .d_flag = D_OTHER|D_MPSAFE
};
#ifdef CFATTACH_DECL3_NEW
@@ -118,12 +152,6 @@ CFATTACH_DECL2_NEW(mbgclock,
extern struct cfdriver mbgclock_cd;
-#undef DEBUG /* XXX for now */
-
-#if defined( MBG_DEBUG )
-int debug = MBG_DEBUG;
-#endif
-
#if defined( DEBUG )
static int mbgclockdebug = ~0;
#define DB_FOLLOW 0x00000001
@@ -322,7 +350,7 @@ mbgclock_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
/* PCI Support Functions */
static void
-mbg_deallocate_resource( BSD_RSRC_INFO *p_ri )
+mbg_deallocate_resource( EXT_RSRC_INFO *p_ri )
{
if ( p_ri->valid )
{
@@ -339,23 +367,23 @@ mbg_dealloc_rsrcs( struct mbgclock_softc *psc )
{
PCPS_DDEV *pddev = psc->pddev;
-/* mbg_deallocate_resource( device, &prsrci->irq.bsd, SYS_RES_IRQ ); */
-
if ( pddev != NULL )
{
PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
int i;
+ /* mbg_deallocate_resource( device, &prsrci->irq.bsd, SYS_RES_IRQ ); */
+
for ( i = 0; i < N_PCPS_MEM_RSRC; i++ )
- mbg_deallocate_resource( &prsrci->mem[i].bsd );
+ mbg_deallocate_resource( &prsrci->mem[i].ext );
for ( i = 0; i < N_PCPS_PORT_RSRC; i++ )
- mbg_deallocate_resource( &prsrci->port[i].bsd );
+ mbg_deallocate_resource( &prsrci->port[i].ext );
}
}
static void
-mbg_alloc_rsrc( struct mbgclock_softc *psc , int reg, BSD_RSRC_INFO *p_ri, int type )
+mbg_alloc_rsrc( struct mbgclock_softc *psc , int reg, EXT_RSRC_INFO *p_ri, int type )
{
p_ri->reg = reg;
p_ri->type = type;
@@ -373,17 +401,26 @@ mbg_alloc_rsrc( struct mbgclock_softc *psc , int reg, BSD_RSRC_INFO *p_ri, int t
static void
mbg_alloc_rsrcs( struct mbgclock_softc *psc )
{
- PCPS_DDEV *pddev = psc->pddev;
+ PCPS_DDEV *pddev = psc->pddev;
PCPS_RSRC_INFO *prsrci = &pddev->rsrc_info;
- BSD_RSRC_INFO ri;
- int bar;
+ EXT_RSRC_INFO ri;
+ pcireg_t command;
+ int bar;
+
/* clear valid flags */
for ( bar = 0; bar < prsrci->num_rsrc_io; bar ++)
- prsrci->port[bar].bsd.valid = 0;
+ prsrci->port[bar].ext.valid = 0;
for ( bar = 0; bar < prsrci->num_rsrc_mem; bar ++)
- prsrci->mem[bar].bsd.valid = 0;
+ prsrci->mem[bar].ext.valid = 0;
+
+ command = pci_conf_read(psc->pa.pa_pc, psc->pa.pa_tag, PCI_COMMAND_STATUS_REG);
+
+ _mbgddmsg_4( MBG_DBG_INIT_DEV,
+ "%s: PCI device 0x%04X:0x%04X : command status register: 0x%08X",
+ pcps_driver_name, PCI_VENDOR(psc->pa.pa_id),
+ PCI_PRODUCT(psc->pa.pa_id), command );
for ( bar = 0; bar < 6; bar ++ )
{
@@ -391,7 +428,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
int reg = PCI_BAR( bar );
_mbgddmsg_4( MBG_DBG_INIT_DEV,
- "%s: alloc I/O range %i: PCI device 0x%04X:0x%04X supported",
+ "%s: alloc I/O range %i: PCI device 0x%04X:0x%04X",
pcps_driver_name, bar, PCI_VENDOR(psc->pa.pa_id),
PCI_PRODUCT(psc->pa.pa_id) );
@@ -404,7 +441,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
if ( ri.valid )
{
- prsrci->port[prsrci->num_rsrc_io].bsd = ri;
+ prsrci->port[prsrci->num_rsrc_io].ext = ri;
pcps_add_rsrc_io( pddev, ri.base, ri.size );
continue;
}
@@ -417,7 +454,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
}
break;
- case PCI_MAPREG_MEM_TYPE_64BIT:
+ case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
#if __LP64__
#if 0
aprint_error_dev(psc->dev,
@@ -427,7 +464,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
#else
/*FALLTHROUGH*/
#endif
- case PCI_MAPREG_TYPE_MEM:
+ case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
/* case PCI_MAPREG_TYPE_ROM: currently same as above */
if ( prsrci->num_rsrc_mem < N_PCPS_MEM_RSRC )
{
@@ -435,7 +472,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
if ( ri.valid )
{
- prsrci->mem[prsrci->num_rsrc_mem].bsd = ri;
+ prsrci->mem[prsrci->num_rsrc_mem].ext = ri;
pcps_add_rsrc_mem( pddev,
(MBG_MEM_ADDR)bus_space_vaddr( ri.bst, ri.bsh),
ri.size );
@@ -456,7 +493,7 @@ mbg_alloc_rsrcs( struct mbgclock_softc *psc )
if ( ri.res )
{
- prsrci->port[prsrci->num_rsrc_irq].bsd = ri;
+ prsrci->port[prsrci->num_rsrc_irq].ext = ri;
pcps_add_rsrc_irq( pddev, rman_get_start( ri.res ) );
}
#endif
@@ -497,22 +534,34 @@ mbgclock_match(struct device *parent, struct cfdata *match, void *aux)
return 0;
}
-
static void
mbgclock_attach(struct device *parent, struct device *self, void *aux)
{
int rc = 0;
int idx;
char devinfo[256];
+ int error;
struct mbgclock_softc *psc = device_private(self);
struct pci_attach_args *pa = aux;
uint16_t dev_id = PCI_PRODUCT(pa->pa_id);
+ pcireg_t ecap;
DPRINTF(DB_FOLLOW, ("mbgclock_attach(0x%p, 0x%p, 0x%p)\n", parent, self, aux));
psc->dev = self;
psc->pa = *pa;
psc->last_status = 0;
+ callout_init(&psc->callout, CALLOUT_MPSAFE);
+
+#ifdef DEBUG
+ pci_conf_print(psc->pa.pa_pc, psc->pa.pa_tag, NULL);
+#endif
+
+ if ((error = pci_activate(psc->pa.pa_pc, psc->pa.pa_tag, self,
+ NULL)) && error != EOPNOTSUPP) {
+ aprint_error_dev(psc->dev, "cannot activate %d\n", error);
+ return;
+ }
_mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: attach for device 0x%04X",
pcps_driver_name, dev_id );
@@ -592,7 +641,7 @@ mbgclock_attach(struct device *parent, struct device *self, void *aux)
/* actually 10 MHz as fraction counter covering 2^32 ticks */
psc->tc.tc_frequency = 0x100000000ULL;
psc->tc.tc_name = NULL; /* NULL -> not enabled */
- psc->tc.tc_quality = -10000;
+ psc->tc.tc_quality = 0; /* don't override any std time counters */
psc->tc.tc_priv = psc;
psc->tc.tc_next = NULL;
@@ -603,8 +652,6 @@ mbgclock_attach(struct device *parent, struct device *self, void *aux)
tc_init(&psc->tc);
}
- callout_init(&psc->callout, CALLOUT_MPSAFE);
-
return;
fail:
@@ -786,7 +833,7 @@ int mbgclockioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
PCPS_DDEV *pddev;
int rc;
- _mbgddmsg_1( MBG_DBG_INIT_DEV, "%s: ioctl called", pcps_driver_name );
+ _mbgddmsg_2( MBG_DBG_INIT_DEV, "%s: ioctl called, flag=0x%x", pcps_driver_name, flag );
DPRINTF(DB_FOLLOW, ("mbgclockioctl(0x%"PRIx64", 0x%lx, %p, 0x%x, %p)\n",
dev, cmd, data, flag, l->l_proc));
@@ -875,7 +922,7 @@ int mbgclockioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_WRITE,
&cmd))
{
- _mbgddmsg_5( MBG_DBG_INFO, "%s: %p IOCTL 0x%02lX: WRTIE/PASSTHRU_WRITE permission denied, dev %s_%s",
+ _mbgddmsg_5( MBG_DBG_INFO, "%s: %p IOCTL 0x%02lX: WRITE/PASSTHRU_WRITE permission denied, dev %s_%s",
pcps_driver_name, dev, cmd, _pcps_ddev_type_name( pddev ), _pcps_ddev_sernum( pddev ) );
return EPERM;
}
@@ -1048,7 +1095,8 @@ mbgclock_tick(void *arg)
pps_ref_event(&psc->pps_state,
(psc->pps_state.ppsparam.mode & PPS_CAPTUREASSERT) ?
PPS_CAPTUREASSERT : PPS_CAPTURECLEAR,
- &bintime_ref_ts);
+ &bintime_ref_ts,
+ PPS_REFEVNT_CAPCUR);
}
mutex_spin_exit(&timecounter_lock);
@@ -1079,7 +1127,8 @@ mbgclock_tick(void *arg)
pps_ref_event(&psc->pps_state,
(psc->pps_state.ppsparam.mode & PPS_CAPTUREASSERT) ?
PPS_CAPTUREASSERT : PPS_CAPTURECLEAR,
- &bintime_ref_ts);
+ &bintime_ref_ts,
+ PPS_REFEVNT_CAPCUR);
mutex_spin_exit(&timecounter_lock);
}
@@ -1099,7 +1148,7 @@ mbgclock_tick(void *arg)
snprintb(b, sizeof b, MBG_PCPS_FMT_STATUS, ht.status);
aprint_error_dev(psc->dev,
- "clock nut synchronized: Status=%s\n",
+ "clock not synchronized: Status=%s\n",
b);
/* XXX kill timecounter - only needed while counter is linked to time */
if (psc->tc.tc_name != NULL) {
@@ -1130,5 +1179,5 @@ mbgclock_tick(void *arg)
* calculate next callout shortly after next second
*/
microtime(&tv);
- callout_schedule(&psc->callout, hz - mstohz(tv.tv_usec / 1000));
+ callout_schedule(&psc->callout, 1 + hz - mstohz(tv.tv_usec / 1000));
}
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index 2a63b1a..373edb1 100755
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.36 2017/07/04 12:35:11 martin REL_M $
+ * $Id: mbg_tgt.h 1.38 2017/08/08 13:07:31 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
+ * Revision 1.38 2017/08/08 13:07:31 martin
+ * Proper fix for PRId64 and others.
+ * Define _CRT_SECURE_NO_WARNINGS only if not already defined.
+ * Revision 1.37 2017/07/10 07:08:45 thomas-b
+ * Define PRId64 if it is not defined in inttypes.h
* Revision 1.36 2017/07/04 12:35:11 martin
* Fixed build for Windows kernel space.
* Don't define ssize_t if HAVE_SSIZE_T is already defined.
@@ -350,11 +355,14 @@ extern "C" {
#define MBG_TGT_POSIX
#define MBG_TGT_UNIX
+
#endif
#if defined( MBG_TGT_WIN32 )
- #define _CRT_SECURE_NO_WARNINGS 1
+ #if !defined( _CRT_SECURE_NO_WARNINGS )
+ #define _CRT_SECURE_NO_WARNINGS 1
+ #endif
#endif
@@ -557,6 +565,10 @@ extern "C" {
#include <stdint.h>
#include <inttypes.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
+
+ #if !defined( PRId64 )
+ #define MBG_PRE64_PREFIX "I64"
+ #endif
#else
#define MBG_TGT_HAS_INT_8_16_32 1
#define MBG_PRE64_PREFIX "I64"
diff --git a/mbglib/common/mbgddmsg.h b/mbglib/common/mbgddmsg.h
index 4517d7b..be08283 100755
--- a/mbglib/common/mbgddmsg.h
+++ b/mbglib/common/mbgddmsg.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgddmsg.h 1.11 2017/07/05 14:31:23 martin REL_M $
+ * $Id: mbgddmsg.h 1.12 2017/08/10 13:52:39 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -13,6 +13,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgddmsg.h $
+ * Revision 1.12 2017/08/10 13:52:39 martin
+ * Distinguish targets in more detail.
* Revision 1.11 2017/07/05 14:31:23 martin
* Added _mbg_kdd_msg...() macros.
* Code cleanup.
@@ -59,8 +61,9 @@
#include <linux/version.h>
#elif defined( MBG_TGT_BSD )
// nothing to include
-#else // MBG_TGT_QNX, MBG_TGT_DOS, ...
- //##+++++++++++++
+#elif defined( MBG_TGT_QNX )
+ #include <stdio.h>
+#elif defined( MBG_TGT_DOS )
#include <stdio.h>
#endif
diff --git a/mbglib/common/mbggenio.h b/mbglib/common/mbggenio.h
index 4487130..fbb8f4d 100755
--- a/mbglib/common/mbggenio.h
+++ b/mbglib/common/mbggenio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbggenio.h 1.6 2012/10/02 18:43:36 martin REL_M $
+ * $Id: mbggenio.h 1.7 2017/08/10 13:53:37 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbggenio.h $
+ * Revision 1.7 2017/08/10 13:53:37 martin
+ * Unified extended resource properties handling.
* Revision 1.6 2012/10/02 18:43:36 martin
* Fixed includes for NetBSD.
* Specify I/O range number when calling port I/O macros
@@ -78,19 +80,19 @@ extern "C" {
#include <machine/bus.h>
#endif
- #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, _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) )
+ #define _mbg_inp8( _d, _i, _p ) ( (uint8_t) bus_space_read_1( ( (_d)->rsrc_info.port[_i].ext.bst ), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p) ) )
+ #define _mbg_inp16( _d, _i, _p ) ( (uint16_t) bus_space_read_2( ( (_d)->rsrc_info.port[_i].ext.bst ), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p) ) )
+ #define _mbg_inp32( _d, _i, _p ) ( (uint32_t) bus_space_read_4( ( (_d)->rsrc_info.port[_i].ext.bst), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p) ) )
+
+ #define _mbg_outp8( _d, _i, _p, _v ) bus_space_write_1( ( (_d)->rsrc_info.port[_i].ext.bst ), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p), (_v) )
+ #define _mbg_outp16( _d, _i, _p, _v ) bus_space_write_2( ( (_d)->rsrc_info.port[_i].ext.bst ), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p), (_v) )
+ #define _mbg_outp32( _d, _i, _p, _v ) bus_space_write_4( ( (_d)->rsrc_info.port[_i].ext.bst ), \
+ ( (_d)->rsrc_info.port[_i].ext.bsh ), (_p), (_v) )
#elif defined( MBG_TGT_WIN32 )
diff --git a/mbglib/common/mbgsystm.h b/mbglib/common/mbgsystm.h
index e481943..9e9aa41 100755
--- a/mbglib/common/mbgsystm.h
+++ b/mbglib/common/mbgsystm.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsystm.h 1.3 2017/07/26 14:26:17 martin REL_M $
+ * $Id: mbgsystm.h 1.3.1.1 2017/08/02 12:14:42 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsystm.h $
+ * Revision 1.3.1.1 2017/08/02 12:14:42 martin
+ * Include another header file on NetBSD.
* Revision 1.3 2017/07/26 14:26:17 martin
* Fixed build for NetBSD.
* Revision 1.2 2017/07/04 12:26:57 martin
@@ -71,6 +73,7 @@
#if defined( MBG_TGT_NETBSD )
#include <sys/param.h> // mstohz
#include <sys/kernel.h> // hz
+ #include <sys/proc.h> // kpause
#endif
#include <sys/time.h>
diff --git a/mbglib/common/pcpsdrvr.c b/mbglib/common/pcpsdrvr.c
index fd6df88..42882cc 100755
--- a/mbglib/common/pcpsdrvr.c
+++ b/mbglib/common/pcpsdrvr.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.c 1.52 2017/07/04 16:45:36 martin REL_M $
+ * $Id: pcpsdrvr.c 1.53 2017/08/10 14:03:03 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -64,6 +64,10 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.c $
+ * Revision 1.53 2017/08/10 14:03:03 martin
+ * String 'pcps_driver_name' is now defined in pcpsdrvr.h.
+ * Unified extended resource properties handling.
+ * Cleaned up target some dependent code.
* Revision 1.52 2017/07/04 16:45:36 martin
* Support GPS180AMC and GNS181PEX.
* Renamed some functions: Use _device instead of _clock,
@@ -337,7 +341,7 @@
#include <mbgplx.h>
#endif
-#if !defined( MBG_TGT_LINUX ) && !defined( MBG_TGT_BSD )
+#if defined( MBG_TGT_DOS )
#include <assert.h>
#endif
@@ -452,31 +456,20 @@
#define AVOID_REDUNDANT_REDECLARATION 1
#endif
-#if defined( MBG_TGT_KERNEL )
- // Driver name defined by the skeleton driver for the target OS.
- extern const char pcps_driver_name[];
-#else
- // No skeleton driver, but we need a string to pass to debug messages.
- #if DEBUG
- const char pcps_driver_name[] = "pcpsdrvr";
- #endif
-#endif
// In some environments special far functions are are neither
// required nor supported, so redefine calls to those functions
// to appropriate standard function calls.
-#if defined( MBG_TGT_NETWARE ) || defined( MBG_TGT_WIN32 ) || \
- defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD ) || \
- defined( MBG_TGT_QNX )
+#if !defined( MBG_TGT_DOS ) && !defined( MBG_TGT_OS2 )
#define _fmemcpy( _d, _s, _n ) memcpy( _d, _s, _n )
#define _fstrlen( _s ) strlen( _s )
#define _fstrncmp( _s1, _s2, _n ) strncmp( (_s1), (_s2), (_n) )
-#elif defined( MBG_TGT_OS2 )
- #define _fstrncmp( _s1, _s2, _n ) _fmemcmp( (_s1), (_s2), (_n) )
#endif
#if defined( MBG_TGT_OS2 )
+ #define _fstrncmp( _s1, _s2, _n ) _fmemcmp( (_s1), (_s2), (_n) )
+
// Watcom C Compiler options for the OS/2 device driver result in
// warnings if automatic stack addresses are passed to functions.
#define static_wc static
@@ -1097,11 +1090,11 @@ int map_sys_virtual_address( PCPS_DDEV *pddev )
#elif defined( MBG_TGT_FREEBSD )
- pddev->mm_addr = rman_get_virtual( pddev->rsrc_info.mem[0].bsd.res );
+ pddev->mm_addr = rman_get_virtual( pddev->rsrc_info.mem[0].ext.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 );
+ pddev->mm_addr = bus_space_vaddr( pddev->rsrc_info.mem[0].ext.bst, pddev->rsrc_info.mem[0].ext.bsh );
#else // DOS, ...
@@ -2896,7 +2889,7 @@ int pcps_read_sernum( PCPS_DDEV *pddev )
rc = _pcps_read_gps_var( pddev, PC_GPS_IDENT, ident );
- #if !defined( MBG_TGT_LINUX ) && !defined( MBG_TGT_BSD )
+ #if defined( MBG_TGT_DOS )
assert( sizeof( ident ) < sizeof( pddev->dev.cfg.sernum ) );
#endif
diff --git a/mbglib/common/pcpsdrvr.h b/mbglib/common/pcpsdrvr.h
index 405002e..29e7006 100755
--- a/mbglib/common/pcpsdrvr.h
+++ b/mbglib/common/pcpsdrvr.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdrvr.h 1.46 2017/07/04 16:50:48 martin REL_M $
+ * $Id: pcpsdrvr.h 1.47 2017/08/10 13:59:52 martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdrvr.h $
+ * Revision 1.47 2017/08/10 13:59:52 martin
+ * Unified extended resource properties handling.
+ * String 'pcps_driver_name' is now defined here.
* Revision 1.46 2017/07/04 16:50:48 martin
* Support GPS180AMC and GNS181PEX.
* Support new module parameter force_io_access to provide
@@ -469,6 +472,17 @@
extern "C" {
#endif
+#if !defined( MBG_DRVR_NAME )
+ #define MBG_DRVR_NAME "mbgclock"
+#endif
+
+_ext const char pcps_driver_name[]
+#ifdef _DO_INIT
+ = MBG_DRVR_NAME
+#endif
+;
+
+
#define _DEFAULT_PCPS_USE_MM_IO ( MBG_TGT_SUPP_MEM_ACC && !MBG_USE_MM_IO_FOR_PCI )
#if !defined( _PCPS_USE_MM_IO )
@@ -651,16 +665,22 @@ extern "C" {
-#if defined( MBG_TGT_BSD )
+#if defined( MBG_TGT_FREEBSD )
typedef struct
{
-#if defined( MBG_TGT_FREEBSD )
- int rid; /* resource ID */
+ int rid; ///< resource ID
struct resource *res; ///< Resource information
bus_space_tag_t bst; ///< Bus space tag
bus_space_handle_t bsh; ///< Bus space handle
+
+} EXT_RSRC_INFO;
+#define EXT_RSRC_INFO EXT_RSRC_INFO
+
#elif defined( MBG_TGT_NETBSD )
+
+typedef struct
+{
int reg; ///< Base Address Register (BAR)
int type; ///< Type
int valid; ///< Valid flag
@@ -668,8 +688,9 @@ typedef struct
bus_space_handle_t bsh; ///< Bus space handle
bus_addr_t base; ///< Base address
bus_size_t size; ///< Size
-#endif
-} BSD_RSRC_INFO;
+
+} EXT_RSRC_INFO;
+#define EXT_RSRC_INFO EXT_RSRC_INFO
#endif
@@ -683,8 +704,8 @@ typedef struct
*/
typedef struct
{
- #if defined( MBG_TGT_BSD )
- BSD_RSRC_INFO bsd; ///< *BSD-specific stuff
+ #if defined( EXT_RSRC_INFO )
+ EXT_RSRC_INFO ext; ///< OS-specific stuff
#endif
PCPS_IO_ADDR_MAPPED base_mapped; ///< A mapped port base address
PCPS_IO_ADDR_RAW base_raw; ///< A raw port base address
@@ -701,8 +722,8 @@ typedef struct
*/
typedef struct
{
- #if defined( MBG_TGT_BSD )
- BSD_RSRC_INFO bsd; ///< *BSD-specific stuff
+ #if defined( EXT_RSRC_INFO )
+ EXT_RSRC_INFO ext; ///< OS-specific stuff
#endif
MBG_MEM_ADDR start;
ulong len;
@@ -718,8 +739,8 @@ typedef struct
*/
typedef struct
{
- #if defined( MBG_TGT_BSD )
- BSD_RSRC_INFO bsd; ///< *BSD-specific stuff
+ #if defined( EXT_RSRC_INFO )
+ EXT_RSRC_INFO ext; ///< OS-specific stuff
#endif
uint16_t num; ///< The IRQ number
diff --git a/src/external/bsd/meinberg/Makefile b/src/external/bsd/meinberg/Makefile
deleted file mode 100755
index 346d99a..0000000
--- a/src/external/bsd/meinberg/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# $NetBSD: Makefile,v 1.2 2010/08/28 15:42:46 kardel Exp $
-
-SUBDIR+= mbgclock
-SUBDIR+= dist
-
-.include <bsd.subdir.mk>
diff --git a/src/external/bsd/meinberg/Makefile.inc b/src/external/bsd/meinberg/Makefile.inc
deleted file mode 100755
index f169b5c..0000000
--- a/src/external/bsd/meinberg/Makefile.inc
+++ /dev/null
@@ -1,30 +0,0 @@
-# $NetBSD: Makefile.inc,v 1.5 2010/12/04 23:08:32 christos Exp $
-
-.if !defined(MEINBERG_MAKEFILE_INC)
-MEINBERG_MAKEFILE_INC=yes
-
-USE_FORT?= yes # network client/server
-
-# WARNS?= 5
-
-.include <bsd.own.mk>
-
-IDIST= ${NETBSDSRCDIR}/external/bsd/meinberg/dist
-MBG_LIB_COMMON= ${IDIST}/mbglib/common
-MBG_LIB_BSD= ${IDIST}/mbglib/bsd
-
-CPPFLAGS+=-I${MBG_LIB_COMMON} -I${MBG_LIB_BSD}
-
-.if defined(DEBUG)
-CPPFLAGS+=-DDEBUG=${DEBUG}
-.endif
-
-.if defined(MBG_DEBUG)
-CPPFLAGS+=-DMBG_DEBUG=${MBG_DEBUG}
-.endif
-
-.if exists(${.CURDIR}/../../Makefile.inc)
-.include "${.CURDIR}/../../Makefile.inc"
-.endif
-
-.endif
diff --git a/src/external/bsd/meinberg/mbgclock/Makefile.kmod b/src/external/bsd/meinberg/mbgclock/Makefile.kmod
deleted file mode 100755
index 0136033..0000000
--- a/src/external/bsd/meinberg/mbgclock/Makefile.kmod
+++ /dev/null
@@ -1,20 +0,0 @@
-# $NetBSD: Makefile,v 1.1 2009/02/05 17:32:10 haad Exp $
-
-.include "../Makefile.inc"
-
-.PATH: ${MBG_LIB_COMMON} ${MBG_LIB_BSD}
-
-MKMAN=no
-# CFLAGS+=-D_HAVE_PPS_REF_EVENT -DPPS_SYNC
-
-KMOD= mbgclock
-SRCS= mbgclock_main.c
-SRCS+= pcpsdrvr.c
-SRCS+= identdec.c
-SRCS+= rsrc_bsd.c
-
-.if !defined (MKMODULAR) || ( defined(MKMODULAR) && (${MKMODULAR}!="no") )
-.include <bsd.kmodule.mk>
-.else
-.include <bsd.kmod.mk>
-.endif
diff --git a/src/external/bsd/meinberg/mbgclock/files.mbgclock b/src/external/bsd/meinberg/mbgclock/files.mbgclock
deleted file mode 100755
index 94310bc..0000000
--- a/src/external/bsd/meinberg/mbgclock/files.mbgclock
+++ /dev/null
@@ -1,13 +0,0 @@
-# $NetBSD: files.drm,v 1.6 2011/02/18 14:26:09 jmcneill Exp $
-
-device mbgclock
-attach mbgclock at pci
-file external/bsd/meinberg/dist/mbglib/bsd/rsrc_bsd.c mbgclock
-file external/bsd/meinberg/dist/mbglib/common/identdec.c mbgclock
-file external/bsd/meinberg/dist/mbglib/common/pcpsdrvr.c mbgclock
-file external/bsd/meinberg/mbgclock/mbgclock_main.c mbgclock
-
-makeoptions mbgclock CPPFLAGS+="-I$S/external/bsd/meinberg/dist/mbglib/common"
-makeoptions mbgclock CPPFLAGS+="-I$S/external/bsd/meinberg/dist/mbglib/bsd"
-
-