- apply correct formatting to openocd.c
- Thanks Charles Hardin git-svn-id: svn://svn.berlios.de/openocd/trunk@770 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
9103bbbcb5
commit
31e2500259
|
@ -151,8 +151,7 @@ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
|
|||
LOG_DEBUG("jtag interface init complete");
|
||||
|
||||
/* Try to initialize & examine the JTAG chain at this point, but
|
||||
* continue startup regardless
|
||||
*/
|
||||
* continue startup regardless */
|
||||
if (jtag_init(cmd_ctx) == ERROR_OK)
|
||||
{
|
||||
LOG_DEBUG("jtag init complete");
|
||||
|
@ -185,7 +184,6 @@ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
Jim_Interp *interp;
|
||||
command_context_t *active_cmd_ctx;
|
||||
|
||||
|
@ -205,7 +203,7 @@ static int new_int_array_element(Jim_Interp * interp, const char *varname, int i
|
|||
Jim_DecrRefCount(interp, nameObjPtr);
|
||||
Jim_DecrRefCount(interp, valObjPtr);
|
||||
free(namebuf);
|
||||
// printf( "%s = 0%08x\n", namebuf, val );
|
||||
/* printf( "%s = 0%08x\n", namebuf, val ); */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -261,32 +259,24 @@ static int Jim_Command_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *a
|
|||
width = 4;
|
||||
break;
|
||||
default:
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
"Invalid width param, must be 8/16/32", NULL );
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp), "Invalid width param, must be 8/16/32", NULL );
|
||||
return JIM_ERR;
|
||||
}
|
||||
if (len == 0) {
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
"mem2array: zero width read?", NULL );
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings(interp, Jim_GetResult(interp), "mem2array: zero width read?", NULL);
|
||||
return JIM_ERR;
|
||||
}
|
||||
if ((addr + (len * width)) < addr) {
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
"mem2array: addr + len - wraps to zero?", NULL );
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings(interp, Jim_GetResult(interp), "mem2array: addr + len - wraps to zero?", NULL);
|
||||
return JIM_ERR;
|
||||
}
|
||||
/* absurd transfer size? */
|
||||
if (len > 65536) {
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
"mem2array: absurd > 64K item request", NULL );
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings(interp, Jim_GetResult(interp), "mem2array: absurd > 64K item request", NULL);
|
||||
return JIM_ERR;
|
||||
}
|
||||
|
||||
|
@ -296,14 +286,9 @@ static int Jim_Command_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *a
|
|||
/* all is well */
|
||||
} else {
|
||||
char buf[100];
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
sprintf( buf,
|
||||
"mem2array address: 0x%08x is not aligned for %d byte reads",
|
||||
addr, width );
|
||||
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
buf , NULL );
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
sprintf(buf, "mem2array address: 0x%08x is not aligned for %d byte reads", addr, width);
|
||||
Jim_AppendStrings(interp, Jim_GetResult(interp), buf , NULL);
|
||||
return JIM_ERR;
|
||||
}
|
||||
|
||||
|
@ -316,7 +301,6 @@ static int Jim_Command_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *a
|
|||
/* assume ok */
|
||||
e = JIM_OK;
|
||||
while (len) {
|
||||
|
||||
/* Slurp... in buffer size chunks */
|
||||
|
||||
count = len; /* in objects.. */
|
||||
|
@ -324,20 +308,13 @@ static int Jim_Command_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *a
|
|||
count = (sizeof(buffer)/width);
|
||||
}
|
||||
|
||||
retval = target->type->read_memory( target,
|
||||
addr,
|
||||
width,
|
||||
count,
|
||||
buffer );
|
||||
retval = target->type->read_memory( target, addr, width, count, buffer );
|
||||
|
||||
if (retval != ERROR_OK) {
|
||||
/* BOO !*/
|
||||
LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed",
|
||||
addr, width, count );
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings( interp, Jim_GetResult(interp),
|
||||
"mem2array: cannot read memory", NULL );
|
||||
LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count);
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
Jim_AppendStrings(interp, Jim_GetResult(interp), "mem2array: cannot read memory", NULL);
|
||||
e = JIM_ERR;
|
||||
len = 0;
|
||||
} else {
|
||||
|
@ -359,8 +336,8 @@ static int Jim_Command_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *a
|
|||
len -= count;
|
||||
}
|
||||
}
|
||||
Jim_SetResult(interp,
|
||||
Jim_NewEmptyStringObj(interp));
|
||||
|
||||
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
|
||||
|
||||
return JIM_OK;
|
||||
}
|
||||
|
@ -373,11 +350,8 @@ static void tcl_output(void *privData, const char *file, int line, const char *f
|
|||
}
|
||||
|
||||
/* try to execute as Jim command, otherwise fall back to standard command.
|
||||
|
||||
Note that even if the Jim command caused an error, then we succeeded
|
||||
to execute it, hence this fn pretty much always returns ERROR_OK.
|
||||
|
||||
*/
|
||||
* Note that even if the Jim command caused an error, then we succeeded
|
||||
* to execute it, hence this fn pretty much always returns ERROR_OK. */
|
||||
int jim_command(command_context_t *context, char *line)
|
||||
{
|
||||
int retval=ERROR_OK;
|
||||
|
@ -389,8 +363,7 @@ int jim_command(command_context_t *context, char *line)
|
|||
if (retcode == JIM_ERR) {
|
||||
int len, i;
|
||||
|
||||
LOG_USER_N("Runtime error, file \"%s\", line %d:" JIM_NL,
|
||||
interp->errorFileName, interp->errorLine);
|
||||
LOG_USER_N("Runtime error, file \"%s\", line %d:" JIM_NL, interp->errorFileName, interp->errorLine);
|
||||
LOG_USER_N(" %s" JIM_NL,
|
||||
Jim_GetString(interp->result, NULL));
|
||||
Jim_ListLength(interp, interp->stackTrace, &len);
|
||||
|
@ -400,18 +373,15 @@ int jim_command(command_context_t *context, char *line)
|
|||
|
||||
Jim_ListIndex(interp, interp->stackTrace, i, &objPtr, JIM_NONE);
|
||||
proc = Jim_GetString(objPtr, NULL);
|
||||
Jim_ListIndex(interp, interp->stackTrace, i+1, &objPtr,
|
||||
JIM_NONE);
|
||||
Jim_ListIndex(interp, interp->stackTrace, i+1, &objPtr, JIM_NONE);
|
||||
file = Jim_GetString(objPtr, NULL);
|
||||
Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr,
|
||||
JIM_NONE);
|
||||
Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr, JIM_NONE);
|
||||
line = Jim_GetString(objPtr, NULL);
|
||||
LOG_USER_N("In procedure '%s' called at file \"%s\", line %s" JIM_NL,
|
||||
proc, file, line);
|
||||
LOG_USER_N("In procedure '%s' called at file \"%s\", line %s" JIM_NL, proc, file, line);
|
||||
}
|
||||
} else if (retcode == JIM_EXIT) {
|
||||
// ignore.
|
||||
//exit(Jim_GetExitCode(interp));
|
||||
/* ignore. */
|
||||
/* exit(Jim_GetExitCode(interp)); */
|
||||
} else {
|
||||
if (reslen) {
|
||||
int i;
|
||||
|
@ -443,7 +413,7 @@ static int Jim_Command_openocd_ignore(Jim_Interp *interp, int argc, Jim_Obj *con
|
|||
|
||||
if (startLoop)
|
||||
{
|
||||
// We don't know whether or not the telnet/gdb server is running...
|
||||
/* We don't know whether or not the telnet/gdb server is running... */
|
||||
target_call_timer_callbacks_now();
|
||||
}
|
||||
|
||||
|
@ -510,7 +480,7 @@ static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void *
|
|||
}
|
||||
|
||||
if (!active_cmd_ctx) {
|
||||
/* FIXME: Where should this go? */
|
||||
/* TODO: Where should this go? */
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -603,7 +573,7 @@ void initJim2(void)
|
|||
Jim_Eval(interp, "source [find tcl/commands.tcl]");
|
||||
}
|
||||
|
||||
command_context_t *setup_command_handler()
|
||||
command_context_t *setup_command_handler(void)
|
||||
{
|
||||
command_context_t *cmd_ctx;
|
||||
|
||||
|
@ -655,11 +625,9 @@ command_context_t *setup_command_handler()
|
|||
return cmd_ctx;
|
||||
}
|
||||
|
||||
/*
|
||||
normally this is the main() function entry, but if OpenOCD is linked
|
||||
into application, then this fn will not be invoked, but rather that
|
||||
application will have it's own implementation of main().
|
||||
*/
|
||||
/* normally this is the main() function entry, but if OpenOCD is linked
|
||||
* into application, then this fn will not be invoked, but rather that
|
||||
* application will have it's own implementation of main(). */
|
||||
int openocd_main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef JIM_EMBEDDED
|
||||
|
|
Loading…
Reference in New Issue