[svn-commits] tzafrir: tools/trunk r6313 - in /tools/trunk/xpp: ./ perl_modules/Dahdi/ perl...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 2 15:56:46 CDT 2009


Author: tzafrir
Date: Thu Apr  2 15:56:42 2009
New Revision: 6313

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6313
Log:
Support for Astribanks 116x: tools part

* New USB firmware loading mechanism.
  - Incompatible with previous one: upgrade using fxload or hard reset
  - astribank_hexload is the new low-level loading tool
  - fpga_load remains for backward compatibility.
  - xpp/astribank_upgrade: automate upgrading using fxload
* Much enhanced control protocol ("MPP")
  - astribank_tool is the low-level tool for that.
* Support for the TwinStar (dual USB port)
  - Managed through astribank_tool
  - Wrapper perl modules and scripts provided
* Allow explicit ordering of Astribanks
  - /etc/dahdi/xpp_order - explicit order of Astribanks on the system
  - The default sorter is now to use those and fall back to connectors
    (previous default).
  - An option to dahdi_registration to change sorting.

Added:
    tools/trunk/xpp/astribank_allow.c   (with props)
    tools/trunk/xpp/astribank_hexload.8   (with props)
    tools/trunk/xpp/astribank_hexload.c   (with props)
    tools/trunk/xpp/astribank_tool.8   (with props)
    tools/trunk/xpp/astribank_tool.c   (with props)
    tools/trunk/xpp/astribank_upgrade   (with props)
    tools/trunk/xpp/astribank_usb.c   (with props)
    tools/trunk/xpp/astribank_usb.h   (with props)
    tools/trunk/xpp/debug.c   (with props)
    tools/trunk/xpp/debug.h   (with props)
    tools/trunk/xpp/mpp.h   (with props)
    tools/trunk/xpp/mpp_funcs.c   (with props)
    tools/trunk/xpp/mpp_funcs.h   (with props)
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Mpp.pm   (with props)
    tools/trunk/xpp/pic_loader.c   (with props)
    tools/trunk/xpp/pic_loader.h   (with props)
    tools/trunk/xpp/twinstar   (with props)
    tools/trunk/xpp/twinstar_hook   (with props)
    tools/trunk/xpp/twinstar_setup   (with props)
    tools/trunk/xpp/xpp_order   (with props)
Modified:
    tools/trunk/xpp/   (props changed)
    tools/trunk/xpp/Makefile
    tools/trunk/xpp/dahdi_drivers
    tools/trunk/xpp/dahdi_genconf
    tools/trunk/xpp/dahdi_hardware
    tools/trunk/xpp/dahdi_registration
    tools/trunk/xpp/hexfile.h
    tools/trunk/xpp/lsdahdi
    tools/trunk/xpp/perl_modules/Dahdi/Hardware.pm
    tools/trunk/xpp/perl_modules/Dahdi/Hardware/PCI.pm
    tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
    tools/trunk/xpp/xpp_fxloader
    tools/trunk/xpp/xpp_sync

Propchange: tools/trunk/xpp/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Apr  2 15:56:42 2009
@@ -1,3 +1,6 @@
+astribank_hexload
+astribank_allow
+astribank_tool
 fpga_load
 test_parse
 libhexfile.*

Modified: tools/trunk/xpp/Makefile
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/Makefile?view=diff&rev=6313&r1=6312&r2=6313
==============================================================================
--- tools/trunk/xpp/Makefile (original)
+++ tools/trunk/xpp/Makefile Thu Apr  2 15:56:42 2009
@@ -1,6 +1,5 @@
 PEDANTIC	= -ansi -pedantic -std=c99
 
-RANLIB		= ranlib
 INSTALL		= install
 INSTALL_DATA	= install -m 644
 
@@ -54,12 +53,20 @@
 
 PERL_MANS	= $(PERL_SCRIPTS:%=%.8)
 
-TARGETS	= perlcheck
-PROG_INSTALL	= #genzaptelconf
+ABHEXLOAD_OBJS		= astribank_hexload.o hexfile.o pic_loader.o astribank_usb.o mpp_funcs.o debug.o
+ABTOOL_OBJS		= astribank_tool.o astribank_usb.o mpp_funcs.o debug.o
+ABALLOW_OBJS		= astribank_allow.o astribank_usb.o mpp_funcs.o debug.o
+
+TARGETS	= .perlcheck
+PROG_INSTALL	= 
 MAN_INSTALL	= $(PROG_INSTALL:%=%.8)
 ifeq	(1,$(PBX_USB))
-TARGETS	+= libhexfile.a fpga_load test_parse
-PROG_INSTALL	+= fpga_load
+TARGETS	+= fpga_load		\
+	   astribank_tool	\
+	   astribank_hexload	\
+	   astribank_allow	\
+	   test_parse
+PROG_INSTALL	+= fpga_load astribank_tool astribank_hexload
 endif
 ifneq	(,$(PERLLIBDIR))
 PROG_INSTALL	+= $(PERL_SCRIPTS)
@@ -94,27 +101,34 @@
 	done
 endif
 
-libhexfile.a: hexfile.o
-	$(AR) cru $@ $^
-	$(RANLIB) $@
+fpga_load: fpga_load.o hexfile.o
+	$(CC) -L. -o $@ $^ $(EXTRA_LIBS) -lusb
 
