[dahdi-commits] dahdi/tools.git branch "master" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Nov 5 02:09:32 CST 2015


branch "master" has been updated
       via  42850dba3555005315fecac37b2e3c6ed9af73a6 (commit)
       via  06ae8473d7e2e7a58cedc902129761ceb1c0479d (commit)
       via  dbb5ba6db63b1fe46ff35ec11b813970c459c6d3 (commit)
       via  2097f1adc56c34aa855d6859c704ac8075c4218a (commit)
       via  d02361e99fc24fb60e63060dab06ed2bda6d61c9 (commit)
       via  77a3d8b0a7548e9231c2aa0b14a41b6835049040 (commit)
       via  bd49fc9d9577a0a2a27e9f3e25a463b2a222e7e3 (commit)
       via  0e6b068e8902eb6a96017e37b71bbe1a934a105a (commit)
       via  9c61e40187a6ad8a7d76432dd479336435cc388b (commit)
       via  5ee15a2337607cfd9867292acb404850fec895ea (commit)
       via  01faf597d6faf11f91a1772913e95c277eb121a8 (commit)
       via  48b25e849f060abcbb8bf67906c4918d7c6c2b71 (commit)
       via  d239b8dc4dd4445c0609990153d699f514ece604 (commit)
       via  4676ad6671c7182c9b556dc3174529153d97b1dd (commit)
       via  b47152670012f0d2d11bd4bde2d9397121f797a3 (commit)
      from  855772135cc92a87ed3b26afc03011cf36aff939 (commit)

Summary of changes:
 .gitignore                                         |    8 +
 Makefile.legacy                                    |    4 +-
 build_tools/make_version                           |    2 +
 configure.ac                                       |   63 +-
 xpp/Makefile.am                                    |   65 +-
 xpp/astribank.c                                    |  177 ++++
 xpp/astribank.h                                    |   33 +
 xpp/astribank_allow.c                              |   47 +-
 xpp/astribank_hexload.c                            |   64 +-
 xpp/astribank_license.c                            |    2 +-
 xpp/astribank_license.h                            |    2 +-
 xpp/astribank_tool.c                               |  119 +--
 xpp/astribank_usb.c                                |  276 ------
 xpp/astribank_usb.h                                |  113 ---
 xpp/echo_loader.c                                  |   59 +-
 xpp/echo_loader.h                                  |    8 +-
 xpp/mpp.h                                          |  202 -----
 xpp/mpptalk.c                                      |  771 ++++++++++------
 xpp/mpptalk.h                                      |  188 ++--
 xpp/mpptalk_defs.h                                 |  113 ---
 xpp/oct612x/Makefile.am                            |    3 +
 xpp/pic_loader.c                                   |   47 +-
 xpp/pic_loader.h                                   |    6 +-
 xpp/xpp.rules                                      |    1 +
 xpp/xtalk/Makefile.am                              |   91 ++
 xpp/xtalk/debug.c                                  |    3 +-
 xpp/xtalk/include/xtalk/api_defs.h                 |   38 +
 xpp/xtalk/{ => include}/xtalk/debug.h              |   11 +-
 .../xtalk/firmware_defs.h}                         |   17 +-
 xpp/xtalk/{xtalk.h => include/xtalk/proto.h}       |   68 +-
 xpp/xtalk/include/xtalk/proto_raw.h                |   76 ++
 xpp/xtalk/include/xtalk/proto_sync.h               |   75 ++
 xpp/xtalk/include/xtalk/xlist.h                    |   32 +
 xpp/xtalk/include/xtalk/xtalk_iface.h              |   19 +
 xpp/xtalk/include/xtalk/xusb.h                     |  115 +++
 xpp/xtalk/include/xtalk/xusb_iface.h               |   43 +
 xpp/xtalk/xlist.c                                  |   14 +-
 xpp/xtalk/xlist_test.c                             |   73 ++
 xpp/xtalk/xtalk-xusb.c                             |   70 ++
 xpp/xtalk/xtalk.c                                  |  497 -----------
 xpp/xtalk/xtalk_base.c                             |  350 ++++++++
 xpp/xtalk/xtalk_base.h                             |   73 ++
 xpp/xtalk/xtalk_raw.c                              |  221 +++++
 xpp/xtalk/xtalk_raw_test.c                         |  207 +++++
 xpp/xtalk/xtalk_send.8                             |   49 +
 xpp/xtalk/xtalk_send.c                             |  220 +++++
 xpp/xtalk/xtalk_sync.c                             |  290 ++++++
 xpp/xtalk/xtalk_test.c                             |  199 +++++
 xpp/xtalk/xusb.c                                   |  943 --------------------
 xpp/xtalk/xusb.h                                   |  102 ---
 xpp/xtalk/xusb_common.c                            |  434 +++++++++
 xpp/xtalk/xusb_common.h                            |  104 +++
 xpp/xtalk/xusb_libusb.c                            |  843 +++++++++++++++++
 xpp/xtalk/xusb_libusbx.c                           |  826 +++++++++++++++++
 xpp/xtalk/xusb_test.c                              |  124 +++
 xpp/xtalk/xusb_test_bypath.c                       |   76 ++
 56 files changed, 5819 insertions(+), 2857 deletions(-)
 create mode 100644 xpp/astribank.c
 create mode 100644 xpp/astribank.h
 delete mode 100644 xpp/astribank_usb.c
 delete mode 100644 xpp/astribank_usb.h
 delete mode 100644 xpp/mpp.h
 delete mode 100644 xpp/mpptalk_defs.h
 create mode 100644 xpp/xtalk/Makefile.am
 create mode 100644 xpp/xtalk/include/xtalk/api_defs.h
 copy xpp/xtalk/{ => include}/xtalk/debug.h (84%)
 rename xpp/xtalk/{xtalk_defs.h => include/xtalk/firmware_defs.h} (80%)
 rename xpp/xtalk/{xtalk.h => include/xtalk/proto.h} (70%)
 create mode 100644 xpp/xtalk/include/xtalk/proto_raw.h
 create mode 100644 xpp/xtalk/include/xtalk/proto_sync.h
 create mode 100644 xpp/xtalk/include/xtalk/xlist.h
 create mode 100644 xpp/xtalk/include/xtalk/xtalk_iface.h
 create mode 100644 xpp/xtalk/include/xtalk/xusb.h
 create mode 100644 xpp/xtalk/include/xtalk/xusb_iface.h
 create mode 100644 xpp/xtalk/xlist_test.c
 create mode 100644 xpp/xtalk/xtalk-xusb.c
 delete mode 100644 xpp/xtalk/xtalk.c
 create mode 100644 xpp/xtalk/xtalk_base.c
 create mode 100644 xpp/xtalk/xtalk_base.h
 create mode 100644 xpp/xtalk/xtalk_raw.c
 create mode 100644 xpp/xtalk/xtalk_raw_test.c
 create mode 100644 xpp/xtalk/xtalk_send.8
 create mode 100644 xpp/xtalk/xtalk_send.c
 create mode 100644 xpp/xtalk/xtalk_sync.c
 create mode 100644 xpp/xtalk/xtalk_test.c
 delete mode 100644 xpp/xtalk/xusb.c
 delete mode 100644 xpp/xtalk/xusb.h
 create mode 100644 xpp/xtalk/xusb_common.c
 create mode 100644 xpp/xtalk/xusb_common.h
 create mode 100644 xpp/xtalk/xusb_libusb.c
 create mode 100644 xpp/xtalk/xusb_libusbx.c
 create mode 100644 xpp/xtalk/xusb_test.c
 create mode 100644 xpp/xtalk/xusb_test_bypath.c


- Log -----------------------------------------------------------------
commit 42850dba3555005315fecac37b2e3c6ed9af73a6
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon May 11 14:10:02 2015 +0300

    xpp: refactor manual pages out of conditionals
    
    * So they are always included in 'make dist' even if PBX_USB is false.
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/Makefile.am b/xpp/Makefile.am
index 32aa3ac..369e1d2 100644
--- a/xpp/Makefile.am
+++ b/xpp/Makefile.am
@@ -20,6 +20,14 @@ GLOBAL_CFLAGS	+= \
 	-Wformat=2
 endif
 
+man_pages	= \
+		astribank_tool.8 \
+		astribank_hexload.8 \
+		astribank_allow.8 \
+		astribank_is_starting.8
+
+man_MANS	+= $(man_pages)
+
 if PERL
 SUBDIRS		+= perl_modules
 
@@ -141,13 +149,6 @@ astribank_allow_CFLAGS		= $(GLOBAL_CFLAGS)
 astribank_allow_LDFLAGS		= $(USB_LIBS)
 astribank_allow_LDADD		= libastribank.la
 
-man_pages	= \
-		astribank_tool.8 \
-		astribank_hexload.8 \
-		astribank_allow.8 \
-		astribank_is_starting.8
-
-man_MANS	+= $(man_pages)
 endif
 
 EXTRA_DIST	= \

