From 5ef5c39b9a25cc306f055f2c9ced07166e46cfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Sat, 23 May 2009 18:47:49 +0000 Subject: [PATCH] port BSDL message system to urj_log/urj_err_set functionality git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1623 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 9 +++ urjtag/include/urjtag/error.h | 4 ++ urjtag/src/apps/bsdl2jtag/bsdl2jtag.c | 5 ++ urjtag/src/bsdl/bsdl.c | 92 ++++++--------------------- urjtag/src/bsdl/bsdl_bison.y | 51 +++++++-------- urjtag/src/bsdl/bsdl_flex.l | 24 +++---- urjtag/src/bsdl/bsdl_msg.h | 36 +++++++++-- urjtag/src/bsdl/bsdl_sem.c | 31 ++++----- urjtag/src/bsdl/vhdl_bison.y | 50 +++++++-------- urjtag/src/bsdl/vhdl_flex.l | 30 ++++----- urjtag/src/global/urjtag.c | 4 ++ 11 files changed, 156 insertions(+), 180 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 03441f00..d1d49de5 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,12 @@ +2009-05-23 Arnim Laeuger + + * include/urjtag/error.h, src/global/urjtag.c, + src/apps/bsdl2jtag/bsdl2jtag.c, + src/bsdl/bsdl_msg.h, src/bsdl/bsdl.c, src/bsdl/bsdl_sem.c, + src/bsdl/vhdl_flex.l, src/bsdl/vhdl_bison.y, + src/bsdl/bsdl_flex.l, src/bsdl/bsdl_bison.y: port BSDL message system to + urj_log/urj_err_set functionality + 2009-05-23 Rutger Hofman * configure.ac, Makefile.am: add an option (--disable-apps) to build only diff --git a/urjtag/include/urjtag/error.h b/urjtag/include/urjtag/error.h index 1630383f..cc57eaa5 100644 --- a/urjtag/include/urjtag/error.h +++ b/urjtag/include/urjtag/error.h @@ -37,6 +37,7 @@ typedef enum urj_error URJ_ERROR_ALREADY, URJ_ERROR_OUT_OF_MEMORY, URJ_ERROR_NO_CHAIN, + URJ_ERROR_NO_PART, URJ_ERROR_NO_ACTIVE_INSTRUCTION, URJ_ERROR_NO_DATA_REGISTER, URJ_ERROR_INVALID, @@ -62,6 +63,9 @@ typedef enum urj_error URJ_ERROR_FLASH_ERASE, URJ_ERROR_FLASH_UNLOCK, + URJ_ERROR_BSDL_VHDL, + URJ_ERROR_BSDL_BSDL, + URJ_ERROR_UNIMPLEMENTED, } urj_error_t; diff --git a/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c b/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c index c6468c33..1d52c2c1 100644 --- a/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c +++ b/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c @@ -91,6 +91,11 @@ main (int argc, char *const argv[]) /* log all messages to the jtag_file */ urj_log_state.out_vprintf = log_to_file; result = urj_bsdl_read_file (chain, argv[1], URJ_BSDL_MODE_DUMP, NULL); + if (result < 0) + { + urj_log (URJ_LOG_LEVEL_ERROR, "Error: %s\n", urj_error_describe()); + urj_error_reset (); + } fclose (jtag_file); cleanup (chain); diff --git a/urjtag/src/bsdl/bsdl.c b/urjtag/src/bsdl/bsdl.c index 883e69e5..4aebfd3b 100644 --- a/urjtag/src/bsdl/bsdl.c +++ b/urjtag/src/bsdl/bsdl.c @@ -49,59 +49,6 @@ #endif -/***************************************************************************** - * urj_bsdl_msg( proc_mode, type, format, ... ) - * - * Main printing function for the BSDL subsystem. - * - * Parameters - * proc_mode : processing mode, consisting of BSDL_MODE_* bits - * type : one of the BSDL_MSG_* defines, determines message tag - * format : printf format - * ... : additional parameters to fill the printf format string - * - * Returns - * void - ****************************************************************************/ -void -urj_bsdl_msg (int proc_mode, int type, const char *format, ...) -{ - va_list lst; - - va_start (lst, format); - switch (type) - { - case BSDL_MSG_NOTE: - if (!(proc_mode & URJ_BSDL_MODE_MSG_NOTE)) - return; - printf ("-N- "); - break; - case BSDL_MSG_WARN: - if (!(proc_mode & URJ_BSDL_MODE_MSG_WARN)) - return; - printf ("-W- "); - break; - case BSDL_MSG_ERR: - // @@@@ RFHH set urj_error (but to what?) - if (!(proc_mode & URJ_BSDL_MODE_MSG_ERR)) - return; - printf ("-E- "); - break; - case BSDL_MSG_FATAL: - // @@@@ RFHH set urj_error (but to what?) - if (!(proc_mode & URJ_BSDL_MODE_MSG_FATAL)) - return; - printf ("-F- "); - break; - default: - printf ("-?- "); - break; - } - vprintf (format, lst); - va_end (lst); -} - - /***************************************************************************** * urj_bsdl_read_file( chain, BSDL_File_Name, proc_mode, idcode ) * @@ -130,6 +77,9 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, int Compile_Errors = 1; int result = 0; + /* purge previous errors */ + urj_error_reset (); + if (globs->debug) proc_mode |= URJ_BSDL_MODE_MSG_ALL; @@ -140,14 +90,14 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, { if (chain == NULL) { - urj_bsdl_msg (proc_mode, BSDL_MSG_ERR, - _("No JTAG chain available\n")); + urj_bsdl_err_set (proc_mode, URJ_ERROR_NO_CHAIN, + "Can't execute commands without chain"); return -1; } if (chain->parts == NULL) { - urj_bsdl_msg (proc_mode, BSDL_MSG_ERR, - _("Chain without any parts\n")); + urj_bsdl_err_set (proc_mode, URJ_ERROR_NO_PART, + "Can't execute commands without part"); return -1; } if (!(chain && chain->parts)) @@ -164,14 +114,13 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, BSDL_File = fopen (BSDL_File_Name, "r"); - urj_bsdl_msg (proc_mode, BSDL_MSG_NOTE, _("Reading file '%s'\n"), - BSDL_File_Name); + urj_bsdl_msg (proc_mode, _("Reading file '%s'\n"), BSDL_File_Name); if (BSDL_File == NULL) { - urj_bsdl_msg (proc_mode, - BSDL_MSG_ERR, _("Unable to open BSDL file '%s'\n"), - BSDL_File_Name); + urj_bsdl_err_set (proc_mode, URJ_ERROR_IO, + "Unable to open BSDL file '%s'", + BSDL_File_Name); return -1; } @@ -186,7 +135,6 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, if (Compile_Errors == 0) { urj_bsdl_msg (proc_mode, - BSDL_MSG_NOTE, _("BSDL file '%s' passed VHDL stage correctly\n"), BSDL_File_Name); @@ -194,18 +142,14 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, if (result >= 0) urj_bsdl_msg (proc_mode, - BSDL_MSG_NOTE, - _ - ("BSDL file '%s' passed BSDL stage correctly\n"), + _("BSDL file '%s' passed BSDL stage correctly\n"), BSDL_File_Name); } else { - urj_bsdl_msg (proc_mode, - BSDL_MSG_ERR, - _ - ("BSDL file '%s' contains errors in VHDL stage, stopping\n"), + urj_bsdl_err (proc_mode, + _("BSDL file '%s' contains errors in VHDL stage, stopping\n"), BSDL_File_Name); } @@ -280,7 +224,7 @@ urj_bsdl_set_path (urj_chain_t *chain, const char *pathlist) if (globs->debug) for (num = 0; globs->path_list[num] != NULL; num++) urj_bsdl_msg (URJ_BSDL_MODE_MSG_ALL, - BSDL_MSG_NOTE, "%s\n", globs->path_list[num]); + "%s\n", globs->path_list[num]); } @@ -357,9 +301,9 @@ urj_bsdl_scan_files (urj_chain_t *chain, const char *idcode, int proc_mode) closedir (dir); } else - urj_bsdl_msg (proc_mode, - BSDL_MSG_WARN, _("Cannot open directory %s\n"), - globs->path_list[idx]); + urj_bsdl_warn (proc_mode, + _("Cannot open directory %s\n"), + globs->path_list[idx]); idx++; } diff --git a/urjtag/src/bsdl/bsdl_bison.y b/urjtag/src/bsdl/bsdl_bison.y index 453abe9b..fec62bd5 100644 --- a/urjtag/src/bsdl/bsdl_bison.y +++ b/urjtag/src/bsdl/bsdl_bison.y @@ -886,18 +886,22 @@ Exit_Instruction_List : IDENTIFIER static void Print_Error (urj_bsdl_parser_priv_t *priv_data, const char *Errmess) { - urj_bsdl_msg (priv_data->jtag_ctrl->proc_mode, - BSDL_MSG_ERR, _("Line %d, %s.\n"), - priv_data->lineno, Errmess); + urj_bsdl_err (priv_data->jtag_ctrl->proc_mode, + _("Line %d, %s.\n"), priv_data->lineno, Errmess); + + /* set an error if nothing else is pending */ + if (urj_error_get () == URJ_ERROR_OK) + urj_bsdl_err_set (priv_data->jtag_ctrl->proc_mode, + URJ_ERROR_BSDL_BSDL, + "Parser error, see log for details"); } /*----------------------------------------------------------------------*/ static void Print_Warning (urj_bsdl_parser_priv_t *priv_data, const char *Warnmess) { - urj_bsdl_msg (priv_data->jtag_ctrl->proc_mode, - BSDL_MSG_WARN, _("Line %d, %s.\n"), - priv_data->lineno, Warnmess); + urj_bsdl_warn (priv_data->jtag_ctrl->proc_mode, + _("Line %d, %s.\n"), priv_data->lineno, Warnmess); } /*----------------------------------------------------------------------*/ @@ -1137,9 +1141,8 @@ urj_bsdl_parser_init (urj_bsdl_jtag_ctrl_t *jtag_ctrl) 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"), - __FILE__, __LINE__); + urj_bsdl_err_set (jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); return NULL; } @@ -1209,9 +1212,8 @@ add_instruction (urj_bsdl_parser_priv_t *priv, char *instr, char *opcode) priv->jtag_ctrl->instr_list = new_instr; } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } @@ -1271,9 +1273,8 @@ ac_add_instruction (urj_bsdl_parser_priv_t *priv, char *instr) tmp_ai->instr_list = new_instr; } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } @@ -1308,9 +1309,8 @@ ac_apply_assoc (urj_bsdl_parser_priv_t *priv) jc->ainfo_list = new_ai; } else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (jc->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); /* clean up obsolete temporary entries */ tmp_ai->reg = NULL; @@ -1348,9 +1348,8 @@ prt_add_name (urj_bsdl_parser_priv_t *priv, char *name) pd->names_list = new_string; } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } @@ -1505,9 +1504,8 @@ ci_set_cell_spec (urj_bsdl_parser_priv_t *priv, } else { - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); ci->port_name = NULL; } @@ -1557,9 +1555,8 @@ ci_append_cell_info (urj_bsdl_parser_priv_t *priv, int bit_num) tmp_ci->basic_safe_value = NULL; } else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (jc->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } diff --git a/urjtag/src/bsdl/bsdl_flex.l b/urjtag/src/bsdl/bsdl_flex.l index 5a568771..eb153e24 100644 --- a/urjtag/src/bsdl/bsdl_flex.l +++ b/urjtag/src/bsdl/bsdl_flex.l @@ -400,11 +400,10 @@ ISC_Illegal_Exit ISC_ILLEGAL_EXIT return( DECIMAL_NUMBER );} {Real_Number} {yylval->str = new_string( yyextra, yytext ); return( REAL_NUMBER );} -{Illegal} {urj_bsdl_msg( yyextra->proc_mode, - BSDL_MSG_ERR, - _("Illegal character %c (/%03o) at line %d:\n"), - (char)yytext[yyleng-1], (int)yytext[yyleng-1], - yylineno ); +{Illegal} {urj_bsdl_err_set( yyextra->proc_mode, URJ_ERROR_BSDL_BSDL, + "Illegal character %c (/%03o) at line %d:", + (char)yytext[yyleng-1], (int)yytext[yyleng-1], + yylineno ); yyextra->Compile_Errors++; return( ILLEGAL ); /* Will cause syntax error */} <> { @@ -435,17 +434,15 @@ urj_bsdl_flex_init (int proc_mode) /* get our scanner structure */ if (yylex_init (&scanner) != 0) { - urj_bsdl_msg (proc_mode, - BSDL_MSG_FATAL, - _("Scanner could not be initialized\n")); + urj_bsdl_err_set (proc_mode, URJ_ERROR_BSDL_BSDL, + "Scanner could not be initialized"); return NULL; } if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t)))) { - urj_bsdl_msg (proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); yylex_destroy (scanner); return NULL; } @@ -534,9 +531,8 @@ new_string (urj_bsdl_scan_extra_t *extra, const char *str) n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */ } else - urj_bsdl_msg (extra->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (extra->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); return (n_str); } diff --git a/urjtag/src/bsdl/bsdl_msg.h b/urjtag/src/bsdl/bsdl_msg.h index 3927ca9e..48c95bae 100644 --- a/urjtag/src/bsdl/bsdl_msg.h +++ b/urjtag/src/bsdl/bsdl_msg.h @@ -25,14 +25,38 @@ #ifndef URJ_BSDL_MSG_H #define URJ_BSDL_MSG_H +#include +#include + +#include + #include "bsdl_types.h" -/* message types for urj_bsdl_msg() */ -#define BSDL_MSG_NOTE 0 -#define BSDL_MSG_WARN 1 -#define BSDL_MSG_ERR 2 -#define BSDL_MSG_FATAL 3 +#define urj_bsdl_msg(proc_mode, ...) \ + do { \ + if (proc_mode & URJ_BSDL_MODE_MSG_NOTE) { \ + urj_log (URJ_LOG_LEVEL_NORMAL, "-N- "); \ + urj_log (URJ_LOG_LEVEL_NORMAL, __VA_ARGS__);} \ + } while (0) + +#define urj_bsdl_warn(proc_mode, ...) \ + do { \ + if (proc_mode & URJ_BSDL_MODE_MSG_WARN) { \ + urj_log (URJ_LOG_LEVEL_WARNING, "-W- "); \ + urj_log (URJ_LOG_LEVEL_WARNING, __VA_ARGS__);} \ + } while (0) + +#define urj_bsdl_err(proc_mode, ...) \ + do { \ + if (proc_mode & URJ_BSDL_MODE_MSG_ERR) { \ + urj_log (URJ_LOG_LEVEL_ERROR, "-E- "); \ + urj_log (URJ_LOG_LEVEL_ERROR, __VA_ARGS__);} \ + } while (0) -void urj_bsdl_msg (int, int, const char *, ...); +#define urj_bsdl_err_set(proc_mode, err, ...) \ + do { \ + if (proc_mode & URJ_BSDL_MODE_MSG_ERR) \ + urj_error_set (err, __VA_ARGS__); \ + } while (0) #endif /* URJ_BSDL_MSG_H */ diff --git a/urjtag/src/bsdl/bsdl_sem.c b/urjtag/src/bsdl/bsdl_sem.c index de684532..29bded1e 100644 --- a/urjtag/src/bsdl/bsdl_sem.c +++ b/urjtag/src/bsdl/bsdl_sem.c @@ -134,10 +134,11 @@ urj_bsdl_emit_ports (urj_bsdl_jtag_ctrl_t *jc) result = URJ_STATUS_OK; } else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_FATAL, - _("Out of memory, %s line %i\n"), __FILE__, - __LINE__); + { + urj_bsdl_err_set (jc->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); + return URJ_STATUS_FAIL; + } name = name->next; } @@ -199,8 +200,8 @@ urj_bsdl_process_idcode (urj_bsdl_jtag_ctrl_t *jc) if (jc->idcode) result = create_register (jc, "DIR", strlen (jc->idcode)); else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_WARN, _("No IDCODE specification found.\n")); + urj_bsdl_warn (jc->proc_mode, + _("No IDCODE specification found.\n")); return result; } @@ -546,9 +547,9 @@ parse_vhdl_elem (urj_bsdl_parser_priv_t *priv, urj_vhdl_elem_t *elem) buf = malloc (buf_len); if (!buf) { - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, + URJ_ERROR_OUT_OF_MEMORY, + "No memory"); return -1; } buf[0] = '\0'; @@ -645,11 +646,9 @@ compare_idcode (urj_bsdl_jtag_ctrl_t *jc, const char *idcode) idcode_match = 0; if (idcode_match) - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_NOTE, _("IDCODE matched\n")); + urj_bsdl_msg (jc->proc_mode, _("IDCODE matched\n")); else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_NOTE, _("IDCODE mismatch\n")); + urj_bsdl_msg (jc->proc_mode, _("IDCODE mismatch\n")); } } @@ -696,8 +695,7 @@ urj_bsdl_process_elements (urj_bsdl_jtag_ctrl_t *jc, const char *idcode) if (!(result & URJ_BSDL_MODE_SYN_CHECK)) { - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_ERR, + urj_bsdl_err (jc->proc_mode, _("BSDL stage reported errors, aborting.\n")); urj_bsdl_parser_deinit (priv); return -1; @@ -705,8 +703,7 @@ urj_bsdl_process_elements (urj_bsdl_jtag_ctrl_t *jc, const char *idcode) } if (jc->idcode) - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_NOTE, _("Got IDCODE: %s\n"), jc->idcode); + urj_bsdl_msg (jc->proc_mode, _("Got IDCODE: %s\n"), jc->idcode); if (jc->proc_mode & URJ_BSDL_MODE_IDCODE_CHECK) result |= compare_idcode (jc, idcode); diff --git a/urjtag/src/bsdl/vhdl_bison.y b/urjtag/src/bsdl/vhdl_bison.y index 4d49ac57..8c763918 100644 --- a/urjtag/src/bsdl/vhdl_bison.y +++ b/urjtag/src/bsdl/vhdl_bison.y @@ -665,14 +665,19 @@ Print_Error (urj_vhdl_parser_priv_t *priv_data, const char *Errmess) urj_bsdl_jtag_ctrl_t *jc = priv_data->jtag_ctrl; if (priv_data->Reading_Package) - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_ERR, _("In Package %s, Line %d, %s.\n"), + urj_bsdl_err (jc->proc_mode, + _("In Package %s, Line %d, %s.\n"), priv_data->Package_File_Name, urj_vhdl_flex_get_lineno (priv_data->scanner), Errmess); else - urj_bsdl_msg (jc->proc_mode, - BSDL_MSG_ERR, _("Line %d, %s.\n"), + urj_bsdl_err (jc->proc_mode, + _("Line %d, %s.\n"), urj_vhdl_flex_get_lineno (priv_data->scanner), Errmess); + + /* set an error if nothing else is pending */ + if (urj_error_get () == URJ_ERROR_OK) + urj_bsdl_err_set (jc->proc_mode, URJ_ERROR_BSDL_VHDL, + "Parser error, see log for details"); } /*----------------------------------------------------------------------*/ @@ -843,9 +848,8 @@ urj_vhdl_parser_init (FILE *f, urj_bsdl_jtag_ctrl_t *jtag_ctrl) if (!(new_priv = malloc (sizeof (urj_vhdl_parser_priv_t)))) { - urj_bsdl_msg (jtag_ctrl->proc_mode, - BSDL_MSG_ERR, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); return NULL; } @@ -949,9 +953,8 @@ urj_vhdl_port_add_name (urj_vhdl_parser_priv_t *priv, char *name) pd->names_list = new_string; } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } @@ -1042,9 +1045,8 @@ urj_vhdl_port_apply_port (urj_vhdl_parser_priv_t *priv) tmp_pd->next = NULL; } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } static void @@ -1078,8 +1080,8 @@ set_attr_bool (urj_vhdl_parser_priv_t *priv, char *name, int value) add_elem (priv, el); } else - urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } #endif @@ -1099,9 +1101,8 @@ set_attr_decimal (urj_vhdl_parser_priv_t *priv, char *name, int value) add_elem (priv, el); } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } static void @@ -1131,9 +1132,8 @@ set_attr_string (urj_vhdl_parser_priv_t *priv, char *name, char *string) add_elem (priv, el); } else - urj_bsdl_msg (priv->jtag_ctrl->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } #if 0 @@ -1151,8 +1151,8 @@ set_attr_real (urj_vhdl_parser_priv_t *priv, char *name, char *string) add_elem (priv, el); } else - urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } #endif @@ -1171,8 +1171,8 @@ set_attr_const (urj_vhdl_parser_priv_t *priv, char *name, char *string) add_elem (priv, el); } else - urj_bsdl_msg (BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (priv->jtag_ctrl->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); } #endif diff --git a/urjtag/src/bsdl/vhdl_flex.l b/urjtag/src/bsdl/vhdl_flex.l index f6910fb8..1368b556 100644 --- a/urjtag/src/bsdl/vhdl_flex.l +++ b/urjtag/src/bsdl/vhdl_flex.l @@ -330,11 +330,10 @@ Std_1532_2002 STD_1532_2002 return (REAL_NUMBER);} {Concatenate} {return (CONCATENATE);} {Semicolon} {return (SEMICOLON);} -{Illegal} {urj_bsdl_msg (yyextra->proc_mode, - BSDL_MSG_ERR, - _("Illegal character %c (/%03o) at line %d:\n"), - (char)yytext[yyleng-1], (int)yytext[yyleng-1], - yylineno); +{Illegal} {urj_bsdl_err_set (yyextra->proc_mode, URJ_ERROR_BSDL_VHDL, + "Illegal character %c (/%03o) at line %d:", + (char)yytext[yyleng-1], (int)yytext[yyleng-1], + yylineno); yyextra->Compile_Errors++; return (ILLEGAL); /* Will cause syntax error */} <> { @@ -366,17 +365,16 @@ urj_vhdl_flex_init (FILE *f, int proc_mode) /* get our scanner structure */ if (yylex_init (&scanner) != 0) { - urj_bsdl_msg (proc_mode, BSDL_MSG_FATAL, - _("Scanner could not be initialized\n")); + urj_bsdl_err_set (proc_mode, URJ_ERROR_BSDL_VHDL, + "Scanner could not be initialized"); return NULL; } yyset_in (f, scanner); if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t)))) { - urj_bsdl_msg (proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); yylex_destroy (scanner); return NULL; } @@ -465,9 +463,8 @@ new_string (urj_bsdl_scan_extra_t *extra, const char *str) n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */ } else - urj_bsdl_msg (extra->proc_mode, - BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), - __FILE__, __LINE__); + urj_bsdl_err_set (extra->proc_mode, URJ_ERROR_OUT_OF_MEMORY, + "No memory"); return n_str; } @@ -524,10 +521,9 @@ urj_vhdl_flex_switch_file (yyscan_t scanner, char *filename) f = fopen (db_file, "r"); if (!f) - urj_bsdl_msg (extra->proc_mode, - BSDL_MSG_FATAL, - _("Cannot open file %s or %s.\n"), filename, - db_file); + urj_bsdl_err_set (extra->proc_mode, URJ_ERROR_IO, + "Cannot open file %s or %s", filename, + db_file); free (db_file); if (!f) return; diff --git a/urjtag/src/global/urjtag.c b/urjtag/src/global/urjtag.c index 3623c53a..ee46c86d 100644 --- a/urjtag/src/global/urjtag.c +++ b/urjtag/src/global/urjtag.c @@ -100,6 +100,7 @@ urj_error_string (urj_error_t err) case URJ_ERROR_ALREADY: return "already defined"; case URJ_ERROR_OUT_OF_MEMORY: return "out of memory"; case URJ_ERROR_NO_CHAIN: return "no chain"; + case URJ_ERROR_NO_PART: return "no part"; case URJ_ERROR_NO_ACTIVE_INSTRUCTION: return "no active instruction"; case URJ_ERROR_NO_DATA_REGISTER: return "no data register"; case URJ_ERROR_INVALID: return "invalid parameter"; @@ -125,6 +126,9 @@ urj_error_string (urj_error_t err) case URJ_ERROR_FLASH_ERASE: return "flash erase"; case URJ_ERROR_FLASH_UNLOCK: return "flash unlock"; + case URJ_ERROR_BSDL_VHDL: return "vhdl subsystem"; + case URJ_ERROR_BSDL_BSDL: return "bsdl subsystem"; + case URJ_ERROR_UNIMPLEMENTED: return "unimplemented"; }