summaryrefslogtreecommitdiffstats
path: root/dmascc
diff options
context:
space:
mode:
Diffstat (limited to 'dmascc')
-rw-r--r--dmascc/Makefile399
-rw-r--r--dmascc/README.dmascc63
-rw-r--r--dmascc/dmascc_cfg.c264
3 files changed, 641 insertions, 85 deletions
diff --git a/dmascc/Makefile b/dmascc/Makefile
new file mode 100644
index 0000000..1a062ca
--- /dev/null
+++ b/dmascc/Makefile
@@ -0,0 +1,399 @@
+# Generated automatically from Makefile.in by configure.
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = /bin/sh
+
+srcdir = .
+top_srcdir = ..
+prefix = /usr/local
+exec_prefix = ${prefix}
+
+bindir = ${exec_prefix}/bin
+sbindir = ${exec_prefix}/sbin
+libexecdir = ${exec_prefix}/libexec
+datadir = ${prefix}/share
+sysconfdir = ${prefix}/etc
+sharedstatedir = ${prefix}/com
+localstatedir = ${prefix}/var
+libdir = ${exec_prefix}/lib
+infodir = ${prefix}/info
+mandir = ${prefix}/man
+includedir = ${prefix}/include
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/ax25-tools
+pkglibdir = $(libdir)/ax25-tools
+pkgincludedir = $(includedir)/ax25-tools
+
+top_builddir = ..
+
+ACLOCAL = aclocal
+AUTOCONF = autoconf
+AUTOMAKE = automake
+AUTOHEADER = autoheader
+
+INSTALL = /usr/bin/install -c
+INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_SCRIPT = ${INSTALL_PROGRAM}
+transform = s,x,x,
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+AWK = mawk
+AX25IO_LIB =
+AX25_LIB = -lax25
+CC = gcc
+CXX = c++
+DMASCC =
+FLTK_LIB = -lfltk -lGL -lSM -lICE -lXi -lXext -lX11
+MAKEINFO = /home/csmall/ax25/ax25-tools/missing makeinfo
+NCURSES_LIB = -lncurses
+PACKAGE = ax25-tools
+UTIL_LIB = -lutil
+VERSION = 0.0.8cvs
+Z_LIB = -lz
+
+sbin_PROGRAMS = dmascc_cfg
+
+dmascc_cfg_SOURCE = dmascc_cfg.c
+
+man_MANS = dmascc_cfg.1
+
+EXTRA_DIST = $(man_MANS) $(doc_DATA)
+
+docdir = $(datadir)/doc/ax25-tools
+doc_DATA = README.dmascc
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(sbin_PROGRAMS)
+
+
+DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I..
+CPPFLAGS =
+LDFLAGS =
+LIBS =
+X_CFLAGS = -I/usr/X11R6/include
+X_LIBS = -L/usr/X11R6/lib
+X_EXTRA_LIBS =
+X_PRE_LIBS = -lSM -lICE
+dmascc_cfg_SOURCES = dmascc_cfg.c
+dmascc_cfg_OBJECTS = dmascc_cfg.o
+dmascc_cfg_LDADD = $(LDADD)
+dmascc_cfg_DEPENDENCIES =
+dmascc_cfg_LDFLAGS =
+CFLAGS = -g -O2 -Wall
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+man1dir = $(mandir)/man1
+MANS = $(man_MANS)
+
+NROFF = nroff
+DATA = $(doc_DATA)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+DEP_FILES = .deps/dmascc_cfg.P
+SOURCES = dmascc_cfg.c
+OBJECTS = dmascc_cfg.o
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu dmascc/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-sbinPROGRAMS:
+
+clean-sbinPROGRAMS:
+ -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+
+distclean-sbinPROGRAMS:
+
+maintainer-clean-sbinPROGRAMS:
+
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(sbindir)
+ @list='$(sbin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-sbinPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(sbin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+dmascc_cfg: $(dmascc_cfg_OBJECTS) $(dmascc_cfg_DEPENDENCIES)
+ @rm -f dmascc_cfg
+ $(LINK) $(dmascc_cfg_LDFLAGS) $(dmascc_cfg_OBJECTS) $(dmascc_cfg_LDADD) $(LIBS)
+
+install-man1:
+ $(mkinstalldirs) $(DESTDIR)$(man1dir)
+ @list='$(man1_MANS)'; \
+ l2='$(man_MANS)'; for i in $$l2; do \
+ case "$$i" in \
+ *.1*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
+ done
+
+uninstall-man1:
+ @list='$(man1_MANS)'; \
+ l2='$(man_MANS)'; for i in $$l2; do \
+ case "$$i" in \
+ *.1*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
+ rm -f $(DESTDIR)$(man1dir)/$$inst; \
+ done
+install-man: $(MANS)
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-man1
+uninstall-man:
+ @$(NORMAL_UNINSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) uninstall-man1
+
+install-docDATA: $(doc_DATA)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(docdir)
+ @list='$(doc_DATA)'; for p in $$list; do \
+ if test -f $(srcdir)/$$p; then \
+ echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p"; \
+ $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p; \
+ else if test -f $$p; then \
+ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p"; \
+ $(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p; \
+ fi; fi; \
+ done
+
+uninstall-docDATA:
+ @$(NORMAL_UNINSTALL)
+ list='$(doc_DATA)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(docdir)/$$p; \
+ done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = dmascc
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu dmascc/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-sbinPROGRAMS
+install-exec: install-exec-am
+
+install-data-am: install-man install-docDATA
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-sbinPROGRAMS uninstall-man uninstall-docDATA
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS) $(MANS) $(DATA)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man1 \
+ $(DESTDIR)$(docdir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-sbinPROGRAMS mostlyclean-compile \
+ mostlyclean-tags mostlyclean-depend mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-sbinPROGRAMS clean-compile clean-tags clean-depend \
+ clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-sbinPROGRAMS distclean-compile distclean-tags \
+ distclean-depend distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-sbinPROGRAMS \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-depend maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
+clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
+install-sbinPROGRAMS mostlyclean-compile distclean-compile \
+clean-compile maintainer-clean-compile install-man1 uninstall-man1 \
+install-man uninstall-man uninstall-docDATA install-docDATA tags \
+mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
+distdir mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+installconf:
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/dmascc/README.dmascc b/dmascc/README.dmascc
index fcd7746..1945616 100644
--- a/dmascc/README.dmascc
+++ b/dmascc/README.dmascc
@@ -1,3 +1,5 @@
+$Id: README.dmascc,v 1.2 2001/05/10 10:44:45 csmall Exp $
+
The dmascc_cfg utility
======================
@@ -14,18 +16,19 @@ Options:
--show Show all configurable parameters for this port.
May be specified at any time by any user.
-All other options change parameters and thus may only be specified
- - by root
- - when the interface is down
+All other options change parameters and thus may only be specified by root
+and only when the interface is down.
+
+f ... floating-point argument, i ... integer argument.
---speed <f> Set frequency of baud rate generator. A value of 0 disables
+--frequency f Set frequency of baud rate generator. A value of 0 disables
the baud rate generator and the digital PLL. Use the
--show option to check whether the frequency you selected
could be approximated with sufficient accuracy.
--nrzi 0 | 1 0 selects NRZ mode, 1 selects NRZI mode.
---clocks <i> Set clock mode. You may OR together three choices (other
+--clocks i Set clock mode. You may OR together three choices (other
values are not supported and may cause strange results):
TX clock pin: 0x00 input
@@ -45,25 +48,49 @@ All other options change parameters and thus may only be specified
* Not allowed on PI2 Port A if J3 is installed.
# TX clock pin must be configured as input
- + Speed must be equal to 32 times the baud rate.
+ + The BRG frequency must be equal to 32 times the baud rate.
+
+--txdelay f Set the transmit delay (in ms).
+
+--txpause f Set the delay (in ms) between two transmitted packets.
+ This parameter sometimes helps to reduce RX FIFO overruns,
+ if the receiving station has a slower CPU than the
+ transmitting station and cannot re-initialize the SCC's
+ receiver quickly enough.
---txdelay <f> Set transmit delay in ms (0 < f < 2500).
+--txtimeout f Set the time (in ms), after which the transmitter may
+ not squeeze in another packet, but rather has to go
+ off-air.
---txtime <f> Set maximum time in s the transmitter may be active
- (0 < f).
+--txtail f Set the time (in ms) between the end of the last packet
+ and the RTS line actually going inactive.
---sqdelay <f> Set squelch delay in ms (0 < f < 2500).
+--rtsoff f Set the DCD settling time (in ms) after switching off the
+ transmitter. During this period the DCD line is being
+ ignored. This parameter is especially useful for the
+ S5SCC/DMA, which frequently generates short DCD pulses
+ after switching from TX to RX.
---slottime <f> Set slot time in ms (0 < f < 2500).
+--dcdon f Set the DCD settling time (in ms) after the DCD line has
+ become active. This parameter should be < txdelay.
---waittime <f> Set the minimum time in ms between transmitter off and
- transmitter on (0 < f < 2500).
+--dcdoff f Set the DCD settling time (in ms) after the DCD line has
+ become inactive. This parameter should be >= rtsoff.
---persist <i> Set persistence parameter (0 <= i <= 255).
+--slottime f Set the slot time (in ms).
---dma <i> Set DMA channel (0, 1, or 3). 0 disables DMA.
+--persist i Set the persistence parameter (1 <= i <= 256). After the
+ DCD off settling time has expired, the driver waits
+ random(0..255)/persist*slottime before activating the
+ RTS line. Integer arithmetic is being performed;
+ persist==256 thus means zero delay in any case (which only
+ makes sense in a two-station scenario).
-<f> ... floating-point argument, <i> ... integer argument.
-Parameters are not checked for validity. The driver or the kernel may crash
-if you specify invalid values.
+--waittime f Set the minimum time (in ms) before a station may start
+ transmitting again (after the RTS off settling time has
+ expired). This value should be larger than
+ 255/persist*slottime.
+--dma i Set the DMA channel (-1, 0, 1, or 3). -1 disables DMA.
+ 0 is only valid on the S5SCC/DMA. Remember, DMA can be
+ used only on channel A (dmascc0, dmascc2, and so on).
diff --git a/dmascc/dmascc_cfg.c b/dmascc/dmascc_cfg.c
index 4cece3d..47b4ac2 100644
--- a/dmascc/dmascc_cfg.c
+++ b/dmascc/dmascc_cfg.c
@@ -1,8 +1,8 @@
/*
- * $Id: dmascc_cfg.c,v 0.7 1997/12/02 11:31:21 oe1kib Exp $
+ * $Id: dmascc_cfg.c,v 1.2 2001/05/10 10:44:45 csmall Exp $
*
* Configuration utility for dmascc driver
- * Copyright (C) 1997 Klaus Kudielka
+ * Copyright (C) 1997,2000 Klaus Kudielka
*
* 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
@@ -26,36 +26,68 @@
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include <net/if.h>
-#include <linux/dmascc.h>
+#include <linux/if.h>
#include <asm/param.h>
-void usage(char *name)
+/* Ioctls */
+#define SIOCGSCCPARAM SIOCDEVPRIVATE
+#define SIOCSSCCPARAM (SIOCDEVPRIVATE+1)
+
+/* Frequency of timer 0 */
+#define TMR_0_HZ 25600
+
+/* Configurable parameters */
+struct scc_param {
+ int pclk_hz; /* frequency of BRG input (don't change) */
+ int brg_tc; /* BRG terminal count; BRG disabled if < 0 */
+ int nrzi; /* 0 (nrz), 1 (nrzi) */
+ int clocks; /* see dmascc_cfg documentation */
+ int txdelay; /* [1/TMR_0_HZ] */
+ int txtimeout; /* [1/HZ] */
+ int txtail; /* [1/TMR_0_HZ] */
+ int waittime; /* [1/TMR_0_HZ] */
+ int slottime; /* [1/TMR_0_HZ] */
+ int persist; /* 1 ... 256 */
+ int dma; /* -1 (disable), 0, 1, 3 */
+ int txpause; /* [1/TMR_0_HZ] */
+ int rtsoff; /* [1/TMR_0_HZ] */
+ int dcdon; /* [1/TMR_0_HZ] */
+ int dcdoff; /* [1/TMR_0_HZ] */
+ int reserved[35];
+};
+
+void usage(void)
{
fprintf(stderr,
- "usage: %s <interface> [ options ... ]\n\n"
- "options: --show show configuration\n"
- " --speed <f> set baud rate\n"
- " --nrzi 0 | 1 set NRZ or NRZI encoding\n"
- " --clocks <i> set clock mode\n"
- " --txdelay <f> set transmit delay in ms\n"
- " --txtime <f> set maximum transmit time in s\n"
- " --sqdelay <f> set squelch delay in ms\n"
- " --slottime <f> set slot time in ms\n"
- " --waittime <f> set wait time after transmit in ms\n"
- " --persist <i> set persistence parameter\n"
- " --dma <i> set DMA channel\n", name);
+ "usage: dmascc_cfg <interface> [ options ... ]\n\n"
+ "options: --show show updated configuration\n"
+ " --frequency f frequency of baud rate generator in Hz\n"
+ " --nrzi n NRZ (0) or NRZI (1) encoding\n"
+ " --clocks n clock mode (see manual page)\n"
+ " --txdelay t transmit delay in ms\n"
+ " --txpause t inter-packet delay in ms\n"
+ " --txtimeout t stop transmitting packets after t ms\n"
+ " --txtail t transmit tail in ms\n"
+ " --rtsoff t DCD settling time in ms (after RTS off)\n"
+ " --dcdon t DCD settling time in ms (after DCD on)\n"
+ " --dcdoff t DCD settling time in ms (after DCD off)\n"
+ " --slottime t slot time in ms\n"
+ " --persist n persistence parameter (1..256)\n"
+ " --waittime t wait time after transmit in ms\n"
+ " --dma n "
+ "DMA channel: -1 (no DMA), 0 (S5SCC/DMA only), 1, 3\n"
+ );
}
int main(int argc, char *argv[])
{
- int sk, show = 0, set = 0, error = 0;
+ int sk, show = 0, set = 0, old = 0, secondary;
struct ifreq ifr;
struct scc_param param;
- char **option, *end;
+ char **option, *end, *error = NULL;
if (argc < 2) {
- usage(argv[0]);
+ usage();
return 1;
}
@@ -64,6 +96,14 @@ int main(int argc, char *argv[])
return 2;
}
+ memset(&param, 0, sizeof(param));
+ param.txpause = -1;
+
+ if strncmp(argv[1], "dmascc", 6) {
+ fprintf(stderr, "invalid interface name.\n");
+ return 5;
+ }
+
strncpy(ifr.ifr_name, argv[1], IFNAMSIZ);
ifr.ifr_data = (caddr_t) &param;
if (ioctl(sk, SIOCGSCCPARAM, &ifr) < 0) {
@@ -72,91 +112,173 @@ int main(int argc, char *argv[])
return 3;
}
+ if (param.txpause == -1) {
+ param.txpause = 0;
+ old = 1;
+ }
+
+ secondary = argv[1][strlen(argv[1])-1]%2;
+
option = argv + 2;
while (!error && *option != NULL) {
if (!strcmp(*option, "--show")) {
show = 1;
option++;
- } else if (!strcmp(*option, "--speed")) {
+ } else if (!strcmp(*option, "--frequency")) {
option++;
if (*option != NULL) {
- double speed;
+ double f;
set = 1;
- speed = strtod(*option++, &end);
- if (*end) error = 1; else {
- if (speed <= 0.0) param.brg_tc = -1;
- else param.brg_tc = param.pclk_hz / (speed * 2) - 2;
- if (param.brg_tc > 0xffff) param.brg_tc = -1;
+ f = strtod(*option++, &end);
+ if (*end) error = "frequency not a number";
+ else {
+ if (f < 0.0) error = "frequency < 0";
+ else if (f == 0.0) param.brg_tc = -1;
+ else {
+ param.brg_tc = param.pclk_hz / (f * 2) - 2;
+ if (param.brg_tc > 0xffff) error = "frequency too low";
+ if (param.brg_tc < 0) error = "frequency too high";
+ }
}
- } else error = 1;
+ } else error = "--frequency requires parameter";
} else if (!strcmp(*option, "--nrzi")) {
option++;
if (*option != NULL) {
set = 1;
param.nrzi = strtol(*option++, &end, 0);
- if (*end) error = 1;
- } else error = 1;
+ if (*end || param.nrzi < 0 || param.nrzi > 1)
+ error = "nrzi must be 0 or 1";
+ } else error = "--nrzi requires parameter";
} else if (!strcmp(*option, "--clocks")) {
option++;
if (*option != NULL) {
set = 1;
param.clocks = strtol(*option++, &end, 0);
- if (*end) error = 1;
- } else error = 1;
+ if (*end) error = "clock mode not a number";
+ else if ((param.clocks & ~0x7f)) error = "invalid clock mode";
+ } else error = "--clocks requires parameter";
} else if (!strcmp(*option, "--txdelay")) {
option++;
if (*option != NULL) {
set = 1;
param.txdelay = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
- if (*end) error = 1;
- } else error = 1;
- } else if (!strcmp(*option, "--txtime")) {
+ if (*end) error = "txdelay not a number";
+ else if (param.txdelay < 0) error = "txdelay < 0";
+ else if (param.txdelay > 0xffff) error = "txdelay too large";
+ } else error = "--txdelay requires parameter";
+ } else if (!strcmp(*option, "--txpause")) {
option++;
if (*option != NULL) {
set = 1;
- param.txtime = HZ * strtod(*option++, &end);
- if (*end) error = 1;
- } else error = 1;
- } else if (!strcmp(*option, "--sqdelay")) {
+ param.txpause = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "txpause not a number";
+ else if (param.txpause < 0) error = "txpause < 0";
+ else if (param.txpause > 0xffff) error = "txpause too large";
+ if (old && param.txpause != 0)
+ fprintf(stderr, "warning: old driver; txpause not supported.\n");
+ } else error = "--txpause requires parameter";
+ } else if (!strcmp(*option, "--txtimeout")) {
option++;
if (*option != NULL) {
set = 1;
- param.sqdelay = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
- if (*end) error = 1;
- } else error = 1;
- } else if (!strcmp(*option, "--slottime")) {
+ param.txtimeout = HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "txtimeout not a number";
+ else if (param.txtimeout < 0) error = "txtimeout < 0";
+ } else error = "--txtimeout requires parameter";
+ } else if (!strcmp(*option, "--txtail")) {
option++;
if (*option != NULL) {
set = 1;
- param.slottime = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
- if (*end) error = 1;
- } else error = 1;
- } else if (!strcmp(*option, "--waittime")) {
+ param.txtail = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "txtail not a number";
+ else if (param.txtail < 0) error = "txtail < 0";
+ else if (param.txtail > 0xffff) error = "txtail too large";
+ } else error = "--txtail requires parameter";
+ } else if (!strcmp(*option, "--rtsoff")) {
option++;
if (*option != NULL) {
set = 1;
- param.waittime = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
- if (*end) error = 1;
- } else error = 1;
+ param.rtsoff = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "rtsoff not a number";
+ else if (param.rtsoff < 0) error = "rtsoff < 0";
+ else if (param.rtsoff > 0xffff) error = "rtsoff too large";
+ if (old && param.rtsoff != 0)
+ fprintf(stderr, "warning: old driver; rtsoff not supported.\n");
+ } else error = "--rtsoff requires parameter";
+ } else if (!strcmp(*option, "--dcdon")) {
+ option++;
+ if (*option != NULL) {
+ set = 1;
+ param.dcdon = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "dcdon not a number";
+ else if (param.dcdon < 0) error = "dcdon < 0";
+ else if (param.dcdon > 0xffff) error = "dcdon too large";
+ if (old && param.dcdon != 0)
+ fprintf(stderr, "warning: old driver; dcdon not supported.\n");
+ } else error = "--dcdon requires parameter";
+ } else if (!strcmp(*option, "--dcdoff")) {
+ option++;
+ if (*option != NULL) {
+ set = 1;
+ param.dcdoff = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "dcdoff not a number";
+ else if (param.dcdoff < 0) error = "dcdoff < 0";
+ else if (param.dcdoff > 0xffff) error = "dcdoff too large";
+ if (old && param.dcdoff != 0)
+ fprintf(stderr, "warning: old driver; dcdoff not supported.\n");
+ } else error = "--dcdoff requires parameter";
+ } else if (!strcmp(*option, "--slottime")) {
+ option++;
+ if (*option != NULL) {
+ set = 1;
+ param.slottime = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "slottime not a number";
+ else if (param.slottime < 0) error = "slottime < 0";
+ else if (param.slottime > 0xffff) error = "slottime too large";
+ } else error = "--slottime requires parameter";
} else if (!strcmp(*option, "--persist")) {
option++;
if (*option != NULL) {
set = 1;
param.persist = strtol(*option++, &end, 0);
- if (*end) error = 1;
- } else error = 1;
+ if (*end) error = "persist not a number";
+ else if (param.persist < 1) error = "persist < 1";
+ else if (param.persist > 256) error = "persist > 256";
+ } else error = "--persist requires parameter";
+ } else if (!strcmp(*option, "--waittime")) {
+ option++;
+ if (*option != NULL) {
+ set = 1;
+ param.waittime = TMR_0_HZ * strtod(*option++, &end) / 1000.0;
+ if (*end) error = "waittime not a number";
+ else if (param.waittime < 0) error = "waittime < 0";
+ else if (param.waittime > 0xffff) error = "waittime too large";
+ } else error = "--waittime requires parameter";
} else if (!strcmp(*option, "--dma")) {
option++;
if (*option != NULL) {
+ int dma = param.dma;
set = 1;
param.dma = strtol(*option++, &end, 0);
- if (*end) error = 1;
- } else error = 1;
- } else error = 1;
+ if (*end) error = "DMA channel not a number";
+ else if (secondary && param.dma != -1)
+ error = "SCC port B must have DMA disabled";
+ else if (param.dma < -1 || param.dma == 2 || param.dma > 3)
+ error = "invalid DMA channel";
+ else if (param.pclk_hz != 9830400 && param.dma == 0)
+ error = "only S5SCC/DMA supports DMA channel 0";
+ else if (old && param.dma == 0)
+ error = "old driver; DMA channel 0 not supported";
+ else if (old && param.dma == -1 && dma > 0)
+ error = "old driver; reload module or reboot to disable DMA";
+ else if (old && param.dma == -1 && dma == 0)
+ param.dma = 0;
+ } else error = "--dma requires parameter";
+ } else error = "invalid option";
}
if (error) {
- usage(argv[0]);
+ fprintf(stderr, "usage error: %s.\n", error);
close(sk);
return 1;
}
@@ -170,20 +292,28 @@ int main(int argc, char *argv[])
}
if (show) {
- double speed;
- if (param.brg_tc < 0) speed = 0.0;
- else speed = ((double) param.pclk_hz) / ( 2 * (param.brg_tc + 2));
- printf("speed = %.2f\nnrzi = %d\nclocks = 0x%02X\n"
- "txdelay = %.2f ms\ntxtime = %.2f s\nsqdelay = %.2f ms\n"
- "slottime = %.2f ms\nwaittime = %.2f ms\npersist = %d\n"
- "dma = %d\n",
- speed, param.nrzi, param.clocks,
+ double f;
+ if (param.brg_tc < 0) f = 0.0;
+ else f = ((double) param.pclk_hz) / ( 2 * (param.brg_tc + 2));
+ printf("dmascc_cfg %s \\\n--frequency %.2f --nrzi %d --clocks 0x%02X "
+ "--txdelay %.2f \\\n--txpause %.2f --txtimeout %.2f "
+ "--txtail %.2f --rtsoff %.2f \\\n--dcdon %.2f --dcdoff %.2f "
+ "--slottime %.2f --persist %d \\\n--waittime %.2f --dma %d\n",
+ argv[1],
+ f,
+ param.nrzi,
+ param.clocks,
param.txdelay * 1000.0 / TMR_0_HZ,
- (double) param.txtime / HZ,
- param.sqdelay * 1000.0 / TMR_0_HZ,
+ param.txpause * 1000.0 / TMR_0_HZ,
+ param.txtimeout * 1000.0 / HZ,
+ param.txtail * 1000.0 / TMR_0_HZ,
+ param.rtsoff * 1000.0 / TMR_0_HZ,
+ param.dcdon * 1000.0 / TMR_0_HZ,
+ param.dcdoff * 1000.0 / TMR_0_HZ,
param.slottime * 1000.0 / TMR_0_HZ,
+ param.persist,
param.waittime * 1000.0 / TMR_0_HZ,
- param.persist, param.dma);
+ (old && param.dma == 0) ? -1 : param.dma);
}
close(sk);