Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Trigger Distribution
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Trigger Distribution
Commits
a9d7899e
Commit
a9d7899e
authored
Jan 25, 2019
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: remove deprecated lib-old
parent
407f25d7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
0 additions
and
3144 deletions
+0
-3144
.gitignore
software/lib-old/.gitignore
+0
-3
Makefile
software/lib-old/Makefile
+0
-49
libwrtd-common.c
software/lib-old/libwrtd-common.c
+0
-298
libwrtd-input.c
software/lib-old/libwrtd-input.c
+0
-767
libwrtd-internal.c
software/lib-old/libwrtd-internal.c
+0
-102
libwrtd-internal.h
software/lib-old/libwrtd-internal.h
+0
-50
libwrtd-logging.c
software/lib-old/libwrtd-logging.c
+0
-296
libwrtd-output.c
software/lib-old/libwrtd-output.c
+0
-1164
libwrtd.h
software/lib-old/libwrtd.h
+0
-331
readme.md
software/lib-old/readme.md
+0
-84
No files found.
software/lib-old/.gitignore
deleted
100644 → 0
View file @
407f25d7
*.a
*.so
.depend
software/lib-old/Makefile
deleted
100644 → 0
View file @
407f25d7
# If it exists includes Makefile.specific. In this Makefile, you should put
# specific Makefile code that you want to run before this. For example,
# build a particular environment.
-include
Makefile.specific
# include parent_common.mk for buildsystem's defines
# It allows you to inherit an environment configuration from larger project
REPO_PARENT
?=
..
-include
$(REPO_PARENT)/parent_common.mk
TRTL
?=
../../dependencies/mock-turtle/software
LIBTDC
?=
../../fmc-tdc-sw/lib
LIBFD
?=
../../fine-delay-sw/lib
LIBS
=
libwrtd.so
LIB
=
libwrtd.a
LOBJ
:=
libwrtd-internal.o
LOBJ
+=
libwrtd-common.o
LOBJ
+=
libwrtd-logging.o
LOBJ
+=
libwrtd-input.o
LOBJ
+=
libwrtd-output.o
CFLAGS
+=
-Wall
-ggdb
-O2
-fPIC
-I
.
-I
../include
-I
$(TRTL)
/include
-I
$(TRTL)
/lib
-I
$(LIBFD)
-I
$(LIBTDC)
-I
$(LIBFD)
/../kernel
CFLAGS
+=
-Werror
CFLAGS
+=
$(EXTRACFLAGS)
LDLIBS
+=
-L
.
-lwrtd
ARFLAGS
=
rc
modules all
:
$(LIB) $(LIBS)
%
:
%.c $(LIB)
$(CC)
$(CFLAGS)
$(LDFLAGS)
$*
.c
$(LDLIBS)
-o
$@
$(LIB)
:
$(LOBJ)
$(AR)
$(ARFLAGS)
$@
$^
$(LIBS)
:
$(LIB)
$(CC)
-shared
-o
$@
-Wl
,--whole-archive,-soname,
$@
$^
-Wl
,--no-whole-archive
clean
:
rm
-f
$(LIB)
.depend
*
.o
*
~
.depend
:
Makefile $(wildcard *.c *.h)
$(CC)
$(CFLAGS)
-M
$
(
LOBJ:.o
=
.c
)
-o
$@
install modules_install
:
-include
.depend
software/lib-old/libwrtd-common.c
deleted
100644 → 0
View file @
407f25d7
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* inspired by a draft of 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.
*
* 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/>.
*/
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <libmockturtle.h>
#include <libwrtd-internal.h>
static
const
char
*
const
wrtd_errors
[]
=
{
"Received an invalid answer from white-rabbit-node-code CPU"
,
"Cannot read channel/trigger state"
,
"You are using an invalid binary"
,
"Invalid dead time value"
,
"Invalid delay value"
,
"Invalid trigger identifier"
,
"Invalid channel number"
,
"Function not yet implemented"
,
"Received an invalid trigger entry"
,
"Received an invalid hash entry"
,
"Received an invalid hash chain"
,
"Received an invalid trigger handle"
,
"Trigger not found"
,
"No trigger condition"
,
"Invalid pulse width"
,
"Invalid input real-time application version"
,
"Invalid output real-time application version"
};
/**
* It returns a string messages corresponding to a given error code. If
* it is not a libwrtd error code, it will run trtl_strerror()
* @param[in] err error code
* @return a message error
*/
const
char
*
wrtd_strerror
(
int
err
)
{
if
(
err
<
EWRTD_INVALID_ANSWER_ACK
||
err
>=
__EWRTD_MAX_ERROR_NUMBER
)
return
trtl_strerror
(
err
);
return
wrtd_errors
[
err
-
EWRTD_INVALID_ANSWER_ACK
];
}
/**
* It initializes the WRTD library. It must be called before doing
* anything else. If you are going to load/unload WRTD devices, then
* you have to un-load (wrtd_exit()) e reload (wrtd_init()) the library.
*
* This library is based on the libmockturtle, so internally, this function also
* run trtl_init() in order to initialize the WRNC library.
* @return 0 on success, otherwise -1 and errno is appropriately set
*/
int
wrtd_init
(
void
)
{
int
err
;
err
=
trtl_init
();
if
(
err
)
return
err
;
return
0
;
}
/**
* It releases the resources allocated by wrtd_init(). It must be called when
* you stop to use this library. Then, you cannot use functions from this
* library.
*/
void
wrtd_exit
(
void
)
{
trtl_exit
();
}
static
int
__wrtd_load
(
struct
wrtd_desc
*
wrtd
,
char
*
fw
,
unsigned
int
cpu
,
uint16_t
id
)
{
struct
trtl_fw_version
version
;
int
err
;
err
=
trtl_cpu_load_application_file
(
wrtd
->
trtl
,
cpu
,
fw
);
if
(
err
)
return
err
;
err
=
trtl_cpu_enable
(
wrtd
->
trtl
,
cpu
);
if
(
err
)
return
err
;
/* Do a ping, but wait for 5sec for the FW to be ready. */
err
=
trtl_fw_ping_timeout
(
wrtd
->
trtl
,
cpu
,
0
,
5000
);
if
(
err
)
return
err
;
err
=
trtl_fw_version
(
wrtd
->
trtl
,
cpu
,
0
,
&
version
);
if
(
err
)
return
err
;
if
(
version
.
rt_id
!=
id
)
{
errno
=
EWRTD_INVALID_IN_APP
;
return
-
1
;
}
return
0
;
}
/**
* It loads the input firmare (TDC)
* @param[in] dev device token
* @param[in] fw path to firmware
* @return 0 on success, otherwise -1 and errno is appropriately set
*/
int
wrtd_in_load
(
struct
wrtd_node
*
dev
,
char
*
fw
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
return
__wrtd_load
(
wrtd
,
fw
,
WRTD_CPU_TDC
,
WRTD_IN_RT_ID
);
}
/**
* It loads the output firmare (FD)
* @param[in] dev device token
* @param[in] fw path to firmware
* @return 0 on success, otherwise -1 and errno is appropriately set
*/
int
wrtd_out_load
(
struct
wrtd_node
*
dev
,
char
*
fw
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
return
__wrtd_load
(
wrtd
,
fw
,
WRTD_CPU_FD
,
WRTD_OUT_RT_ID
);
}
/**
* It opens and initialize the configuration for the given device
* @param[in] device_id device identifier
* @return It returns an anonymous wrtd_node structure on success.
* On error, NULL is returned, and errno is set appropriately.
*/
struct
wrtd_node
*
wrtd_open
(
uint32_t
device_id
)
{
struct
wrtd_desc
*
wrtd
;
wrtd
=
malloc
(
sizeof
(
struct
wrtd_desc
));
if
(
!
wrtd
)
return
NULL
;
wrtd
->
trtl
=
trtl_open_by_id
(
device_id
);
if
(
!
wrtd
->
trtl
)
goto
out
;
wrtd
->
dev_id
=
device_id
;
return
(
struct
wrtd_node
*
)
wrtd
;
out:
free
(
wrtd
);
return
NULL
;
}
/**
* It closes a WRTD device opened with one of the following function:
* wrtd_open_by_lun(), wrtd_open_by_fmc()
* @param[in] dev device token
*/
void
wrtd_close
(
struct
wrtd_node
*
dev
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
trtl_close
(
wrtd
->
trtl
);
free
(
wrtd
);
dev
=
NULL
;
}
/**
* It returns the WRNC token in order to allows users to run
* functions from the WRNC library
* @param[in] dev device token
* @return the WRNC token
*/
struct
trtl_dev
*
wrtd_get_trtl_dev
(
struct
wrtd_node
*
dev
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
return
(
struct
trtl_dev
*
)
wrtd
->
trtl
;
}
/**
* It converts the white rabbit time stamp to a pico seconds
* @param[in] ts time-stamp
* @param[out] pico pico-seconds
*/
void
wrtd_ts_to_pico
(
struct
wr_timestamp
*
ts
,
uint64_t
*
pico
)
{
uint64_t
p
;
p
=
ts
->
frac
*
8000
/
4096
;
p
+=
(
uint64_t
)
ts
->
ticks
*
8000LL
;
p
+=
ts
->
seconds
*
(
1000ULL
*
1000ULL
*
1000ULL
*
1000ULL
);
*
pico
=
p
;
}
/**
* It converts a pico seconds integer into a white rabbit time stamp
* @param[in] pico pico-seconds
* @param[out] ts time-stamp
*/
void
wrtd_pico_to_ts
(
uint64_t
*
pico
,
struct
wr_timestamp
*
ts
)
{
uint64_t
p
=
*
pico
;
ts
->
seconds
=
p
/
(
1000ULL
*
1000ULL
*
1000ULL
*
1000ULL
);
p
%=
(
1000ULL
*
1000ULL
*
1000ULL
*
1000ULL
);
ts
->
ticks
=
p
/
8000
;
p
%=
8000
;
ts
->
frac
=
p
*
4096
/
8000
;
}
/**
* It converts a white rabbit time stamp to seconds and pico-seconds
* @param[in] ts time-stamp
* @param[out] sec seconds
* @param[out] pico pico-seconds
*/
void
wrtd_ts_to_sec_pico
(
struct
wr_timestamp
*
ts
,
uint64_t
*
sec
,
uint64_t
*
pico
)
{
*
sec
=
ts
->
seconds
;
*
pico
=
ts
->
frac
*
8000
/
4096
;
*
pico
+=
(
uint64_t
)
ts
->
ticks
*
8000LL
;
}
/**
* It converts a white rabbit time stamp to seconds and pico-seconds
* @param[in] sec seconds
* @param[in] pico pico-seconds
* @param[out] ts time-stamp
*/
void
wrtd_sec_pico_to_ts
(
uint64_t
sec
,
uint64_t
pico
,
struct
wr_timestamp
*
ts
)
{
ts
->
seconds
=
sec
;
ts
->
ticks
=
pico
/
8000
;
ts
->
frac
=
(
pico
%
8000
)
*
4096
/
8000
;
}
/**
* Substract two timestamp. Returns -1 if the result would be negative.
* @param[in] l left operand
* @param[in] r right operand
* @param[out] res result
*/
int
wrtd_ts_sub
(
struct
wr_timestamp
*
res
,
struct
wr_timestamp
*
l
,
struct
wr_timestamp
*
r
)
{
int
carry
;
uint32_t
rticks
;
uint64_t
rsecs
;
carry
=
(
l
->
frac
<
r
->
frac
);
res
->
frac
=
(
carry
?
4096
:
0
)
+
l
->
frac
-
r
->
frac
;
rticks
=
r
->
ticks
+
(
carry
?
1
:
0
);
carry
=
l
->
ticks
<
rticks
;
res
->
ticks
=
(
carry
?
125000000
:
0
)
+
l
->
ticks
-
rticks
;
rsecs
=
r
->
seconds
+
(
carry
?
1
:
0
);
if
(
l
->
seconds
<
rsecs
)
return
-
1
;
res
->
seconds
=
l
->
seconds
-
rsecs
;
return
0
;
}
software/lib-old/libwrtd-input.c
deleted
100644 → 0
View file @
407f25d7
This diff is collapsed.
Click to expand it.
software/lib-old/libwrtd-internal.c
deleted
100644 → 0
View file @
407f25d7
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* inspired by a draft of 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.
*
* 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/>.
*/
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <libmockturtle.h>
#include "libwrtd-internal.h"
/**
* It validates the answer of a synchronous message
* @param[in] msg message to validate
* @return 0 if it is valid, -1 otherwise and errno is appropriately set
*/
int
wrtd_validate_acknowledge
(
struct
trtl_msg
*
msg
)
{
if
(
msg
->
hdr
.
len
!=
2
||
msg
->
data
[
0
]
!=
WRTD_REP_ACK_ID
)
{
errno
=
EWRTD_INVALID_ANSWER_ACK
;
return
-
1
;
}
return
0
;
}
/**
* It extracts a wr_timestamp from a given buffer (arriving from a real-time
* application)
* @param[in] buf answer of the real time application
* @param[in] offset offset of the timestamp inside the answer buffer
* @param[out] ts where write the wr_timestamp
*/
void
unbag_ts
(
uint32_t
*
buf
,
int
offset
,
struct
wr_timestamp
*
ts
)
{
ts
->
seconds
=
buf
[
offset
];
ts
->
ticks
=
buf
[
offset
+
1
];
ts
->
frac
=
buf
[
offset
+
2
];
}
/**
* It compares two triggers id. The output is the same of memcmp(2)
* @param[in] id1 first id to compare
* @param[in] id2 second id to compare
* @return like memcmp(2)
*/
int
wrtd_trig_id_cmp
(
struct
wrtd_trig_id
*
id1
,
struct
wrtd_trig_id
*
id2
)
{
return
memcmp
(
id1
,
id2
,
sizeof
(
struct
wrtd_trig_id
));
}
/*
* Internal helper to send and receive synchronous messages to/from the WRNC
*/
int
wrtd_send_and_receive_sync
(
struct
wrtd_desc
*
wrtd
,
struct
trtl_msg
*
msg
,
int
cpu
)
{
int
err
;
err
=
trtl_msg_sync
(
wrtd
->
trtl
,
cpu
,
0
,
msg
,
msg
,
WRTD_DEFAULT_TIMEOUT
);
return
err
<
0
?
err
:
0
;
/* ignore timeout */
}
/**
* It performs a simple request to a given core which will only answer
* with an ACK
*/
int
wrtd_trivial_request
(
struct
wrtd_node
*
dev
,
struct
trtl_msg
*
request_msg
,
int
cpu
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
int
err
;
err
=
wrtd_send_and_receive_sync
(
wrtd
,
request_msg
,
cpu
);
if
(
err
)
return
err
;
return
wrtd_validate_acknowledge
(
request_msg
);
}
software/lib-old/libwrtd-internal.h
deleted
100644 → 0
View file @
407f25d7
/*
* Copyright (C) 2014 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* License: GPL v3
*/
#ifndef __LIBWRTD_INTERNAL__H__
#define __LIBWRTD_INTERNAL__H__
#include <stdlib.h>
#include <errno.h>
#include <libwrtd.h>
/* FIXME
* Statically defined but we must find a dynamic way to determinate
* these offsets
*/
#define WRTD_TDC_DEV_ID_OFFSET 0
#define WRTD_FD_DEV_ID_OFFSET 1
/**
* Description of a White-Rabbit Trigger-Distribution device
*/
struct
wrtd_desc
{
struct
trtl_dev
*
trtl
;
/**< WRNC device associated */
uint32_t
dev_id
;
/**< fmc device id */
uint32_t
app_id
;
/**< Application id */
uint32_t
n_cpu
;
/**< Number of CPUs */
};
#define WRTD_OUT_CHANNEL_PUBLIC_SIZE (sizeof(struct wrtd_out_channel) \
- sizeof(struct wrtd_out_channel_private))
/**
* @file libwrtd-interal.c
*/
void
unbag_ts
(
uint32_t
*
buf
,
int
offset
,
struct
wr_timestamp
*
ts
);
int
wrtd_validate_acknowledge
(
struct
trtl_msg
*
msg
);
int
wrtd_trig_id_cmp
(
struct
wrtd_trig_id
*
id1
,
struct
wrtd_trig_id
*
id2
);
extern
int
wrtd_trivial_request
(
struct
wrtd_node
*
dev
,
struct
trtl_msg
*
request_msg
,
int
cpu
);
extern
int
wrtd_send_and_receive_sync
(
struct
wrtd_desc
*
wrtd
,
struct
trtl_msg
*
msg
,
int
cpu
);
#endif
software/lib-old/libwrtd-logging.c
deleted
100644 → 0
View file @
407f25d7
/*
* Copyright (C) 2015-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@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.
*
* 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/>.
*/
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <poll.h>
#include <libmockturtle.h>
#include <libwrtd-internal.h>
/**
* It returns a human readable string that describe a given log level
* @param[in] lvl log level
* @return a string if the log level is mapped, otherwise an empty string
*/
const
char
*
wrtd_strlogging
(
enum
wrtd_log_level
lvl
)
{
switch
(
lvl
&
WRTD_LOG_LEVEL_MASK
)
{
case
WRTD_LOG_NOTHING
:
return
"off"
;
case
WRTD_LOG_RAW
:
return
"raw"
;
case
WRTD_LOG_SENT
:
return
"sent"
;
case
WRTD_LOG_PROMISC
:
return
"promiscuous"
;
case
WRTD_LOG_FILTERED
:
return
"filtered"
;
case
WRTD_LOG_EXECUTED
:
return
"executed"
;
case
WRTD_LOG_MISSED
:
return
"missed"
;
case
WRTD_LOG_ALL
:
return
"all"
;
}
return
"n/a"
;
}
/**
* It returns the full string describing the log_level in use
* @param[out] buf where write the string
* @param[in] log_level the log level to describe
*/
void
wrtd_strlogging_full
(
char
*
buf
,
uint32_t
log_level
)
{
enum
wrtd_log_level
lvl
;
if
(
!
log_level
)
{
/* No log level */
strcpy
(
buf
,
wrtd_strlogging
(
log_level
));
return
;
}
strcpy
(
buf
,
""
);
for
(
lvl
=
0x1
;
lvl
<=
WRTD_LOG_MISSED
;
lvl
<<=
1
)
{
if
(
lvl
&
log_level
)
{
strcat
(
buf
,
wrtd_strlogging
(
lvl
));
strcat
(
buf
,
" "
);
}
}
}
/**
* It converts a given logging string into a log_level
* @param[in] log string log level
* @return the correspondent log level enum
*/
enum
wrtd_log_level
wrtd_strlogging_to_level
(
char
*
log
)
{
if
(
!
strcmp
(
log
,
"all"
))
return
WRTD_LOG_ALL
;
if
(
!
strcmp
(
log
,
"promiscuous"
))
return
WRTD_LOG_PROMISC
;
if
(
!
strcmp
(
log
,
"raw"
))
return
WRTD_LOG_RAW
;
if
(
!
strcmp
(
log
,
"executed"
))
return
WRTD_LOG_EXECUTED
;
if
(
!
strcmp
(
log
,
"missed"
))
return
WRTD_LOG_MISSED
;
if
(
!
strcmp
(
log
,
"sent"
))
return
WRTD_LOG_SENT
;
if
(
!
strcmp
(
log
,
"filtered"
))
return
WRTD_LOG_FILTERED
;
return
WRTD_LOG_NOTHING
;
}
/**
* It reads one or more log entry from a given hmq_log. The user of this
* function must check that the hmq_log used correspond to a logging interface
* @param[in] hmq_log logging HMQ.
* @param[out] log log message
* @param[in] count number of messages to read
* @param[in] poll_timeout poll(2) timeout argument. Negative means infinite.
* @return number of read messages on success (check errno if it returns less
* messages than expected), -1 on error and errno is set appropriately
*/
int
wrtd_log_read
(
struct
wrtd_node
*
dev
,
struct
wrtd_log_entry
*
log
,
int
count
,
int
poll_timeout
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
struct
wrtd_log_entry
*
cur
=
log
;
struct
trtl_msg
msg
;
#define __WRTD_POLL_N 2
struct
polltrtl
p
[
__WRTD_POLL_N
];
int
remaining
=
count
;
int
n_read
=
0
,
ret
,
i
;
for
(
i
=
0
;
i
<
__WRTD_POLL_N
;
++
i
)
{
p
[
i
].
trtl
=
wrtd
->
trtl
;
p
[
i
].
idx_hmq
=
0
;
p
[
i
].
events
=
POLLIN
;
}
p
[
0
].
idx_cpu
=
WRTD_CPU_TDC
;
p
[
1
].
idx_cpu
=
WRTD_CPU_FD
;
/* Clean up errno to be able to distinguish between error cases and
normal behaviour when the function return less messages
than expected */
errno
=
0
;
while
(
remaining
>
0
)
{
ret
=
trtl_msg_poll
(
p
,
2
,
poll_timeout
);
if
(
ret
<=
0
)
break
;
for
(
i
=
0
;
i
<
__WRTD_POLL_N
;
++
i
)
{
if
(
!
(
p
[
i
].
revents
&
POLLIN
))
continue
;
ret
=
trtl_msg_async_recv
(
p
[
i
].
trtl
,
p
[
i
].
idx_cpu
,
p
[
i
].
idx_hmq
,
&
msg
,
1
);
if
(
ret
<=
0
)
break
;
memcpy
(
cur
,
msg
.
data
,
sizeof
(
struct
wrtd_log_entry
));
cur
->
type
|=
(
p
[
i
].
idx_cpu
<<
WRTD_LOG_CPU_SHIFT
);
remaining
--
;
n_read
++
;
cur
++
;
}
}
#undef __WRTD_POLL_N
return
(
n_read
>
0
||
errno
==
0
?
n_read
:
-
1
);
}
/**
* @param[in] dev device token
* @param[in] channel 0-based channel index
* @param[in] log_level log level to apply to the logging messages
* @return 0 on success, -1 on error and errno is set appropriately
*/
static
int
wrtd_log_level_set
(
struct
wrtd_node
*
dev
,
unsigned
int
channel
,
uint32_t
log_level
,
int
core
)
{
struct
wrtd_desc
*
wrtd
=
(
struct
wrtd_desc
*
)
dev
;
struct
trtl_tlv
tlv
;
struct
wrtd_out_channel
ochan
;
struct
wrtd_in_channel
ichan
;
int
err
;
switch
(
core
)
{
case
WRTD_CPU_FD
:
if
(
channel
>=
FD_NUM_CHANNELS
)
{
errno
=
EWRTD_INVALID_CHANNEL
;
return
-
1
;
}
tlv
.
type
=
OUT_STRUCT_CHAN_0
+
channel
;
tlv
.
size
=
WRTD_OUT_CHANNEL_PUBLIC_SIZE
;
tlv
.
buf
=
&
ochan
;
break
;
case
WRTD_CPU_TDC
:
if
(
channel
>=
TDC_NUM_CHANNELS
)
{
errno
=
EWRTD_INVALID_CHANNEL
;
return
-
1
;
}
tlv
.
type
=
IN_STRUCT_CHAN_0
+
channel
;
tlv
.
size
=
sizeof
(
struct
wrtd_in_channel
);
tlv
.
buf
=
&
ichan
;
break
;
default:
abort
();
}
err
=
trtl_fw_buffer_get
(
wrtd
->
trtl
,
core
,
0
,
&
tlv
,
1
);
if
(
err
)
return
err
;
switch
(
core
)
{
case
WRTD_CPU_FD
:
ochan
.
config
.
log_level
=
log_level
;
break
;
case
WRTD_CPU_TDC
:
ichan
.
config
.
log_level
=
log_level
;
break
;
default:
abort
();
}
return
trtl_fw_buffer_set
(
wrtd
->
trtl
,
core
,
0
,
&
tlv
,
1
);
}
/**
* It sets the logging level for an output channel
* @param[in] dev device token
* @param[in] output index (0-based) of output channel
* @param[in] log_level log level to apply to the logging messages
* @return 0 on success, -1 on error and errno is set appropriately
*/
int
wrtd_out_log_level_set
(
struct
wrtd_node
*
dev
,
unsigned
int
output
,
uint32_t
log_level
)
{
return
wrtd_log_level_set
(
dev
,
output
,
log_level
,
WRTD_CPU_FD
);
}
/**
* It gets the logging level for an output channel
* @param[in] dev device token
* @param[in] output index (0-based) of output channel
* @param[out] log_level current log level used by the Real-Time application
* @return 0 on success, -1 on error and errno is set appropriately
*/
int
wrtd_out_log_level_get
(
struct
wrtd_node
*
dev
,
unsigned
int
input
,
uint32_t
*
log_level
)
{
struct
wrtd_output_state
state
;
int
err
;
err
=
wrtd_out_state_get
(
dev
,
input
,
&
state
);
if
(
err
)
return
err
;
*
log_level
=
state
.
log_level
;
return
0
;
}
/**
* It sets the logging level for an input channel
* @param[in] dev device token
* @param[in] input index (0-based) of input channel
* @param[in] log_level log level to apply to the logging messages
* @return 0 on success, -1 on error and errno is set appropriately
*/
int
wrtd_in_log_level_set
(
struct
wrtd_node
*
dev
,
unsigned
int
input
,
uint32_t
log_level
)
{
return
wrtd_log_level_set
(
dev
,
input
,
log_level
,
WRTD_CPU_TDC
);
}
/**
* It gets the logging level for an input channel
* @param[in] dev device token
* @param[in] input index (0-based) of input channel
* @param[out] log_level current log level used by the Real-Time application
* @return 0 on success, -1 on error and errno is set appropriately
*/
int
wrtd_in_log_level_get
(
struct
wrtd_node
*
dev
,
unsigned
int
input
,
uint32_t
*
log_level
)
{
struct
wrtd_input_state
state
;
int
err
;
err
=
wrtd_in_state_get
(
dev
,
input
,
&
state
);
if
(
err
)
return
err
;
*
log_level
=
state
.
log_level
;
return
0
;
}
software/lib-old/libwrtd-output.c
deleted
100644 → 0
View file @
407f25d7
This diff is collapsed.
Click to expand it.
software/lib-old/libwrtd.h
deleted
100644 → 0
View file @
407f25d7
This diff is collapsed.
Click to expand it.
software/lib-old/readme.md
deleted
100644 → 0
View file @
407f25d7
Library Overview {#mainpage}
================
This is the
**WRTD**
library documentation. Here you can find all
the information about the
*White-Rabbit Trigger-Distribution*
API and the main
library behavior that you need to be aware of.
If you are reading this from the doxygen documentation, then you can find
the API documentation in the usual Doxygen places. Otherwise, you can get
the API documentation directly from the source code that you can find in
the
*lib*
directory.
In this document we are going to provides you some clues to understand how
to use the library API.
This library is completely base on the
*White-Rabbit Node-Core*
library.
It uses all its features to establish the communication between the
Trigger Distribution Real Time applications. This library hides the knowledge
about the conventions (protocol) used between the Host and the Real Time
applications and it exposes a simple API for the interaction.
While reading any documentation we suggest you to read the dictionary to avoid
misinterpretation.
Overview
========
The White-Rabbit Trigger-Distribution is a system that allow its users to detect
a trigger (pulse), propagate it over the White-Rabbit network and reproduce it
on a remote machine. This library is in charge to ease the configuration of this
system. The system is based on the White-Rabbit Node-Core. There are two cores
running separately two Real Time applications: one to manage the input,
one to manage the output.
+--------------Trigger-Distribution-System-------------+
| RealTime App - - - - - - - - - RealTime App |
-\ | +-------+ ( ) +--------+ | /-
|--------|->| INPUT |--->( WhiteRabbit Network )--->| OUTPUT |--|------->|
-/ PULSE | +-------+ ( ) +--------+ | PULSE \-
| - - - - - - - - - |
+------------------------------------------------------+
Initialization
==============
To be able to use this library the first thing to do is to initialize a library
instance using wrtd_init(); form this point on you are able to use the
library API. Of course, when you finished to use the library you have to
remove this instance using wrtd_exit().
At the beginning, all communication channels are close, so before start to
communicate with the Real Time application you have to open your communication
channel. Then, close it when you have done.
Logging
=======
The WRTD Real Time applications are able to provide some logging information
about the things happening on the FPGA. This interface is read only, so
you can only read logging messages. There are only two configuration parameters:
one for the
*logging level*
; the other one to set the exclusivity access to the
logging interface. When the logging interface is shared, then also other users
are allowed to get the same messages.
Input
=====
The
*input*
Real Time application and the associated part of library manages
the detection of the incoming pulse and their correct propagation over the
white-rabbit network as trigger event.
The library allows the user to fully configure the input parameter and to get
the current status of Real Time application but also to get information about
the triggers associated to the input channels. Go directly to the API for the
list of parameters that you can set.
Output
======
The
*input*
Real Time application and the associated part of library manages
the pluse generation and their correct reception from the white-rabbit
network as trigger event.
The library allows the user to fully configure the output parameter and to get
the current status of Real Time application but also to get information about
the trigger associated to the output channesl. Go directly to the API for the
list of parameters that you can set.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment