Commit 0cba0d4d authored by ntfreak's avatar ntfreak
Browse files

- remove target specific variant and use target->variant member

- fix build warning in cortex_m3
- code cleanup - remove trailing lf and convert c++ comments

git-svn-id: svn://svn.berlios.de/openocd/trunk@1238 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 846a2589
......@@ -44,7 +44,6 @@ enum fileio_type
FILEIO_BINARY,
};
enum fileio_access
{
FILEIO_READ, /* open for reading, position at beginning */
......
......@@ -413,7 +413,6 @@ void alive_sleep(int ms)
}
}
void busy_sleep(int ms)
{
long long then;
......
......@@ -163,6 +163,5 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]
exit(-1);
}
return ERROR_OK;
}
......@@ -525,7 +525,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
int tclapi_register_commands()
{
register_jim("ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing");
......
......@@ -43,10 +43,8 @@ typedef unsigned int u32;
typedef unsigned long long u64;
#endif
typedef struct jtag_tap_s jtag_tap_t;
/* DANGER!!!! here be dragons! Note that the pointer in
* memory might be unaligned. On some CPU's, i.e. ARM7,
* the 2 lsb are ignored for 32 bit access, on others
......@@ -59,26 +57,25 @@ typedef struct jtag_tap_s jtag_tap_t;
#define be_to_h_u16(x) ((u16)((x)[1] | (x)[0] << 8))
#define h_u32_to_le(buf, val) do {\
(buf)[3] = ((val) & 0xff000000) >> 24;\
(buf)[2] = ((val) & 0x00ff0000) >> 16;\
(buf)[1] = ((val) & 0x0000ff00) >> 8;\
(buf)[0] = ((val) & 0x000000ff);\
(buf)[3] = ((val) & 0xff000000) >> 24;\
(buf)[2] = ((val) & 0x00ff0000) >> 16;\
(buf)[1] = ((val) & 0x0000ff00) >> 8;\
(buf)[0] = ((val) & 0x000000ff);\
} while (0)
#define h_u32_to_be(buf, val) do {\
(buf)[0] = ((val) & 0xff000000) >> 24;\
(buf)[1] = ((val) & 0x00ff0000) >> 16;\
(buf)[2] = ((val) & 0x0000ff00) >> 8;\
(buf)[3] = ((val) & 0x000000ff);\
(buf)[0] = ((val) & 0xff000000) >> 24;\
(buf)[1] = ((val) & 0x00ff0000) >> 16;\
(buf)[2] = ((val) & 0x0000ff00) >> 8;\
(buf)[3] = ((val) & 0x000000ff);\
} while (0)
#define h_u16_to_le(buf, val) do {\
(buf)[1] = ((val) & 0xff00) >> 8;\
(buf)[0] = ((val) & 0x00ff) >> 0;\
(buf)[1] = ((val) & 0xff00) >> 8;\
(buf)[0] = ((val) & 0x00ff) >> 0;\
} while (0)
#define h_u16_to_be(buf, val) do {\
(buf)[0] = ((val) & 0xff00) >> 8;\
(buf)[1] = ((val) & 0x00ff) >> 0;\
(buf)[0] = ((val) & 0xff00) >> 8;\
(buf)[1] = ((val) & 0x00ff) >> 0;\
} while (0)
#endif /* TYPES_H */
......@@ -39,7 +39,6 @@
bitbang_interface_t *bitbang_interface;
/* DANGER!!!! clock absolutely *MUST* be 0 in idle or reset won't work!
*
* Set this to 1 and str912 reset halt will fail.
......@@ -316,4 +315,3 @@ int bitbang_execute_queue(void)
return retval;
}
......@@ -34,7 +34,6 @@
#include <stdlib.h>
#include <unistd.h>
bitq_interface_t *bitq_interface; /* low level bit queue interface */
bitq_state_t bitq_in_state; /* state of input queue */
......@@ -42,7 +41,6 @@ bitq_state_t bitq_in_state; /* state of input queue */
u8 *bitq_in_buffer; /* buffer dynamically reallocated as needed */
unsigned long bitq_in_bufsize=32; /* min. buffer size */
/*
* input queue processing does not use jtag_read_buffer() to avoid unnecessary overhead
* also the buffer for incomming data is reallocated only if necessary
......@@ -129,8 +127,6 @@ void bitq_in_proc(void)
}
}
void bitq_io(int tms, int tdi, int tdo_req)
{
bitq_interface->out(tms, tdi, tdo_req);
......@@ -138,7 +134,6 @@ void bitq_io(int tms, int tdi, int tdo_req)
if (bitq_interface->in_rdy()) bitq_in_proc();
}
void bitq_end_state(enum tap_state state)
{
if (state==-1) return;
......@@ -149,7 +144,6 @@ void bitq_end_state(enum tap_state state)
end_state = state;
}
void bitq_state_move(enum tap_state new_state)
{
int i=0;
......@@ -170,7 +164,6 @@ void bitq_state_move(enum tap_state new_state)
cur_state = new_state;
}
void bitq_path_move(pathmove_command_t *cmd)
{
int i;
......@@ -189,7 +182,6 @@ void bitq_path_move(pathmove_command_t *cmd)
end_state = cur_state;
}
void bitq_runtest(int num_cycles)
{
int i;
......@@ -205,7 +197,6 @@ void bitq_runtest(int num_cycles)
if (cur_state != end_state) bitq_state_move(end_state);
}
void bitq_scan_field(scan_field_t *field, int pause)
{
int bit_cnt;
......@@ -245,7 +236,6 @@ void bitq_scan_field(scan_field_t *field, int pause)
}
}
void bitq_scan(scan_command_t *cmd)
{
int i;
......@@ -258,7 +248,6 @@ void bitq_scan(scan_command_t *cmd)
bitq_scan_field(&cmd->fields[i], 1);
}
int bitq_execute_queue(void)
{
jtag_command_t *cmd = jtag_command_queue; /* currently processed command */
......@@ -356,7 +345,6 @@ int bitq_execute_queue(void)
return bitq_in_state.status;
}
void bitq_cleanup(void)
{
if (bitq_in_buffer!=NULL)
......
......@@ -26,7 +26,6 @@
#include "jtag.h"
#include "bitbang.h"
int dummy_speed(int speed);
int dummy_register_commands(struct command_context_s *cmd_ctx);
int dummy_init(void);
......@@ -65,7 +64,6 @@ int dummy_read(void)
return 1;
}
void dummy_write(int tck, int tms, int tdi)
{
}
......@@ -74,7 +72,6 @@ void dummy_reset(int trst, int srst)
{
}
int dummy_speed(int speed)
{
return ERROR_OK;
......@@ -85,7 +82,6 @@ int dummy_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
int dummy_init(void)
{
bitbang_interface = &dummy_bitbang;
......@@ -98,8 +94,6 @@ int dummy_quit(void)
return ERROR_OK;
}
void dummy_led(int on)
{
}
......@@ -250,8 +250,6 @@ jtag_interface_t *jtag = NULL;
jtag_interface_t *jtag_interface = NULL;
int jtag_speed = 0;
/* forward declarations */
void jtag_add_pathmove(int num_states, enum tap_state *path);
void jtag_add_runtest(int num_cycles, enum tap_state endstate);
......@@ -279,14 +277,12 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
jtag_tap_t *jtag_AllTaps(void)
{
return jtag_all_taps;
};
int
jtag_NumTotalTaps(void)
int jtag_NumTotalTaps(void)
{
jtag_tap_t *t;
int n;
......@@ -300,8 +296,7 @@ jtag_NumTotalTaps(void)
return n;
}
int
jtag_NumEnabledTaps(void)
int jtag_NumEnabledTaps(void)
{
jtag_tap_t *t;
int n;
......@@ -345,8 +340,7 @@ jtag_tap_t *jtag_TapByString( const char *s )
return t;
}
jtag_tap_t *
jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *o )
jtag_tap_t * jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *o )
{
jtag_tap_t *t;
const char *cp;
......@@ -365,8 +359,7 @@ jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *o )
}
/* returns a pointer to the n-th device in the scan chain */
jtag_tap_t *
jtag_TapByAbsPosition( int n )
jtag_tap_t * jtag_TapByAbsPosition( int n )
{
int orig_n;
jtag_tap_t *t;
......@@ -381,7 +374,6 @@ jtag_TapByAbsPosition( int n )
return t;
}
int jtag_register_event_callback(int (*callback)(enum jtag_event event, void *priv), void *priv)
{
jtag_event_callback_t **callbacks_p = &jtag_event_callbacks;
......@@ -463,7 +455,6 @@ jtag_command_t** jtag_get_last_command_p(void)
return last_comand_pointer;
}
void* cmd_queue_alloc(size_t size)
{
cmd_queue_page_t **p_page = &cmd_queue_pages;
......@@ -498,10 +489,9 @@ void* cmd_queue_alloc(size_t size)
};
#define ALIGN_SIZE (sizeof(union worse_case_align))
// The alignment process.
/* The alignment process. */
size = (size + ALIGN_SIZE -1) & (~(ALIGN_SIZE-1));
// Done...
/* Done... */
if (*p_page)
{
......@@ -652,7 +642,6 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
(*last_cmd)->cmd.scan->fields[nth_tap].out_value = buf_set_ones(cmd_queue_alloc(CEIL(scan_size, 8)), scan_size);
(*last_cmd)->cmd.scan->fields[nth_tap].out_mask = NULL;
tap->bypass = 1;
}
/* update device information */
......@@ -1023,7 +1012,6 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
jtag_prelude1();
retval=interface_jtag_add_pathmove(num_states, path);
cmd_queue_cur_state = path[num_states - 1];
if (retval!=ERROR_OK)
......@@ -1805,8 +1793,7 @@ jtag_tap_configure_cmd( Jim_GetOptInfo *goi,
return JIM_OK;
}
static int
jim_newtap_cmd( Jim_GetOptInfo *goi )
static int jim_newtap_cmd( Jim_GetOptInfo *goi )
{
jtag_tap_t *pTap;
jtag_tap_t **ppTap;
......@@ -1832,16 +1819,15 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
{ .name = NULL , .value = -1 },
};
pTap = malloc( sizeof(jtag_tap_t) );
memset( pTap, 0, sizeof(*pTap) );
if( !pTap ){
Jim_SetResult_sprintf( goi->interp, "no memory");
return JIM_ERR;
}
//
// we expect CHIP + TAP + OPTIONS
//
/*
* we expect CHIP + TAP + OPTIONS
* */
if( goi->argc < 3 ){
Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ....");
return JIM_ERR;
......@@ -1852,7 +1838,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
Jim_GetOpt_String( goi, &cp, NULL );
pTap->tapname = strdup(cp);
// name + dot + name + null
/* name + dot + name + null */
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1;
cp = malloc( x );
sprintf( cp, "%s.%s", pTap->chip, pTap->tapname );
......@@ -1861,16 +1847,15 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc);
// default is enabled
/* default is enabled */
pTap->enabled = 1;
// deal with options
/* deal with options */
#define NTREQ_IRLEN 1
#define NTREQ_IRCAPTURE 2
#define NTREQ_IRMASK 4
// clear them as we find them
/* clear them as we find them */
reqbits = (NTREQ_IRLEN | NTREQ_IRCAPTURE | NTREQ_IRMASK);
while( goi->argc ){
......@@ -1921,7 +1906,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
return e;
}
if( (w < 0) || (w > 0xffff) ){
// wacky value
/* wacky value */
Jim_SetResult_sprintf( goi->interp, "option: %s - wacky value: %d (0x%x)",
n->name, (int)(w), (int)(w));
return JIM_ERR;
......@@ -1940,17 +1925,17 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
reqbits &= (~(NTREQ_IRCAPTURE));
break;
}
} // switch(n->value)
} // while( goi->argc )
} /* switch(n->value) */
} /* while( goi->argc ) */
// Did we get all the options?
/* Did we get all the options? */
if( reqbits ){
// no
Jim_SetResult_sprintf( goi->interp,
"newtap: %s missing required parameters",
pTap->dotted_name);
// fixme: Tell user what is missing :-(
// no memory leaks pelase
/* TODO: Tell user what is missing :-( */
/* no memory leaks pelase */
free(((void *)(pTap->expected_ids)));
free(((void *)(pTap->chip)));
free(((void *)(pTap->tapname)));
......@@ -1976,7 +1961,6 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
pTap->bypass = 1;
jtag_register_event_callback(jtag_reset_callback, pTap );
ppTap = &(jtag_all_taps);
......@@ -1995,13 +1979,10 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
(*ppTap)->ir_capture_value,
(*ppTap)->ir_capture_mask );
return ERROR_OK;
}
static int
jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
static int jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
{
Jim_GetOptInfo goi;
int e;
......@@ -2034,7 +2015,7 @@ jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
};
context = Jim_GetAssocData(interp, "context");
// go past the command
/* go past the command */
Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
e = Jim_GetOpt_Nvp( &goi, jtag_cmds, &n );
......@@ -2045,9 +2026,9 @@ jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
Jim_SetEmptyResult( goi.interp );
switch( n->value ){
case JTAG_CMD_INTERFACE:
// return the name of the interface
// TCL code might need to know the exact type...
// FUTURE: we allow this as a means to "set" the interface.
/* return the name of the interface */
/* TCL code might need to know the exact type... */
/* FUTURE: we allow this as a means to "set" the interface. */
if( goi.argc != 0 ){
Jim_WrongNumArgs( goi.interp, 1, goi.argv-1, "(no params)");
return JIM_ERR;
......@@ -2142,7 +2123,6 @@ jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
}
}
return JIM_ERR;
}
......@@ -2203,8 +2183,6 @@ int jtag_interface_init(struct command_context_s *cmd_ctx)
if (jtag_interface->init() != ERROR_OK)
return ERROR_JTAG_INIT_FAILED;
jtag = jtag_interface;
return ERROR_OK;
}
......@@ -2216,7 +2194,6 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx)
LOG_DEBUG("Init JTAG chain");
tap = jtag_NextEnabledTap(NULL);
if( tap == NULL ){
LOG_ERROR("There are no enabled taps?");
......@@ -2390,14 +2367,14 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
int e;
char buf[1024];
Jim_Obj *newargs[ 10 ];
//
// CONVERT SYNTAX
//
// argv[-1] = command
// argv[ 0] = ir length
// argv[ 1] = ir capture
// argv[ 2] = ir mask
// argv[ 3] = not actually used by anything but in the docs
/*
* CONVERT SYNTAX
* argv[-1] = command
* argv[ 0] = ir length
* argv[ 1] = ir capture
* argv[ 2] = ir mask
* argv[ 3] = not actually used by anything but in the docs
*/
if( argc < 4 ){
command_print( cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax");
......@@ -2413,8 +2390,6 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
command_print( cmd_ctx, "jtag newtap stm32 boundry ....., and the tap: \"stm32.boundery\"");
command_print( cmd_ctx, "And then refer to the taps by the dotted name.");
newargs[0] = Jim_NewStringObj( interp, "jtag", -1 );
newargs[1] = Jim_NewStringObj( interp, "newtap", -1 );
sprintf( buf, "chip%d", jtag_NumTotalTaps() );
......@@ -2441,8 +2416,6 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
Jim_GetString( newargs[8], NULL ),
Jim_GetString( newargs[9], NULL ) );
e = jim_jtag_command( interp, 10, newargs );
if( e != JIM_OK ){
command_print( cmd_ctx, "%s", Jim_GetString( Jim_GetResult(interp), NULL ) );
......@@ -2450,7 +2423,6 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
return e;
}
int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
jtag_tap_t *tap;
......@@ -2835,7 +2807,6 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args)
Jim_GetLong(interp, args[i], &bits);
str = Jim_GetString(args[i+1], &len);
fields[field_count].tap = tap;
fields[field_count].num_bits = bits;
fields[field_count].out_value = malloc(CEIL(bits, 8));
......@@ -2904,7 +2875,6 @@ int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd
return ERROR_OK;
}
int jtag_power_dropout(int *dropout)
{
return jtag->power_dropout(dropout);
......@@ -2945,4 +2915,3 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
Jim_Nvp_value2name_simple( nvp_jtag_tap_event, e)->name);
}
}
......@@ -78,11 +78,10 @@ typedef struct scan_field_s
/* in_check_value/mask, in_handler_error_handler, in_handler_priv can be used by the in handler, otherwise they contain garbage */
u8 *in_check_value; /* used to validate scan results */
u8 *in_check_mask; /* check specified bits against check_value */
in_handler_t in_handler; /* process received buffer using this handler */
in_handler_t in_handler;/* process received buffer using this handler */
void *in_handler_priv; /* additional information for the in_handler */
} scan_field_t;
enum scan_type
{
/* IN: from device to host, OUT: from host to device */
......@@ -158,12 +157,12 @@ typedef struct jtag_command_s
extern jtag_command_t *jtag_command_queue;
// forward declaration
/* forward declaration */
typedef struct jtag_tap_event_action_s jtag_tap_event_action_t;
// this is really: typedef jtag_tap_t
// But - the typedef is done in "types.h"
// due to "forward decloration reasons"
/* this is really: typedef jtag_tap_t */
/* But - the typedef is done in "types.h" */
/* due to "forward decloration reasons" */
struct jtag_tap_s
{
const char *chip;
......@@ -188,22 +187,21 @@ struct jtag_tap_s
};
extern jtag_tap_t *jtag_AllTaps(void);
extern jtag_tap_t *jtag_TapByPosition(int n);
extern jtag_tap_t *jtag_TapByPosition( int n );
extern jtag_tap_t *jtag_TapByString( const char *dotted_name );
extern jtag_tap_t *jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *obj );
extern jtag_tap_t *jtag_TapByAbsPosition( int abs_position );
extern jtag_tap_t *jtag_TapByPosition(int n);
extern jtag_tap_t *jtag_TapByString(const char *dotted_name);
extern jtag_tap_t *jtag_TapByJimObj(Jim_Interp *interp, Jim_Obj *obj);
extern jtag_tap_t *jtag_TapByAbsPosition(int abs_position);
extern int jtag_NumEnabledTaps(void);
extern int jtag_NumTotalTaps(void);
static __inline__ jtag_tap_t *
jtag_NextEnabledTap( jtag_tap_t *p )
{
if( p == NULL ){
// start at the head of list
/* start at the head of list */
p = jtag_AllTaps();
} else {
// start *after* this one
/* start *after* this one */
p = p->next_tap;
}
while( p ){
......@@ -216,9 +214,6 @@ jtag_NextEnabledTap( jtag_tap_t *p )
return p;
}
enum reset_line_mode
{
LINE_OPEN_DRAIN = 0x0,
......@@ -440,8 +435,6 @@ extern int interface_jtag_add_end_state(enum tap_state endstate);
extern void jtag_add_sleep(u32 us);
extern int interface_jtag_add_sleep(u32 us);
/*
* For software FIFO implementations, the queued commands can be executed
* during this call or earlier. A sw queue might decide to push out
......@@ -468,7 +461,6 @@ extern int interface_jtag_execute_queue(void);
extern int jtag_power_dropout(int *dropout);
extern int jtag_srst_asserted(int *srst_asserted);
/* JTAG support functions */
extern void jtag_set_check_value(scan_field_t *field, u8 *value, u8 *mask, error_handler_t *in_error_handler);
extern enum scan_type jtag_scan_type(scan_command_t *cmd);
......@@ -494,8 +486,6 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e);
#define ERROR_JTAG_QUEUE_FAILED (-104)
#define ERROR_JTAG_DEVICE_ERROR (-107)
/* this allows JTAG devices to implement the entire jtag_xxx() layer in hw/sw */
#ifdef HAVE_JTAG_MINIDRIVER_H
/* Here a #define MINIDRIVER() and an inline version of hw fifo interface_jtag_add_dr_out can be defined */
......@@ -527,9 +517,6 @@ extern void interface_jtag_add_dr_out(jtag_tap_t *tap,
enum tap_state end_state);
#endif
static __inline__ void jtag_add_dr_out(jtag_tap_t *tap,
int num_fields,