[svn-commits] tzafrir: tools/trunk r9825 - in /tools/trunk/xpp: ./ xtalk/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Mar 10 12:48:14 CST 2011
Author: tzafrir
Date: Thu Mar 10 12:48:11 2011
New Revision: 9825
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9825
Log:
xpp: use 'xtalk' for the USB access code
* Move most of the USB access code from xpp/ to xpp/xtalk/ .
* astribank_tool and such tools can now use a shorter -D mmm/nnn rather
than a full path.
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Added:
tools/trunk/xpp/mpptalk.c (with props)
tools/trunk/xpp/mpptalk.h (contents, props changed)
- copied, changed from r9731, tools/trunk/xpp/mpp_funcs.h
tools/trunk/xpp/mpptalk_defs.h (with props)
tools/trunk/xpp/xtalk/
tools/trunk/xpp/xtalk/debug.c (contents, props changed)
- copied, changed from r9731, tools/trunk/xpp/debug.c
tools/trunk/xpp/xtalk/debug.h (contents, props changed)
- copied, changed from r9731, tools/trunk/xpp/debug.h
tools/trunk/xpp/xtalk/xlist.c (with props)
tools/trunk/xpp/xtalk/xlist.h (with props)
tools/trunk/xpp/xtalk/xtalk.c (with props)
tools/trunk/xpp/xtalk/xtalk.h (with props)
tools/trunk/xpp/xtalk/xtalk_defs.h (with props)
tools/trunk/xpp/xtalk/xusb.c (with props)
tools/trunk/xpp/xtalk/xusb.h (with props)
Removed:
tools/trunk/xpp/debug.c
tools/trunk/xpp/debug.h
tools/trunk/xpp/mpp_funcs.c
tools/trunk/xpp/mpp_funcs.h
Modified:
tools/trunk/xpp/Makefile
tools/trunk/xpp/astribank_allow.8
tools/trunk/xpp/astribank_allow.c
tools/trunk/xpp/astribank_hexload.8
tools/trunk/xpp/astribank_hexload.c
tools/trunk/xpp/astribank_tool.8
tools/trunk/xpp/astribank_tool.c
tools/trunk/xpp/astribank_usb.c
tools/trunk/xpp/astribank_usb.h
tools/trunk/xpp/mpp.h
tools/trunk/xpp/pic_loader.c
tools/trunk/xpp/xpp_fxloader
Modified: tools/trunk/xpp/Makefile
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/Makefile?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/Makefile (original)
+++ tools/trunk/xpp/Makefile Thu Mar 10 12:48:11 2011
@@ -54,9 +54,12 @@
PERL_MANS = $(PERL_SCRIPTS:%=%.8)
-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
+XTALK_OBJS = xtalk/xtalk.o xtalk/xusb.o xtalk/xlist.o xtalk/debug.o
+ASTRIBANK_OBJS = astribank_usb.o mpptalk.o $(XTALK_OBJS)
+
+ABHEXLOAD_OBJS = astribank_hexload.o hexfile.o pic_loader.o $(ASTRIBANK_OBJS) $(OCT_OBJS)
+ABTOOL_OBJS = astribank_tool.o $(ASTRIBANK_OBJS)
+ABALLOW_OBJS = astribank_allow.o $(ASTRIBANK_OBJS)
TARGETS = .perlcheck astribank_is_starting
PROG_INSTALL = astribank_is_starting
@@ -102,6 +105,8 @@
done
endif
+CFLAGS += -I. -Ixtalk
+
fpga_load: fpga_load.o hexfile.o
fpga_load: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
@@ -130,11 +135,11 @@
touch $@
clean:
- $(RM) .depend *.o $(TARGETS)
+ $(RM) .depend *.o xtalk/*.o $(TARGETS)
.PHONY: depend
depend: .depend
-.depend: *.c *.h
- @$(CC) -MM *.c > $@ || rm -f $@
+.depend: *.c *.h xtalk/*.c xtalk/*.h
+ @$(CC) $(CFLAGS) -MM *.c xtalk/*.c > $@ || rm -f $@
include .depend
Modified: tools/trunk/xpp/astribank_allow.8
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_allow.8?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_allow.8 (original)
+++ tools/trunk/xpp/astribank_allow.8 Thu Mar 10 12:48:11 2011
@@ -30,11 +30,11 @@
.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
+Required. The device to read from/write to. This is
+\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) or dahdi_hardware(8).
+On older versions of this toolyou needed a complete path to the device,
+which would be /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR, or
/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
.RE
Modified: tools/trunk/xpp/astribank_allow.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_allow.c?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_allow.c (original)
+++ tools/trunk/xpp/astribank_allow.c Thu Mar 10 12:48:11 2011
@@ -32,8 +32,8 @@
#include <arpa/inet.h>
#include <ctype.h>
#include "mpp.h"
-#include "mpp_funcs.h"
-#include "debug.h"
+#include "mpptalk.h"
+#include <debug.h>
static const char rcsid[] = "$Id$";
@@ -327,7 +327,7 @@
usage();
}
DBG("Startup %s\n", devpath);
- if((astribank = mpp_init(devpath)) == NULL) {
+ if((astribank = mpp_init(devpath, 1)) == NULL) {
ERR("Failed initializing MPP\n");
return 1;
}
Modified: tools/trunk/xpp/astribank_hexload.8
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_hexload.8?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_hexload.8 (original)
+++ tools/trunk/xpp/astribank_hexload.8 Thu Mar 10 12:48:11 2011
@@ -20,11 +20,11 @@
.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
+Required. The device to read from/write to. This is
+\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) or dahdi_hardware(8).
+On older versions of this toolyou needed a complete path to the device,
+which would be /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR, or
/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
.RE
Modified: tools/trunk/xpp/astribank_hexload.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_hexload.c?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_hexload.c (original)
+++ tools/trunk/xpp/astribank_hexload.c Thu Mar 10 12:48:11 2011
@@ -27,9 +27,9 @@
#include <errno.h>
#include <assert.h>
#include <arpa/inet.h>
-#include "debug.h"
+#include <debug.h>
#include "hexfile.h"
-#include "mpp_funcs.h"
+#include "mpptalk.h"
#include "pic_loader.h"
#include "astribank_usb.h"
@@ -80,12 +80,16 @@
int ret;
int i;
char star[] = "+\\+|+/+-";
+ const char *devstr;
if((hexdata = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) {
perror(hexfile);
return -errno;
}
- INFO("Loading hexfile to %s: %s (version %s)\n",
+ devstr = xusb_devpath(astribank->xusb);
+ INFO("%s [%s]: Loading %s Firmware: %s (version %s)\n",
+ devstr,
+ xusb_serial(astribank->xusb),
dev_dest2str(dest),
hexdata->fname, hexdata->version_info);
#if 0
@@ -96,7 +100,7 @@
}
#endif
if((ret = mpp_send_start(astribank, dest, hexdata->version_info)) < 0) {
- ERR("Failed hexfile send start: %d\n", ret);
+ ERR("%s: Failed hexfile send start: %d\n", devstr, ret);
return ret;
}
for(i = 0; i < hexdata->maxlines; i++) {
@@ -109,7 +113,7 @@
fflush(stdout);
}
if(finished) {
- ERR("Extra data after End Of Data Record (line %d)\n", i);
+ ERR("%s: Extra data after End Of Data Record (line %d)\n", devstr, i);
return 0;
}
if(hexline->d.content.header.tt == TT_EOF) {
@@ -118,7 +122,7 @@
continue;
}
if((ret = handle_hexline(astribank, hexline)) < 0) {
- ERR("Failed hexfile sending in lineno %d (ret=%d)\n", i, ret);;
+ ERR("%s: Failed hexfile sending in lineno %d (ret=%d)\n", devstr, i, ret);;
return ret;
}
}
@@ -127,7 +131,7 @@
fflush(stdout);
}
if((ret = mpp_send_end(astribank)) < 0) {
- ERR("Failed hexfile send end: %d\n", ret);
+ ERR("%s: Failed hexfile send end: %d\n", devstr, ret);
return ret;
}
#if 0
@@ -208,20 +212,37 @@
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_dest) {
+ /*
+ * MPP Interface
+ */
+ struct astribank_device *astribank;
+
+ if((astribank = mpp_init(devpath, iface_num)) == NULL) {
+ ERR("%s: Opening astribank failed\n", devpath);
+ return 1;
+ }
+ //show_astribank_info(astribank);
if(load_hexfile(astribank, argv[optind], dest) < 0) {
- ERR("Loading firmware to %s failed\n", dev_dest2str(dest));
+ ERR("%s: Loading firmware to %s failed\n", devpath, dev_dest2str(dest));
return 1;
}
+ astribank_close(astribank, 0);
} else if(opt_pic) {
- if((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) {
- ERR("Loading PIC's failed\n");
+ /*
+ * XPP Interface
+ */
+ struct astribank_device *astribank;
+
+ if((astribank = astribank_open(devpath, iface_num)) == NULL) {
+ ERR("%s: Opening astribank failed\n", devpath);
return 1;
+ }
+ if (opt_pic) {
+ if ((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) {
+ ERR("%s: Loading PIC's failed\n", devpath);
+ return 1;
+ }
}
}
astribank_close(astribank, 0);
Modified: tools/trunk/xpp/astribank_tool.8
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_tool.8?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_tool.8 (original)
+++ tools/trunk/xpp/astribank_tool.8 Thu Mar 10 12:48:11 2011
@@ -17,11 +17,11 @@
.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
+Required. The device to read from/write to. This is
+\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) or dahdi_hardware(8).
+On older versions of this toolyou needed a complete path to the device,
+which would be /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR, or
/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
.RE
Modified: tools/trunk/xpp/astribank_tool.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_tool.c?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_tool.c (original)
+++ tools/trunk/xpp/astribank_tool.c Thu Mar 10 12:48:11 2011
@@ -28,8 +28,10 @@
#include <getopt.h>
#include <sys/types.h>
#include <arpa/inet.h>
-#include "mpp_funcs.h"
-#include "debug.h"
+#include "astribank_usb.h"
+#include "mpptalk.h"
+#include <debug.h>
+#include <xusb.h>
#define DBG_MASK 0x80
/* if enabled, adds support for resetting pre-MPP USB firmware - if we
@@ -132,7 +134,7 @@
DBG("Failed re-opening astribank device for old_reset\n");
return -ENODEV;
}
- ret = send_usb(astribank, buf, 1, 5000);
+ ret = xusb_send(astribank->xusb, buf, 1, 5000);
/* If we just had a reenumeration, we may get -ENODEV */
if(ret < 0 && ret != -ENODEV)
@@ -205,7 +207,7 @@
usage();
}
DBG("Startup %s\n", devpath);
- if((astribank = mpp_init(devpath)) == NULL) {
+ if((astribank = mpp_init(devpath, 1)) == NULL) {
ERR("Failed initializing MPP\n");
#ifdef SUPPORT_OLD_RESET
DBG("opt_reset = %s\n", opt_reset);
Modified: tools/trunk/xpp/astribank_usb.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_usb.c?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_usb.c (original)
+++ tools/trunk/xpp/astribank_usb.c Thu Mar 10 12:48:11 2011
@@ -30,39 +30,44 @@
#include <stdarg.h>
#include <syslog.h>
#include <arpa/inet.h>
+#include <xusb.h>
#include "astribank_usb.h"
-#include "debug.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), \
+#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), \
- .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),
- TYPE_ENTRY(USB_FIRMWARE_II, 2, 1, 2, MP_EP_OUT, MP_EP_IN,
- MP_EP_OUT,
- MP_EP_IN),
- TYPE_ENTRY(USB_PIC, 2, 0, 2, XPP_EP_OUT, XPP_EP_IN,
- XPP_EP_OUT,
- XPP_EP_IN),
-
+ }
+
+#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),
+};
+
+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
@@ -71,262 +76,41 @@
/*
* USB handling
*/
-
-/* return 1 if:
- * - str has a number
- * - It is larger than 0
- * - It equals num
- */
-static int num_matches(int num, const char* str) {
- int str_val = atoi(str);
- if (str_val <= 0)
- return 0;
- return (str_val == num);
-}
-
-struct usb_device *dev_of_path(const char *path)
-{
- struct usb_bus *bus;
- struct usb_device *dev;
- char dirname[PATH_MAX];
- char filename[PATH_MAX];
- const char *p;
- int bnum;
- int dnum;
- int ret;
-
- assert(path != NULL);
- if(access(path, F_OK) < 0) {
- perror(path);
- return NULL;
- }
- /* Find last '/' */
- if((p = memrchr(path, '/', strlen(path))) == NULL) {
- ERR("Missing a '/' in %s\n", path);
- return NULL;
- }
- /* Get the device number */
- ret = sscanf(p + 1, "%d", &dnum);
- if(ret != 1) {
- ERR("Path tail is not a device number: '%s'\n", p);
- return NULL;
- }
- /* Search for a '/' before that */
- p = memrchr(path, '/', p - path);
- if(p == NULL)
- p = path; /* Relative path */
- else
- p++; /* skip '/' */
- /* Get the bus number */
- ret = sscanf(p, "%d", &bnum);
- if(ret != 1) {
- ERR("Path tail is not a bus number: '%s'\n", p);
- return NULL;
- }
- sprintf(dirname, "%03d", bnum);
- sprintf(filename, "%03d", dnum);
- for (bus = usb_busses; bus; bus = bus->next) {
- if (! num_matches(bnum, bus->dirname))
- //if(strcmp(bus->dirname, dirname) != 0)
- continue;
- for (dev = bus->devices; dev; dev = dev->next) {
- //if(strcmp(dev->filename, filename) == 0)
- if (num_matches(dnum, dev->filename))
- return dev;
- }
- }
- ERR("no usb device match '%s'\n", path);
- return NULL;
-}
-
-int get_usb_string(struct astribank_device *astribank, uint8_t item, char *buf, unsigned int len)
-{
- char tmp[BUFSIZ];
- int ret;
-
- assert(astribank->handle);
- if (!item)
- return 0;
- ret = usb_get_string_simple(astribank->handle, item, tmp, BUFSIZ);
- if (ret <= 0)
- return ret;
- return snprintf(buf, len, "%s", tmp);
-}
-
-static int match_interface(const struct astribank_device *astribank,
- const struct interface_type *itype)
-{
- struct usb_interface *interface;
- struct usb_interface_descriptor *iface_desc;
- struct usb_config_descriptor *config_desc;
- int i = itype - interface_types;
- int inum;
- int num_altsetting;
-
- DBG("Checking[%d]: interfaces=%d interface num=%d endpoints=%d: \"%s\"\n",
- i,
- itype->num_interfaces,
- itype->my_interface_num,
- itype->num_endpoints,
- itype->name);
- config_desc = astribank->dev->config;
- if (!config_desc) {
- ERR("No configuration descriptor: strange USB1 controller?\n");
- return 0;
- }
- if(config_desc->bNumInterfaces <= itype->my_interface_num) {
- DBG("Too little interfaces: have %d need %d\n",
- config_desc->bNumInterfaces, itype->my_interface_num + 1);
- return 0;
- }
- if(astribank->my_interface_num != itype->my_interface_num) {
- DBG("Wrong match -- not my interface num (wanted %d)\n", astribank->my_interface_num);
- return 0;
- }
- inum = itype->my_interface_num;
- interface = &config_desc->interface[inum];
- assert(interface != NULL);
- iface_desc = interface->altsetting;
- num_altsetting = interface->num_altsetting;
- assert(num_altsetting != 0);
- assert(iface_desc != NULL);
- if(iface_desc->bInterfaceClass != 0xFF) {
- DBG("Bad interface class 0x%X\n", iface_desc->bInterfaceClass);
- return 0;
- }
- if(iface_desc->bInterfaceNumber != itype->my_interface_num) {
- DBG("Bad interface number %d\n", iface_desc->bInterfaceNumber);
- return 0;
- }
- if(iface_desc->bNumEndpoints != itype->num_endpoints) {
- DBG("Different number of endpoints %d\n", iface_desc->bNumEndpoints);
- return 0;
- }
- return 1;
-}
-
-static int astribank_init(struct astribank_device *astribank)
-{
- struct usb_device_descriptor *dev_desc;
- struct usb_config_descriptor *config_desc;
- struct usb_interface *interface;
- struct usb_interface_descriptor *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- const struct interface_type *fwtype;
- int i;
-
- assert(astribank);
- astribank->handle = usb_open(astribank->dev);
- if(!astribank->handle) {
- ERR("Failed to open usb device '%s/%s': %s\n",
- astribank->dev->bus->dirname, astribank->dev->filename, usb_strerror());
- return 0;
- }
- fwtype = astribank->fwtype;
- if(usb_claim_interface(astribank->handle, fwtype->my_interface_num) != 0) {
- ERR("usb_claim_interface: %s\n", usb_strerror());
- return 0;
- }
- dev_desc = &astribank->dev->descriptor;
- config_desc = astribank->dev->config;
- if (!config_desc) {
- ERR("usb interface without a configuration\n");
- return 0;
- }
- DBG("Got config_desc. Looking for interface %d\n", fwtype->my_interface_num);
- interface = &config_desc->interface[fwtype->my_interface_num];
- iface_desc = interface->altsetting;
- endpoint = iface_desc->endpoint;
- astribank->is_usb2 = (endpoint->wMaxPacketSize == 512);
- for(i = 0; i < iface_desc->bNumEndpoints; i++, endpoint++) {
- DBG("Validating endpoint @ %d (interface %d)\n", i, fwtype->my_interface_num);
- if(endpoint->bEndpointAddress != fwtype->endpoints[i]) {
- ERR("Wrong endpoint 0x%X != 0x%X (at index %d)\n",
- endpoint->bEndpointAddress,
- fwtype->endpoints[i],
- i);
- return 0;
- }
- if(endpoint->bEndpointAddress == MP_EP_OUT || endpoint->bEndpointAddress == MP_EP_IN) {
- if(endpoint->wMaxPacketSize > PACKET_SIZE) {
- ERR("Endpoint #%d wMaxPacketSize too large (%d)\n", i, endpoint->wMaxPacketSize);
- return 0;
- }
- }
- }
- astribank->my_ep_in = fwtype->my_ep_in;
- astribank->my_ep_out = fwtype->my_ep_out;
- if(get_usb_string(astribank, dev_desc->iManufacturer, astribank->iManufacturer, BUFSIZ) < 0)
- return 0;
- if(get_usb_string(astribank, dev_desc->iProduct, astribank->iProduct, BUFSIZ) < 0)
- return 0;
- if(get_usb_string(astribank, dev_desc->iSerialNumber, astribank->iSerialNumber, BUFSIZ) < 0)
- return 0;
- if(get_usb_string(astribank, iface_desc->iInterface, astribank->iInterface, BUFSIZ) < 0)
- return 0;
- DBG("ID=%04X:%04X Manufacturer=[%s] Product=[%s] SerialNumber=[%s] Interface=[%s]\n",
- dev_desc->idVendor,
- dev_desc->idProduct,
- astribank->iManufacturer,
- astribank->iProduct,
- astribank->iSerialNumber,
- astribank->iInterface);
- if(usb_clear_halt(astribank->handle, astribank->my_ep_out) != 0) {
- ERR("Clearing output endpoint: %s\n", usb_strerror());
- return 0;
- }
- if(usb_clear_halt(astribank->handle, astribank->my_ep_in) != 0) {
- ERR("Clearing input endpoint: %s\n", usb_strerror());
- return 0;
- }
- if((i = flush_read(astribank)) < 0) {
- ERR("flush_read failed: %d\n", i);
- return 0;
- }
- return 1;
-}
-
struct astribank_device *astribank_open(const char devpath[], int iface_num)
{
- struct astribank_device *astribank;
- int i;
+ struct astribank_device *astribank = NULL;
+ struct xusb *xusb;
DBG("devpath='%s' iface_num=%d\n", devpath, iface_num);
- if((astribank = malloc(sizeof(*astribank))) == NULL) {
- ERR("Out of memory");
- return NULL;
+ 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;
- usb_init();
- usb_find_busses();
- usb_find_devices();
- astribank->dev = dev_of_path(devpath);
- if(!astribank->dev) {
- ERR("Bailing out\n");
+ if (xusb_claim_interface(astribank->xusb) < 0) {
+ ERR("xusb_claim_interface failed\n");
goto fail;
}
- DBG("Scan interface types (astribank has %d interfaces)\n", astribank->dev->config->bNumInterfaces);
- for(i = 0; i < sizeof(interface_types)/sizeof(interface_types[0]); i++) {
- if(match_interface(astribank, &interface_types[i])) {
- DBG("Identified[%d]: interfaces=%d endpoints=%d: \"%s\"\n",
- i,
- interface_types[i].num_interfaces,
- interface_types[i].num_endpoints,
- interface_types[i].name);
- astribank->fwtype = &interface_types[i];
- goto found;
- }
- }
- ERR("Didn't find suitable device\n");
-fail:
- free(astribank);
- return NULL;
-found:
- if(!astribank_init(astribank))
- goto fail;
astribank->tx_sequenceno = 1;
return astribank;
+fail:
+ if (astribank) {
+ free(astribank);
+ astribank = NULL;
+ }
+ return NULL;
}
/*
@@ -334,100 +118,36 @@
*/
void show_astribank_info(const struct astribank_device *astribank)
{
- struct usb_device_descriptor *dev_desc;
- struct usb_device *dev;
+ struct xusb *xusb;
assert(astribank != NULL);
- dev = astribank->dev;
- dev_desc = &dev->descriptor;
+ xusb = astribank->xusb;
+ assert(xusb != NULL);
if(verbose <= LOG_INFO) {
- INFO("usb:%s/%s: ID=%04X:%04X [%s / %s / %s]\n",
- dev->bus->dirname,
- dev->filename,
- dev_desc->idVendor,
- dev_desc->idProduct,
- astribank->iManufacturer,
- astribank->iProduct,
- astribank->iSerialNumber);
+ xusb_showinfo(xusb);
} else {
- printf("USB Bus/Device: [%s/%s]\n", dev->bus->dirname, dev->filename);
- printf("USB Firmware Type: [%s]\n", astribank->fwtype->name);
- printf("USB iManufacturer: [%s]\n", astribank->iManufacturer);
- printf("USB iProduct: [%s]\n", astribank->iProduct);
- printf("USB iSerialNumber: [%s]\n", astribank->iSerialNumber);
+ 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->handle)
- return; /* Nothing to do */
- if(!disconnected) {
- if(usb_release_interface(astribank->handle, astribank->fwtype->my_interface_num) != 0) {
- ERR("Releasing interface: usb: %s\n", usb_strerror());
- }
- }
- if(usb_close(astribank->handle) != 0) {
- ERR("Closing device: usb: %s\n", usb_strerror());
+ if (astribank->xusb) {
+ xusb_close(astribank->xusb);
+ astribank->xusb = NULL;
}
astribank->tx_sequenceno = 0;
- astribank->handle = NULL;
-}
-
-int send_usb(struct astribank_device *astribank, char *buf, int len, int timeout)
-{
- int ret;
-
- dump_packet(LOG_DEBUG, __FUNCTION__, buf, len);
- if(astribank->my_ep_out & USB_ENDPOINT_IN) {
- ERR("send_usb called with an input endpoint 0x%x\n", astribank->my_ep_out);
- return -EINVAL;
- }
- ret = usb_bulk_write(astribank->handle, astribank->my_ep_out, buf, len, timeout);
- if(ret < 0) {
- /*
- * If the device was gone, it may be the
- * result of renumeration. Ignore it.
- */
- if(ret != -ENODEV) {
- ERR("bulk_write to endpoint 0x%x failed: (%d) %s\n",
- astribank->my_ep_out, ret, usb_strerror());
- dump_packet(LOG_ERR, "send_usb[ERR]", buf, len);
- exit(2);
- } else {
- DBG("bulk_write to endpoint 0x%x got ENODEV\n", astribank->my_ep_out);
- astribank_close(astribank, 1);
- }
- return ret;
- } else if(ret != len) {
- ERR("bulk_write to endpoint 0x%x short write: (%d) %s\n",
- astribank->my_ep_out, ret, usb_strerror());
- dump_packet(LOG_ERR, "send_usb[ERR]", buf, len);
- return -EFAULT;
- }
- return ret;
-}
-
-int recv_usb(struct astribank_device *astribank, char *buf, size_t len, int timeout)
-{
- int ret;
-
- if(astribank->my_ep_in & USB_ENDPOINT_OUT) {
- ERR("recv_usb called with an output endpoint 0x%x\n", astribank->my_ep_in);
- return -EINVAL;
- }
- ret = usb_bulk_read(astribank->handle, astribank->my_ep_in, buf, len, timeout);
- if(ret < 0) {
- DBG("bulk_read from endpoint 0x%x failed: (%d) %s\n",
- astribank->my_ep_in, ret, usb_strerror());
- memset(buf, 0, len);
- return ret;
- }
- dump_packet(LOG_DEBUG, __FUNCTION__, buf, ret);
- return ret;
-}
-
+}
+
+#if 0
int flush_read(struct astribank_device *astribank)
{
char tmpbuf[BUFSIZ];
@@ -441,10 +161,11 @@
return ret;
} else if(ret > 0) {
DBG("Got %d bytes:\n", ret);
- dump_packet(LOG_DEBUG, __FUNCTION__, tmpbuf, ret);
+ dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, tmpbuf, ret);
}
return 0;
}
+#endif
int release_isvalid(uint16_t release)
@@ -541,12 +262,10 @@
int astribank_has_twinstar(struct astribank_device *astribank)
{
- struct usb_device_descriptor *dev_desc;
uint16_t product_series;
assert(astribank != NULL);
- dev_desc = &astribank->dev->descriptor;
- product_series = dev_desc->idProduct;
+ product_series = xusb_product_id(astribank->xusb);
product_series &= 0xFFF0;
if(product_series == 0x1160) /* New boards */
return 1;
Modified: tools/trunk/xpp/astribank_usb.h
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/astribank_usb.h?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/astribank_usb.h (original)
+++ tools/trunk/xpp/astribank_usb.h Thu Mar 10 12:48:11 2011
@@ -23,7 +23,8 @@
*/
#include <stdio.h>
-#include <usb.h>
+#include <xusb.h>
+#include <xtalk.h>
#include "mpp.h"
/*
@@ -63,14 +64,12 @@
};
struct astribank_device {
- struct usb_device *dev;
+ 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 iManufacturer[BUFSIZ];
- char iProduct[BUFSIZ];
- char iSerialNumber[BUFSIZ];
char iInterface[BUFSIZ];
int is_usb2;
enum eeprom_type eeprom_type;
@@ -79,7 +78,6 @@
uint8_t mpp_proto_version;
struct eeprom_table *eeprom;
struct firmware_versions fw_versions;
- const struct interface_type *fwtype;
uint16_t tx_sequenceno;
};
Modified: tools/trunk/xpp/mpp.h
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/mpp.h?view=diff&rev=9825&r1=9824&r2=9825
==============================================================================
--- tools/trunk/xpp/mpp.h (original)
+++ tools/trunk/xpp/mpp.h Thu Mar 10 12:48:11 2011
@@ -25,6 +25,10 @@
/*
* MPP - Managment Processor Protocol definitions
*/
+
+#include <mpptalk_defs.h>
+#include <stdint.h>
+#include <xtalk.h>
#ifdef __GNUC__
#define PACKED __attribute__((packed))
@@ -63,7 +67,8 @@
uint8_t ports_bri;
uint8_t ports_pri;
uint8_t extra_features; /* BIT(0) - TwinStar */
- uint8_t reserved[3];
+ uint8_t ports_echo;
+ uint8_t reserved[2];
uint32_t timestamp;
} PACKED;
@@ -81,53 +86,6 @@
char text[24];
} PACKED;
-enum mpp_command_ops {
- /* MSB of op signifies a reply from device */
- MPP_ACK = 0x80,
-
- MPP_PROTO_QUERY = 0x01,
- MPP_PROTO_REPLY = 0x81,
-
- MPP_RENUM = 0x0B, /* Trigger USB renumeration */
-
- MPP_EEPROM_SET = 0x0D,
-
- MPP_CAPS_GET = 0x0E,
- MPP_CAPS_GET_REPLY = 0x8E,
- MPP_CAPS_SET = 0x0F, /* Set AB capabilities */
-
- MPP_DEV_SEND_START = 0x05,
- MPP_DEV_SEND_SEG = 0x07,
- MPP_DEV_SEND_END = 0x09,
-
- MPP_STATUS_GET = 0x11, /* Get Astribank Status */
- MPP_STATUS_GET_REPLY = 0x91,
- MPP_STATUS_GET_REPLY_V13 = 0x91, /* backward compat */
-
- MPP_EXTRAINFO_GET = 0x13, /* Get extra vendor information */
- MPP_EXTRAINFO_GET_REPLY = 0x93,
- MPP_EXTRAINFO_SET = 0x15, /* Set extra vendor information */
-
- MPP_EEPROM_BLK_RD = 0x27,
- MPP_EEPROM_BLK_RD_REPLY = 0xA7,
-
- MPP_SER_SEND = 0x37,
- MPP_SER_RECV = 0xB7,
-
- MPP_RESET = 0x45, /* Reset both FPGA and USB firmwares */
- MPP_HALF_RESET = 0x47, /* Reset only FPGA firmware */
-
- /* Twinstar */
- MPP_TWS_WD_MODE_SET = 0x31, /* Set watchdog off/on guard */
- MPP_TWS_WD_MODE_GET = 0x32, /* Current watchdog mode */
- MPP_TWS_WD_MODE_GET_REPLY = 0xB2, /* Current watchdog mode */
- MPP_TWS_PORT_SET = 0x34, /* USB-[0/1] */
- MPP_TWS_PORT_GET = 0x35, /* USB-[0/1] */
- MPP_TWS_PORT_GET_REPLY = 0xB5, /* USB-[0/1] */
- MPP_TWS_PWR_GET = 0x36, /* Power: bits -> USB ports */
- MPP_TWS_PWR_GET_REPLY = 0xB6, /* Power: bits -> USB ports */
-};
-
struct mpp_header {
uint16_t len;
uint16_t seq;
@@ -141,33 +99,10 @@
/* Individual commands structure */
-#define CMD_DEF(name, ...) struct d_ ## name { __VA_ARGS__ } PACKED d_ ## name
-
-CMD_DEF(ACK,
- uint8_t stat;
- );
-
-CMD_DEF(PROTO_QUERY,
- uint8_t proto_version;
- uint8_t reserved;
- );
-
-CMD_DEF(PROTO_REPLY,
- uint8_t proto_version;
- uint8_t reserved;
- );
-
-CMD_DEF(STATUS_GET);
-
-CMD_DEF(STATUS_GET_REPLY_V13,
- uint8_t i2cs_data;
-
-#define STATUS_FPGA_LOADED(x) ((x) & 0x01)
- uint8_t status; /* BIT(0) - FPGA is loaded */
- );
+CMD_DEF(MPP, STATUS_GET);
-CMD_DEF(STATUS_GET_REPLY,
+CMD_DEF(MPP, STATUS_GET_REPLY,
uint8_t i2cs_data;
#define STATUS_FPGA_LOADED(x) ((x) & 0x01)
@@ -175,170 +110,90 @@
struct firmware_versions fw_versions;
);
-CMD_DEF(EEPROM_SET,
+CMD_DEF(MPP, EEPROM_SET,
struct eeprom_table data;
);
-CMD_DEF(CAPS_GET);
+CMD_DEF(MPP, CAPS_GET);
-CMD_DEF(CAPS_GET_REPLY,
+CMD_DEF(MPP, CAPS_GET_REPLY,
struct eeprom_table data;
struct capabilities capabilities;
struct capkey key;
);
-CMD_DEF(CAPS_SET,
+CMD_DEF(MPP, CAPS_SET,
struct eeprom_table data;
struct capabilities capabilities;
struct capkey key;
);
-CMD_DEF(EXTRAINFO_GET);
+CMD_DEF(MPP, EXTRAINFO_GET);
-CMD_DEF(EXTRAINFO_GET_REPLY,
+CMD_DEF(MPP, EXTRAINFO_GET_REPLY,
struct extrainfo info;
);
-CMD_DEF(EXTRAINFO_SET,
+CMD_DEF(MPP, EXTRAINFO_SET,
struct extrainfo info;
);
-CMD_DEF(RENUM);
+CMD_DEF(MPP, RENUM);
-CMD_DEF(EEPROM_BLK_RD,
+CMD_DEF(MPP, EEPROM_BLK_RD,
uint16_t offset;
uint16_t len;
);
-CMD_DEF(EEPROM_BLK_RD_REPLY,
+CMD_DEF(MPP, EEPROM_BLK_RD_REPLY,
uint16_t offset;
uint8_t data[0];
);
-CMD_DEF(DEV_SEND_START,
+CMD_DEF(MPP, DEV_SEND_START,
uint8_t dest;
char ihex_version[VERSION_LEN];
);
-CMD_DEF(DEV_SEND_END);
+CMD_DEF(MPP, DEV_SEND_END);
-CMD_DEF(DEV_SEND_SEG,
+CMD_DEF(MPP, DEV_SEND_SEG,
uint16_t offset;
uint8_t data[0];
);
-CMD_DEF(RESET);
-CMD_DEF(HALF_RESET);
+CMD_DEF(MPP, RESET);
+CMD_DEF(MPP, HALF_RESET);
-CMD_DEF(SER_SEND,
+CMD_DEF(MPP, SER_SEND,
uint8_t data[0];
);
-CMD_DEF(SER_RECV,
+CMD_DEF(MPP, SER_RECV,
uint8_t data[0];
);
-CMD_DEF(TWS_WD_MODE_SET,
+CMD_DEF(MPP, TWS_WD_MODE_SET,
uint8_t wd_active;
);
-CMD_DEF(TWS_WD_MODE_GET);
-CMD_DEF(TWS_WD_MODE_GET_REPLY,
+CMD_DEF(MPP, TWS_WD_MODE_GET);
+CMD_DEF(MPP, TWS_WD_MODE_GET_REPLY,
uint8_t wd_active;
);
-CMD_DEF(TWS_PORT_SET,
+CMD_DEF(MPP, TWS_PORT_SET,
uint8_t portnum;
);
-CMD_DEF(TWS_PORT_GET);
-CMD_DEF(TWS_PORT_GET_REPLY,
+CMD_DEF(MPP, TWS_PORT_GET);
+CMD_DEF(MPP, TWS_PORT_GET_REPLY,
uint8_t portnum;
);
-CMD_DEF(TWS_PWR_GET);
-CMD_DEF(TWS_PWR_GET_REPLY,
+CMD_DEF(MPP, TWS_PWR_GET);
+CMD_DEF(MPP, TWS_PWR_GET_REPLY,
uint8_t power;
);
-#undef CMD_DEF
-
-#define MEMBER(n) struct d_ ## n d_ ## n
-
-struct mpp_command {
- struct mpp_header header;
- union {
- MEMBER(ACK);
- MEMBER(PROTO_QUERY);
- MEMBER(PROTO_REPLY);
- MEMBER(STATUS_GET);
- MEMBER(STATUS_GET_REPLY_V13);
- MEMBER(STATUS_GET_REPLY);
- MEMBER(EEPROM_SET);
- MEMBER(CAPS_GET);
- MEMBER(CAPS_GET_REPLY);
- MEMBER(CAPS_SET);
- MEMBER(EXTRAINFO_GET);
- MEMBER(EXTRAINFO_GET_REPLY);
- MEMBER(EXTRAINFO_SET);
- MEMBER(RENUM);
- MEMBER(EEPROM_BLK_RD);
- MEMBER(EEPROM_BLK_RD_REPLY);
- MEMBER(DEV_SEND_START);
- MEMBER(DEV_SEND_SEG);
- MEMBER(DEV_SEND_END);
- MEMBER(RESET);
- MEMBER(HALF_RESET);
- MEMBER(SER_SEND);
- MEMBER(SER_RECV);
- /* Twinstar */
- MEMBER(TWS_WD_MODE_SET);
- MEMBER(TWS_WD_MODE_GET);
- MEMBER(TWS_WD_MODE_GET_REPLY);
- MEMBER(TWS_PORT_SET);
- MEMBER(TWS_PORT_GET);
- MEMBER(TWS_PORT_GET_REPLY);
- MEMBER(TWS_PWR_GET);
- MEMBER(TWS_PWR_GET_REPLY);
- uint8_t raw_data[0];
- } PACKED alt;
-} PACKED;
-#undef MEMBER
-
-#define CMD_FIELD(cmd, name, field) ((cmd)->alt.d_ ## name.field)
-
-enum mpp_ack_stat {
- STAT_OK = 0x00, /* acknowledges previous command */
- STAT_FAIL = 0x01, /* Last command failed */
- STAT_RESET_FAIL = 0x02, /* reset failed */
- STAT_NODEST = 0x03, /* No destination is selected */
- STAT_MISMATCH = 0x04, /* Data mismatch */
- STAT_NOACCESS = 0x05, /* No access */
- STAT_BAD_CMD = 0x06, /* Bad command */
- STAT_TOO_SHORT = 0x07, /* Packet is too short */
- STAT_ERROFFS = 0x08, /* Offset error */
- STAT_NOCODE = 0x09, /* Source was not burned before */
- STAT_NO_LEEPROM = 0x0A, /* Large EEPROM was not found */
- STAT_NO_EEPROM = 0x0B, /* No EEPROM was found */
- STAT_WRITE_FAIL = 0x0C, /* Writing to device failed */
- STAT_FPGA_ERR = 0x0D, /* FPGA error */
- STAT_KEY_ERR = 0x0E, /* Bad Capabilities Key */
- STAT_NOCAPS_ERR = 0x0F, /* No matching capability */
- STAT_NOPWR_ERR = 0x10, /* No power on USB connector */
- STAT_CAPS_FPGA_ERR = 0x11, /* Setting of the capabilities while FPGA is loaded */
-};
-
-enum eeprom_type { /* EEPROM_QUERY: i2cs(ID1, ID0) */
- EEPROM_TYPE_NONE = 0,
- EEPROM_TYPE_SMALL = 1,
- EEPROM_TYPE_LARGE = 2,
- EEPROM_TYPE_UNUSED = 3,
-};
-
-enum dev_dest {
- DEST_NONE = 0x00,
- DEST_FPGA = 0x01,
- DEST_EEPROM = 0x02,
-};
-
#endif /* MPP_H */
Added: tools/trunk/xpp/mpptalk.c
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/mpptalk.c?view=auto&rev=9825
==============================================================================
--- tools/trunk/xpp/mpptalk.c (added)
+++ tools/trunk/xpp/mpptalk.c Thu Mar 10 12:48:11 2011
@@ -1,0 +1,915 @@
+/*
+ * 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 <assert.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include "hexfile.h"
+#include "astribank_usb.h"
+#include "mpp.h"
+#include "mpptalk.h"
+#include <debug.h>
+#include <xusb.h>
+#include <xtalk.h>
+
+static const char rcsid[] = "$Id$";
+
+#define DBG_MASK 0x02
+
+const char *ack_status_msg(uint8_t status)
+{
+ const static char *msgs[] = {
+ [STAT_OK] = "Acknowledges previous command",
+ [STAT_FAIL] = "Last command failed",
+ [STAT_RESET_FAIL] = "Reset failed",
+ [STAT_NODEST] = "No destination is selected",
+ [STAT_MISMATCH] = "Data mismatch",
+ [STAT_NOACCESS] = "No access",
+ [STAT_BAD_CMD] = "Bad command",
+ [STAT_TOO_SHORT] = "Packet is too short",
+ [STAT_ERROFFS] = "Offset error",
+ [STAT_NOCODE] = "Source was not burned before",
+ [STAT_NO_LEEPROM] = "Large EEPROM was not found",
+ [STAT_NO_EEPROM] = "No EEPROM was found",
+ [STAT_WRITE_FAIL] = "Writing to device failed",
+ [STAT_FPGA_ERR] = "FPGA error",
+ [STAT_KEY_ERR] = "Bad Capabilities Key",
+ [STAT_NOCAPS_ERR] = "No matching capability",
+ [STAT_NOPWR_ERR] = "No power on USB connector",
+ [STAT_CAPS_FPGA_ERR] = "Setting of the capabilities while FPGA is loaded",
+ };
+ if(status > sizeof(msgs)/sizeof(msgs[0]))
+ return "ERROR CODE TOO LARGE";
+ if(!msgs[status])
+ return "MISSING ERROR CODE";
+ return msgs[status];
+}
+
+const char *eeprom_type2str(int et)
+{
+ const static char *msgs[] = {
+ [EEPROM_TYPE_NONE] = "NONE",
+ [EEPROM_TYPE_SMALL] = "SMALL",
+ [EEPROM_TYPE_LARGE] = "LARGE",
+ [EEPROM_TYPE_UNUSED] = "UNUSED",
+ };
+ if(et > sizeof(msgs)/sizeof(msgs[0]))
+ return NULL;
+ return msgs[et];
+};
+
+const char *dev_dest2str(int dest)
+{
+ const static char *msgs[] = {
+ [DEST_NONE] = "NONE",
+ [DEST_FPGA] = "FPGA",
+ [DEST_EEPROM] = "EEPROM",
+ };
+ if(dest > sizeof(msgs)/sizeof(msgs[0]))
+ return NULL;
+ return msgs[dest];
+};
+
+union XTALK_PDATA(MPP) {
+ MEMBER(MPP, STATUS_GET);
+ MEMBER(MPP, STATUS_GET_REPLY);
+ MEMBER(MPP, EEPROM_SET);
+ MEMBER(MPP, CAPS_GET);
+ MEMBER(MPP, CAPS_GET_REPLY);
+ MEMBER(MPP, CAPS_SET);
+ MEMBER(MPP, EXTRAINFO_GET);
+ MEMBER(MPP, EXTRAINFO_GET_REPLY);
+ MEMBER(MPP, EXTRAINFO_SET);
+ MEMBER(MPP, RENUM);
+ MEMBER(MPP, EEPROM_BLK_RD);
+ MEMBER(MPP, EEPROM_BLK_RD_REPLY);
+ MEMBER(MPP, DEV_SEND_SEG);
+ MEMBER(MPP, DEV_SEND_START);
+ MEMBER(MPP, DEV_SEND_END);
+ MEMBER(MPP, RESET);
+ MEMBER(MPP, HALF_RESET);
+ MEMBER(MPP, SER_SEND);
+ MEMBER(MPP, SER_RECV);
+ /* Twinstar */
+ MEMBER(MPP, TWS_WD_MODE_SET);
+ MEMBER(MPP, TWS_WD_MODE_GET);
+ MEMBER(MPP, TWS_WD_MODE_GET_REPLY);
+ MEMBER(MPP, TWS_PORT_SET);
+ MEMBER(MPP, TWS_PORT_GET);
+ MEMBER(MPP, TWS_PORT_GET_REPLY);
+ MEMBER(MPP, TWS_PWR_GET);
+ MEMBER(MPP, TWS_PWR_GET_REPLY);
+} PACKED members;
+
+struct xtalk_protocol astribank_proto = {
+ .name = "ABNK",
+ .proto_version = 0x14,
+ .commands = {
+ CMD_SEND(MPP, STATUS_GET),
+ CMD_RECV(MPP, STATUS_GET_REPLY, NULL),
+ CMD_SEND(MPP, EEPROM_SET),
+ CMD_SEND(MPP, CAPS_GET),
+ CMD_RECV(MPP, CAPS_GET_REPLY, NULL),
+ CMD_SEND(MPP, CAPS_SET),
+ CMD_SEND(MPP, EXTRAINFO_GET),
+ CMD_RECV(MPP, EXTRAINFO_GET_REPLY, NULL),
+ CMD_SEND(MPP, EXTRAINFO_SET),
+ CMD_SEND(MPP, RENUM),
+ CMD_SEND(MPP, EEPROM_BLK_RD),
+ CMD_RECV(MPP, EEPROM_BLK_RD_REPLY, NULL),
+ CMD_SEND(MPP, DEV_SEND_SEG),
+ CMD_SEND(MPP, DEV_SEND_START),
+ CMD_SEND(MPP, DEV_SEND_END),
+ CMD_SEND(MPP, RESET),
+ CMD_SEND(MPP, HALF_RESET),
[... 3057 lines stripped ...]
More information about the svn-commits
mailing list