diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 17694526..001b017c 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,9 @@ +2009-05-23 Arnim Laeuger + + * src/bsdl2jtag, configure.ac, Makefile.am, + src/apps/bsdl2jtag/Makefile.am, src/apps/bsdl2jtag/bsdl2jtag.c: + replace wrapper shell script with application that links to liburjtag + 2009-05-22 Arnim Laeuger * src/bsdl/bsdl_sem.c: replace remaining printf invocations with urj_log diff --git a/urjtag/Makefile.am b/urjtag/Makefile.am index 2fc1d870..6b15964b 100644 --- a/urjtag/Makefile.am +++ b/urjtag/Makefile.am @@ -29,6 +29,7 @@ SUBDIRS = \ data \ src \ src/apps/jtag \ + src/apps/bsdl2jtag \ po DIST_SUBDIRS = \ @@ -40,4 +41,3 @@ EXTRA_DIST = \ tools/config.rpath ACLOCAL_AMFLAGS = -I m4 - diff --git a/urjtag/configure.ac b/urjtag/configure.ac index f20bfdfa..bcba770e 100644 --- a/urjtag/configure.ac +++ b/urjtag/configure.ac @@ -73,6 +73,7 @@ AC_CONFIG_FILES( src/jim/Makefile src/global/Makefile src/apps/jtag/Makefile + src/apps/bsdl2jtag/Makefile po/Makefile.in ) diff --git a/urjtag/src/bsdl2jtag b/urjtag/src/apps/bsdl2jtag/Makefile.am old mode 100755 new mode 100644 similarity index 61% rename from urjtag/src/bsdl2jtag rename to urjtag/src/apps/bsdl2jtag/Makefile.am index f7ebaab9..c2c2b300 --- a/urjtag/src/bsdl2jtag +++ b/urjtag/src/apps/bsdl2jtag/Makefile.am @@ -1,10 +1,7 @@ -#!/bin/bash # # $Id$ # -# Convert a BSDL file to a jtag part description -# -# Copyright (C) 2009, A. Laeuger +# Copyright (C) 2002 ETC s.r.o. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,27 +19,19 @@ # 02111-1307, USA. # -scriptname=`basename $0` - -function usage () -{ - cat < -Converts a BSDL file to a jtag part description. - -Parameters - bsdl-file : Name of BSDL file - jtag-file : Name of converted jtag description file +include $(top_srcdir)/Makefile.rules -EOF -} +bin_PROGRAMS = \ + bsdl2jtag -if [[ -z $1 || -z $2 ]]; then - usage - exit 1 -fi +bsdl2jtag_SOURCES = \ + bsdl2jtag.c +bsdl2jtag_LDADD = \ + $(top_srcdir)/src/liburjtag.la \ + @LIBINTL@ -echo "bsdl dump $1" | jtag > $2 +localedir = $(datadir)/locale +INCLUDES = -DLOCALEDIR=\"$(localedir)\" -exit 0 +AM_CFLAGS = $(WARNINGCFLAGS) diff --git a/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c b/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c new file mode 100644 index 00000000..c6468c33 --- /dev/null +++ b/urjtag/src/apps/bsdl2jtag/bsdl2jtag.c @@ -0,0 +1,98 @@ +/* + * $Id$ + * + * Copyright (C) 2009, Arnim Laeuger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Arnim Laeuger , 2009. + * + */ + +#include + +#include +#include + +#include +#include + + +FILE *jtag_file; + +static int +log_to_file (const char *fmt, va_list ap) +{ + return vfprintf (jtag_file, fmt, ap); +} + + +static void +cleanup (urj_chain_t *chain) +{ + urj_tap_chain_free (chain); +} + + +static void +usage (void) +{ + puts ("Usage: bsdl2jtag "); + puts ("Converts a BSDL file to a jtag part description.\n"); + puts ("Parameters"); + puts (" bsdl-file : Name of BSDL file"); + puts (" jtag-file : Name of converted jtag description file"); + puts (""); +} + + +int +main (int argc, char *const argv[]) +{ + int result; + urj_chain_t *chain = NULL; + + chain = urj_tap_chain_alloc (); + if (chain == NULL) + { + urj_log (URJ_LOG_LEVEL_NORMAL, "Error: %s\n", + urj_error_describe()); + return 1; + } + + if (argc != 3) + { + usage (); + cleanup (chain); + return 1; + } + + jtag_file = fopen (argv[2], "w"); + if (jtag_file == NULL) + { + printf ("Error: Can't open '%s' in write mode.\n", argv[2]); + cleanup (chain); + return 1; + } + + /* 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); + + fclose (jtag_file); + cleanup (chain); + return result < 0 ? 1 : 0; +}