]>
cvs.zerfleddert.de Git - usb-driver/blob - usb-driver.c
1 /* libusb/ppdev connector for XILINX impact
3 * Copyright (c) 2007 Michael Gernoth <michael@gernoth.net>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 #include <sys/types.h>
39 #include <sys/ioctl.h>
40 #include <sys/utsname.h>
41 #include <bits/wordsize.h>
45 #include <linux/personality.h>
46 #include "usb-driver.h"
50 static int (*ioctl_func
) (int, int, void *) = NULL
;
51 static int *windrvrfds
= NULL
;
52 static int windrvrfds_count
= 0;
53 static unsigned long ppbase
= 0;
54 static unsigned long ecpbase
= 0;
55 static struct parport_config
*pport
= NULL
;
56 static FILE *modulesfp
= NULL
;
57 static FILE *baseaddrfp
= NULL
;
58 static int baseaddrnum
= 0;
59 static int modules_read
= 0;
63 void hexdump(unsigned char *buf
, int len
, char *prefix
) {
66 fprintf(stderr
, "%s %03x: ", prefix
, i
);
67 for(i
= 0; i
<len
; i
++) {
68 fprintf(stderr
,"%02x ", buf
[i
]);
71 if (((i
% 16) == 15) && ((i
+1) < len
))
72 fprintf(stderr
,"\n%s %03x: ", prefix
, i
+1);
78 static int do_wdioctl(int fd
, unsigned int request
, unsigned char *wdioctl
) {
79 struct header_struct
* wdheader
= (struct header_struct
*)wdioctl
;
80 struct version_struct
*version
;
83 if (wdheader
->magic
!= MAGIC
) {
84 fprintf(stderr
,"!!!ERROR: magic header does not match!!!\n");
85 return (*ioctl_func
) (fd
, request
, wdioctl
);
88 switch(request
& ~(0xc0000000)) {
90 version
= (struct version_struct
*)(wdheader
->data
);
91 strcpy(version
->version
, "libusb-driver.so version: " USB_DRIVER_VERSION
);
92 version
->versionul
= 802;
100 case CARD_REGISTER_OLD
:
102 DPRINTF("CARD_REGISTER\n");
104 struct card_register
* cr
= (struct card_register
*)(wdheader
->data
);
106 DPRINTF("-> Items: %lu, Addr: 0x%lx, bytes: %lu, bar: %lu\n",
108 (unsigned long)cr
->Card
.Item
[0].I
.IO
.dwAddr
,
109 cr
->Card
.Item
[0].I
.IO
.dwBytes
,
110 cr
->Card
.Item
[0].I
.IO
.dwBar
);
112 DPRINTF("-> Items: %lu, Addr: 0x%lx, bytes: %lu, bar: %lu\n",
114 (unsigned long)cr
->Card
.Item
[1].I
.IO
.dwAddr
,
115 cr
->Card
.Item
[1].I
.IO
.dwBytes
,
116 cr
->Card
.Item
[1].I
.IO
.dwBar
);
118 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
122 pport
= config_get((unsigned long)cr
->Card
.Item
[0].I
.IO
.dwAddr
/ 0x10);
126 ret
= pport
->open((unsigned long)cr
->Card
.Item
[0].I
.IO
.dwAddr
/ 0x10);
128 ppbase
= (unsigned long)cr
->Card
.Item
[0].I
.IO
.dwAddr
;
130 if (cr
->Card
.dwItems
> 1 && cr
->Card
.Item
[1].I
.IO
.dwAddr
)
131 ecpbase
= (unsigned long)cr
->Card
.Item
[1].I
.IO
.dwAddr
;
139 DPRINTF("<-hCard: %lu\n", cr
->hCard
);
144 DPRINTF("USB_TRANSFER\n");
146 struct usb_transfer
*ut
= (struct usb_transfer
*)(wdheader
->data
);
149 DPRINTF("-> unique: 0x%lx, pipe: %lu, read: %lu, options: %lx, size: %lu, timeout: %lx\n",
150 ut
->dwUniqueID
, ut
->dwPipeNum
, ut
->fRead
,
151 ut
->dwOptions
, ut
->dwBufferSize
, ut
->dwTimeout
);
152 if (ut
->dwPipeNum
== 0) {
153 DPRINTF("-> setup packet:");
154 hexdump(ut
->SetupPacket
, 8, "");
157 if (!ut
->fRead
&& ut
->dwBufferSize
)
159 hexdump(ut
->pBuffer
, ut
->dwBufferSize
, "->");
164 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
166 ret
= xpcu_transfer(ut
);
170 DPRINTF("Transferred: %lu (%s)\n",ut
->dwBytesTransferred
, (ut
->fRead
?"read":"write"));
171 if (ut
->fRead
&& ut
->dwBytesTransferred
)
173 hexdump(ut
->pBuffer
, ut
->dwBytesTransferred
, "<-");
181 DPRINTF("INT_ENABLE\n");
183 struct interrupt
*it
= (struct interrupt
*)(wdheader
->data
);
185 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
186 it
->hInterrupt
, it
->dwOptions
,
187 it
->dwCmds
, it
->fEnableOk
, it
->dwCounter
,
188 it
->dwLost
, it
->fStopped
);
191 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
193 ret
= xpcu_int_state(it
, ENABLE_INTERRUPT
);
196 DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
197 it
->hInterrupt
, it
->dwOptions
,
198 it
->dwCmds
, it
->fEnableOk
, it
->dwCounter
,
199 it
->dwLost
, it
->fStopped
);
205 DPRINTF("INT_DISABLE\n");
207 struct interrupt
*it
= (struct interrupt
*)(wdheader
->data
);
209 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
210 it
->hInterrupt
, it
->dwOptions
,
211 it
->dwCmds
, it
->fEnableOk
, it
->dwCounter
,
212 it
->dwLost
, it
->fStopped
);
214 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
216 ret
= xpcu_int_state(it
, DISABLE_INTERRUPT
);
218 DPRINTF("<- Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
219 it
->hInterrupt
, it
->dwOptions
,
220 it
->dwCmds
, it
->fEnableOk
, it
->dwCounter
,
221 it
->dwLost
, it
->fStopped
);
225 case USB_SET_INTERFACE
:
226 DPRINTF("USB_SET_INTERFACE\n");
228 struct usb_set_interface
*usi
= (struct usb_set_interface
*)(wdheader
->data
);
230 DPRINTF("-> unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
231 usi
->dwUniqueID
, usi
->dwInterfaceNum
,
232 usi
->dwAlternateSetting
, usi
->dwOptions
);
234 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
236 ret
= xpcu_set_interface(usi
);
238 DPRINTF("<- unique: 0x%lx, interfacenum: %lu, alternatesetting: %lu, options: %lx\n",
239 usi
->dwUniqueID
, usi
->dwInterfaceNum
,
240 usi
->dwAlternateSetting
, usi
->dwOptions
);
244 case USB_GET_DEVICE_DATA_OLD
:
245 case USB_GET_DEVICE_DATA
:
246 DPRINTF("USB_GET_DEVICE_DATA\n");
248 struct usb_get_device_data
*ugdd
= (struct usb_get_device_data
*)(wdheader
->data
);
250 DPRINTF("-> unique: 0x%lx, bytes: %lu, options: %lx\n",
251 ugdd
->dwUniqueID
, ugdd
->dwBytes
,
254 ret
= xpcu_deviceinfo(ugdd
);
259 case EVENT_REGISTER_OLD
:
261 DPRINTF("EVENT_REGISTER\n");
263 struct event
*e
= (struct event
*)(wdheader
->data
);
268 DPRINTF("-> handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
269 e
->handle
, e
->dwAction
,
270 e
->dwStatus
, e
->dwEventId
, e
->dwCardType
,
271 e
->hKernelPlugIn
, e
->dwOptions
,
272 e
->u
.Usb
.deviceId
.dwVendorId
,
273 e
->u
.Usb
.deviceId
.dwProductId
,
274 e
->u
.Usb
.dwUniqueID
, e
->dwEventVer
,
275 e
->dwNumMatchTables
);
278 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
284 DPRINTF("<- handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
285 e
->handle
, e
->dwAction
,
286 e
->dwStatus
, e
->dwEventId
, e
->dwCardType
,
287 e
->hKernelPlugIn
, e
->dwOptions
,
288 e
->u
.Usb
.deviceId
.dwVendorId
,
289 e
->u
.Usb
.deviceId
.dwProductId
,
290 e
->u
.Usb
.dwUniqueID
, e
->dwEventVer
,
291 e
->dwNumMatchTables
);
293 for (i
= 0; i
< e
->dwNumMatchTables
; i
++)
294 DPRINTF("match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
295 e
->matchTables
[i
].VendorId
,
296 e
->matchTables
[i
].ProductId
,
297 e
->matchTables
[i
].bDeviceClass
,
298 e
->matchTables
[i
].bDeviceSubClass
,
299 e
->matchTables
[i
].bInterfaceClass
,
300 e
->matchTables
[i
].bInterfaceSubClass
,
301 e
->matchTables
[i
].bInterfaceProtocol
);
308 DPRINTF("TRANSFER\n");
310 WD_TRANSFER
*tr
= (WD_TRANSFER
*)(wdheader
->data
);
313 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
315 ret
= pport
->transfer(tr
, fd
, request
, ppbase
, ecpbase
, 1);
320 case MULTI_TRANSFER_OLD
:
322 DPRINTF("MULTI_TRANSFER\n");
324 WD_TRANSFER
*tr
= (WD_TRANSFER
*)(wdheader
->data
);
325 unsigned long num
= wdheader
->size
/sizeof(WD_TRANSFER
);
327 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
329 ret
= pport
->transfer(tr
, fd
, request
, ppbase
, ecpbase
, num
);
334 case EVENT_UNREGISTER
:
336 struct event
*e
= (struct event
*)(wdheader
->data
);
338 DPRINTF("EVENT_UNREGISTER\n");
340 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
348 DPRINTF("INT_WAIT\n");
350 struct interrupt
*it
= (struct interrupt
*)(wdheader
->data
);
352 DPRINTF("-> Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
353 it
->hInterrupt
, it
->dwOptions
,
354 it
->dwCmds
, it
->fEnableOk
, it
->dwCounter
,
355 it
->dwLost
, it
->fStopped
);
358 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
360 ret
= xpcu_int_wait(it
);
363 DPRINTF("<- INT_WAIT_RETURN: Handle: 0x%lx, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n",
364 it
->hInterrupt
, it
->dwOptions
, it
->dwCmds
,
365 it
->fEnableOk
, it
->dwCounter
, it
->dwLost
,
370 case CARD_UNREGISTER
:
371 DPRINTF("CARD_UNREGISTER\n");
373 struct card_register
* cr
= (struct card_register
*)(wdheader
->data
);
375 DPRINTF("-> Addr: 0x%lx, bytes: %lu, bar: %lu\n",
376 (unsigned long)cr
->Card
.Item
[0].I
.IO
.dwAddr
,
377 cr
->Card
.Item
[0].I
.IO
.dwBytes
,
378 cr
->Card
.Item
[0].I
.IO
.dwBar
);
380 DPRINTF("-> hCard: %lu\n", cr
->hCard
);
383 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
386 pport
->close(cr
->hCard
);
394 DPRINTF("EVENT_PULL\n");
396 struct event
*e
= (struct event
*)(wdheader
->data
);
400 DPRINTF("-> handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lx, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
401 e
->handle
, e
->dwAction
, e
->dwStatus
,
402 e
->dwEventId
, e
->dwCardType
, e
->hKernelPlugIn
,
403 e
->dwOptions
, e
->u
.Usb
.deviceId
.dwVendorId
,
404 e
->u
.Usb
.deviceId
.dwProductId
,
405 e
->u
.Usb
.dwUniqueID
, e
->dwEventVer
,
406 e
->dwNumMatchTables
);
408 for (i
= 0; i
< e
->dwNumMatchTables
; i
++)
409 DPRINTF("-> match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
410 e
->matchTables
[i
].VendorId
,
411 e
->matchTables
[i
].ProductId
,
412 e
->matchTables
[i
].bDeviceClass
,
413 e
->matchTables
[i
].bDeviceSubClass
,
414 e
->matchTables
[i
].bInterfaceClass
,
415 e
->matchTables
[i
].bInterfaceSubClass
,
416 e
->matchTables
[i
].bInterfaceProtocol
);
420 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
426 DPRINTF("<- handle: 0x%lx, action: %lu, status: %lu, eventid: %lu, cardtype: %lx, kplug: %lu, options: %lu, dev: %lx:%lx, unique: 0x%lx, ver: %lu, nummatch: %lu\n",
427 e
->handle
, e
->dwAction
, e
->dwStatus
,
428 e
->dwEventId
, e
->dwCardType
, e
->hKernelPlugIn
,
429 e
->dwOptions
, e
->u
.Usb
.deviceId
.dwVendorId
,
430 e
->u
.Usb
.deviceId
.dwProductId
,
431 e
->u
.Usb
.dwUniqueID
, e
->dwEventVer
,
432 e
->dwNumMatchTables
);
434 for (i
= 0; i
< e
->dwNumMatchTables
; i
++)
435 DPRINTF("<- match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n",
436 e
->matchTables
[i
].VendorId
,
437 e
->matchTables
[i
].ProductId
,
438 e
->matchTables
[i
].bDeviceClass
,
439 e
->matchTables
[i
].bDeviceSubClass
,
440 e
->matchTables
[i
].bInterfaceClass
,
441 e
->matchTables
[i
].bInterfaceSubClass
,
442 e
->matchTables
[i
].bInterfaceProtocol
);
449 fprintf(stderr
,"!!!Unsupported IOCTL: %x!!!\n", request
);
451 ret
= (*ioctl_func
) (fd
, request
, wdioctl
);
459 int ioctl(int fd
, unsigned long int request
, ...) {
465 ioctl_func
= (int (*) (int, int, void *)) dlsym (RTLD_NEXT
, "ioctl");
467 va_start (args
, request
);
468 argp
= va_arg (args
, void *);
471 for (i
= 0; i
< windrvrfds_count
; i
++) {
472 if (fd
== windrvrfds
[i
])
473 return do_wdioctl(fd
, request
, argp
);
476 return (*ioctl_func
) (fd
, request
, argp
);
479 int open (const char *pathname
, int flags
, ...) {
480 static int (*func
) (const char *, int, mode_t
) = NULL
;
486 func
= (int (*) (const char *, int, mode_t
)) dlsym (RTLD_NEXT
, "open");
488 if (flags
& O_CREAT
) {
489 va_start(args
, flags
);
490 mode
= va_arg(args
, mode_t
);
494 if (!strcmp (pathname
, "/dev/windrvr6")) {
495 DPRINTF("opening windrvr6 (%d)\n", windrvrfds_count
);
496 windrvrfds
= realloc(windrvrfds
, sizeof(int) * (++windrvrfds_count
));
501 windrvrfds
[windrvrfds_count
-1] = fd
= (*func
) ("/dev/null", flags
, mode
);
503 windrvrfds
[windrvrfds_count
-1] = fd
= (*func
) (pathname
, flags
, mode
);
509 return (*func
) (pathname
, flags
, mode
);
513 static int (*func
) (int) = NULL
;
517 func
= (int (*) (int)) dlsym(RTLD_NEXT
, "close");
519 for (i
= 0; i
< windrvrfds_count
; i
++) {
520 if (fd
== windrvrfds
[i
] && windrvrfds
[i
] >= 0) {
521 int remaining
= windrvrfds_count
- (i
+ 1);
522 DPRINTF("close windrvr6 (%d)\n", i
);
524 memmove(&(windrvrfds
[i
]), &(windrvrfds
[i
+1]), remaining
* sizeof(int));
525 windrvrfds
= realloc(windrvrfds
, sizeof(int) * --windrvrfds_count
);
526 if (!windrvrfds_count
)
535 FILE *fopen(const char *path
, const char *mode
) {
537 static FILE* (*func
) (const char*, const char*) = NULL
;
542 func
= (FILE* (*) (const char*, const char*)) dlsym(RTLD_NEXT
, "fopen");
544 for (i
= 0; i
< 4; i
++) {
545 snprintf(buf
, sizeof(buf
), "/proc/sys/dev/parport/parport%d/base-addr", i
);
546 if (!strcmp(path
, buf
)) {
547 DPRINTF("open base-addr of parport%d\n", i
);
548 if (config_is_real_pport(i
)) {
549 ret
= (*func
) (path
, mode
);
551 ret
= (*func
) ("/dev/null", mode
);
563 ret
= (*func
) (path
, mode
);
565 if (!strcmp(path
, "/proc/modules")) {
566 DPRINTF("opening /proc/modules\n");
567 if (!ret
&& errno
== ENOENT
) {
568 /* Hmm.. there appears to be no /proc/modules file
570 ret
= (*func
)("/dev/null", mode
);
571 DPRINTF("No /proc/modules -- faking\n");
582 char *fgets(char *s
, int size
, FILE *stream
) {
583 static char* (*func
) (char*, int, FILE*) = NULL
;
584 const char modules
[][256] = {"windrvr6 1 0 - Live 0xdeadbeef\n", "parport_pc 1 0 - Live 0xdeadbeef\n"};
590 func
= (char* (*) (char*, int, FILE*)) dlsym(RTLD_NEXT
, "fgets");
592 if (modulesfp
== stream
) {
593 if (modules_read
< sizeof(modules
) / sizeof(modules
[0])) {
594 strcpy(s
, modules
[modules_read
]);
598 } else if (baseaddrfp
== stream
) {
599 snprintf(s
, sizeof(buf
), "%d\t%d\n",
600 (baseaddrnum
) * 0x10,
601 ((baseaddrnum
) * 0x10) + 0x400);
604 ret
= (*func
)(s
,size
,stream
);
610 int fclose(FILE *fp
) {
611 static int (*func
) (FILE*) = NULL
;
614 func
= (int (*) (FILE*)) dlsym(RTLD_NEXT
, "fclose");
616 if (fp
== modulesfp
) {
620 if (fp
== baseaddrfp
) {
627 int access(const char *pathname
, int mode
) {
628 static int (*func
) (const char*, int);
631 func
= (int (*) (const char*, int)) dlsym(RTLD_NEXT
, "access");
633 if (pathname
&& !strcmp(pathname
, "/dev/windrvr6")) {
636 return (*func
)(pathname
, mode
);
641 /* USB cable sharing needs to overload semop, TODO! */
642 int semop (int __semid
, struct sembuf
*__sops
, size_t __nsops
) {
643 static int (*func
) (int, struct sembuf
*, size_t) = NULL
;
647 func
= (int (*) (int, struct sembuf
*, size_t)) dlsym(RTLD_NEXT
, "semop");
649 fprintf(stderr
,"semop: semid: 0x%X, elements: %d\n", __semid
, __nsops
);
650 for (i
= 0; i
< __nsops
; i
++) {
651 fprintf(stderr
, " num: %u, op: %d, flg: %d\n", __sops
[i
].sem_num
, __sops
[i
].sem_op
, __sops
[i
].sem_flg
);
652 if (__sops
[i
].sem_op
< 0) {
653 fprintf(stderr
, "SEMAPHORE LOCK\n");
655 fprintf(stderr
, "SEMAPHORE UNLOCK\n");
659 return (*func
)(__semid
, __sops
, __nsops
);
664 * Ugly hack for ISE 12. Preload doesn't seem to work correctly for
665 * libImpactComm.so. Even though the file is still read with fopen(),
666 * the version from libc is used and not the one from this file.
667 * Replace the function calling fopen() instead...
668 * echo '_Z14isModuleLoadedPci' | c++filt
670 long int _Z14isModuleLoadedPci(char *module_name
, int i
) {
671 DPRINTF("_Z14isModuleLoadedPci: Checking for module %s (%d)\n", module_name
, i
);
676 /* XilCommNS::CPortResources::Instance() */
677 void* _ZN9XilCommNS14CPortResources8InstanceEv() {
678 static void* (*func
) (void) = NULL
;
682 func
= (void* (*) (void)) dlsym(RTLD_NEXT
, "_ZN9XilCommNS14CPortResources8InstanceEv");
684 DPRINTF("-> XilCommNS::CPortResources::Instance()\n");
689 hexdump(ret
, 0x29, "<-");
693 portinfo
= ((unsigned char**)ret
+0x00);
694 hexdump(portinfo
, 256, "PI");
695 hexdump(portinfo
+0x50, 4, "BS");
696 hexdump(portinfo
+0x54, 4, "BE");
697 hexdump(portinfo
+0x58, 4, "ES");
698 hexdump(portinfo
+0x5c, 4, "EE");
703 DPRINTF("<- XilCommNS::CPortResources::Instance()\n");
708 static void __attribute__ ((constructor
)) libusbdriver_init(void) {
713 for (i
= 0; i
< 4; i
++) {
714 snprintf(buf
, sizeof(buf
), "XIL_IMPACT_ENV_LPT%d_BASE_ADDRESS", i
+1);
715 snprintf(buf2
, sizeof(buf2
), "%x", 0x10*i
);
716 setenv(buf
, buf2
, 1);
717 snprintf(buf
, sizeof(buf
), "XIL_IMPACT_ENV_LPT%d_ECP_ADDRESS", i
+1);
718 snprintf(buf2
, sizeof(buf2
), "%x", (0x10*i
)+0x400);
719 setenv(buf
, buf2
, 1);
722 setenv("XIL_IMPACT_USE_LIBUSB", "0", 1);
723 setenv("XIL_IMPACT_USE_WINDRIVER", "1", 1);
732 if (ret
== 0 && (!strcmp(un
.machine
, "x86_64"))) {
733 DPRINTF("setting 32bit personality\n");
734 (long)syscall(SYS_personality
, PER_LINUX32
);