* src/tap/cable/*.c: convert return values, error handling, printfs

* src/**: globally remove \n or !\n from error detail msgs; sanitize
    error prints a tiny bit




git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1594 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent f7b75f7289
commit 603611e442

@ -1,3 +1,9 @@
2009-05-14 Rutger Hofman <rfhh>
* src/tap/cable/*.c: convert return values, error handling, printfs
* src/**: globally remove \n or !\n from error detail msgs; sanitize
error prints a tiny bit
2009-05-12 Rutger Hofman <rfhh>
* src/cmd/*.c, many more files: have the commands in src/cmd/ return

@ -46,7 +46,9 @@ extern urj_buses_t urj_buses;
extern const urj_bus_driver_t *urj_bus_drivers[];
void urj_bus_buses_free (void);
/* @@@@ RFHH return status */
void urj_bus_buses_add (urj_bus_t *abus);
/* @@@@ RFHH return status? */
void urj_bus_buses_delete (urj_bus_t *abus);
/** set active bus

@ -57,14 +57,15 @@ struct urj_cable_driver
void (*clock) (urj_cable_t *, int, int, int);
/** @return 0 or 1 on success; -1 on failure */
int (*get_tdo) (urj_cable_t *);
/** @return the number of transferred bits on success; -1 on failure */
int (*transfer) (urj_cable_t *, int, char *, char *);
/** @return nonnegative number, or the number of transferred bits on
* success; -1 on failure */
int (*transfer) (urj_cable_t *, int, const char *, char *);
/** @return 0 or 1 on success; -1 on failure */
int (*set_signal) (urj_cable_t *, int, int);
/** @return 0 or 1 on success; -1 on failure */
int (*get_signal) (urj_cable_t *, urj_pod_sigsel_t);
void (*flush) (urj_cable_t *, urj_cable_flush_amount_t);
void (*help) (const char *);
void (*help) (urj_log_level_t ll, const char *);
};
typedef struct urj_cable_queue urj_cable_queue_t;

@ -24,7 +24,7 @@
#ifndef URJ_FCLOCK_FCLOCK_H
#define URJ_FCLOCK_FCLOCK_H
/* @@@@ this had better be an internal include file RFHH */
/* @@@@ RFHH this had better be an internal include file */
#ifdef __cplusplus
@ -45,8 +45,10 @@ extern "C"
time*/
long double urj_lib_frealtime (CVOID);
#ifdef UNUSED /* RFHH */
/* return the CPU time used by this process (seconds) */
long double fcputime (CVOID);
#endif
#ifdef __cplusplus

@ -20,6 +20,8 @@
*
*/
/* @@@@ RFHH candidate for internal include file? */
#ifndef URJ_USBCONN_LIBFTDX_H
#define URJ_USBCONN_LIBFTDX_H 1

@ -45,6 +45,7 @@
#ifdef ENABLE_NLS
#include <locale.h>
#endif /* ENABLE_NLS */
#include <errno.h>
#include <urjtag/chain.h>
#include <urjtag/bus.h>
@ -59,18 +60,26 @@ static int urj_interactive = 0;
#define HISTORYFILE "history"
#define RCFILE "rc"
static void
static int
jtag_create_jtagdir (void)
{
char *home = getenv ("HOME");
char *jdir;
int r;
if (!home)
return;
{
urj_error_set (URJ_ERROR_UNSUPPORTED, "env var HOME not set");
return URJ_STATUS_FAIL;
}
jdir = malloc (strlen (home) + strlen (JTAGDIR) + 2); /* "/" and trailing \0 */
if (!jdir)
return;
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
strlen (home) + strlen (JTAGDIR) + 2);
return URJ_STATUS_FAIL;
}
strcpy (jdir, home);
strcat (jdir, "/");
@ -78,12 +87,26 @@ jtag_create_jtagdir (void)
/* Create the directory if it doesn't exists. */
#ifdef __MINGW32__
mkdir (jdir);
r = mkdir (jdir);
#else
mkdir (jdir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
r = mkdir (jdir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
#endif
if (r == -1)
{
if (errno == EEXIST)
{
/* @@@@ RFHH check if it is a directory */
errno = 0;
} else {
free (jdir);
urj_error_IO_set ("cannot mkdir(%s)", jdir);
return URJ_STATUS_FAIL;
}
}
free (jdir);
return URJ_STATUS_OK;
}
#ifdef HAVE_LIBREADLINE
@ -103,7 +126,7 @@ urj_cmd_completion (const char *text, int start, int end)
#ifdef HAVE_READLINE_HISTORY
static void
static int
jtag_load_history (void)
{
char *home = getenv ("HOME");
@ -112,11 +135,18 @@ jtag_load_history (void)
using_history ();
if (!home)
return;
{
urj_error_set (URJ_ERROR_UNSUPPORTED, "env var HOME not set");
return URJ_STATUS_FAIL;
}
file = malloc (strlen (home) + strlen (JTAGDIR) + strlen (HISTORYFILE) + 3); /* 2 x "/" and trailing \0 */
if (!file)
return;
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
strlen (home) + strlen (JTAGDIR) + strlen (HISTORYFILE) + 3);
return URJ_STATUS_FAIL;
}
strcpy (file, home);
strcat (file, "/");
@ -127,20 +157,29 @@ jtag_load_history (void)
read_history (file);
free (file);
return URJ_STATUS_OK;
}
static void
static int
jtag_save_history (void)
{
char *home = getenv ("HOME");
char *file;
if (!home)
return;
{
urj_error_set (URJ_ERROR_UNSUPPORTED, "env var HOME not set");
return URJ_STATUS_FAIL;
}
file = malloc (strlen (home) + strlen (JTAGDIR) + strlen (HISTORYFILE) + 3); /* 2 x "/" and trailing \0 */
if (!file)
return;
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
strlen (home) + strlen (JTAGDIR) + strlen (HISTORYFILE) + 3);
return URJ_STATUS_FAIL;
}
strcpy (file, home);
strcat (file, "/");
@ -151,6 +190,8 @@ jtag_save_history (void)
write_history (file);
free (file);
return URJ_STATUS_OK;
}
#endif /* HAVE_READLINE_HISTORY */
@ -218,6 +259,7 @@ jtag_readline_loop (urj_chain_t *chain, const char *prompt)
/* We got EOF, bail */
if (!line)
{
/* @@@@ RFHH check strdup result */
line = strdup ("quit\n");
puts ("quit");
if (!line)
@ -271,11 +313,18 @@ jtag_parse_rc (urj_chain_t *chain)
int go;
if (!home)
return 1;
{
urj_error_set (URJ_ERROR_UNSUPPORTED, "env var HOME not set");
return URJ_STATUS_FAIL;
}
file = malloc (strlen (home) + strlen (JTAGDIR) + strlen (RCFILE) + 3); /* 2 x "/" and trailing \0 */
if (!file)
return 1;
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
strlen (home) + strlen (JTAGDIR) + strlen (RCFILE) + 3);
return URJ_STATUS_FAIL;
}
strcpy (file, home);
strcat (file, "/");
@ -491,7 +540,11 @@ main (int argc, char *const argv[])
}
/* Create ~/.jtag */
jtag_create_jtagdir ();
if (jtag_create_jtagdir () != URJ_STATUS_OK)
{
urj_warning ("%s\n", urj_error_describe());
urj_error_reset();
}
/* Parse and execute the RC file */
if (!norc)

