Commit 60ba4476 authored by ntfreak's avatar ntfreak
Browse files

- fix incorrectly registered function openocd_array2mem

- removed unused variables
- reformatted lpc288x.[ch]
- fixed helper/Makefile.am dependencies
- add correct svn props to added files

git-svn-id: svn://svn.berlios.de/openocd/trunk@829 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 722fcb8d
...@@ -141,12 +141,12 @@ int flash_register_commands(struct command_context_s *cmd_ctx) ...@@ -141,12 +141,12 @@ int flash_register_commands(struct command_context_s *cmd_ctx)
static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{ {
flash_bank_t *p;
if (argc != 1) { if (argc != 1) {
Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command"); Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command");
return JIM_ERR; return JIM_ERR;
} }
flash_bank_t *p;
int i = 0;
if (!flash_banks) if (!flash_banks)
{ {
...@@ -158,7 +158,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) ...@@ -158,7 +158,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{ {
Jim_Obj *elem=Jim_NewListObj(interp, NULL, 0); Jim_Obj *elem=Jim_NewListObj(interp, NULL, 0);
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "name", -1)); Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "name", -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, p->driver->name, -1)); Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, p->driver->name, -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "base", -1)); Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "base", -1));
...@@ -178,7 +177,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) ...@@ -178,7 +177,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK; return JIM_OK;
} }
int flash_init_drivers(struct command_context_s *cmd_ctx) int flash_init_drivers(struct command_context_s *cmd_ctx)
{ {
if (flash_banks) if (flash_banks)
......
This diff is collapsed.
...@@ -26,16 +26,15 @@ ...@@ -26,16 +26,15 @@
typedef struct lpc288x_flash_bank_s typedef struct lpc288x_flash_bank_s
{ {
u32 working_area; u32 working_area;
u32 working_area_size; u32 working_area_size;
/* chip id register */ /* chip id register */
u32 cidr; u32 cidr;
char * target_name; char * target_name;
u32 cclk; u32 cclk;
u32 sector_size_break; u32 sector_size_break;
} lpc288x_flash_bank_t; } lpc288x_flash_bank_t;
#endif /* lpc288x_H */ #endif /* lpc288x_H */
INCLUDES = -I$(top_srcdir)/src $(all_includes) INCLUDES = -I$(top_srcdir)/src $(all_includes) -I$(top_srcdir)/src/target
METASOURCES = AUTO METASOURCES = AUTO
AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@ AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@
noinst_LIBRARIES = libhelper.a noinst_LIBRARIES = libhelper.a
...@@ -10,20 +10,18 @@ CONFIGFILES = options.c jim.c ...@@ -10,20 +10,18 @@ CONFIGFILES = options.c jim.c
endif endif
libhelper_a_SOURCES = binarybuffer.c $(CONFIGFILES) configuration.c log.c command.c time_support.c \ libhelper_a_SOURCES = binarybuffer.c $(CONFIGFILES) configuration.c log.c command.c time_support.c \
replacements.c fileio.c replacements.c fileio.c startup_tcl.c
noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \
time_support.h replacements.h fileio.h \
jim.h
libhelper_a_SOURCES += startup_tcl.c noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \
time_support.h replacements.h fileio.h jim.h
noinst_PROGRAMS = bin2char noinst_PROGRAMS = bin2char
bin2char_SOURCES = bin2char.c bin2char_SOURCES = bin2char.c
# Convert .tcl to cfile # Convert .tcl to cfile
startup_tcl.c: bin2char startup.tcl startup_tcl.c: startup.tcl bin2char$(EXEEXT)
./bin2char startup_tcl < $(srcdir)/startup.tcl > startup_tcl.c ./bin2char$(EXEEXT) startup_tcl < $(srcdir)/$< > $@
# add startup_tcl.c to make clean list # add startup_tcl.c to make clean list
CLEANFILES = startup_tcl.c CLEANFILES = startup_tcl.c
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
#endif #endif
#include "replacements.h" #include "replacements.h"
#include "target.h"
#include "command.h" #include "command.h"
#include "configuration.h"
#include "log.h" #include "log.h"
#include "time_support.h" #include "time_support.h"
...@@ -44,6 +45,9 @@ Jim_Interp *interp = NULL; ...@@ -44,6 +45,9 @@ Jim_Interp *interp = NULL;
int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int run_command(command_context_t *context, command_t *c, char *words[], int num_words);
static void tcl_output(void *privData, const char *file, int line, const char *function, const char *string) static void tcl_output(void *privData, const char *file, int line, const char *function, const char *string)
{ {
Jim_Obj *tclOutput=(Jim_Obj *)privData; Jim_Obj *tclOutput=(Jim_Obj *)privData;
...@@ -178,7 +182,6 @@ command_t* register_command(command_context_t *context, command_t *parent, char ...@@ -178,7 +182,6 @@ command_t* register_command(command_context_t *context, command_t *parent, char
Jim_CreateCommand(interp, full_name, script_command, c, NULL); Jim_CreateCommand(interp, full_name, script_command, c, NULL);
free((void *)full_name); free((void *)full_name);
/* accumulate help text in Tcl helptext list. */ /* accumulate help text in Tcl helptext list. */
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
if (Jim_IsShared(helptext)) if (Jim_IsShared(helptext))
...@@ -207,7 +210,6 @@ int unregister_all_commands(command_context_t *context) ...@@ -207,7 +210,6 @@ int unregister_all_commands(command_context_t *context)
if (context == NULL) if (context == NULL)
return ERROR_OK; return ERROR_OK;
while(NULL != context->commands) while(NULL != context->commands)
{ {
c = context->commands; c = context->commands;
...@@ -277,7 +279,6 @@ int unregister_command(command_context_t *context, char *name) ...@@ -277,7 +279,6 @@ int unregister_command(command_context_t *context, char *name)
return ERROR_OK; return ERROR_OK;
} }
void command_output_text(command_context_t *context, const char *data) void command_output_text(command_context_t *context, const char *data)
{ {
if( context && context->output_handler && data ){ if( context && context->output_handler && data ){
...@@ -435,7 +436,6 @@ int command_run_line(command_context_t *context, char *line) ...@@ -435,7 +436,6 @@ int command_run_line(command_context_t *context, char *line)
return retval; return retval;
} }
int command_run_linef(command_context_t *context, char *format, ...) int command_run_linef(command_context_t *context, char *format, ...)
{ {
int retval=ERROR_FAIL; int retval=ERROR_FAIL;
...@@ -451,8 +451,6 @@ int command_run_linef(command_context_t *context, char *format, ...) ...@@ -451,8 +451,6 @@ int command_run_linef(command_context_t *context, char *format, ...)
return retval; return retval;
} }
void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv) void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv)
{ {
context->output_handler = output_handler; context->output_handler = output_handler;
...@@ -476,7 +474,6 @@ int command_done(command_context_t *context) ...@@ -476,7 +474,6 @@ int command_done(command_context_t *context)
return ERROR_OK; return ERROR_OK;
} }
/* find full path to file */ /* find full path to file */
static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv) static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{ {
...@@ -502,8 +499,6 @@ static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv) ...@@ -502,8 +499,6 @@ static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK; return JIM_OK;
} }
static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void *cookie) static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void *cookie)
{ {
size_t nbytes; size_t nbytes;
......
...@@ -76,14 +76,12 @@ extern int command_run_line(command_context_t *context, char *line); ...@@ -76,14 +76,12 @@ extern int command_run_line(command_context_t *context, char *line);
extern int command_run_linef(command_context_t *context, char *format, ...); extern int command_run_linef(command_context_t *context, char *format, ...);
extern void command_output_text(command_context_t *context, const char *data); extern void command_output_text(command_context_t *context, const char *data);
#define ERROR_COMMAND_CLOSE_CONNECTION (-600) #define ERROR_COMMAND_CLOSE_CONNECTION (-600)
#define ERROR_COMMAND_SYNTAX_ERROR (-601) #define ERROR_COMMAND_SYNTAX_ERROR (-601)
#define ERROR_COMMAND_NOTFOUND (-602) #define ERROR_COMMAND_NOTFOUND (-602)
extern int fast_and_dangerous; extern int fast_and_dangerous;
/* Integrate the JIM TCL interpretor into the command processing. */ /* Integrate the JIM TCL interpretor into the command processing. */
#include <stdarg.h> #include <stdarg.h>
#ifdef __ECOS #ifdef __ECOS
......
...@@ -970,7 +970,7 @@ static void Jim_InitExtension(Jim_Interp *interp) ...@@ -970,7 +970,7 @@ static void Jim_InitExtension(Jim_Interp *interp)
#ifdef JIM_EMBEDDED #ifdef JIM_EMBEDDED
Jim_Interp *ExportedJimCreateInterp(void); Jim_Interp *ExportedJimCreateInterp(void);
static void Jim_InitEmbedded(void) { static inline void Jim_InitEmbedded(void) {
Jim_Interp *i = ExportedJimCreateInterp(); Jim_Interp *i = ExportedJimCreateInterp();
Jim_InitExtension(i); Jim_InitExtension(i);
Jim_FreeInterp(i); Jim_FreeInterp(i);
......
...@@ -761,9 +761,6 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num, ...@@ -761,9 +761,6 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num,
} }
} }
void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{ {
int retval; int retval;
...@@ -872,7 +869,6 @@ void jtag_add_pathmove(int num_states, enum tap_state *path) ...@@ -872,7 +869,6 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
jtag_error=retval; jtag_error=retval;
} }
int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path) int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path)
{ {
jtag_command_t **last_cmd = jtag_get_last_command_p(); jtag_command_t **last_cmd = jtag_get_last_command_p();
...@@ -1040,7 +1036,6 @@ int MINIDRIVER(interface_jtag_add_reset)(int req_trst, int req_srst) ...@@ -1040,7 +1036,6 @@ int MINIDRIVER(interface_jtag_add_reset)(int req_trst, int req_srst)
(*last_cmd)->cmd.reset->trst = req_trst; (*last_cmd)->cmd.reset->trst = req_trst;
(*last_cmd)->cmd.reset->srst = req_srst; (*last_cmd)->cmd.reset->srst = req_srst;
return ERROR_OK; return ERROR_OK;
} }
...@@ -1120,7 +1115,6 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer) ...@@ -1120,7 +1115,6 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer)
} }
return bit_count; return bit_count;
} }
int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
...@@ -1631,7 +1625,6 @@ int jtag_init(struct command_context_s *cmd_ctx) ...@@ -1631,7 +1625,6 @@ int jtag_init(struct command_context_s *cmd_ctx)
return jtag_init_reset(cmd_ctx); return jtag_init_reset(cmd_ctx);
} }
static int default_khz(int khz, int *jtag_speed) static int default_khz(int khz, int *jtag_speed)
{ {
LOG_ERROR("Translation from khz to jtag_speed not implemented"); LOG_ERROR("Translation from khz to jtag_speed not implemented");
...@@ -1931,7 +1924,6 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char * ...@@ -1931,7 +1924,6 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_OK; return ERROR_OK;
} }
int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{ {
enum tap_state state; enum tap_state state;
...@@ -2007,7 +1999,6 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char ** ...@@ -2007,7 +1999,6 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **
} }
int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{ {
int i; int i;
...@@ -2051,7 +2042,7 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args) ...@@ -2051,7 +2042,7 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args)
scan_field_t *fields; scan_field_t *fields;
int num_fields; int num_fields;
int field_count = 0; int field_count = 0;
int i, j, e; int i, e;
long device; long device;
/* args[1] = device /* args[1] = device
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "tcl_server.h" #include "tcl_server.h"
#include "jim.h"
#include "log.h" #include "log.h"
#include "command.h" #include "command.h"
...@@ -34,15 +33,14 @@ ...@@ -34,15 +33,14 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#define TCL_SERVER_VERSION "TCL Server 0.1" #define TCL_SERVER_VERSION "TCL Server 0.1"
#define TCL_MAX_LINE (4096) #define TCL_MAX_LINE (4096)
typedef struct tcl_connection_s { typedef struct tcl_connection_s {
int tc_linedrop; int tc_linedrop;
int tc_lineoffset; int tc_lineoffset;
char tc_line[TCL_MAX_LINE]; char tc_line[TCL_MAX_LINE];
int tc_outerror; /* flag an output error */
int tc_outerror; /* flag an output error */
} tcl_connection_t; } tcl_connection_t;
extern Jim_Interp *interp; extern Jim_Interp *interp;
...@@ -64,137 +62,137 @@ static int tcl_closed(connection_t *connection); ...@@ -64,137 +62,137 @@ static int tcl_closed(connection_t *connection);
*/ */
int tcl_output(connection_t *connection, const void *data, ssize_t len) int tcl_output(connection_t *connection, const void *data, ssize_t len)
{ {
ssize_t wlen; ssize_t wlen;
tcl_connection_t *tclc; tcl_connection_t *tclc;
tclc = connection->priv; tclc = connection->priv;
if (tclc->tc_outerror) if (tclc->tc_outerror)
return ERROR_SERVER_REMOTE_CLOSED; return ERROR_SERVER_REMOTE_CLOSED;
wlen = write_socket(connection->fd, data, len); wlen = write_socket(connection->fd, data, len);
if (wlen == len) if (wlen == len)
return ERROR_OK; return ERROR_OK;
LOG_ERROR("error during write: %d != %d", (int)wlen, (int)len); LOG_ERROR("error during write: %d != %d", (int)wlen, (int)len);
tclc->tc_outerror = 1; tclc->tc_outerror = 1;
return ERROR_SERVER_REMOTE_CLOSED; return ERROR_SERVER_REMOTE_CLOSED;
} }
/* connections */ /* connections */
static int tcl_new_connection(connection_t *connection) static int tcl_new_connection(connection_t *connection)
{ {
tcl_connection_t *tclc; tcl_connection_t *tclc;
tclc = malloc(sizeof(tcl_connection_t)); tclc = malloc(sizeof(tcl_connection_t));
if (tclc == NULL) if (tclc == NULL)
return ERROR_CONNECTION_REJECTED; return ERROR_CONNECTION_REJECTED;
memset(tclc, 0, sizeof(tcl_connection_t)); memset(tclc, 0, sizeof(tcl_connection_t));
connection->priv = tclc; connection->priv = tclc;
return ERROR_OK; return ERROR_OK;
} }
static int tcl_input(connection_t *connection) static int tcl_input(connection_t *connection)
{ {
int retval; int retval;
int i; int i;
ssize_t rlen; ssize_t rlen;
const char *result; const char *result;
int reslen; int reslen;
tcl_connection_t *tclc; tcl_connection_t *tclc;
char in[256]; char in[256];
rlen = read_socket(connection->fd, &in, sizeof(in)); rlen = read_socket(connection->fd, &in, sizeof(in));
if (rlen <= 0) { if (rlen <= 0) {
if (rlen < 0) if (rlen < 0)
LOG_ERROR("error during read: %s", strerror(errno)); LOG_ERROR("error during read: %s", strerror(errno));
return ERROR_SERVER_REMOTE_CLOSED; return ERROR_SERVER_REMOTE_CLOSED;
} }
tclc = connection->priv; tclc = connection->priv;
if (tclc == NULL) if (tclc == NULL)
return ERROR_CONNECTION_REJECTED; return ERROR_CONNECTION_REJECTED;
/* push as much data into the line as possible */ /* push as much data into the line as possible */
for (i = 0; i < rlen; i++) for (i = 0; i < rlen; i++)
{ {
if (!isprint(in[i]) && !isspace(in[i])) if (!isprint(in[i]) && !isspace(in[i]))
{ {
/* drop this line */ /* drop this line */
tclc->tc_linedrop = 1; tclc->tc_linedrop = 1;
continue; continue;
} }
/* buffer the data */ /* buffer the data */
tclc->tc_line[tclc->tc_lineoffset] = in[i]; tclc->tc_line[tclc->tc_lineoffset] = in[i];
if (tclc->tc_lineoffset < TCL_MAX_LINE) if (tclc->tc_lineoffset < TCL_MAX_LINE)
tclc->tc_lineoffset++; tclc->tc_lineoffset++;
else else
tclc->tc_linedrop = 1; tclc->tc_linedrop = 1;
if (in[i] != '\n') if (in[i] != '\n')
continue; continue;
/* process the line */ /* process the line */
if (tclc->tc_linedrop) { if (tclc->tc_linedrop) {
#define ESTR "line too long\n" #define ESTR "line too long\n"
retval = tcl_output(connection, ESTR, sizeof(ESTR)); retval = tcl_output(connection, ESTR, sizeof(ESTR));
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
#undef ESTR #undef ESTR
} else { }
tclc->tc_line[tclc->tc_lineoffset-1] = '\0'; else {
retval = Jim_Eval(interp, tclc->tc_line); tclc->tc_line[tclc->tc_lineoffset-1] = '\0';
result = Jim_GetString(Jim_GetResult(interp), &reslen); retval = Jim_Eval(interp, tclc->tc_line);
retval = tcl_output(connection, result, reslen); result = Jim_GetString(Jim_GetResult(interp), &reslen);
if (retval != ERROR_OK) retval = tcl_output(connection, result, reslen);
return retval; if (retval != ERROR_OK)
if (memchr(result, '\n', reslen) == NULL) return retval;
tcl_output(connection, "\n", 1); if (memchr(result, '\n', reslen) == NULL)
} tcl_output(connection, "\n", 1);
tclc->tc_lineoffset = 0; }
tclc->tc_linedrop = 0;
} tclc->tc_lineoffset = 0;
tclc->tc_linedrop = 0;
return ERROR_OK; }
return ERROR_OK;
} }
static int tcl_closed(connection_t *connection) static int tcl_closed(connection_t *connection)
{ {
/* cleanup connection context */ /* cleanup connection context */
if (connection->priv) { if (connection->priv) {
free(connection->priv); free(connection->priv);
connection->priv = NULL; connection->priv = NULL;
} }