Commit b295efd5 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski Committed by Federico Vaga

wrtd: removed WR locking from userspace library

now the synchronization is done by the RT. TDC and FD driver
submodules can be removed now, useless now.
parent b1e8b088
...@@ -4,9 +4,3 @@ ...@@ -4,9 +4,3 @@
[submodule "fmc-bus"] [submodule "fmc-bus"]
path = fmc-bus path = fmc-bus
url = git@ohwr.org:fmc-projects/fmc-bus.git url = git@ohwr.org:fmc-projects/fmc-bus.git
[submodule "applications/wrtd/fmc-tdc-sw"]
path = applications/wrtd/fmc-tdc-sw
url = git@ohwr.org:fmc-projects/fmc-tdc/fmc-tdc-sw.git
[submodule "applications/wrtd/fine-delay-sw"]
path = applications/wrtd/fine-delay-sw
url = git@ohwr.org:fmc-projects/fmc-delay-1ns-8cha/fine-delay-sw.git
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.PHONY: all clean modules install modules_install clean_all .PHONY: all clean modules install modules_install clean_all
.PHONY: gitmodules prereq prereq_install prereq_install_warn prereq_clean .PHONY: gitmodules prereq prereq_install prereq_install_warn prereq_clean
DIRS = fmc-tdc-sw fine-delay-sw lib tools DIRS = lib tools
all clean modules install modules_install: gitmodules all clean modules install modules_install: gitmodules
for d in $(DIRS); do $(MAKE) -C $$d $@ || exit 1; done for d in $(DIRS); do $(MAKE) -C $$d $@ || exit 1; done
fine-delay-sw @ d1af1b1c
Subproject commit d1af1b1c5b337f15ab86c8e145a03ea7bd010a3e
fmc-tdc-sw @ 9d9fc227
Subproject commit 9d9fc227870afdc702a2ce789b40b35cd7128639
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include <libwrnc.h> #include <libwrnc.h>
#include <libwrtd-internal.h> #include <libwrtd-internal.h>
#include <wrtd-serializers.h> #include <wrtd-serializers.h>
#include <fmctdc-lib.h>
#include <fdelay-lib.h>
static const uint32_t application_id[] = { static const uint32_t application_id[] = {
0x115790de, 0x115790de,
...@@ -198,92 +196,6 @@ struct wrnc_dev *wrtd_get_wrnc_dev(struct wrtd_node *dev) ...@@ -198,92 +196,6 @@ struct wrnc_dev *wrtd_get_wrnc_dev(struct wrtd_node *dev)
} }
/**
* It synchronize the mezzanines with the white rabbit network
* TODO- remove this function as soon as the RT application can
* sync the hardware
* @param[in] dev device token
* @return 0 on success, -1 on error and errno is appropiately set
*/
int wrtd_white_rabbit_sync(struct wrtd_node *dev, unsigned long timeout_s)
{
struct wrtd_desc *wrtd = (struct wrtd_desc *)dev;
struct fmctdc_board *tdc;
struct fdelay_board *fd;
unsigned long time_left;
uint32_t dev_id = wrtd->dev_id - WRNC_FMC_OFFSET;
int err, n;
/* Lock TDC to white-rabbit */
n = fmctdc_init();
if (n <= 0)
goto out_tdc;
tdc = fmctdc_open(-1, dev_id + WRTD_TDC_DEV_ID_OFFSET);
if (!tdc)
goto out_tdc_open;
err = fmctdc_wr_mode(tdc, 1);
if (err) {
errno = err;
goto out_tdc_sync;
}
/* wait until TDC is in wr mode */
time_left = timeout_s;
do {
err = fmctdc_check_wr_mode(tdc);
sleep(1);
} while (--time_left > 0 && err != 0 && err != ENOLINK);
if (err) {
errno = err;
goto out_tdc_sync;
}
if (!time_left) {
errno = ETIME;
goto out_tdc_sync;
}
fmctdc_close(tdc);
fmctdc_exit();
/* Lock FD to white-rabbit */
n = fdelay_init();
if (n <= 0)
goto out_fd;
fd = fdelay_open(-1, dev_id + WRTD_FD_DEV_ID_OFFSET);
if (!fd)
goto out_fd_open;
err = fdelay_wr_mode(fd, 1);
if (err) {
errno = err;
goto out_fd_sync;
}
time_left = timeout_s;
do {
err = fdelay_check_wr_mode(fd);
sleep(1);
} while (--time_left > 0 && err != 0 && err != ENOLINK);
if (err) {
errno = err;
goto out_fd_sync;
}
if (!time_left) {
errno = ETIME;
goto out_fd_sync;
}
return 0;
out_tdc_sync:
fmctdc_close(tdc);
out_tdc_open:
fmctdc_exit();
out_tdc:
return -1;
out_fd_sync:
fdelay_close(fd);
out_fd_open:
fdelay_exit();
out_fd:
return -1;
}
/** /**
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
DESTDIR ?= /usr/local DESTDIR ?= /usr/local
LIBTDC ?= ../fmc-tdc-sw/lib
LIBFD ?= ../fine-delay-sw/lib
WRNC ?= ../../../ WRNC ?= ../../../
CFLAGS += -Wall -ggdb -I. -I../include -I$(WRNC)/lib -I$(WRNC)/kernel -I../lib $(EXTRACFLAGS) CFLAGS += -Wall -ggdb -I. -I../include -I$(WRNC)/lib -I$(WRNC)/kernel -I../lib $(EXTRACFLAGS)
LDLIBS += -L$(LIBFD) -lfdelay -L$(LIBTDC) -lfmctdc -L../lib -lwrtd -L$(WRNC)/lib -lwrnc LDLIBS += -L../lib -lwrtd -L$(WRNC)/lib -lwrnc
PROGS := wrtd-boot PROGS := wrtd-boot
PROGS += wrtd-in-config PROGS += wrtd-in-config
......
...@@ -35,7 +35,6 @@ static void help() ...@@ -35,7 +35,6 @@ static void help()
fprintf(stderr, "-D WRNC device identificator\n"); fprintf(stderr, "-D WRNC device identificator\n");
fprintf(stderr, "-t path to TDC real-time application\n"); fprintf(stderr, "-t path to TDC real-time application\n");
fprintf(stderr, "-f path to Fine-Delay real-time application\n"); fprintf(stderr, "-f path to Fine-Delay real-time application\n");
fprintf(stderr, "-T seconds to wait for White-Rabbit synchronization\n");
exit(1); exit(1);
} }
...@@ -126,12 +125,11 @@ int main(int argc, char *argv[]) ...@@ -126,12 +125,11 @@ int main(int argc, char *argv[])
char *tdc = NULL, *fd =NULL, c; char *tdc = NULL, *fd =NULL, c;
struct wrtd_node *wrtd; struct wrtd_node *wrtd;
struct wrnc_dev *wrnc; struct wrnc_dev *wrnc;
unsigned long timeout = 180;
int32_t offset; int32_t offset;
atexit(wrtd_exit); atexit(wrtd_exit);
while ((c = getopt (argc, argv, "hD:t:f:T:")) != -1) { while ((c = getopt (argc, argv, "hD:t:f:")) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
case '?': case '?':
...@@ -146,9 +144,6 @@ int main(int argc, char *argv[]) ...@@ -146,9 +144,6 @@ int main(int argc, char *argv[])
case 'f': case 'f':
fd = optarg; fd = optarg;
break; break;
case 'T':
sscanf(optarg, "%lu", &timeout);
break;
} }
} }
...@@ -175,15 +170,6 @@ int main(int argc, char *argv[]) ...@@ -175,15 +170,6 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
/* Synchronize TDC and FD mezzanines */
fprintf(stdout, "Synchronizing TDC and FD to White-Rabbit\n");
err = wrtd_white_rabbit_sync(wrtd, timeout);
if (err) {
fprintf(stderr, "Cannot synchronize mezzanines: %s\n",
wrtd_strerror(errno));
exit(1);
}
/* Load the application into the WRNC CPUs */ /* Load the application into the WRNC CPUs */
fprintf(stdout, "Programming on TDC: %s\n", tdc); fprintf(stdout, "Programming on TDC: %s\n", tdc);
fprintf(stdout, "Programming on FD: %s\n", fd); fprintf(stdout, "Programming on FD: %s\n", fd);
......
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