-fpga_load: fpga_load.o libhexfile.a
-	$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
+astribank_hexload: $(ABHEXLOAD_OBJS)
+	$(CC) -L. -o $@ $(ABHEXLOAD_OBJS) $(EXTRA_LIBS) -lusb
+
+astribank_tool: $(ABTOOL_OBJS)
+	$(CC) -L. -o $@ $(ABTOOL_OBJS) $(EXTRA_LIBS) -lusb
+
+astribank_allow: $(ABALLOW_OBJS)
+	$(CC) -L. -o $@ $(ABALLOW_OBJS) $(EXTRA_LIBS) -lusb
 
 fpga_load.o: CFLAGS+=-D_GNU_SOURCE	# We use memrchr()
 
-hexfile.o: hexfile.c hexfile.h
-	$(CC) $(CFLAGS) $(PEDANTIC) -c $<
+test_parse: test_parse.o hexfile.o
+	$(CC) -L. -o $@ $^ $(EXTRA_LIBS) -lusb
 
-test_parse.o: test_parse.c hexfile.h
-	$(CC) $(CFLAGS) $(PEDANTIC) -c $<
 
-test_parse: test_parse.o libhexfile.a
-	$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
-
-perlcheck: $(PERL_SCRIPTS)
+.perlcheck: $(PERL_SCRIPTS)
 	for i in $^; do perl -I./perl_modules -c $$i || exit 1; done
 	touch $@
 
 clean:
-	$(RM) *.o $(TARGETS)
+	$(RM) .depend *.o $(TARGETS)
+
+.PHONY: depend
+depend: .depend
+.depend: *.c *.h
+	@$(CC) -MM *.c > $@ || rm -f $@
+
+include .depend