commit 06ae8473d7e2e7a58cedc902129761ceb1c0479d
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon May 11 14:08:51 2015 +0300

    xpp: Move astribank_license to libastribank
    
    * So it's available to all utilities
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/Makefile.am b/xpp/Makefile.am
index ef203ff..32aa3ac 100644
--- a/xpp/Makefile.am
+++ b/xpp/Makefile.am
@@ -85,6 +85,8 @@ libastribank_la_SOURCES	= \
 		astribank.h	\
 		mpptalk.c	\
 		mpptalk.h	\
+		astribank_license.c	\
+		astribank_license.h	\
 		#
 
 libastribank_la_CFLAGS		= $(GLOBAL_CFLAGS)
@@ -135,12 +137,6 @@ astribank_hexload_LDADD		= \
 		oct612x/liboctasic.la	\
 		#
 
-astribank_allow_SOURCES		= \
-			astribank_allow.c	\
-			astribank_license.c	\
-			astribank_license.h	\
-			#
-
 astribank_allow_CFLAGS		= $(GLOBAL_CFLAGS)
 astribank_allow_LDFLAGS		= $(USB_LIBS)
 astribank_allow_LDADD		= libastribank.la

commit dbb5ba6db63b1fe46ff35ec11b813970c459c6d3
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon Dec 22 20:32:33 2014 +0200

    xpp: allow XTALK_OPTIONS from a file
    
    * The file is defined as XTALK_OPTIONS_FILE (/etc/dahdi/xpp.conf):
      - Lines beginning with '#' are skipped.
      - Line beginning with "XTALK_OPTIONS" are used.
      - Anything after whitespaces (with optional "=" characters) is part
        of the value.
    
    * An environment variable named "XTALK_OPTIONS" may override file contents.
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/xtalk/Makefile.am b/xpp/xtalk/Makefile.am
index f719627..3cbdaa2 100644
--- a/xpp/xtalk/Makefile.am
+++ b/xpp/xtalk/Makefile.am
@@ -1,5 +1,11 @@
 VISIBILITY_DEFS		= -DXTALK_DLL -DXTALK_DLL_EXPORTS
-COMMON_CFLAGS		= -Wall -Wno-unknown-pragmas -Werror $(VISIBILITY_DEFS) $(CFLAG_VISIBILITY)
+COMMON_CFLAGS		= \
+		-Wall \
+		-Wno-unknown-pragmas \
+		-Werror \
+		$(VISIBILITY_DEFS) \
+		$(CFLAG_VISIBILITY)
+
 AM_CFLAGS		= $(COMMON_CFLAGS)
 
 
@@ -35,7 +41,13 @@ dist_noinst_HEADERS	= \
 
 man_MANS		= xtalk_send.8
 
-libxtalk_la_CFLAGS	= $(COMMON_CFLAGS) -I$(srcdir)/include -I$(srcdir) $(USB_CFLAGS)
+libxtalk_la_CFLAGS	= \
+		$(COMMON_CFLAGS) \
+		-I$(srcdir)/include \
+		-I$(srcdir) \
+		$(USB_CFLAGS) \
+		-DXTALK_OPTIONS_FILE=\"/etc/dahdi/xpp.conf\"
+
 libxtalk_la_LDFLAGS	= #
 libxtalk_la_LIBADD	= $(USB_LIBS)
 libxtalk_la_SOURCES	= \
diff --git a/xpp/xtalk/xusb_common.c b/xpp/xtalk/xusb_common.c
index 125f735..e5d4bbd 100644
--- a/xpp/xtalk/xusb_common.c
+++ b/xpp/xtalk/xusb_common.c
@@ -1,5 +1,6 @@
 #define	_GNU_SOURCE	/* for memrchr() */
 #include <assert.h>
+#include <ctype.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -360,16 +361,66 @@ int xtalk_option_use_clear_halt(void)
 	return use_clear_halt;
 }
 
+static void chomp(char *buf)
+{
+	char *p;
+	int len;
+
+	if (!buf)
+		return;
+	len = strlen(buf);
+	for (p = buf + len - 1; p >= buf && isspace(*p); p--)
+		*p = '\0';
+}
+
+static const char *OPTION_VAR = "XTALK_OPTIONS";
+
+/* Caller should free the returned string if it is not NULL */
+static char *read_options(const char *fname)
+{
+	FILE *fp;
+	char buf[BUFSIZ];
+	char *p;
+	char *ret_buf;
+
+	fp = fopen(fname, "r");
+	if (!fp) {
+		DBG("Failed opening '$fname': %s\n", strerror(errno));
+		return NULL;
+	}
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
+		chomp(buf);
+		if (buf[0] == '\0' || buf[0] == '#')
+			continue;
+		if (strncmp(buf, OPTION_VAR, strlen(OPTION_VAR)) != 0)
+			continue;
+		/* fprintf(stderr, "INPUT> '%s'\n", p); */
+		p = buf + strlen(OPTION_VAR);
+		while (*p && (isspace(*p) || *p == '='))
+			p++;
+		ret_buf = malloc(sizeof(buf));
+		strcpy(ret_buf, p); /* Cannot overflow */
+		return ret_buf;
+	}
+	fclose(fp);
+	return NULL;
+}
+
 int xtalk_parse_options(void)
 {
 	char *xtalk_options;
 	char *saveptr;
 	char *token;
 	int ret;
+	int free_options = 0;
 
 	xtalk_options = getenv("XTALK_OPTIONS");
-	if (!xtalk_options)
-		return 0;
+	if (!xtalk_options) {
+		xtalk_options = read_options(XTALK_OPTIONS_FILE);
+		if (!xtalk_options)
+			return 0;
+		free_options = 1;
+	}
 	token = strtok_r(xtalk_options, " \t", &saveptr);
 	while (token) {
 		ret = xtalk_one_option(token);
@@ -377,5 +428,7 @@ int xtalk_parse_options(void)
 			return ret;
 		token = strtok_r(NULL, " \t", &saveptr);
 	}
+	if (free_options)
+		free(xtalk_options);
 	return 0;
 }

