Commit 1394f372 authored by Dimitris Lampridis's avatar Dimitris Lampridis Committed by Dimitris Lampridis

sw: wip cleanup and comments

parent 1f2cd1f6
......@@ -44,3 +44,16 @@ else
GIT_VERSION=$(GIT_VERSION) EXCLUDE_FILES=$(EXCLUDE_FILES) BRIEF=$(BRIEF) \
OUTPUT=$(DOXY_OUT) doxygen ./doxygen-wrtd-config
endif
# List of Doxygen folders to consider
DOXINPUT := ../software/lib
DOXINPUT += ../software/include
DOXINPUT += ../software/firmware/common
DOXEXCL := ""
# List of actual Doxygen source files
DOXSRC = $(shell find $(DOXINPUT) -type f -name '*.[chS]')
.doxystamp: $(DOXSRC)
GIT_VERSION=$(GIT_VERSION) DOXINPUT="$(DOXINPUT)" DOXEXCL="$(DOXEXCL)" doxygen ./doxygen-wrtd-config
@touch .doxystamp
Dictionary
==========
The main purpose of this dictionary is to explain the
White-Rabbit Trigger-Distribution terminology.
channel
dead time
delay
input
output
pulse
trigger
trigger condition
\ No newline at end of file
Introduction
============
`Hello` *there* [link](https://ohwr.org)
- item 1
- item 2
[dictionary](dictionary.md)
-include Makefile.specific
DIRS := tdc fd adc
all clean cleanall modules install modules_install: $(DIRS)
clean: TARGET = clean
......
#
# Automatically generated file; DO NOT EDIT.
# fmc-svec-carrier fw-01 demo configuration
#
#
......
/*
* Copyright (C) 2018 CERN (www.cern.ch)
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
/**
* @file wrtd-adcin.c
*
* ADCIN: trigger coming from the ADC mezzanine.
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
/* ADCIN: trigger coming from the ADC mezzanine. */
#include "mockturtle-rt.h"
#define ADCIN_NUM_CHANNELS 5
......
/*
* Copyright (C) 2013-2018 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-adcin.c
*
* ADCout: trigger ADC sampling. Output from the WRTD pov.
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
/* ADCout: trigger ADC sampling. Output from the WRTD pov. */
#include <errno.h>
#include <string.h>
......
/*
* Copyright (C) 2013-2018 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-rt-adc.c
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
#include <mockturtle-framework.h>
#include "wrtd-common.h"
......
/*
* acam_gpx.h
/**
* @file acam_gpx.h
*
* Copyright (c) 2012-2013 CERN (http://www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; version 2 of the License.
* Copyright (c) 2012-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __ACAM_GPX_H
......@@ -102,4 +101,3 @@
#define AR12_StartNU (1<<26)
#endif
/* Generic output queue.
User needs to define:
OUT_QUEUE_PREFIX: the prefix (ends with an '_')
OUT_QUEUE_SIZE: max length of the queue
OUT_QUEUE_MAXTIME: maximum time in advance.
*/
/**
* @file out_queue.h
*
* Generic output queue. Users need to define:
* - `OUT_QUEUE_PREFIX` : the prefix (must end with an '_')
* - `OUT_QUEUE_SIZE` : max length of the queue
* - `OUT_QUEUE_MAXTIME`: maximum time in advance.
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef OUT_QUEUE_PREFIX
#error "OUT_QUEUE_PREFIX not defined"
......
/* This is a basic linker configuration for WRTD.
/**
* @file trtl-memory.ld
*
* This is a basic linker configuration for WRTD.
*
* It expects that every MT CPU has at least 32KB
* of memory, as well as 2KB of shared memory for
* all CPUS.
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
MEMORY
......
/* Code to insert inside the firmware:
#define NBR_CPUS xxx
#define CPU_IDX xxx
#define NBR_RULES xxx
#define NBR_DEVICES xxx
#define NBR_ALARMS xxx
#define DEVICES_NBR_CHS { xxx, 0, 0, 0}
#define DEVICES_CHS_DIR { WRTD_CH_DIR_IN, 0, 0, 0}
#define APP_ID WRTD_APP_xxx
#define APP_VER RT_VERSION(xxx, 0)
#define APP_NAME xxx
#define WRTD_NET_RX x // 1 = enabled, 0 = disabled
#define WRTD_NET_TX x
#define WRTD_LOCAL_RX x
#define WRTD_LOCAL_TX x
#include "wrtd-rt-common.h"
*/
/**
* @file wrtd-rt-common.h
*
* This is the common part that should be included
* by every WRTD firmware application.
*
* In order for it to work, the firmware application
* must declare the following definitions and includes:
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* #define NBR_CPUS xxx
* #define CPU_IDX xxx
* #define NBR_RULES xxx
* #define NBR_DEVICES xxx
* #define NBR_ALARMS xxx
* #define DEVICES_NBR_CHS { xxx, 0, 0, 0}
* #define DEVICES_CHS_DIR { WRTD_CH_DIR_IN, 0, 0, 0}
* #define APP_ID WRTD_APP_xxx
* #define APP_VER RT_VERSION(xxx, 0)
* #define APP_NAME xxx
* #define WRTD_NET_RX x // 1 = enabled, 0 = disabled
* #define WRTD_NET_TX x
* #define WRTD_LOCAL_RX x
* #define WRTD_LOCAL_TX x
* #include "wrtd-rt-common.h"
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
/* Remote message queue for network. */
#define WRTD_RMQ 0
......@@ -183,7 +195,7 @@ static void wrtd_recv_loopback(void)
q->read_idx = (q->read_idx + 1) & (LOOPBACK_QUEUE_SIZE - 1);
smem_atomic_add(&q->count, -1);
}
#endif
#endif // NBR_CPUS
static inline void ts_add2_ns(struct wrtd_tstamp *ts, uint32_t ns)
{
......@@ -241,7 +253,6 @@ static void wrtd_log(uint32_t type, uint32_t reason,
{
struct wrtd_log_entry *log;
struct trtl_fw_msg msg;
struct wrtd_tstamp now;
int ret;
/* First, handle statistics */
......@@ -276,11 +287,6 @@ static void wrtd_log(uint32_t type, uint32_t reason,
return;
}
if ( ts == NULL )
ts_now(&now);
else
now = *ts;
mq_map_out_message(TRTL_HMQ, WRTD_HMQ, &msg);
msg.header->flags = 0;
......@@ -295,7 +301,10 @@ static void wrtd_log(uint32_t type, uint32_t reason,
else
memset(&log->event, 0, sizeof(struct wrtd_event));
log->ts = now;
if (ts != NULL)
log->ts = *ts;
else
memset(&log->ts, 0, sizeof(struct wrtd_tstamp));
mq_send(TRTL_HMQ, WRTD_HMQ);
......@@ -357,7 +366,7 @@ static int wrtd_send_network(struct wrtd_event *ev)
return 0;
}
#endif
#endif // WRTD_NET_TX
static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
{
......@@ -365,12 +374,8 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
struct wrtd_tstamp now;
uint32_t lat_ns;
/* Event was received. */
rule->stat.rx_events++;
rule->stat.rx_last = ev->ts;
/* Check hold-off.
Note: this also exclude events that came before the last
Note: this also excludes events that came before the last
one. */
if (rule->conf.hold_off_ns) {
if (ts_cmp(&ev->ts, &rule->stat.hold_off) < 0) {
......@@ -385,14 +390,18 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
&ev->ts, rule->conf.hold_off_ns);
}
/* Event was received. */
rule->stat.rx_events++;
rule->stat.rx_last = ev->ts;
ts_now(&now);
/* Compute latency. */
do {
lat_ns = now.ns - ev->ts.ns;
if(lat_ns >> 31) {
/* Result is negatif, possible only if differ by
1 sec. */
/* Result is negative, possible only if
timestamps differ by 1 sec. */
if (ev->ts.seconds + 1 == now.seconds)
lat_ns += 1000000000;
else
......@@ -559,7 +568,7 @@ static void wrtd_recv_network(void)
wrtd_route_in(&ev);
}
#endif
#endif //WRTD_NET_RX
#if NBR_ALARMS > 0
static void wrtd_alarms(void)
......@@ -601,7 +610,7 @@ static void wrtd_alarms(void)
ts_add2_ns(&al->event.ts, al->period_ns);
}
}
#endif
#endif // NBR_ALARMS
static int wrtd_action_readw(struct trtl_fw_msg *msg_i,
struct trtl_fw_msg *msg_o)
......@@ -631,7 +640,6 @@ static int wrtd_action_readw(struct trtl_fw_msg *msg_i,
return 0;
}
static int wrtd_action_writew(struct trtl_fw_msg *msg_i,
struct trtl_fw_msg *msg_o)
{
......@@ -658,7 +666,6 @@ static int wrtd_action_writew(struct trtl_fw_msg *msg_i,
return 0;
}
static int wrtd_action_get_config(struct trtl_fw_msg *msg_i,
struct trtl_fw_msg *msg_o)
{
......@@ -678,7 +685,6 @@ static int wrtd_action_get_config(struct trtl_fw_msg *msg_i,
return 0;
}
static trtl_fw_action_t *wrtd_actions[] = {
[WRTD_ACTION_GET_CONFIG] = wrtd_action_get_config,
[WRTD_ACTION_READW] = wrtd_action_readw,
......
#
# Automatically generated file; DO NOT EDIT.
# fmc-svec-carrier fw-01 demo configuration
#
#
......
/*
/**
* @file fd_acam.c
*
* Accessing the ACAM chip and configuring it.
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* Copyright (c) 2012-2019 CERN (home.cern)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
......@@ -81,7 +82,9 @@ static int acam_calc_pll(uint64_t tref, int bin, int *hsdiv_out,
tmpll = div_u64(tref << refdiv, 216);
bin = div_u64(tmpll, hsdiv);
}
return (bin + 1); /* We always return the bin size in the I mode. Other modes should scale it appropriately. */
/* We always return the bin size in the I mode.
Other modes should scale it appropriately. */
return (bin + 1);
}
static void acam_set_address(struct wrtd_fd_dev *fd, int addr)
......@@ -235,7 +238,6 @@ static struct acam_init_data acam_init_regs_imode[] = {
{4, AR4_EFlagHiZN | AR4_MasterReset | AR4_StartTimer(0)},
};
static int acam_configure(struct wrtd_fd_dev *fd, enum fd_acam_modes mode,
const struct acam_init_data *regs, int n_regs )
{
......@@ -293,7 +295,6 @@ static int acam_configure(struct wrtd_fd_dev *fd, enum fd_acam_modes mode,
return 0;
}
int fd_acam_init(struct wrtd_fd_dev *fd)
{
int ret;
......@@ -304,13 +305,15 @@ int fd_acam_init(struct wrtd_fd_dev *fd)
if ( (ret = acam_test_bus(fd)) )
return ret;
if ( (ret = acam_configure(fd, ACAM_IMODE, acam_init_regs_imode, ARRAY_SIZE(acam_init_regs_imode))) )
if ( (ret = acam_configure(fd, ACAM_IMODE, acam_init_regs_imode,
ARRAY_SIZE(acam_init_regs_imode))) )
return ret;
if ( (ret = fd_calibrate_outputs(fd)) )
return ret;
if ( (ret = acam_configure(fd, ACAM_GMODE, acam_init_regs_gmode, ARRAY_SIZE(acam_init_regs_gmode))) )
if ( (ret = acam_configure(fd, ACAM_GMODE, acam_init_regs_gmode,
ARRAY_SIZE(acam_init_regs_gmode))) )
return ret;
acam_set_bypass(fd, 0); /* Driven by core, not host */
......
/*
/**
* @file fd_calibrate.c
*
* Calibrate the output path.
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
* Copyright (c) 2012-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
......@@ -24,7 +25,6 @@ static void acam_set_bypass(struct wrtd_fd_dev *fd, int on)
fd_writel(fd, on ? FD_GCR_BYPASS : 0, FD_REG_GCR);
}
/*
* Measures the the FPGA-generated TDC start and the output of one of
* the fine delay chips (channel) at a pre-defined number of taps
......
/*
/**
* @file fd_gpio.c
*
* SPI access to fine-delay internals
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* Copyright (c) 2012-2019 CERN (home.cern)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
......
/*
/**
* @file fd_i2c.c
*
* I2C access (on-board EEPROM)
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* Copyright (c) 2012-2019 CERN (home.cern)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
......
/*
* Copyright (C) 2018 CERN (www.cern.ch)
/**
* @file fd_init.c
*
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <errno.h>
#include <string.h>
......
/*
* Copyright (C) 2018 CERN (www.cern.ch)
/**
* @file fd_pll.c
*
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <errno.h>
#include <string.h>
......
/**
* @file pll_config.h
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
struct ad9516_reg {
int reg;
......
/*
* Copyright (C) 2013-2018 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-fd.c
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
......
/**
* @file wrtd-fd.h
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __FINE_DELAY_WRAPPER_H
#define __FINE_DELAY_WRAPPER_H
......
/*
* Copyright (C) 2013-2018 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-rt-fd.c
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
......
#
# Automatically generated file; DO NOT EDIT.
# fmc-svec-carrier fw-01 demo configuration
#
#
......
/*
* tdc_registers.h
/**
* @file tdc_regs.h
*
* Copyright (c) 2012 CERN (http://www.cern.ch)
* Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
* Copyright (c) 2012-2019 CERN (home.cern)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; version 2 of the License.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __TDC_REGISTERS_H
......@@ -125,11 +122,10 @@
#define TDC_DMA_STAT_ERROR 0x3
/* TDC core submodule offsets (wrs to the TDC control registers block) */
#define TDC_MEZZ_ONEWIRE_OFFSET (-0x1000)
#define TDC_MEZZ_EIC_OFFSET (0x1000)
#define TDC_MEZZ_I2C_OFFSET (0x2000)
#define TDC_MEZZ_MEM_OFFSET (0x3000)
#define TDC_MEZZ_ONEWIRE_OFFSET -0x1000
#define TDC_MEZZ_EIC_OFFSET 0x1000
#define TDC_MEZZ_I2C_OFFSET 0x2000
#define TDC_MEZZ_MEM_OFFSET 0x3000
#endif /* __TDC_REGISTERS_H */
/*
* Copyright (C) 2013-2018 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-rt-tdc.c
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "mockturtle-rt.h"
#include <mockturtle-framework.h>
#include "wrtd-common.h"
......
/*
* Copyright (C) 2018 CERN (www.cern.ch)
* Author: Dimitris Lampridis <dimitris.lampridis@cern.ch>
/**
* @file wrtd-tdc.c
*
* Copyright (c) 2018-2019 CERN (home.cern)
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
......@@ -22,7 +23,6 @@
#define DEFAULT_DEAD_TIME (80000/16)
struct wrtd_tdc_dev {
uint32_t io_addr;
/* FIXME: base channel (to create the event id). */
......
......@@ -23,24 +23,27 @@
/**
* WRTD timestamp format
*/
struct wrtd_tstamp {
// TODO: maybe distinguish between UTC and TAI
// TODO: maybe distinguish between UTC and TAI
typedef struct wrtd_tstamp {
/** TAI seconds since 1/1/1970 (Unix Epoch Time). */
uint32_t seconds;
/** Number of nanoseconds. Wraps at 10e9. */
uint32_t ns;
/** Number of fractional nanoseconds. Unit is 2e-32 ns. */
uint32_t frac;
};
} wrtd_tstamp;
struct wrtd_event {
/* Time of the event. */
/** Time of the event. */
struct wrtd_tstamp ts;
/* Event id. */
/** Event id. */
char id[WRTD_ID_LEN];
/* Sequence number. */
/** Sequence number. */
uint32_t seq;
/* Associated flags. */
/** Associated flags. */
unsigned char flags;
};
......
......@@ -850,6 +850,29 @@ enum wrtd_status wrtd_attr_get_rule_send_late(struct wrtd_dev *wrtd,
return WRTD_SUCCESS;
}
enum wrtd_status wrtd_attr_get_sys_time(struct wrtd_dev *wrtd,
struct wrtd_tstamp *value)
{
enum wrtd_status status;
struct wrtd_config_msg msg;
if(wrtd == NULL){
return WRTD_ERROR_NOT_INITIALIZED;
}
/* Always use CPU #0 (it does exist!). */
status = wrtd_msg_get_config(wrtd, 0, &msg, __func__);
WRTD_RETURN_IF_ERROR(status);
*value = msg.now;
return WRTD_SUCCESS;
}
/**
*@} End group Time
*/
enum wrtd_status wrtd_attr_global(struct wrtd_dev *wrtd,
const char *rep_cap_id)
{
......
......@@ -123,7 +123,7 @@ enum wrtd_status wrtd_log_read(struct wrtd_dev *wrtd,
}
/* Clean up errno to be able to distinguish between error cases and
normal behaviour when the function return less messages
normal behaviour when the function returns less messages
than expected */
errno = 0;
......@@ -135,7 +135,7 @@ enum wrtd_status wrtd_log_read(struct wrtd_dev *wrtd,
}
if (ret < 0)
return wrtd_return_error
(wrtd, WRTD_ERROR_INTERNAL, "%s/%s: %s",
(wrtd, WRTD_ERROR_INTERNAL, "%s/%s(poll): %s",
caller_func, __func__, trtl_strerror(errno));
for (i = 0; i < wrtd->nbr_cpus; ++i) {
......@@ -144,7 +144,7 @@ enum wrtd_status wrtd_log_read(struct wrtd_dev *wrtd,
ret = trtl_msg_async_recv(wrtd->trtl, i, WRTD_HMQ, &msg, 1);
if (ret <= 0)
return wrtd_return_error
(wrtd, WRTD_ERROR_INTERNAL, "%s/%s: %s",
(wrtd, WRTD_ERROR_INTERNAL, "%s/%s(recv): %s",
caller_func, __func__, trtl_strerror(errno));
memcpy(log, msg.data, sizeof(struct wrtd_log_entry));
......@@ -321,17 +321,16 @@ enum wrtd_status wrtd_fill_roots(struct wrtd_dev *wrtd, const char *caller_func)
if (status != WRTD_SUCCESS)
return status;
if (wrtd->roots[cpu].ver_major != WRTD_VERSION_MAJOR) {
status = wrtd_return_error
/* Invalidate root. */
wrtd->roots[cpu].ver_major = 0;
return wrtd_return_error
(wrtd, WRTD_ERROR_VERSION_MISMATCH,
"%s/%s: incorrect major version (%d instead of %d)",
caller_func, __func__,
wrtd->roots[cpu].ver_major,
WRTD_VERSION_MAJOR);
/* Invalidate root. */
wrtd->roots[cpu].ver_major = 0;
return status;
}
if (wrtd->roots[cpu].ver_minor != WRTD_VERSION_MINOR) {
if (wrtd->roots[cpu].ver_minor > WRTD_VERSION_MINOR) {
/* Invalidate root. */
wrtd->roots[cpu].ver_major = 0;
return wrtd_return_error
......@@ -621,4 +620,3 @@ inline enum wrtd_status wrtd_rule_check_disabled(struct wrtd_dev *wrtd, unsigned
caller_func, __func__);
return WRTD_SUCCESS;
}
......@@ -11,13 +11,6 @@
#define WRTD_RETURN_IF_ERROR(status) if(status != WRTD_SUCCESS) return status
/* A complete log entry needs 35+1+35+1+9+1+8=90 + 1 for null termination.
1st field: log tstamp in YYYY-MM-DD,hh:mm:ss.xxx.yyy.zzz+fff format.
2nd field: event tstamp in YYYY-MM-DD,hh:mm:ss.xxx.yyy.zzz+fff format.
3rd field: log type, padded with spaces to 9 characters.
4th field: log reason, padded with spaces to 8 characters. */
#define WRTD_LOG_ENTRY_SIZE 91
#define WRTD_DEFAULT_TIMEOUT 1000
/* Add nanoseconds to an existing wrtd timestamp */
......@@ -302,6 +295,8 @@ enum wrtd_status wrtd_attr_set_rule_send_late(struct wrtd_dev *wrtd,
enum wrtd_status wrtd_attr_get_rule_send_late(struct wrtd_dev *wrtd,
const char *rep_cap_id,
bool *value);
enum wrtd_status wrtd_attr_get_sys_time(struct wrtd_dev *wrtd,
struct wrtd_tstamp *value);
enum wrtd_status wrtd_attr_global(struct wrtd_dev *wrtd,
const char *rep_cap_id);
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-config.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* Copyright (c) 2018-2019 CERN (home.cern)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <stdint.h>
......@@ -367,7 +356,8 @@ static enum wrtd_status wrtd_cmd_sys_time(struct wrtd_dev *wrtd,
struct wrtd_tstamp t;
enum wrtd_status res;
res = wrtd_get_sys_time(wrtd, &t);
res = wrtd_get_attr_tstamp(wrtd, WRTD_GLOBAL_REP_CAP_ID,
WRTD_ATTR_SYS_TIME, &t);
WRTD_RETURN_IF_ERROR(res);
print_ts(&t);
......@@ -481,7 +471,8 @@ static enum wrtd_status wrtd_cmd_set_alarm(struct wrtd_dev *wrtd,
/* Set time. */
status = wrtd_get_sys_time(wrtd, &ts);
status = wrtd_get_attr_tstamp(wrtd, WRTD_GLOBAL_REP_CAP_ID,
WRTD_ATTR_SYS_TIME, &ts);
WRTD_RETURN_IF_ERROR(status);
ts_add_ps(&ts, delay);
......
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
/**
* @file wrtd-inout-common.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* Copyright (c) 2018-2019 CERN (home.cern)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <stdint.h>
......
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
/**
* @file wrtd-internal.h
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Copyright (c) 2018-2019 CERN (home.cern)
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef __WRTD_TOOLS_INTERNAL_H__
......
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
/**
* @file wrtd-logging.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* Copyright (c) 2018-2019 CERN (home.cern)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <stdint.h>
......@@ -36,7 +26,6 @@ static void help(void)
exit(1);
}
static void print_logging (struct wrtd_dev *wrtd, int n_read)
{
char log_entry[WRTD_LOG_ENTRY_SIZE];
......
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