Added: tools/trunk/xpp/astribank_allow.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_allow.c?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_allow.c (added)
+++ tools/trunk/xpp/astribank_allow.c Thu Apr  2 15:56:42 2009
@@ -1,0 +1,378 @@
+/*
+ * Written by Oron Peled <oron at actcom.co.il> and
+ *            Alex Landau <alex.landau at xorcom.com>
+ * Copyright (C) 2008, Xorcom
+ *
+ * All rights reserved.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include <getopt.h>
+#include <time.h>
+#include <arpa/inet.h>
+#include <ctype.h>
+#include "mpp.h"
+#include "mpp_funcs.h"
+#include "debug.h"
+
+static const char rcsid[] = "$Id$";
+
+#define	DBG_MASK	0x80
+
+static char	*progname;
+
+static void usage()
+{
+	fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> options\n", progname);
+	fprintf(stderr, "\tOptions:\n");
+	fprintf(stderr, "\t\t[-v]               # Increase verbosity\n");
+	fprintf(stderr, "\t\t[-d mask]          # Debug mask (0xFF for everything)\n");
+	fprintf(stderr, "\t\t[-w]               # Write capabilities to EEPROM, otherwise read capabilities\n");
+	fprintf(stderr, "\t\t[-f filename]      # License filename (stdin/stdout if not specified)\n\n");
+	exit(1);
+}
+
+static int capabilities_burn(
+		struct astribank_device *astribank,
+		struct eeprom_table *eeprom_table,
+		struct capabilities *capabilities,
+		struct capkey *key)
+{
+	int	ret;
+
+	INFO("Burning capabilities\n");
+	ret = mpp_caps_set(astribank, eeprom_table, capabilities, key);
+	if(ret < 0) {
+		ERR("Capabilities burning failed: %d\n", ret);
+		return ret;
+	}
+	INFO("Done\n");
+	return 0;
+}
+
+static int bin_to_file(void *buf, int len, FILE *f)
+{
+	static int bytes_on_line;
+	unsigned char *p = buf;
+	if (buf == NULL) {
+		if (bytes_on_line != 0) {
+			if (fprintf(f, "\n") != 1)
+				return -1;
+			bytes_on_line = 0;
+		}
+		return 0;
+	}
+	int i;
+	for (i = 0; i < len; i++) {
+		if (fprintf(f, "%02x", *p++) != 2)
+			return -1;
+		bytes_on_line++;
+		if (bytes_on_line >= 16) {
+			if (fprintf(f, "\n") != 1)
+				return -1;
+			bytes_on_line = 0;
+		}
+	}
+	return 0;
+}
+
+static int write_to_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *key, FILE *f)
+{
+	fprintf(f, "-----BEGIN XORCOM LICENSE BLOCK-----\n");
+	fprintf(f, "Version: 1.0\n");
+	fprintf(f, "Timestamp: %u\n", caps->timestamp);
+	fprintf(f, "Serial: %.*s\n", LABEL_SIZE, eeprom_table->label);
+	fprintf(f, "Capabilities.Port.FXS: %d\n", caps->ports_fxs);
+	fprintf(f, "Capabilities.Port.FXO: %d\n", caps->ports_fxo);
+	fprintf(f, "Capabilities.Port.BRI: %d\n", caps->ports_bri);
+	fprintf(f, "Capabilities.Port.PRI: %d\n", caps->ports_pri);
+	fprintf(f, "Capabilities.Twinstar: %d\n", CAP_EXTRA_TWINSTAR(caps));
+	fprintf(f, "Data:\n");
+	bin_to_file(eeprom_table, sizeof(*eeprom_table), f);
+	bin_to_file(caps, sizeof(*caps), f);
+	bin_to_file(key, sizeof(*key), f);
+	bin_to_file(NULL, 0, f);
+	fprintf(f, "-----END XORCOM LICENSE BLOCK-----\n");
+	return 0;
+}
+
+/*
+ * Removes whitespace on both sizes of the string.
+ * Returns a pointer to the first non-space char. The string
+ * is modified in place to trim trailing whitespace.
+ * If the whole string is whitespace, returns NULL.
+ */
+char *trim(char *s)
+{
+	int len = strlen(s);
+	while (len > 0 && isspace(s[len-1])) {
+		len--;
+	}
+	if (len == 0)
+		return NULL;
+	s[len] = '\0';
+	while (isspace(*s))
+		s++;
+	/* *s is not a space, since in this case we'd return NULL above */
+	return s;
+}
+
+int get_key_value(char *line, char **key, char **value)
+{
+	char *p = strchr(line, ':');
+	if (p == NULL)
+		return -1;
+	*p = '\0';
+	*key = trim(line);
+	*value = trim(p + 1);
+	return 0;
+}
+
+static int hex_digit_to_int(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	else if (c >= 'a' && c <= 'f')
+		return c - 'a' + 10;
+	else
+		return -1;
+}
+
+static int str_to_bin(char *line, void *buf, int maxlen)
+{
+	static int offset;
+	unsigned char *p = buf;
+	if (strlen(line) % 2 != 0)
+		return -1;
+	while (offset < maxlen && *line) {
+		uint8_t value;
+		char c = hex_digit_to_int(*line++);
+		if (c < 0 || *line == '\0')
+			return -1;
+		value = c << 4;
+		c = hex_digit_to_int(*line++);
+		if (c < 0)
+			return -1;
+		value |= c;
+		p[offset++] = value;
+	}
+	if (offset == maxlen && *line)
+		return -1;
+	return offset;
+}
+
+static int read_from_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *capkey, FILE *f)
+{
+	char buf[256];
+	char *line, *key, *value;
+	int state = 0;
+	int lineno = 0;
+	struct table {
+		struct eeprom_table eeprom_table;
+		struct capabilities capabilities;
+		struct capkey capkey;
+	} PACKED table;
+
+	memset(&table, 0, sizeof(struct table));
+	/*
+	 * states:
+	 * 0: start - before BEGIN_LICENSE_BLOCK line. on BEGIN_LICENSE_BLOCK line goto 1.
+	 * 1: read Version, goto 2. if not version line then error.
+	 * 2: after BEGIN line. split line into key:value. if line is Data:, goto 3.
+	 * 3: read binary data. if line is END_LICENSE_BLOCK goto 4.
+	 * 4: END_LICENSE_BLOCK - if not EOF - error. otherwise exit loop and success.
+	 */
+	while (fgets(buf, 256, f) != NULL) {
+		lineno++;
+		int len = strlen(buf);
+		if (len > 0 && buf[len-1] != '\n') {
+			ERR("Line %d: Line too long\n", lineno);
+			return -1;
+		}
+		line = trim(buf);
+		if (line == NULL) {
+			ERR("Line %d: Empty line\n", lineno);
+		}
+		switch (state) {
+			case 0:
+				if (strcmp(line, "-----BEGIN XORCOM LICENSE BLOCK-----") == 0)
+					state = 1;
+				else {
+					ERR("Line %d: Invalid license begin block\n", lineno);
+					return -1;
+				}
+				break;
+			case 1:
+				if (get_key_value(line, &key, &value) < 0) {
+					ERR("Line %d: Can't parse line\n", lineno);
+					return -1;
+				}
+				if (strcmp(key, "Version") == 0) {
+					if (strcmp(value, "1.0") == 0) {
+						state = 2;
+					} else {
+						ERR("Line %d: Unknown license file version '%s', need version '1.0'\n", lineno, value);
+						return -1;
+					}
+				} else {
+					ERR("Line %d: No license file version\n", lineno);
+					return -1;
+				}
+				break;
+			case 2:
+				if (get_key_value(line, &key, &value) < 0) {
+					ERR("Line %d: Can't parse line\n", lineno);
+					return -1;
+				}
+				if (strcmp(key, "Data") == 0) {
+					state = 3;
+					break;
+				}
+				break;
+			case 3:
+				if (strcmp(line, "-----END XORCOM LICENSE BLOCK-----") == 0) {
+					state = 4;
+					break;
+				}
+				if (str_to_bin(line, &table, sizeof(table)) < 0) {
+					ERR("Line %d: Error in data block\n", lineno);
+					return -1;
+				}
+				break;
+			case 4:
+				ERR("Extra data after license end block\n");
+				return -1;
+		}
+	}
+	if (state != 4) {
+		ERR("Invalid license file\n");
+		return -1;
+	}
+	memcpy(eeprom_table, &table.eeprom_table, sizeof(*eeprom_table));
+	memcpy(caps, &table.capabilities, sizeof(*caps));
+	memcpy(capkey, &table.capkey, sizeof(*capkey));
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	char			*devpath = NULL;
+	struct astribank_device *astribank;
+	struct eeprom_table	eeprom_table;
+	struct capabilities	caps;
+	struct capkey		key;
+	const char		options[] = "vd:D:wf:";
+	int			do_write = 0;
+	FILE			*file;
+	char			*filename = NULL;
+	int			ret;
+
+	progname = argv[0];
+	while (1) {
+		int	c;
+
+		c = getopt (argc, argv, options);
+		if (c == -1)
+			break;
+
+		switch (c) {
+			case 'D':
+				devpath = optarg;
+				break;
+			case 'v':
+				verbose++;
+				break;
+			case 'd':
+				debug_mask = strtoul(optarg, NULL, 0);
+				break;
+			case 'w':
+				do_write = 1;
+				break;
+			case 'f':
+				filename = optarg;
+				break;
+			case 'h':
+			default:
+				ERR("Unknown option '%c'\n", c);
+				usage();
+		}
+	}
+	if(!devpath) {
+		ERR("Missing device path\n");
+		usage();
+	}
+	DBG("Startup %s\n", devpath);
+	if((astribank = mpp_init(devpath)) == NULL) {
+		ERR("Failed initializing MPP\n");
+		return 1;
+	}
+	if(astribank->eeprom_type != EEPROM_TYPE_LARGE) {
+		ERR("Cannot use this program with astribank EEPROM type %d (need %d)\n",
+			astribank->eeprom_type, EEPROM_TYPE_LARGE);
+		return 1;
+	}
+	ret = mpp_caps_get(astribank, &eeprom_table, &caps, &key);
+	if(ret < 0) {
+		ERR("Failed to get original capabilities: %d\n", ret);
+		return 1;
+	}
+	if (do_write) {
+		/* update capabilities based on input file */
+		file = stdin;
+		if (filename) {
+			file = fopen(filename, "r");
+			if (file == NULL) {
+				ERR("Can't open file '%s'\n", filename);
+				return 1;
+			}
+		}
+		ret = read_from_file(&eeprom_table, &caps, &key, file);
+		if (ret < 0) {
+			ERR("Failed to read capabilities from file: %d\n", ret);
+			return 1;
+		}
+		show_capabilities(&caps, stderr);
+		if (capabilities_burn(astribank, &eeprom_table, &caps, &key) < 0)
+			return 1;
+		if (file != stdin)
+			fclose(file);
+	} else {
+		/* print capabilities to stdout */
+		file = stdout;
+		if (filename) {
+			file = fopen(filename, "w");
+			if (file == NULL) {
+				ERR("Can't create file '%s'\n", filename);
+				return 1;
+			}
+		}
+		ret = write_to_file(&eeprom_table, &caps, &key, file);
+		if (ret < 0) {
+			ERR("Failed to write capabilities to file: %d\n", ret);
+			return 1;
+		}
+		if (file != stdout)
+			fclose(file);
+	}
+	mpp_exit(astribank);
+	return 0;
+}