@ -265,7 +265,7 @@ urj_bsdl_set_path (urj_chain_t *chain, const char *pathlist)
len = strlen (elem);
else
len = delim - elem;
/* @@@@ ToDo check malloc result RFHH */
/* @@@@ RFHH check malloc result */
pathelem = malloc (len + 1);
memcpy (pathelem, elem, len);
pathelem[len] = '\0';
@ -326,7 +326,7 @@ urj_bsdl_scan_files (urj_chain_t *chain, const char *idcode, int proc_mode)
{
char *name;
/* @@@@ RFHH ToDo handle malloc error result */
/* @@@@ RFHH handle malloc error result */
name = malloc (strlen (globs->path_list[idx])
+ strlen (elem->d_name) + 1 + 1);
if (name)

@ -1135,9 +1135,7 @@ urj_bsdl_parser_init (urj_bsdl_jtag_ctrl_t *jtag_ctrl)
{
urj_bsdl_parser_priv_t *new_priv;
if (!
(new_priv =
(urj_bsdl_parser_priv_t *) malloc (sizeof (urj_bsdl_parser_priv_t))))
if (!(new_priv = malloc (sizeof (urj_bsdl_parser_priv_t))))
{
urj_bsdl_msg (jtag_ctrl->proc_mode,
BSDL_MSG_ERR, _("Out of memory, %s line %i\n"),
@ -1201,8 +1199,7 @@ add_instruction (urj_bsdl_parser_priv_t *priv, char *instr, char *opcode)
{
urj_bsdl_instr_elem_t *new_instr;
new_instr =
(urj_bsdl_instr_elem_t *) malloc (sizeof (urj_bsdl_instr_elem_t));
new_instr = malloc (sizeof (urj_bsdl_instr_elem_t));
if (new_instr)
{
new_instr->next = priv->jtag_ctrl->instr_list;
@ -1264,8 +1261,7 @@ ac_add_instruction (urj_bsdl_parser_priv_t *priv, char *instr)
urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo);
urj_bsdl_instr_elem_t *new_instr;
new_instr =
(urj_bsdl_instr_elem_t *) malloc (sizeof (urj_bsdl_instr_elem_t));
new_instr = malloc (sizeof (urj_bsdl_instr_elem_t));
if (new_instr)
{
new_instr->next = tmp_ai->instr_list;
@ -1301,9 +1297,7 @@ ac_apply_assoc (urj_bsdl_parser_priv_t *priv)
urj_bsdl_types_ainfo_elem_t *tmp_ai = &(priv->ainfo);
urj_bsdl_types_ainfo_elem_t *new_ai;
new_ai =
(urj_bsdl_types_ainfo_elem_t *)
malloc (sizeof (urj_bsdl_types_ainfo_elem_t));
new_ai = malloc (sizeof (urj_bsdl_types_ainfo_elem_t));
if (new_ai)
{
new_ai->next = jc->ainfo_list;
@ -1345,8 +1339,7 @@ prt_add_name (urj_bsdl_parser_priv_t *priv, char *name)
urj_bsdl_port_desc_t *pd = &(priv->tmp_port_desc);
urj_bsdl_string_elem_t *new_string;
new_string =
(urj_bsdl_string_elem_t *) malloc (sizeof (urj_bsdl_string_elem_t));
new_string = malloc (sizeof (urj_bsdl_string_elem_t));
if (new_string)
{
new_string->next = pd->names_list;
@ -1499,7 +1492,7 @@ ci_set_cell_spec (urj_bsdl_parser_priv_t *priv,
*/
name_len = strlen (name->string);
str_len = name_len + 1 + 10 + 1 + 1;
if ((port_string = (char *) malloc (str_len)) != NULL)
if ((port_string = malloc (str_len)) != NULL)
{
if (pd->is_vector)
snprintf (port_string, str_len - 1, "%s(%d)", name->string,
@ -1543,7 +1536,7 @@ ci_append_cell_info (urj_bsdl_parser_priv_t *priv, int bit_num)
urj_bsdl_cell_info_t *ci;
urj_bsdl_jtag_ctrl_t *jc = priv->jtag_ctrl;
ci = (urj_bsdl_cell_info_t *) malloc (sizeof (urj_bsdl_cell_info_t));
ci = malloc (sizeof (urj_bsdl_cell_info_t));
if (ci)
{
ci->next = NULL;

@ -65,7 +65,6 @@ static int
urj_bsdl_set_instruction_length (urj_bsdl_jtag_ctrl_t *jc)
{
if (jc->proc_mode & URJ_BSDL_MODE_INSTR_EXEC)
// @@@@ RFHH check result
(void) urj_part_instruction_length_set (jc->part, jc->instr_len);
if (jc->proc_mode & URJ_BSDL_MODE_INSTR_PRINT)
printf ("instruction %i\n", jc->instr_len);
@ -127,7 +126,6 @@ urj_bsdl_emit_ports (urj_bsdl_jtag_ctrl_t *jc)
port_string[str_len - 1] = '\0';
if (jc->proc_mode & URJ_BSDL_MODE_INSTR_EXEC)
// @@@@ RFHH check result
(void) urj_part_signal_define (jc->chain, port_string);
if (jc->proc_mode & URJ_BSDL_MODE_INSTR_PRINT)
printf ("signal %s\n", port_string);

@ -615,7 +615,7 @@ Init_Text (urj_vhdl_parser_priv_t *priv)
{
if (priv->len_buffer == 0)
{
/* @@@@ ToDo check malloc result RFHH */
/* @@@@ RFHH check malloc result */
priv->buffer = malloc (160);
priv->len_buffer = 160;
}
@ -651,7 +651,7 @@ Store_Text (urj_vhdl_parser_priv_t *priv, char *Source)
req_len = strlen (priv->buffer) + strlen (Source) + 1;
if (req_len > priv->len_buffer)
{
/* @@@@ ToDo check realloc result RFHH */
/* @@@@ RFHH check realloc result */
priv->buffer = realloc (priv->buffer, req_len);
priv->len_buffer = req_len;
}

@ -510,6 +510,7 @@ urj_vhdl_flex_switch_file (yyscan_t scanner, char *filename)
const char *db_path = urj_get_data_dir ();
char *db_file;
/* @@@@ RFHH handle malloc failure */
if ((db_file = malloc (strlen (db_path) + 1 + /* "/" */
4 + /* "bsdl" */
1 + /* "/" */

@ -72,13 +72,19 @@ au1500_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -548,13 +548,19 @@ avr32_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -70,13 +70,19 @@ bcm1250_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -78,13 +78,19 @@ bf533_ezkit_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -78,13 +78,19 @@ bf533_stamp_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -78,13 +78,19 @@ bf537_stamp_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -73,13 +73,19 @@ bf548_ezkit_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -78,13 +78,19 @@ bf561_ezkit_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -76,13 +76,19 @@ flashbscoach_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -165,11 +165,15 @@ urj_bus_buses_add (urj_bus_t *abus)
urj_bus_t **b;
if (abus == NULL)
/* @@@@ RFHH add status return */
return;
b = realloc (urj_buses.buses, (urj_buses.len + 1) * sizeof (urj_bus_t *));
if (b == NULL)
{
/* @@@@ RFHH add status return */
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
printf (_("Out of memory\n"));
return;
}
@ -189,6 +193,7 @@ urj_bus_buses_delete (urj_bus_t *abus)
if (abus == urj_buses.buses[i])
break;
if (i >= urj_buses.len)
/* @@@@ RFHH add status return */
return;
while (i + 1 < urj_buses.len)
@ -202,6 +207,7 @@ urj_bus_buses_delete (urj_bus_t *abus)
urj_buses.buses = b;
if (urj_bus != abus)
/* @@@@ RFHH add status return */
return;
if (urj_buses.len > 0)

@ -123,13 +123,19 @@ ejtag_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}
@ -181,9 +187,8 @@ ejtag_run_pracc (urj_bus_t *bus, const uint32_t *code, unsigned int len)
ejctrl = urj_part_find_data_register (bus->part, "EJCONTROL");
if (!(ejaddr && ejdata && ejctrl))
{
printf (_
("%s(%d) EJADDRESS, EJDATA or EJCONTROL register not found\n"),
__FILE__, __LINE__);
urj_error_set (URJ_ERROR_NOTFOUND,
_("EJADDRESS, EJDATA or EJCONTROL register not found"));
return 0;
}
@ -310,8 +315,8 @@ ejtag_bus_init (urj_bus_t *bus)
ejall = urj_part_find_data_register (bus->part, "EJALL");
if (!(ejctrl && ejimpl))
{
printf (_("%s(%d) EJCONTROL or EJIMPCODE register not found\n"),
__FILE__, __LINE__);
urj_error_set (URJ_ERROR_NOTFOUND,
_("EJCONTROL or EJIMPCODE register not found"));
return URJ_STATUS_FAIL;
}
@ -520,9 +525,9 @@ ejtag_bus_init (urj_bus_t *bus)
if (!ejctrl->out->data[BrkSt])
{
printf (_("%s(%d) Failed to enter debug mode, ctrl=%s\n"),
__FILE__, __LINE__,
urj_tap_register_get_string (ejctrl->out));
urj_error_set (URJ_ERROR_ILLEGAL_STATE,
_("Failed to enter debug mode, ctrl=%s"),
urj_tap_register_get_string (ejctrl->out));
return URJ_STATUS_FAIL;
}
else
@ -595,8 +600,6 @@ ejtag_bus_area (urj_bus_t *bus, uint32_t adr, urj_bus_area_t *area)
return URJ_STATUS_OK;
}
/* @@@@ RFHH Added a parameter bus on the assumption it doesn't really
* want to access the global urj_bus_t *bus */
static int
ejtag_gen_read (urj_bus_t *bus, uint32_t *code, uint32_t adr)
{

@ -96,13 +96,19 @@ ejtag_dma_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}
@ -169,8 +175,6 @@ siz_ (int sz)
* low-level dma write
*
*/
/* @@@@ RFHH Add a parameter bus on the assumption that the code doesn't
* really want to access the global variable urj_bus_t *bus */
static void
ejtag_dma_write (urj_bus_t *bus, unsigned int addr, unsigned int data, int sz)
{
@ -264,8 +268,6 @@ ejtag_dma_write (urj_bus_t *bus, unsigned int addr, unsigned int data, int sz)
* low level dma read operation
*
*/
/* @@@@ RFHH Add a parameter bus on the assumption that the code doesn't
* really want to access the global variable urj_bus_t *bus */
static unsigned int
ejtag_dma_read (urj_bus_t *bus, unsigned int addr, int sz)
{

@ -309,6 +309,8 @@ fjmem_query_blocks (urj_chain_t *chain, urj_part_t *part, urj_bus_t *bus)
if ((bl = calloc (1, sizeof (block_param_t))) == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
printf (_("out of memory\n"));
failed |= 1;
break;
@ -421,13 +423,19 @@ fjmem_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -68,13 +68,19 @@ h7202_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -68,13 +68,19 @@ ixp425_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -148,13 +148,19 @@ jopcyc_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -84,13 +84,19 @@ lh7a400_bus_new (urj_chain_t *chain, const const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -85,13 +85,19 @@ mpc5200_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = bp = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -160,13 +160,19 @@ mpc824x_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -66,13 +66,19 @@ ppc405ep_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -68,13 +68,19 @@ ppc440gx_ebc8_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -103,13 +103,18 @@ prototype_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}

@ -158,13 +158,19 @@ pxa2xx_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -114,17 +114,22 @@ s3c4510_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}
dbus_width = 16;
bus->chain = chain;
bus->part = part = chain->parts->parts[chain->active_part];

@ -73,13 +73,19 @@ sa1110_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -74,13 +74,19 @@ sh7727_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -74,13 +74,18 @@ sh7750r_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -72,13 +72,20 @@ sh7751r_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -76,13 +76,19 @@ sharc_21065L_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -108,13 +108,19 @@ slsup3_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -82,13 +82,19 @@ tx4925_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -167,13 +167,19 @@ zefant_xs3_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver,
bus = calloc (1, sizeof (urj_bus_t));
if (!bus)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (urj_bus_t));
return NULL;
}
bus->driver = driver;
bus->params = calloc (1, sizeof (bus_params_t));
if (!bus->params)
{
free (bus);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails",
1, sizeof (bus_params_t));
return NULL;
}

@ -68,7 +68,6 @@ cmd_addpart_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_FAIL;
}
/* @@@@ RFHH check result */
urj_part_parts_set_instruction (chain->parts, "BYPASS");
urj_tap_chain_shift_instructions (chain);

@ -96,7 +96,8 @@ cmd_cable_run (urj_chain_t *chain, char *params[])
{
if (strcasecmp (params[2], "help") == 0)
{
urj_tap_cable_drivers[i]->help (urj_tap_cable_drivers[i]->name);
urj_tap_cable_drivers[i]->help (URJ_LOG_LEVEL_NORMAL,
urj_tap_cable_drivers[i]->name);
return URJ_STATUS_OK;
}
}

@ -82,10 +82,17 @@ const urj_cmd_t *urj_cmds[] = {
NULL /* last must be NULL */
};
/*
* @param text match commands whose prefix equals <code>text</code>. Rotates
* through the registered commands. The prefix length is set when
* the rotating state is reset.
* @@@@ RFHH that is weird behaviour. Why not do the prefix length as strlen(text)?
*/
char *
urj_cmd_find_next (const char *text, int state)
{
static size_t cmd_idx, len;
char *next = NULL;
if (!state)
{
@ -97,10 +104,16 @@ urj_cmd_find_next (const char *text, int state)
{
char *name = urj_cmds[cmd_idx++]->name;
if (!strncmp (name, text, len))
return strdup (name);
{
next = strdup (name);
if (next == NULL)
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup(%s) fails",
name);
break;
}
}
return NULL;
return next;
}
int

@ -86,7 +86,6 @@ cmd_scan_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_FAIL;
}
/* @@@@ RFHH check result */
urj_tap_chain_shift_instructions (chain);
obsr = urj_tap_register_alloc (bsr->out->len);
@ -95,7 +94,6 @@ cmd_scan_run (urj_chain_t *chain, char *params[])
urj_tap_register_init (obsr, urj_tap_register_get_string (bsr->out)); // copy
/* @@@@ RFHH check result */
urj_tap_chain_shift_data_registers (chain, 1);
urj_part_signal_t *s;

@ -87,8 +87,7 @@ cmd_svf_run (urj_chain_t *chain, char *params[])
}
else
{
urj_error_IO_set ("%s: cannot open file '%s'",
params[0], params[1]);
urj_error_IO_set ("%s: cannot open file '%s'", params[0], params[1]);
result = URJ_STATUS_FAIL;
}

@ -160,8 +160,8 @@ urj_flash_cfi_detect (urj_bus_t *bus, uint32_t adr,
return URJ_STATUS_FAIL;
}
(*cfi_array)->cfi_chips[d / 8] =
calloc (1, sizeof (urj_flash_cfi_chip_t));
(*cfi_array)->cfi_chips[d / 8] = calloc (1,
sizeof (urj_flash_cfi_chip_t));
if (!(*cfi_array)->cfi_chips[d / 8])
{
write1 (0, CFI_CMD_READ_ARRAY1);

@ -94,7 +94,7 @@ urj_flash_detectflash (urj_log_level_t ll, urj_bus_t *bus, uint32_t adr)
if (urj_flash_cfi_array == NULL)
{
urj_error_set (URJ_ERROR_NOTFOUND, _("Flash not found!"));
urj_error_set (URJ_ERROR_NOTFOUND, _("Flash not found"));
return URJ_STATUS_FAIL;
}

@ -107,7 +107,7 @@ urj_flashmsbin (urj_bus_t *bus, FILE *f, int noverify)
set_flash_driver ();
if (!urj_flash_cfi_array || !flash_driver)
{
urj_error_set (URJ_ERROR_NOTFOUND, _("no flash driver found\n"));
urj_error_set (URJ_ERROR_NOTFOUND, _("no flash driver found"));
return URJ_STATUS_FAIL;
}
@ -121,7 +121,7 @@ urj_flashmsbin (urj_bus_t *bus, FILE *f, int noverify)
sync[7] = '\0';
if (strcmp ("B000FF\n", sync) != 0)
{
urj_error_set (URJ_ERROR_INVALID, _("Invalid sync sequence!\n"));
urj_error_set (URJ_ERROR_INVALID, _("Invalid sync sequence"));
return URJ_STATUS_FAIL;
}
}
@ -227,7 +227,7 @@ urj_flashmsbin (urj_bus_t *bus, FILE *f, int noverify)
break;
if (l & 3)
{
urj_error_set (URJ_ERROR_INVALID, _("Invalid record length!"));
urj_error_set (URJ_ERROR_INVALID, _("Invalid record length"));
return URJ_STATUS_FAIL;
}
@ -462,7 +462,7 @@ urj_flasherase (urj_bus_t *bus, uint32_t addr, int number)
set_flash_driver ();
if (!urj_flash_cfi_array || !flash_driver)
{
urj_error_set (URJ_ERROR_NOTFOUND, _("no flash driver found\n"));
urj_error_set (URJ_ERROR_NOTFOUND, _("no flash driver found"));
return URJ_STATUS_FAIL;
}
cfi = &urj_flash_cfi_array->cfi_chips[0]->cfi;
@ -525,9 +525,7 @@ urj_flasherase (urj_bus_t *bus, uint32_t addr, int number)
urj_log (URJ_LOG_LEVEL_NORMAL, _("\nErasing (partially) Failed.\n"));
/* BYPASS */
/* @@@@ RFHH check result */
// urj_part_parts_set_instruction( ps, "BYPASS" );
/* @@@@ RFHH check result */
// urj_tap_chain_shift_instructions( chain );
return status;

@ -251,13 +251,13 @@ intel_flash_erase_block (urj_flash_cfi_array_t *cfi_array, uint32_t adr)
case 0:
return URJ_STATUS_OK;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_PROGRAM_ERROR:
urj_error_set (URJ_ERROR_FLASH_ERASE, _("invalid command seq\n"));
urj_error_set (URJ_ERROR_FLASH_ERASE, _("invalid command seq"));
return URJ_STATUS_FAIL;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_VPEN_ERROR:
urj_error_set (URJ_ERROR_FLASH_ERASE, _("low vpen\n"));
urj_error_set (URJ_ERROR_FLASH_ERASE, _("low vpen"));
return URJ_STATUS_FAIL;
case CFI_INTEL_SR_ERASE_ERROR | CFI_INTEL_SR_BLOCK_LOCKED:
urj_error_set (URJ_ERROR_FLASH_ERASE, _("block locked\n"));
urj_error_set (URJ_ERROR_FLASH_ERASE, _("block locked"));
return URJ_STATUS_FAIL;
default:
break;
@ -283,7 +283,7 @@ intel_flash_unlock_block (urj_flash_cfi_array_t *cfi_array, uint32_t adr)
if (sr != CFI_INTEL_SR_READY)
{
urj_error_set (URJ_ERROR_FLASH_UNLOCK,
_("unknown error while unlocking block\n"));
_("unknown error while unlocking block"));
return URJ_STATUS_FAIL;
}
@ -307,7 +307,7 @@ intel_flash_program_single (urj_flash_cfi_array_t *cfi_array,
if (sr != CFI_INTEL_SR_READY)
{
urj_error_set (URJ_ERROR_FLASH_PROGRAM,
_("unknown error while programming\n"));
_("unknown error while programming"));
return URJ_STATUS_FAIL;
}
@ -366,7 +366,7 @@ intel_flash_program_buffer (urj_flash_cfi_array_t *cfi_array,
if (sr != CFI_INTEL_SR_READY)
{
urj_error_set (URJ_ERROR_FLASH_PROGRAM,
_("unknown error while programming\n"));
_("unknown error while programming"));
return URJ_STATUS_FAIL;
}
@ -478,7 +478,7 @@ intel_flash_program32_single (urj_flash_cfi_array_t *cfi_array,
if (sr != ((CFI_INTEL_SR_READY << 16) | CFI_INTEL_SR_READY))
{
urj_error_set (URJ_ERROR_FLASH_PROGRAM, "\nsr = 0x%08X\n", sr);
urj_error_set (URJ_ERROR_FLASH_PROGRAM, "sr = 0x%08X", sr);
return URJ_STATUS_FAIL;
}

@ -65,7 +65,8 @@ urj_parse_line (urj_chain_t *chain, char *line)
sline = malloc (l + 1);
if (sline == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%d) fails", l + 1);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
(size_t) (l + 1));
return URJ_STATUS_FAIL;
}
@ -104,7 +105,7 @@ urj_parse_line (urj_chain_t *chain, char *line)
if (a == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
(tcnt + 1) * sizeof (char *));
(size_t) ((tcnt + 1) * sizeof (char *)));
return URJ_STATUS_FAIL;
}

@ -228,7 +228,6 @@ urj_jim_alloc_device (int num_sregs, const int reg_size[])
int i, r;
urj_jim_device_t *dev = malloc (sizeof (urj_jim_device_t));
if (dev == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",

@ -63,7 +63,7 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
}
if (ctrl_num != -1 && ctrl_num >= bsr->in->len)
{
urj_error_set(URJ_ERROR_INVALID, _("invalid control bit number\n"));
urj_error_set(URJ_ERROR_INVALID, _("invalid control bit number"));
return URJ_STATUS_FAIL;
}
@ -74,7 +74,7 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
b = malloc (sizeof *b);
if (!b)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc fails");
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails", sizeof *b);
return URJ_STATUS_FAIL;
}
@ -82,7 +82,7 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
if (!b->name)
{
free (b);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup fails");
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup(%s) fails", name);
return URJ_STATUS_FAIL;
}

@ -217,7 +217,7 @@ urj_part_set_signal (urj_part_t *p, urj_part_signal_t *s, int out, int val)
if (!bsr)
{
urj_error_set (URJ_ERROR_NOTFOUND,
_("Boundary Scan Register (BSR) not found\n"));
_("Boundary Scan Register (BSR) not found"));
return URJ_STATUS_FAIL;
}
@ -228,7 +228,7 @@ urj_part_set_signal (urj_part_t *p, urj_part_signal_t *s, int out, int val)
if (!s->output)
{
urj_error_set (URJ_ERROR_INVALID,
_("signal '%s' cannot be set as output\n"), s->name);
_("signal '%s' cannot be set as output"), s->name);
return URJ_STATUS_FAIL;
}
bsr->in->data[s->output->bit] = val & 1;
@ -243,7 +243,7 @@ urj_part_set_signal (urj_part_t *p, urj_part_signal_t *s, int out, int val)
if (!s->input)
{
urj_error_set (URJ_ERROR_INVALID,
_("signal '%s' cannot be set as input\n"), s->name);
_("signal '%s' cannot be set as input"), s->name);
return URJ_STATUS_FAIL;
}
if (s->output)
@ -270,14 +270,14 @@ urj_part_get_signal (urj_part_t *p, const urj_part_signal_t *s)
if (!bsr)
{
urj_error_set (URJ_ERROR_NOTFOUND,
_("Boundary Scan Register (BSR) not found\n"));
_("Boundary Scan Register (BSR) not found"));
return -1;
}
if (!s->input)
{
urj_error_set (URJ_ERROR_INVALID,
_("signal '%s' is not input signal\n"), s->name);
_("signal '%s' is not input signal"), s->name);
return -1;
}

@ -111,7 +111,7 @@ urj_part_signal_define_pin (urj_chain_t *chain, const char *signal_name,
if (urj_part_find_signal (part, signal_name) != NULL)
{
urj_error_set (URJ_ERROR_ALREADY,
_("Signal '%s' already defined\n"), signal_name);
_("Signal '%s' already defined"), signal_name);
return NULL;
}
@ -155,7 +155,7 @@ urj_part_signal_redefine_pin (urj_chain_t *chain, urj_part_signal_t *s,
s->pin = strdup (pin_name);
if (s->pin == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup fails");
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup(%s) fails", pin_name);
return URJ_STATUS_FAIL;
}

@ -658,14 +658,14 @@ urj_svf_runtest (urj_chain_t *chain, urj_svf_parser_priv_t *priv,
if (params->run_count > 0 && params->run_clk != TCK)
{
urj_error_set (URJ_ERROR_INVALID,
_("Error %s: only TCK is supported for RUNTEST.\n"),
_("Error %s: only TCK is supported for RUNTEST"),
"svf");
return (0);
}
if (params->max_time > 0.0 && params->max_time < params->min_time)
{
urj_error_set (URJ_ERROR_OUT_OF_BOUNDS,
_("Error %s: maximum time must be larger or equal to minimum time.\n"),
_("Error %s: maximum time must be larger or equal to minimum time"),
"svf");
return (0);
}
@ -707,7 +707,7 @@ urj_svf_runtest (urj_chain_t *chain, urj_svf_parser_priv_t *priv,
else
{
urj_error_set (URJ_ERROR_OUT_OF_BOUNDS,
_("Error %s: Maximum cable clock frequency required for RUNTEST.\n"),
_("Error %s: Maximum cable clock frequency required for RUNTEST"),
"svf");
urj_log (URJ_LOG_LEVEL_ERROR,
_(" Set the cable frequency with 'FREQUENCY <Hz>'.\n"));
@ -948,7 +948,6 @@ urj_svf_sxr (urj_chain_t *chain, urj_svf_parser_priv_t *priv,
{
case generic_ir:
urj_svf_goto_state (chain, URJ_TAP_STATE_SHIFT_IR);
/* @@@@ RFHH check result */
urj_tap_chain_shift_instructions_mode (chain,
sxr_params->params.tdo ? 1 : 0,
0, URJ_CHAIN_EXITMODE_EXIT1);
@ -962,7 +961,6 @@ urj_svf_sxr (urj_chain_t *chain, urj_svf_parser_priv_t *priv,
case generic_dr:
urj_svf_goto_state (chain, URJ_TAP_STATE_SHIFT_DR);
/* @@@@ RFHH check result */
urj_tap_chain_shift_data_registers_mode (chain,
sxr_params->params.
tdo ? 1 : 0, 0,
@ -1010,7 +1008,7 @@ urj_svf_trst (urj_chain_t *chain, urj_svf_parser_priv_t *priv, int trst_mode)
if (priv->svf_trst_absent)
{
urj_error_set (URJ_ERROR_ILLEGAL_STATE,
_("Error %s: no further TRST command allowed after mode ABSENT\n"),
_("Error %s: no further TRST command allowed after mode ABSENT"),
"svf");
return (0);
}
@ -1033,7 +1031,7 @@ urj_svf_trst (urj_chain_t *chain, urj_svf_parser_priv_t *priv, int trst_mode)
if (priv->svf_state_executed)
{
urj_error_set (URJ_ERROR_ILLEGAL_STATE,
_("Error %s: TRST ABSENT must not be issued after a STATE command\n"),
_("Error %s: TRST ABSENT must not be issued after a STATE command"),
"svf");
return (0);
}
@ -1041,7 +1039,7 @@ urj_svf_trst (urj_chain_t *chain, urj_svf_parser_priv_t *priv, int trst_mode)
priv->sdr_params.params.number > 0.0)
{
urj_error_set (URJ_ERROR_ILLEGAL_STATE,
_("Error %s: TRST ABSENT must not be issued after an SIR or SDR command\n"),
_("Error %s: TRST ABSENT must not be issued after an SIR or SDR command"),
"svf");
}
break;
@ -1141,14 +1139,14 @@ urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch,
- data register */
if (chain == NULL)
{
urj_error_set (URJ_ERROR_NO_CHAIN, _("%s: no JTAG chain available\n"),
urj_error_set (URJ_ERROR_NO_CHAIN, _("%s: no JTAG chain available"),
"svf");
return 0;
}
if (chain->parts == NULL)
{
urj_error_set (URJ_ERROR_NOTFOUND,
_("%s: chain without any parts\n"), "svf");
_("%s: chain without any parts"), "svf");
return 0;
}
priv.part = chain->parts->parts[chain->active_part];
@ -1164,7 +1162,7 @@ urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch,
if (!(priv.dr = urj_part_find_data_register (priv.part, "SDR")))
{
urj_error_set (URJ_ERROR_NOTFOUND,
_("%s: could not establish SDR register\n"),
_("%s: could not establish SDR register"),
"svf");
return 0;
}
@ -1204,7 +1202,7 @@ urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch,
if (!(priv.ir = urj_part_find_instruction (priv.part, "SIR")))
{
urj_error_set (URJ_ERROR_NOTFOUND,
_("%s: could not establish SIR instruction\n"),
_("%s: could not establish SIR instruction"),
"svf");
return 0;
}

@ -178,7 +178,7 @@ urj_tap_cable_init (urj_cable_t *cable)
if (cable->todo.data == NULL || cable->done.data == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY,
_("malloc(%zd) or malloc(%zd) fails"),
_("malloc(%zd)/malloc(%zd) fails"),
cable->todo.max_items * sizeof (urj_cable_queue_t),
cable->done.max_items * sizeof (urj_cable_queue_t));
if (cable->todo.data != NULL)

@ -23,6 +23,7 @@
*/
#include <urjtag/sysdep.h>
#include <urjtag/error.h>
#include <stdlib.h>
#include <string.h>
@ -57,6 +58,12 @@ extend_cmd_buffer (urj_tap_cable_cx_cmd_t *cmd)
cmd->buf = realloc (cmd->buf, cmd->buf_len);
}
if (cmd->buf == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "realloc(%s,%zd) fails",
"cmd->buf", cmd->buf_len);
}
return cmd->buf ? 1 : 0;
}
@ -217,6 +224,12 @@ urj_tap_cable_cx_cmd_queue (urj_tap_cable_cx_cmd_root_t *cmd_root,
}
}
if (cmd == NULL)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd)/malloc(%zd) fails",
sizeof (urj_tap_cable_cx_cmd_t), 64);
}
return cmd;
}

