diff --git a/jtag/include/cable.h b/jtag/include/cable.h index 81f856c1..23931105 100644 --- a/jtag/include/cable.h +++ b/jtag/include/cable.h @@ -48,6 +48,7 @@ struct cable_driver_t { int (*transfer)( cable_t *, int, char *, char * ); int (*set_trst)( cable_t *, int ); int (*get_trst)( cable_t * ); + void (*help)( char * ); }; struct cable_t { diff --git a/jtag/src/cmd/cable.c b/jtag/src/cmd/cable.c index b07de4e4..2b7deb54 100644 --- a/jtag/src/cmd/cable.c +++ b/jtag/src/cmd/cable.c @@ -39,12 +39,35 @@ static int cmd_cable_run( char *params[] ) { - cable_t *cable = malloc( sizeof *cable ); + cable_t *cable; int i; + int paramc = cmd_params( params ); /* we need at least one parameter for 'cable' command */ - if (cmd_params( params ) < 2) - return -1; + if (paramc < 2) return -1; + + /* maybe old syntax was used? search connection type driver */ + for (i = 0; parport_drivers[i]; i++) + if (strcasecmp( params[1], parport_drivers[i]->type ) == 0) + break; + + if (parport_drivers[i] != 0) + { + /* Old syntax was used. Swap params. */ + char *tmparam; + printf( _("Note: the 'cable' command syntax changed, please read the help text\n") ); + if (paramc >= 4) + { + tmparam = params[3]; + params[3] = params[2]; + } + else if (paramc >= 3) + { + char *tmparam = params[2]; + }; + params[2] = params[1]; + params[1] = tmparam; + } /* search cable driver list */ for (i = 0; cable_drivers[i]; i++) @@ -55,6 +78,15 @@ cmd_cable_run( char *params[] ) return 1; } + if (paramc >= 3) + { + if (strcasecmp( params[2], "help" ) == 0) + { + cable_drivers[i]->help(cable_drivers[i]->name); + return 1; + } + } + if (bus) { bus_free( bus ); bus = NULL; @@ -62,6 +94,8 @@ cmd_cable_run( char *params[] ) chain_disconnect( chain ); + cable = malloc( sizeof(cable_t) ); + if (!cable) { printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__); return 1; @@ -100,6 +134,8 @@ cmd_cable_help( void ) "DRIVER name of cable\n" "DRIVER_OPTS options for the selected cable\n" "\n" + "Type \"cable DRIVER help\" for info about options for cable DRIVER.\n" + "\n" "List of supported cables:\n" ), "cable" ); diff --git a/jtag/src/tap/cable/arcom.c b/jtag/src/tap/cable/arcom.c index 2dce386f..3855fb82 100644 --- a/jtag/src/tap/cable/arcom.c +++ b/jtag/src/tap/cable/arcom.c @@ -111,5 +111,6 @@ cable_driver_t arcom_cable_driver = { arcom_get_tdo, generic_transfer, arcom_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/byteblaster.c b/jtag/src/tap/cable/byteblaster.c index 9e3e9194..0da81712 100644 --- a/jtag/src/tap/cable/byteblaster.c +++ b/jtag/src/tap/cable/byteblaster.c @@ -137,5 +137,6 @@ cable_driver_t byteblaster_cable_driver = { byteblaster_get_tdo, generic_transfer, byteblaster_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/dlc5.c b/jtag/src/tap/cable/dlc5.c index 8b54b0c6..25abba28 100644 --- a/jtag/src/tap/cable/dlc5.c +++ b/jtag/src/tap/cable/dlc5.c @@ -108,5 +108,6 @@ cable_driver_t dlc5_cable_driver = { dlc5_get_tdo, generic_transfer, dlc5_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/ea253.c b/jtag/src/tap/cable/ea253.c index 89a7c417..f04010d7 100644 --- a/jtag/src/tap/cable/ea253.c +++ b/jtag/src/tap/cable/ea253.c @@ -111,5 +111,6 @@ cable_driver_t ea253_cable_driver = { ea253_get_tdo, generic_transfer, ea253_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/ei012.c b/jtag/src/tap/cable/ei012.c index ebed907e..8cd08d30 100644 --- a/jtag/src/tap/cable/ei012.c +++ b/jtag/src/tap/cable/ei012.c @@ -113,5 +113,6 @@ cable_driver_t ei012_cable_driver = { ei012_get_tdo, generic_transfer, ei012_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index 1498a6bb..f8f4ce1d 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -466,6 +466,18 @@ ft2232_transfer( cable_t *cable, int len, char *in, char *out ) return 0; } +void +ft2232_usbcable_help(char *cablename) +{ + printf( _( + "Usage: cable %s ftdi-mpsse VID:PID\n" + "\n" + "VID vendor ID (hex, e.g. 9FB, or empty)\n" + "PID product ID (hex, e.g. 6001, or empty)\n" + "\n" + ), cablename ); +} + cable_driver_t ft2232_cable_driver = { "FT2232", N_("Generic FTDI FT2232 Cable"), @@ -478,7 +490,8 @@ cable_driver_t ft2232_cable_driver = { ft2232_get_tdo, ft2232_transfer, ft2232_set_trst, - generic_get_trst + generic_get_trst, + ft2232_usbcable_help }; cable_driver_t ft2232_armusbocd_cable_driver = { @@ -493,7 +506,8 @@ cable_driver_t ft2232_armusbocd_cable_driver = { ft2232_get_tdo, ft2232_transfer, ft2232_set_trst, - generic_get_trst + generic_get_trst, + ft2232_usbcable_help }; diff --git a/jtag/src/tap/cable/generic.c b/jtag/src/tap/cable/generic.c index e08d786e..af989d39 100644 --- a/jtag/src/tap/cable/generic.c +++ b/jtag/src/tap/cable/generic.c @@ -123,3 +123,21 @@ generic_get_trst( cable_t *cable ) { return PARAM_TRST(cable); } + +void +generic_lptcable_help( char *cablename ) +{ + printf( _( + "Usage: cable %s parallel PORTADDR\n" +#if HAVE_LINUX_PPDEV_H + " or: cable %s ppdev DEV\n" +#endif + "\n" + "PORTADDR parallel port address (e.g. 0x378)\n" +#if HAVE_LINUX_PPDEV_H + "DEV ppdev device (e.g. /dev/parport0)\n" +#endif + "\n" + ), cablename, cablename ); +} + diff --git a/jtag/src/tap/cable/generic.h b/jtag/src/tap/cable/generic.h index d6b5eb63..a43c1aa5 100644 --- a/jtag/src/tap/cable/generic.h +++ b/jtag/src/tap/cable/generic.h @@ -42,5 +42,6 @@ void generic_cable_free( cable_t *cable ); void generic_done( cable_t *cable ); int generic_transfer( cable_t *cable, int len, char *in, char *out ); int generic_get_trst( cable_t *cable ); +void generic_lptcable_help( char *name ); #endif /* GENERIC_H */ diff --git a/jtag/src/tap/cable/keithkoep.c b/jtag/src/tap/cable/keithkoep.c index 2f58b93a..a7786aad 100644 --- a/jtag/src/tap/cable/keithkoep.c +++ b/jtag/src/tap/cable/keithkoep.c @@ -120,5 +120,6 @@ cable_driver_t keithkoep_cable_driver = { keithkoep_get_tdo, generic_transfer, keithkoep_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help, }; diff --git a/jtag/src/tap/cable/lattice.c b/jtag/src/tap/cable/lattice.c index c86c29bd..92916afd 100644 --- a/jtag/src/tap/cable/lattice.c +++ b/jtag/src/tap/cable/lattice.c @@ -103,5 +103,6 @@ cable_driver_t lattice_cable_driver = { lattice_get_tdo, generic_transfer, lattice_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help }; diff --git a/jtag/src/tap/cable/mpcbdm.c b/jtag/src/tap/cable/mpcbdm.c index 068efa6e..6958b8c8 100644 --- a/jtag/src/tap/cable/mpcbdm.c +++ b/jtag/src/tap/cable/mpcbdm.c @@ -117,5 +117,6 @@ cable_driver_t mpcbdm_cable_driver = { mpcbdm_get_tdo, generic_transfer, mpcbdm_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help, }; diff --git a/jtag/src/tap/cable/triton.c b/jtag/src/tap/cable/triton.c index 17e253b5..c05454c8 100644 --- a/jtag/src/tap/cable/triton.c +++ b/jtag/src/tap/cable/triton.c @@ -122,5 +122,6 @@ cable_driver_t triton_cable_driver = { triton_get_tdo, generic_transfer, triton_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help, }; diff --git a/jtag/src/tap/cable/usbblaster.c b/jtag/src/tap/cable/usbblaster.c index 99008eb6..a1636a3e 100644 --- a/jtag/src/tap/cable/usbblaster.c +++ b/jtag/src/tap/cable/usbblaster.c @@ -163,6 +163,18 @@ usbblaster_transfer( cable_t *cable, int len, char *in, char *out ) return 0; } +void +usbblaster_help(char *cablename) +{ + printf( _( + "Usage: cable %s ftdi VID:PID\n" + "\n" + "VID vendor ID (hex, e.g. 9FB, or empty)\n" + "PID product ID (hex, e.g. 6001, or empty)\n" + "\n" + ), cablename ); +} + cable_driver_t usbblaster_cable_driver = { "UsbBlaster", N_("Altera USB-Blaster Cable"), @@ -175,5 +187,6 @@ cable_driver_t usbblaster_cable_driver = { usbblaster_get_tdo, usbblaster_transfer, usbblaster_set_trst, - generic_get_trst + generic_get_trst, + usbblaster_help, }; diff --git a/jtag/src/tap/cable/wiggler.c b/jtag/src/tap/cable/wiggler.c index 31731625..b9acf266 100644 --- a/jtag/src/tap/cable/wiggler.c +++ b/jtag/src/tap/cable/wiggler.c @@ -135,6 +135,7 @@ cable_driver_t igloo_cable_driver = { wiggler_get_tdo, generic_transfer, wiggler_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help, }; diff --git a/jtag/src/tap/cable/wiggler2.c b/jtag/src/tap/cable/wiggler2.c index 5d786e2e..6f5daac1 100644 --- a/jtag/src/tap/cable/wiggler2.c +++ b/jtag/src/tap/cable/wiggler2.c @@ -127,5 +127,6 @@ cable_driver_t wiggler2_cable_driver = { wiggler2_get_tdo, generic_transfer, wiggler2_set_trst, - generic_get_trst + generic_get_trst, + generic_lptcable_help, }; diff --git a/jtag/src/tap/cable/xpc.c b/jtag/src/tap/cable/xpc.c index 80c5cc29..b5c0140e 100644 --- a/jtag/src/tap/cable/xpc.c +++ b/jtag/src/tap/cable/xpc.c @@ -94,6 +94,18 @@ xpc_set_trst( cable_t *cable, int trst ) return 1; } +void +xpcu_usbcable_help(char *cablename) +{ + printf( _( + "Usage: cable %s xpcu VID:PID\n" + "\n" + "VID vendor ID (hex, e.g. 9FB, or empty)\n" + "PID product ID (hex, e.g. 6001, or empty)\n" + "\n" + ), cablename ); +} + cable_driver_t xpc_int_cable_driver = { "xpc_int", N_("Xilinx Platform Cable USB internal chain"), @@ -106,9 +118,16 @@ cable_driver_t xpc_int_cable_driver = { xpc_get_tdo, generic_transfer, xpc_set_trst, - generic_get_trst + generic_get_trst, + xpcu_usbcable_help }; +void +xpc_ext_usbcable_help() +{ + xpcu_usbcable_help("xpc_ext"); +} + cable_driver_t xpc_ext_cable_driver = { "xpc_ext", N_("Xilinx Platform Cable USB external chain"), @@ -121,6 +140,7 @@ cable_driver_t xpc_ext_cable_driver = { xpc_get_tdo, generic_transfer, xpc_set_trst, - generic_get_trst + generic_get_trst, + xpcu_usbcable_help };