Propchange: tools/trunk/xpp/astribank_allow.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_allow.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_allow.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_hexload.8
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_hexload.8?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_hexload.8 (added)
+++ tools/trunk/xpp/astribank_hexload.8 Thu Apr  2 15:56:42 2009
@@ -1,0 +1,66 @@
+.TH "ASTRIBANK_HEXLOAD" "8" "29 March 2009" "" ""
+
+.SH NAME
+astribank_tool \- Xorcom Astribank (xpp) firmware loader
+.SH SYNOPSIS
+.B astribank_tool -D \fIdevice-path\fR <\fB-F|-p\fR> [\fIoptions\fR] \fIhexfile\fR
+
+.B astribank_tool [-h]
+
+.SH DESCRIPTION
+.B astribank_hexload
+is a second-stage firmware loader for Xorcom Astribanks. Note that some 
+older models use fpga_load(8) instead.
+
+It is used to load a file in the Intel HEX format into a Xorcom
+Astribank. It can be used to load either an FPGA firmware or a PIC
+firmware. It is normally run by the script xpp_fxloader.
+
+.SH OPTIONS
+.B -D 
+.I device-path
+.RS
+Required. The device to read from/write to. On modern UDEV-based system
+this is usually /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR,
+where \fIbus_num\fR and \fIdevice_num\fR are the first two numbers in the
+output of lsusb(8).
+On older systems that use usbfs, it is usually
+/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
+.RE
+
+.B -F
+.RS
+The firmware to load is a FPGA firmware.
+.RE
+
+.B -p
+.RS
+The firmware to load is a PIC firmware.
+.RE
+
+.B -v
+.RS
+Increase verbosity. May be used multiple times.
+.RE
+
+.B -d \fImask\fR
+.RS
+Set debug mask to \fImask\fR. Default is 0, 0xFF is "everything".
+.RE
+
+.B -h
+.RS
+Displays usage message.
+.RE
+
+.SH SEE ALSO
+fxload(8), lsusb(8), astribank_tool(8), fpga_load(8)
+
+.SH AUTHOR
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com> .
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any 
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.