@ -248,9 +248,8 @@ ft2232_set_frequency (urj_cable_t *cable, uint32_t new_frequency)
if (div >= (1 << 16))
{
div = (1 << 16) - 1;
printf (_
("Warning: Setting lowest supported frequency for FT2232: %d\n"),
FT2232_MAX_TCK_FREQ / div);
urj_warning (_("Setting lowest supported frequency for FT2232: %d\n"),
FT2232_MAX_TCK_FREQ / div);
}
/* send new divisor to device */
@ -276,7 +275,7 @@ ft2232_generic_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* safe default values */
params->low_byte_value = 0;
@ -309,7 +308,7 @@ ft2232_generic_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = 0;
return 0;
return URJ_STATUS_OK;
}
static int
@ -319,7 +318,7 @@ ft2232_jtagkey_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
set nOE to '0' -> activate output enables */
@ -363,7 +362,7 @@ ft2232_jtagkey_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -374,7 +373,7 @@ ft2232_armusbocd_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
set nOE to '0' -> activate output enables */
@ -418,7 +417,7 @@ ft2232_armusbocd_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -429,7 +428,7 @@ ft2232_gnice_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* safe default values */
params->low_byte_value = 0;
@ -464,7 +463,7 @@ ft2232_gnice_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST;
return 0;
return URJ_STATUS_OK;
}
@ -475,7 +474,7 @@ ft2232_oocdlinks_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction */
params->low_byte_value = 0;
@ -518,7 +517,7 @@ ft2232_oocdlinks_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -529,7 +528,7 @@ ft2232_turtelizer2_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
set nJTAGOE to '0' -> activate output enables
@ -568,7 +567,7 @@ ft2232_turtelizer2_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -579,7 +578,7 @@ ft2232_usbtojtagif_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
nTRST = 1, RST = 1, DBGRQ = 0 */
@ -622,7 +621,7 @@ ft2232_usbtojtagif_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -633,7 +632,7 @@ ft2232_signalyzer_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
nTRST = 1, nSRST = 1 */
@ -668,7 +667,7 @@ ft2232_signalyzer_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
@ -679,7 +678,7 @@ ft2232_flyswatter_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* static low byte value and direction:
nTRST = 1, nSRST = 1 (ADBUS5 inverted),
@ -716,7 +715,7 @@ ft2232_flyswatter_init (urj_cable_t *cable)
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
return 0;
return URJ_STATUS_OK;
}
static int
@ -726,7 +725,7 @@ ft2232_usbscarab2_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
/* Check if cable is connected to the target and the target is powered on */
urj_tap_cable_cx_cmd_queue (cmd_root, 1);
@ -736,9 +735,9 @@ ft2232_usbscarab2_init (urj_cable_t *cable)
if ((urj_tap_cable_cx_xfer_recv (cable) & BITMASK_USBSCARAB2_nCONNECTED)
!= 0)
{
printf (_
("Error: Please power on the TARGET board and connect VCC signal!\n"));
return -1;
urj_error_set (URJ_ERROR_ILLEGAL_STATE,
_("Please power on the TARGET board and connect VCC signal"));
return URJ_STATUS_FAIL;
}
/* These bits will be set by default to: */
@ -774,8 +773,8 @@ ft2232_usbscarab2_init (urj_cable_t *cable)
params->last_tdo_valid = 0;
params->signals = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
printf ("Cable initialization OK!\n");
return 0;
urj_log (URJ_LOG_LEVEL_NORMAL, "Cable initialization OK!\n");
return URJ_STATUS_OK;
}
@ -1347,7 +1346,8 @@ ft2232_set_signal (urj_cable_t *cable, int mask, int val)
static void
ft2232_transfer_schedule (urj_cable_t *cable, int len, char *in, char *out)
ft2232_transfer_schedule (urj_cable_t *cable, int len, const char *in,
char *out)
{
params_t *params = (params_t *) cable->params;
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
@ -1542,7 +1542,7 @@ ft2232_transfer_finish (urj_cable_t *cable, int len, char *out)
static int
ft2232_transfer (urj_cable_t *cable, int len, char *in, char *out)
ft2232_transfer (urj_cable_t *cable, int len, const char *in, char *out)
{
params_t *params = (params_t *) cable->params;
@ -1699,7 +1699,10 @@ ft2232_flush (urj_cable_t *cable, urj_cable_flush_amount_t how_much)
int m = urj_tap_cable_add_queue_item (cable,
&(cable->done));
if (m < 0)
printf ("out of memory!\n");
{
// retain error state
// urj_log (URJ_LOG_LEVEL_NORMAL, "out of memory!\n");
}
cable->done.data[m].action = URJ_TAP_CABLE_TRANSFER;
cable->done.data[m].arg.xferred.len =
cable->todo.data[j].arg.transfer.len;
@ -1727,23 +1730,23 @@ static int
ft2232_connect (char *params[], urj_cable_t *cable)
{
params_t *cable_params;
int result;
/* perform urj_tap_cable_generic_usbconn_connect */
if ((result = urj_tap_cable_generic_usbconn_connect (params, cable)) != 0)
return result;
if (urj_tap_cable_generic_usbconn_connect (params, cable) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
cable_params = malloc (sizeof (params_t));
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof (params_t));
/* NOTE:
* Call the underlying usbport driver (*free) routine directly
* not urj_tap_cable_generic_usbconn_free() since it also free's cable->params
* (which is not established) and cable (which the caller will do)
*/
cable->link.usb->driver->free (cable->link.usb);
return 4;
return URJ_STATUS_FAIL;
}
cable_params->mpsse_frequency = 0;
@ -1755,7 +1758,7 @@ ft2232_connect (char *params[], urj_cable_t *cable)
free (cable->params);
cable->params = cable_params;
return 0;
return URJ_STATUS_OK;
}
@ -1783,7 +1786,7 @@ urj_usbconn_cable_t urj_tap_cable_usbconn_usbscarab2_ftdi;
static void
ft2232_usbcable_help (const char *cablename)
ft2232_usbcable_help (urj_log_level_t ll, const char *cablename)
{
urj_usbconn_cable_t *conn;
@ -1817,14 +1820,14 @@ ft2232_usbcable_help (const char *cablename)
conn = &urj_tap_cable_usbconn_ft2232_ftdi;
found:
printf (_
("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [driver=DRIVER]\n"
"\n" "VID vendor ID (hex), defaults to %04X\n"
"PID product ID (hex), defaults to %04X\n"
"DESC Some string to match in description or serial no.\n"
"DRIVER usbconn driver, either ftdi-mpsse or ftd2xx-mpsse\n"
" defaults to %s if not specified\n" "\n"), cablename,
conn->vid, conn->pid, DEFAULT_DRIVER);
urj_log (ll,
_("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [driver=DRIVER]\n"
"\n" "VID vendor ID (hex), defaults to %04X\n"
"PID product ID (hex), defaults to %04X\n"
"DESC Some string to match in description or serial no.\n"
"DRIVER usbconn driver, either ftdi-mpsse or ftd2xx-mpsse\n"
" defaults to %s if not specified\n" "\n"), cablename,
conn->vid, conn->pid, DEFAULT_DRIVER);
}

@ -46,17 +46,14 @@
#endif
#undef VERBOSE
#ifdef VERBOSE
static void
print_vector (int len, char *vec)
print_vector (urj_log_level_t ll, int len, char *vec)
{
int i;
for (i = 0; i < len; i++)
printf ("%c", vec[i] ? '1' : '0');
urj_log (ll, "%c", vec[i] ? '1' : '0');
}
#endif
void
urj_tap_cable_generic_disconnect (urj_cable_t *cable)
@ -66,7 +63,7 @@ urj_tap_cable_generic_disconnect (urj_cable_t *cable)
}
int
urj_tap_cable_generic_transfer (urj_cable_t *cable, int len, char *in,
urj_tap_cable_generic_transfer (urj_cable_t *cable, int len, const char *in,
char *out)
{
int i;
@ -97,9 +94,7 @@ do_one_queued_action (urj_cable_t *cable)
{
int i;
#ifdef VERBOSE
printf ("do_one_queued\n");
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "do_one_queued\n");
if ((i = urj_tap_cable_get_queue_item (cable, &(cable->todo))) >= 0)
{
@ -111,8 +106,10 @@ do_one_queued_action (urj_cable_t *cable)
|| cable->todo.data[i].action == URJ_TAP_CABLE_GET_SIGNAL
|| cable->todo.data[i].action == URJ_TAP_CABLE_TRANSFER)
{
printf (_("No space in cable activity results queue.\n"));
urj_error_set (URJ_ERROR_OUT_OF_BOUNDS,
_("No space in cable activity results queue"));
urj_tap_cable_purge_queue (&(cable->done), 1);
/* @@@@ RFHH shouldn't we bail out? */
}
}
@ -131,6 +128,7 @@ do_one_queued_action (urj_cable_t *cable)
break;
case URJ_TAP_CABLE_TRANSFER:
{
/* @@@@ RFHH check result */
int r = cable->driver->transfer (cable,
cable->todo.data[i].arg.
transfer.len,
@ -142,12 +140,12 @@ do_one_queued_action (urj_cable_t *cable)
free (cable->todo.data[i].arg.transfer.in);
if (cable->todo.data[i].arg.transfer.out != NULL)
{
/* @@@@ RFHH check result */
j = urj_tap_cable_add_queue_item (cable, &(cable->done));
#ifdef VERBOSE
printf ("add result from transfer to %p.%d (out=%p)\n",
&(cable->done), j,
cable->todo.data[i].arg.transfer.out);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"add result from transfer to %p.%d (out=%p)\n",
&(cable->done), j,
cable->todo.data[i].arg.transfer.out);
cable->done.data[j].action = URJ_TAP_CABLE_TRANSFER;
cable->done.data[j].arg.xferred.len =
cable->todo.data[i].arg.transfer.len;
@ -158,20 +156,20 @@ do_one_queued_action (urj_cable_t *cable)
break;
}
case URJ_TAP_CABLE_GET_TDO:
/* @@@@ RFHH check result */
j = urj_tap_cable_add_queue_item (cable, &(cable->done));
#ifdef VERBOSE
printf ("add result from get_tdo to %p.%d\n", &(cable->done), j);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"add result from get_tdo to %p.%d\n", &(cable->done), j);
cable->done.data[j].action = URJ_TAP_CABLE_GET_TDO;
cable->done.data[j].arg.value.val =
cable->driver->get_tdo (cable);
break;
case URJ_TAP_CABLE_GET_SIGNAL:
/* @@@@ RFHH check result */
j = urj_tap_cable_add_queue_item (cable, &(cable->done));
#ifdef VERBOSE
printf ("add result from get_signal to %p.%d\n", &(cable->done),
j);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"add result from get_signal to %p.%d\n", &(cable->done),
j);
cable->done.data[j].action = URJ_TAP_CABLE_GET_SIGNAL;
cable->done.data[j].arg.value.sig =
cable->todo.data[i].arg.value.sig;
@ -180,15 +178,11 @@ do_one_queued_action (urj_cable_t *cable)
cable->todo.data[i].arg.value.sig);
break;
}
#ifdef VERBOSE
printf ("do_one_queued done\n");
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "do_one_queued done\n");
return 1;
}
#ifdef VERBOSE
printf ("do_one_queued abort\n");
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "do_one_queued abort\n");
return 0;
}
@ -220,9 +214,7 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
{
int r, bits = 0, tdo = 0;
#ifdef VERBOSE
printf ("flush(%d)\n", cable->todo.num_items);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "flush(%d)\n", cable->todo.num_items);
/* Combine as much as possible into transfer() */
@ -234,37 +226,29 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
&& cable->todo.data[i].action != URJ_TAP_CABLE_TRANSFER
&& cable->todo.data[i].action != URJ_TAP_CABLE_GET_TDO)
{
#ifdef VERBOSE
printf
("cutoff at n=%d because action unsuitable for transfer\n",
n);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"cutoff at n=%d because action unsuitable for transfer\n",
n);
break;
}
if (cable->todo.data[i].action == URJ_TAP_CABLE_CLOCK
&& cable->todo.data[i].arg.clock.tms != 0)
{
#ifdef VERBOSE
printf
("cutoff at n=%d because clock.tms=1 is unsuitable for transfer\n",
n);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"cutoff at n=%d because clock.tms=1 is unsuitable for transfer\n",
n);
break;
}
if (cable->todo.data[i].action == URJ_TAP_CABLE_CLOCK)
{
int k = cable->todo.data[i].arg.clock.n;
#ifdef VERBOSE
printf ("%d clock(s)\n", k);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "%d clock(s)\n", k);
bits += k;
}
else if (cable->todo.data[i].action == URJ_TAP_CABLE_TRANSFER)
{
int k = cable->todo.data[i].arg.transfer.len;
#ifdef VERBOSE
printf ("%d transfer\n", k);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "%d transfer\n", k);
bits += k;
}
i++;
@ -272,9 +256,8 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
i = 0;
}
#ifdef VERBOSE
printf ("%d combined into one (%d bits)\n", n, bits);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL, "%d combined into one (%d bits)\n",
n, bits);
if (bits == 0 || n <= 1)
{
@ -323,18 +306,17 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
/* Step 3: Do the transfer */
/* @@@@ RFHH check result */
r = cable->driver->transfer (cable, bits, in, out);
#ifdef VERBOSE
printf ("in: ");
print_vector (bits, in);
printf ("\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "in: ");
print_vector (URJ_LOG_LEVEL_DETAIL, bits, in);
urj_log (URJ_LOG_LEVEL_DETAIL, "\n");
if (out)
{
printf ("out: ");
print_vector (bits, out);
printf ("\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "out: ");
print_vector (URJ_LOG_LEVEL_DETAIL, bits, out);
urj_log (URJ_LOG_LEVEL_DETAIL, "\n");
}
#endif
/* Step 4: Pick results from transfer */
@ -348,12 +330,11 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
}
else if (cable->todo.data[i].action == URJ_TAP_CABLE_GET_TDO)
{
int c =
urj_tap_cable_add_queue_item (cable, &(cable->done));
#ifdef VERBOSE
printf ("add result from transfer to %p.%d\n",
&(cable->done), c);
#endif
int c = urj_tap_cable_add_queue_item (cable,
&(cable->done));
urj_log (URJ_LOG_LEVEL_DETAIL,
"add result from transfer to %p.%d\n",
&(cable->done), c);
cable->done.data[c].action = URJ_TAP_CABLE_GET_TDO;
cable->done.data[c].arg.value.val = tdo;
}
@ -366,10 +347,9 @@ urj_tap_cable_generic_flush_using_transfer (urj_cable_t *cable,
{
int c = urj_tap_cable_add_queue_item (cable,
&(cable->done));
#ifdef VERBOSE
printf ("add result from transfer to %p.%d\n",
&(cable->done), c);
#endif
urj_log (URJ_LOG_LEVEL_DETAIL,
"add result from transfer to %p.%d\n",
&(cable->done), c);
cable->done.data[c].action = URJ_TAP_CABLE_TRANSFER;
cable->done.data[c].arg.xferred.len = len;
cable->done.data[c].arg.xferred.res = r;
@ -417,7 +397,8 @@ urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
new_frequency < (1.0 + tolerance) * frequency)
return;
printf ("requested frequency %u, now calibrating delay loop\n",
urj_log (URJ_LOG_LEVEL_NORMAL,
"requested frequency %u, now calibrating delay loop\n",
new_frequency);
while (1)
@ -435,8 +416,8 @@ urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
if (end < start)
{
printf (_
("calibration error, wall clock is not monotonically increasing\n"));
urj_log (URJ_LOG_LEVEL_ERROR,
_("calibration error, wall clock is not monotonically increasing\n"));
break;
}
if (end == start)
@ -447,7 +428,7 @@ urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
continue;
}
real_frequency = (long double) loops / (end - start);
printf ("new real frequency %Lg, delay %u\n",
urj_log (URJ_LOG_LEVEL_NORMAL, "new real frequency %Lg, delay %u\n",
real_frequency, delay);
new_delay = (long double) delay *real_frequency / new_frequency;
@ -473,7 +454,7 @@ urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
{
if (delay == 0)
{
printf ("operating without delay\n");
urj_log (URJ_LOG_LEVEL_NORMAL, "operating without delay\n");
frequency = real_frequency;
break;
}
@ -490,7 +471,7 @@ urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
}
}
printf ("done\n");
urj_log (URJ_LOG_LEVEL_NORMAL, "done\n");
cable->delay = delay;
cable->frequency = frequency;

@ -38,7 +38,8 @@ typedef struct
void urj_tap_cable_generic_disconnect (urj_cable_t *cable);
void urj_tap_cable_generic_set_frequency (urj_cable_t *cable,
uint32_t new_freq);
int urj_tap_cable_generic_transfer (urj_cable_t *cable, int len, char *in,
/** @return number of clocks on success; -1 on error */
int urj_tap_cable_generic_transfer (urj_cable_t *cable, int len, const char *in,
char *out);
int urj_tap_cable_generic_get_signal (urj_cable_t *cable,
urj_pod_sigsel_t sig);

@ -37,15 +37,13 @@
#include "generic.h"
#include "generic_parport.h"
#undef VERBOSE
#ifdef VERBOSE
#ifdef UNUSED
static void
print_vector (int len, char *vec)
print_vector (urj_log_level_t ll, int len, char *vec)
{
int i;
for (i = 0; i < len; i++)
printf ("%c", vec[i] ? '1' : '0');
urj_log (ll, "%c", vec[i] ? '1' : '0');
}
#endif
@ -58,8 +56,8 @@ urj_tap_cable_generic_parport_connect (char *params[], urj_cable_t *cable)
if (urj_cmd_params (params) < 3)
{
printf (_("not enough arguments!\n"));
return 1;
urj_error_set (URJ_ERROR_SYNTAX, _("not enough arguments"));
return URJ_STATUS_FAIL;
}
/* search parport driver list */
@ -68,8 +66,9 @@ urj_tap_cable_generic_parport_connect (char *params[], urj_cable_t *cable)
break;
if (!urj_tap_parport_drivers[i])
{
printf (_("Unknown port driver: %s\n"), params[1]);
return 2;
urj_error_set (URJ_ERROR_NOTFOUND, _("Unknown port driver: %s"),
params[1]);
return URJ_STATUS_FAIL;
}
/* set up parport driver */
@ -78,23 +77,25 @@ urj_tap_cable_generic_parport_connect (char *params[], urj_cable_t *cable)
if (port == NULL)
{
printf (_("Error: Cable connection failed!\n"));
return 3;
// retain error state
// printf (_("Error: Cable connection failed!\n"));
return URJ_STATUS_FAIL;
}
cable_params = malloc (sizeof *cable_params);
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof *cable_params);
urj_tap_parport_drivers[i]->parport_free (port);
return 4;
return URJ_STATUS_FAIL;
}
cable->link.port = port;
cable->params = cable_params;
cable->chain = NULL;
return 0;
return URJ_STATUS_OK;
}
void
@ -112,28 +113,29 @@ urj_tap_cable_generic_parport_done (urj_cable_t *cable)
}
void
urj_tap_cable_generic_parport_help (const char *cablename)
urj_tap_cable_generic_parport_help (urj_log_level_t ll, const char *cablename)
{
printf (_("Usage: cable %s parallel PORTADDR\n"
urj_log (ll,
_("Usage: cable %s parallel PORTADDR\n"
#if ENABLE_LOWLEVEL_PPDEV
" or: cable %s ppdev PPDEV\n"
" or: cable %s ppdev PPDEV\n"
#endif
#if HAVE_DEV_PPBUS_PPI_H
" or: cable %s ppi PPIDEV\n"
" or: cable %s ppi PPIDEV\n"
#endif
"\n" "PORTADDR parallel port address (e.g. 0x378)\n"
"\n" "PORTADDR parallel port address (e.g. 0x378)\n"
#if ENABLE_LOWLEVEL_PPDEV
"PPDEV ppdev device (e.g. /dev/parport0)\n"
"PPDEV ppdev device (e.g. /dev/parport0)\n"
#endif
#if HAVE_DEV_PPBUS_PPI_H
"PPIDEF ppi device (e.g. /dev/ppi0)\n"
"PPIDEF ppi device (e.g. /dev/ppi0)\n"
#endif
"\n"),
"\n"),
#if ENABLE_LOWLEVEL_PPDEV
cablename,
cablename,
#endif
#if HAVE_DEV_PPBUS_PPI_H
cablename,
cablename,
#endif
cablename);
cablename);
}

