* Copyright (C) 2008 by Rick Altherr *
* kc8apf@kc8apf.net> *
* *
+ * Copyright (C) 2011 by Broadcom Corporation *
+ * Evan Hunter - ehunter@broadcom.com *
+ * *
+ * Copyright (C) ST-Ericsson SA 2011 *
+ * michel.jaouen@stericsson.com : smp minimum support *
+ * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
#include "register.h"
#include "trace.h"
#include "image.h"
+#include "rtos/rtos.h"
+static int target_read_buffer_default(struct target *target, uint32_t address,
+ uint32_t size, uint8_t *buffer);
+static int target_write_buffer_default(struct target *target, uint32_t address,
+ uint32_t size, const uint8_t *buffer);
static int target_array2mem(Jim_Interp *interp, struct target *target,
int argc, Jim_Obj *const *argv);
static int target_mem2array(Jim_Interp *interp, struct target *target,
extern struct target_type xscale_target;
extern struct target_type cortexm3_target;
extern struct target_type cortexa8_target;
-extern struct target_type cortexa9_target;
extern struct target_type arm11_target;
extern struct target_type mips_m4k_target;
extern struct target_type avr_target;
&xscale_target,
&cortexm3_target,
&cortexa8_target,
- &cortexa9_target,
&arm11_target,
&mips_m4k_target,
&avr_target,
return target->type->name;
}
-static int target_write_memory_imp(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+static int target_write_memory_imp(struct target *target, uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
if (!target_was_examined(target))
{
}
int target_write_memory(struct target *target,
- uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+ uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
return target->type->write_memory(target, address, size, count, buffer);
}
static int target_write_phys_memory(struct target *target,
- uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+ uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
return target->type->write_phys_memory(target, address, size, count, buffer);
}
int target_bulk_write_memory(struct target *target,
- uint32_t address, uint32_t count, uint8_t *buffer)
+ uint32_t address, uint32_t count, const uint8_t *buffer)
{
return target->type->bulk_write_memory(target, address, count, buffer);
}
int target_add_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
- if (target->state != TARGET_HALTED) {
+ if ((target->state != TARGET_HALTED)&&(breakpoint->type!=BKPT_HARD)) {
LOG_WARNING("target %s is not halted", target->cmd_name);
return ERROR_TARGET_NOT_HALTED;
}
static int
err_write_phys_memory(struct target *target, uint32_t address,
- uint32_t size, uint32_t count, uint8_t *buffer)
+ uint32_t size, uint32_t count, const uint8_t *buffer)
{
LOG_ERROR("Not implemented: %s", __func__);
return ERROR_FAIL;
type->read_phys_memory = type->read_memory;
type->virt2phys = identity_virt2phys;
}
+
+ if (target->type->read_buffer == NULL)
+ target->type->read_buffer = target_read_buffer_default;
+
+ if (target->type->write_buffer == NULL)
+ target->type->write_buffer = target_write_buffer_default;
+
return ERROR_OK;
}
* mode respectively, otherwise data is handled as quickly as
* possible
*/
-int target_write_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
+int target_write_buffer(struct target *target, uint32_t address, uint32_t size, const uint8_t *buffer)
{
- int retval;
LOG_DEBUG("writing buffer of %i byte at 0x%8.8x",
(int)size, (unsigned)address);
return ERROR_FAIL;
}
+ return target->type->write_buffer(target, address, size, buffer);
+}
+
+static int target_write_buffer_default(struct target *target, uint32_t address, uint32_t size, const uint8_t *buffer)
+{
+ int retval = ERROR_OK;
+
if (((address % 2) == 0) && (size == 2))
{
return target_write_memory(target, address, 2, 1, buffer);
return retval;
}
- return ERROR_OK;
+ return retval;
}
/* Single aligned words are guaranteed to use 16 or 32 bit access
*/
int target_read_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
{
- int retval;
LOG_DEBUG("reading buffer of %i byte at 0x%8.8x",
(int)size, (unsigned)address);
return ERROR_FAIL;
}
+ return target->type->read_buffer(target, address, size, buffer);
+}
+
+static int target_read_buffer_default(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
+{
+ int retval = ERROR_OK;
+
if (((address % 2) == 0) && (size == 2))
{
return target_read_memory(target, address, 2, 1, buffer);
}
typedef int (*target_write_fn)(struct target *target,
- uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
+ uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
static int target_write_memory_fast(struct target *target,
- uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
+ uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
return target_write_buffer(target, address, size * count, buffer);
}
TCFG_VARIANT,
TCFG_COREID,
TCFG_CHAIN_POSITION,
+ TCFG_DBGBASE,
+ TCFG_RTOS,
};
static Jim_Nvp nvp_config_opts[] = {
{ .name = "-variant", .value = TCFG_VARIANT },
{ .name = "-coreid", .value = TCFG_COREID },
{ .name = "-chain-position", .value = TCFG_CHAIN_POSITION },
-
+ { .name = "-dbgbase", .value = TCFG_DBGBASE },
+ { .name = "-rtos", .value = TCFG_RTOS },
{ .name = NULL, .value = -1 }
};
/* loop for more e*/
break;
+
case TCFG_ENDIAN:
if (goi->isconfigure) {
e = Jim_GetOpt_Nvp(goi, nvp_target_endian, &n);
if (e != JIM_OK) {
return e;
}
- target->coreid = (int)w;
+ target->coreid = (int32_t)w;
} else {
if (goi->argc != 0) {
goto no_params;
Jim_SetResultString(goi->interp, target->tap->dotted_name, -1);
/* loop for more e*/
break;
+ case TCFG_DBGBASE:
+ if (goi->isconfigure) {
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK) {
+ return e;
+ }
+ target->dbgbase = (uint32_t)w;
+ target->dbgbase_set = true;
+ } else {
+ if (goi->argc != 0) {
+ goto no_params;
+ }
+ }
+ Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->dbgbase));
+ /* loop for more */
+ break;
+
+ case TCFG_RTOS:
+ /* RTOS */
+ {
+ int result = rtos_create( goi, target );
+ if ( result != JIM_OK )
+ {
+ return result;
+ }
+ }
+ /* loop for more */
+ break;
}
} /* while (goi->argc) */
target->endianness = TARGET_ENDIAN_UNKNOWN;
+ target->rtos = NULL;
+ target->rtos_auto_detect = false;
+
/* Do the rest as "configure" options */
goi->isconfigure = 1;
e = target_configure(goi, target);
return JIM_OK;
}
+static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+ int i;
+ const char *targetname;
+ int retval,len;
+ struct target *target;
+ struct target_list *head, *curr, *new;
+ curr = (struct target_list*) NULL;
+ head = (struct target_list*) NULL;
+ new = (struct target_list*) NULL;
+
+ retval = 0;
+ LOG_DEBUG("%d",argc);
+ /* argv[1] = target to associate in smp
+ * argv[2] = target to assoicate in smp
+ * argv[3] ...
+ */
+
+ for(i=1;i<argc;i++)
+ {
+
+ targetname = Jim_GetString(argv[i], &len);
+ target = get_target(targetname);
+ LOG_DEBUG("%s ",targetname);
+ if (target)
+ {
+ new=malloc(sizeof(struct target_list));
+ new->target = target;
+ new->next = (struct target_list*)NULL;
+ if (head == (struct target_list*)NULL)
+ {
+ head = new;
+ curr = head;
+ }
+ else
+ {
+ curr->next = new;
+ curr = new;
+ }
+ }
+ }
+ /* now parse the list of cpu and put the target in smp mode*/
+ curr=head;
+
+ while(curr!=(struct target_list *)NULL)
+ {
+ target=curr->target;
+ target->smp = 1;
+ target->head = head;
+ curr=curr->next;
+ }
+ return retval;
+}
+
+
static int jim_target_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_GetOptInfo goi;
.help = "Returns the number of targets as an integer "
"(DEPRECATED)",
},
+ {
+ .name = "smp",
+ .mode = COMMAND_ANY,
+ .jim_handler = jim_target_smp,
+ .usage = "targetname1 targetname2 ...",
+ .help = "gather several target in a smp list"
+ },
+
COMMAND_REGISTRATION_DONE
};