static struct usb_device *usbdevice;
static usb_dev_handle *usb_devhandle = NULL;
static unsigned long card_type;
+static int ints_enabled = 0;
#define NO_WINDRVR 1
return (*ioctl_func) (fd, request, wdioctl);
}
+ fprintf(stderr,"PID %d: ",getpid());
switch(request) {
case VERSION:
version = (struct version_struct*)(wdheader->data);
{
fprintf(stderr,"Read: ");
hexdump(ut->pBuffer, ut->dwBytesTransferred);
+ fprintf(stderr,"\n");
}
- fprintf(stderr,"\n");
}
break;
case INT_ENABLE:
- fprintf(stderr,"faking INT_ENABLE");
+ fprintf(stderr,"INT_ENABLE\n");
{
struct interrupt *it = (struct interrupt*)(wdheader->data);
+ 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->fEnableOk = 1;
+ ints_enabled = 1;
//ret = (*ioctl_func) (fd, request, wdioctl);
}
#else
it->dwCounter = 0;
it->fStopped = 1;
+ ints_enabled = 0;
#endif
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 USB_GET_DEVICE_DATA:
- fprintf(stderr,"USB_GET_DEVICE_DATA\n");
+ fprintf(stderr,"faking USB_GET_DEVICE_DATA\n");
{
struct usb_get_device_data *ugdd = (struct usb_get_device_data*)(wdheader->data);
int pSize;
fprintf(stderr, "unique: %lu, bytes: %lu, options: %lx\n", ugdd->dwUniqueID, ugdd->dwBytes, ugdd->dwOptions);
pSize = ugdd->dwBytes;
-#ifndef NO_WINDRVR
- ret = (*ioctl_func) (fd, request, wdioctl);
-#else
+ //ret = (*ioctl_func) (fd, request, wdioctl);
if (!ugdd->dwBytes) {
if (usbdevice) {
ugdd->dwBytes = usb_deviceinfo(NULL);
} else {
usb_deviceinfo((unsigned char*)ugdd->pBuf);
}
-#endif
+
if (pSize) {
struct usb_device_info *udi = (struct usb_device_info*)ugdd->pBuf;
fprintf(stderr, "Vendor: %x\n", udi->Descriptor.idVendor);
-
- hexdump(ugdd->pBuf, pSize);
- fprintf(stderr, "\n");
}
}
break;
{
struct interrupt *it = (struct interrupt*)(wdheader->data);
+ 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);
#ifndef NO_WINDRVR
it->dwCounter = 1;
} else {
//FIXME: signal durch FUTEX, overload futex!
- kill(getpid(), SIGHUP);
+ while(ints_enabled) {sleep(1);}
}
} else {
- kill(getpid(), SIGHUP);
+ while(ints_enabled) {sleep(1);}
}
#endif
- 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);
+ fprintf(stderr,"INT_WAIT_RETURN: 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;
e->dwCardType = card_type;
e->dwAction = 1;
e->dwEventId = 109;
- e->u.Usb.dwUniqueID = 4711;
+ e->u.Usb.dwUniqueID = 110;
e->matchTables[0].VendorId = usbdevice->descriptor.idVendor;
e->matchTables[0].ProductId = usbdevice->descriptor.idProduct;
e->matchTables[0].bDeviceClass = usbdevice->descriptor.bDeviceClass;
fprintf(stderr,"handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lx, 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: %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);
+
}
break;
return ret;
}
+int futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3) {
+ static int (*func) (int*, int, int, const struct timespec*, int*, int) = NULL;
+ int ret;
+
+ if (!func)
+ func = (int (*) (int*, int, int, const struct timespec*, int*, int)) dlsym(REAL_LIBC, "futex");
+
+ fprintf(stderr,"FUTEX: %x\n", (unsigned int)uaddr);
+ ret = (*func) (uaddr, op, val, timeout, uaddr2, val3);
+
+ return ret;
+}
+
+
#if 0
void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{