@ -32,6 +32,6 @@ int urj_tap_cable_generic_parport_connect (char *params[],
urj_cable_t *cable);
void urj_tap_cable_generic_parport_free (urj_cable_t *cable);
void urj_tap_cable_generic_parport_done (urj_cable_t *cable);
void urj_tap_cable_generic_parport_help (const char *name);
void urj_tap_cable_generic_parport_help (urj_log_level_t ll, const char *name);
#endif /* URJ_TAP_CABLE_GENERIC_H */

@ -35,8 +35,7 @@
#include <urjtag/cmd.h>
#undef VERBOSE
/* @@@@ RFHH put these in a .h file */
#ifdef ENABLE_CABLE_XPC
extern urj_usbconn_cable_t urj_tap_cable_usbconn_xpc_int;
extern urj_usbconn_cable_t urj_tap_cable_usbconn_xpc_ext;
@ -186,9 +185,8 @@ urj_tap_cable_generic_usbconn_connect (char *params[], urj_cable_t *cable)
for (i = 0; urj_tap_usbconn_drivers[i] && !conn; i++)
{
if ((user_specified.driver == NULL)
||
(strcasecmp
(user_specified.driver, urj_tap_usbconn_drivers[i]->type) == 0))
|| (strcasecmp (user_specified.driver,
urj_tap_usbconn_drivers[i]->type) == 0))
{
int j;
@ -196,14 +194,11 @@ urj_tap_cable_generic_usbconn_connect (char *params[], urj_cable_t *cable)
for (j = 0; urj_tap_cable_usbconn_cables[j] && !conn; j++)
{
if ((user_specified.name == NULL)
||
(strcasecmp
(user_specified.name,
urj_tap_cable_usbconn_cables[j]->name) == 0))
|| (strcasecmp (user_specified.name,
urj_tap_cable_usbconn_cables[j]->name) == 0))
{
if (strcasecmp
(urj_tap_cable_usbconn_cables[j]->driver,
urj_tap_usbconn_drivers[i]->type) == 0)
if (strcasecmp (urj_tap_cable_usbconn_cables[j]->driver,
urj_tap_usbconn_drivers[i]->type) == 0)
{
urj_usbconn_cable_t cable_try =
*(urj_tap_cable_usbconn_cables[j]);
@ -215,6 +210,7 @@ urj_tap_cable_generic_usbconn_connect (char *params[], urj_cable_t *cable)
if (user_specified.desc != 0)
cable_try.desc = user_specified.desc;
// @@@@ RFHH bail out on failure?
conn =
urj_tap_usbconn_drivers[i]->
connect ((const char **) &params[1], paramc - 1,
@ -227,23 +223,27 @@ urj_tap_cable_generic_usbconn_connect (char *params[], urj_cable_t *cable)
if (!conn)
{
printf (_("Couldn't connect to suitable USB device.\n"));
return 2;
// @@@@ RFHH make this into either the error from drivers->connect,
// or urj_error_set (NOT_FOUND)
urj_log (URJ_LOG_LEVEL_ERROR,
_("Couldn't connect to suitable USB device.\n"));
return URJ_STATUS_FAIL;
}
cable_params = malloc (sizeof (urj_tap_cable_generic_params_t));
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof (urj_tap_cable_generic_params_t));
urj_tap_usbconn_drivers[i]->free (conn);
return 4;
return URJ_STATUS_FAIL;
}
cable->link.usb = conn;
cable->params = cable_params;
cable->chain = NULL;
return 0;
return URJ_STATUS_OK;
}
void
@ -261,12 +261,13 @@ urj_tap_cable_generic_usbconn_done (urj_cable_t *cable)
}
void
urj_tap_cable_generic_usbconn_help (const char *cablename)
urj_tap_cable_generic_usbconn_help (urj_log_level_t ll, const char *cablename)
{
printf (_("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [...]\n"
"\n"
"VID USB Device Vendor ID (hex, e.g. 0abc)\n"
"PID USB Device Product ID (hex, e.g. 0abc)\n"
"DESC Some string to match in description or serial no.\n"
"\n"), cablename);
urj_log (ll,
_("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [...]\n"
"\n"
"VID USB Device Vendor ID (hex, e.g. 0abc)\n"
"PID USB Device Product ID (hex, e.g. 0abc)\n"
"DESC Some string to match in description or serial no.\n"
"\n"), cablename);
}

