Commit 6b40ded5 authored by Alessandro Rubini's avatar Alessandro Rubini

oldtools: recover files removed from lib/ by last commits

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 84750ca9
......@@ -638,14 +638,17 @@ programs should not refer to.
@item The @i{tools} directory hosts the suggested command-line tools
to use the device for testing and quick access. They demonstrate use
of the library functions.
of the library functions using internally-consistent command line
conventions. All command names begin with @t{fmc-fdelay-}
@item The @i{oldtools} directory includes tools that access @sc{zio}
directly; they are not built by default any more because they are now
deprecated; we also removed documentation for them, for the same
reason. We keep them for our previous users, in case they still want
to run previous scripts the saved in the past. The old tools use
an @code{fd-raw-} name pattern.
to run previous scripts the saved in the past. The directory
also includes tools that used to be built withing @t{lib/} and
are deprecated as well. The old tools use
the name patterns @code{fd-raw-} and @code{fdelay-}
@item The @i{lib} directory contains the userspace library, providing a
simple C API to access the driver.
......
......@@ -4,3 +4,5 @@ fd-raw-gettime
fd-raw-settime
fd-raw-output
fd-raw-perf
fdelay-list
fdelay-term
\ No newline at end of file
......@@ -2,7 +2,7 @@
M = $(shell /bin/pwd)/../kernel
HOST_EXTRACFLAGS += -I$(M) -I../zio/include -Wno-trigraphs -Wall -ggdb
HOST_EXTRACFLAGS += -I$(M) -I../lib -I../zio/include -Wno-trigraphs -Wall -ggdb
HOSTCC ?= gcc
......@@ -13,6 +13,11 @@ hostprogs-y += parport-burst
hostprogs-y += fd-raw-output
hostprogs-y += fd-raw-perf
# programs that used to live in lib/
hostprogs-y += fdelay-list
hostprogs-y += fdelay-term
# we are not in the kernel, so we need to piggy-back on "make modules"
all modules: $(hostprogs-y)
......@@ -24,4 +29,4 @@ modules_install install:
# we need this as we are out of the kernel
%: %.c
$(HOSTCC) $(HOST_EXTRACFLAGS) -O2 -Wall $^ -o $@
$(HOSTCC) $(HOST_EXTRACFLAGS) -O2 -Wall $^ -L../lib -lfdelay -o $@
/* Silly thing that lists installed fine-delay boards */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define FDELAY_INTERNAL /* hack... */
#include "fdelay-lib.h"
int main(int argc, char **argv)
{
int i, j;
struct __fdelay_board *b;
struct fdelay_board *ub;
i = fdelay_init();
if (i < 0) {
fprintf(stderr, "%s: fdelay_init(): %s\n", argv[0],
strerror(errno));
exit(1);
}
printf("%s: found %i boards\n", argv[0], i);
for (j = 0; j < i; j++) {
ub = fdelay_open(j, -1);
b = (typeof(b))ub;
printf(" dev_id %04x, %s, %s\n", b->dev_id, b->devbase,
b->sysbase);
}
fdelay_exit();
return 0;
}
/* Simple demo that acts on the termination of the first board */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "fdelay-lib.h"
int main(int argc, char **argv)
{
struct fdelay_board *b;
int i, hwval, newval;
int dev = 0;
if (argc < 2) {
fprintf(stderr, "%s: Use %s <dev> 1|0\n", argv[0], argv[0]);
exit(1);
}
newval = -1;
if (argc > 2) {
dev = strtol(argv[1], NULL, 0);
if (!strcmp(argv[2], "0"))
newval = 0;
else if (!strcmp(argv[2], "1"))
newval = 1;
else {
fprintf(stderr, "%s: arg \"%s\" is not 0 nor 1\n",
argv[0], argv[2]);
exit(1);
}
}
i = fdelay_init();
if (i < 0) {
fprintf(stderr, "%s: fdelay_init(): %s\n", argv[0],
strerror(errno));
exit(1);
}
if (i == 0) {
fprintf(stderr, "%s: no boards found\n", argv[0]);
exit(1);
}
if (i != 1) {
fprintf(stderr, "%s: found %i boards\n",
argv[0], i);
}
b = fdelay_open(dev, -1);
if (!b) {
fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0],
strerror(errno));
exit(1);
}
fprintf(stderr, "%s: using board %d\n", argv[0], dev);
hwval = fdelay_get_config_tdc(b);
switch(newval) {
case 1:
hwval |= FD_TDCF_TERM_50;
break;
case 0:
hwval &= ~FD_TDCF_TERM_50;
break;
}
fdelay_set_config_tdc(b, hwval);
hwval = fdelay_get_config_tdc(b);
printf("%s: termination is %d %s\n", argv[0], hwval,
hwval & FD_TDCF_TERM_50 ? "on" : "off");
fdelay_close(b);
fdelay_exit();
return 0;
}
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