]> git.zerfleddert.de Git - usb-driver/blobdiff - usb-driver.c
init libusb
[usb-driver] / usb-driver.c
index cf17890ec75ba56780d63b3ce40e4bae173f1af6..ea8a7a70085996e0a898e619e790bef3190f1c29 100644 (file)
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <stdio.h>
+#include <usb.h>
 #include "xilinx.h"
 
 static int (*ioctl_func) (int, int, void *) = NULL;
 static int windrvrfd = 0;
+static struct usb_bus *busses = NULL;
 
 void hexdump(unsigned char *buf, int len);
 void diff(unsigned char *buf1, unsigned char *buf2, int len);
@@ -88,7 +90,7 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                        {
                                struct interrupt *it = (struct interrupt*)(wdheader->data);
 
-                               fprintf(stderr," Handle: %lu, Options: %lx, ncmds: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds);
+                               fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
 
                                it->fEnableOk = 1;
                                //ret = (*ioctl_func) (fd, request, wdioctl);
@@ -101,15 +103,11 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                        {
                                struct interrupt *it = (struct interrupt*)(wdheader->data);
 
-                               fprintf(stderr," Handle: %lu, Options: %lx, ncmds: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds);
-
-                               hexdump(wdheader->data, wdheader->size);
+                               fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
                                //it->dwCounter = 0;
                                //it->fStopped = 1;
                                ret = (*ioctl_func) (fd, request, wdioctl);
-                               fprintf(stderr,"\n\n");
-                               hexdump(wdheader->data, wdheader->size);
-                               fprintf(stderr,"\n");
+                               fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
                        }
                        break;
 
@@ -139,6 +137,24 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                        }
                        break;
 
+               case EVENT_REGISTER:
+                       fprintf(stderr,"EVENT_REGISTER\n");
+                       {
+                               struct event *e = (struct event*)(wdheader->data);
+                               int i;
+
+                               fprintf(stderr,"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++)
+                                       fprintf(stderr,"match: dev: %x:%x, 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);
+
+                               ret = (*ioctl_func) (fd, request, wdioctl);
+
+                               fprintf(stderr,"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++)
+                                       fprintf(stderr,"match: dev: %x:%x, 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);
+                       }
+                       break;
+
                case TRANSFER:
                        fprintf(stderr,"TRANSFER\n");
                        ret = (*ioctl_func) (fd, request, wdioctl);
@@ -151,7 +167,14 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
 
                case INT_WAIT:
                        fprintf(stderr,"INT_WAIT\n");
-                       ret = (*ioctl_func) (fd, request, wdioctl);
+                       {
+                               struct interrupt *it = (struct interrupt*)(wdheader->data);
+
+                               fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
+
+                               ret = (*ioctl_func) (fd, request, wdioctl);
+                               fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
+                       }
                        break;
 
                case CARD_UNREGISTER:
@@ -161,12 +184,20 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
 
                case EVENT_PULL:
                        fprintf(stderr,"EVENT_PULL\n");
-                       ret = (*ioctl_func) (fd, request, wdioctl);
-                       break;
+                       {
+                               struct event *e = (struct event*)(wdheader->data);
+                               int i;
 
-               case EVENT_REGISTER:
-                       fprintf(stderr,"EVENT_REGISTER\n");
-                       ret = (*ioctl_func) (fd, request, wdioctl);
+                               fprintf(stderr,"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++)
+                                       fprintf(stderr,"match: dev: %x:%x, 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);
+
+                               ret = (*ioctl_func) (fd, request, wdioctl);
+
+                               fprintf(stderr,"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++)
+                                       fprintf(stderr,"match: dev: %x:%x, 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);
+                       }
                        break;
 
                default:
@@ -200,6 +231,13 @@ int open (const char *pathname, int flags, ...)
        if (!strcmp (pathname, "/dev/windrvr6")) {
                fprintf(stderr,"opening windrvr6\n");
                windrvrfd = fd;
+               if (!busses) {
+                       usb_init();
+                       usb_find_busses();
+                       usb_find_devices();
+
+                       busses = usb_get_busses();
+               }
        }
 
        return fd;
Impressum, Datenschutz