@ -28,10 +28,13 @@
#include <urjtag/cable.h>
#include <urjtag/usbconn.h>
/** @return 0 on success, > 0 on error.
* Make this: URJ_STATUS_OK on success, URJ_STATUS_FAIL and urj_error on
* error */
int urj_tap_cable_generic_usbconn_connect (char *params[],
urj_cable_t *cable);
void urj_tap_cable_generic_usbconn_done (urj_cable_t *cable);
void urj_tap_cable_generic_usbconn_help (const char *name);
void urj_tap_cable_generic_usbconn_help (urj_log_level_t ll, const char *name);
void urj_tap_cable_generic_usbconn_free (urj_cable_t *cable);
#endif /* URJ_TAP_CABLE_GENERIC_H */

@ -52,32 +52,34 @@ jim_cable_connect (char *params[], urj_cable_t *cable)
if (urj_cmd_params (params) < 1)
{
printf (_("not enough arguments!\n"));
return 1;
urj_error_set (URJ_ERROR_SYNTAX, _("not enough arguments"));
return URJ_STATUS_FAIL;
}
printf (_("JTAG target simulator JIM - work in progress!\n"));
urj_warning (_("JTAG target simulator JIM - work in progress!\n"));
s = urj_jim_init ();
if (!s)
{
printf (_("Initialization failed.\n"));
return 3;
// retain error state
// printf (_("Initialization failed.\n"));
return URJ_STATUS_FAIL;
}
cable_params = malloc (sizeof (jim_cable_params_t));
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof (jim_cable_params_t));
urj_jim_free (s);
return 4;
return URJ_STATUS_FAIL;
}
cable->params = cable_params;
((jim_cable_params_t *) (cable->params))->s = s;
cable->chain = NULL;
return 0;
return URJ_STATUS_OK;
}
static void
@ -106,7 +108,7 @@ jim_cable_done (urj_cable_t *cable)
static int
jim_cable_init (urj_cable_t *cable)
{
return 0;
return URJ_STATUS_OK;
}
static void
@ -148,9 +150,9 @@ jim_cable_set_trst (urj_cable_t *cable, int trst)
}
static void
jim_cable_help (const char *cablename)
jim_cable_help (urj_log_level_t ll, const char *cablename)
{
printf (_("Usage: cable %s\n"), cablename);
urj_log (ll, _("Usage: cable %s\n"), cablename);
}
urj_cable_driver_t urj_tap_cable_jim_driver = {

@ -47,10 +47,6 @@
#include <usb.h>
#include <string.h>
#define INFO(...) printf(__VA_ARGS__)
#define ERROR(...) printf(__VA_ARGS__)
#define DEBUG(...)
#define JLINK_WRITE_ENDPOINT 0x02
#define JLINK_READ_ENDPOINT 0x81
@ -108,7 +104,9 @@ static void jlink_tap_append_step (jlink_usbconn_data_t *data, int, int);
/* Jlink lowlevel functions */
static int jlink_usb_message (urj_usbconn_libusb_param_t *params, int, int);
/** @return number of bytes written; -1 on error */
static int jlink_usb_write (urj_usbconn_libusb_param_t *params, unsigned int);
/** @return number of bytes read; -1 on error */
static int jlink_usb_read (urj_usbconn_libusb_param_t *params);
static void jlink_debug_buffer (char *buffer, int length);
@ -125,7 +123,7 @@ void
urj_tap_cable_jlink_reset (urj_usbconn_libusb_param_t *params, int trst,
int srst)
{
DEBUG ("trst: %i, srst: %i\n", trst, srst);
urj_log (URJ_LOG_LEVEL_DETAIL, "trst: %i, srst: %i\n", trst, srst);
/* Signals are active low */
if (trst == 0)
@ -154,14 +152,15 @@ jlink_simple_command (urj_usbconn_libusb_param_t *params, uint8_t command)
int result;
jlink_usbconn_data_t *data = params->data;
DEBUG ("simple_command: 0x%02x\n", command);
urj_log (URJ_LOG_LEVEL_DETAIL, "simple_command: 0x%02x\n", command);
data->usb_out_buffer[0] = command;
result = jlink_usb_write (params, 1);
if (result != 1)
{
ERROR ("J-Link command 0x%02x failed (%d)\n", command, result);
urj_log (URJ_LOG_LEVEL_ERROR, "J-Link command 0x%02x failed (%d)\n",
command, result);
}
}
@ -178,23 +177,25 @@ jlink_get_status (urj_usbconn_libusb_param_t *params)
if (result == 8)
{
int vref = data->usb_in_buffer[0] + (data->usb_in_buffer[1] << 8);
INFO ("Vref = %d.%d TCK=%d TDI=%d TDO=%d TMS=%d TRES=%d TRST=%d\n",
vref / 1000, vref % 1000,
data->usb_in_buffer[2],
data->usb_in_buffer[3],
data->usb_in_buffer[4],
data->usb_in_buffer[5],
data->usb_in_buffer[6], data->usb_in_buffer[7]);
urj_log (URJ_LOG_LEVEL_NORMAL,
"Vref = %d.%d TCK=%d TDI=%d TDO=%d TMS=%d TRES=%d TRST=%d\n",
vref / 1000, vref % 1000,
data->usb_in_buffer[2],
data->usb_in_buffer[3],
data->usb_in_buffer[4],
data->usb_in_buffer[5],
data->usb_in_buffer[6], data->usb_in_buffer[7]);
if (vref < 1500)
{
ERROR
("Vref too low. Eventually the target isn't powered or disconnected?\n");
urj_log (URJ_LOG_LEVEL_ERROR,
"Vref too low. Possibly the target isn't powered or disconnected?\n");
result = -15;
}
}
else
{
ERROR ("J-Link command 0x07 (get status) failed (%d)\n", result);
urj_log (URJ_LOG_LEVEL_ERROR,
"J-Link command 0x07 (get status) failed (%d)\n", result);
}
return result;
@ -234,7 +235,7 @@ jlink_tap_append_step (jlink_usbconn_data_t *data, int tms, int tdi)
}
else
{
ERROR ("jlink_tap_append_step, overflow\n");
urj_log (URJ_LOG_LEVEL_ERROR, "jlink_tap_append_step, overflow\n");
}
}
@ -281,8 +282,9 @@ jlink_tap_execute (urj_usbconn_libusb_param_t *params)
}
else
{
ERROR ("jlink_tap_execute, wrong result %d, expected %d\n",
result, byte_length);
urj_log (URJ_LOG_LEVEL_ERROR,
"jlink_tap_execute, wrong result %d, expected %d\n",
result, byte_length);
return -2;
}
@ -311,16 +313,18 @@ jlink_usb_message (urj_usbconn_libusb_param_t *params, int out_length,
}
else
{
ERROR ("usb_bulk_read failed (requested=%d, result=%d)\n",
in_length, result);
urj_log (URJ_LOG_LEVEL_ERROR,
"usb_bulk_read failed (requested=%d, result=%d)\n",
in_length, result);
return -1;
}
}
else
{
ERROR ("usb_bulk_write failed (requested=%d, result=%d)\n",
out_length, result);
urj_log (URJ_LOG_LEVEL_ERROR,
"usb_bulk_write failed (requested=%d, result=%d)\n",
out_length, result);
return -1;
}
@ -339,8 +343,9 @@ jlink_usb_write (urj_usbconn_libusb_param_t *params, unsigned int out_length)
if (out_length > JLINK_OUT_BUFFER_SIZE)
{
ERROR ("jlink_jtag_write illegal out_length=%d (max=%d)\n",
out_length, JLINK_OUT_BUFFER_SIZE);
urj_log (URJ_LOG_LEVEL_ERROR,
"jlink_jtag_write illegal out_length=%d (max=%d)\n",
out_length, JLINK_OUT_BUFFER_SIZE);
return -1;
}
@ -350,8 +355,9 @@ jlink_usb_write (urj_usbconn_libusb_param_t *params, unsigned int out_length)
data->usb_out_buffer,
out_length, JLINK_USB_TIMEOUT);
DEBUG ("jlink_usb_write, out_length = %d, result = %d\n", out_length,
result);
urj_log (URJ_LOG_LEVEL_DETAIL,
"jlink_usb_write, out_length = %d, result = %d\n", out_length,
result);
jlink_debug_buffer (data->usb_out_buffer, out_length);
return result;
}
@ -370,7 +376,7 @@ jlink_usb_read (urj_usbconn_libusb_param_t *params)
JLINK_IN_BUFFER_SIZE,
JLINK_USB_TIMEOUT);
DEBUG ("jlink_usb_read, result = %d\n", result);
urj_log (URJ_LOG_LEVEL_DETAIL, "jlink_usb_read, result = %d\n", result);
jlink_debug_buffer (data->usb_in_buffer, result);
return result;
}
@ -395,8 +401,8 @@ jlink_debug_buffer (char *buffer, int length)
snprintf (s, 4, " %02x", buffer[j]);
strcat (line, s);
}
DEBUG (line);
DEBUG ("\n");
urj_log (URJ_LOG_LEVEL_DETAIL, line);
urj_log (URJ_LOG_LEVEL_DETAIL, "\n");
}
}
@ -413,12 +419,14 @@ jlink_init (urj_cable_t *cable)
params->data = malloc (sizeof (jlink_usbconn_data_t));
if (params->data == NULL)
{
return -1;
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
sizeof (jlink_usbconn_data_t));
return URJ_STATUS_FAIL;
}
data = params->data;
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
jlink_tap_init (data);
@ -427,25 +435,27 @@ jlink_init (urj_cable_t *cable)
if (result != 2 || data->usb_in_buffer[0] != 0x07
|| data->usb_in_buffer[1] != 0x00)
{
INFO ("J-Link initial read failed, don't worry (result=%d)\n",
result);
urj_log (URJ_LOG_LEVEL_NORMAL,
"J-Link initial read failed, don't worry (result=%d)\n",
result);
}
result = jlink_get_status (params);
if (result < 0)
{
ERROR ("Resetting J-Link. Please retry the cable command.\n");
urj_log (URJ_LOG_LEVEL_ERROR,
"Resetting J-Link. Please retry the cable command.\n");
usb_reset (params->handle);
return -1;
return URJ_STATUS_FAIL;
}
INFO ("J-Link JTAG Interface ready\n");
urj_log (URJ_LOG_LEVEL_NORMAL, "J-Link JTAG Interface ready\n");
urj_tap_cable_jlink_set_frequency (cable, 4E6);
urj_tap_cable_jlink_reset (params, 0, 0);
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -481,13 +491,15 @@ urj_tap_cable_jlink_set_frequency (urj_cable_t *cable, uint32_t frequency)
if (result != 3)
{
ERROR ("J-Link setting speed failed (%d)\n", result);
urj_log (URJ_LOG_LEVEL_ERROR,
"J-Link setting speed failed (%d)\n", result);
}
}
else
{
INFO ("Requested speed %dkHz exceeds maximum of %dkHz, ignored\n",
speed, JLINK_MAX_SPEED);
urj_log (URJ_LOG_LEVEL_NORMAL,
"Requested speed %dkHz exceeds maximum of %dkHz, ignored\n",
speed, JLINK_MAX_SPEED);
}
}
@ -537,7 +549,7 @@ jlink_copy_out_data (jlink_usbconn_data_t *data, int len, int offset,
}
static int
jlink_transfer (urj_cable_t *cable, int len, char *in, char *out)
jlink_transfer (urj_cable_t *cable, int len, const char *in, char *out)
{
int i, j;
urj_usbconn_libusb_param_t *params = cable->link.usb->params;

@ -67,12 +67,12 @@ static int
keithkoep_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
return -1;
return URJ_STATUS_FAIL;
urj_tap_parport_set_control (cable->link.port, 1 << TRST);
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
return 0;
return URJ_STATUS_OK;
}
static void

@ -57,18 +57,19 @@ lattice_init (urj_cable_t *cable)
int data;
if (urj_tap_parport_open (cable->link.port))
return -1;
return URJ_STATUS_FAIL;
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST))
return -1;
if (urj_tap_parport_set_data (cable->link.port, 1 << TRST)
!= URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
else
PARAM_SIGNALS (cable) = ((data >> TRST) && 1) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void

@ -65,12 +65,12 @@ static int
mpcbdm_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
return -1;
return URJ_STATUS_FAIL;
urj_tap_parport_set_control (cable->link.port, 0);
PARAM_SIGNALS (cable) = (URJ_POD_CS_TRST | URJ_POD_CS_RESET);
return 0;
return URJ_STATUS_OK;
}
static void

@ -70,12 +70,12 @@ static int
triton_init (urj_cable_t *cable)
{
if (urj_tap_parport_open (cable->link.port))
return -1;
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST | URJ_POD_CS_RESET;
urj_tap_parport_set_data (cable->link.port, (1 << TRST) | (1 << SRESET));
return 0;
return URJ_STATUS_OK;
}
static void
@ -91,14 +91,12 @@ triton_clock (urj_cable_t *cable, int tms, int tdi, int n)
for (i = 0; i < n; i++)
{
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (sreset << SRESET) | (0 <<
TCK)
| (tms << TMS) | (tdi << TDI));
(trst << TRST) | (sreset << SRESET)
| (0 << TCK) | (tms << TMS) | (tdi << TDI));
urj_tap_cable_wait (cable);
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (sreset << SRESET) | (1 <<
TCK)
| (tms << TMS) | (tdi << TDI));
(trst << TRST) | (sreset << SRESET)
| (1 << TCK) | (tms << TMS) | (tdi << TDI));
urj_tap_cable_wait (cable);
}
@ -115,8 +113,7 @@ triton_get_tdo (urj_cable_t *cable)
int sreset = (PARAM_SIGNALS (cable) & URJ_POD_CS_RESET) ? 1 : 0;
urj_tap_parport_set_data (cable->link.port,
(trst << TRST) | (sreset << SRESET) | (0 <<
TCK));
(trst << TRST) | (sreset << SRESET) | (0 << TCK));
PARAM_SIGNALS (cable) &=
~(URJ_POD_CS_TDI | URJ_POD_CS_TCK | URJ_POD_CS_TMS);

