X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/blobdiff_plain/2c2119ebab64d22a917a658c82946913c52ff7e4..f10480d179d5e5b0fc19c04ab9e4ec3e50e46329:/usb-driver.c diff --git a/usb-driver.c b/usb-driver.c index cf17890..ea8a7a7 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -18,10 +18,12 @@ #include #include #include +#include #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;