Compare commits
16 Commits
v2.9.0
...
v2.9.2-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1d55683ae | ||
|
|
9285e86492 | ||
|
|
ca7c04e9cb | ||
|
|
ae02edacb4 | ||
|
|
2abfd165ae | ||
|
|
1e6b2741db | ||
|
|
794c8eb048 | ||
|
|
ffe36c63e0 | ||
|
|
f2628eeedd | ||
|
|
1292ea9078 | ||
|
|
cfee27106b | ||
|
|
066fa2aff3 | ||
|
|
bce5afacf1 | ||
|
|
dd752529f0 | ||
|
|
27d07446ef | ||
|
|
8e2a5def27 |
1
Makefile
1
Makefile
@@ -108,6 +108,7 @@ endif
|
||||
ASSIGNED_DATA_SCRIPTS:=\
|
||||
dahdi_handle_device \
|
||||
dahdi_span_config \
|
||||
dahdi_auto_assign_compat \
|
||||
span_config.d/10-dahdi-cfg \
|
||||
span_config.d/20-fxotune \
|
||||
span_config.d/50-asterisk \
|
||||
|
||||
@@ -148,11 +148,6 @@ xpp_startup() {
|
||||
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
|
||||
|
||||
hotplug_exit_after_load
|
||||
|
||||
# overriding locales for the above two, as perl can be noisy
|
||||
# when locales are missing.
|
||||
# No register all the devices if they didn't auto-register:
|
||||
LC_ALL=C dahdi_registration on
|
||||
}
|
||||
|
||||
|
||||
@@ -263,6 +258,9 @@ case "$1" in
|
||||
|
||||
xpp_startup
|
||||
|
||||
# Assign all spans that weren't handled via udev + /etc/dahdi/assigned-spans.conf
|
||||
/usr/share/dahdi/dahdi_auto_assign_compat
|
||||
|
||||
if [ $system = debian ]; then
|
||||
echo -n "Running dahdi_cfg: "
|
||||
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
|
||||
|
||||
@@ -1672,13 +1672,13 @@ finish:
|
||||
|
||||
lock = sem_open(SEM_NAME, O_CREAT, O_RDWR, 1);
|
||||
if (SEM_FAILED == lock) {
|
||||
error("Unable to create 'dahdi_cfg' mutex.\n");
|
||||
perror("Unable to create 'dahdi_cfg' mutex");
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
|
||||
if (-1 == sem_wait(lock)) {
|
||||
error("Failed to wait for dahdi_cfg mutex.\n");
|
||||
perror("Failed to wait for 'dahdi_cfg' mutex");
|
||||
exit_code = 1;
|
||||
goto unlink_sem;
|
||||
}
|
||||
@@ -1730,7 +1730,7 @@ finish:
|
||||
}
|
||||
|
||||
if (-1 == sem_wait(lock)) {
|
||||
error("Failed to wait for dahdi_cfg mutex after creating dynamic spans.\n");
|
||||
perror("Failed to wait for 'dahdi_cfg' mutex after creating dynamic spans");
|
||||
exit_code = 1;
|
||||
goto unlink_sem;
|
||||
}
|
||||
|
||||
@@ -188,28 +188,57 @@ show_spantypes() {
|
||||
done
|
||||
}
|
||||
|
||||
list_pri_spantypes() {
|
||||
find $DEVICES -follow -maxdepth 1 -name spantype | \
|
||||
xargs cat | \
|
||||
sed -n '/:[ETJ]1$/s/^.*://p' | \
|
||||
sort -u | \
|
||||
tr '\n' ' ' | \
|
||||
sed -e 's/^ *//' -e 's/ *$//'
|
||||
}
|
||||
|
||||
dump_config() {
|
||||
pri_spantypes=`list_pri_spantypes`
|
||||
num_spantypes=`echo "$pri_spantypes" | wc -w`
|
||||
gen_default=''
|
||||
echo '#'
|
||||
echo "# Autogenerated by $0 on `date`"
|
||||
echo "# Map PRI DAHDI devices to span types for E1/T1/J1"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
echo "# Was run with '--line-mode=$DEFAULT_LINE_MODE' -- so will:"
|
||||
echo "# * Generate default wildcard entry"
|
||||
echo "# * Generate commented-out device list (for overrides)"
|
||||
fi
|
||||
echo ''
|
||||
fmt="%-65s %s\n"
|
||||
printf "$fmt" '# @location/hardware_id' 'span_type'
|
||||
echo "#"
|
||||
|
||||
echo "# Summary:"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
echo ""
|
||||
echo "# Wildcard line-mode $DEFAULT_LINE_MODE".
|
||||
printf "$fmt" "*" "*:$DEFAULT_LINE_MODE"
|
||||
echo ""
|
||||
echo "# A list of commented out configurations for spans."
|
||||
echo "# Each item may be un-commented to provide an override."
|
||||
gen_default="$DEFAULT_LINE_MODE"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Was run with '--line-mode=$DEFAULT_LINE_MODE'"
|
||||
elif [ "$num_spantypes" -eq 1 ]; then
|
||||
gen_default="$pri_spantypes"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
else
|
||||
echo "# * Not generating wildcard match."
|
||||
echo "# - Was run without '--line-mode' option and span were of mixed types [$pri_spantypes]"
|
||||
fi
|
||||
echo "#"
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
echo "# * Generating a list of commented out configurations for spans."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
echo "# - Uncomment for specific overrides"
|
||||
else
|
||||
echo "# * Generating a list of specific span configurations."
|
||||
echo "# - Spans were of mixed types: $pri_spantypes"
|
||||
fi
|
||||
echo "#"
|
||||
echo ''
|
||||
|
||||
fmt="%-65s %s"
|
||||
printf "$fmt\n" '# @location/hardware_id' 'span_type'
|
||||
|
||||
if [ "$gen_default" != '' ]; then
|
||||
printf "$fmt\t\t# Wildcard line-mode" "*" "*:$gen_default"
|
||||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
@@ -226,10 +255,10 @@ dump_config() {
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
printf "#$fmt" "$id" "$st"
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
printf "#$fmt\n" "$id" "$st"
|
||||
else
|
||||
printf "$fmt" "$id" "$st"
|
||||
printf "$fmt\n" "$id" "$st"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@@ -237,7 +266,7 @@ dump_config() {
|
||||
;;
|
||||
esac
|
||||
done | sort -n
|
||||
#echo ''
|
||||
echo ''
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
25
hotplug/dahdi_auto_assign_compat
Executable file
25
hotplug/dahdi_auto_assign_compat
Executable file
@@ -0,0 +1,25 @@
|
||||
#! /bin/sh
|
||||
|
||||
devdir='/sys/bus/dahdi_devices/devices'
|
||||
|
||||
# DAHDI is loaded?
|
||||
if [ ! -d "$devdir" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
devices_by_registration_time() {
|
||||
grep -H '' $devdir/*/registration_time 2>/dev/null | \
|
||||
sed 's,/registration_time:,\t,' | \
|
||||
sort -k 2,2
|
||||
}
|
||||
|
||||
# First assign non-Astribank devices
|
||||
devices_by_registration_time | \
|
||||
grep -v '/astribanks:' | \
|
||||
while read devpath time; do
|
||||
echo >&2 "D: auto '$devpath'"
|
||||
dahdi_span_assignments auto "$devpath"
|
||||
done
|
||||
|
||||
# Now handle Astribanks
|
||||
LC_ALL=C dahdi_registration -Rv on
|
||||
@@ -36,16 +36,6 @@ if [ "$DAHDI_UDEV_DISABLE_DEVICES" = 'yes' ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if we can safely do our job
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -eq 1 ]; then
|
||||
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Can we pass a different value so we can use
|
||||
# alternate (testing) configuration?
|
||||
# Meanwhile, make it hard-coded.
|
||||
@@ -72,12 +62,24 @@ run_parts() {
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
|
||||
# Check if we can safely do our job
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -ne 0 ]; then
|
||||
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
remove)
|
||||
# Nothing to do yet...
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
*)
|
||||
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
|
||||
|
||||
@@ -62,6 +62,20 @@ run_parts() {
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
|
||||
# Old driver. These scripts probably won't work anyway.
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
if [ -f /sys/module/dahdi ]; then
|
||||
$LOGGER "Old driver (no auto_assign_spans parameter). Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $(cat /sys/module/dahdi/parameters/auto_assign_spans) -ne 0 ]; then
|
||||
$LOGGER "auto_assign_spans=1. Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set variables
|
||||
span_devpath="/sys$DEVPATH"
|
||||
SPANNO=`echo "$span_devpath" | sed 's,.*/span-,,'`
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
if [ -r "$DAHDICONFDIR/span-types.conf" ]; then
|
||||
dahdi_span_types set "/sys$DEVPATH"
|
||||
fi
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
# For now, handle only spans in assigned-spans.conf
|
||||
# We leave other cases to /etc/init.d/dahdi, so
|
||||
# legacy ordering can be preserved.
|
||||
if [ -r "$DAHDICONFDIR/assigned-spans.conf" ]; then
|
||||
dahdi_span_assignments add "/sys$DEVPATH"
|
||||
else
|
||||
# No configuration. No order guaranteed
|
||||
dahdi_span_assignments auto "/sys$DEVPATH"
|
||||
fi
|
||||
|
||||
@@ -111,17 +111,6 @@
|
||||
# Channel(s) are signalled using FXO Groundstart protocol.
|
||||
# fxoks::
|
||||
# Channel(s) are signalled using FXO Koolstart protocol.
|
||||
# sf::
|
||||
# Channel(s) are signalled using in-band single freq tone.
|
||||
# Syntax as follows:
|
||||
#
|
||||
# channel# => sf:<rxfreq>,<rxbw>,<rxflag>,<txfreq>,<txlevel>,<txflag>
|
||||
#
|
||||
# rxfreq is rx tone freq in Hz, rxbw is rx notch (and decode)
|
||||
# bandwith in hz (typically 10.0), rxflag is either 'normal' or
|
||||
# 'inverted', txfreq is tx tone freq in hz, txlevel is tx tone
|
||||
# level in dbm, txflag is either 'normal' or 'inverted'. Set
|
||||
# rxfreq or txfreq to 0.0 if that tone is not desired.
|
||||
#
|
||||
# unused::
|
||||
# No signalling is performed, each channel in the list remains idle
|
||||
|
||||
43
xpp/Makefile
43
xpp/Makefile
@@ -54,7 +54,8 @@ OCT_DEFINES = \
|
||||
-DcOCT6100_MAX_ECHO_CHANNELS=672 \
|
||||
-DcOCT6100_MAX_MIXER_EVENTS=1344
|
||||
|
||||
ECHO_LOADER = echo_loader.o
|
||||
ECHO_LOADER_SRC = echo_loader.c
|
||||
ECHO_LOADER = $(ECHO_LOADER_SRC:.c=.o)
|
||||
endif
|
||||
|
||||
%.8: %
|
||||
@@ -71,12 +72,33 @@ PERL_SCRIPTS = \
|
||||
|
||||
PERL_MANS = $(PERL_SCRIPTS:%=%.8)
|
||||
|
||||
XTALK_OBJS = xtalk/xtalk.o xtalk/xusb.o xtalk/xlist.o xtalk/debug.o
|
||||
ASTRIBANK_OBJS = astribank_usb.o mpptalk.o $(XTALK_OBJS)
|
||||
# List all our sources
|
||||
XUSB_SRCS = xtalk/xusb.c xtalk/xlist.c xtalk/debug.c
|
||||
XTALK_SRCS = xtalk/xtalk.c
|
||||
MPPTALK_SRCS = mpptalk.c
|
||||
ASTRIBANK_SRCS = astribank_usb.c
|
||||
ABHEXLOAD_SRCS = astribank_hexload.c hexfile.c pic_loader.c
|
||||
ABTOOL_SRCS = astribank_tool.c
|
||||
ABALLOW_SRCS = astribank_allow.c astribank_license.c
|
||||
|
||||
ABHEXLOAD_OBJS = astribank_hexload.o hexfile.o pic_loader.o $(ECHO_LOADER) $(ASTRIBANK_OBJS) $(OCT_HERE_OBJS)
|
||||
ABTOOL_OBJS = astribank_tool.o $(ASTRIBANK_OBJS)
|
||||
ABALLOW_OBJS = astribank_allow.o astribank_license.o $(ASTRIBANK_OBJS)
|
||||
SRCS = \
|
||||
$(XUSB_SRCS) \
|
||||
$(XTALK_SRCS) \
|
||||
$(MPPTALK_SRCS) \
|
||||
$(ASTRIBANK_SRCS) \
|
||||
$(ABHEXLOAD_SRCS) \
|
||||
$(ABTOOL_SRCS) \
|
||||
$(ABALLOW_SRCS) \
|
||||
$(ECHO_LOADER_SRC)
|
||||
|
||||
# Derive object files from source list
|
||||
XUSB_OBJS = $(XUSB_SRCS:.c=.o)
|
||||
XTALK_OBJS = $(XTALK_SRCS:.c=.o) $(XUSB_OBJS)
|
||||
MPPTALK_OBJS = $(MPPTALK_SRCS:.c=.o) $(XTALK_OBJS)
|
||||
ASTRIBANK_OBJS = $(ASTRIBANK_SRCS:.c=.o) $(MPPTALK_OBJS)
|
||||
ABHEXLOAD_OBJS = $(ABHEXLOAD_SRCS:.c=.o) $(ASTRIBANK_OBJS) $(ECHO_LOADER) $(OCT_HERE_OBJS)
|
||||
ABTOOL_OBJS = $(ABTOOL_SRCS:.c=.o) $(ASTRIBANK_OBJS)
|
||||
ABALLOW_OBJS = $(ABALLOW_SRCS:.c=.o) $(ASTRIBANK_OBJS)
|
||||
|
||||
TARGETS = .perlcheck astribank_is_starting
|
||||
PROG_INSTALL = astribank_is_starting
|
||||
@@ -124,7 +146,7 @@ ifneq (,$(PERLLIBDIR))
|
||||
done
|
||||
endif
|
||||
|
||||
CFLAGS += -I. -Ixtalk
|
||||
CFLAGS += -I. -Ixtalk -Wall -Werror
|
||||
|
||||
astribank_hexload: $(ABHEXLOAD_OBJS)
|
||||
astribank_hexload: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
@@ -170,8 +192,11 @@ clean:
|
||||
$(RM) .depend .octasic.depend *.o xtalk/*.o $(OCT_HERE_OBJS) $(TARGETS)
|
||||
|
||||
.PHONY: depend
|
||||
ifeq (1,$(PBX_USB))
|
||||
depend: .depend
|
||||
.depend: *.c *.h xtalk/*.c xtalk/*.h
|
||||
@$(CC) $(CFLAGS) -MM *.c xtalk/*.c > $@ || rm -f $@
|
||||
.depend: *.c *.h xtalk/*.c
|
||||
@echo "Calculating dependencies"
|
||||
@if ! $(CC) $(CFLAGS) $(OCT_CFLAGS) -MM $(SRCS) > $@; then $(RM) $@; exit 1; fi
|
||||
|
||||
include .depend
|
||||
endif
|
||||
|
||||
@@ -35,12 +35,17 @@ my %opts;
|
||||
getopts('vRs:', \%opts) || usage;
|
||||
|
||||
my $dahdi_autoreg = check_param('/sys/module/xpp/parameters/dahdi_autoreg') eq 'Y';
|
||||
my $auto_assign_spans = check_param('/sys/module/dahdi/parameters/auto_assign_spans') eq '1';
|
||||
my $auto_assign_spans = check_param('/sys/module/dahdi/parameters/auto_assign_spans') ne '0';
|
||||
my $assigned_spans_config = $ENV{'ASSIGNED_SPANS_CONF_FILE'} || '/etc/dahdi/assigned-spans.conf';
|
||||
my $span_types_config = $ENV{'SPAN_TYPES_CONF_FILE'} || '/etc/dahdi/span-types.conf';
|
||||
my $have_assigned_spans_config = -f $assigned_spans_config || 0;
|
||||
my $have_span_types_config = -f $span_types_config || 0;
|
||||
|
||||
# Spans will be auto-assigned by default if either:
|
||||
# - Driver $auto_assign_spans them or
|
||||
# - Udev script see that we $have_span_types_config and it "add" them
|
||||
my $default_auto_assign = $auto_assign_spans || $have_assigned_spans_config;
|
||||
|
||||
my $sorter;
|
||||
my $sort_order = $opts{'s'};
|
||||
if(defined $sort_order) {
|
||||
@@ -100,11 +105,14 @@ foreach my $xbus (Dahdi::Xpp::xbuses($sorter)) {
|
||||
}
|
||||
myprintf "%3s ==> %3s\n", state2str($prev), state2str($on);
|
||||
}
|
||||
if (defined($on) && $on && ! $have_assigned_spans_config && ! $auto_assign_spans) {
|
||||
next unless defined($on) && $on;
|
||||
# Only assign if no default assignment, or forced by '-R' option
|
||||
if ($opts{'R'} || ! $default_auto_assign) {
|
||||
# Emulate /etc/dahdi/assigned-spans.conf:
|
||||
# - We iterate over $xbus according to /etc/dahdi/xpp_order
|
||||
# - We "auto" assign all spans of current $xbus
|
||||
my $devpath = sprintf "/sys/bus/dahdi_devices/devices/astribanks:xbus-%02d", $xbus->num;
|
||||
myprintf "auto-assign $devpath\n";
|
||||
my @cmd = ('dahdi_span_assignments', 'auto', $devpath);
|
||||
system @cmd;
|
||||
warn "Failed '@cmd' (status=$?)\n" if $?;
|
||||
|
||||
@@ -362,7 +362,7 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
|
||||
DBG("Loading %s file...\n", filename);
|
||||
pFile = fopen(filename, "rb");
|
||||
if (pFile == NULL) {
|
||||
ERR("fopen\n");
|
||||
ERR("fopen: %s\n", strerror(errno));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,11 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
|
||||
} else {
|
||||
DBG("allocated mem for pbyFileData\n");
|
||||
}
|
||||
fread(pbyFileData, 1, *pLen, pFile);
|
||||
if (fread(pbyFileData, 1, *pLen, pFile) != *pLen) {
|
||||
fclose(pFile);
|
||||
ERR("fread: %s\n", strerror(errno));
|
||||
return -ENODEV;
|
||||
}
|
||||
fclose(pFile);
|
||||
DBG("Successful loading %s file into memory "
|
||||
"(size = %d, DUMP: first = %02X %02X, last = %02X %02X)\n",
|
||||
|
||||
@@ -30,16 +30,21 @@ sub generate($$$) {
|
||||
return if $?;
|
||||
|
||||
my $line_mode = $genopts->{'line-mode'};
|
||||
$line_mode = 'E1' unless defined $line_mode;
|
||||
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
|
||||
warn "Empty configuration -- no spans\n" unless @spans;
|
||||
my $cmd;
|
||||
if (defined $line_mode) {
|
||||
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
|
||||
$cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
|
||||
printf("Generating $file (with default line-mode %s)\n", $line_mode)
|
||||
if $genopts->{verbose};
|
||||
} else {
|
||||
$cmd = "dahdi_span_types dumpconfig > $file";
|
||||
printf("Generating $file (no --line-mode override)\n")
|
||||
if $genopts->{verbose};
|
||||
}
|
||||
rename "$file", "$file.bak"
|
||||
or $! == 2 # ENOENT (No dependency on Errno.pm)
|
||||
or die "Failed to backup old config: $!\n";
|
||||
#$gconfig->dump;
|
||||
printf("Generating $file (with default line-mode %s)\n", $line_mode)
|
||||
if $genopts->{verbose};
|
||||
my $cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
|
||||
system $cmd;
|
||||
die "Command failed (status=$?): '$cmd'" if $?;
|
||||
}
|
||||
|
||||
@@ -41,18 +41,25 @@ ab_list() {
|
||||
}
|
||||
|
||||
ab_serial_nums() {
|
||||
ab_list | \
|
||||
sed 's,$,/serial,' | \
|
||||
xargs grep -H '' 2>/dev/null | \
|
||||
sed 's,.*/serial:,,' | \
|
||||
sed 's/^$/NO-SERIAL/' | \
|
||||
sort -u
|
||||
for i in `ab_list`; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo "NO-SERIAL"
|
||||
else
|
||||
echo "$s"
|
||||
fi
|
||||
done | sort -u || :
|
||||
}
|
||||
|
||||
detected_serial_nums() {
|
||||
cat /sys/bus/astribanks/devices/*/transport/serial 2> /dev/null | \
|
||||
sed 's/^$/NO-SERIAL/' | \
|
||||
sort -u || :
|
||||
for i in /sys/bus/astribanks/devices/*/transport; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo "NO-SERIAL"
|
||||
else
|
||||
echo "$s"
|
||||
fi
|
||||
done | sort -u || :
|
||||
}
|
||||
|
||||
calc_union() {
|
||||
@@ -72,6 +79,10 @@ waitfor_ab_initialization() {
|
||||
fi
|
||||
test "$oldab" != "$ab"
|
||||
do
|
||||
if [ "$ab" = '' ]; then
|
||||
echo >&2 "Astribanks disappeared"
|
||||
break
|
||||
fi
|
||||
oldab="$ab"
|
||||
cat $ab
|
||||
#echo -n 1>&2 "_"
|
||||
@@ -94,6 +105,14 @@ if ! astribank_is_starting; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanity check
|
||||
for i in `ab_list`; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo >&2 "WARNING! Astribank without serial number: $i"
|
||||
fi
|
||||
done
|
||||
|
||||
serial_nums=`ab_serial_nums`
|
||||
|
||||
# Loop until detected (hopefully) all astribanks and they are initialized
|
||||
|
||||
@@ -61,6 +61,21 @@ struct xusb {
|
||||
|
||||
static void xusb_init();
|
||||
|
||||
/*
|
||||
* XTALK_OPTIONS:
|
||||
* A white-space separated list of options, read from the environment
|
||||
* variable of that name. Existing options:
|
||||
*
|
||||
* - "use-clear-halt" -- force USB "clear_halt" operation during
|
||||
* device initialization
|
||||
* - "no-lock" -- prevent using global sempahore to serialize libusb
|
||||
* initialization. Previously done via "XUSB_NOLOCK"
|
||||
* environment variable.
|
||||
*/
|
||||
int xtalk_parse_options(void);
|
||||
int xtalk_option_use_clear_halt(void);
|
||||
int xtalk_option_no_lock(void);
|
||||
|
||||
void xusb_init_spec(struct xusb_spec *spec, char *name,
|
||||
uint16_t vendor_id, uint16_t product_id,
|
||||
int nifaces, int iface, int nep, int ep_out, int ep_in)
|
||||
@@ -257,13 +272,16 @@ int xusb_claim_interface(struct xusb *xusb)
|
||||
xusb->iProduct,
|
||||
xusb->iSerialNumber,
|
||||
xusb->iInterface);
|
||||
if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
|
||||
ERR("Clearing output endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
|
||||
ERR("Clearing input endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
if (xtalk_option_use_clear_halt()) {
|
||||
DBG("Using clear_halt()\n");
|
||||
if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
|
||||
ERR("Clearing output endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
|
||||
ERR("Clearing input endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = xusb_flushread(xusb);
|
||||
if (ret < 0) {
|
||||
@@ -857,13 +875,63 @@ static int initizalized;
|
||||
static void xusb_init()
|
||||
{
|
||||
if (!initizalized) {
|
||||
if (!getenv("XUSB_NOLOCK"))
|
||||
xtalk_parse_options();
|
||||
if (!xtalk_option_no_lock())
|
||||
xusb_lock_usb();
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
initizalized = 1;
|
||||
if (!getenv("XUSB_NOLOCK"))
|
||||
if (!xtalk_option_no_lock())
|
||||
xusb_unlock_usb();
|
||||
}
|
||||
}
|
||||
|
||||
/* XTALK option handling */
|
||||
static int use_clear_halt = 0;
|
||||
static int libusb_no_lock = 0;
|
||||
|
||||
static int xtalk_one_option(const char *option_string)
|
||||
{
|
||||
if (strcmp(option_string, "use-clear-halt") == 0) {
|
||||
use_clear_halt = 1;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(option_string, "no-lock") == 0) {
|
||||
libusb_no_lock = 1;
|
||||
return 0;
|
||||
}
|
||||
ERR("Unknown XTALK_OPTIONS content: '%s'\n", option_string);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int xtalk_option_use_clear_halt(void)
|
||||
{
|
||||
return use_clear_halt;
|
||||
}
|
||||
|
||||
int xtalk_option_no_lock(void)
|
||||
{
|
||||
return libusb_no_lock;
|
||||
}
|
||||
|
||||
int xtalk_parse_options(void)
|
||||
{
|
||||
char *xtalk_options;
|
||||
char *saveptr;
|
||||
char *token;
|
||||
int ret;
|
||||
|
||||
xtalk_options = getenv("XTALK_OPTIONS");
|
||||
if (!xtalk_options)
|
||||
return 0;
|
||||
token = strtok_r(xtalk_options, " \t", &saveptr);
|
||||
while (token) {
|
||||
ret = xtalk_one_option(token);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
token = strtok_r(NULL, " \t", &saveptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user