@ -86,8 +86,8 @@ ts7800_gpio_open (urj_cable_t *cable)
p->fd_dev_mem = open ("/dev/mem", O_RDWR | O_SYNC);
if (p->fd_dev_mem == -1)
{
printf (_("Error: unable to open /dev/mem\n"));
return -1;
urj_error_IO_set (_("unable to open /dev/mem"));
return URJ_STATUS_FAIL;
}
p->map_size = getpagesize ();
@ -99,9 +99,9 @@ ts7800_gpio_open (urj_cable_t *cable)
p->fd_dev_mem, GPIO_BASE & ~map_mask);
if (p->map_base == MAP_FAILED)
{
printf (_("Error: unable to mmap the GPIO registers\n"));
urj_error_IO_set (_("unable to mmap the GPIO registers"));
close (p->fd_dev_mem);
return -1;
return URJ_STATUS_FAIL;
}
/* Create the pointers to access the GPIO registers */
@ -113,7 +113,7 @@ ts7800_gpio_open (urj_cable_t *cable)
p->lastout = p->gpio_base[GPIO_OUT];
return 0;
return URJ_STATUS_OK;
}
static int
@ -124,10 +124,10 @@ ts7800_gpio_close (urj_cable_t *cable)
/* Unmap the GPIO registers */
if (munmap (p->map_base, p->map_size) == -1)
{
printf (_("Error: unable to munmap the GPIO registers\n"));
urj_error_IO_set (_("unable to munmap the GPIO registers"));
}
close (p->fd_dev_mem);
return 0;
return URJ_STATUS_OK;
}
static int
@ -157,25 +157,28 @@ ts7800_connect (char *params[], urj_cable_t *cable)
if (urj_cmd_params (params) != 1)
{
printf (_("Error: This cable type does not accept parameters!\n"));
return 1;
urj_error_set (URJ_ERROR_SYNTAX,
_("This cable type does not accept parameters"));
return URJ_STATUS_FAIL;
}
printf (_("Initializing TS-7800 Built-in JTAG Chain\n"));
urj_log (URJ_LOG_LEVEL_NORMAL,
_("Initializing TS-7800 Built-in JTAG Chain\n"));
cable_params = malloc (sizeof *cable_params);
if (!cable_params)
{
printf (_("%s(%d) Out of memory\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof *cable_params);
free (cable);
return 4;
return URJ_STATUS_FAIL;
}
cable->params = cable_params;
cable->chain = NULL;
cable->delay = 1000;
return 0;
return URJ_STATUS_OK;
}
static void
@ -198,11 +201,11 @@ ts7800_init (urj_cable_t *cable)
ts7800_params_t *p = cable->params;
if (ts7800_gpio_open (cable))
return -1;
return URJ_STATUS_FAIL;
p->signals = URJ_POD_CS_TRST;
return 0;
return URJ_STATUS_OK;
}
static void
@ -289,9 +292,10 @@ ts7800_get_signal (urj_cable_t *cable, urj_pod_sigsel_t sig)
}
static void
ts7800_help (const char *cablename)
ts7800_help (urj_log_level_t ll, const char *cablename)
{
printf (_("Usage: cable %s\n" "\n"), cablename);
urj_log (ll,
_("Usage: cable %s\n" "\n"), cablename);
}
urj_cable_driver_t urj_tap_cable_ts7800_driver = {

@ -69,23 +69,23 @@ static int
usbblaster_connect (char *params[], urj_cable_t *cable)
{
params_t *cable_params;
int result;
/* perform urj_tap_cable_generic_usbconn_connect */
if ((result = urj_tap_cable_generic_usbconn_connect (params, cable)) != 0)
return result;
if (urj_tap_cable_generic_usbconn_connect (params, cable) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
cable_params = malloc (sizeof (params_t));
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof (params_t));
/* NOTE:
* Call the underlying usbport driver (*free) routine directly
* not urj_tap_cable_generic_usbconn_free() since it also free's cable->params
* (which is not established) and cable (which the caller will do)
*/
cable->link.usb->driver->free (cable->link.usb);
return 4;
return URJ_STATUS_FAIL;
}
urj_tap_cable_cx_cmd_init (&(cable_params->cmd_root));
@ -94,15 +94,15 @@ usbblaster_connect (char *params[], urj_cable_t *cable)
free (cable->params);
cable->params = cable_params;
return 0;
return URJ_STATUS_OK;
}
static void
usbblaster_set_frequency (urj_cable_t *cable, uint32_t new_frequency)
{
if (new_frequency != FIXED_FREQUENCY)
printf (_("Warning: USB-Blaster frequency is fixed to %ld Hz\n"),
FIXED_FREQUENCY);
urj_warning (_("USB-Blaster frequency is fixed to %ld Hz\n"),
FIXED_FREQUENCY);
cable->frequency = FIXED_FREQUENCY;
}
@ -115,7 +115,7 @@ usbblaster_init (urj_cable_t *cable)
urj_tap_cable_cx_cmd_root_t *cmd_root = &(params->cmd_root);
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
urj_tap_cable_cx_cmd_queue (cmd_root, 0);
for (i = 0; i < 64; i++)
@ -125,7 +125,7 @@ usbblaster_init (urj_cable_t *cable)
usbblaster_set_frequency (cable, FIXED_FREQUENCY);
return 0;
return URJ_STATUS_OK;
}
static void
@ -148,7 +148,7 @@ usbblaster_clock_schedule (urj_cable_t *cable, int tms, int tdi, int n)
tms = tms ? (1 << TMS) : 0;
tdi = tdi ? (1 << TDI) : 0;
// printf("clock: %d %d %d\n", tms, tdi, n);
// urj_log (URJ_LOG_LEVEL_COMM, "clock: %d %d %d\n", tms, tdi, n);
m = n;
if (tms == 0 && m >= 8)
@ -223,7 +223,7 @@ usbblaster_get_tdo_finish (urj_cable_t *cable)
{
#if 0
char x = (urj_tap_cable_cx_xfer_recv (cable) & (1 << TDO)) ? 1 : 0;
printf ("GetTDO %d\n", x);
urj_log (URJ_LOG_LEVEL_COMM, "GetTDO %d\n", x);
return x;
#else
return (urj_tap_cable_cx_xfer_recv (cable) & (1 << TDO)) ? 1 : 0;
@ -248,7 +248,7 @@ usbblaster_set_signal (urj_cable_t *cable, int mask, int val)
}
static void
usbblaster_transfer_schedule (urj_cable_t *cable, int len, char *in,
usbblaster_transfer_schedule (urj_cable_t *cable, int len, const char *in,
char *out)
{
params_t *params = (params_t *) cable->params;
@ -261,10 +261,10 @@ usbblaster_transfer_schedule (urj_cable_t *cable, int len, char *in,
#if 0
{
int o;
printf ("%d in: ", len);
urj_log (URJ_LOG_LEVEL_COMM, "%d in: ", len);
for (o = 0; o < len; o++)
printf ("%c", in[o] ? '1' : '0');
printf ("\n");
urj_log (URJ_LOG_LEVEL_COMM, "%c", in[o] ? '1' : '0');
urj_log (URJ_LOG_LEVEL_COMM, "\n");
}
#endif
@ -341,7 +341,7 @@ usbblaster_transfer_finish (urj_cable_t *cable, int len, char *out)
int j;
unsigned char b = urj_tap_cable_cx_xfer_recv (cable);
#if 0
printf ("read byte: %02X\n", b);
urj_log (URJ_LOG_LEVEL_COMM, "read byte: %02X\n", b);
#endif
for (j = 1; j < 256; j <<= 1)
@ -357,10 +357,10 @@ usbblaster_transfer_finish (urj_cable_t *cable, int len, char *out)
#if 0
{
int o;
printf ("%d out: ", len);
urj_log (URJ_LOG_LEVEL_COMM, "%d out: ", len);
for (o = 0; o < len; o++)
printf ("%c", out[o] ? '1' : '0');
printf ("\n");
urj_log (URJ_LOG_LEVEL_COMM, "%c", out[o] ? '1' : '0');
urj_log (URJ_LOG_LEVEL_COMM, "\n");
}
#endif
@ -368,7 +368,7 @@ usbblaster_transfer_finish (urj_cable_t *cable, int len, char *out)
}
static int
usbblaster_transfer (urj_cable_t *cable, int len, char *in, char *out)
usbblaster_transfer (urj_cable_t *cable, int len, const char *in, char *out)
{
params_t *params = (params_t *) cable->params;
@ -470,7 +470,10 @@ usbblaster_flush (urj_cable_t *cable, urj_cable_flush_amount_t how_much)
int m = urj_tap_cable_add_queue_item (cable,
&(cable->done));
if (m < 0)
printf ("out of memory!\n");
{
// retain error state
// urj_log (URJ_LOG_LEVEL_NORMAL, "out of memory!\n");
}
cable->done.data[m].action = URJ_TAP_CABLE_TRANSFER;
cable->done.data[m].arg.xferred.len =
cable->todo.data[j].arg.transfer.len;
@ -494,16 +497,16 @@ usbblaster_flush (urj_cable_t *cable, urj_cable_flush_amount_t how_much)
}
static void
usbblaster_help (const char *cablename)
usbblaster_help (urj_log_level_t ll, const char *cablename)
{
printf (_
("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [driver=DRIVER]\n"
"\n" "VID vendor ID (hex, e.g. 0abc)\n"
"PID product ID (hex, e.g. 0abc)\n"
"DESC Some string to match in description or serial no.\n"
"DRIVER usbconn driver, either ftdi or ftd2xx\n"
" defaults to %s if not specified\n" "\n"), cablename,
DEFAULT_DRIVER);
urj_log (ll,
_("Usage: cable %s [vid=VID] [pid=PID] [desc=DESC] [driver=DRIVER]\n"
"\n" "VID vendor ID (hex, e.g. 0abc)\n"
"PID product ID (hex, e.g. 0abc)\n"
"DESC Some string to match in description or serial no.\n"
"DRIVER usbconn driver, either ftdi or ftd2xx\n"
" defaults to %s if not specified\n" "\n"), cablename,
DEFAULT_DRIVER);
}
urj_cable_driver_t urj_tap_cable_usbblaster_driver = {

@ -92,22 +92,21 @@ ep9307_gpio_open (urj_cable_t *cable)
p->fd_dev_mem = open ("/dev/mem", O_RDWR | O_SYNC);
if (p->fd_dev_mem == -1)
{
printf (_("Error: unable to open /dev/mem\n"));
return -1;
urj_error_IO_set (_("unable to open /dev/mem"));
return URJ_STATUS_FAIL;
}
p->map_size = getpagesize ();
map_mask = p->map_size - 1;
/* Map the System Controller registers */
p->map_base =
mmap (0, p->map_size, PROT_READ | PROT_WRITE, MAP_SHARED,
p->fd_dev_mem, SYSCON_BASE & ~map_mask);
p->map_base = mmap (0, p->map_size, PROT_READ | PROT_WRITE, MAP_SHARED,
p->fd_dev_mem, SYSCON_BASE & ~map_mask);
if (p->map_base == MAP_FAILED)
{
printf (_("Error: unable to mmap the System Control registers\n"));
urj_error_IO_set (_("unable to mmap the System Control registers"));
close (p->fd_dev_mem);
return -1;
return URJ_STATUS_FAIL;
}
/* Create the pointers to access the DeviceCfg and SysSWLock registers */
@ -125,10 +124,9 @@ ep9307_gpio_open (urj_cable_t *cable)
/* Unmap the System Controller registers */
if (munmap (p->map_base, p->map_size) == -1)
{
printf (_
("Error: unable to munmap the System Controller registers\n"));
urj_error_IO_set (_("unable to munmap the System Controller registers"));
close (p->fd_dev_mem);
return -1;
return URJ_STATUS_FAIL;
}
/* Map the GPIO registers */
@ -137,9 +135,9 @@ ep9307_gpio_open (urj_cable_t *cable)
p->fd_dev_mem, GPIO_BASE & ~map_mask);
if (p->map_base == MAP_FAILED)
{
printf (_("Error: unable to mmap the GPIO registers\n"));
urj_error_IO_set (_("unable to mmap the GPIO registers"));
close (p->fd_dev_mem);
return -1;
return URJ_STATUS_FAIL;
}
/* Create the pointers to access the PHDR and PHDDR registers */
@ -152,7 +150,7 @@ ep9307_gpio_open (urj_cable_t *cable)
tmp &= GPIO_OUTPUT_MASK;
*((uint32_t *) gpio_PHDDR) = tmp;
return 0;
return URJ_STATUS_OK;
}
static int
@ -163,10 +161,10 @@ ep9307_gpio_close (urj_cable_t *cable)
/* Unmap the GPIO registers */
if (munmap (p->map_base, p->map_size) == -1)
{
printf (_("Error: unable to munmap the GPIO registers\n"));
urj_error_IO_set (_("unable to munmap the GPIO registers"));
}
close (p->fd_dev_mem);
return 0;
return URJ_STATUS_OK;
}
static int
@ -202,24 +200,27 @@ ep9307_connect (char *params[], urj_cable_t *cable)
if (urj_cmd_params (params) != 1)
{
printf (_("Error: This cable type does not accept parameters!\n"));
return 1;
urj_error_set (URJ_ERROR_SYNTAX,
_("This cable type does not accept parameters"));
return URJ_STATUS_FAIL;
}
printf (_("Initializing Vision EP9307 SoM GPIO JTAG Cable\n"));
urj_log (URJ_LOG_LEVEL_NORMAL,
_("Initializing Vision EP9307 SoM GPIO JTAG Cable\n"));
cable_params = malloc (sizeof *cable_params);
if (!cable_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
return 4;
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof *cable_params);
return URJ_STATUS_FAIL;
}
cable->link.port = NULL;
cable->params = cable_params;
cable->chain = NULL;
return 0;
return URJ_STATUS_OK;
}
static void
@ -235,13 +236,13 @@ ep9307_init (urj_cable_t *cable)
ep9307_params_t *p = cable->params;
if (ep9307_gpio_open (cable))
return -1;
return URJ_STATUS_FAIL;
ep9307_gpio_write (cable, 1 << TRST);
urj_tap_cable_wait (cable);
p->signals = URJ_POD_CS_TRST;
return 0;
return URJ_STATUS_OK;
}
static void
@ -290,10 +291,8 @@ ep9307_current_signals (urj_cable_t *cable)
{
ep9307_params_t *p = cable->params;
int sigs =
p->
signals & ~(URJ_POD_CS_TMS | URJ_POD_CS_TDI | URJ_POD_CS_TCK |
URJ_POD_CS_TRST);
int sigs = p->signals & ~(URJ_POD_CS_TMS | URJ_POD_CS_TDI | URJ_POD_CS_TCK
| URJ_POD_CS_TRST);
if (p->lastout & (1 << TCK))
sigs |= URJ_POD_CS_TCK;
if (p->lastout & (1 << TDI))
@ -335,9 +334,9 @@ ep9307_get_signal (urj_cable_t *cable, urj_pod_sigsel_t sig)
}
static void
ep9307_help (const char *cablename)
ep9307_help (urj_log_level_t ll, const char *cablename)
{
printf (_("Usage: cable %s\n" "\n"), cablename);
urj_log (ll, _("Usage: cable %s\n" "\n"), cablename);
}
urj_cable_driver_t urj_tap_cable_ep9307_driver = {

@ -69,52 +69,48 @@
#define xstr(s) str(s)
#define str(s) #s
static const char *std_wgl_map = xstr (TDO) ","
xstr (nTRST)
","
xstr (TDI)
","
xstr (TCK)
","
xstr (TMS)
"," "#"
xstr (nSRESET);
xstr (nTRST) ","
xstr (TDI) ","
xstr (TCK) ","
xstr (TMS) ","
"#" xstr (nSRESET);
/* private parameters of this cable driver */
typedef struct
{
int signals;
int trst_lvl;
int srst_act, srst_inact;
int tms_act, tms_inact;
int tck_act, tck_inact;
int tdi_act, tdi_inact;
int tdo_act, tdo_inact;
int trst_act, trst_inact;
int unused_bits;
} wiggler_params_t;
typedef struct
{
int signals;
int trst_lvl;
int srst_act, srst_inact;
int tms_act, tms_inact;
int tck_act, tck_inact;
int tdi_act, tdi_inact;
int tdo_act, tdo_inact;
int trst_act, trst_inact;
int unused_bits;
} wiggler_params_t;
/* access macros for the parameters */
#define PRM_SIGNALS(cable) ((wiggler_params_t *) cable->params)->signals
#define PRM_TRST_LVL(cable) ((wiggler_params_t *) cable->params)->trst_lvl
#define PRM_SRST_ACT(cable) ((wiggler_params_t *) cable->params)->srst_act
#define PRM_SRST_INACT(cable) ((wiggler_params_t *) cable->params)->srst_inact
#define PRM_TMS_ACT(cable) ((wiggler_params_t *) cable->params)->tms_act
#define PRM_TMS_INACT(cable) ((wiggler_params_t *) cable->params)->tms_inact
#define PRM_TCK_ACT(cable) ((wiggler_params_t *) cable->params)->tck_act
#define PRM_TCK_INACT(cable) ((wiggler_params_t *) cable->params)->tck_inact
#define PRM_TDI_ACT(cable) ((wiggler_params_t *) cable->params)->tdi_act
#define PRM_TDI_INACT(cable) ((wiggler_params_t *) cable->params)->tdi_inact
#define PRM_TDO_ACT(cable) ((wiggler_params_t *) cable->params)->tdo_act
#define PRM_TDO_INACT(cable) ((wiggler_params_t *) cable->params)->tdo_inact
#define PRM_TRST_ACT(cable) ((wiggler_params_t *) cable->params)->trst_act
#define PRM_TRST_INACT(cable) ((wiggler_params_t *) cable->params)->trst_inact
#define PRM_UNUSED_BITS(cable) ((wiggler_params_t *) cable->params)->unused_bits
static int map_pin (char *pin, int *act, int *inact)
#define PRM_SIGNALS(cable) ((wiggler_params_t *) (cable)->params)->signals
#define PRM_TRST_LVL(cable) ((wiggler_params_t *) (cable)->params)->trst_lvl
#define PRM_SRST_ACT(cable) ((wiggler_params_t *) (cable)->params)->srst_act
#define PRM_SRST_INACT(cable) ((wiggler_params_t *) (cable)->params)->srst_inact
#define PRM_TMS_ACT(cable) ((wiggler_params_t *) (cable)->params)->tms_act
#define PRM_TMS_INACT(cable) ((wiggler_params_t *) (cable)->params)->tms_inact
#define PRM_TCK_ACT(cable) ((wiggler_params_t *) (cable)->params)->tck_act
#define PRM_TCK_INACT(cable) ((wiggler_params_t *) (cable)->params)->tck_inact
#define PRM_TDI_ACT(cable) ((wiggler_params_t *) (cable)->params)->tdi_act
#define PRM_TDI_INACT(cable) ((wiggler_params_t *) (cable)->params)->tdi_inact
#define PRM_TDO_ACT(cable) ((wiggler_params_t *) (cable)->params)->tdo_act
#define PRM_TDO_INACT(cable) ((wiggler_params_t *) (cable)->params)->tdo_inact
#define PRM_TRST_ACT(cable) ((wiggler_params_t *) (cable)->params)->trst_act
#define PRM_TRST_INACT(cable) ((wiggler_params_t *) (cable)->params)->trst_inact
#define PRM_UNUSED_BITS(cable) ((wiggler_params_t *) (cable)->params)->unused_bits
static int map_pin (char *pin, int *act, int *inact)
{
int bitnum;
int inverted = 0;
@ -126,7 +122,10 @@ static const char *std_wgl_map = xstr (TDO) ","
}
if (!isdigit (*pin))
{
urj_error_set (URJ_ERROR_SYNTAX, "should be digit: '%s'", pin);
return -1;
}
bitnum = atoi (pin) % 8;
@ -171,7 +170,10 @@ set_mapping (char *bitmap, urj_cable_t *cable)
}
if (!syntax)
{
urj_error_set (URJ_ERROR_SYNTAX, "pin mapping");
return -1;
}
if (map_pin (tdo, &(PRM_TDO_ACT (cable)), &(PRM_TDO_INACT (cable))) != 0)
return -1;
@ -184,8 +186,7 @@ set_mapping (char *bitmap, urj_cable_t *cable)
return -1;
if (map_pin (tms, &(PRM_TMS_ACT (cable)), &(PRM_TMS_INACT (cable))) != 0)
return -1;
if (map_pin (srst, &(PRM_SRST_ACT (cable)), &(PRM_SRST_INACT (cable))) !=
0)
if (map_pin (srst, &(PRM_SRST_ACT (cable)), &(PRM_SRST_INACT (cable))) != 0)
return -1;
return 0;
@ -195,7 +196,6 @@ set_mapping (char *bitmap, urj_cable_t *cable)
static int
wiggler_connect (char *params[], urj_cable_t *cable)
{
int result;
char *param_bitmap = NULL;
wiggler_params_t *wiggler_params;
@ -207,8 +207,8 @@ wiggler_connect (char *params[], urj_cable_t *cable)
params[3] = NULL;
}
if ((result = urj_tap_cable_generic_parport_connect (params, cable)) != 0)
return result;
if (urj_tap_cable_generic_parport_connect (params, cable) != URJ_STATUS_OK)
return URJ_STATUS_FAIL;
if (param_bitmap)
params[3] = param_bitmap;
@ -216,7 +216,8 @@ wiggler_connect (char *params[], urj_cable_t *cable)
wiggler_params = malloc (sizeof *wiggler_params);
if (!wiggler_params)
{
printf (_("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, _("malloc(%zd) fails"),
sizeof *wiggler_params);
/* NOTE:
* Call the underlying parport driver (*free) routine directly
* not generic_parconn_free() since it also free's cable->params
@ -233,26 +234,26 @@ wiggler_connect (char *params[], urj_cable_t *cable)
if (!param_bitmap)
param_bitmap = (char *) std_wgl_map;
if ((result = set_mapping (param_bitmap, cable)) != 0)
if (set_mapping (param_bitmap, cable) != 0)
{
printf (_("Pin mapping failed\n"));
urj_log (URJ_LOG_LEVEL_ERROR, _("Pin mapping failed\n"));
/* NOTE:
* Call the underlying parport driver (*free) routine directly
* not generic_parconn_free() since it also free'scable (which
* not generic_parconn_free() since it also free's cable (which
* the caller will do)
*/
cable->link.port->driver->parport_free (cable->link.port);
free (cable->params);
return result;
return URJ_STATUS_FAIL;
}
/* Certain Macraigor Wigglers appear to use one of the unused data lines as a
power line so set all unused bits high. */
PRM_UNUSED_BITS (cable) =
~(PRM_SRST_ACT (cable) | PRM_SRST_INACT (cable) | PRM_TMS_ACT (cable)
| PRM_TMS_INACT (cable) | PRM_TCK_ACT (cable) |
PRM_TCK_INACT (cable) | PRM_TDI_ACT (cable) | PRM_TDI_INACT (cable)
| PRM_TRST_ACT (cable) | PRM_TRST_INACT (cable)) & 0xff;
| PRM_TMS_INACT (cable) | PRM_TCK_ACT (cable) | PRM_TCK_INACT (cable)
| PRM_TDI_ACT (cable) | PRM_TDI_INACT (cable) | PRM_TRST_ACT (cable)
| PRM_TRST_INACT (cable)) & 0xff;
return 0;
}
@ -267,11 +268,12 @@ wiggler_init (urj_cable_t *cable)
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data
(cable->link.port,
(PRM_TRST_ACT (cable) | PRM_TRST_INACT (cable)) |
PRM_UNUSED_BITS (cable)))
return -1;
if (urj_tap_parport_set_data (cable->link.port,
(PRM_TRST_ACT (cable)
| PRM_TRST_INACT (cable))
| PRM_UNUSED_BITS (cable))
!= URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PRM_TRST_LVL (cable) = PRM_TRST_ACT (cable) | PRM_TRST_INACT (cable);
}
else
@ -281,7 +283,7 @@ wiggler_init (urj_cable_t *cable)
PRM_SIGNALS (cable) =
(PRM_TRST_LVL (cable) == PRM_TRST_ACT (cable)) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void
@ -294,25 +296,23 @@ wiggler_clock (urj_cable_t *cable, int tms, int tdi, int n)
for (i = 0; i < n; i++)
{
urj_tap_parport_set_data (cable->link.port, PRM_TRST_LVL (cable) |
PRM_TCK_INACT (cable) |
(tms ? PRM_TMS_ACT (cable) :
PRM_TMS_INACT (cable)) | (tdi ?
PRM_TDI_ACT
(cable) :
PRM_TDI_INACT
(cable)) |
PRM_UNUSED_BITS (cable));
urj_tap_parport_set_data (cable->link.port,
PRM_TRST_LVL (cable)
| PRM_TCK_INACT (cable)
| (tms ? PRM_TMS_ACT (cable)
: PRM_TMS_INACT (cable))
| (tdi ? PRM_TDI_ACT (cable)
: PRM_TDI_INACT (cable))
| PRM_UNUSED_BITS (cable));
urj_tap_cable_wait (cable);
urj_tap_parport_set_data (cable->link.port, PRM_TRST_LVL (cable) |
PRM_TCK_ACT (cable) |
(tms ? PRM_TMS_ACT (cable) :
PRM_TMS_INACT (cable)) | (tdi ?
PRM_TDI_ACT
(cable) :
PRM_TDI_INACT
(cable)) |
PRM_UNUSED_BITS (cable));
urj_tap_parport_set_data (cable->link.port,
PRM_TRST_LVL (cable)
| PRM_TCK_ACT (cable)
| (tms ? PRM_TMS_ACT (cable)
: PRM_TMS_INACT (cable))
| (tdi ? PRM_TDI_ACT (cable)
: PRM_TDI_INACT (cable))
| PRM_UNUSED_BITS (cable));
urj_tap_cable_wait (cable);
}
@ -373,32 +373,32 @@ wiggler_get_signal (urj_cable_t *cable, urj_pod_sigsel_t sig)
}
static void
wiggler_help (const char *cablename)
wiggler_help (urj_log_level_t ll, const char *cablename)
{
printf (_
("Usage: cable %s parallel PORTADDR [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
urj_log (ll,
_("Usage: cable %s parallel PORTADDR [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
#if ENABLE_LOWLEVEL_PPDEV
" or: cable %s ppdev PPDEV [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
" or: cable %s ppdev PPDEV [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
#endif
#if HAVE_DEV_PPBUS_PPI_H
" or: cable %s ppi PPIDEV [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
" or: cable %s ppi PPIDEV [TDO,TRST,TDI,TCK,TMS,SRESET]\n"
#endif
"\n" "PORTADDR parallel port address (e.g. 0x378)\n"
"\n" "PORTADDR parallel port address (e.g. 0x378)\n"
#if ENABLE_LOWLEVEL_PPDEV
"PPDEV ppdev device (e.g. /dev/parport0)\n"
"PPDEV ppdev device (e.g. /dev/parport0)\n"
#endif
#if HAVE_DEV_PPBUS_PPI_H
"PPIDEF ppi device (e.g. /dev/ppi0)\n"
"PPIDEF ppi device (e.g. /dev/ppi0)\n"
#endif
"TDO, ... parallel port bit number, prepend '#' for inversion\n"
" default is '%s'\n" "\n"),
"TDO, ... parallel port bit number, prepend '#' for inversion\n"
" default is '%s'\n" "\n"),
#if ENABLE_LOWLEVEL_PPDEV
cablename,
cablename,
#endif
#if HAVE_DEV_PPBUS_PPI_H
cablename,
cablename,
#endif
cablename, std_wgl_map);
cablename, std_wgl_map);
}
urj_cable_driver_t urj_tap_cable_wiggler_driver = {

@ -71,22 +71,23 @@ wiggler2_init (urj_cable_t *cable)
int data;
if (urj_tap_parport_open (cable->link.port))
return -1;
return URJ_STATUS_FAIL;
// TODO: CPU_RESET bit is set to zero here and can't be changed afterwards
// If CPU_RESET=0 doesn't harm, it means it is an active high signal? - kawk
if ((data = urj_tap_parport_get_data (cable->link.port)) < 0)
{
if (urj_tap_parport_set_data
(cable->link.port, (1 << TRST) | UNUSED_BITS))
return -1;
if (urj_tap_parport_set_data (cable->link.port,
(1 << TRST) | UNUSED_BITS)
!= URJ_STATUS_OK)
return URJ_STATUS_FAIL;
PARAM_SIGNALS (cable) = URJ_POD_CS_TRST;
}
else
PARAM_SIGNALS (cable) = ((data >> TRST) && 1) ? URJ_POD_CS_TRST : 0;
return 0;
return URJ_STATUS_OK;
}
static void

