xscale: better fix for debug_handler.bin
authorDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 16 Oct 2009 20:52:40 +0000 (13:52 -0700)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 16 Oct 2009 20:52:40 +0000 (13:52 -0700)
Generate a C struct with the data, and use that, instead of an
assembly language file.  The assembly language causes issues on
Darwin and MS-Windows, which don't necessarily use GNU AS; or
if they do, don't necessarily use its ELF syntax.

It's also better in two other ways:  fewer global symbols; and
the init-time size check gets optimized away at compile time.
(Unless it fails, in which case bigger chunks of the file vanish.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
configure.in
src/helper/Makefile.am
src/target/Makefile.am
src/target/xscale.c
src/target/xscale.h
src/target/xscale_debug.S [deleted file]

index 84574bec6e36dc0b9f22648c561fa499466150a5..8e2881cf43beb049931f3f71c82084095c4d2457 100644 (file)
@@ -16,7 +16,6 @@ AC_LANG_C
 AC_PROG_CC
 AC_PROG_CC_C99
 AM_PROG_CC_C_O
-AM_PROG_AS
 AC_PROG_RANLIB
 
 dnl disable checks for C++, Fortran and GNU Java Compiler
index 7047253b24c633d406dcf97321999d7088c9733f..67250a18d288aab5aac0108f7576336be82f6c3f 100644 (file)
@@ -52,12 +52,16 @@ noinst_HEADERS = \
        startup.tcl \
        bin2char.c
 
-bin2char$(EXEEXT_FOR_BUILD): bin2char.c
+BIN2C = bin2char$(EXEEXT_FOR_BUILD)
+
+BUILT_SOURCES = $(BIN2C)
+
+$(BIN2C): bin2char.c
        ${CC_FOR_BUILD} ${CFLAGS_FOR_BUILD} $(srcdir)/bin2char.c -o $@
 
 # Convert .tcl to cfile
-startup_tcl.c: startup.tcl bin2char$(EXEEXT_FOR_BUILD)
-       ./bin2char$(EXEEXT_FOR_BUILD) startup_tcl < $(srcdir)/startup.tcl > $@
+startup_tcl.c: startup.tcl $(BIN2C)
+       ./$(BIN2C) startup_tcl < $(srcdir)/startup.tcl > $@
 
 # add startup_tcl.c to make clean list
 CLEANFILES = startup_tcl.c bin2char$(EXEEXT_FOR_BUILD)
index a2c34f0f74355ca427f55c1ad09c57cc4e870d86..ea1641ef0dbfedd41b4976efba999083231780f7 100644 (file)
@@ -10,11 +10,10 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/src/jtag \
        -I$(top_srcdir)/src/xsvf
 
-# ideally this would be specific to xscale_debug.S ...
-libtarget_la_CCASFLAGS = \
-       -Wa,-I$(top_srcdir)/src/target \
-       $(AM_CCASFLAGS)
+BIN2C = $(top_srcdir)/src/helper/bin2char$(EXEEXT_FOR_BUILD)
 
+xscale_debug.h: $(BIN2C) xscale/debug_handler.bin
+       $(BIN2C) < xscale/debug_handler.bin xscale_debug_handler > xscale_debug.h
 
 METASOURCES = AUTO
 noinst_LTLIBRARIES = libtarget.la
@@ -41,7 +40,6 @@ libtarget_la_SOURCES = \
        feroceon.c \
        etb.c \
        xscale.c \
-       xscale_debug.S \
        arm_simulator.c \
        image.c \
        armv7m.c \
@@ -62,6 +60,9 @@ libtarget_la_SOURCES = \
        mips_ejtag.c \
        avrt.c
 
+BUILT_SOURCES = \
+       xscale_debug.h
+
 noinst_HEADERS = \
        target.h \
        target_type.h \
@@ -85,6 +86,7 @@ noinst_HEADERS = \
        arm926ejs.h \
        etb.h \
        xscale.h \
+       xscale_debug.h \
        arm_simulator.h \
        image.h \
        armv7m.h \
index dd16b35e52d275d1e31eea890db375f1b86bb11b..640eb01b6712531ff41f5851cf4c8b4077a112bb 100644 (file)
@@ -69,6 +69,17 @@ static int xscale_unset_breakpoint(struct target_s *, breakpoint_t *);
 static int xscale_read_trace(target_t *);
 
 
+/* This XScale "debug handler" is loaded into the processor's
+ * mini-ICache, which is 2K of code writable only via JTAG.
+ *
+ * FIXME  the OpenOCD "bin2char" utility currently doesn't handle
+ * binary files cleanly.  It's string oriented, and terminates them
+ * with a NUL character.  Better would be to generate the constants
+ * and let other code decide names, scoping, and other housekeeping.
+ */
+static /* unsigned const char xscale_debug_handler[] = ... */
+#include "xscale_debug.h"
+
 static char *const xscale_reg_list[] =
 {
        "XSCALE_MAINID",                /* 0 */
@@ -1594,7 +1605,7 @@ static int xscale_deassert_reset(target_t *target)
                 * force that, so writing new contents is reliable...
                 */
                address = xscale->handler_address;
-               for (unsigned binary_size = xscale_debug_handler_size;
+               for (unsigned binary_size = sizeof xscale_debug_handler - 1;
                                binary_size > 0;
                                binary_size -= buf_cnt, buffer += buf_cnt)
                {
@@ -3030,7 +3041,7 @@ static int xscale_target_create(struct target_s *target, Jim_Interp *interp)
 {
        xscale_common_t *xscale;
 
-       if (xscale_debug_handler_size > 0x800) {
+       if (sizeof xscale_debug_handler - 1 > 0x800) {
                LOG_ERROR("debug_handler.bin: larger than 2kb");
                return ERROR_FAIL;
        }
index 9d92550a6c7b84a5a5bb1dd71de6900a6941c5c7..a5d83ee675c7a4aafe3385ac3ff1d08d1497e8d9 100644 (file)
@@ -170,10 +170,4 @@ enum
 
 #define ERROR_XSCALE_NO_TRACE_DATA     (-1500)
 
-/* This XScale "debug handler" is loaded into the processor's
- * mini-ICache, which is 2K of code writable only via JTAG.
- */
-extern const uint8_t xscale_debug_handler[];
-extern const uint32_t xscale_debug_handler_size;
-
 #endif /* XSCALE_H */
diff --git a/src/target/xscale_debug.S b/src/target/xscale_debug.S
deleted file mode 100644 (file)
index 0a7b87d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-       .section        .rodata
-
-       .align          4
-       .global          xscale_debug_handler
-xscale_debug_handler:
-       .incbin         "xscale/debug_handler.bin"
-       .size           xscale_debug_handler, . - xscale_debug_handler
-
-       .align          4
-       .global          xscale_debug_handler_size
-xscale_debug_handler_size:
-       .word           . - xscale_debug_handler
-       .size           xscale_debug_handler_size, 4

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)