URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/tags/or1ksim/or1ksim-0.4.0rc2/testsuite/test-code/lib-jtag
- from Rev 121 to Rev 128
- ↔ Reverse comparison
Rev 121 → Rev 128
/Makefile.in
0,0 → 1,527
# Makefile.in generated by automake 1.11.1 from Makefile.am. |
# @configure_input@ |
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, |
# Inc. |
# This Makefile.in is free software; the Free Software Foundation |
# gives unlimited permission to copy and/or distribute it, |
# with or without modifications, as long as this notice is preserved. |
|
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
# PARTICULAR PURPOSE. |
|
@SET_MAKE@ |
|
# Makefile.am for libor1ksim test programs for JTAG |
|
# Copyright (C) Embecosm Limited, 2010 |
|
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> |
|
# This file is part of OpenRISC 1000 Architectural Simulator. |
|
# 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 3 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, see <http:#www.gnu.org/licenses/>. */ |
|
# ----------------------------------------------------------------------------- |
# This code is commented throughout for use with Doxygen. |
# ----------------------------------------------------------------------------- |
VPATH = @srcdir@ |
pkgdatadir = $(datadir)/@PACKAGE@ |
pkgincludedir = $(includedir)/@PACKAGE@ |
pkglibdir = $(libdir)/@PACKAGE@ |
pkglibexecdir = $(libexecdir)/@PACKAGE@ |
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
install_sh_DATA = $(install_sh) -c -m 644 |
install_sh_PROGRAM = $(install_sh) -c |
install_sh_SCRIPT = $(install_sh) -c |
INSTALL_HEADER = $(INSTALL_DATA) |
transform = $(program_transform_name) |
NORMAL_INSTALL = : |
PRE_INSTALL = : |
POST_INSTALL = : |
NORMAL_UNINSTALL = : |
PRE_UNINSTALL = : |
POST_UNINSTALL = : |
build_triplet = @build@ |
host_triplet = @host@ |
target_triplet = @target@ |
check_PROGRAMS = lib-jtag$(EXEEXT) lib-jtag-full$(EXEEXT) |
subdir = testsuite/test-code/lib-jtag |
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in |
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ |
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ |
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ |
$(top_srcdir)/configure.ac |
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
$(ACLOCAL_M4) |
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
CONFIG_HEADER = $(top_builddir)/config.h |
CONFIG_CLEAN_FILES = |
CONFIG_CLEAN_VPATH_FILES = |
am_lib_jtag_OBJECTS = lib-jtag.$(OBJEXT) |
lib_jtag_OBJECTS = $(am_lib_jtag_OBJECTS) |
lib_jtag_DEPENDENCIES = $(top_builddir)/libsim.la |
am_lib_jtag_full_OBJECTS = lib-jtag-full.$(OBJEXT) |
lib_jtag_full_OBJECTS = $(am_lib_jtag_full_OBJECTS) |
lib_jtag_full_DEPENDENCIES = $(top_builddir)/libsim.la |
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) |
depcomp = $(SHELL) $(top_srcdir)/depcomp |
am__depfiles_maybe = depfiles |
am__mv = mv -f |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ |
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ |
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
CCLD = $(CC) |
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ |
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ |
$(LDFLAGS) -o $@ |
SOURCES = $(lib_jtag_SOURCES) $(lib_jtag_full_SOURCES) |
DIST_SOURCES = $(lib_jtag_SOURCES) $(lib_jtag_full_SOURCES) |
ETAGS = etags |
CTAGS = ctags |
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
ACLOCAL = @ACLOCAL@ |
AMTAR = @AMTAR@ |
AR = @AR@ |
ARFLAGS = @ARFLAGS@ |
AUTOCONF = @AUTOCONF@ |
AUTOHEADER = @AUTOHEADER@ |
AUTOMAKE = @AUTOMAKE@ |
AWK = @AWK@ |
BUILD_DIR = @BUILD_DIR@ |
CC = @CC@ |
CCAS = @CCAS@ |
CCASDEPMODE = @CCASDEPMODE@ |
CCASFLAGS = @CCASFLAGS@ |
CCDEPMODE = @CCDEPMODE@ |
CFLAGS = @CFLAGS@ |
CPP = @CPP@ |
CPPFLAGS = @CPPFLAGS@ |
CPU_ARCH = @CPU_ARCH@ |
CYGPATH_W = @CYGPATH_W@ |
DEBUGFLAGS = @DEBUGFLAGS@ |
DEFS = @DEFS@ |
DEJAGNU = @DEJAGNU@ |
DEPDIR = @DEPDIR@ |
DSYMUTIL = @DSYMUTIL@ |
DUMPBIN = @DUMPBIN@ |
ECHO_C = @ECHO_C@ |
ECHO_N = @ECHO_N@ |
ECHO_T = @ECHO_T@ |
EGREP = @EGREP@ |
EXEEXT = @EXEEXT@ |
FGREP = @FGREP@ |
GREP = @GREP@ |
INCLUDES = @INCLUDES@ |
INSTALL = @INSTALL@ |
INSTALL_DATA = @INSTALL_DATA@ |
INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
LD = @LD@ |
LDFLAGS = @LDFLAGS@ |
LIBOBJS = @LIBOBJS@ |
LIBS = @LIBS@ |
LIBTOOL = @LIBTOOL@ |
LIPO = @LIPO@ |
LN_S = @LN_S@ |
LOCAL_CFLAGS = @LOCAL_CFLAGS@ |
LOCAL_DEFS = @LOCAL_DEFS@ |
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ |
LTLIBOBJS = @LTLIBOBJS@ |
MAKEINFO = @MAKEINFO@ |
MKDIR_P = @MKDIR_P@ |
NM = @NM@ |
NMEDIT = @NMEDIT@ |
OBJDUMP = @OBJDUMP@ |
OBJEXT = @OBJEXT@ |
OTOOL = @OTOOL@ |
OTOOL64 = @OTOOL64@ |
PACKAGE = @PACKAGE@ |
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |
RANLIB = @RANLIB@ |
RUNTESTDEFAULTFLAGS = @RUNTESTDEFAULTFLAGS@ |
SED = @SED@ |
SET_MAKE = @SET_MAKE@ |
SHELL = @SHELL@ |
STRIP = @STRIP@ |
SUMVERSION = @SUMVERSION@ |
TERMCAP_LIB = @TERMCAP_LIB@ |
VERSION = @VERSION@ |
abs_builddir = @abs_builddir@ |
abs_srcdir = @abs_srcdir@ |
abs_top_builddir = @abs_top_builddir@ |
abs_top_srcdir = @abs_top_srcdir@ |
ac_ct_CC = @ac_ct_CC@ |
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ |
am__include = @am__include@ |
am__leading_dot = @am__leading_dot@ |
am__quote = @am__quote@ |
am__tar = @am__tar@ |
am__untar = @am__untar@ |
bindir = @bindir@ |
build = @build@ |
build_alias = @build_alias@ |
build_cpu = @build_cpu@ |
build_os = @build_os@ |
build_vendor = @build_vendor@ |
builddir = @builddir@ |
datadir = @datadir@ |
datarootdir = @datarootdir@ |
docdir = @docdir@ |
dvidir = @dvidir@ |
exec_prefix = @exec_prefix@ |
host = @host@ |
host_alias = @host_alias@ |
host_cpu = @host_cpu@ |
host_os = @host_os@ |
host_vendor = @host_vendor@ |
htmldir = @htmldir@ |
includedir = @includedir@ |
infodir = @infodir@ |
install_sh = @install_sh@ |
libdir = @libdir@ |
libexecdir = @libexecdir@ |
localedir = @localedir@ |
localstatedir = @localstatedir@ |
lt_ECHO = @lt_ECHO@ |
mandir = @mandir@ |
mkdir_p = @mkdir_p@ |
oldincludedir = @oldincludedir@ |
pdfdir = @pdfdir@ |
prefix = @prefix@ |
program_transform_name = @program_transform_name@ |
psdir = @psdir@ |
sbindir = @sbindir@ |
sharedstatedir = @sharedstatedir@ |
srcdir = @srcdir@ |
subdirs = @subdirs@ |
sysconfdir = @sysconfdir@ |
target = @target@ |
target_alias = @target_alias@ |
target_cpu = @target_cpu@ |
target_os = @target_os@ |
target_vendor = @target_vendor@ |
top_build_prefix = @top_build_prefix@ |
top_builddir = @top_builddir@ |
top_srcdir = @top_srcdir@ |
|
# Simple JTAG handling |
lib_jtag_SOURCES = lib-jtag.c |
lib_jtag_LDADD = $(top_builddir)/libsim.la |
|
# Simple JTAG handling |
lib_jtag_full_SOURCES = lib-jtag-full.c |
lib_jtag_full_LDADD = $(top_builddir)/libsim.la |
all: all-am |
|
.SUFFIXES: |
.SUFFIXES: .c .lo .o .obj |
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) |
@for dep in $?; do \ |
case '$(am__configure_deps)' in \ |
*$$dep*) \ |
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ |
&& { if test -f $@; then exit 0; else break; fi; }; \ |
exit 1;; \ |
esac; \ |
done; \ |
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/test-code/lib-jtag/Makefile'; \ |
$(am__cd) $(top_srcdir) && \ |
$(AUTOMAKE) --gnu testsuite/test-code/lib-jtag/Makefile |
.PRECIOUS: Makefile |
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
@case '$?' in \ |
*config.status*) \ |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ |
*) \ |
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ |
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ |
esac; |
|
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
|
$(top_srcdir)/configure: $(am__configure_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(ACLOCAL_M4): $(am__aclocal_m4_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(am__aclocal_m4_deps): |
|
clean-checkPROGRAMS: |
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ |
echo " rm -f" $$list; \ |
rm -f $$list || exit $$?; \ |
test -n "$(EXEEXT)" || exit 0; \ |
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ |
echo " rm -f" $$list; \ |
rm -f $$list |
lib-jtag$(EXEEXT): $(lib_jtag_OBJECTS) $(lib_jtag_DEPENDENCIES) |
@rm -f lib-jtag$(EXEEXT) |
$(LINK) $(lib_jtag_OBJECTS) $(lib_jtag_LDADD) $(LIBS) |
lib-jtag-full$(EXEEXT): $(lib_jtag_full_OBJECTS) $(lib_jtag_full_DEPENDENCIES) |
@rm -f lib-jtag-full$(EXEEXT) |
$(LINK) $(lib_jtag_full_OBJECTS) $(lib_jtag_full_LDADD) $(LIBS) |
|
mostlyclean-compile: |
-rm -f *.$(OBJEXT) |
|
distclean-compile: |
-rm -f *.tab.c |
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib-jtag-full.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib-jtag.Po@am__quote@ |
|
.c.o: |
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(COMPILE) -c $< |
|
.c.obj: |
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` |
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` |
|
.c.lo: |
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< |
|
mostlyclean-libtool: |
-rm -f *.lo |
|
clean-libtool: |
-rm -rf .libs _libs |
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) |
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ |
unique=`for i in $$list; do \ |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
done | \ |
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \ |
END { if (nonempty) { for (i in files) print i; }; }'`; \ |
mkid -fID $$unique |
tags: TAGS |
|
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ |
$(TAGS_FILES) $(LISP) |
set x; \ |
here=`pwd`; \ |
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ |
unique=`for i in $$list; do \ |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
done | \ |
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \ |
END { if (nonempty) { for (i in files) print i; }; }'`; \ |
shift; \ |
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ |
test -n "$$unique" || unique=$$empty_fix; \ |
if test $$# -gt 0; then \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
"$$@" $$unique; \ |
else \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
$$unique; \ |
fi; \ |
fi |
ctags: CTAGS |
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ |
$(TAGS_FILES) $(LISP) |
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ |
unique=`for i in $$list; do \ |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
done | \ |
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \ |
END { if (nonempty) { for (i in files) print i; }; }'`; \ |
test -z "$(CTAGS_ARGS)$$unique" \ |
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ |
$$unique |
|
GTAGS: |
here=`$(am__cd) $(top_builddir) && pwd` \ |
&& $(am__cd) $(top_srcdir) \ |
&& gtags -i $(GTAGS_ARGS) "$$here" |
|
distclean-tags: |
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags |
|
distdir: $(DISTFILES) |
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
list='$(DISTFILES)'; \ |
dist_files=`for file in $$list; do echo $$file; done | \ |
sed -e "s|^$$srcdirstrip/||;t" \ |
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ |
case $$dist_files in \ |
*/*) $(MKDIR_P) `echo "$$dist_files" | \ |
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ |
sort -u` ;; \ |
esac; \ |
for file in $$dist_files; do \ |
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ |
if test -d $$d/$$file; then \ |
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ |
if test -d "$(distdir)/$$file"; then \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ |
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ |
else \ |
test -f "$(distdir)/$$file" \ |
|| cp -p $$d/$$file "$(distdir)/$$file" \ |
|| exit 1; \ |
fi; \ |
done |
check-am: all-am |
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) |
check: check-am |
all-am: Makefile |
installdirs: |
install: install-am |
install-exec: install-exec-am |
install-data: install-data-am |
uninstall: uninstall-am |
|
install-am: all-am |
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
|
installcheck: installcheck-am |
install-strip: |
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
`test -z '$(STRIP)' || \ |
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install |
mostlyclean-generic: |
|
clean-generic: |
|
distclean-generic: |
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) |
|
maintainer-clean-generic: |
@echo "This command is intended for maintainers to use" |
@echo "it deletes files that may require special tools to rebuild." |
clean: clean-am |
|
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ |
mostlyclean-am |
|
distclean: distclean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
distclean-am: clean-am distclean-compile distclean-generic \ |
distclean-tags |
|
dvi: dvi-am |
|
dvi-am: |
|
html: html-am |
|
html-am: |
|
info: info-am |
|
info-am: |
|
install-data-am: |
|
install-dvi: install-dvi-am |
|
install-dvi-am: |
|
install-exec-am: |
|
install-html: install-html-am |
|
install-html-am: |
|
install-info: install-info-am |
|
install-info-am: |
|
install-man: |
|
install-pdf: install-pdf-am |
|
install-pdf-am: |
|
install-ps: install-ps-am |
|
install-ps-am: |
|
installcheck-am: |
|
maintainer-clean: maintainer-clean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
maintainer-clean-am: distclean-am maintainer-clean-generic |
|
mostlyclean: mostlyclean-am |
|
mostlyclean-am: mostlyclean-compile mostlyclean-generic \ |
mostlyclean-libtool |
|
pdf: pdf-am |
|
pdf-am: |
|
ps: ps-am |
|
ps-am: |
|
uninstall-am: |
|
.MAKE: check-am install-am install-strip |
|
.PHONY: CTAGS GTAGS all all-am check check-am clean \ |
clean-checkPROGRAMS clean-generic clean-libtool ctags \ |
distclean distclean-compile distclean-generic \ |
distclean-libtool distclean-tags distdir dvi dvi-am html \ |
html-am info info-am install install-am install-data \ |
install-data-am install-dvi install-dvi-am install-exec \ |
install-exec-am install-html install-html-am install-info \ |
install-info-am install-man install-pdf install-pdf-am \ |
install-ps install-ps-am install-strip installcheck \ |
installcheck-am installdirs maintainer-clean \ |
maintainer-clean-generic mostlyclean mostlyclean-compile \ |
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ |
tags uninstall uninstall-am |
|
|
# Tell versions [3.59,3.63) of GNU make to not export all variables. |
# Otherwise a system limit (for SysV at least) may be exceeded. |
.NOEXPORT: |
/lib-jtag-full.c
0,0 → 1,1509
/* lib-jtag-full.c. Comprehensive test of Or1ksim library JTAG interface. |
|
Copyright (C) 1999-2006 OpenCores |
Copyright (C) 2010 Embecosm Limited |
|
Contributors various OpenCores participants |
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> |
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
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 3 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, see <http://www.gnu.org/licenses/>. */ |
|
/* ---------------------------------------------------------------------------- |
This code is commented throughout for use with Doxygen. |
--------------------------------------------------------------------------*/ |
|
#include <errno.h> |
#include <stddef.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <string.h> |
|
#include "or1ksim.h" |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Compute a IEEE 802.3 CRC-32. |
|
Print an error message if we get a duff argument, but we really should |
not. |
|
@param[in] value The value to shift into the CRC |
@param[in] num_bits The number of bits in the value. |
@param[in] crc_in The existing CRC |
|
@return The computed CRC. */ |
/* --------------------------------------------------------------------------*/ |
static unsigned long int |
crc32 (unsigned long long int value, |
int num_bits, |
unsigned long int crc_in) |
{ |
if ((1 > num_bits) || (num_bits > 64)) |
{ |
printf ("ERROR: Max 64 bits of CRC can be computed. Ignored\n"); |
return crc_in; |
} |
|
static const unsigned long int CRC32_POLY = 0x04c11db7; |
int i; |
|
/* Compute the CRC, MS bit first */ |
for (i = num_bits - 1; i >= 0; i--) |
{ |
unsigned long int d; |
unsigned long int t; |
|
d = (1 == ((value >> i) & 1)) ? 0xfffffff : 0x0000000; |
t = (1 == ((crc_in >> 31) & 1)) ? 0xfffffff : 0x0000000; |
|
crc_in <<= 1; |
crc_in ^= (d ^ t) & CRC32_POLY; |
} |
|
return crc_in; |
|
} /* crc32 () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Reverse a value's bits |
|
@param[in] val The value to reverse (up to 64 bits). |
@param[in] len The number of bits to reverse. |
|
@return The reversed value */ |
/* --------------------------------------------------------------------------*/ |
static unsigned long long |
reverse_bits (unsigned long long val, |
int len) |
{ |
if ((1 > len) || (len > 64)) |
{ |
printf ("ERROR: Cannot reverse %d bits. Returning zero\n", len); |
return 0; |
} |
|
/* Reverse the string */ |
val = (((val & 0xaaaaaaaaaaaaaaaaULL) >> 1) | |
((val & 0x5555555555555555ULL) << 1)); |
val = (((val & 0xccccccccccccccccULL) >> 2) | |
((val & 0x3333333333333333ULL) << 2)); |
val = (((val & 0xf0f0f0f0f0f0f0f0ULL) >> 4) | |
((val & 0x0f0f0f0f0f0f0f0fULL) << 4)); |
val = (((val & 0xff00ff00ff00ff00ULL) >> 8) | |
((val & 0x00ff00ff00ff00ffULL) << 8)); |
val = (((val & 0xffff0000ffff0000ULL) >> 16) | |
((val & 0x0000ffff0000ffffULL) << 16)); |
|
return ((val >> 32) | (val << 32)) >> (64 - len); |
|
} /* reverse_bits () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Dump a JTAG register |
|
Prefix with the supplied string and add a newline afterwards. |
|
@param[in] prefix Prefix string to print out |
@param[in] jreg The JTAG register |
@param[in] num_bytes The number of bytes in the register */ |
/* --------------------------------------------------------------------------*/ |
static void |
dump_jreg (const char *prefix, |
unsigned char *jreg, |
int num_bytes) |
{ |
int i; |
|
printf ("%s: 0x", prefix); |
|
/* Dump each byte in turn */ |
for (i = num_bytes - 1; i >=0; i--) |
{ |
printf ("%02x", jreg[i]); |
} |
|
printf ("\n"); |
|
} /* dump_jreg () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG instruction register |
|
Usage: |
|
INSTRUCTION <value> |
|
The single argument is a single hex digit, specifying the instruction |
value. |
|
Like all the JTAG instructions, it must be reversed, so it is shifted MS |
bit first. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_instruction (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Shifting instruction.\n"); |
|
/* Do we have the arg? */ |
if (next_jreg >= argc) |
{ |
printf ("ERROR: no instruction register value found.\n"); |
return 0; |
} |
|
/* Is the argument in range? */ |
unsigned long int ival = strtoul (argv[next_jreg], NULL, 16); |
|
if (ival > 0xf) |
{ |
printf ("ERROR: instruction value 0x%lx too large\n", ival); |
return 0; |
} |
|
/* Reverse the bits of the value */ |
ival = reverse_bits (ival, 4); |
|
/* Allocate space and populate the register */ |
unsigned char *jreg = malloc (1); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for instruction register failed.\n"); |
return 0; |
} |
|
jreg[0] = ival; |
|
dump_jreg (" shifting in", jreg, 1); |
|
double t = or1ksim_jtag_shift_ir (jreg, 4); |
|
dump_jreg (" shifted out", jreg, 1); |
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_instruction () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG SELECT_MODULE debug data register |
|
Usage: |
|
SELECT_MODULE <value> |
|
The one argument is a single hex digit, specifying the module value. |
|
Like all the JTAG fields, it must be reversed, so it is shifted MS |
bit first. It also requires a 32-bit CRC. |
|
On return we get a status register and CRC. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_select_module (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Selecting module.\n"); |
|
/* Do we have the arg? */ |
if (next_jreg >= argc) |
{ |
printf ("ERROR: no module specified.\n"); |
return 0; |
} |
|
/* Is the argument in range? */ |
unsigned long int module_id = strtoul (argv[next_jreg], NULL, 16); |
|
if (module_id > 0xf) |
{ |
printf ("ERROR: module value 0x%lx too large\n", module_id); |
return 0; |
} |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (1, 1, 0xffffffff); |
crc_in = crc32 (module_id, 4, crc_in); |
|
/* Reverse the fields */ |
module_id = reverse_bits (module_id, 4); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 module bits in |
- 32 bit CRC in |
- 4 bits status out |
- 32 bits CRC out |
|
Total 73 bits = 10 bytes */ |
int num_bytes = 10; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for SELECT_MODULE register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[0] = 0x01; |
jreg[0] |= module_id << 1; |
jreg[0] |= crc_in << 5; |
jreg[1] = crc_in >> 3; |
jreg[2] = crc_in >> 11; |
jreg[3] = crc_in >> 19; |
jreg[4] = crc_in >> 27; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char status; |
unsigned long int crc_out; |
|
status = ((jreg[4] >> 5) | (jreg[5] << 3)) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[5] >> 1) | |
((unsigned long int) jreg[6] << 7) | |
((unsigned long int) jreg[7] << 15) | |
((unsigned long int) jreg[8] << 23) | |
((unsigned long int) jreg[9] << 31); |
|
/* Reverse the fields */ |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed = crc32 (status, 4, 0xffffffff); |
|
/* Log the results */ |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_select_module () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG WRITE_COMMAND debug data register |
|
Usage: |
|
WRITE_COMMAND <access_type> <address> <length> |
|
The argumens are all hex values: |
- access_type Access type - 4 bits |
- address 32-bit address |
- length number of bytes to transer up to 2^16. |
|
Like all the JTAG fields these must be reversed, so they are shifted MS bit |
first. They also require a 32-bit CRC. |
|
On return we get a status register and CRC. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_write_command (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing WRITE_COMMAND.\n"); |
|
/* Do we have the args */ |
if (next_jreg + 3 > argc) |
{ |
printf ("WRITE_COMMAND usage: WRITE_COMMAND <access_type> <address> " |
"<length>\n"); |
return 0; |
} |
|
/* Are the arguments in range? Remember the length we actually put in has 1 |
subtracted. */ |
unsigned long int cmd = 2; /* WRITE_COMMAND */ |
|
unsigned long int access_type = strtoul (argv[next_jreg ], NULL, 16); |
unsigned long int addr = strtoul (argv[next_jreg + 1], NULL, 16); |
unsigned long int len = strtoul (argv[next_jreg + 2], NULL, 16) - 1; |
|
if (access_type > 0xf) |
{ |
printf ("ERROR: WRITE_COMMAND access type 0x%lx too large\n", |
access_type); |
return 0; |
} |
|
if (addr > 0xffffffff) |
{ |
printf ("ERROR: WRITE_COMMAND address 0x%lx too large\n", addr); |
return 0; |
} |
|
if ((len + 1) < 0x1) |
{ |
printf ("ERROR: WRITE_COMMAND length 0x%lx too small\n", len + 1); |
return 0; |
} |
else if ((len + 1) > 0x10000) |
{ |
printf ("ERROR: WRITE_COMMAND length 0x%lx too large\n", len + 1); |
return 0; |
} |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
crc_in = crc32 (access_type, 4, crc_in); |
crc_in = crc32 (addr, 32, crc_in); |
crc_in = crc32 (len, 16, crc_in); |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
access_type = reverse_bits (access_type, 4); |
addr = reverse_bits (addr, 32); |
len = reverse_bits (len, 16); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- 4 bits access type in |
- 32 bits address in |
- 16 bits length in |
- 32 bits CRC in |
- 4 bits status out |
- 32 bits CRC out |
|
Total 125 bits = 16 bytes */ |
int num_bytes = 16; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for WRITE_COMMAND register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[ 0] = 0x0; |
|
jreg[ 0] |= cmd << 1; |
|
jreg[ 0] |= access_type << 5; |
jreg[ 1] = access_type >> 3; |
|
jreg[ 1] |= addr << 1; |
jreg[ 2] = addr >> 7; |
jreg[ 3] = addr >> 15; |
jreg[ 4] = addr >> 23; |
jreg[ 5] = addr >> 31; |
|
jreg[ 5] |= len << 1; |
jreg[ 6] = len >> 7; |
jreg[ 7] = len >> 15; |
|
jreg[ 7] |= crc_in << 1; |
jreg[ 8] = crc_in >> 7; |
jreg[ 9] = crc_in >> 15; |
jreg[10] = crc_in >> 23; |
jreg[11] = crc_in >> 31; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 16 + 32 + 4 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char status; |
unsigned long int crc_out; |
|
status = (jreg[11] >> 1) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[11] >> 5) | |
((unsigned long int) jreg[12] << 3) | |
((unsigned long int) jreg[13] << 11) | |
((unsigned long int) jreg[14] << 19) | |
((unsigned long int) jreg[15] << 27); |
|
/* Reverse the fields */ |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed = crc32 (status, 4, 0xffffffff); |
|
/* Log the results */ |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_write_command () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG READ_COMMAND debug data register |
|
Usage: |
|
READ_COMMAND |
|
There are no arguments. It is used to read back the values used in a prior |
WRITE_COMMAND. |
|
On return we get the access type, address, length, status register and CRC. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_read_command (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing READ_COMMAND.\n"); |
|
/* The only value on input is the READ_COMMAND command */ |
unsigned long int cmd = 1; /* READ_COMMAND */ |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- 32 bits CRC in |
- 4 bits access type out |
- 32 bits address out |
- 16 bits length out |
- 4 bits status out |
- 32 bits CRC out |
|
Total 125 bits = 16 bytes */ |
int num_bytes = 16; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for READ_COMMAND register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[ 0] = 0x0; |
|
jreg[0] |= cmd << 1; |
|
jreg[0] |= crc_in << 5; |
jreg[1] = crc_in >> 3; |
jreg[2] = crc_in >> 11; |
jreg[3] = crc_in >> 19; |
jreg[4] = crc_in >> 27; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 16 + 32 + 4 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char access_type; |
unsigned long int addr; |
unsigned long int len; |
unsigned char status; |
unsigned long int crc_out; |
|
access_type = ((jreg[4] >> 5) | (jreg[5] << 3)) & 0xf ; |
addr = ((unsigned long int) jreg[ 5] >> 1) | |
((unsigned long int) jreg[ 6] << 7) | |
((unsigned long int) jreg[ 7] << 15) | |
((unsigned long int) jreg[ 8] << 23) | |
((unsigned long int) jreg[ 9] << 31); |
|
len = ((unsigned long int) jreg[ 9] >> 1) | |
((unsigned long int) jreg[10] << 7) | |
((unsigned long int) (jreg[11] & 0x1) << 15); |
|
status = (jreg[11] >> 1) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[11] >> 5) | |
((unsigned long int) jreg[12] << 3) | |
((unsigned long int) jreg[13] << 11) | |
((unsigned long int) jreg[14] << 19) | |
((unsigned long int) jreg[15] << 27); |
|
/* Reverse the fields */ |
|
access_type = reverse_bits (access_type, 4); |
addr = reverse_bits (addr, 32); |
len = reverse_bits (len, 16); |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed; |
|
crc_computed = crc32 (access_type, 4, 0xffffffff); |
crc_computed = crc32 (addr, 32, crc_computed); |
crc_computed = crc32 (len, 16, crc_computed); |
crc_computed = crc32 (status, 4, crc_computed); |
|
/* Log the results. Remember the length is 1 greater than the value |
returned. */ |
printf (" access_type: 0x%x\n", access_type); |
printf (" address: 0x%lx\n", addr); |
printf (" length: 0x%lx\n", len + 1); |
printf (" status: 0x%x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_read_command () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG GO_COMMAND_WRITE debug data register |
|
Usage: |
|
GO_COMMAND_WRITE <data> |
|
The one argument is a string of bytes to be written, LS byte first. |
|
Like all the JTAG fields, each data byte must be reversed, so it is shifted |
MS bit first. It also requires a 32-bit CRC. |
|
On return we get a status register and CRC. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_go_command_write (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing GO_COMMAND_WRITE.\n"); |
|
/* Do we have the arg */ |
if (next_jreg >= argc) |
{ |
printf ("GO_COMMAND_WRITE usage: GO_COMMAND_WRITE <data>.\n"); |
return 0; |
} |
|
/* Break out the fields, including the data string into a vector of bytes. */ |
unsigned long int cmd = 0; /* GO_COMMAND */ |
|
char *data_str = argv[next_jreg]; |
int data_len = strlen (data_str); |
int data_bytes = data_len / 2; |
unsigned char *data = malloc (data_bytes); |
|
if (NULL == data) |
{ |
printf ("ERROR: data malloc for GO_COMMAND_WRITE register failed.\n"); |
return 0; |
} |
|
if (1 == (data_len % 2)) |
{ |
printf ("Warning: GO_COMMAND_WRITE odd char ignored\n"); |
} |
|
int i; |
|
for (i = 0; i < data_bytes; i++) |
{ |
int ch_off_ms = i * 2; |
int ch_off_ls = i * 2 + 1; |
|
/* Get each nybble in turn, remembering that we may not have a MS nybble |
if the data string has an odd number of chars. */ |
data[i] = 0; |
|
int j; |
|
for (j = ch_off_ms; j <= ch_off_ls; j++) |
{ |
char c = data_str[j]; |
int dig_val = (('0' <= c) && (c <= '9')) ? c - '0' : |
(('a' <= c) && (c <= 'f')) ? c - 'a' + 10 : |
(('A' <= c) && (c <= 'F')) ? c - 'A' + 10 : -1; |
|
if (dig_val < 0) |
{ |
printf ("ERROR: Non-hex digit in data: %c\n", c); |
free (data); |
return 0; |
} |
|
data[i] = (data[i] << 4) | dig_val; |
} |
} |
|
/* Are the arguments in range? Remember the length we actually put in has 1 |
subtracted. */ |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
|
for (i = 0; i < data_bytes; i++) |
{ |
crc_in = crc32 (data[i], 8, crc_in); |
} |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
|
for (i = 0; i < data_bytes; i++) |
{ |
data[i] = reverse_bits (data[i], 8); |
} |
|
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- data_bytes * 8 bits access type in |
- 32 bits CRC in |
- 4 bits status out |
- 32 bits CRC out |
|
Total 73 + data_bytes * 8 bits = 10 + data_bytes bytes */ |
int num_bytes = 10 + data_bytes; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: jreg malloc for GO_COMMAND_WRITE register failed.\n"); |
free (data); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[ 0] = 0x0; |
jreg[ 0] |= cmd << 1; |
|
for (i = 0; i < data_bytes; i++) |
{ |
jreg[i] |= data[i] << 5; |
jreg[i + 1] = data[i] >> 3; |
} |
|
jreg[data_bytes ] |= crc_in << 5; |
jreg[data_bytes + 1] = crc_in >> 3; |
jreg[data_bytes + 2] = crc_in >> 11; |
jreg[data_bytes + 3] = crc_in >> 19; |
jreg[data_bytes + 4] = crc_in >> 27; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, |
32 + 4 + 32 + data_bytes * 8 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char status; |
unsigned long int crc_out; |
|
status = ((jreg[data_bytes + 4] >> 5) | (jreg[data_bytes + 5] << 3)) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[data_bytes + 5] >> 1) | |
((unsigned long int) jreg[data_bytes + 6] << 7) | |
((unsigned long int) jreg[data_bytes + 7] << 15) | |
((unsigned long int) jreg[data_bytes + 8] << 23) | |
((unsigned long int) jreg[data_bytes + 9] << 31); |
|
/* Reverse the fields */ |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed = crc32 (status, 4, 0xffffffff); |
|
/* Log the results */ |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (data); |
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_go_command_write () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG GO_COMMAND_READ debug data register |
|
Usage: |
|
GO_COMMAND_READ <length> |
|
The one argument is a length in hex, specifying the number of bytes to be |
read. |
|
On return we get a status register and CRC. |
|
Like all JTAG fields, the CRC shifted in, the data read back, the status |
and CRC shifted out, must be reversed, since they are shifted in MS bit |
first and out LS bit first. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_go_command_read (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing GO_COMMAND_READ.\n"); |
|
/* Do we have the args */ |
if (next_jreg >= argc) |
{ |
printf ("GO_COMMAND_READ usage: GO_COMMAND_READ <length>\n"); |
return 0; |
} |
|
/* Is the argument in range? Remember the length we actually put in has 1 |
subtracted, so although it is a 16-bit field, it can be up to 2^16. */ |
unsigned long int cmd = 0; /* GO_COMMAND */ |
unsigned long int data_bytes = strtoul (argv[next_jreg], NULL, 16); |
|
if (data_bytes < 0) |
{ |
printf ("ERROR: GO_COMMAND_READ length 0x%lx too small\n", data_bytes); |
return 0; |
} |
else if (data_bytes > 0x10000) |
{ |
printf ("ERROR: GO_COMMAND_READ length 0x%lx too large\n", data_bytes); |
return 0; |
} |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- 32 bits CRC in |
- data_bytes * 8 bits access type out |
- 4 bits status out |
- 32 bits CRC out |
|
Total 73 + data_bytes * 8 bits = 10 + data_bytes bytes */ |
int num_bytes = 10 + data_bytes; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc forGO_COMMAND_READ register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[0] = 0x0; |
jreg[0] |= cmd << 1; |
|
jreg[0] |= crc_in << 5; |
jreg[1] = crc_in >> 3; |
jreg[2] = crc_in >> 11; |
jreg[3] = crc_in >> 19; |
jreg[4] = crc_in >> 27; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, |
32 + 4 + data_bytes * 8 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char *data = malloc (data_bytes); |
unsigned char status; |
unsigned long int crc_out; |
|
if (NULL == data) |
{ |
printf ("ERROR: data malloc for GO_COMMAND_READ register failed.\n"); |
free (jreg); |
return 0; |
} |
|
int i; |
|
for (i = 0; i < data_bytes; i++) |
{ |
data[i] = ((jreg[i + 4] >> 5) | (jreg[i + 5] << 3)) & 0xff; |
} |
|
status = ((jreg[data_bytes + 4] >> 5) | (jreg[data_bytes + 5] << 3)) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[data_bytes + 5] >> 1) | |
((unsigned long int) jreg[data_bytes + 6] << 7) | |
((unsigned long int) jreg[data_bytes + 7] << 15) | |
((unsigned long int) jreg[data_bytes + 8] << 23) | |
((unsigned long int) jreg[data_bytes + 9] << 31); |
|
/* Reverse the fields */ |
for (i = 0; i < data_bytes; i++) |
{ |
data[i] = reverse_bits (data[i], 8); |
} |
|
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed = 0xffffffff; |
|
for (i = 0; i < data_bytes; i++) |
{ |
crc_computed = crc32 (data[i], 8, crc_computed); |
} |
|
crc_computed = crc32 (status, 4, crc_computed); |
|
/* Log the results, remembering these are bytes, so endianness is not a |
factor here. Since the OR1K is big endian, the lowest numbered byte will |
be the least significant, and the first printed */ |
printf (" data: "); |
|
for (i = 0; i < data_bytes; i++) |
{ |
printf ("%02x", data[i]); |
} |
|
printf ("\n"); |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (data); |
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_go_command_read () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG WRITE_CONTROL debug data register |
|
Usage: |
|
WRITE_CONTROL <reset> <stall> |
|
The arguments should be either zero or one. |
|
The arguments are used to construct the 52-bit CPU control register. Like |
all JTAG fields, it must be reversed, so it is shifted MS bit first. It |
also requires a 32-bit CRC. |
|
On return we get a status register and CRC. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_write_control (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing WRITE_CONTROL.\n"); |
|
/* Do we have the args */ |
if (next_jreg + 2 > argc) |
{ |
printf ("WRITE_CONTROL usage: WRITE_CONTROL <reset> <status>\n"); |
return 0; |
} |
|
/* Are the arguments in range? */ |
unsigned long int cmd = 4; /* WRITE_CONTROL */ |
|
unsigned long int reset = strtoul (argv[next_jreg ], NULL, 16); |
unsigned long int stall = strtoul (argv[next_jreg + 1], NULL, 16); |
|
if (reset > 0x1) |
{ |
printf ("ERROR: invalid WRITE_CONTROL reset value 0x%lx.\n", reset); |
return 0; |
} |
|
if (stall > 0x1) |
{ |
printf ("ERROR: invalid WRITE_CONTROL stall value 0x%lx.\n", stall); |
return 0; |
} |
|
/* Construct the control register */ |
unsigned long long int creg = ((unsigned long long int) reset << 51) | |
((unsigned long long int) stall << 50); |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
crc_in = crc32 (creg, 52, crc_in); |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
creg = reverse_bits (creg, 52); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- 52 bits control register |
- 32 bits CRC in |
- 4 bits status out |
- 32 bits CRC out |
|
Total 125 bits = 16 bytes */ |
int num_bytes = 16; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for WRITE_CONTROL register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[ 0] = 0x0; |
|
jreg[ 0] |= cmd << 1; |
|
jreg[ 0] |= creg << 5; |
jreg[ 1] = creg >> 3; |
jreg[ 2] = creg >> 11; |
jreg[ 3] = creg >> 19; |
jreg[ 4] = creg >> 27; |
jreg[ 5] = creg >> 35; |
jreg[ 6] = creg >> 43; |
jreg[ 7] = creg >> 51; |
|
jreg[ 7] |= crc_in << 1; |
jreg[ 8] = crc_in >> 7; |
jreg[ 9] = crc_in >> 15; |
jreg[10] = crc_in >> 23; |
jreg[11] = crc_in >> 31; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 52 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned char status; |
unsigned long int crc_out; |
|
status = (jreg[11] >> 1) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[11] >> 5) | |
((unsigned long int) jreg[12] << 3) | |
((unsigned long int) jreg[13] << 11) | |
((unsigned long int) jreg[14] << 19) | |
((unsigned long int) jreg[15] << 27); |
|
/* Reverse the fields */ |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed = crc32 (status, 4, 0xffffffff); |
|
/* Log the results */ |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_write_control () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Process a JTAG READ_CONTROL debug data register |
|
Usage: |
|
READ_CONTROL |
|
There are no arguments. It requires a 32-bit CRC. |
|
On return we get the control register, status and CRC. |
|
Like all the JTAG fields, they must be reversed, as resutl is shifted out |
LS bit first. |
|
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] argc argc from the main program (for checking next_jreg). |
@param[in] argv argv from the main program. |
|
@return 1 (TRUE) on success, 0 (FALSE) on failure. */ |
/* --------------------------------------------------------------------------*/ |
static int |
process_read_control (int next_jreg, |
int argc, |
char *argv[]) |
{ |
printf ("Processing READ_CONTROL.\n"); |
|
/* Only input field is cmd. */ |
unsigned long int cmd = 3; /* READ_CONTROL */ |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
|
crc_in = crc32 (0, 1, 0xffffffff); |
crc_in = crc32 (cmd, 4, crc_in); |
|
/* Reverse the fields */ |
cmd = reverse_bits (cmd, 4); |
crc_in = reverse_bits (crc_in, 32); |
|
/* Allocate space and initialize the register |
- 1 indicator bit |
- 4 bits command in |
- 32 bits CRC in |
- 52 bits control register out |
- 4 bits status out |
- 32 bits CRC out |
|
Total 125 bits = 16 bytes */ |
int num_bytes = 16; |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
printf ("ERROR: malloc for READ_CONTROL register failed.\n"); |
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
jreg[0] = 0x0; |
|
jreg[0] |= cmd << 1; |
|
jreg[0] |= crc_in << 5; |
jreg[1] = crc_in >> 3; |
jreg[2] = crc_in >> 11; |
jreg[3] = crc_in >> 19; |
jreg[4] = crc_in >> 27; |
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 52 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
|
/* Break out fields */ |
unsigned long long int creg; |
unsigned char status; |
unsigned long int crc_out; |
|
creg = ((unsigned long long int) jreg[ 4] >> 5) | |
((unsigned long long int) jreg[ 5] << 3) | |
((unsigned long long int) jreg[ 6] << 11) | |
((unsigned long long int) jreg[ 7] << 19) | |
((unsigned long long int) jreg[ 8] << 27) | |
((unsigned long long int) jreg[ 9] << 35) | |
((unsigned long long int) jreg[10] << 43) | |
((unsigned long long int) (jreg[11] & 0x1) << 51); |
|
status = (jreg[11] >> 1) & 0xf ; |
|
crc_out = ((unsigned long int) jreg[11] >> 5) | |
((unsigned long int) jreg[12] << 3) | |
((unsigned long int) jreg[13] << 11) | |
((unsigned long int) jreg[14] << 19) | |
((unsigned long int) jreg[15] << 27); |
|
/* Reverse the fields */ |
creg = reverse_bits (creg, 52); |
status = reverse_bits (status, 4); |
crc_out = reverse_bits (crc_out, 32); |
|
/* Compute our own CRC */ |
unsigned long int crc_computed; |
|
crc_computed = crc32 (creg, 52, 0xffffffff); |
crc_computed = crc32 (status, 4, crc_computed); |
|
const char *reset = (1 == ((creg >> 51) & 1)) ? "enabled" : "disabled"; |
const char *stall = (1 == ((creg >> 50) & 1)) ? "stalled" : "unstalled"; |
|
/* Log the results */ |
printf (" reset: %s\n", reset); |
printf (" stall: %s\n", stall); |
printf (" status: 0x%01x\n", status); |
|
if (crc_out != crc_computed) |
{ |
printf (" CRC mismatch\n"); |
printf (" CRC out: 0x%08lx\n", crc_out); |
printf (" CRC computed: 0x%08lx\n", crc_computed); |
} |
|
printf (" time taken: %.12fs\n", t); |
|
free (jreg); |
return 1; /* Completed successfully */ |
|
} /* process_read_control () */ |
|
|
/* --------------------------------------------------------------------------*/ |
/*!Main program |
|
Build an or1ksim program using the library which loads a program and config |
from the command line and then drives JTAG. |
|
lib-jtag-full <config-file> <image> <jregtype> [<args>] |
[<jregtype> [<args>]] ... |
|
- config-file An Or1ksim configuration file. |
- image A OpenRISC binary image to load into Or1ksim |
- jregtype One of RESET, INSTRUCTION, SELECT_MODULE, WRITE_COMMAND, |
READ_COMMAND, GO_COMMAND_WRITE, GO_COMMAND_READ, |
WRITE_CONTROL or READ_CONTROL. |
- args Arguments required by the jregtype. RESET, READ_COMMAND and |
READ_CONTROL require none. |
|
The target program is run in bursts of 1ms execution, and the type of |
return (OK, hit breakpoint) noted. Between each burst of execution, the |
JTAG interface is reset (for RESET) or the next register is submitted to |
the corresponding Or1ksim JTAG interface and the resulting register noted. |
|
@param[in] argc Number of elements in argv |
@param[in] argv Vector of program name and arguments |
|
@return Return code for the program, zero on success. */ |
/* --------------------------------------------------------------------------*/ |
int |
main (int argc, |
char *argv[]) |
{ |
const double QUANTUM = 5.0e-3; /* Time in sec for each step. */ |
|
/* Check we have minimum number of args. */ |
if (argc < 4) |
{ |
printf ("usage: lib-jtag <config-file> <image> <jregtype> [<args>] " |
"[<jregtype> [<args>]] ...\n"); |
return 1; |
} |
|
/* Initialize the program. Put the initialization message afterwards, or it |
will get swamped by the Or1ksim header. */ |
if (0 == or1ksim_init (argv[1], argv[2], NULL, NULL, NULL)) |
{ |
printf ("Initalization succeeded.\n"); |
} |
else |
{ |
printf ("Initalization failed.\n"); |
return 1; |
} |
|
/* Run repeatedly for 10 milliseconds until we have processed all JTAG |
registers */ |
int next_jreg = 3; /* Offset to next JTAG register */ |
|
do |
{ |
switch (or1ksim_run (QUANTUM)) |
{ |
case OR1KSIM_RC_OK: |
printf ("Execution step completed OK.\n"); |
break; |
|
case OR1KSIM_RC_BRKPT: |
printf ("Execution step completed with breakpoint.\n"); |
break; |
|
default: |
printf ("ERROR: run failed.\n"); |
return 1; |
} |
|
/* Process the next register appropriately, skipping any args after |
processing. */ |
char *jregtype = argv[next_jreg++]; |
|
if (0 == strcasecmp ("RESET", jregtype)) |
{ |
printf ("Resetting JTAG.\n"); |
or1ksim_jtag_reset (); |
} |
else if (0 == strcasecmp ("INSTRUCTION", jregtype)) |
{ |
if (process_instruction (next_jreg, argc, argv)) |
{ |
next_jreg++; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("SELECT_MODULE", jregtype)) |
{ |
if (process_select_module (next_jreg, argc, argv)) |
{ |
next_jreg++; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("WRITE_COMMAND", jregtype)) |
{ |
if (process_write_command (next_jreg, argc, argv)) |
{ |
next_jreg += 3; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("READ_COMMAND", jregtype)) |
{ |
if (process_read_command (next_jreg, argc, argv)) |
{ |
/* succeeded (no args) */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("GO_COMMAND_WRITE", jregtype)) |
{ |
if (process_go_command_write (next_jreg, argc, argv)) |
{ |
next_jreg++; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("GO_COMMAND_READ", jregtype)) |
{ |
if (process_go_command_read (next_jreg, argc, argv)) |
{ |
next_jreg++; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("WRITE_CONTROL", jregtype)) |
{ |
if (process_write_control (next_jreg, argc, argv)) |
{ |
next_jreg += 2; /* succeeded */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else if (0 == strcasecmp ("READ_CONTROL", jregtype)) |
{ |
if (process_read_control (next_jreg, argc, argv)) |
{ |
/* succeeded (no args) */ |
} |
else |
{ |
return 1; /* failed */ |
} |
} |
else |
{ |
printf ("ERROR: Unrecognized JTAG register '%s'.\n", jregtype); |
return 1; |
} |
} |
while (next_jreg < argc); |
|
/* A little longer to allow response to last upcall to be handled. */ |
switch (or1ksim_run (QUANTUM)) |
{ |
case OR1KSIM_RC_OK: |
printf ("Execution step completed OK.\n"); |
break; |
|
case OR1KSIM_RC_BRKPT: |
printf ("Execution step completed with breakpoint.\n"); |
break; |
|
default: |
printf ("ERROR: run failed.\n"); |
return 1; |
} |
|
printf ("Test completed successfully.\n"); |
return 0; |
|
} /* main () */ |
lib-jtag-full.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lib-jtag.c
===================================================================
--- lib-jtag.c (nonexistent)
+++ lib-jtag.c (revision 128)
@@ -0,0 +1,344 @@
+/* lib-jtag.c. Basic test of Or1ksim library JTAG interface.
+
+ Copyright (C) 1999-2006 OpenCores
+ Copyright (C) 2010 Embecosm Limited
+
+ Contributors various OpenCores participants
+ Contributor Jeremy Bennett
+
+ This file is part of OpenRISC 1000 Architectural Simulator.
+
+ 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 3 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, see . */
+
+/* ----------------------------------------------------------------------------
+ This code is commented throughout for use with Doxygen.
+ --------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+#include
+#include
+
+#include "or1ksim.h"
+
+
+/* --------------------------------------------------------------------------*/
+/*!Dump a JTAG register
+
+ Prefix with the supplied string and add a newline afterwards.
+
+ @param[in] prefix Prefix string to print out
+ @param[in] jreg The JTAG register
+ @param[in] num_bytes The number of bytes in the register */
+/* --------------------------------------------------------------------------*/
+static void
+dump_jreg (const char *prefix,
+ unsigned char *jreg,
+ int num_bytes)
+{
+ int i;
+
+ printf ("%s: ", prefix);
+
+ /* Dump each byte in turn */
+ for (i = num_bytes - 1; i >=0; i--)
+ {
+ printf ("%02x", jreg[i]);
+ }
+
+ printf ("\n");
+
+} /* dump_jreg () */
+
+
+/* --------------------------------------------------------------------------*/
+/*!Convert a hex char into its value.
+
+ @param[in] c The char to convert
+
+ @return The value represented by the char, or -1 if it's not a valid
+ char. */
+/* --------------------------------------------------------------------------*/
+static int
+hexch2val (char c)
+{
+ switch (c)
+ {
+ case '0': return 0;
+ case '1': return 1;
+ case '2': return 2;
+ case '3': return 3;
+ case '4': return 4;
+ case '5': return 5;
+ case '6': return 6;
+ case '7': return 7;
+ case '8': return 8;
+ case '9': return 9;
+
+ case 'a': case 'A': return 10;
+ case 'b': case 'B': return 11;
+ case 'c': case 'C': return 12;
+ case 'd': case 'D': return 13;
+ case 'e': case 'E': return 14;
+ case 'f': case 'F': return 15;
+
+ default:
+ return -1;
+ }
+} /* hexch2val () */
+
+
+/* --------------------------------------------------------------------------*/
+/*!Shift a JTAG register.
+
+ Almost all this code is common between the instruction and data
+ registers. All that varies is the library function called and the error
+ message if anything goes wrong. So we common things up here.
+
+ @param[in] type 'D' if this is a data register, 'I' if an instruction
+ register.
+ @param[in] next_jreg Offset into argv of the next JTAG register length
+ field.
+ @param[in] argc argc from the main program (for checking next_jref).
+ @param[in] argv argv from the main program.
+
+ @return 1 (TRUE) on success, 0 (FALSE) on failure. */
+/* --------------------------------------------------------------------------*/
+static int
+process_jreg (const char type,
+ int next_jreg,
+ int argc,
+ char *argv[])
+{
+ const char *long_name = ('D' == type) ? "data" : "instruction";
+
+ /* Do we have the arg (length and value)? */
+ if ((next_jreg + 1) > argc)
+ {
+ printf ("ERROR: no %s register found.\n", long_name);
+ return 0;
+ }
+
+ /* Get the length field */
+ int bit_len = strtol (argv[next_jreg++], NULL, 0);
+
+ if (0 == bit_len)
+ {
+ printf ("ERROR: invalid register length\n");
+ return 0;
+ }
+
+ /* Is the reg an exact number of bytes? */
+ char *hex_str = argv[next_jreg];
+ int num_chars = strlen (hex_str);
+ int num_bytes = (bit_len + 7) / 8;
+
+ if (num_chars > (2 * num_bytes))
+ {
+ printf ("Warning: Too many digits for register: truncated.\n");
+ }
+
+ /* Allocate and clear space */
+ unsigned char *jreg = malloc (num_bytes);
+
+ if (NULL == jreg)
+ {
+ printf ("ERROR: malloc for %s register failed.\n", long_name);
+ return 0;
+ }
+
+ memset (jreg, 0, num_bytes);
+
+ /* Initialize the register. The hex presentation is MS byte of the string on
+ the left (i.e. at offset 0), but the internal representation is LS byte
+ at the lowest address. */
+ int i;
+
+ for (i = num_chars - 1; i >= 0; i--)
+ {
+ int dig_num = num_chars - 1 - i; /* Which digit */
+ int dig_val = hexch2val (hex_str[i]);
+
+ if (dig_val < 0)
+ {
+ printf ("ERROR: %c not valid hex digit.\n", hex_str[i]);
+ free (jreg);
+ return 0;
+ }
+
+ /* MS digits are the odd numbered ones */
+ jreg[dig_num / 2] |= (0 == (dig_num % 2)) ? dig_val : dig_val << 4;
+ }
+
+ /* Note what we are doing */
+ dump_jreg (" shifting in", jreg, num_bytes);
+
+ double t;
+
+ if ('D' == type)
+ {
+ t = or1ksim_jtag_shift_dr (jreg, bit_len);
+ }
+ else
+ {
+ t = or1ksim_jtag_shift_ir (jreg, bit_len);
+ }
+
+ dump_jreg (" shifted out", jreg, num_bytes);
+ printf (" time taken %.12fs\n", t);
+
+ free (jreg);
+ return 1; /* Completed successfully */
+
+} /* process_jreg () */
+
+
+/* --------------------------------------------------------------------------*/
+/*!Main program
+
+ Build an or1ksim program using the library which loads a program and config
+ from the command line which will drive JTAG.
+
+ lib-jtag [ ]
+ [ [ ]] ...
+
+ - config-file An Or1ksim configuration file.
+ - image A OpenRISC binary image to load into Or1ksim
+ - jtype One of 'R' (JTAG reset), 'I' (JTAG instruction register) or
+ 'D' (JTAG data register).
+ - bitlen If jtype is 'D' or 'I', the number of bits in the JTAG
+ register.
+ - reg If jtype is 'D' or 'I', a JTAG register specified in
+ hex. Specified LS digit on the right, and leading zeros may
+ be omitted.
+
+ The target program is run in bursts of 1ms execution, and the type of
+ return (OK, hit breakpoint) noted. Between each burst of execution, the
+ next register is submitted to the corresponding Or1ksim JTAG interface
+ function, and the resulting register (for 'I' and 'D') noted.
+
+ @param[in] argc Number of elements in argv
+ @param[in] argv Vector of program name and arguments
+
+ @return Return code for the program. */
+/* --------------------------------------------------------------------------*/
+int
+main (int argc,
+ char *argv[])
+{
+ /* Check we have minimum number of args. */
+ if (argc < 4)
+ {
+ printf ("usage: lib-jtag [ ] "
+ "[ [ ]] ...\n");
+ return 1;
+ }
+
+ /* Initialize the program. Put the initialization message afterwards, or it
+ will get swamped by the Or1ksim header. */
+ if (0 == or1ksim_init (argv[1], argv[2], NULL, NULL, NULL))
+ {
+ printf ("Initalization succeeded.\n");
+ }
+ else
+ {
+ printf ("Initalization failed.\n");
+ return 1;
+ }
+
+ /* Run repeatedly for 1 millisecond until we have processed all JTAG
+ registers */
+ int next_jreg = 3; /* Offset to next JTAG register */
+
+ do
+ {
+ switch (or1ksim_run (1.0e-3))
+ {
+ case OR1KSIM_RC_OK:
+ printf ("Execution step completed OK.\n");
+ break;
+
+ case OR1KSIM_RC_BRKPT:
+ printf ("Execution step completed with breakpoint.\n");
+ break;
+
+ default:
+ printf ("ERROR: run failed.\n");
+ return 1;
+ }
+
+ /* Process the next arg appropriately. */
+ switch (argv[next_jreg++][0])
+ {
+ case 'R':
+ printf ("Resetting JTAG.\n");
+ or1ksim_jtag_reset ();
+ break;
+
+ case 'I':
+ printf ("Shifting instruction register.\n");
+
+ if (process_jreg ('I', next_jreg, argc, argv))
+ {
+ next_jreg += 2;
+ }
+ else
+ {
+ return 1; /* Something went wrong */
+ }
+
+ break;
+
+ case 'D':
+ printf ("Shifting data register.\n");
+
+ if (process_jreg ('D', next_jreg, argc, argv))
+ {
+ next_jreg += 2;
+ }
+ else
+ {
+ return 1; /* Something went wrong */
+ }
+
+ break;
+
+ default:
+ printf ("ERROR: unknown JTAG request type.\n");
+ return 1;
+ }
+ }
+ while (next_jreg < argc);
+
+ /* A little longer to allow response to last upcall to be handled. */
+ switch (or1ksim_run (1.0e-3))
+ {
+ case OR1KSIM_RC_OK:
+ printf ("Execution step completed OK.\n");
+ break;
+
+ case OR1KSIM_RC_BRKPT:
+ printf ("Execution step completed with breakpoint.\n");
+ break;
+
+ default:
+ printf ("ERROR: run failed.\n");
+ return 1;
+ }
+
+ printf ("Test completed successfully.\n");
+ return 0;
+
+} /* main () */
lib-jtag.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 128)
@@ -0,0 +1,39 @@
+# Makefile.am for libor1ksim test programs for JTAG
+
+# Copyright (C) Embecosm Limited, 2010
+
+# Contributor Jeremy Bennett
+
+# This file is part of OpenRISC 1000 Architectural Simulator.
+
+# 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 3 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, see . */
+
+# -----------------------------------------------------------------------------
+# This code is commented throughout for use with Doxygen.
+# -----------------------------------------------------------------------------
+
+
+# Programs to handle the JTAG interface
+check_PROGRAMS = lib-jtag \
+ lib-jtag-full
+
+# Simple JTAG handling
+lib_jtag_SOURCES = lib-jtag.c
+
+lib_jtag_LDADD = $(top_builddir)/libsim.la
+
+# Simple JTAG handling
+lib_jtag_full_SOURCES = lib-jtag-full.c
+
+lib_jtag_full_LDADD = $(top_builddir)/libsim.la
Makefile.am
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property