static int parportfd = -1;
static unsigned long ppbase = 0;
static unsigned long ecpbase = 0;
-static struct pports *pplist = NULL;
FILE *modulesfp = NULL;
+FILE *baseaddrfp = NULL;
+int baseaddrnum = 0;
static int modules_read = 0;
static struct usb_bus *busses = NULL;
static struct usb_device *usbdevice;
switch(request & ~(0xc0000000)) {
case VERSION:
version = (struct version_struct*)(wdheader->data);
- strcpy(version->version, "libusb-driver.so $Revision: 1.59 $");
+ strcpy(version->version, "libusb-driver.so $Revision: 1.60 $");
version->versionul = 802;
DPRINTF("VERSION\n");
break;
ret = (*ioctl_func) (fd, request, wdioctl);
#else
if (parportfd < 0) {
- int max = -1;
- struct pports **port = &pplist;
-
- while (*port) {
- DPRINTF("Looking up parallel port in linked list, entry: %d\n", (*port)->num);
- if (max < (*port)->num)
- max = (*port)->num;
-
- if ((*port)->base == (unsigned long)cr->Card.Item[0].I.IO.dwAddr) {
- break;
- }
-
- port = &((*port)->next);
- }
-
- if (!(*port)) { /* not found */
- (*port) = malloc(sizeof(struct pports));
- if (!(*port)) {
- perror("malloc");
- exit(EXIT_FAILURE);
- }
-
- (*port)->base = (unsigned long)cr->Card.Item[0].I.IO.dwAddr;
- (*port)->num = max+1;
- (*port)->next = NULL;
-
- DPRINTF("parallel port not in linked list, new entry: %d\n", (*port)->num);
- }
-
- snprintf(ppdev, sizeof(ppdev), "/dev/parport%d", (*port)->num);
+ snprintf(ppdev, sizeof(ppdev), "/dev/parport%lu",
+ (unsigned long)cr->Card.Item[0].I.IO.dwAddr / 0x10);
DPRINTF("opening %s\n", ppdev);
parportfd = open(ppdev, O_RDWR|O_EXCL);
FILE *fopen(const char *path, const char *mode) {
FILE *ret;
static FILE* (*func) (const char*, const char*) = NULL;
+ char buf[256];
+ int i;
if (!func)
func = (FILE* (*) (const char*, const char*)) dlsym(RTLD_NEXT, "fopen");
ret = (*func) (path, mode);
- if (!strcmp (path, "/proc/modules")) {
+ if (!strcmp(path, "/proc/modules")) {
DPRINTF("opening /proc/modules\n");
#ifdef NO_WINDRVR
modulesfp = ret;
modules_read = 0;
#endif
}
+
+ if (ret) {
+ for (i = 0; i < 4; i++) {
+ snprintf(buf, sizeof(buf), "/proc/sys/dev/parport/parport%d/base-addr", i);
+ if (!strcmp(path, buf)) {
+ DPRINTF("open base-addr of parport%d\n", i);
+ baseaddrfp = ret;
+ baseaddrnum = i;
+ }
+ }
+ }
return ret;
}
char *fgets(char *s, int size, FILE *stream) {
static char* (*func) (char*, int, FILE*) = NULL;
const char modules[][256] = {"windrvr6 1 0 - Live 0xdeadbeef\n", "parport_pc 1 0 - Live 0xdeadbeef\n"};
+ char buf[256];
char *ret = NULL;
ret = s;
modules_read++;
}
+ } else if (baseaddrfp == stream) {
+ snprintf(s, sizeof(buf), "%d\t%d\n",
+ (baseaddrnum) * 0x10,
+ ((baseaddrnum) * 0x10) + 0x400);
+ ret = s;
} else {
ret = (*func)(s,size,stream);
}
if (fp == modulesfp) {
modulesfp = NULL;
}
+
+ if (fp == baseaddrfp) {
+ baseaddrfp = NULL;
+ }
return (*func)(fp);
}