diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 3fadb6e6..1aa6ea31 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,12 @@ +2003-04-02 Marcel Telka + + * include/signal.h: Changed signal typedef to signal_t (thanks to Jachym Holecek). + All `signal' instances renamed to `signal_t'. + * src/tap/parport.c: Ported to NetBSD/i386 (Jachym Holecek). + * src/tap/parport/direct.c (parport_drivers): Conditionally removed direct_parport_driver. + * configure.ac: Added test for i386_set_ioperm() function. Defined HAVE_IOPERM + and HAVE_I386_SET_IOPERM. + 2003-04-01 Marcel Telka * src/tap/cable/keithkoep.c: New file. diff --git a/jtag/NEWS b/jtag/NEWS index 7b48c695..0a93cb1f 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -1,6 +1,7 @@ $Id$ * Added driver for Keith & Koep JTAG Cable. + * Ported to NetBSD/i386 (Jachym Holecek). jtag-0.3.1 (2003-03-19): diff --git a/jtag/README b/jtag/README index 11f1acb4..701efbad 100644 --- a/jtag/README +++ b/jtag/README @@ -23,12 +23,13 @@ Feedback and contributions are welcome. Supported operating systems --------------------------- -JTAG Tools should run on all x86 Unix like operating systems including +JTAG Tools should run on all Unix like operating systems including MS Windows 95/98/Me/NT/2000/XP with Cygwin installed. Tested operating systems: - RedHat Linux 8.0 - MS Windows 2000/XP + Cygwin +- NetBSD/i386 Supported hardware diff --git a/jtag/THANKS b/jtag/THANKS index 2ca8d03e..2a5a29fc 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -3,6 +3,7 @@ $Id$ Ian Campbell Alex (d18c7db) Chris Ellec +Jachym Holecek August Hörandl Stas Khirman Christian Pellegrin diff --git a/jtag/configure.ac b/jtag/configure.ac index 58cd7d8e..04eeb514 100644 --- a/jtag/configure.ac +++ b/jtag/configure.ac @@ -75,6 +75,16 @@ fi CPPFLAGS="$CPPFLAGS -I$openwince_includes_path -I$openwince_includes_path/device" AC_SEARCH_LIBS([ioperm], [ioperm]) +if test "$ac_cv_search_ioperm" != "no"; then + AC_DEFINE(HAVE_IOPERM, 1, [Define to 1 if you have the ioperm() function]) +else + AC_SEARCH_LIBS([i386_set_ioperm], [i386]) + if test "$ac_cv_search_i386_set_ioperm" != "no"; then + AC_DEFINE(HAVE_I386_SET_IOPERM, 1, + [Define to 1 if you have the i386_set_ioperm() function]) + fi +fi + AC_CHECK_FUNCS(getline getdelim) AC_CHECK_HEADERS(linux/ppdev.h) diff --git a/jtag/include/bsbit.h b/jtag/include/bsbit.h index e1a830f7..bc0a9e09 100644 --- a/jtag/include/bsbit.h +++ b/jtag/include/bsbit.h @@ -41,14 +41,14 @@ struct bsbit { int bit; char *name; int type; - signal *signal; + signal_t *signal; int safe; /* safe value */ int control; /* -1 for none */ int control_value; int control_state; }; -bsbit *bsbit_alloc( int bit, const char *name, int type, signal* signals, int safe ); +bsbit *bsbit_alloc( int bit, const char *name, int type, signal_t* signals, int safe ); void bsbit_free( bsbit *b ); #endif /* BSBIT_H */ diff --git a/jtag/include/part.h b/jtag/include/part.h index f498be10..86523187 100644 --- a/jtag/include/part.h +++ b/jtag/include/part.h @@ -43,7 +43,7 @@ struct part { char manufacturer[MAXLEN_MANUFACTURER + 1]; char part[MAXLEN_PART + 1]; char stepping[MAXLEN_STEPPING + 1]; - signal *signals; + signal_t *signals; int instruction_length; instruction *instructions; instruction *active_instruction; diff --git a/jtag/include/signal.h b/jtag/include/signal.h index 05d50ed7..57bc49b2 100644 --- a/jtag/include/signal.h +++ b/jtag/include/signal.h @@ -25,18 +25,18 @@ #ifndef SIGNAL_H #define SIGNAL_H -typedef struct signal signal; +typedef struct signal signal_t; #include struct signal { char *name; - signal *next; + signal_t *next; bsbit *input; bsbit *output; }; -signal *signal_alloc( const char *name ); -void signal_free( signal *s ); +signal_t *signal_alloc( const char *name ); +void signal_free( signal_t *s ); #endif /* SIGNAL_H */ diff --git a/jtag/src/part/bsbit.c b/jtag/src/part/bsbit.c index 8b0582a0..fbb6661f 100644 --- a/jtag/src/part/bsbit.c +++ b/jtag/src/part/bsbit.c @@ -28,9 +28,9 @@ #include "bsbit.h" bsbit * -bsbit_alloc( int bit, const char *name, int type, signal* signals, int safe ) +bsbit_alloc( int bit, const char *name, int type, signal_t* signals, int safe ) { - signal *s = signals; + signal_t *s = signals; bsbit *b = malloc( sizeof *b ); if (!b) diff --git a/jtag/src/part/parse.c b/jtag/src/part/parse.c index bfaa24fb..18668d0d 100644 --- a/jtag/src/part/parse.c +++ b/jtag/src/part/parse.c @@ -68,7 +68,7 @@ read_part( FILE *f, tap_register *idr ) /* pin */ if (strcmp( t, "pin" ) == 0) { - signal *s; + signal_t *s; t = get_token( NULL ); if (!t) { diff --git a/jtag/src/part/part.c b/jtag/src/part/part.c index b37a05c7..806b6174 100644 --- a/jtag/src/part/part.c +++ b/jtag/src/part/part.c @@ -60,7 +60,7 @@ part_free( part *p ) /* sirnals */ while (p->signals) { - signal *s = p->signals; + signal_t *s = p->signals; p->signals = s->next; signal_free( s ); } @@ -132,7 +132,7 @@ void part_set_instruction( part *p, const char *iname ) void part_set_signal( part *p, const char *pname, int out, int val ) { - signal *s; + signal_t *s; /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); @@ -179,7 +179,7 @@ part_set_signal( part *p, const char *pname, int out, int val ) int part_get_signal( part *p, const char *pname ) { - signal *s; + signal_t *s; /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); diff --git a/jtag/src/part/signal.c b/jtag/src/part/signal.c index 4b70ac10..348cd79d 100644 --- a/jtag/src/part/signal.c +++ b/jtag/src/part/signal.c @@ -27,10 +27,10 @@ #include "signal.h" -signal * +signal_t * signal_alloc( const char *name ) { - signal *s = malloc( sizeof *s ); + signal_t *s = malloc( sizeof *s ); if (!s) return NULL; @@ -47,7 +47,7 @@ signal_alloc( const char *name ) } void -signal_free( signal *s ) +signal_free( signal_t *s ) { if (!s) return; diff --git a/jtag/src/tap/parport.c b/jtag/src/tap/parport.c index a3d5555f..3a805127 100644 --- a/jtag/src/tap/parport.c +++ b/jtag/src/tap/parport.c @@ -28,13 +28,17 @@ #include "parport.h" +#if defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) extern parport_driver_t direct_parport_driver; +#endif /* defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) */ #ifdef HAVE_LINUX_PPDEV_H extern parport_driver_t ppdev_parport_driver; #endif /* HAVE_LINUX_PPDEV_H */ parport_driver_t *parport_drivers[] = { +#if defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) &direct_parport_driver, +#endif /* defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) */ #ifdef HAVE_LINUX_PPDEV_H &ppdev_parport_driver, #endif /* HAVE_LINUX_PPDEV_H */ diff --git a/jtag/src/tap/parport/direct.c b/jtag/src/tap/parport/direct.c index e786ec39..1b88d137 100644 --- a/jtag/src/tap/parport/direct.c +++ b/jtag/src/tap/parport/direct.c @@ -20,6 +20,7 @@ * 02111-1307, USA. * * Written by Marcel Telka , 2003. + * Ported to NetBSD/i386 by Jachym Holecek , 2003. * */ @@ -33,12 +34,65 @@ #define P_(s,p,n) ngettext(s,p,n) #include -#include #include #include "parport.h" #include "cable.h" +#if defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) + +#if defined(HAVE_IOPERM) +#include +#elif defined(HAVE_I386_SET_IOPERM) +#include +#include +#include +#endif + +#ifdef HAVE_I386_SET_IOPERM +static __inline int +ioperm( unsigned long from, unsigned long num, int permit ) +{ + u_long ports[32]; + u_long i; + + if (i386_get_ioperm( ports ) == -1) + return -1; + + for (i = from; i < (from + num); i++) + if (permit) + ports[i / 32] &= ~(1 << (i % 32)); + else + ports[i / 32] |= (1 << (i % 32)); + + if (i386_set_ioperm( ports ) == -1) + return -1; + + return 0; +} + +static __inline int +iopl( int level ) +{ + return i386_iopl( level ); +} + +static __inline unsigned char +inb( unsigned short int port ) +{ + unsigned char _v; + + __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline void +outb( unsigned char value, unsigned short int port ) +{ + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} +#endif /* HAVE_I386_SET_IOPERM */ + parport_driver_t direct_parport_driver; typedef struct port_node_t port_node_t; @@ -216,3 +270,5 @@ parport_driver_t direct_parport_driver = { direct_get_status, direct_set_control }; + +#endif /* defined(HAVE_IOPERM) || defined(HAVE_I386_SET_IOPERM) */