@ -83,11 +83,11 @@ xpcu_output_enable (struct usb_dev_handle *xpcu, int enable)
if (usb_control_msg
(xpcu, 0x40, 0xB0, enable ? 0x18 : 0x10, 0, NULL, 0, 1000) < 0)
{
perror ("usb_control_msg(0x10/0x18)");
return -1;
urj_error_IO_set ("usb_control_msg(0x10/0x18)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -100,11 +100,11 @@ xpcu_bit_reverse (struct usb_dev_handle *xpcu, uint8_t bits_in,
if (usb_control_msg
(xpcu, 0xC0, 0xB0, 0x0020, bits_in, (char *) bits_out, 1, 1000) < 0)
{
perror ("usb_control_msg(0x20.x) (bit reverse)");
return -1;
urj_error_IO_set ("usb_control_msg(0x20.x) (bit reverse)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
#endif
@ -117,11 +117,11 @@ xpcu_request_28 (struct usb_dev_handle *xpcu, int value)
if (usb_control_msg (xpcu, 0x40, 0xB0, 0x0028, value, NULL, 0, 1000) < 0)
{
perror ("usb_control_msg(0x28.x)");
return -1;
urj_error_IO_set ("usb_control_msg(0x28.x)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -131,11 +131,11 @@ xpcu_write_gpio (struct usb_dev_handle *xpcu, uint8_t bits)
{
if (usb_control_msg (xpcu, 0x40, 0xB0, 0x0030, bits, NULL, 0, 1000) < 0)
{
perror ("usb_control_msg(0x30.0x00) (write port E)");
return -1;
urj_error_IO_set ("usb_control_msg(0x30.0x00) (write port E)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -146,11 +146,11 @@ xpcu_read_gpio (struct usb_dev_handle *xpcu, uint8_t *bits)
if (usb_control_msg (xpcu, 0xC0, 0xB0, 0x0038, 0, (char *) bits, 1, 1000)
< 0)
{
perror ("usb_control_msg(0x38.0x00) (read port E)");
return -1;
urj_error_IO_set ("usb_control_msg(0x38.0x00) (read port E)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -162,10 +162,10 @@ xpcu_read_cpld_version (struct usb_dev_handle *xpcu, uint16_t *buf)
if (usb_control_msg
(xpcu, 0xC0, 0xB0, 0x0050, 0x0001, (char *) buf, 2, 1000) < 0)
{
perror ("usb_control_msg(0x50.1) (read_cpld_version)");
return -1;
urj_error_IO_set ("usb_control_msg(0x50.1) (read_cpld_version)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -176,11 +176,11 @@ xpcu_read_firmware_version (struct usb_dev_handle *xpcu, uint16_t *buf)
if (usb_control_msg
(xpcu, 0xC0, 0xB0, 0x0050, 0x0000, (char *) buf, 2, 1000) < 0)
{
perror ("usb_control_msg(0x50.0) (read_firmware_version)");
return -1;
urj_error_IO_set ("usb_control_msg(0x50.0) (read_firmware_version)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ----------------------------------------------------------------- */
@ -191,11 +191,11 @@ xpcu_select_gpio (struct usb_dev_handle *xpcu, int int_or_ext)
if (usb_control_msg (xpcu, 0x40, 0xB0, 0x0052, int_or_ext, NULL, 0, 1000)
< 0)
{
perror ("usb_control_msg(0x52.x) (select gpio)");
return -1;
urj_error_IO_set ("usb_control_msg(0x52.x) (select gpio)");
return URJ_STATUS_FAIL;
}
return 0;
return URJ_STATUS_OK;
}
/* ---------------------------------------------------------------------- */
@ -241,35 +241,36 @@ xpcu_select_gpio (struct usb_dev_handle *xpcu, int int_or_ext)
* and if there's only one TDO bit, it arrives as the MSB of the word.
*/
/** @return 0 on success; -1 on error */
static int
xpcu_shift (struct usb_dev_handle *xpcu, int reqno, int bits, int in_len,
uint8_t *in, int out_len, uint8_t *out)
{
if (usb_control_msg (xpcu, 0x40, 0xB0, reqno, bits, NULL, 0, 1000) < 0)
{
perror ("usb_control_msg(x.x) (shift)");
urj_error_IO_set ("usb_control_msg(x.x) (shift)");
return -1;
}
#if VERBOSE
{
int i;
printf ("###\n");
printf ("reqno = %02X\n", reqno);
printf ("bits = %d\n", bits);
printf ("in_len = %d, in_len*2 = %d\n", in_len, in_len * 2);
printf ("out_len = %d, out_len*8 = %d\n", out_len, out_len * 8);
urj_log (URJ_LOG_LEVEL_DETAIL, "###\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "reqno = %02X\n", reqno);
urj_log (URJ_LOG_LEVEL_DETAIL, "bits = %d\n", bits);
urj_log (URJ_LOG_LEVEL_DETAIL, "in_len = %d, in_len*2 = %d\n", in_len, in_len * 2);
urj_log (URJ_LOG_LEVEL_DETAIL, "out_len = %d, out_len*8 = %d\n", out_len, out_len * 8);
printf ("a6_display(\"%02X\", \"", bits);
urj_log (URJ_LOG_LEVEL_DETAIL, "a6_display(\"%02X\", \"", bits);
for (i = 0; i < in_len; i++)
printf ("%02X%s", in[i], (i + 1 < in_len) ? "," : "");
printf ("\", ");
urj_log (URJ_LOG_LEVEL_DETAIL, "%02X%s", in[i], (i + 1 < in_len) ? "," : "");
urj_log (URJ_LOG_LEVEL_DETAIL, "\", ");
}
#endif
if (usb_bulk_write (xpcu, 0x02, (char *) in, in_len, 1000) < 0)
{
printf ("\nusb_bulk_write error(shift): %s\n", strerror (errno));
urj_error_IO_set ("usb_bulk_write error(shift)");
return -1;
}
@ -277,7 +278,7 @@ xpcu_shift (struct usb_dev_handle *xpcu, int reqno, int bits, int in_len,
{
if (usb_bulk_read (xpcu, 0x86, (char *) out, out_len, 1000) < 0)
{
printf ("\nusb_bulk_read error(shift): %s\n", strerror (errno));
urj_error_IO_set ("usb_bulk_read error(shift)");
return -1;
}
}
@ -285,10 +286,10 @@ xpcu_shift (struct usb_dev_handle *xpcu, int reqno, int bits, int in_len,
#if VERBOSE
{
int i;
printf ("\"");
urj_log (URJ_LOG_LEVEL_DETAIL, "\"");
for (i = 0; i < out_len; i++)
printf ("%02X%s", out[i], (i + 1 < out_len) ? "," : "");
printf ("\")\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "%02X%s", out[i], (i + 1 < out_len) ? "," : "");
urj_log (URJ_LOG_LEVEL_DETAIL, "\")\n");
}
#endif
@ -305,39 +306,41 @@ xpcu_common_init (urj_cable_t *cable)
struct usb_dev_handle *xpcu;
if (urj_tap_usbconn_open (cable->link.usb))
return -1;
return URJ_STATUS_FAIL;
xpcu = ((urj_usbconn_libusb_param_t *) (cable->link.usb->params))->handle;
r = xpcu_request_28 (xpcu, 0x11);
if (r >= 0)
if (r != URJ_STATUS_FAIL)
r = xpcu_write_gpio (xpcu, 8);
/* Read firmware version (constant embedded in firmware) */
if (r >= 0)
if (r != URJ_STATUS_FAIL)
r = xpcu_read_firmware_version (xpcu, &buf);
if (r >= 0)
if (r != URJ_STATUS_FAIL)
{
printf ("firmware version = 0x%04X (%u)\n", buf, buf);
urj_log (URJ_LOG_LEVEL_NORMAL,
"firmware version = 0x%04X (%u)\n", buf, buf);
}
/* Read CPLD version (via GPIF) */
if (r >= 0)
xpcu_read_cpld_version (xpcu, &buf);
if (r >= 0)
if (r != URJ_STATUS_FAIL)
// @@@@ RFHH added assignment of result to r:
r = xpcu_read_cpld_version (xpcu, &buf);
if (r != URJ_STATUS_FAIL)
{
printf ("cable CPLD version = 0x%04X (%u)\n", buf, buf);
urj_log (URJ_LOG_LEVEL_NORMAL, "cable CPLD version = 0x%04X (%u)\n",
buf, buf);
if (buf == 0)
{
printf
("Warning: version '0' can't be correct. Please try resetting the cable\n");
r = -1;
urj_warning ("version '0' can't be correct. Please try resetting the cable\n");
r = URJ_STATUS_FAIL;
}
}
if (r < 0)
if (r != URJ_STATUS_OK)
{
usb_close (xpcu);
}
@ -350,14 +353,14 @@ xpc_int_init (urj_cable_t *cable)
{
struct usb_dev_handle *xpcu;
if (xpcu_common_init (cable) < 0)
return -1;
if (xpcu_common_init (cable) == URJ_STATUS_FAIL)
return URJ_STATUS_FAIL;
xpcu = ((urj_usbconn_libusb_param_t *) (cable->link.usb->params))->handle;
if (xpcu_select_gpio (xpcu, 0) < 0)
return -1;
if (xpcu_select_gpio (xpcu, 0) == URJ_STATUS_FAIL)
return URJ_STATUS_FAIL;
return 0;
return URJ_STATUS_OK;
}
static int
@ -372,25 +375,30 @@ xpc_ext_init (urj_cable_t *cable)
r = xpcu_common_init (cable);
if (r < 0)
if (r == URJ_STATUS_FAIL)
return r;
cable->params = malloc (sizeof (xpc_cable_params_t));
if (cable->params == NULL)
r = -1;
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
sizeof (xpc_cable_params_t));
r = URJ_STATUS_FAIL;
}
xpcu = ((urj_usbconn_libusb_param_t *) (cable->link.usb->params))->handle;
if (r >= 0)
if (r == URJ_STATUS_OK)
r = xpcu_request_28 (xpcu, 0x11);
if (r >= 0)
if (r == URJ_STATUS_OK)
r = xpcu_output_enable (xpcu, 1);
if (r >= 0)
r = xpcu_shift (xpcu, 0xA6, 2, 2, zero, 0, NULL);
if (r >= 0)
if (r == URJ_STATUS_OK)
r = xpcu_shift (xpcu, 0xA6, 2, 2, zero, 0, NULL) == -1
? URJ_STATUS_FAIL : URJ_STATUS_OK;
if (r == URJ_STATUS_OK)
r = xpcu_request_28 (xpcu, 0x12);
if (r < 0)
if (r != URJ_STATUS_OK)
{
usb_close (xpcu);
@ -443,7 +451,8 @@ xpc_clock (urj_cable_t *cable, int tms, int tdi, int n)
tms = tms ? (1 << TMS) : 0;
tdi = tdi ? (1 << TDI) : 0;
if (xpcu_write_gpio (xpcu, (1 << PROG) | (0 << TCK) | tms | tdi) >= 0)
if (xpcu_write_gpio (xpcu, (1 << PROG) | (0 << TCK) | tms | tdi)
!= URJ_STATUS_FAIL)
{
urj_tap_cable_wait (cable);
for (i = 0; i < n; i++)
@ -527,6 +536,7 @@ xpc_ext_transfer_state_t;
/* ---------------------------------------------------------------------- */
/** @return 0 on success; -1 on error */
static int
xpcu_do_ext_transfer (xpc_ext_transfer_state_t *xts)
{
@ -553,7 +563,7 @@ xpcu_do_ext_transfer (xpc_ext_transfer_state_t *xts)
NULL);
}
if (r >= 0 && xts->out_bits > 0)
if (r != -1 && xts->out_bits > 0)
{
int out_idx = 0;
int out_rem = xts->out_bits;
@ -625,20 +635,25 @@ xpcu_add_bit_for_ext_transfer (xpc_ext_transfer_state_t *xts, char in,
/* ---------------------------------------------------------------------- */
// @@@@ RFHH the specx say that it should be
// @return: num clocks on success, -1 on error.
// Might have to be: return i;
/** @return 0 on success; -1 on error */
static int
xpc_ext_transfer (urj_cable_t *cable, int len, char *in, char *out)
xpc_ext_transfer (urj_cable_t *cable, int len, const char *in, char *out)
{
int i, j;
xpc_ext_transfer_state_t xts;
#if VERBOSE
printf ("---\n");
printf ("transfer size %d, %s output\n", len,
urj_log (URJ_LOG_LEVEL_DETAIL, "---\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "transfer size %d, %s output\n", len,
(out != NULL) ? "with" : "without");
printf ("tdi: ");
urj_log (URJ_LOG_LEVEL_DETAIL, "tdi: ");
for (i = 0; i < len; i++)
printf ("%c", in[i] ? '1' : '0');
printf ("\n");
urj_log (URJ_LOG_LEVEL_DETAIL, "%c", in[i] ? '1' : '0');
urj_log (URJ_LOG_LEVEL_DETAIL, "\n");
#endif
xts.xpcu =

@ -253,7 +253,7 @@ urj_tap_chain_shift_data_registers_mode (urj_chain_t *chain,
if (ps->parts[i]->active_instruction->data_register == NULL)
{
urj_error_set (URJ_ERROR_NO_DATA_REGISTER,
_("Part %d without data register\n"), i);
_("Part %d without data register"), i);
return URJ_STATUS_FAIL;
}
}

@ -519,7 +519,6 @@ urj_tap_detect (urj_chain_t *chain)
return URJ_STATUS_FAIL;
}
/* @@@@ RFHH check results? */
urj_part_parts_set_instruction (chain->parts, "SAMPLE/PRELOAD");
urj_tap_chain_shift_instructions (chain);
urj_tap_chain_shift_data_registers (chain, 1);

@ -179,7 +179,6 @@ urj_tap_discovery (urj_chain_t *chain)
fflush (stdout);
urj_tap_capture_dr (chain);
// @@@@ RFHH check result
rs = urj_tap_detect_register_size (chain);
urj_log (URJ_LOG_LEVEL_NORMAL, _("%d\n"), rs);

@ -154,7 +154,7 @@ direct_parport_alloc (unsigned int port)
if (inpout32_dll_handle == NULL)
{
urj_error_set (URJ_ERROR_IO,
_("Couldn't load InpOut32.dll; maybe not installed?\n"));
_("Couldn't load InpOut32.dll; maybe not installed?"));
urj_error.sys_errno = GetLastError();
return NULL;
}

@ -218,7 +218,7 @@ ppdev_get_data (urj_parport_t *parport)
if (ioctl (p->fd, PPRDATA, &d) == -1)
{
urj_error_IO_set ("ioctl(PPRSTATUS) fails");
urj_error_IO_set ("ioctl(PPRDATA) fails");
return -1;
}
@ -249,7 +249,7 @@ ppdev_set_control (urj_parport_t *parport, uint8_t data)
if (ioctl (p->fd, PPWCONTROL, &data) == -1)
{
urj_error_IO_set ("ioctl(PPWDATA) fails");
urj_error_IO_set ("ioctl(PPWCONTROL) fails");
return URJ_STATUS_FAIL;
}

@ -232,8 +232,7 @@ ppi_set_control (urj_parport_t *parport, uint8_t data)
if (ioctl (p->fd, PPIGCTRL, &data) == -1)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
sizeof (urj_chain_t));
urj_error_IO_set ("ioctl(PPIGCTRL) fails");
return URJ_STATUS_FAIL;
}

@ -61,7 +61,6 @@ urj_tap_reset_bypass (urj_chain_t *chain)
urj_tap_shift_register (chain, ir, NULL, URJ_CHAIN_EXITMODE_IDLE);
urj_tap_register_free (ir);
/* @@@@ RFHH check result */
urj_part_parts_set_instruction (chain->parts, "BYPASS");
}

@ -340,6 +340,7 @@ usbconn_ftd2xx_connect (const char **param, int paramc,
p->fc = NULL;
p->pid = template->pid;
p->vid = template->vid;
/* @@@@ RFHH check strdup result */
p->serial = template->desc ? strdup (template->desc) : NULL;
c->params = p;

@ -285,6 +285,7 @@ usbconn_ftdi_connect (const char **param, int paramc,
p->fc = fc;
p->pid = template->pid;
p->vid = template->vid;
/* @@@@ RFHH check strdup result */
p->serial = template->desc ? strdup (template->desc) : NULL;
c->params = p;
@ -440,8 +441,7 @@ usbconn_ftdi_open (urj_usbconn_t *conn)
if (r >= 0)
if ((r = ftdi_set_latency_timer (fc, 2)) < 0)
urj_error_set (URJ_ERROR_FTD,
_("ftdi_set_latency_timer() failed: %s"),
urj_error_set (URJ_ERROR_FTD, _("ftdi_set_latency_timer() failed: %s"),
ftdi_get_error_string (fc));
#if 0
@ -498,21 +498,21 @@ usbconn_ftdi_mpsse_open (urj_usbconn_t *conn)
ftdi_write_data_set_chunksize (fc,
URJ_USBCONN_FTDX_MAXSEND_MPSSE)) <
0)
puts (ftdi_get_error_string (fc));
urj_log (URJ_LOG_LEVEL_NORMAL, "%s", ftdi_get_error_string (fc));
if (r >= 0)
if ((r =
ftdi_read_data_set_chunksize (fc,
URJ_USBCONN_FTDX_MAXSEND_MPSSE)) <
0)
puts (ftdi_get_error_string (fc));
urj_log (URJ_LOG_LEVEL_NORMAL, "%s", ftdi_get_error_string (fc));
#ifdef LIBFTDI_UNIMPLEMENTED
if (r >= 0)
if ((r = ftdi_set_event_char (fc, 0, 0)) < 0)
puts (ftdi_get_error_string (fc));
urj_log (URJ_LOG_LEVEL_NORMAL, "%s", ftdi_get_error_string (fc));
if (r >= 0)
if ((r = ftdi_set_error_char (fc, 0, 0)) < 0)
puts (ftdi_get_error_string (fc));
urj_log (URJ_LOG_LEVEL_NORMAL, "%s", ftdi_get_error_string (fc));
#endif
/* set a reasonable latency timer value

Loading…
Cancel
Save