Propchange: tools/trunk/xpp/astribank_hexload.8
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_hexload.8
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_hexload.8
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_hexload.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_hexload.c?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_hexload.c (added)
+++ tools/trunk/xpp/astribank_hexload.c Thu Apr  2 15:56:42 2009
@@ -1,0 +1,201 @@
+/*
+ * Written by Oron Peled <oron at actcom.co.il>
+ * Copyright (C) 2008, Xorcom
+ *
+ * All rights reserved.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include <arpa/inet.h>
+#include "debug.h"
+#include "hexfile.h"
+#include "mpp_funcs.h"
+#include "pic_loader.h"
+#include "astribank_usb.h"
+
+#define	DBG_MASK	0x80
+#define	MAX_HEX_LINES	10000
+
+static char	*progname;
+
+static void usage()
+{
+	fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> hexfile...\n", progname);
+	fprintf(stderr, "\tOptions: {-F|-p}\n");
+	fprintf(stderr, "\t\t[-F]               # Load FPGA firmware\n");
+	fprintf(stderr, "\t\t[-p]               # Load PIC firmware\n");
+	fprintf(stderr, "\t\t[-v]               # Increase verbosity\n");
+	fprintf(stderr, "\t\t[-d mask]          # Debug mask (0xFF for everything)\n");
+	exit(1);
+}
+
+int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
+{
+	uint16_t	len;
+	uint16_t	offset_dummy;
+	uint8_t		*data;
+	int		ret;
+
+	assert(hexline);
+	assert(astribank);
+	if(hexline->d.content.header.tt != TT_DATA) {
+		DBG("Non data record type = %d\n", hexline->d.content.header.tt);
+		return 0;
+	}
+	len = hexline->d.content.header.ll;
+	offset_dummy = hexline->d.content.header.offset;
+	data = hexline->d.content.tt_data.data;
+	if((ret = mpp_send_seg(astribank, data, offset_dummy, len)) < 0) {
+		ERR("Failed FPGA send line: %d\n", ret);
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int load_fpga(struct astribank_device *astribank, const char *hexfile)
+{
+	struct hexdata		*hexdata = NULL;
+	int			finished = 0;
+	int			ret;
+	int			i;
+
+	if((hexdata  = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) {
+		perror(hexfile);
+		return -errno;
+	}
+	INFO("Loading FPGA firmware version %s\n", hexdata->version_info);
+#if 0
+	FILE		*fp;
+	if((fp = fopen("fpga_dump_new.txt", "w")) == NULL) {
+		perror("dump");
+		exit(1);
+	}
+#endif
+	if((ret = mpp_send_start(astribank, DEST_FPGA)) < 0) {
+		ERR("Failed FPGA send start: %d\n", ret);
+		return ret;
+	}
+	for(i = 0; i < hexdata->maxlines; i++) {
+		struct hexline	*hexline = hexdata->lines[i];
+
+		if(!hexline)
+			break;
+		if(finished) {
+			ERR("Extra data after End Of Data Record (line %d)\n", i);
+			return 0;
+		}
+		if(hexline->d.content.header.tt == TT_EOF) {
+			DBG("End of data\n");
+			finished = 1;
+			continue;
+		}
+		if((ret = handle_hexline(astribank, hexline)) < 0) {
+			ERR("Failed FPGA sending in lineno %d (ret=%d)\n", i, ret);;
+			return ret;
+		}
+	}
+	if((ret = mpp_send_end(astribank)) < 0) {
+		ERR("Failed FPGA send end: %d\n", ret);
+		return ret;
+	}
+#if 0
+	fclose(fp);
+#endif
+	free_hexdata(hexdata);
+	INFO("FPGA firmware loaded successfully\n");
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	char			*devpath = NULL;
+	struct astribank_device *astribank;
+	int			opt_fpga = 0;
+	int			opt_pic = 0;
+	const char		options[] = "vd:D:Fp";
+	int			iface_num;
+	int			ret;
+
+	progname = argv[0];
+	while (1) {
+		int	c;
+
+		c = getopt (argc, argv, options);
+		if (c == -1)
+			break;
+
+		switch (c) {
+			case 'D':
+				devpath = optarg;
+				break;
+			case 'F':
+				opt_fpga = 1;
+				break;
+			case 'p':
+				opt_pic = 1;
+				break;
+			case 'v':
+				verbose++;
+				break;
+			case 'd':
+				debug_mask = strtoul(optarg, NULL, 0);
+				break;
+			case 'h':
+			default:
+				ERR("Unknown option '%c'\n", c);
+				return 1;
+		}
+	}
+	if((opt_fpga ^ opt_pic) == 0) {
+		ERR("The -F and -p options are mutually exclusive.\n");
+		usage();
+	}
+	iface_num = (opt_fpga) ? 1 : 0;
+	if(opt_fpga) {
+		if(optind != argc - 1) {
+			ERR("The -F option requires exacly one hexfile argument\n");
+			usage();
+		}
+	}
+	if(!devpath) {
+		ERR("Missing device path.\n");
+		usage();
+	}
+	if((astribank = astribank_open(devpath, iface_num)) == NULL) {
+		ERR("Opening astribank failed\n");
+		return 1;
+	}
+	show_astribank_info(astribank);
+	if(opt_fpga) {
+		if(load_fpga(astribank, argv[optind]) < 0) {
+			ERR("Loading FPGA firmware failed\n");
+			return 1;
+		}
+	} else if(opt_pic) {
+		if((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) {
+			ERR("Loading PIC's failed\n");
+			return 1;
+		}
+	}
+	astribank_close(astribank, 0);
+	return 0;
+}

Propchange: tools/trunk/xpp/astribank_hexload.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_hexload.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_hexload.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_tool.8
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_tool.8?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_tool.8 (added)
+++ tools/trunk/xpp/astribank_tool.8 Thu Apr  2 15:56:42 2009
@@ -1,0 +1,79 @@
+.TH "ASTRIBANK_TOOL" "8" "29 March 2009" "" ""
+
+.SH NAME
+astribank_tool \- Xorcom Astribank (xpp) control tool
+.SH SYNOPSIS
+.B astribank_tool -D \fIdevice-path\fR [ options ]
+
+.B astribank_tool [-h]
+
+.SH DESCRIPTION
+.B astribank_tool
+is a tool to control the USB-level functionality of an Astribank.
+
+.SH OPTIONS
+.B -D 
+.I device-path
+.RS
+Required. The device to read from/write to. On modern UDEV-based system
+this is usually /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR,
+where \fIbus_num\fR and \fIdevice_num\fR are the first two numbers in the
+output of lsusb(8).
+On older systems that use usbfs, it is usually
+/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
+.RE
+
+.B -p \fInum\fR
+.RS
+Set the TwinStar port number. Either 0 or 1.
+
+(TODO: explain).
+.RE
+
+.B -r \fItype\fR
+.RS
+Reset the Astribank and renumerate its USB connection to power on product ID.
+
+Tyep can be: \fBhalf\fR or \fBfull\fR.
+
+(TODO: explain those).
+.RE
+
+.B -w 0|1
+.RS
+Enable (1) or disable (0) the TwinStar watchdog. When enabled, the
+Astribank will jump to the second port if this system is "not working"
+and the system on the second port is available.
+.RE
+
+.B -n
+.RS
+Renumerate the Astribank product number (e.g: from 1161 to 1162).
+.RE
+
+.B -v
+.RS
+Increase verbosity. May be used multiple times.
+.RE
+
+.B -d \fImask\fR
+.RS
+Set debug mask to \fImask\fR. Default is 0, 0xFF is "everything".
+.RE
+
+.B -h
+.RS
+Displays usage message.
+.RE
+
+.SH SEE ALSO
+fxload(8), lsusb(8), astribank_hextool(8)
+
+.SH AUTHOR
+This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com> .
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any 
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL.

Propchange: tools/trunk/xpp/astribank_tool.8
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_tool.8
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_tool.8
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_tool.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_tool.c?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_tool.c (added)
+++ tools/trunk/xpp/astribank_tool.c Thu Apr  2 15:56:42 2009
@@ -1,0 +1,202 @@
+/*
+ * Written by Oron Peled <oron at actcom.co.il>
+ * Copyright (C) 2008, Xorcom
+ *
+ * All rights reserved.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include <getopt.h>
+#include <arpa/inet.h>
+#include "mpp_funcs.h"
+#include "debug.h"
+
+#define	DBG_MASK	0x80
+
+static char	*progname;
+
+static void usage()
+{
+	fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev>\n", progname);
+	fprintf(stderr, "\tOptions: {-n|-r kind}\n");
+	fprintf(stderr, "\t\t[-n]               # Renumerate device\n");
+	fprintf(stderr, "\t\t[-r kind]          # Reset: kind = {half|full}\n");
+	fprintf(stderr, "\t\t[-p port]          # TwinStar: USB port number [0, 1]\n");
+	fprintf(stderr, "\t\t[-w (0|1)]         # TwinStar: Watchdog off or on guard\n");
+	fprintf(stderr, "\t\t[-v]               # Increase verbosity\n");
+	fprintf(stderr, "\t\t[-d mask]          # Debug mask (0xFF for everything)\n");
+	exit(1);
+}
+
+static int reset_kind(const char *arg)
+{
+	static const struct {
+		const char	*name;
+		int		type_code;
+	} reset_kinds[] = {
+		{ "half",	0 },
+		{ "full",	1 },
+	};
+	int	i;
+
+	for(i = 0; i < sizeof(reset_kinds)/sizeof(reset_kinds[0]); i++) {
+		if(strcasecmp(reset_kinds[i].name, arg) == 0)
+			return reset_kinds[i].type_code;
+	}
+	ERR("Uknown reset kind '%s'\n", arg);
+	return -1;
+}
+
+
+static int show_hardware(struct astribank_device *astribank)
+{
+	uint8_t	unit;
+	uint8_t	card_status;
+	uint8_t	card_type;
+	int	ret;
+	struct eeprom_table	eeprom_table;
+	struct capabilities	capabilities;
+	struct extrainfo	extrainfo;
+
+	show_astribank_info(astribank);
+	ret = mpp_caps_get(astribank, &eeprom_table, &capabilities, NULL);
+	if(ret < 0)
+		return ret;
+	show_eeprom(&eeprom_table, stdout);
+	show_astribank_status(astribank, stdout);
+	if(astribank->eeprom_type == EEPROM_TYPE_LARGE) {
+		show_capabilities(&capabilities, stdout);
+		if(STATUS_FPGA_LOADED(astribank->status)) {
+			for(unit = 0; unit < 4; unit++) {
+				ret = mpps_card_info(astribank, unit, &card_type, &card_status);
+				if(ret < 0)
+					return ret;
+				printf("CARD %d: type=%x.%x %s\n", unit,
+						((card_type >> 4) & 0xF), (card_type & 0xF),
+						((card_status & 0x1) ? "PIC" : "NOPIC"));
+			}
+		}
+		ret = mpp_extrainfo_get(astribank, &extrainfo);
+		if(ret < 0)
+			return ret;
+		show_extrainfo(&extrainfo, stdout);
+		if(CAP_EXTRA_TWINSTAR(&capabilities)) {
+			twinstar_show(astribank, stdout);
+		}
+	}
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	char			*devpath = NULL;
+	struct astribank_device *astribank;
+	const char		options[] = "vd:D:nr:p:w:";
+	int			opt_renumerate = 0;
+	char			*opt_port = NULL;
+	char			*opt_watchdog = NULL;
+	char			*opt_reset = NULL;
+	int			tws_portnum;
+	int			full_reset;
+	int			ret;
+
+	progname = argv[0];
+	while (1) {
+		int	c;
+
+		c = getopt (argc, argv, options);
+		if (c == -1)
+			break;
+
+		switch (c) {
+			case 'D':
+				devpath = optarg;
+				break;
+			case 'n':
+				opt_renumerate++;
+				break;
+			case 'p':
+				opt_port = optarg;
+				break;
+			case 'w':
+				opt_watchdog = optarg;
+				break;
+			case 'r':
+				opt_reset = optarg;
+				if((full_reset = reset_kind(opt_reset)) < 0)
+					usage();
+				break;
+			case 'v':
+				verbose++;
+				break;
+			case 'd':
+				debug_mask = strtoul(optarg, NULL, 0);
+				break;
+			case 'h':
+			default:
+				ERR("Unknown option '%c'\n", c);
+				usage();
+		}
+	}
+	if(!devpath) {
+		ERR("Missing device path\n");
+		usage();
+	}
+	DBG("Startup %s\n", devpath);
+	if((astribank = mpp_init(devpath)) == NULL) {
+		ERR("Failed initializing MPP\n");
+		return 1;
+	}
+	show_hardware(astribank);
+	if(opt_reset) {
+		if((ret = mpp_reset(astribank, full_reset)) < 0) {
+			ERR("%s Reseting astribank failed: %d\n",
+				(full_reset) ? "Full" : "Half", ret);
+		}
+	} else if(opt_renumerate) {
+		if((ret = mpp_renumerate(astribank)) < 0) {
+			ERR("Renumerating astribank failed: %d\n", ret);
+		}
+	} else if(opt_watchdog) {
+		int	watchdogstate = strtoul(opt_watchdog, NULL, 0);
+
+		INFO("TWINSTAR: Setting watchdog %s-guard\n",
+			(watchdogstate) ? "on" : "off");
+		if((ret = mpp_tws_setwatchdog(astribank, watchdogstate)) < 0) {
+			ERR("Failed to set watchdog to %d\n", watchdogstate);
+			return 1;
+		}
+	} else if(opt_port) {
+		int	new_portnum = strtoul(opt_port, NULL, 0);
+		char	*msg = (new_portnum == tws_portnum)
+					? " Same same, never mind..."
+					: "";
+
+		INFO("TWINSTAR: Setting portnum to %d.%s\n", new_portnum, msg);
+		if((ret = mpp_tws_setportnum(astribank, new_portnum)) < 0) {
+			ERR("Failed to set USB portnum to %d\n", new_portnum);
+			return 1;
+		}
+	}
+	mpp_exit(astribank);
+	return 0;
+}

Propchange: tools/trunk/xpp/astribank_tool.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_tool.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_tool.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_upgrade
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_upgrade?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_upgrade (added)
+++ tools/trunk/xpp/astribank_upgrade Thu Apr  2 15:56:42 2009
@@ -1,0 +1,150 @@
+#!/bin/bash
+
+# astribank_upgrade: force load Xorcom Astribank (XPP) USB firmware
+# A reduced version of xpp_fxloader for manual upgrades.
+#
+# Written by Oron Peled <oron at actcom.co.il>
+# Copyright (C) 2009 Xorcom
+#
+# All rights reserved.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+set -e
+
+# Make sure fxload is in the path:
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin"
+export PATH
+
+me=`basename $0`
+
+if [ -t 2 ]; then
+	LOGGER="logger -i -t '$me' -s"
+else
+	LOGGER="logger -i -t '$me'"
+fi
+
+USBFS_PREFIX=/proc/bus/usb
+DEVUSB_PREFIX=/dev/bus/usb
+USB_PREFIX=
+
+USB_FW="${USB_FW:-USB_FW.hex}"
+
+if [ "$USB_PREFIX" = '' ]; then
+	if [ -d "$DEVUSB_PREFIX" ]; then
+		USB_PREFIX=$DEVUSB_PREFIX
+	elif [ -r "$USBFS_PREFIX/devices" ]; then
+		USB_PREFIX=$USBFS_PREFIX
+	fi
+fi
+
+# With Kernels older that 2.6.10 it seems to be possible
+# to trigger a race condition by running fxload or fpga_load 
+# immediately after the detection of the device.
+KERNEL_HAS_USB_RACE=0
+case "`uname -r`" in 2.6.[89]*) KERNEL_HAS_USB_RACE=1;; esac
+sleep_if_race() {
+  if [ "$KERNEL_HAS_USB_RACE" = '1' ]; then
+    sleep 2
+  fi
+}
+
+find_dev() {
+  v_id=$1
+  p_id=$2
+  
+  lsusb | tr -d : | awk "/ ID $v_id$p_id/{printf \"$USB_PREFIX/%s/%s \",\$2,\$4}"
+}
+
+run_fxload() {
+  sleep_if_race
+  fxload -t fx2 $* 2>&1 1>/dev/null | $LOGGER
+  status=$PIPESTATUS
+  if [ $status != 0 ]; then
+    $LOGGER "fxload failed with status $status"
+    exit 55
+  fi
+}
+
+load_usb_fw() {
+  v_id=$1
+  p_id=$2
+  fw=$3
+  
+  devices=`find_dev $v_id $p_id`
+  for dev in $devices
+  do
+    ver=$(awk '/\$Id:/ { print $4 }' $FIRMWARE_DIR/$fw)
+    $LOGGER "USB Firmware $FIRMWARE_DIR/$fw (Version=$ver) into $dev"
+    run_fxload -D $dev -I $FIRMWARE_DIR/$fw || exit 1
+  done
+}
+
+numdevs() {
+  v_ids="$1"
+  p_ids="$2"
+
+  for v in $v_ids
+  do
+    (
+      for p in $p_ids
+      do
+        find_dev $v $p
+      done
+    )
+  done | wc -w
+}
+
+wait_renumeration() {
+  num="$1"
+  v_ids="$2"
+  p_ids="$3"
+
+  while
+    n=`numdevs "$v_ids" "$p_ids"`
+    [ "$num" -gt "$n" ]
+  do
+    echo -n "."
+    sleep 1
+  done
+  echo "Got all $num devices"
+}
+
+if [ "$#" -ne 1 ]; then
+	echo >&2 "Usage: $0 <firmware_directory>"
+	exit 1
+fi
+FIRMWARE_DIR="$1"
+[ -f "$FIRMWARE_DIR/$USB_FW" ] || {
+	echo >&2 "$0: Could not find '$FIRMWARE_DIR/$USB_FW'"
+	exit 1
+}
+numdevs=`numdevs e4e4 '11[3456][01]'`
+$LOGGER -- "--------- LOADING NEW USB FIRMWARE: ($1) [$numdevs devices]"
+load_usb_fw e4e4 1130 $USB_FW
+load_usb_fw e4e4 1140 $USB_FW
+load_usb_fw e4e4 1150 $USB_FW
+load_usb_fw e4e4 1160 $USB_FW
+load_usb_fw e4e4 1131 $USB_FW
+load_usb_fw e4e4 1141 $USB_FW
+load_usb_fw e4e4 1151 $USB_FW
+load_usb_fw e4e4 1161 $USB_FW
+load_usb_fw e4e4 1132 $USB_FW
+load_usb_fw e4e4 1142 $USB_FW
+load_usb_fw e4e4 1152 $USB_FW
+load_usb_fw e4e4 1162 $USB_FW
+wait_renumeration $numdevs e4e4 '11[3456]1'
+$LOGGER -- "--------- NEW USB FIRMWARE IS LOADED"

Propchange: tools/trunk/xpp/astribank_upgrade
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/astribank_upgrade
------------------------------------------------------------------------------
    svn:executable = *

Propchange: tools/trunk/xpp/astribank_upgrade
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/astribank_upgrade
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: tools/trunk/xpp/astribank_usb.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/xpp/astribank_usb.c?view=auto&rev=6313
==============================================================================
--- tools/trunk/xpp/astribank_usb.c (added)
+++ tools/trunk/xpp/astribank_usb.c Thu Apr  2 15:56:42 2009
@@ -1,0 +1,536 @@
+/*
+ * Written by Oron Peled <oron at actcom.co.il>
+ * Copyright (C) 2008, Xorcom
+ *
+ * All rights reserved.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#define	_GNU_SOURCE	/* for memrchr() */
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <syslog.h>
+#include <arpa/inet.h>
+#include "astribank_usb.h"
+#include "debug.h"
+
+static const char rcsid[] = "$Id$";
+
+#define	DBG_MASK	0x01
+#define	TIMEOUT	500
+
+#define	TYPE_ENTRY(t,ni,n,ne,out,in,...)	\
+	[t] = {					\
+		.type_code = (t),		\
+		.num_interfaces = (ni),		\
+		.my_interface_num = (n),	\
+		.num_endpoints = (ne),		\
+		.my_ep_in = (in),		\
+		.my_ep_out = (out),		\
+		.name = #t,			\
+		.endpoints = { __VA_ARGS__ },	\
+		}
+
+static const struct interface_type interface_types[] = {
+	TYPE_ENTRY(USB_11xx,		1, 0, 4, MP_EP_OUT, MP_EP_IN,
+		XPP_EP_OUT,
+		MP_EP_OUT,
+		XPP_EP_IN,
+		MP_EP_IN),

[... 4431 lines stripped ...]



More information about the svn-commits mailing list