*.swp
src/startup.tcl
-startup_tcl.c
-xscale_debug.h
+startup_tcl.inc
+xscale_debug.inc
bin2char
bin2char.exe
libopenocd_la_SOURCES = \
hello.c \
- openocd.c \
- startup_tcl.c
+ openocd.c
noinst_HEADERS = \
hello.h \
EXTRA_DIST = $(STARTUP_TCL_SRCS)
-BUILT_SOURCES = startup.tcl
+BUILT_SOURCES = startup_tcl.inc
startup.tcl: $(STARTUP_TCL_SRCS)
cat $^ > $@
BIN2C = $(top_srcdir)/src/helper/bin2char.sh
-# Convert .tcl to cfile
-startup_tcl.c: startup.tcl $(BIN2C)
- $(BIN2C) openocd_startup_tcl < $< > $@ || rm -f $@
+# Convert .tcl to c-array
+startup_tcl.inc: startup.tcl $(BIN2C)
+ $(BIN2C) < $< > $@ || { rm -f $@; false; }
-# add startup_tcl.c to make clean list
-CLEANFILES = startup.tcl startup_tcl.c
+# add generated files to make clean list
+CLEANFILES = startup.tcl startup_tcl.inc
# we do not want generated file in the dist
dist-hook:
- rm -f $(distdir)/startup_tcl.c
+ rm -f $(distdir)/startup_tcl.inc
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
#!/bin/sh
-[ $# = 0 ] && {
- echo "Usage: $0 <varname>"
+[ $# != 0 ] && {
+ echo "Usage: $0"
echo
- echo "Read binary data from standard input and write it as a C character"
- echo "array <varname> to standard output. Add a final NULL for terminating."
+ echo "Read binary data from standard input and write it as a comma separated"
+ echo "list of hexadecimal byte values to standard ouput. The output is usable"
+ echo "as a C array initializer. It is terminated with a comma so it can be"
+ echo "continued e.g. for zero termination."
exit 1
}
echo "/* Autogenerated with $0 */"
-echo "unsigned const char $1[] = {"
od -v -A n -t x1 | sed 's/ *\(..\) */0x\1,/g'
-echo "0 /* NULL-terminated */ };"
#define OPENOCD_VERSION \
"Open On-Chip Debugger " VERSION RELSTR " (" PKGBLDDATE ")"
+static const char openocd_startup_tcl[] = {
+#include "startup_tcl.inc"
+0 /* Terminate with zero */
+};
+
/* Give scripts and TELNET a way to find out what version this is */
static int jim_version_command(Jim_Interp *interp, int argc,
Jim_Obj * const *argv)
log_init();
LOG_DEBUG("log_init: complete");
- const char *startup = openocd_startup_tcl;
- struct command_context *cmd_ctx = command_init(startup, interp);
+ struct command_context *cmd_ctx = command_init(openocd_startup_tcl, interp);
/* register subsystem commands */
typedef int (*command_registrant_t)(struct command_context *cmd_ctx_value);
*/
int openocd_main(int argc, char *argv[]);
-/** provides a hard-coded command environment setup */
-extern const char openocd_startup_tcl[];
-
#endif
startup.tcl \
$(wildcard $(srcdir)/xscale/*)
-DEBUG_HEADER = xscale_debug.h
+DEBUG_HEADER = xscale_debug.inc
BUILT_SOURCES = $(DEBUG_HEADER)
CLEANFILES = $(DEBUG_HEADER)
-$(DEBUG_HEADER): $(BIN2C) $(DEBUG_HANDLER)
- $(BIN2C) < $(DEBUG_HANDLER) xscale_debug_handler > xscale_debug.h
+$(DEBUG_HEADER): $(DEBUG_HANDLER) $(BIN2C)
+ $(BIN2C) < $< > $@ || { rm -f $@; false; }
METASOURCES = AUTO
noinst_LTLIBRARIES = libtarget.la
/* 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 const uint8_t xscale_debug_handler[] = {
+#include "xscale_debug.inc"
+};
static char *const xscale_reg_list[] = {
"XSCALE_MAINID", /* 0 */
* coprocessors, trace data, etc.
*/
address = xscale->handler_address;
- for (unsigned binary_size = sizeof xscale_debug_handler - 1;
+ for (unsigned binary_size = sizeof xscale_debug_handler;
binary_size > 0;
binary_size -= buf_cnt, buffer += buf_cnt) {
uint32_t cache_line[8];
{
struct xscale_common *xscale;
- if (sizeof xscale_debug_handler - 1 > 0x800) {
+ if (sizeof xscale_debug_handler > 0x800) {
LOG_ERROR("debug_handler.bin: larger than 2kb");
return ERROR_FAIL;
}