+ case EVENT_REGISTER_OLD:
+ case EVENT_REGISTER:
+ DPRINTF("EVENT_REGISTER\n");
+ {
+ struct event *e = (struct event*)(wdheader->data);
+ struct usb_bus *bus;
+ char* devpos;
+ int busnum = -1, devnum = -1;
+ int i;
+
+ DPRINTF("handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n",
+ e->handle, e->dwAction,
+ e->dwStatus, e->dwEventId, e->dwCardType,
+ e->hKernelPlugIn, e->dwOptions,
+ e->u.Usb.deviceId.dwVendorId,
+ e->u.Usb.deviceId.dwProductId,
+ e->u.Usb.dwUniqueID, e->dwEventVer,
+ e->dwNumMatchTables);
+
+ devpos = getenv("XILINX_USB_DEV");
+ if (devpos != NULL) {
+ int j;
+ char *devstr = NULL, *remainder;
+
+ DPRINTF("XILINX_USB_DEV=%s\n", devpos);
+
+ for (j = 0; j < strlen(devpos) && devpos[j] != 0; j++) {
+ if (devpos[j] == ':') {
+ devpos[j] = 0;
+ devstr = &(devpos[j+1]);
+ }
+ }
+
+ if (devstr && strlen(devstr) > 0) {
+ busnum = strtol(devpos, &remainder, 10);
+ if (devpos == remainder) {
+ busnum = -1;
+ } else {
+ devnum = strtol(devstr, &remainder, 10);
+ if (devstr == remainder) {
+ busnum = -1;
+ devnum = -1;
+ } else {
+ fprintf(stderr,"Using XILINX platform cable USB at %03d:%03d\n",
+ busnum, devnum);
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < e->dwNumMatchTables; i++) {
+
+ DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
+ e->matchTables[i].VendorId,
+ e->matchTables[i].ProductId,
+ e->matchTables[i].bDeviceClass,
+ e->matchTables[i].bDeviceSubClass,
+ e->matchTables[i].bInterfaceClass,
+ e->matchTables[i].bInterfaceSubClass,
+ e->matchTables[i].bInterfaceProtocol);
+
+ for (bus = busses; bus; bus = bus->next) {
+ struct usb_device *dev;
+
+ if ((devnum != -1) && (strtol(bus->dirname, NULL, 10) != busnum))
+ continue;
+
+ for (dev = bus->devices; dev; dev = dev->next) {
+ struct usb_device_descriptor *desc = &(dev->descriptor);
+
+ if((desc->idVendor == e->matchTables[i].VendorId) &&
+ (desc->idProduct == e->matchTables[i].ProductId) &&
+ (desc->bDeviceClass == e->matchTables[i].bDeviceClass) &&
+ (desc->bDeviceSubClass == e->matchTables[i].bDeviceSubClass) &&
+ ((devnum == -1) || (strtol(dev->filename, NULL, 10) == devnum)) ) {
+ int ac;
+ for (ac = 0; ac < desc->bNumConfigurations; ac++) {
+ struct usb_interface *interface = dev->config[ac].interface;
+ int ai;
+
+ for (ai = 0; ai < interface->num_altsetting; ai++) {
+
+ DPRINTF("intclass: %x, intsubclass: %x, intproto: %x\n",
+ interface->altsetting[i].bInterfaceClass,
+ interface->altsetting[i].bInterfaceSubClass,
+ interface->altsetting[i].bInterfaceProtocol);
+
+ if ((interface->altsetting[ai].bInterfaceSubClass == e->matchTables[i].bInterfaceSubClass) &&
+ (interface->altsetting[ai].bInterfaceProtocol == e->matchTables[i].bInterfaceProtocol)){
+ /* TODO: check interfaceClass! */
+ DPRINTF("found device with libusb\n");
+ usbdevice = dev;
+ card_type = e->dwCardType;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+#ifndef NO_WINDRVR
+ ret = (*ioctl_func) (fd, request, wdioctl);
+#else
+ e->handle++;
+#endif
+
+#ifdef DEBUG
+ DPRINTF("handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n",
+ e->handle, e->dwAction,
+ e->dwStatus, e->dwEventId, e->dwCardType,
+ e->hKernelPlugIn, e->dwOptions,
+ e->u.Usb.deviceId.dwVendorId,
+ e->u.Usb.deviceId.dwProductId,
+ e->u.Usb.dwUniqueID, e->dwEventVer,
+ e->dwNumMatchTables);
+
+ for (i = 0; i < e->dwNumMatchTables; i++)
+ DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
+ e->matchTables[i].VendorId,
+ e->matchTables[i].ProductId,
+ e->matchTables[i].bDeviceClass,
+ e->matchTables[i].bDeviceSubClass,
+ e->matchTables[i].bInterfaceClass,
+ e->matchTables[i].bInterfaceSubClass,
+ e->matchTables[i].bInterfaceProtocol);
+#endif
+ }