summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-05-13 21:08:09 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-05-13 21:08:09 +0000
commitd7e54a785544ac40abc4a88383df3a913ca466e8 (patch)
treeabf630c8372e7c81407172ad31190fa8a617a8ed /kernel/xpp/utils
parent823cf303caf13cc6e4fd2c2173804f0990b29532 (diff)
xpp r5723: Includes, among others:
* New firmware protocol version: 3.0 . * New numbers for the device types: (e.g. in card_init* scripts) - FXS: 1 (was: 3) - FXO: 2 (was: 4) - BRI: 3 (was: 6 for TE, 7 for NT) - PRI: 4 (was: 9) * Init scripts of FXS and FXO modules are now written in Perl as well (be sure to have File::Basename, e.g: perl-modules in Debian). * calibrate_slics merged into init_card_1_30 . * Module parameter print_dbg replaced with debug . Same meaning. * init_fxo_modes removed: content moved into init_card_2_30, verified at build time. * Code tested with sparse. Most warnings were fixed. * Set ZT_SIG_DACS for the bchans in the PRI and BRI modules to not get ignored by ztscan. * Handle null config_desc we get from some crazy USB controllers. * genzaptelconf: Fix reporting of empty slots in list mode. * xpp_blink can now blink a single analog port. * "slics" has been renamed "chipregs". * Fixed a small typo in fpga_load(8). * Fixed bashism in xpp_fxloader. Merged revisions 4264 via svnmerge from http://svn.digium.com/svn/zaptel/branches/1.2 git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4266 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/utils')
-rw-r--r--kernel/xpp/utils/Makefile12
-rw-r--r--kernel/xpp/utils/fpga_load.82
-rw-r--r--kernel/xpp/utils/fpga_load.c4
-rwxr-xr-xkernel/xpp/utils/genzaptelconf5
-rw-r--r--kernel/xpp/utils/print_modes.c23
-rwxr-xr-xkernel/xpp/utils/xpp_blink53
-rw-r--r--kernel/xpp/utils/xpp_fxloader11
-rw-r--r--kernel/xpp/utils/xpp_modprobe8
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Chans.pm15
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm34
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm3
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm2
12 files changed, 125 insertions, 47 deletions
diff --git a/kernel/xpp/utils/Makefile b/kernel/xpp/utils/Makefile
index d8290eb..2e3624c 100644
--- a/kernel/xpp/utils/Makefile
+++ b/kernel/xpp/utils/Makefile
@@ -37,7 +37,7 @@ PERL_MODS := $(shell cd zconf; echo $(PERL_MODS_PAT))
XPD_FIRMWARE = $(wildcard ../firmwares/*.hex)
XPD_INIT_DATA = $(XPD_FIRMWARE) init_fxo_modes
-XPD_INIT = $(wildcard ../init_card_?_*) ../calibrate_slics xpp_fxloader
+XPD_INIT = $(wildcard ../init_card_?_*) xpp_fxloader
# Variables that should be defined above, but need sane defaults:
# FIXME: Are those values really sane?
@@ -49,6 +49,8 @@ ifeq (,$(PBX_LIBUSB))
PBX_LIBUSB = $(shell if [ -r /usr/include/usb.h ]; then echo 1; else echo 0; fi)
endif
+WCTDM=$(shell for i in $(ZAP_KERNEL)/wctdm.c $(ZAP_KERNEL)/fxo_modes.h; do [ -f "$$i" ] && echo "$$i"; done)
+
CFLAGS = -g -Wall $(EXTRA_CFLAGS)
%.8: %
@@ -124,8 +126,12 @@ test_parse.o: test_parse.c hexfile.h
test_parse: test_parse.o libhexfile.a
$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
-print_modes: print_modes.c $(ZAP_KERNEL)/fxo_modes.h
- $(HOSTCC) -I$(ZAP_KERNEL) -o $@ $(CFLAGS) $<
+print_modes: print_modes.c wctdm_fxomodes.h
+ $(HOSTCC) -o $@ $(CFLAGS) $<
+
+wctdm_fxomodes.h: $(WCTDM)
+ @echo Building FXO modes from: $(WCTDM)
+ perl -n -e 'print if (/^static struct fxo_mode {$$/ .. /};$$/)' $(WCTDM) >$@ || rm -f $@
init_fxo_modes: print_modes
./$< >$@
diff --git a/kernel/xpp/utils/fpga_load.8 b/kernel/xpp/utils/fpga_load.8
index 412a839..dd21db0 100644
--- a/kernel/xpp/utils/fpga_load.8
+++ b/kernel/xpp/utils/fpga_load.8
@@ -1,7 +1,7 @@
.TH "FPGA_LOAD" "8" "16 April 2006" "" ""
.SH NAME
-ztcfg \- reads and loads zaptel.conf
+fpga_load \- Xorcom Astribank (xpp) firmware tool
.SH SYNOPSIS
.B fpga_load
diff --git a/kernel/xpp/utils/fpga_load.c b/kernel/xpp/utils/fpga_load.c
index 3d6bdbe..7102501 100644
--- a/kernel/xpp/utils/fpga_load.c
+++ b/kernel/xpp/utils/fpga_load.c
@@ -574,6 +574,10 @@ int my_usb_device_init(const char devpath[], struct my_usb_device *mydev, const
}
dev_desc = &mydev->dev->descriptor;
config_desc = mydev->dev->config;
+ if (!config_desc) {
+ ERR("usb interface without a configuration\n");
+ return 0;
+ }
interface = &config_desc->interface[abtype->my_interface_num];
iface_desc = interface->altsetting;
endpoint = iface_desc->endpoint;
diff --git a/kernel/xpp/utils/genzaptelconf b/kernel/xpp/utils/genzaptelconf
index 1435e9f..163f595 100755
--- a/kernel/xpp/utils/genzaptelconf
+++ b/kernel/xpp/utils/genzaptelconf
@@ -973,7 +973,10 @@ EOF
# this is an empty slot.
# TODO: I believe that the Sangoma A20x will reject both and thus
# print nothing here.
- echo "# channel $chan_num, WCTDM, no module." >> $zaptel_file
+ case "$mode" in
+ list) echo "# channel $chan_num, WCTDM, no module.";;
+ files) echo "# channel $chan_num, WCTDM, no module." >> $zaptel_file;;
+ esac
continue
fi
diff --git a/kernel/xpp/utils/print_modes.c b/kernel/xpp/utils/print_modes.c
index e894b11..77e0e33 100644
--- a/kernel/xpp/utils/print_modes.c
+++ b/kernel/xpp/utils/print_modes.c
@@ -1,11 +1,10 @@
#include <stdio.h>
-#include "fxo_modes.h"
+#include "wctdm_fxomodes.h"
int main() {
size_t i;
- printf("case \"$mode\" in\n");
for (i=0; i<(sizeof(fxo_modes)/sizeof(struct fxo_mode)); i++) {
if (fxo_modes[i].name == NULL) break;
int reg16=0, reg26=0, reg30=0, reg31=0x20;
@@ -23,22 +22,12 @@ int main() {
reg31 |= (fxo_modes[i].ohs2 << 3);
- if (fxo_modes[i].ring_osc !=0 ) {
- snprintf(ring_osc, BUFSIZ, "; ring_osc=\"%02X %02X\"",
- (fxo_modes[i].ring_osc)>>8,
- (fxo_modes[i].ring_osc)&&0xFF
- );
- }
- if (fxo_modes[i].ring_x !=0 ) {
- snprintf(ring_x, BUFSIZ, "; ring_x=\"%02X %02X\"",
- (fxo_modes[i].ring_x)>>8,
- (fxo_modes[i].ring_x)&&0xFF
- );
- }
-
- printf("%s)\treg16=%02X; reg26=%02X; reg30=%02X; reg31=%02X%s%s;;\n",
+ if (fxo_modes[i].ring_osc)
+ snprintf(ring_osc, BUFSIZ, "ring_osc=%04X", fxo_modes[i].ring_osc);
+ if (fxo_modes[i].ring_x)
+ snprintf(ring_x, BUFSIZ, "ring_x=%04X", fxo_modes[i].ring_x);
+ printf("%-15s\treg16=%02X\treg26=%02X\treg30=%02X\treg31=%02X\t%s\t%s\n",
fxo_modes[i].name, reg16, reg26, reg30, reg31, ring_osc, ring_x);
}
- printf("esac\n");
return 0;
}
diff --git a/kernel/xpp/utils/xpp_blink b/kernel/xpp/utils/xpp_blink
index 8a96502..bf68d80 100755
--- a/kernel/xpp/utils/xpp_blink
+++ b/kernel/xpp/utils/xpp_blink
@@ -17,16 +17,16 @@ use Zaptel::Xpp;
use Zaptel::Xpp::Xbus;
sub usage {
- die "Usage: $0 {on|off|bzzt} {span <number> | xpd <bus num> [<xpd num>] | label <label>}\n";
+ die "Usage: $0 {on|off|bzzt} {span <number> | chan <number> | xpd <bus num> [<xpd num>] | label <label>}\n";
}
my $state = shift;
my $selector = shift;
usage unless defined($state) and $state =~ /^(on|off|bzzt)$/;
-usage unless defined($selector) and $selector =~ /^(span|xpd|label)$/i;
+usage unless defined($selector) and $selector =~ /^(span|chan|xpd|label)$/i;
my $xpd;
-my @xpds;
+my @blinklist;
my @channels;
if($selector =~ /^span$/i) {
@@ -39,13 +39,24 @@ if($selector =~ /^span$/i) {
my $xpdname = $xpd->fqn;
my $connector = $xpd->xbus->connector;
die "$xpdname is not connected\n" unless defined $connector;
- push(@xpds, $xpd);
+ push(@blinklist, $xpd);
my @chans = $span->chans();
@channels = join(' ', map { $_->num } @chans);
printf "Using %s (connected via $connector): channels @channels\n", $xpd->fqn;
+} elsif($selector =~ /^chan$/i) {
+ my $channo = shift;
+ usage unless defined($channo) and $channo =~ /^\d+/;
+ my @spans = Zaptel::spans();
+ my @chans = map { $_->chans() } @spans;
+ my ($chan) = grep { $_->num eq $channo } @chans;
+ die "Channel $channo was not found\n" unless defined $chan;
+ die "Cannot blink Input ports\n" if $chan->type eq 'IN';
+ die "Cannot blink Output ports\n" if $chan->type eq 'OUT';
+ push(@blinklist, $chan);
} elsif($selector =~ /^xpd$/i) {
my $busnum = shift;
my $xpdnum = shift;
+ my $linenum = shift;
usage unless defined($busnum) and $busnum =~ /^\d+/;
my $xbus = Zaptel::Xpp::Xbus::by_number($busnum);
die "Unkown XBUS number $busnum\n" unless defined $xbus;
@@ -53,28 +64,36 @@ if($selector =~ /^span$/i) {
usage unless $xpdnum =~ /^\d+/;
$xpd = $xbus->get_xpd_by_number($xpdnum);
die "Unkown XPD number $xpdnum on XBUS number $busnum\n" unless defined $xpd;
- push(@xpds, $xpd);
+ if(defined $linenum) {
+ usage unless $linenum =~ /^\d+/;
+ my $lines = $xpd->lines;
+ my $l = @{$lines}[$linenum];
+ die "Bad line number $linenum on XPD $xpd->fqn\n" unless defined $l;
+ push(@blinklist, $l);
+ } else {
+ push(@blinklist, $xpd);
+ }
} else {
- @xpds = $xbus->xpds;
- die "XBUS number $busnum has no XPDS!\n" unless @xpds;
+ @blinklist = $xbus->xpds;
+ die "XBUS number $busnum has no XPDS!\n" unless @blinklist;
}
} elsif($selector =~ /^label$/i) {
my $label = shift;
usage unless defined($label);
my $xbus = Zaptel::Xpp::Xbus::by_label($label);
die "Unkown XBUS label $label\n" unless defined $xbus;
- @xpds = $xbus->xpds;
- die "XBUS label '$label' has no XPDS!\n" unless @xpds;
+ @blinklist = $xbus->xpds;
+ die "XBUS label '$label' has no XPDS!\n" unless @blinklist;
}
if($state eq 'on') {
- $_->blink(1) foreach (@xpds);
+ $_->blink(1) foreach (@blinklist);
} elsif($state eq 'off') {
- $_->blink(0) foreach (@xpds);
+ $_->blink(0) foreach (@blinklist);
} elsif($state eq 'bzzt') {
- $_->blink(1) foreach (@xpds);
+ $_->blink(1) foreach (@blinklist);
sleep 1;
- $_->blink(0) foreach (@xpds);
+ $_->blink(0) foreach (@blinklist);
}
__END__
@@ -85,7 +104,7 @@ xpp_blink - Blink the leds of a specified XPD
=head1 SYNOPSIS
-xpp_blink {on|off|bzzt} {span <number> | xpd <bus num> [<xpd num>]}\n";
+xpp_blink {on|off|bzzt} {span <number> | chan <number> | xpd <bus num> [<xpd num> [<lineno>]]}
=head1 DESCRIPTION
@@ -111,6 +130,8 @@ Blink all the leds of an XPD.
will also print the zaptel channels of the span and the
xbus/xpd this span represents.
+=item chan Select by channel number. This only work for XPD registered to zaptel.
+
=item xpd Select by xbus + xpd numbers. If only xbus number is given, all the
XPDs of the selected xbus (Astribank) are blinked.
@@ -123,7 +144,9 @@ Blink all the leds of an XPD.
$ xpp_blink bzzt span 2
Using XBUS-04/XPD-10 (connected via usb-0000:00:1d.7-1): channels 15 16 17 18 19 20 21 22
- $ xpp_blink on xpd 0 1
+ $ xpp_blink bzzt chan 18
+
+ $ xpp_blink on xpd 0 1 5
$ xpp_blink off xpd 0
diff --git a/kernel/xpp/utils/xpp_fxloader b/kernel/xpp/utils/xpp_fxloader
index 1cbd6b7..5a26560 100644
--- a/kernel/xpp/utils/xpp_fxloader
+++ b/kernel/xpp/utils/xpp_fxloader
@@ -56,6 +56,8 @@ me=`basename $0`
DEBIAN_DEFAULTS="/etc/default/zaptel"
REDHAT_DEFAULTS="/etc/sysconfig/zaptel"
+status_fd=3
+
if [ -r "$DEBIAN_DEFAULTS" -a -r "$REDHAT_DEFAULTS" ]; then
echo 1>&2 "$0: Both '$DEBIAN_DEFAULTS' and '$REDHAT_DEFAULTS' exist"
exit 1
@@ -143,9 +145,12 @@ load_fpga() {
$LOGGER "FPGA Firmware into $dev"
sleep_if_race
- $FPGA_LOAD -D "$dev" -I "$FIRMWARE_DIR/$fw" -i | $LOGGER
- status=$PIPESTATUS
- if [ $status != 0 ]; then
+ (
+ $FPGA_LOAD -D "$dev" -I "$FIRMWARE_DIR/$fw" -i
+ echo $? >$status_fd
+ )>| $LOGGER
+ status=`cat <$status_fd`
+ if [ "$status" != 0 ]; then
echo "fpga_load failed with status $status" | $LOGGER
exit 77
fi
diff --git a/kernel/xpp/utils/xpp_modprobe b/kernel/xpp/utils/xpp_modprobe
index 76c1f7d..e3bacc2 100644
--- a/kernel/xpp/utils/xpp_modprobe
+++ b/kernel/xpp/utils/xpp_modprobe
@@ -1,10 +1,10 @@
# Some debugging options for the brave of heart:
#options zaptel debug=1
#options wcfxo debug=1
-#options xpp print_dbg=1
-#options xpp_usb print_dbg=1
-#options xpd_fxs print_dbg=1
-#options xpd_fxo print_dbg=1
+#options xpp debug=1
+#options xpp_usb debug=1
+#options xpd_fxs debug=1
+#options xpd_fxo debug=1
# For pre-loading of card modules (e.g: xpp_fxs)
#install xpp_usb /sbin/modprobe xpd_fxs && /sbin/modprobe --ignore-install xpp_usb
diff --git a/kernel/xpp/utils/zconf/Zaptel/Chans.pm b/kernel/xpp/utils/zconf/Zaptel/Chans.pm
index b02bf24..6f83f77 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Chans.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Chans.pm
@@ -184,4 +184,19 @@ sub battery($) {
return $line->battery;
}
+sub blink($$) {
+ my $self = shift or die;
+ my $on = shift;
+ my $span = $self->span or die;
+
+ my $xpd = $span->xpd;
+ my $index = $self->index;
+ return undef if !$xpd;
+
+ my @lines = @{$xpd->lines};
+ my $line = $lines[$index];
+ return $line->blink($on);
+}
+
+
1;
diff --git a/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm b/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
index 0014aed..2472c3b 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
@@ -18,12 +18,44 @@ sub new($$$) {
my $index = shift;
defined $index or die;
my $self = {};
- bless $self, ref($xpd);
+ bless $self, $pack;
$self->{XPD} = $xpd;
$self->{INDEX} = $index;
return $self;
}
+sub blink($$) {
+ my $self = shift;
+ my $on = shift;
+ my $xpd = $self->xpd;
+ my $result;
+
+ my $file = "$proc_base/" . $xpd->fqn . "/blink";
+ die "$file is missing" unless -f $file;
+ # First query
+ open(F, "$file") or die "Failed to open $file for reading: $!";
+ $result = <F>;
+ chomp $result;
+ close F;
+ if(defined($on)) { # Now change
+ my $onbitmask = 1 << $self->index;
+ my $offbitmask = $result & ~$onbitmask;
+
+ $result = $offbitmask;
+ $result |= $onbitmask if $on;
+ open(F, ">$file") or die "Failed to open $file for writing: $!";
+ print F "$result";
+ if(!close(F)) {
+ if($! == 17) { # EEXISTS
+ # good
+ } else {
+ undef $result;
+ }
+ }
+ }
+ return $result;
+}
+
sub create_all($$) {
my $pack = shift or die "Wasn't called as a class method\n";
my $xpd = shift || die;
diff --git a/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm b/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
index a5fcf1e..e840f14 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
@@ -41,7 +41,8 @@ sub get_xpd_by_number($$) {
my $xpdid = shift;
die "Missing XPD id parameter" unless defined $xpdid;
my @xpds = $xbus->xpds;
- return $xpds[$xpdid];
+ my ($wanted) = grep { $_->id eq $xpdid } @xpds;
+ return $wanted;
}
sub new($$) {
diff --git a/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm b/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
index 326aafd..1ddb5c8 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
@@ -28,7 +28,7 @@ sub blink($$) {
close F;
if(defined($on) and $on ne $result) { # Now change
open(F, ">$file") or die "Failed to open $file for writing: $!";
- print F ($on)?"1":"0";
+ print F ($on)?"0xFFFF":"0";
if(!close(F)) {
if($! == 17) { # EEXISTS
# good