* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007-2009 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2008, Duane Ellis *
extern target_type_t arm926ejs_target;
extern target_type_t fa526_target;
extern target_type_t feroceon_target;
+extern target_type_t dragonite_target;
extern target_type_t xscale_target;
extern target_type_t cortexm3_target;
extern target_type_t cortexa8_target;
&arm926ejs_target,
&fa526_target,
&feroceon_target,
+ &dragonite_target,
&xscale_target,
&cortexm3_target,
&cortexa8_target,
return cp;
}
-static int max_target_number(void)
-{
- target_t *t;
- int x;
-
- x = -1;
- t = all_targets;
- while (t) {
- if (x < t->target_number) {
- x = (t->target_number) + 1;
- }
- t = t->next;
- }
- return x;
-}
-
/* determine the number of the new target */
static int new_target_number(void)
{
return target;
}
+ /* It's OK to remove this fallback sometime after August 2010 or so */
+
/* no match, try as number */
unsigned num;
if (parse_uint(id, &num) != ERROR_OK)
return NULL;
for (target = all_targets; target; target = target->next) {
- if (target->target_number == (int)num)
+ if (target->target_number == (int)num) {
+ LOG_WARNING("use '%s' as target identifier, not '%u'",
+ target->cmd_name, num);
return target;
+ }
}
return NULL;
return NULL;
}
-int get_num_by_target(target_t *query_target)
-{
- return query_target->target_number;
-}
-
target_t* get_current_target(command_context_t *cmd_ctx)
{
target_t *target = get_target_by_num(cmd_ctx->current_target);
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
+ if (!target->type->soft_reset_halt_imp) {
+ LOG_ERROR("Target %s does not support soft_reset_halt",
+ target->cmd_name);
+ return ERROR_FAIL;
+ }
return target->type->soft_reset_halt_imp(target);
}
size -= aligned;
}
+ /*prevent byte access when possible (avoid AHB access limitations in some cases)*/
+ if(size >=2)
+ {
+ int aligned = size - (size%2);
+ retval = target_read_memory(target, address, 2, aligned / 2, buffer);
+ if (retval != ERROR_OK)
+ return retval;
+
+ buffer += aligned;
+ address += aligned;
+ size -= aligned;
+ }
/* handle tail writes of less than 4 bytes */
if (size > 0)
{
break;
}
image_size += length;
- command_print(cmd_ctx, "%u byte written at address 0x%8.8" PRIx32 "",
+ command_print(cmd_ctx, "%u bytes written at address 0x%8.8" PRIx32 "",
(unsigned int)length,
image.sections[i].base_address + offset);
}
void target_handle_event(target_t *target, enum target_event e)
{
target_event_action_t *teap;
- int done;
-
- teap = target->event_action;
- done = 0;
- while (teap) {
+ for (teap = target->event_action; teap != NULL; teap = teap->next) {
if (teap->event == e) {
- done = 1;
LOG_DEBUG("target: (%d) %s (%s) event: %d (%s) action: %s",
target->target_number,
target->cmd_name,
Jim_PrintErrorMessage(interp);
}
}
- teap = teap->next;
- }
- if (!done) {
- LOG_DEBUG("event: %d %s - no action",
- e,
- Jim_Nvp_value2name_simple(nvp_target_event, e)->name);
}
}
}
if (goi->isconfigure) {
+ bool replace = true;
if (teap == NULL) {
/* create new */
teap = calloc(1, sizeof(*teap));
+ replace = false;
}
teap->event = n->value;
Jim_GetOpt_Obj(goi, &o);
*/
Jim_IncrRefCount(teap->body);
- /* add to head of event list */
- teap->next = target->event_action;
- target->event_action = teap;
+ if (!replace)
+ {
+ /* add to head of event list */
+ teap->next = target->event_action;
+ target->event_action = teap;
+ }
Jim_SetEmptyResult(goi->interp);
} else {
/* get */
break;
case TS_CMD_RESET:
if (goi.argc != 2) {
- Jim_WrongNumArgs(interp, 2, argv, "t | f|assert | deassert BOOL");
+ Jim_WrongNumArgs(interp, 2, argv,
+ "([tT]|[fF]|assert|deassert) BOOL");
return JIM_ERR;
}
e = Jim_GetOpt_Nvp(&goi, nvp_assert, &n);
}
if (!target->tap->enabled)
goto err_tap_disabled;
+ if (!target->type->assert_reset
+ || !target->type->deassert_reset) {
+ Jim_SetResult_sprintf(interp,
+ "No target-specific reset for %s",
+ target->cmd_name);
+ return JIM_ERR;
+ }
/* determine if we should halt or not. */
target->reset_halt = !!a;
/* When this happens - all workareas are invalid. */
return target_create(&goi);
break;
case TG_CMD_NUMBER:
+ /* It's OK to remove this mechanism sometime after August 2010 or so */
+ LOG_WARNING("don't use numbers as target identifiers; use names");
if (goi.argc != 1) {
Jim_SetResult_sprintf(goi.interp, "expected: target number ?NUMBER?");
return JIM_ERR;
if (e != JIM_OK) {
return JIM_ERR;
}
- {
- target_t *t;
- t = get_target_by_num(w);
- if (t == NULL) {
- Jim_SetResult_sprintf(goi.interp,"Target: number %d does not exist", (int)(w));
- return JIM_ERR;
- }
- Jim_SetResultString(goi.interp, t->cmd_name, -1);
- return JIM_OK;
+ for (x = 0, target = all_targets; target; target = target->next, x++) {
+ if (target->target_number == w)
+ break;
}
+ if (target == NULL) {
+ Jim_SetResult_sprintf(goi.interp,
+ "Target: number %d does not exist", (int)(w));
+ return JIM_ERR;
+ }
+ Jim_SetResultString(goi.interp, target->cmd_name, -1);
+ return JIM_OK;
case TG_CMD_COUNT:
if (goi.argc != 0) {
Jim_WrongNumArgs(goi.interp, 0, goi.argv, "<no parameters>");
return JIM_ERR;
}
- Jim_SetResult(goi.interp,
- Jim_NewIntObj(goi.interp, max_target_number()));
+ for (x = 0, target = all_targets; target; target = target->next, x++)
+ continue;
+ Jim_SetResult(goi.interp, Jim_NewIntObj(goi.interp, x));
return JIM_OK;
}
fastload[i].length = length;
image_size += length;
- command_print(cmd_ctx, "%u byte written at address 0x%8.8x",
+ command_print(cmd_ctx, "%u bytes written at address 0x%8.8x",
(unsigned int)length,
((unsigned int)(image.sections[i].base_address + offset)));
}