commit 2097f1adc56c34aa855d6859c704ac8075c4218a
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon Dec 22 14:06:25 2014 +0000

    configure.ac: xpp: now libusbx is the default
    
    * Fallback to old libusb-0.1 if libusbx isn't found.
    * Can force either: --{with,without}-{libusb,libusbx}
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/configure.ac b/configure.ac
index 74f1f0b..9dc008a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,7 +194,7 @@ AC_ARG_WITH([libusb],
 
 # LIBUSBX tests
 have_libusbx=
-AS_IF([test "$with_libusbx" = "yes"],
+AS_IF([test "$with_libusbx" != "no"],
 	[PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
 		[AC_CHECK_LIB([usb-1.0], [libusb_error_name],
 			[

commit d02361e99fc24fb60e63060dab06ed2bda6d61c9
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Sun Dec 21 11:26:29 2014 -0500

    xpp: strict compilation flags in oct612x/
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/oct612x/Makefile.am b/xpp/oct612x/Makefile.am
index 534e39c..78ec483 100644
--- a/xpp/oct612x/Makefile.am
+++ b/xpp/oct612x/Makefile.am
@@ -1,3 +1,5 @@
+GLOBAL_CFLAGS	= -Wall -Werror
+
 OCTASIC_DEFINES	= \
 	-DPTR_TYPE=uint32_t	\
 	-DcOCT6100_INTERNAL_SUPER_ARRAY_SIZE=1024	\
@@ -84,6 +86,7 @@ noinst_HEADERS	= \
 		#
 
 liboctasic_la_CFLAGS	= \
+	$(GLOBAL_CFLAGS) \
 	$(OCTASIC_DEFINES) \
 	$(OCTASIC_CFLAGS)
 

commit 77a3d8b0a7548e9231c2aa0b14a41b6835049040
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon Dec 15 11:15:28 2014 -0500

    xpp: don't use USB "clear-halt" by default
    
    * Problematic with USB3 controllers
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/xtalk/xusb_common.c b/xpp/xtalk/xusb_common.c
index bccfd39..125f735 100644
--- a/xpp/xtalk/xusb_common.c
+++ b/xpp/xtalk/xusb_common.c
@@ -339,7 +339,7 @@ int xusb_flushread(struct xusb_iface *iface)
 	return 0;
 }
 
-static int use_clear_halt = 1;
+static int use_clear_halt = 0;
 
 static int xtalk_one_option(const char *option_string)
 {

commit bd49fc9d9577a0a2a27e9f3e25a463b2a222e7e3
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon Dec 15 11:14:21 2014 -0500

    xpp: xtalk -- no private status range
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/xtalk/xtalk_base.c b/xpp/xtalk/xtalk_base.c
index ee9e462..bbf5640 100644
--- a/xpp/xtalk/xtalk_base.c
+++ b/xpp/xtalk/xtalk_base.c
@@ -117,25 +117,17 @@ int xtalk_set_protocol(struct xtalk_base *xtalk_base,
 
 		stat_msg = (xproto) ? xproto->ack_statuses[i] : NULL;
 		if (stat_msg) {
-			if (!IS_PRIVATE_OP(i)) {
-				ERR("Bad status=0x%X "
-					"(should be in the range [0x%X-0x%X]\n",
-					i, PRIVATE_OP_FIRST, PRIVATE_OP_LAST);
-				return -EINVAL;
-			}
 			xtalk_base->xproto.ack_statuses[i] = stat_msg;
 			DBG("private: status=0x%X (%s)\n", i, stat_msg);
 		} else {
-			if (!IS_PRIVATE_OP(i)) {
-				const char	*stat_msg;
-
-				xtalk_base->xproto.ack_statuses[i] =
-					xproto_base->ack_statuses[i];
-				stat_msg = xtalk_base->xproto.ack_statuses[i];
-				if (stat_msg)
-					DBG("global: status=0x%X (%s)\n",
-						i, stat_msg);
-			}
+			const char	*global_msg;
+
+			xtalk_base->xproto.ack_statuses[i] =
+				xproto_base->ack_statuses[i];
+			global_msg = xtalk_base->xproto.ack_statuses[i];
+			if (global_msg)
+				DBG("global: status=0x%X (%s)\n",
+						i, global_msg);
 		}
 	}
 	xtalk_base->xproto.name = protoname;

commit 0e6b068e8902eb6a96017e37b71bbe1a934a105a
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Sun Dec 21 14:58:03 2014 -0500

    xpp: migrate everything to libxtalk
    
     * Build new libxtalk as local convenience library
     * Have new mpptalk.[ch] and astribank.[ch] wrap the new API
     * Modify all tools to use the new API
    
    Signed-off-by: Oron Peled <oron.peled at xorcom.com>
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/Makefile.am b/xpp/Makefile.am
index e6fb290..ef203ff 100644
--- a/xpp/Makefile.am
+++ b/xpp/Makefile.am
@@ -8,7 +8,7 @@ man_MANS	=
 
 # FIXME: try to improve code, so we can use $(PEDANTIC)
 #PEDANTIC	= -ansi -pedantic -std=c99
-GLOBAL_CFLAGS	= -I$(srcdir) -I$(srcdir)/xtalk $(PEDANTIC)
+GLOBAL_CFLAGS	= -I$(srcdir) -I$(srcdir)/xtalk/include $(PEDANTIC) -Wall
 
 if DAHDI_DEVMODE
 GLOBAL_CFLAGS	+= \
@@ -81,24 +81,14 @@ endif
 noinst_LTLIBRARIES	= libastribank.la libecholoader.la libhexfile.la
 
 libastribank_la_SOURCES	= \
-		astribank_usb.c	\
-		astribank_usb.h	\
+		astribank.c	\
+		astribank.h	\
 		mpptalk.c	\
 		mpptalk.h	\
-		mpp.h	\
-		mpptalk_defs.h	\
-		xtalk/debug.c	\
-		xtalk/debug.h	\
-		xtalk/xlist.c	\
-		xtalk/xlist.h	\
-		xtalk/xtalk.c	\
-		xtalk/xtalk.h	\
-		xtalk/xtalk_defs.h	\
-		xtalk/xusb.c	\
-		xtalk/xusb.h	\
 		#
 
 libastribank_la_CFLAGS		= $(GLOBAL_CFLAGS)
+libastribank_la_LIBADD		= xtalk/libxtalk.la
 
 if USE_OCTASIC
 libecholoader_la_SOURCES	= \
diff --git a/xpp/astribank.c b/xpp/astribank.c
new file mode 100644
index 0000000..2775138
--- /dev/null
+++ b/xpp/astribank.c
@@ -0,0 +1,177 @@
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <xtalk/debug.h>
+#include <xtalk/xusb.h>
+#include "mpptalk.h"
+#include "astribank.h"
+
+#define	DBG_MASK	0x08
+
+struct astribank {
+        struct xusb_device      *xusb_device;
+	struct xusb_iface	*xpp_iface;
+	struct xusb_iface	*mpp_iface;
+        struct mpp_device       *mpp;
+	char *path;
+};
+
+
+struct astribank *astribank_new(const char *path)
+{
+	struct astribank *ab;
+
+	ab = calloc(sizeof(*ab), 1);
+	if (!ab) {
+		ERR("%s: Failed allocating Astribank device\n", path);
+		goto err;
+	}
+	ab->xusb_device = xusb_find_bypath(path);
+	if (!ab->xusb_device) {
+		ERR("%s: Cannot find Astribank\n", path);
+		goto err;
+	}
+	ab->path = strdup(path);
+	if (!ab->path) {
+		ERR("%s: Failed allocating Astribank path\n", path);
+		goto err;
+	}
+	return ab;
+err:
+	astribank_destroy(ab);
+	return NULL;
+}
+
+void astribank_destroy(struct astribank *ab)
+{
+	if (ab) {
+		if (ab->path)
+			free(ab->path);
+		if (ab->xpp_iface)
+			xusb_release(ab->xpp_iface);
+		if (ab->mpp) {
+			mpp_delete(ab->mpp); /* this also closes the underlying xusb */
+			ab->mpp = NULL;
+		}
+		if (ab->xusb_device) {
+			xusb_destroy(ab->xusb_device);
+			ab->xusb_device = NULL;
+		}
+		free(ab);
+		ab = NULL;
+	}
+}
+
+struct xusb_iface *astribank_xpp_open(struct astribank *ab)
+{
+	int ret;
+
+        ret = xusb_claim(ab->xusb_device, 0, &ab->xpp_iface);
+        if (ret < 0) {
+		ERR("%s: Cannot claim XPP interface\n", ab->path);
+		goto err;
+        }
+	DBG("%s: Claimed Astribank XPP interface\n", ab->path);
+	return ab->xpp_iface;
+err:
+	if (ab->xpp_iface)
+		xusb_release(ab->xpp_iface);
+	return NULL;
+}
+
+struct mpp_device *astribank_mpp_open(struct astribank *ab)
+{
+	int ret;
+
+	ret = xusb_claim(ab->xusb_device, 1, &ab->mpp_iface);
+	if (ret < 0) {
+		ERR("%s: Cannot claim MPP interface\n", ab->path);
+		goto err;
+	}
+	DBG("%s: Claimed Astribank MPP interface\n", ab->path);
+	ab->mpp = mpp_new(ab->mpp_iface);
+	if (!ab->mpp) {
+		ERR("Failed initializing MPP protocol\n");
+		goto err;
+	}
+	ret = mpp_status_query(ab->mpp);
+	if (ret < 0) {
+		ERR("status query failed (ret=%d)\n", ret);
+		goto err;
+	}
+	return ab->mpp;
+err:
+	if (ab->mpp) {
+		mpp_delete(ab->mpp); /* this also closes the underlying xusb */
+		ab->mpp = NULL;
+	}
+	return NULL;
+}
+
+struct xusb_device *xusb_dev_of_astribank(const struct astribank *ab)
+{
+	assert(ab->xusb_device);
+	return ab->xusb_device;
+}
+
+const char *astribank_devpath(const struct astribank *ab)
+{
+	return xusb_devpath(ab->xusb_device);
+}
+
+const char *astribank_serial(const struct astribank *ab)
+{
+	return xusb_serial(ab->xusb_device);
+}
+
+void show_astribank_info(const struct astribank *ab)
+{
+	struct xusb_device *xusb_device;
+
+	assert(ab != NULL);
+	xusb_device = ab->xusb_device;
+	assert(xusb_device != NULL);
+	if(verbose <= LOG_INFO) {
+		xusb_showinfo(xusb_device);
+	} else {
+		const struct xusb_spec  *spec;
+
+		spec = xusb_spec(xusb_device);
+		printf("USB    Bus/Device:    [%s]\n", xusb_devpath(xusb_device));
+		printf("USB    Firmware Type: [%s]\n", spec->name);
+		printf("USB    iSerialNumber: [%s]\n", xusb_serial(xusb_device));
+		printf("USB    iManufacturer: [%s]\n", xusb_manufacturer(xusb_device));
+		printf("USB    iProduct:      [%s]\n", xusb_product(xusb_device));
+	}
+}
+
+int astribank_send(struct astribank *ab, int interface_num, const char *buf, int len, int timeout)
+{
+	struct xusb_iface *iface;
+
+	if (interface_num == 0)
+		iface = ab->xpp_iface;
+	else if (interface_num == 1)
+		iface = ab->mpp_iface;
+	else {
+		ERR("Unknown interface number (%d)\n", interface_num);
+		return -EINVAL;
+	}
+	return xusb_send(iface, buf, len, timeout);
+}
+
+int astribank_recv(struct astribank *ab, int interface_num, char *buf, size_t len, int timeout)
+{
+	struct xusb_iface *iface;
+
+	if (interface_num == 0)
+		iface = ab->xpp_iface;
+	else if (interface_num == 1)
+		iface = ab->mpp_iface;
+	else {
+		ERR("Unknown interface number (%d)\n", interface_num);
+		return -EINVAL;
+	}
+	return xusb_recv(iface, buf, len, timeout);
+}
diff --git a/xpp/astribank.h b/xpp/astribank.h
new file mode 100644
index 0000000..a75513a
--- /dev/null
+++ b/xpp/astribank.h
@@ -0,0 +1,33 @@
+#ifndef	ASTRIBANK_H
+#define	ASTRIBANK_H
+
+#include <mpptalk.h>
+
+struct astribank *astribank_new(const char *path);
+void astribank_destroy(struct astribank *ab);
+void show_astribank_info(const struct astribank *ab);
+
+struct xusb_iface *astribank_xpp_open(struct astribank *ab);
+struct mpp_device *astribank_mpp_open(struct astribank *ab);
+
+struct xusb_device *xusb_dev_of_astribank(const struct astribank *ab);
+const char *astribank_devpath(const struct astribank *ab);
+const char *astribank_serial(const struct astribank *ab);
+
+int astribank_send(struct astribank *ab, int interface_num, const char *buf, int len, int timeout);
+int astribank_recv(struct astribank *ab, int interface_num, char *buf, size_t len, int timeout);
+
+
+#define AB_REPORT(report_type, astribank, fmt, ...) \
+	report_type("%s [%s]: " fmt, \
+		astribank_devpath(astribank), \
+		astribank_serial(astribank), \
+		## __VA_ARGS__)
+
+#define AB_INFO(astribank, fmt, ...) \
+		AB_REPORT(INFO, astribank, fmt, ## __VA_ARGS__)
+
+#define AB_ERR(astribank, fmt, ...) \
+		AB_REPORT(ERR, astribank, fmt, ## __VA_ARGS__)
+
+#endif	/* ASTRIBANK_H */
diff --git a/xpp/astribank_allow.c b/xpp/astribank_allow.c
index 8f1ea92..dd8d9d3 100644
--- a/xpp/astribank_allow.c
+++ b/xpp/astribank_allow.c
@@ -31,9 +31,9 @@
 #include <sys/types.h>
 #include <arpa/inet.h>
 #include <ctype.h>
-#include "mpp.h"
+#include <xtalk/debug.h>
 #include "mpptalk.h"
-#include <debug.h>
+#include "astribank.h"
 #include "astribank_license.h"
 
 static const char rcsid[] = "$Id$";
@@ -55,28 +55,11 @@ static void usage()
 	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;
-}
-
 int main(int argc, char *argv[])
 {
 	char			*devpath = NULL;
-	struct astribank_device *astribank;
+	struct astribank *astribank;
+	struct mpp_device *mpp;
 	struct eeprom_table	eeprom_table;
 	struct capabilities	caps;
 	struct capkey		key;
@@ -127,16 +110,19 @@ int main(int argc, char *argv[])
 		usage();
 	}
 	DBG("Startup %s\n", devpath);
-	if((astribank = mpp_init(devpath, 1)) == NULL) {
-		ERR("Failed initializing MPP\n");
+	astribank = astribank_new(devpath);
+	if(!astribank) {
+		ERR("Failed initializing Astribank\n");
 		return 1;
 	}
-	if(astribank->eeprom_type != EEPROM_TYPE_LARGE) {
+	mpp = astribank_mpp_open(astribank);
+	ret = mpp_eeprom_type(mpp);
+	if(ret != EEPROM_TYPE_LARGE) {
 		ERR("Cannot use this program with astribank EEPROM type %d (need %d)\n",
-			astribank->eeprom_type, EEPROM_TYPE_LARGE);
+			ret, EEPROM_TYPE_LARGE);
 		return 1;
 	}
-	ret = mpp_caps_get(astribank, &eeprom_table, &caps, &key);
+	ret = mpp_caps_get(mpp, &eeprom_table, &caps, &key);
 	if(ret < 0) {
 		ERR("Failed to get original capabilities: %d\n", ret);
 		return 1;
@@ -158,8 +144,13 @@ int main(int argc, char *argv[])
 			return 1;
 		}
 		show_capabilities(&caps, stderr);
-		if (capabilities_burn(astribank, &eeprom_table, &caps, &key) < 0)
+		INFO("Burning capabilities\n");
+		ret = mpp_caps_set(mpp, &eeprom_table, &caps, &key);
+		if(ret < 0) {
+			ERR("Capabilities burning failed: %d\n", ret);
 			return 1;
+		}
+		INFO("Done\n");
 		if (file != stdin)
 			fclose(file);
 	} else {
@@ -180,6 +171,6 @@ int main(int argc, char *argv[])
 		if (file != stdout)
 			fclose(file);
 	}
-	mpp_exit(astribank);
+	astribank_destroy(astribank);
 	return 0;
 }
diff --git a/xpp/astribank_hexload.c b/xpp/astribank_hexload.c
index ffc158a..c170968 100644
--- a/xpp/astribank_hexload.c
+++ b/xpp/astribank_hexload.c
@@ -28,13 +28,14 @@
 #include <errno.h>
 #include <assert.h>
 #include <arpa/inet.h>
-#include <debug.h>
+#include <autoconfig.h>
+#include <xtalk/debug.h>
+#include <xtalk/xusb.h>
 #include "hexfile.h"
 #include "mpptalk.h"
+#include "astribank.h"
 #include "pic_loader.h"
 #include "echo_loader.h"
-#include "astribank_usb.h"
-#include "../autoconfig.h"
 
 #define	DBG_MASK	0x80
 #define	MAX_HEX_LINES	64000
@@ -61,7 +62,7 @@ static void usage()
 	exit(1);
 }
 
-int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
+int handle_hexline(struct mpp_device *mpp, struct hexline *hexline)
 {
 	uint16_t	len;
 	uint16_t	offset_dummy;
@@ -69,7 +70,7 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
 	int		ret;
 
 	assert(hexline);
-	assert(astribank);
+	assert(mpp);
 	if(hexline->d.content.header.tt != TT_DATA) {
 		DBG("Non data record type = %d\n", hexline->d.content.header.tt);
 		return 0;
@@ -77,7 +78,7 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
 	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) {
+	if((ret = mpp_send_seg(mpp, data, offset_dummy, len)) < 0) {
 		ERR("Failed hexfile send line: %d\n", ret);
 		return -EINVAL;
 	}
@@ -100,7 +101,7 @@ static void print_parse_errors(int level, const char *msg, ...)
 	}
 }
 
-static int load_hexfile(struct astribank_device *astribank, const char *hexfile, enum dev_dest dest)
+static int load_hexfile(struct mpp_device *mpp, const char *hexfile, enum dev_dest dest)
 {
 	struct hexdata		*hexdata = NULL;
 	int			finished = 0;
@@ -108,19 +109,24 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
 	unsigned		i;
 	char			star[] = "+\\+|+/+-";
 	const char		*devstr;
+	struct xusb_device *xusb_device;
+	struct xusb_iface *xusb_iface;
+
 
 	parse_hexfile_set_reporting(print_parse_errors);
 	if((hexdata  = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) {
 		perror(hexfile);
 		return -errno;
 	}
-	devstr = xusb_devpath(astribank->xusb);
+	xusb_iface = xubs_iface_of_mpp(mpp);
+	xusb_device = xusb_deviceof(xusb_iface);
+	devstr = xusb_devpath(xusb_device);
 	INFO("%s [%s]: Loading %s Firmware: %s (version %s)\n",
 		devstr,
-		xusb_serial(astribank->xusb),
+		xusb_serial(xusb_device),
 		dev_dest2str(dest),
 		hexdata->fname, hexdata->version_info);
-	if((ret = mpp_send_start(astribank, dest, hexdata->version_info)) < 0) {
+	if((ret = mpp_send_start(mpp, dest, hexdata->version_info)) < 0) {
 		ERR("%s: Failed hexfile send start: %d\n", devstr, ret);
 		return ret;
 	}
@@ -142,7 +148,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
 			finished = 1;
 			continue;
 		}
-		if((ret = handle_hexline(astribank, hexline)) < 0) {
+		if((ret = handle_hexline(mpp, hexline)) < 0) {
 			ERR("%s: Failed hexfile sending in lineno %d (ret=%d)\n", devstr, i, ret);;
 			return ret;
 		}
@@ -151,7 +157,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
 		putchar('\n');
 		fflush(stdout);
 	}
-	if((ret = mpp_send_end(astribank)) < 0) {
+	if((ret = mpp_send_end(mpp)) < 0) {
 		ERR("%s: Failed hexfile send end: %d\n", devstr, ret);
 		return ret;
 	}
@@ -178,7 +184,6 @@ int main(int argc, char *argv[])
 	int			opt_sum = 0;
 	enum dev_dest		dest = DEST_NONE;
 	const char		options[] = "vd:D:EFOopAS:";
-	int			iface_num;
 	int			ret;
 
 	progname = argv[0];
@@ -247,7 +252,6 @@ int main(int argc, char *argv[])
 			" and -p options are mutually exclusive, if neither is used then -o should present\n");
 		usage();
 	}
-	iface_num = (opt_dest) ? 1 : 0;
 	if(!opt_pic && !opt_ecver) {
 		if(optind != argc - 1) {
 			ERR("Got %d hexfile names (Need exactly one hexfile)\n",
@@ -270,29 +274,43 @@ int main(int argc, char *argv[])
 		/*
 		 * MPP Interface
 		 */
-		struct astribank_device *astribank;
+		struct astribank *astribank;
+		struct mpp_device *mpp;
 
-		if((astribank = mpp_init(devpath, iface_num)) == NULL) {
+		astribank = astribank_new(devpath);
+		if(!astribank) {
 			ERR("%s: Opening astribank failed\n", devpath);
 			return 1;
 		}
-		//show_astribank_info(astribank);
-		if(load_hexfile(astribank, argv[optind], dest) < 0) {
+		mpp = astribank_mpp_open(astribank);
+		if(!mpp) {
+			ERR("%s: Opening astribank XPP interface failed\n", devpath);
+			return 1;
+		}
+		show_astribank_info(astribank);
+		if(load_hexfile(mpp, argv[optind], dest) < 0) {
 			ERR("%s: Loading firmware to %s failed\n", devpath, dev_dest2str(dest));
 			return 1;
 		}
-		astribank_close(astribank, 0);
+		astribank_destroy(astribank);
 	} else if(opt_pic || opt_echo || opt_ecver) {
 		/*
 		 * XPP Interface
 		 */
-		struct astribank_device *astribank;
+		struct astribank *astribank;
+		struct xusb_iface *xpp_iface;
 
-		if((astribank = astribank_open(devpath, iface_num)) == NULL) {
+		astribank = astribank_new(devpath);
+		if (!astribank) {
 			ERR("%s: Opening astribank failed\n", devpath);
 			return 1;
 		}
-		//show_astribank_info(astribank);
+		xpp_iface = astribank_xpp_open(astribank);
+		if(!xpp_iface) {
+			ERR("%s: Opening astribank XPP interface failed\n", devpath);
+			return 1;
+		}
+		show_astribank_info(astribank);
 #if HAVE_OCTASIC
 		if (opt_ecver) {
 			if((ret = echo_ver(astribank)) < 0) {
@@ -315,7 +333,7 @@ int main(int argc, char *argv[])
 			}
 #endif
 		}
-		astribank_close(astribank, 0);
+		astribank_destroy(astribank);
 	}
 	return 0;
 }
diff --git a/xpp/astribank_license.c b/xpp/astribank_license.c
index 88d2af7..79730d5 100644
--- a/xpp/astribank_license.c
+++ b/xpp/astribank_license.c
@@ -24,7 +24,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
-#include <debug.h>
+#include <xtalk/debug.h>
 #include "astribank_license.h"
 
 #define	ARRAY_SIZE(a)	(sizeof(a)/sizeof((a)[0]))
diff --git a/xpp/astribank_license.h b/xpp/astribank_license.h
index 74d6a31..b036fc4 100644
--- a/xpp/astribank_license.h
+++ b/xpp/astribank_license.h
@@ -1,7 +1,7 @@
 #ifndef	ASTRIBANK_ALLOW_H
 #define	ASTRIBANK_ALLOW_H
 
-#include "mpp.h"
+#include "mpptalk.h"
 
 enum license_markers {
 	LICENSE_MARKER_NONE = 0,
diff --git a/xpp/astribank_tool.c b/xpp/astribank_tool.c
index f3ca976..7be04fb 100644
--- a/xpp/astribank_tool.c
+++ b/xpp/astribank_tool.c
@@ -28,10 +28,10 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include <arpa/inet.h>
-#include "astribank_usb.h"
+#include <xtalk/debug.h>
+#include <xtalk/xusb.h>
 #include "mpptalk.h"
-#include <debug.h>
-#include <xusb.h>
+#include "astribank.h"
 
 #define	DBG_MASK	0x80
 /* if enabled, adds support for resetting pre-MPP USB firmware - if we 
@@ -76,90 +76,11 @@ static int reset_kind(const char *arg)
 	return -1;
 }
 
-
-static int show_hardware(struct astribank_device *astribank)
-{
-	int	ret;
-	struct eeprom_table	eeprom_table;
-	struct capabilities	capabilities;
-	struct extrainfo	extrainfo;
-
-	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)) {
-			uint8_t	unit;
-			uint8_t	card_status;
-			uint8_t	card_type;
-			uint8_t	fpga_configuration;
-			uint8_t	status;
-
-			for(unit = 0; unit < 5; 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 = mpps_stat(astribank, unit, &fpga_configuration, &status);
-			if (ret < 0)
-				return ret;
-			printf("FPGA: %-17s: %d\n", "Configuration num", fpga_configuration);
-			printf("FPGA: %-17s: %s\n", "Watchdog Timer",
-				(SER_STAT_WATCHDOG_READY(status)) ? "ready" : "expired");
-			printf("FPGA: %-17s: %s\n", "XPD Alive",
-				(SER_STAT_XPD_ALIVE(status)) ? "yes" : "no");
-		}
-		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;
-}
-
-#ifdef SUPPORT_OLD_RESET
-/* Try to reset a device using USB_FW.hex, up to Xorcom rev. 6885 */
-int old_reset(const char* devpath)
-{
-	struct astribank_device *astribank;
-	int ret;
-	struct {
-		uint8_t		op;
-	} PACKED header = {0x20}; /* PT_RESET */
-	char *buf = (char*) &header;
-
-	/* Note that the function re-opens the connection to the Astribank
-	 * as any reference to the previous connection was lost when mpp_open
-	 * returned NULL as the astribank reference. */
-	astribank = astribank_open(devpath, 1);
-	if (!astribank) {
-		DBG("Failed re-opening astribank device for old_reset\n");
-		return -ENODEV;
-	}
-	ret = xusb_send(astribank->xusb, buf, 1, 5000);
-
-	/* If we just had a reenumeration, we may get -ENODEV */
-	if(ret < 0 && ret != -ENODEV)
-			return ret;
-	/* We don't astribank_close(), as it has likely been
-	 * reenumerated by now. */
-	return 0;
-}	
-#endif /* SUPPORT_OLD_RESET */
-
 int main(int argc, char *argv[])
 {
 	char			*devpath = NULL;
-	struct astribank_device *astribank;
+	struct astribank *astribank;
+	struct mpp_device *mpp;
 	const char		options[] = "vd:D:nr:p:w:Q";
 	int			opt_renumerate = 0;
 	char			*opt_port = NULL;
@@ -218,20 +139,12 @@ int main(int argc, char *argv[])
 		usage();
 	}
 	DBG("Startup %s\n", devpath);
-	if((astribank = mpp_init(devpath, 1)) == NULL) {
-		ERR("Failed initializing MPP\n");
-#ifdef SUPPORT_OLD_RESET
-		DBG("opt_reset = %s\n", opt_reset);
-		if (opt_reset) {
-			DBG("Trying old reset method\n");
-			if ((ret = old_reset(devpath)) != 0) {
-				ERR("Old reset method failed as well: %d\n", ret);
-			}
-		}
-#endif /* SUPPORT_OLD_RESET */
-
+	astribank = astribank_new(devpath);
+	if(!astribank) {
+		ERR("Failed initializing Astribank\n");
 		return 1;
 	}
+	mpp = astribank_mpp_open(astribank);
 	/*
 	 * First process reset options. We want to be able
 	 * to reset minimal USB firmwares even if they don't
@@ -245,7 +158,7 @@ int main(int argc, char *argv[])
 			return 1;
 		}
 		DBG("Reseting (%s)\n", opt_reset);
-		if((ret = mpp_reset(astribank, full_reset)) < 0) {
+		if((ret = mpp_reset(mpp, full_reset)) < 0) {
 			ERR("%s Reseting astribank failed: %d\n",
 				(full_reset) ? "Full" : "Half", ret);
 		}
@@ -253,10 +166,10 @@ int main(int argc, char *argv[])
 	}
 	show_astribank_info(astribank);
 	if(opt_query) {
-		show_hardware(astribank);
+		show_hardware(mpp);
 	} else if(opt_renumerate) {
 		DBG("Renumerate\n");
-		if((ret = mpp_renumerate(astribank)) < 0) {
+		if((ret = mpp_renumerate(mpp)) < 0) {
 			ERR("Renumerating astribank failed: %d\n", ret);
 		}
 	} else if(opt_watchdog) {
@@ -264,24 +177,24 @@ int main(int argc, char *argv[])
 
 		DBG("TWINSTAR: Setting watchdog %s-guard\n",
 			(watchdogstate) ? "on" : "off");
-		if((ret = mpp_tws_setwatchdog(astribank, watchdogstate)) < 0) {
+		if((ret = mpp_tws_setwatchdog(mpp, 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);
-		int	tws_portnum = mpp_tws_portnum(astribank);
+		int	tws_portnum = mpp_tws_portnum(mpp);
 		char	*msg = (new_portnum == tws_portnum)
 					? " Same same, never mind..."
 					: "";
 
 		DBG("TWINSTAR: Setting portnum to %d.%s\n", new_portnum, msg);
-		if((ret = mpp_tws_setportnum(astribank, new_portnum)) < 0) {
+		if((ret = mpp_tws_setportnum(mpp, new_portnum)) < 0) {
 			ERR("Failed to set USB portnum to %d\n", new_portnum);
 			return 1;
 		}
 	}
 out:
-	mpp_exit(astribank);
+	astribank_destroy(astribank);
 	return 0;
 }
diff --git a/xpp/astribank_usb.c b/xpp/astribank_usb.c
deleted file mode 100644
index af7e6aa..0000000
--- a/xpp/astribank_usb.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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 <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <arpa/inet.h>
-#include <xusb.h>
-#include "astribank_usb.h"
-#include <debug.h>
-
-static const char rcsid[] = "$Id$";
-
-#define	DBG_MASK	0x01
-#define	TIMEOUT	500
-
-#define	TYPE_ENTRY(t,p,ni,n,ne,out,in,...)	\
-		{				\
-		.my_vendor_id = 0xe4e4,		\
-		.my_product_id = (p),		\
-		.name = #t,			\
-		.num_interfaces = (ni),		\
-		.my_interface_num = (n),	\
-		.num_endpoints = (ne),		\
-		.my_ep_in = (in),		\
-		.my_ep_out = (out),		\
-		}
-
-#define	ARRAY_SIZE(x)	(sizeof(x)/sizeof(x[0]))
-
-static const struct xusb_spec	astribank_specs[] = {
-	/* OLD Firmwares */
-	TYPE_ENTRY("USB-OLDFXS",	0x1131, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("FPGA-OLDFXS",	0x1132, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("USB-BRI",		0x1141, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("FPGA-BRI",		0x1142, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("USB-OLD",		0x1151, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("FPGA-OLD",		0x1152, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-
-	TYPE_ENTRY("USB-MULTI",		0x1161, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("FPGA-MULTI",	0x1162, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("BURNED-MULTI",	0x1164, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-	TYPE_ENTRY("USB-BURN",		0x1112, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
-};
-
-static const struct xusb_spec	astribank_pic_specs[] = {
-	TYPE_ENTRY("USB_PIC",		0x1161, 2, 0, 2, XPP_EP_OUT, XPP_EP_IN),
-};
-#undef TYPE_ENTRY
-
-//static int	verbose = LOG_DEBUG;
-
-/*
- * USB handling
- */
-struct astribank_device *astribank_open(const char devpath[], int iface_num)
-{
-	struct astribank_device	*astribank = NULL;
-	struct xusb		*xusb;
-
-	DBG("devpath='%s' iface_num=%d\n", devpath, iface_num);
-	if((astribank = malloc(sizeof(struct astribank_device))) == NULL) {
-		ERR("Out of memory\n");
-		goto fail;
-	}
-	memset(astribank, 0, sizeof(*astribank));
-	if (iface_num) {
-		xusb  = xusb_find_bypath(astribank_specs, ARRAY_SIZE(astribank_specs), devpath);
-	} else {
-		xusb  = xusb_find_bypath(astribank_pic_specs, ARRAY_SIZE(astribank_pic_specs), devpath);
-	}
-	if (!xusb) {
-		ERR("%s: No device found\n", __func__);
-		goto fail;
-	}
-	astribank->xusb = xusb;
-	astribank->is_usb2 = (xusb_packet_size(xusb) == 512);
-	astribank->my_interface_num = iface_num;
-	if (xusb_claim_interface(astribank->xusb) < 0) {
-		ERR("xusb_claim_interface failed\n");
-		goto fail;
-	}
-	astribank->tx_sequenceno = 1;
-	return astribank;
-fail:
-	if (astribank) {
-		free(astribank);
-		astribank = NULL;
-	}
-	return NULL;
-}
-
-/*
- * MP device handling
- */
-void show_astribank_info(const struct astribank_device *astribank)
-{
-	struct xusb			*xusb;
-
-	assert(astribank != NULL);
-	xusb = astribank->xusb;
-	assert(xusb != NULL);
-	if(verbose <= LOG_INFO) {
-		xusb_showinfo(xusb);
-	} else {
-		const struct xusb_spec	*spec;
-
-		spec = xusb_spec(xusb);
-		printf("USB    Bus/Device:    [%s]\n", xusb_devpath(xusb));
-		printf("USB    Firmware Type: [%s]\n", spec->name);
-		printf("USB    iSerialNumber: [%s]\n", xusb_serial(xusb));
-		printf("USB    iManufacturer: [%s]\n", xusb_manufacturer(xusb));
-		printf("USB    iProduct:      [%s]\n", xusb_product(xusb));
-	}
-}
-
-void astribank_close(struct astribank_device *astribank, int disconnected)
-{
-	assert(astribank != NULL);
-	if (astribank->xusb) {
-		xusb_close(astribank->xusb);
-		astribank->xusb = NULL;
-	}
-	astribank->tx_sequenceno = 0;
-}
-
-#if 0
-int flush_read(struct astribank_device *astribank)
-{
-	char		tmpbuf[BUFSIZ];
-	int		ret;
-
-	DBG("starting...\n");
-	memset(tmpbuf, 0, BUFSIZ);
-	ret = recv_usb(astribank, tmpbuf, BUFSIZ, 1);
-	if(ret < 0 && ret != -ETIMEDOUT) {
-		ERR("ret=%d\n", ret);
-		return ret;
-	} else if(ret > 0) {
-		DBG("Got %d bytes:\n", ret);
-		dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, tmpbuf, ret);
-	}
-	return 0;
-}
-#endif
-
-
-int release_isvalid(uint16_t release)
-{
-	uint8_t	rmajor = (release >> 8) & 0xFF;
-	uint8_t	rminor = release & 0xFF;
-
-	return	(rmajor > 0) &&
-		(rmajor < 10) &&
-		(rminor > 0) &&
-		(rminor < 10);
-}
-
-int label_isvalid(const char *label)
-{
-	int		len;
-	int		goodlen;
-	const char	GOOD_CHARS[] =
-				"abcdefghijklmnopqrstuvwxyz"
-				"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-				"0123456789"
-				"-_.";
-
-	len = strlen(label);
-	goodlen = strspn(label, GOOD_CHARS);
-	if(len > LABEL_SIZE) {
-		ERR("Label too long (%d > %d)\n", len, LABEL_SIZE);
-		return 0;
-	}
-	if(goodlen != len) {
-		ERR("Bad character in label (pos=%d)\n", goodlen);
-		return 0;
-	}
-	return 1;
-}
-
-int eeprom_fill(struct eeprom_table *eprm,
-	const char *vendor,
-	const char *product,
-	const char *release,
-	const char *label)
-{
-	uint16_t	val;
-
-	eprm->source = 0xC0;
-	eprm->config_byte = 0;
-	if(vendor) {
-		val = strtoul(vendor, NULL, 0);
-		if(!val) {
-			ERR("Invalid vendor '%s'\n",
-				vendor);
-			return -EINVAL;
-		}
-		eprm->vendor = val;
-	}
-	if(product) {
-		val = strtoul(product, NULL, 0);
-		if(!val) {
-			ERR("Invalid product '%s'\n",
-				product);
-			return -EINVAL;
-		}
-		eprm->product = val;
-	}
-	if(release) {
-		int		release_major = 0;
-		int		release_minor = 0;
-		uint16_t	value;
-
-		if(sscanf(release, "%d.%d", &release_major, &release_minor) != 2) {
-			ERR("Failed to parse release number '%s'\n", release);
-			return -EINVAL;
-		}
-		value = (release_major << 8) | release_minor;
-		DBG("Parsed release(%d): major=%d, minor=%d\n",
-			value, release_major, release_minor);
-		if(!release_isvalid(value)) {
-			ERR("Invalid release number 0x%X\n", value);
-			return -EINVAL;
-		}
-		eprm->release = value;
-	}
-	if(label) {
-		/* padding */
-		if(!label_isvalid(label)) {
-			ERR("Invalid label '%s'\n", label);
-			return -EINVAL;
-		}
-		memset(eprm->label, 0, LABEL_SIZE);
-		memcpy(eprm->label, label, strlen(label));
-	}
-	return 0;
-}
-
-int astribank_has_twinstar(struct astribank_device *astribank)
-{
-	uint16_t			product_series;
-
-	assert(astribank != NULL);
-	product_series = xusb_product_id(astribank->xusb);
-	product_series &= 0xFFF0;
-	if(product_series == 0x1160)	/* New boards */
-		return 1;
-	return 0;
-}
-
diff --git a/xpp/astribank_usb.h b/xpp/astribank_usb.h
deleted file mode 100644
index 69778e6..0000000
--- a/xpp/astribank_usb.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef	ASTRIBANK_USB_H
-#define	ASTRIBANK_USB_H
-/*
- * 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 <xusb.h>
-#include <xtalk.h>
-#include "mpp.h"
-
-/*
- * Astribank handling
- */
-
-#define	PACKET_SIZE	512
-
-/* USB Endpoints */
-#define	MP_EP_OUT	0x04	/* Managment processor */
-#define	MP_EP_IN	0x88	/* Managment processor */
-
-#define	XPP_EP_OUT	0x02	/* XPP */
-#define	XPP_EP_IN	0x86	/* XPP */
-
-/* USB firmware types */
-#define	USB_11xx	0
-#define	USB_FIRMWARE_II	1
-#define	USB_PIC		2
-
-struct interface_type {
-	int	type_code;
-	int	num_interfaces;
-	int	my_interface_num;
-	int	num_endpoints;
-	int	my_ep_out;
-	int	my_ep_in;
-	char	*name;
-	int	endpoints[4];	/* for matching */
-};
-
-enum eeprom_burn_state {
-	BURN_STATE_NONE		= 0,
-	BURN_STATE_STARTED	= 1,
-	BURN_STATE_ENDED	= 2,
-	BURN_STATE_FAILED	= 3,
-};
-
-struct astribank_device {
-	struct xusb		*xusb;
-	struct xtalk_device	*xtalk_dev;
-	usb_dev_handle		*handle;
-	int			my_interface_num;
-	int			my_ep_out;
-	int			my_ep_in;
-	char			iInterface[BUFSIZ];
-	int			is_usb2;
-	enum eeprom_type	eeprom_type;
-	enum eeprom_burn_state	burn_state;
-	uint8_t			status;
-	uint8_t			mpp_proto_version;
-	struct eeprom_table	*eeprom;
-	struct firmware_versions	fw_versions;
-	uint16_t		tx_sequenceno;
-};
-
-/*
- * Prototypes
- */
-struct astribank_device	*astribank_open(const char devpath[], int iface_num);
-void astribank_close(struct astribank_device *astribank, int disconnected);
-void show_astribank_info(const struct astribank_device *astribank);
-int send_usb(struct astribank_device *astribank, char *buf, int len, int timeout);
-int recv_usb(struct astribank_device *astribank, char *buf, size_t len, int timeout);
-int flush_read(struct astribank_device *astribank);
-int eeprom_fill(struct eeprom_table *eprm,
-		const char *vendor,
-		const char *product,
-		const char *release,
-		const char *label);
-int astribank_has_twinstar(struct astribank_device *astribank);
-int label_isvalid(const char *label);
-
-#define	AB_REPORT(report_type, astribank, fmt, ...) \
-	report_type("%s [%s]: " fmt, \
-		xusb_devpath((astribank)->xusb), \
-		xusb_serial((astribank)->xusb), \
-		## __VA_ARGS__)
-
-#define	AB_INFO(astribank, fmt, ...) \
-		AB_REPORT(INFO, astribank, fmt, ## __VA_ARGS__)
-
-#define	AB_ERR(astribank, fmt, ...) \
-		AB_REPORT(ERR, astribank, fmt, ## __VA_ARGS__)
-
-#endif	/* ASTRIBANK_USB_H */
diff --git a/xpp/echo_loader.c b/xpp/echo_loader.c
index ca92883..827f6ef 100644
--- a/xpp/echo_loader.c
+++ b/xpp/echo_loader.c
@@ -28,12 +28,21 @@
 #include <limits.h>
 #include <regex.h>
 #include <sys/time.h>
-#include "echo_loader.h"
-#include "debug.h"
+#include <unistd.h>
 #include <oct6100api/oct6100_api.h>
+#include <xtalk/debug.h>
+#include <xtalk/xusb.h>
+#include <astribank.h>
+#include "echo_loader.h"
 #include "parse_span_specs.h"
 
-#define DBG_MASK        	0x03
+#ifdef	__GNUC__
+#define	PACKED	__attribute__((packed))
+#else
+#define	PACKED
+#endif
+
+#define DBG_MASK        	0x10
 #define	TIMEOUT			1000
 #define ECHO_MAX_CHANS		128
 #define ECHO_RIN_STREAM		0
@@ -53,7 +62,7 @@ static float oct_fw_load_timeout = 2.0;
 struct echo_mod {
 	tPOCT6100_INSTANCE_API pApiInstance;
 	UINT32 ulEchoChanHndl[256];
-	struct astribank_device *astribank;
+	struct astribank *astribank;
 	int maxchans;
 };
 
@@ -100,9 +109,9 @@ static struct usb_buffer {
 } usb_buffer;
 
 
-static void usb_buffer_init(struct astribank_device *astribank, struct usb_buffer *ub)
+static void usb_buffer_init(struct astribank *astribank, struct usb_buffer *ub)
 {
-	ub->max_len = xusb_packet_size(astribank->xusb);
+	ub->max_len = xusb_packet_size(xusb_dev_of_astribank(astribank));
 	ub->curr = 0;
 	ub->min_send = INT_MAX;
 	ub->max_send = 0;
@@ -120,7 +129,7 @@ static long usb_buffer_usec(struct usb_buffer *ub)
 		(now.tv_usec - ub->start.tv_usec);
 }
 
-static void usb_buffer_showstatistics(struct astribank_device *astribank, struct usb_buffer *ub)
+static void usb_buffer_showstatistics(struct astribank *astribank, struct usb_buffer *ub)
 {
 	long	usec;
 
@@ -133,7 +142,7 @@ static void usb_buffer_showstatistics(struct astribank_device *astribank, struct
 		usec / 1000, usec / ub->num_sends);
 }
 
-static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffer *ub)
+static int usb_buffer_flush(struct astribank *astribank, struct usb_buffer *ub)
 {
 	int	ret;
 	long	t;
@@ -142,7 +151,7 @@ static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffe
 
 	if (ub->curr == 0)
 		return 0;
-	ret = xusb_send(astribank->xusb, ub->data, ub->curr, TIMEOUT);
+	ret = astribank_send(astribank, 0, ub->data, ub->curr, TIMEOUT);
 	if (ret < 0) {
 		AB_ERR(astribank, "xusb_send failed: %d\n", ret);
 		return ret;
@@ -175,7 +184,7 @@ static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffe
 	return ret;
 }
 
-static int usb_buffer_append(struct astribank_device *astribank, struct usb_buffer *ub,
+static int usb_buffer_append(struct astribank *astribank, struct usb_buffer *ub,
 	char *buf, int len)
 {
 	if (ub->curr + len >= ub->max_len) {
@@ -188,7 +197,7 @@ static int usb_buffer_append(struct astribank_device *astribank, struct usb_buff
 	return len;
 }
 
-static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer *ub,
+static int usb_buffer_send(struct astribank *astribank, struct usb_buffer *ub,
 	char *buf, int len, int timeout, int recv_answer)
 {
 	int	ret = 0;
@@ -209,7 +218,7 @@ static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer
 		ret = usb_buffer_flush(astribank, ub);
 		if (ret < 0)
 			return ret;
-		ret = xusb_recv(astribank->xusb, buf, PACKET_SIZE, TIMEOUT);
+		ret = astribank_recv(astribank, 0, buf, PACKET_SIZE, TIMEOUT);
 		if (ret <= 0) {
 			AB_ERR(astribank, "No USB packs to read: %s\n", strerror(-ret));
 			return -EINVAL;
@@ -239,7 +248,7 @@ static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer
 	return ret;
 }
 
-int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver)
+int spi_send(struct astribank *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver)
 {
 	int				ret;
 	char				buf[PACKET_SIZE];
@@ -272,7 +281,7 @@ int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, i
 	return ret;
 }
 
-int test_send(struct astribank_device *astribank)
+int test_send(struct astribank *astribank)
 {
 	int                             ret;
 	char                            buf[PACKET_SIZE];
@@ -300,7 +309,7 @@ int test_send(struct astribank_device *astribank)
 	return ret;
 }
 
-int echo_send_data(struct astribank_device *astribank, const unsigned int addr, const unsigned int data)
+int echo_send_data(struct astribank *astribank, const unsigned int addr, const unsigned int data)
 {
 	int ret;
 /*	DBG("SEND: %04X -> [%04X]\n", data, addr);
@@ -330,7 +339,7 @@ failed:
 	return ret;
 }
 
-int echo_recv_data(struct astribank_device *astribank, const unsigned int addr)
+int echo_recv_data(struct astribank *astribank, const unsigned int addr)
 {
 	unsigned int data = 0x00;
 	int ret;
@@ -452,7 +461,7 @@ UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
 	const unsigned int 		addr 		= f_pWriteParams->ulWriteAddress;
 	const unsigned int 		data 		= f_pWriteParams->usWriteData;
 	const struct echo_mod		*echo_mod 	= (struct echo_mod *)(f_pWriteParams->pProcessContext);
-	struct astribank_device 	*astribank 	= echo_mod->astribank;
+	struct astribank 	*astribank 	= echo_mod->astribank;
 	int ret;
 
 	ret = echo_send_data(astribank, addr, data);
@@ -469,7 +478,7 @@ UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParam
 	unsigned int              	data;
 	unsigned int              	len;
 	const struct echo_mod           *echo_mod;
-	struct astribank_device   	*astribank;
+	struct astribank   	*astribank;
 	unsigned int 			i;
 
 	len = f_pSmearParams->ulWriteLength;
@@ -495,7 +504,7 @@ UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParam
 	unsigned int              	data;
 	unsigned int 			len 		= f_pBurstParams->ulWriteLength;
 	const struct echo_mod		*echo_mod 	= (struct echo_mod *)f_pBurstParams->pProcessContext;
-	struct astribank_device 	*astribank 	= echo_mod->astribank;
+	struct astribank 	*astribank 	= echo_mod->astribank;
 	unsigned int 			i;
 
 	for (i = 0; i < len; i++) {
@@ -516,7 +525,7 @@ UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
 {
 	const unsigned int              addr =  f_pReadParams->ulReadAddress;
 	const struct echo_mod		*echo_mod;
-	struct astribank_device 	*astribank;
+	struct astribank 	*astribank;
 	int ret;
 
 	echo_mod = (struct echo_mod *)f_pReadParams->pProcessContext;
@@ -535,7 +544,7 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
 	unsigned int              	addr;
 	unsigned int              	len;
 	const struct echo_mod		*echo_mod;
-	struct astribank_device 	*astribank;
+	struct astribank 	*astribank;
 	unsigned int 			i;
 
 	len = f_pBurstParams->ulReadLength;
@@ -555,13 +564,13 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
 	return cOCT6100_ERR_OK;
 }
 
-inline int get_ver(struct astribank_device *astribank)
+inline int get_ver(struct astribank *astribank)
 {
 	return spi_send(astribank, 0, 0, 1, 1);
 }
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-UINT32 init_octasic(char *filename, struct astribank_device *astribank, struct span_specs *span_specs)
+UINT32 init_octasic(char *filename, struct astribank *astribank, struct span_specs *span_specs)
 {
 	int							cpld_ver;
 	struct echo_mod						*echo_mod;
@@ -838,7 +847,7 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, struct s
 }
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-int load_echo(struct astribank_device *astribank, char *filename, int default_is_alaw, const char *span_spec)
+int load_echo(struct astribank *astribank, char *filename, int default_is_alaw, const char *span_spec)
 {
 	int		ret;
 	UINT32		octasic_status;
@@ -868,7 +877,7 @@ int load_echo(struct astribank_device *astribank, char *filename, int default_is
 	return 0;
 }
 
-int echo_ver(struct astribank_device *astribank)
+int echo_ver(struct astribank *astribank)
 {
 	usb_buffer_init(astribank, &usb_buffer);
 	return get_ver(astribank);
diff --git a/xpp/echo_loader.h b/xpp/echo_loader.h
index 2bffda2..d361d8a 100644
--- a/xpp/echo_loader.h
+++ b/xpp/echo_loader.h
@@ -23,10 +23,10 @@
  */
 
 #include <stdint.h>
-#include "astribank_usb.h"
+#include "astribank.h"
 
-int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver);
-int load_echo(struct astribank_device *astribank, char *filename, int is_alaw, const char *span_spec);
-int echo_ver(struct astribank_device *astribank);
+int spi_send(struct astribank *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver);
+int load_echo(struct astribank *astribank, char *filename, int is_alaw, const char *span_spec);
+int echo_ver(struct astribank *astribank);
 
 #endif	/* ECHO_LOADER_H */
diff --git a/xpp/mpp.h b/xpp/mpp.h
deleted file mode 100644
index 53ea81e..0000000
--- a/xpp/mpp.h
+++ /dev/null
@@ -1,202 +0,0 @@
-#ifndef	MPP_H
-#define	MPP_H
-/*
- * 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.
- *
- */
-
-/*
- * MPP - Managment Processor Protocol definitions
- */
-
-#include <mpptalk_defs.h>
-#include <stdint.h>
-#include <xtalk.h>
-
-#ifdef	__GNUC__
-#define	PACKED	__attribute__((packed))
-#else
-#error "We do not know how your compiler packs structures"
-#endif
-
-#define	MK_PROTO_VERSION(major, minor)	(((major) << 4) | (0x0F & (minor)))
-
-#define	MPP_PROTOCOL_VERSION	MK_PROTO_VERSION(1,4)
-#define	MPP_SUPPORTED_VERSION(x)	((x) == MK_PROTO_VERSION(1,3) || (x) == MK_PROTO_VERSION(1,4))
-
-/*
- * The eeprom_table is common to all eeprom types.
- */
-#define	LABEL_SIZE	8
-struct eeprom_table {
-	uint8_t		source;		/* C0 - small eeprom, C2 - large eeprom */
-	uint16_t	vendor;
-	uint16_t	product;
-	uint16_t	release;	/* BCD encoded release */
-	uint8_t		config_byte;	/* Must be 0 */
-	uint8_t		label[LABEL_SIZE];
-} PACKED;
-
-#define	VERSION_LEN	6
-struct firmware_versions {
-	char	usb[VERSION_LEN];
-	char	fpga[VERSION_LEN];
-	char	eeprom[VERSION_LEN];
-} PACKED;
-
-struct capabilities {
-	uint8_t		ports_fxs;
-	uint8_t		ports_fxo;
-	uint8_t		ports_bri;
-	uint8_t		ports_pri;
-	uint8_t		extra_features;	/* BIT(0) - TwinStar */
-	uint8_t		ports_echo;
-	uint8_t		reserved[2];
-	uint32_t	timestamp;
-} PACKED;
-
-#define	CAP_EXTRA_TWINSTAR(c)		((c)->extra_features & 0x01)
-#define	CAP_EXTRA_TWINSTAR_SET(c)	do {(c)->extra_features |= 0x01;} while (0)
-#define	CAP_EXTRA_TWINSTAR_CLR(c)	do {(c)->extra_features &= ~0x01;} while (0)
-
-#define	KEYSIZE	16
-
-struct capkey {
-	uint8_t	k[KEYSIZE];
-} PACKED;
-
-struct extrainfo {
-	char		text[EXTRAINFO_SIZE];
-} PACKED;
-
-struct mpp_header {
-	uint16_t	len;
-	uint16_t	seq;
-	uint8_t		op;	/* MSB: 0 - to device, 1 - from device */
-} PACKED;
-
-enum mpp_ser_op {
-	SER_CARD_INFO_GET	= 0x1,
-	SER_STAT_GET		= 0x3,
-/* Status bits */
-#define	SER_STAT_WATCHDOG_READY(s)	((s) & 0x01)
-#define	SER_STAT_XPD_ALIVE(s)		((s) & 0x02)
-};
-
-/* Individual commands structure */
-
-CMD_DEF(MPP, STATUS_GET);
-
-
-CMD_DEF(MPP, STATUS_GET_REPLY,
-	uint8_t	i2cs_data;
-
-#define	STATUS_FPGA_LOADED(x)	((x) & 0x01)
-	uint8_t	status;		/* BIT(0) - FPGA is loaded */
-	struct firmware_versions fw_versions;
-	);
-
-CMD_DEF(MPP, EEPROM_SET,
-	struct eeprom_table	data;
-	);
-
-CMD_DEF(MPP, CAPS_GET);
-
-CMD_DEF(MPP, CAPS_GET_REPLY,
-	struct eeprom_table	data;
-	struct capabilities	capabilities;
-	struct capkey		key;
-	);
-
-CMD_DEF(MPP, CAPS_SET,
... 9085 lines suppressed ...


-- 
dahdi/tools.git



More information about the dahdi-commits mailing list