Commit 7a8e4912 authored by Lucas Russo's avatar Lucas Russo

Merge branch 'devel'

Version v0.2
parents 2856e2ea 3804d6a4
......@@ -5,37 +5,20 @@ compiler:
- clang
- gcc
sudo: false
env:
- BOARD=ml605 WITH_EXAMPLES=with_examples
- BOARD=afcv3 WITH_EXAMPLES=with_examples
- BOARD=ml605 EXAMPLES=with_examples LIBS_LINK=without_libs_link
- BOARD=afcv3 EXAMPLES=with_examples LIBS_LINK=without_libs_link
addons:
apt:
packages:
- uuid-dev
before_install:
- git submodule update --init --recursive
# Build-check-install all subprojects
before_script:
- sudo apt-get install uuid-dev
# libsodium
- git clone git://github.com/jedisct1/libsodium.git
- ( cd libsodium; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# libzmq
- git clone git://github.com/zeromq/libzmq.git
- ( cd libzmq; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# CZMQ
- git clone git://github.com/zeromq/czmq.git
- ( cd czmq; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Zyre
- git clone git://github.com/zeromq/zyre.git
- ( cd zyre; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Malamute
- git clone git://github.com/zeromq/malamute.git
- ( cd malamute; ./autogen.sh; ./configure; make check; sudo make install; sudo ldconfig )
# Build and check this project
script:
- ./ci_build.sh
This diff is collapsed.
This diff is collapsed.
......@@ -9,9 +9,9 @@ Software for controlling the AFC BPM boards
Make sure you have the following libraries installed, either by download
the binaries or executing the instructions below:
* zeromq-4.2.0 (http://zeromq.org/area:download)
* czmq-3.0.1 (http://czmq.zeromq.org/page:get-the-software)
* mlm-0.1.0 (https://github.com/zeromq/malamute.git)
* zeromq-4.2.0 (https://github.com/lnls-dig/libzmq/tree/v4.2.0-pre)
* czmq-3.0.2 (https://github.com/zeromq/czmq/tree/v3.0.2)
* mlm-0.1.2 (https://github.com/lnls-dig/malamute/tree/v0.1.2)
## Optional libraries:
......
......@@ -9,60 +9,140 @@ dev_mngr
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
workdir = . # Working directory for daemon
spawn_broker = no # Ask to spawn broker (options are: yes or no)
# Device I/O configurations
dev_io
board0
board1
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board1
board2
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board2
board3
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board3
board4
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board4
board5
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board5
board6
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board7
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board8
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board9
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board10
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board11
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board12
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
......@@ -9,114 +9,140 @@ dev_mngr
filename = dev_mngr.log
verbose = 1 # Ask for a trace
daemonize = no # Ask for daemonize process (options are: yes or no)
workdir = . # Working directory for daemon
spawn_broker = no # Ask to spawn broker (options are: yes or no)
# Device I/O configurations
dev_io
board0
bpm0
dbe
afe
bind =
bpm1
dbe
afe
bind =
board1
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board2
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.210:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.211:6791
board3
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.208:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.209:6791
board4
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.206:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.207:6791
board5
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board6
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board7
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.204:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.205:6791
board8
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.202:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.203:6791
board9
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.200:6791
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind = tcp://10.2.117.201:6791
board10
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board11
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
board12
bpm0
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
bpm1
spawn_epics_ioc = yes # Ask to spawn EPICS IOC (Options are: yes or no)
dbe
afe
bind =
#!/usr/bin/env bash
./compile.sh $BOARD $WITH_EXAMPLES
# help debug
set -x
# Build and local install repositories
mkdir tmp
BUILD_PREFIX=$PWD/tmp
LIBSODIUM_VER=1.0.3
LIBZMQ_VER=v4.2.0-pre
LIBCZMQ_VER=v3.0.2
MALAMUTE_VER=v0.1.1
ZYRE_VER=v1.1.0
CONFIG_FLAGS=()
CONFIG_FLAGS+=("CFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("CPPFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("CXXFLAGS=-I${BUILD_PREFIX}/include")
CONFIG_FLAGS+=("LDFLAGS=-L${BUILD_PREFIX}/lib")
KERNEL_FLAGS=()
KERNEL_FLAGS+=("INSTALLDIR=${BUILD_PREFIX}/lib/modules/$(shell uname -r)/extra")
KERNEL_FLAGS+=("INSTALLHDRDIR=${BUILD_PREFIX}/include/pciDriver/driver")
BPM_OPTS=()
BPM_OPTS+=(${CONFIG_FLAGS[@]})
BPM_OPTS+=(${KERNEL_FLAGS[@]})
BPM_OPTS+=("PREFIX=${BUILD_PREFIX}")
CONFIG_OPTS=()
CONFIG_OPTS+=(${CONFIG_FLAGS[@]})
CONFIG_OPTS+=("PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig")
CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}")
# libsodium
git clone --branch=${LIBSODIUM_VER} git://github.com/jedisct1/libsodium.git &&
( cd libsodium; ./autogen.sh && ./configure --prefix=$BUILD_PREFIX &&
make check && make install ) || exit 1
# libzmq
git clone --branch=${LIBZMQ_VER} git://github.com/lnls-dig/libzmq.git &&
( cd libzmq; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# CZMQ
git clone --branch=${LIBCZMQ_VER} git://github.com/zeromq/czmq.git &&
( cd czmq; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# Zyre
git clone --branch=${ZYRE_VER} git://github.com/zeromq/zyre.git &&
( cd zyre; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
# Malamute
git clone --branch=${MALAMUTE_VER} git://github.com/lnls-dig/malamute.git &&
( cd malamute; ./autogen.sh && ./configure "${CONFIG_OPTS[@]}" &&
make check && make install ) || exit 1
./compile.sh $BOARD $EXAMPLES $LIBS_LINK "${BPM_OPTS[@]}"
......@@ -2,6 +2,7 @@
VALID_BOARDS_STR="Valid values are: \"ml605\" and \"afcv3\"."
VALID_WITH_EXAMPLES_STR="Valid values are: \"with_examples\" or \"without_examples\"."
VALID_WITH_LIBS_LINK_STR="Valid values are: \"with_libs_link\" or \"without_libs_link\"."
#######################################
# All of our Makefile options
......@@ -27,6 +28,20 @@ if [ -n "$WITH_EXAMPLES" ] && [ "$WITH_EXAMPLES" != "with_examples" ] && [ "$WIT
exit 1
fi
WITH_LIBS_LINK=$3
if [ -n "$WITH_LIBS_LINK" ] && [ "$WITH_LIBS_LINK" != "with_libs_link" ] && [ "$WITH_LIBS_LINK" != "without_libs_link" ]; then
echo "Wrong variable value. "$VALID_WITH_LIBS_LINK_STR
exit 1
fi
EXTRA_FLAGS=()
# Get all other arguments
for item in "${@:4}"
do
EXTRA_FLAGS+=("${item}")
done
# Select if we want to have the AFCv3 DDR memory shrink to 2^28 or the full size 2^32. Options are: (y)es ot (n)o.
# This is a TEMPORARY fix until the AFCv3 FPGA firmware is fixed. If unsure, select (y)es.
SHRINK_AFCV3_DDR_SIZE=y
......@@ -61,11 +76,23 @@ CFG=lnls_defconfig
export CFG
COMMAND_DEPS="\
make deps && \
sudo make deps_install"
make ${EXTRA_FLAGS[@]} deps && \
make ${EXTRA_FLAGS[@]} deps_install"
COMMAND_LIBS="\
make \
${EXTRA_FLAGS[@]} \
BOARD=${BOARD} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
ERRHAND_SUBSYS_ON='"${ERRHAND_SUBSYS_ON}"' \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} \
libs_compile_install"
COMMAND_HAL="\
make BOARD=${BOARD} \
make \
${EXTRA_FLAGS[@]} \
BOARD=${BOARD} \
SHRINK_AFCV3_DDR_SIZE=${SHRINK_AFCV3_DDR_SIZE} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
......@@ -77,28 +104,27 @@ COMMAND_HAL="\
AFE_RFFE_TYPE=${AFE_RFFE_TYPE} \
WITH_DEVIO_CFG=${WITH_DEVIO_CFG} \
CFG_DIR=${CFG_DIR} && \
sudo make CFG=${CFG} install"
COMMAND_LIBBPMCLIENT="\
make BOARD=${BOARD} \
ERRHAND_DBG=${ERRHAND_DBG} \
ERRHAND_MIN_LEVEL=${ERRHAND_MIN_LEVEL} \
ERRHAND_SUBSYS_ON='"${ERRHAND_SUBSYS_ON}"' \
LOCAL_MSG_DBG=${LOCAL_MSG_DBG} && \
sudo make libbpmclient_install"
make CFG=${CFG} ${EXTRA_FLAGS[@]} install"
if [ "$WITH_EXAMPLES" = "with_examples" ]; then
COMMAND_EXAMPLES="\
make examples"
make ${EXTRA_FLAGS[@]} examples"
else
COMMAND_EXAMPLES=""
fi
if [ "$WITH_LIBS_LINK" == "with_libs_link" ] || [ "$WITH_LIBS_LINK" == "" ]; then
COMMAND_LIBS_LINK="ldconfig"
else
COMMAND_LIBS_LINK=""
fi
COMMAND_ARRAY=(
"${COMMAND_DEPS}"
"${COMMAND_LIBS}"
"${COMMAND_HAL}"
"${COMMAND_LIBBPMCLIENT}"
"${COMMAND_EXAMPLES}"
"${COMMAND_LIBS_LINK}"
)
for i in "${COMMAND_ARRAY[@]}"
......
......@@ -11,8 +11,12 @@ OBJCOPY ?= $(CROSS_COMPILE)objcopy
SIZE ?= $(CROSS_COMPILE)size
MAKE ?= make
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
LOCAL_MSG_DBG ?= n
DBE_DBG ?= n
......@@ -33,6 +37,15 @@ CFLAGS_DEBUG += -g
CFLAGS_PLATFORM = -Wall -Wextra -Werror \
-Wno-missing-field-initializers \
-Wno-missing-braces
ifeq ($(notdir $(CC)),$(filter $(notdir $(CC)),gcc cc))
CFLAGS_PLATFORM += -Wno-cpp
endif
ifeq ($(notdir $(CC)),clang)
CFLAGS_PLATFORM += -Wno-error=\#warnings
endif
LDFLAGS_PLATFORM =
# Libraries
......@@ -43,12 +56,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I/usr/local/lib
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
#-Os
LDFLAGS = $(LDFLAGS_PLATFORM)
#-ffunction-sections -fdata-sections -Wl,--gc-sections
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Every .c file will must be a separate example
examples_SRC = $(wildcard *.c)
......@@ -57,7 +68,7 @@ OUT = $(basename $(examples_SRC))
all: $(OUT)
%: %.c
$(CC) $(LFLAGS) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LIBS)
$(CC) $(LDFLAGS) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LIBS)
#BAD
clean:
......
......@@ -19,6 +19,7 @@
#define DFLT_BOARD_NUMBER 0
#define MIN_NUM_SAMPLES 4
/* Arbitrary hard limits */
#define MAX_NUM_SAMPLES (1 << 28)
#define MAX_NUM_CHANS (1 << 8)
......@@ -135,7 +136,12 @@ int main (int argc, char *argv [])
else {
num_samples = strtoul (num_samples_str, NULL, 10);
if (num_samples > MAX_NUM_SAMPLES) {
if (num_samples < MIN_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too small! Defaulting to: %u\n",
MIN_NUM_SAMPLES);
num_samples = MIN_NUM_SAMPLES;
}
else if (num_samples > MAX_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too big! Defaulting to: %u\n",
MAX_NUM_SAMPLES);
num_samples = MAX_NUM_SAMPLES;
......@@ -197,11 +203,21 @@ int main (int argc, char *argv [])
goto err_bpm_client_new;
}
/* Set trigger to skip */
uint32_t acq_trig = 0;
bpm_client_err_e err = bpm_set_acq_trig (bpm_client, service, acq_trig);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_acq_set_trig failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_size = num_samples*acq_chan[chan].sample_size;
uint32_t *data = (uint32_t *) zmalloc (data_size*sizeof (uint8_t));
bool new_acq = true;
acq_trans_t acq_trans = {.req = {
.num_samples = num_samples,
.num_samples_pre = num_samples,
.num_samples_post = 0,
.num_shots = 1,
.chan = chan,
},
.block = {
......@@ -209,7 +225,7 @@ int main (int argc, char *argv [])
.data_size = data_size,
}
};
bpm_client_err_e err = bpm_get_curve (bpm_client, service, &acq_trans,
err = bpm_get_curve (bpm_client, service, &acq_trans,
50000, new_acq);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_get_curve failed\n");
......@@ -221,6 +237,7 @@ int main (int argc, char *argv [])
print_data (chan, data, acq_trans.block.bytes_read);
err_bpm_client_new:
err_bpm_set_acq_trig:
err_bpm_get_curve:
str_p = &chan_str;
free (*str_p);
......
/*
* * Simple example demonstrating the communication between
* * a client and the FPGA device
* */
#include <czmq.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <bpm_client.h>
#define DFLT_BIND_FOLDER "/tmp/bpm"
#define DFLT_BPM_NUMBER 0
#define MAX_BPM_NUMBER 1
#define DFLT_BOARD_NUMBER 0
void print_help (char *program_name)
{
printf( "Usage: %s [options]\n"
"\t-h This help message\n"
"\t-v Verbose output\n"
"\t-b <broker_endpoint> Broker endpoint\n"
"\t-board <AMC board = [0|1|2|3|4|5]>\n"
"\t-bpm <BPM number = [0|1]>\n"
, program_name);
}
int main (int argc, char *argv [])
{
int verbose = 0;
char *broker_endp = NULL;
char *board_number_str = NULL;
char *bpm_number_str = NULL;
char **str_p = NULL;
if (argc < 2) {
print_help (argv[0]);
exit (1);
}
/* FIXME: This is rather buggy! */
/* Simple handling of command-line options. This should be done
* * with getopt, for instance*/
int i;
for (i = 1; i < argc; i++)
{
if (streq(argv[i], "-v")) {
verbose = 1;
}
else if (streq(argv[i], "-h"))
{
print_help (argv [0]);
exit (1);
}
else if (streq (argv[i], "-b")) {
str_p = &broker_endp;
}
else if (streq (argv[i], "-board")) { /* board_number: board number */
str_p = &board_number_str;
}
else if (streq(argv[i], "-bpm"))
{
str_p = &bpm_number_str;
}
/* Fallout for options with parameters */
else {
*str_p = strdup (argv[i]);
}
}
/* Set default broker address */
if (broker_endp == NULL) {
broker_endp = strdup ("ipc://"DFLT_BIND_FOLDER);
}
/* Set default board number */
uint32_t board_number;
if (board_number_str == NULL) {
fprintf (stderr, "[client:acq]: Setting default value to BOARD number: %u\n",
DFLT_BOARD_NUMBER);
board_number = DFLT_BOARD_NUMBER;
}
else {
board_number = strtoul (board_number_str, NULL, 10);
}
/* Set default bpm number */
uint32_t bpm_number;
if (bpm_number_str == NULL) {
fprintf (stderr, "[client:leds]: Setting default value to BPM number: %u\n",
DFLT_BPM_NUMBER);
bpm_number = DFLT_BPM_NUMBER;
}
else {
bpm_number = strtoul (bpm_number_str, NULL, 10);
if (bpm_number > MAX_BPM_NUMBER) {
fprintf (stderr, "[client:leds]: BPM number too big! Defaulting to: %u\n",
MAX_BPM_NUMBER);
bpm_number = MAX_BPM_NUMBER;
}
}
char service[50];
snprintf (service, sizeof (service), "BPM%u:DEVIO:ACQ%u", board_number, bpm_number);
bpm_client_t *bpm_client = bpm_client_new (broker_endp, verbose, NULL);
if (bpm_client == NULL) {
fprintf (stderr, "[client:acq]: bpm_client could be created\n");
goto err_bpm_client_new;
}
bpm_client_err_e err = BPM_CLIENT_SUCCESS;
/* Generate trigger */
uint32_t sw_trig = 1;
err = bpm_set_acq_sw_trig (bpm_client, service, sw_trig);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_acq_set_trig failed\n");
goto err_bpm_set_acq_sw_trig;
}
err_bpm_set_acq_sw_trig:
err_bpm_client_new:
str_p = &board_number_str;
free (*str_p);
board_number_str = NULL;
str_p = &bpm_number_str;
free (*str_p);
bpm_number_str = NULL;
str_p = &broker_endp;
free (*str_p);
broker_endp = NULL;
bpm_client_destroy (&bpm_client);
return 0;
}
/*
* * Simple example demonstrating the communication between
* * a client and the FPGA device
* */
#include <czmq.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <bpm_client.h>
#define DFLT_BIND_FOLDER "/tmp/bpm"
#define DFLT_NUM_SAMPLES 4096
#define DFLT_CHAN_NUM 0
#define DFLT_BPM_NUMBER 0
#define MAX_BPM_NUMBER 1
#define DFLT_BOARD_NUMBER 0
#define MIN_NUM_SAMPLES 4
/* Arbitrary hard limits */
#define MAX_NUM_SAMPLES (1 << 28)
#define MAX_NUM_CHANS (1 << 8)
void print_data (uint32_t chan, uint32_t *data, uint32_t size)
{
/* FIXME: Make it more generic */
if (chan == 0 || chan == 1 /* Only ADC and ADC SWAP */ ) {
int16_t *raw_data16 = (int16_t *) data;
for (uint32_t i = 0; i < (size/sizeof(uint16_t)) / 4; i++) {
if (zctx_interrupted) {
break;
}
printf ("%6u\t %8d\t %8d\t %8d\t %8d\n", i,
raw_data16[(i*4)],
raw_data16[(i*4)+1],
raw_data16[(i*4)+2],
raw_data16[(i*4)+3]);
}
}
else {
int32_t *raw_data32 = (int32_t *) data;
for (uint32_t i = 0; i < (size/sizeof(uint32_t)) / 4; i++) {
if (zctx_interrupted) {
break;
}
printf ("%6u\t %8d\t %8d\t %8d\t %8d\n", i,
raw_data32[(i*4)],
raw_data32[(i*4)+1],
raw_data32[(i*4)+2],
raw_data32[(i*4)+3]);
}
}
}
void print_help (char *program_name)
{
printf( "Usage: %s [options]\n"
"\t-h This help message\n"
"\t-v Verbose output\n"
"\t-b <broker_endpoint> Broker endpoint\n"
"\t-s <num_samples_str> Number of samples\n"
"\t-board <AMC board = [0|1|2|3|4|5]>\n"
"\t-bpm <BPM number = [0|1]>\n"
"\t-ch <chan_str> Acquisition channel\n"
, program_name);
}
int main (int argc, char *argv [])
{
int verbose = 0;
char *broker_endp = NULL;
char *num_samples_str = NULL;
char *board_number_str = NULL;
char *bpm_number_str = NULL;
char *chan_str = NULL;
char **str_p = NULL;
if (argc < 3) {
print_help (argv[0]);
exit (1);
}
/* FIXME: This is rather buggy! */
/* Simple handling of command-line options. This should be done
* * with getopt, for instance*/
int i;
for (i = 1; i < argc; i++)
{
if (streq(argv[i], "-v")) {
verbose = 1;
}
else if (streq(argv[i], "-h"))
{
print_help (argv [0]);
exit (1);
}
else if (streq (argv[i], "-b")) {
str_p = &broker_endp;
}
else if (streq (argv[i], "-s")) { /* s: samples */
str_p = &num_samples_str;
}
else if (streq (argv[i], "-ch")) { /* ch: channel */
str_p = &chan_str;
}
else if (streq (argv[i], "-board")) { /* board_number: board number */
str_p = &board_number_str;
}
else if (streq(argv[i], "-bpm"))
{
str_p = &bpm_number_str;
}
/* Fallout for options with parameters */
else {
*str_p = strdup (argv[i]);
}
}
/* Set default broker address */
if (broker_endp == NULL) {
broker_endp = strdup ("ipc://"DFLT_BIND_FOLDER);
}
/* Set default number samples */
uint32_t num_samples;
if (num_samples_str == NULL) {
fprintf (stderr, "[client:acq]: Setting default value to number of samples: %u\n",
DFLT_NUM_SAMPLES);
num_samples = DFLT_NUM_SAMPLES;
}
else {
num_samples = strtoul (num_samples_str, NULL, 10);
if (num_samples < MIN_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too small! Defaulting to: %u\n",
MIN_NUM_SAMPLES);
num_samples = MIN_NUM_SAMPLES;
}
else if (num_samples > MAX_NUM_SAMPLES) {
fprintf (stderr, "[client:acq]: Number of samples too big! Defaulting to: %u\n",
MAX_NUM_SAMPLES);
num_samples = MAX_NUM_SAMPLES;
}
}
//fprintf (stdout, "[client:acq]: num_samples = %u\n", num_samples);
/* Set default channel */
uint32_t chan;
if (chan_str == NULL) {
fprintf (stderr, "[client:acq]: Setting default value to 'chan'\n");
chan = DFLT_CHAN_NUM;
}
else {
chan = strtoul (chan_str, NULL, 10);
if (chan > END_CHAN_ID-1) {
fprintf (stderr, "[client:acq]: Channel number too big! Defaulting to: %u\n",
MAX_NUM_CHANS);
chan = END_CHAN_ID-1;
}
}
//fprintf (stdout, "[client:acq]: chan = %u\n", chan);
/* Set default board number */
uint32_t board_number;
if (board_number_str == NULL) {
fprintf (stderr, "[client:acq]: Setting default value to BOARD number: %u\n",
DFLT_BOARD_NUMBER);
board_number = DFLT_BOARD_NUMBER;
}
else {
board_number = strtoul (board_number_str, NULL, 10);
}
/* Set default bpm number */
uint32_t bpm_number;
if (bpm_number_str == NULL) {
fprintf (stderr, "[client:leds]: Setting default value to BPM number: %u\n",
DFLT_BPM_NUMBER);
bpm_number = DFLT_BPM_NUMBER;
}
else {
bpm_number = strtoul (bpm_number_str, NULL, 10);
if (bpm_number > MAX_BPM_NUMBER) {
fprintf (stderr, "[client:leds]: BPM number too big! Defaulting to: %u\n",
MAX_BPM_NUMBER);
bpm_number = MAX_BPM_NUMBER;
}
}
char service[50];
snprintf (service, sizeof (service), "BPM%u:DEVIO:ACQ%u", board_number, bpm_number);
bpm_client_t *bpm_client = bpm_client_new (broker_endp, verbose, NULL);
if (bpm_client == NULL) {
fprintf (stderr, "[client:acq]: bpm_client could be created\n");
goto err_bpm_client_new;
}
bpm_client_err_e err = BPM_CLIENT_SUCCESS;
/* Change trigger type here if needed */
uint32_t acq_trig = 2;
err = bpm_set_acq_trig (bpm_client, service, acq_trig);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_trig failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_trig_thres = 200;
err = bpm_set_acq_data_trig_thres (bpm_client, service, data_trig_thres);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_data_trig_thres failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_trig_pol = 0;
err = bpm_set_acq_data_trig_pol (bpm_client, service, data_trig_pol);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_data_trig_pol failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_trig_sel = 0;
err = bpm_set_acq_data_trig_sel (bpm_client, service, data_trig_sel);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_data_trig_sel failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_trig_filt = 1;
err = bpm_set_acq_data_trig_filt (bpm_client, service, data_trig_filt);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_data_trig_filt failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t hw_trig_dly = 0;
err = bpm_set_acq_hw_trig_dly (bpm_client, service, hw_trig_dly);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_hw_trig_dly failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t data_trig_chan = 6;
err = bpm_set_acq_data_trig_chan (bpm_client, service, data_trig_chan);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_acq_data_trig_chan failed\n");
goto err_bpm_set_acq_trig;
}
uint32_t num_samples_pre = num_samples;
uint32_t num_samples_post = num_samples;
uint32_t num_shots = 1;
uint32_t data_size = (num_samples_pre+num_samples_post+100)*num_shots*
acq_chan[chan].sample_size;
uint32_t *data = (uint32_t *) zmalloc (data_size*sizeof (uint8_t));
bool new_acq = true;
acq_trans_t acq_trans = {.req = {
.num_samples_pre = num_samples_pre,
.num_samples_post = num_samples_post,
.num_shots = num_shots,
.chan = chan,
},
.block = {
.data = data,
.data_size = data_size,
}
};
err = bpm_get_curve (bpm_client, service, &acq_trans,
500000, new_acq);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_get_curve failed\n");
goto err_bpm_get_curve;
}
//fprintf (stdout, "[client:acq]: bpm_get_curve was successfully executed\n");
fprintf (stdout, "clear\n");
print_data (chan, data, acq_trans.block.bytes_read);
err_bpm_client_new:
err_bpm_set_acq_trig:
err_bpm_get_curve:
str_p = &chan_str;
free (*str_p);
chan_str = NULL;
str_p = &board_number_str;
free (*str_p);
board_number_str = NULL;
str_p = &bpm_number_str;
free (*str_p);
bpm_number_str = NULL;
str_p = &num_samples_str;
free (*str_p);
num_samples_str = NULL;
str_p = &broker_endp;
free (*str_p);
broker_endp = NULL;
bpm_client_destroy (&bpm_client);
return 0;
}
......@@ -109,7 +109,7 @@ int main (int argc, char *argv [])
}
for (i = 0; i < 32768; ++i) {
uint32_t leds = (1 << 1);
uint32_t leds = 1;
unsigned int j;
for (j = 0; j < 3; ++j) {
if (zctx_interrupted) {
......
......@@ -108,8 +108,16 @@ int main (int argc, char *argv [])
goto err_bpm_client_new;
}
uint32_t monit_updt = 1;
bpm_client_err_e err = bpm_set_monit_updt (bpm_client, service,
monit_updt);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_monit_updt failed\n");
goto err_set_monit_updt;
}
uint32_t monit_amp;
bpm_client_err_e err = bpm_get_monit_amp_ch0 (bpm_client, service,
err = bpm_get_monit_amp_ch0 (bpm_client, service,
&monit_amp);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_get_monit_amp_ch0 failed\n");
......@@ -144,6 +152,7 @@ int main (int argc, char *argv [])
err_bpm_client_new:
err_get_monit_amp:
err_set_monit_updt:
bpm_client_destroy (&bpm_client);
str_p = &board_number_str;
free (*str_p);
......
......@@ -108,8 +108,16 @@ int main (int argc, char *argv [])
goto err_bpm_client_new;
}
uint32_t monit_updt = 1;
bpm_client_err_e err = bpm_set_monit_updt (bpm_client, service,
monit_updt);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_set_monit_updt failed\n");
goto err_set_monit_updt;
}
uint32_t monit_pos;
bpm_client_err_e err = bpm_get_monit_pos_x (bpm_client, service,
err = bpm_get_monit_pos_x (bpm_client, service,
&monit_pos);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: bpm_get_monit_pos_x failed\n");
......@@ -144,6 +152,7 @@ int main (int argc, char *argv [])
err_bpm_client_new:
err_get_monit_pos:
err_set_monit_updt:
bpm_client_destroy (&bpm_client);
str_p = &board_number_str;
free (*str_p);
......
......@@ -96,6 +96,7 @@ typedef struct _func_call_t {
int main (int argc, char *argv [])
{
int verbose = 0;
bpm_client_err_e err = BPM_CLIENT_SUCCESS;
char *broker_endp = NULL;
char *board_number_str = NULL;
char *bpm_number_str = NULL;
......@@ -226,7 +227,7 @@ int main (int argc, char *argv [])
if (func_call [i].call == 1) {
fprintf (stdout, "[client:rffe_ctl]: Calling function #%d\n", i);
fprintf (stdout, "[client:rffe_ctl]: Argument: %f\n", strtod (*func_call [i].arg, NULL));
bpm_client_err_e err = bpm_rffe_funcs [i]
err = bpm_rffe_funcs [i]
(bpm_client, service, strtod (*func_call [i].arg, NULL));
if (err != BPM_CLIENT_SUCCESS) {
......@@ -236,6 +237,43 @@ int main (int argc, char *argv [])
}
}
double temp;
err = bpm_get_rffe_temp1 (bpm_client, service, &temp);
if (err != BPM_CLIENT_SUCCESS) {
fprintf (stderr, "[client:rffe_ctl]: Error executing remote "
"function: %s\n", bpm_client_err_str (err));
}
fprintf (stdout, "[client:rffe_ctl]: Temp1: %f\n", temp);
err = bpm_get_rffe_temp2 (bpm_client, service, &temp);
if (err != BPM_CLIENT_SUCCESS) {
fprintf (stderr, "[client:rffe_ctl]: Error executing remote "
"function: %s\n", bpm_client_err_str (err));
}
fprintf (stdout, "[client:rffe_ctl]: Temp2: %f\n", temp);
err = bpm_get_rffe_temp3 (bpm_client, service, &temp);
if (err != BPM_CLIENT_SUCCESS) {
fprintf (stderr, "[client:rffe_ctl]: Error executing remote "
"function: %s\n", bpm_client_err_str (err));
}
fprintf (stdout, "[client:rffe_ctl]: Temp3: %f\n", temp);
err = bpm_get_rffe_temp4 (bpm_client, service, &temp);
if (err != BPM_CLIENT_SUCCESS) {
fprintf (stderr, "[client:rffe_ctl]: Error executing remote "
"function: %s\n", bpm_client_err_str (err));
}
fprintf (stdout, "[client:rffe_ctl]: Temp4: %f\n", temp);
double att;
err = bpm_get_rffe_att1 (bpm_client, service, &att);
if (err != BPM_CLIENT_SUCCESS) {
fprintf (stderr, "[client:rffe_ctl]: Error executing remote "
"function: %s\n", bpm_client_err_str (err));
}
fprintf (stdout, "[client:rffe_ctl]: Att1: %f\n", att);
err_bpm_client_new:
bpm_client_destroy (&bpm_client);
......
......@@ -11,7 +11,6 @@
#define MAX_BPM_NUMBER 1
#define DFLT_BOARD_NUMBER 0
#define MAX_BOARD_NUMBER 5
#define DFLT_SI571_FREQ 100000000.000 /* 100 MHz */
#define MAX_SI571_FREQ 1000000000.000 /* 1GHz */
......@@ -85,18 +84,12 @@ int main (int argc, char *argv [])
/* Set default board number */
uint32_t board_number;
if (board_number_str == NULL) {
fprintf (stderr, "[client:si571_ctl]: Setting default value to BOARD number: %u\n",
fprintf (stderr, "[client:acq]: Setting default value to BOARD number: %u\n",
DFLT_BOARD_NUMBER);
board_number = DFLT_BOARD_NUMBER;
}
else {
board_number = strtoul (board_number_str, NULL, 10);
if (board_number > MAX_BOARD_NUMBER) {
fprintf (stderr, "[client:si571_ctl]: BOARD number too big! Defaulting to: %u\n",
MAX_BOARD_NUMBER);
board_number = MAX_BOARD_NUMBER;
}
}
/* Set default bpm number */
......
Subproject commit bd1eb1ec1104f4b4cbe796ce07a003440105b265
Subproject commit 4657a65846484096a3981b1218c13b8e7d2ddbff
......@@ -19,11 +19,11 @@ OBJDUMP = $(CROSS_COMPILE)objdump
# calculate endianness at compile time
ENDIAN := $(shell ./check-endian $(CC))
CFLAGS = -Wall -ggdb -O2
CFLAGS += -I../../include # for <sdb.h>
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -Wno-pointer-sign
CFLAGS += $(ENDIAN) $(LINUXINCLUDE)
override CFLAGS += -Wall -ggdb -O2
override CFLAGS += -I../../include # for <sdb.h>
override CFLAGS += -ffunction-sections -fdata-sections
override CFLAGS += -Wno-pointer-sign
override CFLAGS += $(ENDIAN) $(LINUXINCLUDE)
LIB = libsdbfs.a
......
# This is an example config file, that can be used to build a filesystem
# from this very directory. Please note that gensdbfs doesn't look for
# config files in subdirectories but only in the tol-level one.
.
vendor = 0x123456789abcdef
device = 257
position = 0x1000
Makefile
position = 0
gensdbfs.c
write = 1
maxsize = 0x10000
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
ERRHAND_DBG ?= y
ERRHAND_MIN_LEVEL ?= DBG_LVL_ERR
ERRHAND_SUBSYS_ON ?= "(DBG_DEV_MNGR | DBG_DEV_IO | DBG_SM_IO | DBG_LIB_CLIENT | DBG_SM_PR | DBG_SM_CH | DBG_LL_IO | DBG_HAL_UTILS)"
CFLAGS = -Wall -ggdb
CFLAGS += -I.. -I../../../include
CFLAGS_LNLS = -DERRHAND_DBG=$(ERRHAND_DBG) -DERRHAND_MIN_LEVEL=$(ERRHAND_MIN_LEVEL) \
-DERRHAND_SUBSYS_ON=$(ERRHAND_SUBSYS_ON)
LDFLAGS = -L.. -lsdbfs
LDFLAGS_LNLS = -lllio -lerrhand -lconvc -lczmq -lpcidriver
PROG = gensdbfs sdb-read sdb-read-lnls sdb-extract
all: $(PROG)
%: %.c
$(CC) $(CFLAGS) -o $@ $*.c $(LDFLAGS)
sdb-read-lnls: sdb-read-lnls.c
$(CC) $(CFLAGS) $(CFLAGS_LNLS) -o $@ $< $(LDFLAGS) $(LDFLAGS_LNLS)
$(PROG): ../libsdbfs.a
clean:
rm -f $(PROG) *.o *~ core
# add the other unused targets, so the rule in ../Makefile works
modules install modules_install:
This diff is collapsed.
#ifndef __GENSDBFS_H__
#define __GENSDBFS_H__
#include <stdint.h>
#define CFG_NAME "--SDB-CONFIG--"
#define DEFAULT_VENDOR htonll(0x46696c6544617461LL) /* "FileData" */
/* We need to keep track of each file as both unix and sdb entity*/
struct sdbf {
struct stat stbuf;
struct dirent de;
union {
struct sdb_device s_d;
struct sdb_interconnect s_i;
struct sdb_bridge s_b;
};
char *fullname;
char *basename;
unsigned long ustart, rstart; /* user (mandated), relative */
unsigned long base, size; /* base is absolute, for output */
int nfiles, totsize; /* for dirs */
struct sdbf *dot; /* for files, pointer to owning dir */
struct sdbf *parent; /* for dirs, current dir in ../ */
struct sdbf *subdir; /* for files that are dirs */
int level; /* subdir level */
int userpos; /* only allowed at level 0 */
};
static inline uint64_t htonll(uint64_t ll)
{
uint64_t res;
if (htonl(1) == 1)
return ll;
res = htonl(ll >> 32);
res |= (uint64_t)(htonl((uint32_t)ll)) << 32;
return res;
}
#define ntohll htonll
#endif /* __GENSDBFS_H__ */
/*
* Copyright (C) 2013 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*
* This work is part of the White Rabbit project, a research effort led
* by CERN, the European Institute for Nuclear Research.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "libsdbfs.h"
#define CFG_NAME "--SDB-CONFIG--"
/*
* This is similar to ./sdb-read, so some code duplication is there,
* but I'd better keep the tools separate and simple
*/
char *prgname;
static int opt_force, opt_entry;
static int create_file(struct sdbfs *fs, struct sdb_device *d, FILE *cfgf)
{
FILE *f;
struct sdb_product *p;
struct sdb_component *c;
char name[32];
int mode = 0444;
c = &d->sdb_component;
p = &c->product;
/* Remove trailing spaces from the name */
strncpy(name, (char *)p->name, sizeof(p->name));
name[sizeof(p->name)] = '\0';
while (name[strlen(name) - 1] == ' ')
name[strlen(name) - 1] = '\0';
/* Print cfgfile information */
fprintf(cfgf, "%s\n" "\tvendor = 0x%016llx\n" "\tdevice = 0x%08x\n",
name, ntohll(p->vendor_id), ntohl(p->device_id));
fprintf(cfgf, "\tposition = 0x%llx\n", ntohll(c->addr_first));
if (ntohl(d->bus_specific) & SDB_DATA_WRITE) {
fprintf(cfgf, "\twrite = 1\n");
mode |= 0222;
}
if (ntohl(d->bus_specific) & SDB_DATA_EXEC)
mode |= 0111;
fprintf(cfgf, "\n");
/* Create the actual file unless it is the root directory */
if (!strcmp(name, "."))
return 0;
f = fopen(name, "w");
if (!f) {
fprintf(stderr, "%s: open(%s): %s\n", prgname, name,
strerror(errno));
return -1;
}
fwrite(fs->data + ntohll(c->addr_first), 1,
ntohll(c->addr_last) + 1 - ntohll(c->addr_first), f);
fclose(f);
chmod(name, mode);
return 0;
}
/* As promised, here's the user-interface glue (and initialization, I admit) */
int main(int argc, char **argv)
{
int n, new, c, err, cfgfd;
FILE *f, *cfgf;
struct sdbfs _fs;
struct sdbfs *fs = &_fs; /* I like to type "fs->" */
struct sdb_device *d;
struct stat stbuf;
void *mapaddr;
char *fsname, *dirname;
struct dirent **namelist;
int i, pagesize = getpagesize();
prgname = argv[0];
while ( (c = getopt(argc, argv, "e:f")) != -1) {
switch (c) {
case 'f':
opt_force = 1;
break;
case 'e':
if (sscanf(optarg, "%i", &opt_entry) != 1) {
fprintf(stderr, "%s: not a number \"%s\"\n",
prgname, optarg);
exit(1);
}
}
}
if (optind != argc - 2) {
fprintf(stderr, "%s: Use: \"%s [-f] [-e <entry>] "
"<output-dir> <sdb-file>\n", prgname, prgname);
exit(1);
}
fsname = argv[optind + 1];
dirname = argv[optind];
if ( !(f = fopen(fsname, "r")) || fstat(fileno(f), &stbuf) < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, fsname,
strerror(errno));
exit(1);
}
stbuf.st_size += pagesize - 1;
stbuf.st_size &= ~(pagesize - 1);
mapaddr = mmap(0, stbuf.st_size, PROT_READ, MAP_PRIVATE, fileno(f), 0);
if (mapaddr == MAP_FAILED) {
/* I used to complain, but sysfs doesn't allow mmapping... */
mapaddr = malloc(stbuf.st_size);
if (!mapaddr) {
fprintf(stderr, "%s: out of memory reading \"%s\"\n",
argv[0], fsname);
exit(1);
}
i = fread(mapaddr, 1, stbuf.st_size, f);
if (i < stbuf.st_size) {
fprintf(stderr, "%s: %s: short read\n",
argv[0], fsname);
exit(1);
}
}
/* Check output dir is empty, open config file */
/* Open the filesystem */
memset(fs, 0, sizeof(*fs));
fs->name = fsname; /* not mandatory */
fs->blocksize = 256; /* only used for writing, actually */
fs->entrypoint = opt_entry;
fs->data = mapaddr;
err = sdbfs_dev_create(fs);
if (err) {
fprintf(stderr, "%s: sdbfs_dev_create(): %s\n", prgname,
strerror(-err));
fprintf(stderr, "\t(wrong entry point 0x%08lx?)\n",
fs->entrypoint);
exit(1);
}
/* We are sure the fs is good: create output dir and cfgfile */
if (mkdir(dirname, 0777) < 0 && errno != EEXIST) {
fprintf(stderr, "%s: %s: %s\n", prgname, dirname,
strerror(errno));
exit(1);
}
if (chdir(dirname) < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, dirname,
strerror(errno));
exit(1);
}
n = scandir(".", &namelist, 0, 0);
if (!opt_force && n != 2) {
fprintf(stderr, "%s: %s: not empty\n", prgname, dirname);
exit(1);
}
cfgfd = open(CFG_NAME, O_RDWR | O_CREAT | O_EXCL, 0666);
if (cfgfd < 0) {
fprintf(stderr, "%s: Warning: %s/%s: %s\n", prgname, dirname,
CFG_NAME, strerror(errno));
cfgf = fopen("/dev/null", "w");
} else {
cfgf = fdopen(cfgfd, "w");
}
/* Save the header */
fprintf(cfgf, "# Configuration file generated by %s, reading %s\n\n",
prgname, fsname);
/* The root directory is a file like the other ones */
while ( (d = sdbfs_scan(fs, new)) != NULL) {
create_file(fs, d, cfgf);
new = 0;
}
sdbfs_dev_destroy(fs);
return 0;
}
/*
* Copyright (C) 2012,2014 CERN (www.cern.ch)
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 2 or any later version.
*
* This work is part of the White Rabbit project, a research effort led
* by CERN, the European Institute for Nuclear Research.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <ll_io.h>
#include <pcie_regs.h>
#include "libsdbfs.h"
char *prgname;
int opt_long, opt_verbose, opt_entry;
static void help(void)
{
fprintf(stderr, "%s: Use: \"%s [options] <image-file> [<file>]\n",
prgname, prgname);
fprintf(stderr, " -l long listing (like ls -l)\n");
fprintf(stderr, " -v verbose\n");
fprintf(stderr, " -e <num> entry point offset\n");
exit(1);
}
struct sdbr_drvdata {
llio_t *llio;
};
/*
* This read method is needed for non-mmappable files, or stuff that
* you can't know the size of (e.g., char devices). You can force use of
* read, to exercise the library procedures, using "-r"
*/
static int do_read(struct sdbfs *fs, int offset, void *buf, int count)
{
struct sdbr_drvdata *drvdata = fs->drvdata;
if (opt_verbose)
fprintf(stderr, "%s @ 0x%08x - size 0x%x (%i)\n", __func__,
offset, count, count);
return llio_read_block (drvdata->llio, BAR4_ADDR | (offset), count,
(uint32_t *) buf);
}
/* Boring ascii representation of a device */
static int list_device(struct sdb_device *d, int depth, int base)
{
struct sdb_product *p;
struct sdb_component *c;
struct sdb_synthesis *s;
unsigned char *data;
static int warned;
char *warn;
int i, ret;
c = &d->sdb_component;
p = &c->product;
s = (void *)d;
if (!warned && opt_long) {
fprintf(stderr, "%s: listing format is to be defined\n",
prgname);
warned = 1;
}
/* Different sdb items are listed in different ways */
switch(p->record_type) {
/* The following items are components, and are listed as such */
case sdb_type_interconnect:
case sdb_type_device:
case sdb_type_bridge:
if (!opt_long) {
printf("%.19s\n", p->name);
return 0;
}
/* hack: show directory level looking at the internals */
printf("%016llx:%08x @ %08llx-%08llx ",
(long long)ntohll(p->vendor_id), ntohl(p->device_id),
(long long)base + ntohll(c->addr_first),
(long long)base + ntohll(c->addr_last));
for (i = 0; i < depth; i++)
printf(" ");
printf("%.19s\n", p->name);
return 0;
/* A product, but not a component (no address range) */
case sdb_type_integration:
if (!opt_long) {
printf("%.19s\n", p->name);
return 0;
}
printf("%016llx:%08x ",
(long long)ntohll(p->vendor_id), ntohl(p->device_id));
/* like above, show directory level */
for (i = 0; i < depth; i++)
printf(" ");
printf("%.19s\n", p->name);
return 0;
/* Just a string */
case sdb_type_repo_url:
if (opt_long)
printf("repo-url: %.63s\n",
((struct sdb_repo_url *)d)->repo_url);
return 0;
/* Some metadata */
case sdb_type_synthesis:
if (!opt_long)
return 0;
printf("synthesis-name: %.16s\n", s->syn_name);
printf(" commit-id: ");
for (i = 0; i < sizeof(s->commit_id); i++)
printf("%02x", s->commit_id[i]);
printf("\n");
/* Some of the following fields are sometimes empty */
if (s->tool_name[0] && s->tool_name[0] != ' ')
printf(" tool-name: %.8s\n", s->tool_name);
if (s->tool_version)
printf(" tool-version: 0x%08x\n",
ntohl(s->tool_version));
if (s->date)
printf(" build-date: %08x\n", ntohl(s->date));
if (s->user_name[0] && s->tool_name[0] != ' ')
printf(" build-user: %.15s\n", s->user_name);
return 0;
case sdb_type_empty:
return 0;
default:
break;
}
/* Unknown record type */
if (p->record_type & 0x80) {
warn = "Warning";
ret = 0;
} else {
warn = "Error";
ret = -1;
}
fprintf(stderr, "%s: unknown record type 0x%02x\n", warn,
p->record_type);
if (!opt_long) {
printf("Unknown-record\n");
return ret;
}
/* long listing of unknown record */
printf("Unknown-record:\n");
data = (void *)d;
for (i = 0; i < sizeof(struct sdb_empty); i++)
printf("%s%02x%c",
(i & 0xf) == 0 ? " " : "",
data[i],
(i & 0xf) == 0xf ? '\n' : ' ');
return ret;
}
/* The following three function perform the real work, main() is just glue */
static int do_list(struct sdbfs *fs)
{
struct sdb_device *d;
int new = 1;
int err = 0;
while ( (d = sdbfs_scan(fs, new)) != NULL) {
err += list_device(d, fs->depth, fs->base[fs->depth]);
new = 0;
}
return err;
}
static int do_cat_name(struct sdbfs *fs, char *name)
{
char buf[4096];
int i;
i = sdbfs_open_name(fs, name);
if (i < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, name, strerror(-i));
exit(1);
}
while ( (i = sdbfs_fread(fs, -1, buf, sizeof(buf))) > 0)
fwrite(buf, 1, i, stdout);
sdbfs_close(fs);
return 0;
}
static int do_cat_id(struct sdbfs *fs, uint64_t vendor, uint32_t dev)
{
char buf[4096];
int i;
i = sdbfs_open_id(fs, htonll(vendor), htonl(dev));
if (i < 0) {
fprintf(stderr, "%s: %016llx-%08x: %s\n", prgname,
(long long)vendor, dev, strerror(-i));
exit(1);
}
while ( (i = sdbfs_fread(fs, -1, buf, sizeof(buf))) > 0)
fwrite(buf, 1, i, stdout);
sdbfs_close(fs);
return 0;
}
/* As promised, here's the user-interface glue (and initialization, I admit) */
int main(int argc, char **argv)
{
int c, err;
struct sdbfs _fs;
struct sdbfs *fs = &_fs; /* I like to type "fs->" */
struct sdbr_drvdata *drvdata;
char *fsname;
char *filearg = NULL;
unsigned long int32;
unsigned long long int64;
prgname = argv[0];
while ( (c = getopt(argc, argv, "lvre:")) != -1) {
switch (c) {
case 'l':
opt_long = 1;
break;
case 'v':
opt_verbose = 1;
break;
case 'e':
if (sscanf(optarg, "%i", &opt_entry) != 1) {
fprintf(stderr, "%s: not a number \"%s\"\n",
prgname, optarg);
exit(1);
}
break;
}
}
if (optind < argc - 2 || optind > argc - 1)
help();
fsname = argv[optind];
if (optind + 1 < argc)
filearg = argv[optind + 1];
/* So, describe the filesystem instance and give it to the library */
memset(fs, 0, sizeof(*fs));
drvdata = calloc(1, sizeof(*drvdata));
if (!drvdata) {perror("malloc"); exit(1);}
drvdata->llio = llio_new ("llio_pcie", fsname, PCIE_DEV, opt_verbose);
if (!drvdata->llio) {
fprintf(stderr, "%s: llio_new() error\n", prgname);
exit(1);
}
err = llio_open (drvdata->llio, NULL);
if (err) {
fprintf(stderr, "%s: llio_open() error %i\n", prgname, err);
exit(1);
}
fs->drvdata = drvdata;
fs->name = fsname; /* not mandatory */
fs->blocksize = 256; /* only used for writing, actually */
fs->entrypoint = opt_entry;
fs->read = do_read;
if (opt_verbose)
fs->flags |= SDBFS_F_VERBOSE;
err = sdbfs_dev_create(fs);
if (err) {
fprintf(stderr, "%s: sdbfs_dev_create(): %s\n", prgname,
strerror(-err));
fprintf(stderr, "\t(wrong entry point 0x%08lx?)\n",
fs->entrypoint);
exit(1);
}
/* Now use the thing: either scan, or look for name, or look for id */
if (!filearg)
err = do_list(fs);
else if (sscanf(filearg, "%llx:%lx", &int64, &int32) != 2)
err = do_cat_name(fs, filearg);
else
err = do_cat_id(fs, int64, int32);
llio_destroy(&((struct sdbr_drvdata *)fs->drvdata)->llio);
free(fs->drvdata);
sdbfs_dev_destroy(fs);
return err;
}
/*
* Copyright (C) 2012,2014 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*
* This work is part of the White Rabbit project, a research effort led
* by CERN, the European Institute for Nuclear Research.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "libsdbfs.h"
char *prgname;
int opt_long, opt_verbose, opt_read, opt_entry, opt_mem;
unsigned long opt_memaddr, opt_memsize;
static void help(void)
{
fprintf(stderr, "%s: Use: \"%s [options] <image-file> [<file>]\n",
prgname, prgname);
fprintf(stderr, " -l long listing (like ls -l)\n");
fprintf(stderr, " -v verbose\n");
fprintf(stderr, " -r force use of read(2), not mmap(2)\n");
fprintf(stderr, " -e <num> entry point offset\n");
fprintf(stderr, " -m <size>@<addr> memory subset to use\n");
fprintf(stderr, " -m <addr>+<size> memory subset to use\n");
exit(1);
}
struct sdbr_drvdata {
void *mapaddr;
FILE *f;
unsigned long memaddr;
unsigned long memsize;
};
/*
* This read method is needed for non-mmappable files, or stuff that
* you can't know the size of (e.g., char devices). You can force use of
* read, to exercise the library procedures, using "-r"
*/
static int do_read(struct sdbfs *fs, int offset, void *buf, int count)
{
struct sdbr_drvdata *drvdata = fs->drvdata;
if (opt_verbose)
fprintf(stderr, "%s @ 0x%08x - size 0x%x (%i)\n", __func__,
offset, count, count);
if (drvdata->mapaddr) {
memcpy(buf, drvdata->mapaddr + offset, count);
return count;
}
/* not mmapped: seek and read */
if (fseek(drvdata->f, drvdata->memaddr + offset, SEEK_SET) < 0)
return -1;
return fread(buf, 1, count, drvdata->f);
}
/* Boring ascii representation of a device */
static int list_device(struct sdb_device *d, int depth, int base)
{
struct sdb_product *p;
struct sdb_component *c;
struct sdb_synthesis *s;
unsigned char *data;
static int warned;
char *warn;
int i, ret;
c = &d->sdb_component;
p = &c->product;
s = (void *)d;
if (!warned && opt_long) {
fprintf(stderr, "%s: listing format is to be defined\n",
prgname);
warned = 1;
}
/* Different sdb items are listed in different ways */
switch(p->record_type) {
/* The following items are components, and are listed as such */
case sdb_type_interconnect:
case sdb_type_device:
case sdb_type_bridge:
if (!opt_long) {
printf("%.19s\n", p->name);
return 0;
}
/* hack: show directory level looking at the internals */
printf("%016llx:%08x @ %08llx-%08llx ",
(long long)ntohll(p->vendor_id), ntohl(p->device_id),
(long long)base + ntohll(c->addr_first),
(long long)base + ntohll(c->addr_last));
for (i = 0; i < depth; i++)
printf(" ");
printf("%.19s\n", p->name);
return 0;
/* A product, but not a component (no address range) */
case sdb_type_integration:
if (!opt_long) {
printf("%.19s\n", p->name);
return 0;
}
printf("%016llx:%08x ",
(long long)ntohll(p->vendor_id), ntohl(p->device_id));
/* like above, show directory level */
for (i = 0; i < depth; i++)
printf(" ");
printf("%.19s\n", p->name);
return 0;
/* Just a string */
case sdb_type_repo_url:
if (opt_long)
printf("repo-url: %.63s\n",
((struct sdb_repo_url *)d)->repo_url);
return 0;
/* Some metadata */
case sdb_type_synthesis:
if (!opt_long)
return 0;
printf("synthesis-name: %.16s\n", s->syn_name);
printf(" commit-id: ");
for (i = 0; i < sizeof(s->commit_id); i++)
printf("%02x", s->commit_id[i]);
printf("\n");
/* Some of the following fields are sometimes empty */
if (s->tool_name[0] && s->tool_name[0] != ' ')
printf(" tool-name: %.8s\n", s->tool_name);
if (s->tool_version)
printf(" tool-version: 0x%08x\n",
ntohl(s->tool_version));
if (s->date)
printf(" build-date: %08x\n", ntohl(s->date));
if (s->user_name[0] && s->tool_name[0] != ' ')
printf(" build-user: %.15s\n", s->user_name);
return 0;
case sdb_type_empty:
return 0;
default:
break;
}
/* Unknown record type */
if (p->record_type & 0x80) {
warn = "Warning";
ret = 0;
} else {
warn = "Error";
ret = -1;
}
fprintf(stderr, "%s: unknown record type 0x%02x\n", warn,
p->record_type);
if (!opt_long) {
printf("Unknown-record\n");
return ret;
}
/* long listing of unknown record */
printf("Unknown-record:\n");
data = (void *)d;
for (i = 0; i < sizeof(struct sdb_empty); i++)
printf("%s%02x%c",
(i & 0xf) == 0 ? " " : "",
data[i],
(i & 0xf) == 0xf ? '\n' : ' ');
return ret;
}
/* The following three function perform the real work, main() is just glue */
static int do_list(struct sdbfs *fs)
{
struct sdb_device *d;
int new = 1;
int err = 0;
while ( (d = sdbfs_scan(fs, new)) != NULL) {
err += list_device(d, fs->depth, fs->base[fs->depth]);
new = 0;
}
return err;
}
static int do_cat_name(struct sdbfs *fs, char *name)
{
char buf[4096];
int i;
i = sdbfs_open_name(fs, name);
if (i < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, name, strerror(-i));
exit(1);
}
while ( (i = sdbfs_fread(fs, -1, buf, sizeof(buf))) > 0)
fwrite(buf, 1, i, stdout);
sdbfs_close(fs);
return 0;
}
static int do_cat_id(struct sdbfs *fs, uint64_t vendor, uint32_t dev)
{
char buf[4096];
int i;
i = sdbfs_open_id(fs, htonll(vendor), htonl(dev));
if (i < 0) {
fprintf(stderr, "%s: %016llx-%08x: %s\n", prgname,
(long long)vendor, dev, strerror(-i));
exit(1);
}
while ( (i = sdbfs_fread(fs, -1, buf, sizeof(buf))) > 0)
fwrite(buf, 1, i, stdout);
sdbfs_close(fs);
return 0;
}
/* As promised, here's the user-interface glue (and initialization, I admit) */
int main(int argc, char **argv)
{
int c, err;
FILE *f;
struct sdbfs _fs;
struct sdbfs *fs = &_fs; /* I like to type "fs->" */
struct stat stbuf;
struct sdbr_drvdata *drvdata;
void *mapaddr;
char *fsname;
char *filearg = NULL;
unsigned long int32;
unsigned long long int64;
int pagesize = getpagesize();
prgname = argv[0];
while ( (c = getopt(argc, argv, "lvre:m:")) != -1) {
switch (c) {
case 'l':
opt_long = 1;
break;
case 'v':
opt_verbose = 1;
break;
case 'r':
opt_read = 1;
break;
case 'e':
if (sscanf(optarg, "%i", &opt_entry) != 1) {
fprintf(stderr, "%s: not a number \"%s\"\n",
prgname, optarg);
exit(1);
}
break;
case 'm':
/* memory: "size@addr", "addr+size" (blanks ok) */
if (sscanf(optarg, "%li @ %li", &opt_memsize,
&opt_memaddr) == 2)
break;
if (sscanf(optarg, "%li + %li", &opt_memaddr,
&opt_memsize) == 2)
break;
fprintf(stderr, "%s: \"%s\" must be <size>@<addr> "
"or <addr>+<size>\n", prgname, optarg);
exit(1);
break;
}
}
if (optind < argc - 2 || optind > argc - 1)
help();
fsname = argv[optind];
if (optind + 1 < argc)
filearg = argv[optind + 1];
if ( !(f = fopen(fsname, "r")) || fstat(fileno(f), &stbuf) < 0) {
fprintf(stderr, "%s: %s: %s\n", prgname, fsname,
strerror(errno));
exit(1);
}
stbuf.st_size += pagesize - 1;
stbuf.st_size &= ~(pagesize - 1);
mapaddr = mmap(0,
opt_memsize ? opt_memsize : stbuf.st_size,
PROT_READ, MAP_PRIVATE, fileno(f),
opt_memaddr /* 0 by default */);
if (mapaddr == MAP_FAILED)
mapaddr = NULL; /* We'll seek/read */
/* So, describe the filesystem instance and give it to the library */
memset(fs, 0, sizeof(*fs));
drvdata = calloc(1, sizeof(*drvdata));
if (!drvdata) {perror("malloc"); exit(1);}
drvdata->f = f;
drvdata->memaddr = opt_memaddr;
drvdata->memsize = opt_memsize;
drvdata->mapaddr = mapaddr;
fs->drvdata = drvdata;
fs->name = fsname; /* not mandatory */
fs->blocksize = 256; /* only used for writing, actually */
fs->entrypoint = opt_entry;
if (opt_read || !drvdata->mapaddr)
fs->read = do_read;
else
fs->data = mapaddr;
if (opt_verbose)
fs->flags |= SDBFS_F_VERBOSE;
err = sdbfs_dev_create(fs);
if (err) {
fprintf(stderr, "%s: sdbfs_dev_create(): %s\n", prgname,
strerror(-err));
fprintf(stderr, "\t(wrong entry point 0x%08lx?)\n",
fs->entrypoint);
exit(1);
}
/* Now use the thing: either scan, or look for name, or look for id */
if (!filearg)
err = do_list(fs);
else if (sscanf(filearg, "%llx:%lx", &int64, &int32) != 2)
err = do_cat_name(fs, filearg);
else
err = do_cat_id(fs, int64, int32);
sdbfs_dev_destroy(fs);
return err;
}
Subproject commit 1168603b61ab36fe788a8290ae1f98762718d536
Subproject commit 7255640760a4d2adccf4d56e1746c4dfebc682b5
#ifndef _MEM_LAYOUT_H_
#define _MEM_LAYOUT_H_
#include "hw/pcie_regs.h"
#include "pcie_regs.h"
#include "acq_chan_afcv3.h"
#define NUM_MAX_SLOTS 12
#define NUM_MAX_BPM_PER_SLOT 2
#define NUM_MAX_BPMS (NUM_MAX_SLOTS * NUM_MAX_BPM_PER_SLOT)
#define NUM_FMC130M_4CH_SMIOS 2
/*********************** Static AFCv3 FPGA layout ***********************/
......@@ -21,6 +25,9 @@
/* AFC DIAG Components */
#define WB_AFC_DIAG_CTRL_RAW_REGS_OFFS 0x0000
/* ACQ Components */
#define WB_ACQ_CORE_CTRL_RAW_REGS_OFFS 0x0000
/* Should be autodiscovered by SDB */
/* Wishbone RAW Addresses */
......@@ -110,6 +117,9 @@
#define DSP_CTRL_REGS_OFFS (BAR4_ADDR | DSP_CTRL_RAW_REGS_OFFS)
#define DSP_BPM_SWAP_OFFS (BAR4_ADDR | DSP_BPM_RAW_SWAP_OFFS)
/* ACQ Components */
#define WB_ACQ_CORE_CTRL_REGS_OFFS (BAR4_ADDR | WB_ACQ_CORE_CTRL_RAW_REGS_OFFS)
/* Wishbone Addresses */
#define FMC1_130M_BASE_ADDR (BAR4_ADDR | FMC1_130M_BASE_RAW_ADDR)
......
#ifndef _MEM_LAYOUT_H_
#define _MEM_LAYOUT_H_
#include "hw/pcie_regs.h"
#include "pcie_regs.h"
#include "acq_chan_ml605.h"
#define NUM_MAX_SLOTS 1
#define NUM_MAX_BPM_PER_SLOT 2
#define NUM_MAX_BPMS (NUM_MAX_SLOTS * NUM_MAX_BPM_PER_SLOT)
#define NUM_FMC130M_4CH_SMIOS 1
/*********************** Static ML605 FPGA layout ***********************/
......@@ -18,6 +22,9 @@
#define DSP_CTRL_RAW_REGS_OFFS 0x0000
#define DSP_BPM_RAW_SWAP_OFFS 0x0100
/* ACQ Components */
#define WB_ACQ_CORE_CTRL_RAW_REGS_OFFS 0x0000
/* Should be autodiscovered by SDB */
/* Wishbone RAW Addresses */
......@@ -78,6 +85,9 @@
#define DSP_CTRL_REGS_OFFS (/*BAR4_ADDR |*/ DSP_CTRL_RAW_REGS_OFFS)
#define DSP_BPM_SWAP_OFFS (/*BAR4_ADDR |*/ DSP_BPM_RAW_SWAP_OFFS)
/* ACQ Components */
#define WB_ACQ_CORE_CTRL_REGS_OFFS (/*BAR4_ADDR |*/ WB_ACQ_CORE_CTRL_RAW_REGS_OFFS)
/* Wishbone Addresses */
#define FMC1_130M_BASE_ADDR (BAR4_ADDR | FMC1_130M_BASE_RAW_ADDR)
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _BPM_SERVER_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _BPM_SERVER_CLASSES_H_
......@@ -12,21 +12,20 @@
#include "bpm_server_prelude.h"
/* External dependencies */
#include <czmq.h>
#include <malamute.h>
#include <bsmp/client.h>
#include <convc.h>
#include <disptable.h>
#include <errhand.h>
#include <hutils.h>
#include <ll_io.h>
/* Internal libraries dependencies */
#include "libsdbfs.h"
#include "convc.h"
#include "disp_table.h"
#include "errhand.h"
#include "hutils.h"
#include "hal_stddef.h"
#include "hutils_math.h"
/* General dependencies */
#include "board.h"
#include "epics_mapping.h"
#include "revision.h"
#include "acq_chan_gen_defs.h"
......@@ -62,19 +61,6 @@ typedef struct _devio_info_t devio_info_t;
/* Opaque dmngr_t class structure */
typedef struct _dmngr_t dmngr_t;
/* Forward llio_err_e declaration enumeration */
typedef enum _llio_err_e llio_err_e;
/* Forward llio_type_e declaration enumeration */
typedef enum _llio_type_e llio_type_e;
/* Forward llio_eth_type_e declaration enumeration */
typedef enum _llio_eth_type_e llio_eth_type_e;
/* Opaque llio_dev_info_t structure */
typedef struct _llio_dev_info_t llio_dev_info_t;
/* Opaque llio_endpoint_t structure */
typedef struct _llio_endpoint_t llio_endpoint_t;
/* Opaque llio_t structure */
typedef struct _llio_t llio_t;
/* Forward devio_err_e declaration enumeration */
typedef enum _devio_err_e devio_err_e;
/* Forward devio_type_e declaration enumeration */
......@@ -119,16 +105,6 @@ typedef struct _zmq_server_args_t zmq_server_args_t;
#include "dev_mngr_dev_info.h"
#include "dev_mngr_core.h"
/* LL_IO */
#include "ll_io_err.h"
#include "ll_io_utils.h"
#include "ll_io_dev_info.h"
#include "ll_io_endpoint.h"
#include "ll_io.h"
#include "ll_io_pcie.h"
#include "ll_io_eth_utils.h"
#include "ll_io_eth.h"
/* DEV_IO */
#include "dev_io_err.h"
#include "dev_io_utils.h"
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Copied from CZMQ repository, available at
......@@ -16,4 +16,26 @@
#include <sys/types.h>
#include <stdbool.h>
/* zeroMQ libraries */
#include <zmq.h>
#include <czmq.h>
#include <malamute.h>
/* Check for library versions */
/* ZMQ */
#if ZMQ_VERSION < 40200
#error "BPM-SW requires at least libzmq/4.2.0."
#endif
/* CZMQ */
#if CZMQ_VERSION < 30001
#error "BPM-SW requires at least czmq/3.0.1"
#endif
/* MLM */
#if MALAMUTE_VERSION < 100
#error "BPM-SW requires at least malamute/0.1.0"
#endif
#endif
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _AD9510_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _E24AA64_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _PCA9547_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SI57X_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_IO_CORE_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_IO_EXPORTS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_IO_UTILS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_MNGR_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_MNGR_CORE_H_
......@@ -20,6 +20,9 @@ extern char *dmngr_verbose_str;
extern int dmngr_verbose;
extern char *dmngr_daemonize_str;
extern int dmngr_daemonize;
extern char *dmngr_work_dir;
extern char *dmngr_spawn_broker_cfg_str;
extern int dmngr_spawn_broker_cfg;
/* Signal handler function pointer */
typedef void (*sig_handler_fp)(int sig, siginfo_t *siginfo, void *context);
......@@ -42,14 +45,14 @@ typedef struct {
spawn_broker_handler_fp dmngr_spawn_broker; /* Called to spawn (or respawn a zeroMQ broker */
/* List of dmngr_sig_handler_t */
zlist_t *sig_ops;
zlistx_t *sig_ops;
} dmngr_ops_t;
/***************** Our methods *****************/
/* Creates a new instance of the Device Manager */
dmngr_t * dmngr_new (char *name, char *endpoint, int verbose,
const char *log_prefix, zhash_t *hints_h);
const char *log_prefix, zhashx_t *hints_h);
/* Destroy an instance of the Device Manager */
dmngr_err_e dmngr_destroy (dmngr_t **self_p);
......@@ -68,6 +71,12 @@ dmngr_err_e dmngr_spawn_chld (dmngr_t *self, const char *program, char *const ar
/* Setting all operations at once */
dmngr_err_e dmngr_set_ops (dmngr_t *self, dmngr_ops_t *dmngr_ops);
/* Set configuration filename */
dmngr_err_e dmngr_set_cfg_file (dmngr_t *self, char *cfg_file);
/* Get const reference to configuration filename */
const char * dmngr_get_cfg_file (dmngr_t *self);
/* Clone configuration filename */
char * dmngr_clone_cfg_file (dmngr_t *self);
/* Is broker Running? */
bool dmngr_is_broker_running (dmngr_t *self);
/* Spawn broker if not running */
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _DEV_MNGR_DEV_INFO_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
/*
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _EPICS_MAPPING_H_
#define _EPICS_MAPPING_H_
#ifdef __cplusplus
extern "C" {
#endif
/* BPM reverse mappping structure */
typedef struct {
int bpm_id;
} board_epics_rev_map_t;
typedef struct {
int telnet_port;
} board_epics_opts_t;
/* EPICS mapping definitions */
extern const board_epics_rev_map_t board_epics_rev_map [NUM_MAX_SLOTS+1][NUM_MAX_BPM_PER_SLOT];
extern const board_epics_opts_t board_epics_opts [NUM_MAX_SLOTS+1][NUM_MAX_BPM_PER_SLOT];
#ifdef __cplusplus
}
#endif
#endif
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _EXP_MSG_ZMQ_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _EXP_OPS_CODES_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Cut from Linux sources */
......
......@@ -3,7 +3,7 @@
* File : wb_acq_core_regs.h
* Author : auto-generated by wbgen2 from acq_core.wb
* Created : Fri May 16 20:02:39 2014
* Created : Thu Oct 22 17:24:54 2015
* Standard : ANSI C
THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE acq_core.wb
......@@ -115,16 +115,26 @@
#define ACQ_CORE_TRIG_CFG_INT_TRIG_SEL_R(reg) WBGEN2_GEN_READ(reg, 4, 2)
/* definitions for field: Reserved in reg: Trigger configuration */
#define ACQ_CORE_TRIG_CFG_RESERVED_MASK WBGEN2_GEN_MASK(6, 10)
#define ACQ_CORE_TRIG_CFG_RESERVED_MASK WBGEN2_GEN_MASK(6, 26)
#define ACQ_CORE_TRIG_CFG_RESERVED_SHIFT 6
#define ACQ_CORE_TRIG_CFG_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 6, 10)
#define ACQ_CORE_TRIG_CFG_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 6, 10)
#define ACQ_CORE_TRIG_CFG_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 6, 26)
#define ACQ_CORE_TRIG_CFG_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 6, 26)
/* definitions for field: Threshold for internal trigger in reg: Trigger configuration */
#define ACQ_CORE_TRIG_CFG_INT_TRIG_THRES_MASK WBGEN2_GEN_MASK(16, 16)
#define ACQ_CORE_TRIG_CFG_INT_TRIG_THRES_SHIFT 16
#define ACQ_CORE_TRIG_CFG_INT_TRIG_THRES_W(value) WBGEN2_GEN_WRITE(value, 16, 16)
#define ACQ_CORE_TRIG_CFG_INT_TRIG_THRES_R(reg) WBGEN2_GEN_READ(reg, 16, 16)
/* definitions for register: Trigger data config threshold */
/* definitions for field: Internal trigger threshold glitch filter in reg: Trigger data config threshold */
#define ACQ_CORE_TRIG_DATA_CFG_THRES_FILT_MASK WBGEN2_GEN_MASK(0, 8)
#define ACQ_CORE_TRIG_DATA_CFG_THRES_FILT_SHIFT 0
#define ACQ_CORE_TRIG_DATA_CFG_THRES_FILT_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define ACQ_CORE_TRIG_DATA_CFG_THRES_FILT_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for field: Reserved in reg: Trigger data config threshold */
#define ACQ_CORE_TRIG_DATA_CFG_RESERVED_MASK WBGEN2_GEN_MASK(8, 24)
#define ACQ_CORE_TRIG_DATA_CFG_RESERVED_SHIFT 8
#define ACQ_CORE_TRIG_DATA_CFG_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 8, 24)
#define ACQ_CORE_TRIG_DATA_CFG_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 8, 24)
/* definitions for register: Trigger data threshold */
/* definitions for register: Trigger delay */
......@@ -154,6 +164,8 @@
/* definitions for register: DDR3 Start Address */
/* definitions for register: DDR3 End Address */
/* definitions for register: Acquisition channel control */
/* definitions for field: Acquisition channel selection in reg: Acquisition channel control */
......@@ -161,29 +173,53 @@
#define ACQ_CORE_ACQ_CHAN_CTL_WHICH_SHIFT 0
#define ACQ_CORE_ACQ_CHAN_CTL_WHICH_W(value) WBGEN2_GEN_WRITE(value, 0, 5)
#define ACQ_CORE_ACQ_CHAN_CTL_WHICH_R(reg) WBGEN2_GEN_READ(reg, 0, 5)
/* FIXME: The FPGA firmware is WORD addressed for now */
/* definitions for field: Reserved in reg: Acquisition channel control */
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED_MASK WBGEN2_GEN_MASK(5, 3)
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED_SHIFT 5
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 5, 3)
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 5, 3)
/* definitions for field: Data-driven channel selection in reg: Acquisition channel control */
#define ACQ_CORE_ACQ_CHAN_CTL_DTRIG_WHICH_MASK WBGEN2_GEN_MASK(8, 5)
#define ACQ_CORE_ACQ_CHAN_CTL_DTRIG_WHICH_SHIFT 8
#define ACQ_CORE_ACQ_CHAN_CTL_DTRIG_WHICH_W(value) WBGEN2_GEN_WRITE(value, 8, 5)
#define ACQ_CORE_ACQ_CHAN_CTL_DTRIG_WHICH_R(reg) WBGEN2_GEN_READ(reg, 8, 5)
/* definitions for field: Reserved1 in reg: Acquisition channel control */
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED1_MASK WBGEN2_GEN_MASK(13, 19)
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED1_SHIFT 13
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED1_W(value) WBGEN2_GEN_WRITE(value, 13, 19)
#define ACQ_CORE_ACQ_CHAN_CTL_RESERVED1_R(reg) WBGEN2_GEN_READ(reg, 13, 19)
/* FIXME: The FPGA firmware is BYTE/WORD addressed depending on the board */
/* [0x0]: REG Control register */
#define ACQ_CORE_REG_CTL (0x00000000 >> __WR_SHIFT_FIX__)
/* [0x4]: REG Status register */
#define ACQ_CORE_REG_STA (0x00000004 >> __WR_SHIFT_FIX__)
/* [0x8]: REG Trigger configuration */
#define ACQ_CORE_REG_TRIG_CFG (0x00000008 >> __WR_SHIFT_FIX__)
/* [0xc]: REG Trigger delay */
#define ACQ_CORE_REG_TRIG_DLY (0x0000000c >> __WR_SHIFT_FIX__)
/* [0x10]: REG Software trigger */
#define ACQ_CORE_REG_SW_TRIG (0x00000010 >> __WR_SHIFT_FIX__)
/* [0x14]: REG Number of shots */
#define ACQ_CORE_REG_SHOTS (0x00000014 >> __WR_SHIFT_FIX__)
/* [0x18]: REG Trigger address register */
#define ACQ_CORE_REG_TRIG_POS (0x00000018 >> __WR_SHIFT_FIX__)
/* [0x1c]: REG Pre-trigger samples */
#define ACQ_CORE_REG_PRE_SAMPLES (0x0000001c >> __WR_SHIFT_FIX__)
/* [0x20]: REG Post-trigger samples */
#define ACQ_CORE_REG_POST_SAMPLES (0x00000020 >> __WR_SHIFT_FIX__)
/* [0x24]: REG Samples counter */
#define ACQ_CORE_REG_SAMPLES_CNT (0x00000024 >> __WR_SHIFT_FIX__)
/* [0x28]: REG DDR3 Start Address */
#define ACQ_CORE_REG_DDR3_START_ADDR (0x00000028 >> __WR_SHIFT_FIX__)
/* [0x2c]: REG Acquisition channel control */
#define ACQ_CORE_REG_ACQ_CHAN_CTL (0x0000002c >> __WR_SHIFT_FIX__)
/* [0xc]: REG Trigger data config threshold */
#define ACQ_CORE_REG_TRIG_DATA_CFG (0x0000000c >> __WR_SHIFT_FIX__)
/* [0x10]: REG Trigger data threshold */
#define ACQ_CORE_REG_TRIG_DATA_THRES (0x00000010 >> __WR_SHIFT_FIX__)
/* [0x14]: REG Trigger delay */
#define ACQ_CORE_REG_TRIG_DLY (0x00000014 >> __WR_SHIFT_FIX__)
/* [0x18]: REG Software trigger */
#define ACQ_CORE_REG_SW_TRIG (0x00000018 >> __WR_SHIFT_FIX__)
/* [0x1c]: REG Number of shots */
#define ACQ_CORE_REG_SHOTS (0x0000001c >> __WR_SHIFT_FIX__)
/* [0x20]: REG Trigger address register */
#define ACQ_CORE_REG_TRIG_POS (0x00000020 >> __WR_SHIFT_FIX__)
/* [0x24]: REG Pre-trigger samples */
#define ACQ_CORE_REG_PRE_SAMPLES (0x00000024 >> __WR_SHIFT_FIX__)
/* [0x28]: REG Post-trigger samples */
#define ACQ_CORE_REG_POST_SAMPLES (0x00000028 >> __WR_SHIFT_FIX__)
/* [0x2c]: REG Samples counter */
#define ACQ_CORE_REG_SAMPLES_CNT (0x0000002c >> __WR_SHIFT_FIX__)
/* [0x30]: REG DDR3 Start Address */
#define ACQ_CORE_REG_DDR3_START_ADDR (0x00000030 >> __WR_SHIFT_FIX__)
/* [0x34]: REG DDR3 End Address */
#define ACQ_CORE_REG_DDR3_END_ADDR (0x00000034 >> __WR_SHIFT_FIX__)
/* [0x38]: REG Acquisition channel control */
#define ACQ_CORE_REG_ACQ_CHAN_CTL (0x00000038 >> __WR_SHIFT_FIX__)
#endif
......@@ -3,7 +3,7 @@
* File : pos_calc_regs.h
* Author : auto-generated by wbgen2 from wb_pos_calc_regs.wb
* Created : Fri May 16 20:11:41 2014
* Created : Thu Sep 17 16:29:28 2015
* Standard : ANSI C
THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wb_pos_calc_regs.wb
......@@ -350,6 +350,8 @@
/* definitions for register: Monit. Q Position Value */
/* definitions for register: Monit. Sum Position Value */
/* definitions for register: Monit. Amp/Pos update trigger */
/* [0x0]: REG Config divisor threshold TBT register */
#define POS_CALC_REG_DS_TBT_THRES 0x00000000
/* [0x4]: REG Config divisor threshold FOFB register */
......@@ -406,4 +408,6 @@
#define POS_CALC_REG_DSP_MONIT_POS_Q 0x00000068
/* [0x6c]: REG Monit. Sum Position Value */
#define POS_CALC_REG_DSP_MONIT_POS_SUM 0x0000006c
/* [0x70]: REG Monit. Amp/Pos update trigger */
#define POS_CALC_REG_DSP_MONIT_UPDT 0x00000070
#endif
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _MSG_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _MSG_MACROS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SMPR_I2C_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SMPR_SPI_REGS_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _REVISION_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _RW_PARAM_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _RW_PARAM_CODES_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_CH_24AA64_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_CH_AD9510_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_CH_PCA9547_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_CH_RFFE_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_CH_SI57X_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_H_
......@@ -30,6 +30,7 @@ extern "C" {
#define SMIO_DISPATCH_FUNC_WRAPPER_GEN(func_name, ...) \
({ \
volatile const smio_mod_dispatch_t *smio_mod_dispatch = &_smio_mod_dispatch; \
smio_err_e local_err = SMIO_ERR_FUNC_NOT_IMPL; \
if (smio_mod_dispatch[th_args->smio_id].bootstrap_ops && \
smio_mod_dispatch[th_args->smio_id].bootstrap_ops->func_name) { \
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_BOOTSTRAP_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_EXPORTS_H_
......
......@@ -2,12 +2,12 @@
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_EXPORTS_HELPER_H_
#define _SM_IO_EXPORTS_HELPER_H_
#include "disp_table.h"
#include "disptable.h"
#endif
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _MOD_DISPATCH_H_
......@@ -18,9 +18,28 @@ typedef struct {
uint32_t id;
const char *name;
const smio_bootstrap_ops_t *bootstrap_ops;
} smio_mod_dispatch_t;
} __attribute__ ((aligned (16))) smio_mod_dispatch_t;
extern const smio_mod_dispatch_t smio_mod_dispatch [];
/*
* WARNING! Using SMIO_MOD_DECLARE requires .smio_mod_dispatch section in linker script
* .smio_mod_dispatch : ALIGN(4)
* {
* _smio_mod_dispatch = .;
* KEEP(*(.smio_mod_dispatch))
* _esmio_mod_dispatch = .;
* }
*/
extern const smio_mod_dispatch_t _smio_mod_dispatch;
extern const smio_mod_dispatch_t _esmio_mod_dispatch;
#define SMIO_MOD_DECLARE(mod_id, mod_name, mod_bootstrap_ops) \
const smio_mod_dispatch_t __attribute__ ((section (".smio_mod_dispatch"))) \
smio_mod_ ## mod_id ## _ ## mod_name = { \
.id = mod_id, \
.name = mod_name, \
.bootstrap_ops = &mod_bootstrap_ops \
};
#ifdef __cplusplus
}
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_THSAFE_CODES_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_PR_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_PR_BSMP_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
/* Error definitions and output stringification based on the work available
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_PR_I2C_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_PR_SPI_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SMIO_THSAFE_ZMQ_CLIENT_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SMIO_THSAFE_ZMQ_SERVER_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _THSAFE_MSG_ZMQ_H_
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _VARG_MACROS_H_
......
SECTIONS
{
.smio_mod_dispatch : ALIGN(8)
{
_smio_mod_dispatch = .;
KEEP(*(.smio_mod_dispatch))
_esmio_mod_dispatch = .;
}
}
INSERT AFTER .rodata;
......@@ -11,12 +11,12 @@ fi
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {broker endpoint}"
echo "Usage: `basename $0` {cfg file}"
exit 1;
fi
broker_endp=$1
cfg_file=$1
valgrind --leak-check=yes --trace-children=yes \
--suppressions=valgrind.supp ./dev_mngr "ipc://"$broker_endp > \
--suppressions=valgrind.supp ./dev_mngr -f $cfg_file > \
valgrind_report.txt 2>&1
#!/usr/bin/env bash
killall dev_io
killall malamute
killall dev_mngr
#!/bin/sh
BIN_DIR=$1
function usage {
echo "Usage: $0 <bin directory> [options]"
}
if [ -z "$BIN_DIR" ]; then
echo "\"BIN_DIR\" variable unset."
usage
exit 1
fi
for opt in "${@:2}"
do
OPTS+=("${item}")
done
${BIN_DIR}/dev_io ${EXTRA_FLAGS[@]}
#!/bin/sh
BIN_INSTANCE=$1
function usage {
echo "Usage: $0 <bin instance>"
}
if [ -z "$BIN_INSTANCE" ]; then
echo "\"BIN_INSTANCE\" variable unset."
usage
exit 1
fi
# FIXME: Find correct dev_io instance looking at all running processes
TARGET_PID=$(ps aux | grep -Ei "dev_io.*/dev/fpga-${BIN_INSTANCE}.*" | head -1 | awk '{print $2}')
kill ${TARGET_PID}
#!/usr/bin/env python
# Copyright 2008 Marcus D. Hanwell <marcus@cryos.org>
# Minor changes for NUT by Charles Lepple
# Distributed under the terms of the GNU General Public License v2 or later
import string, re, os
from textwrap import TextWrapper
import sys
rev_range = ''
if len(sys.argv) > 1:
base = sys.argv[1]
rev_range = '%s..HEAD' % base
# Execute git log with the desired command line options.
fin = os.popen('git log --summary --stat --no-merges --date=short %s' % rev_range, 'r')
# Create a ChangeLog file in the current directory.
fout = open('ChangeLog', 'w')
# Set up the loop variables in order to locate the blocks we want
authorFound = False
dateFound = False
messageFound = False
filesFound = False
message = ""
messageNL = False
files = ""
prevAuthorLine = ""
wrapper = TextWrapper(initial_indent="\t", subsequent_indent="\t ")
# The main part of the loop
for line in fin:
# The commit line marks the start of a new commit object.
if line.startswith('commit'):
# Start all over again...
authorFound = False
dateFound = False
messageFound = False
messageNL = False
message = ""
filesFound = False
files = ""
continue
# Match the author line and extract the part we want
elif 'Author:' in line:
authorList = re.split(': ', line, 1)
author = authorList[1]
author = author[0:len(author)-1]
authorFound = True
# Match the date line
elif 'Date:' in line:
dateList = re.split(': ', line, 1)
date = dateList[1]
date = date[0:len(date)-1]
dateFound = True
# The Fossil-IDs are ignored:
elif line.startswith(' Fossil-ID:') or line.startswith(' [[SVN:'):
continue
# The svn-id lines are ignored
elif ' git-svn-id:' in line:
continue
# The sign off line is ignored too
elif 'Signed-off-by' in line:
continue
# Extract the actual commit message for this commit
elif authorFound & dateFound & messageFound == False:
# Find the commit message if we can
if len(line) == 1:
if messageNL:
messageFound = True
else:
messageNL = True
elif len(line) == 4:
messageFound = True
else:
if len(message) == 0:
message = message + line.strip()
else:
message = message + " " + line.strip()
# If this line is hit all of the files have been stored for this commit
elif re.search('files? changed', line) >= 0:
filesFound = True
continue
# Collect the files for this commit. FIXME: Still need to add +/- to files
elif authorFound & dateFound & messageFound:
fileList = re.split(' \| ', line, 2)
if len(fileList) > 1:
if len(files) > 0:
files = files + ", " + fileList[0].strip()
else:
files = fileList[0].strip()
# All of the parts of the commit have been found - write out the entry
if authorFound & dateFound & messageFound & filesFound:
# First the author line, only outputted if it is the first for that
# author on this day
authorLine = date + " " + author
if len(prevAuthorLine) == 0:
fout.write(authorLine + "\n\n")
elif authorLine == prevAuthorLine:
pass
else:
fout.write("\n" + authorLine + "\n\n")
# Assemble the actual commit message line(s) and limit the line length
# to 80 characters.
commitLine = "* " + files + ": " + message
# Write out the commit line
fout.write(wrapper.fill(commitLine) + "\n")
#Now reset all the variables ready for a new commit block.
authorFound = False
dateFound = False
messageFound = False
messageNL = False
message = ""
filesFound = False
files = ""
prevAuthorLine = authorLine
# Close the input and output lines now that we are finished.
fin.close()
fout.close()
function find_acq_non_consecutive(filename)
data=load(filename);
for n = 1:size(data,2)
nc = find_non_consecutive(data(:,n)');
nc_wrap = omit_wraparound(data(:,n)', nc, "twoscomplement", 16)
end
end
function x = find_non_consecutive(a)
p = find(diff(a)!=1);
x = [p;p+1];
end
function x = omit_wraparound(a, nc_idx, mode, num_bits)
if strcmp (mode, "twoscomplement")
limit_bot = -2^(num_bits-1);
limit_up = 2^(num_bits-1)-1;
elseif strcmp (mode, "offsetbinary")
limit_bot = 0;
limit_up = 2^(num_bits)-1;
else
error ("mode is not valid! Supported modes are \"twoscomplement\" and \"offsetbinary\"");
end
x = [];
for n = 1:2:size(nc_idx,1)*size(nc_idx,2)
if a(nc_idx(n)) != limit_up || a(nc_idx(n+1)) != limit_bot
x = [x, [nc_idx(n);nc_idx(n+1)]];
end
end
end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
board_DIR = $(SRC_DIR)/boards/afcv3
board_OBJS = $(board_DIR)/epics_mapping.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment