aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc Schink <dev@zapb.de>2021-06-07 14:40:30 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2022-03-12 09:48:00 +0000
commite370e06b724f6e3a0fdd8611a3d461c2cc15735c (patch)
tree2df1c37487c523c41ec26f9d3f76545ffd160f7c /src
parent38183dc856fdb7e69c8407911ff16383f4b12247 (diff)
downloadriscv-openocd-e370e06b724f6e3a0fdd8611a3d461c2cc15735c.zip
riscv-openocd-e370e06b724f6e3a0fdd8611a3d461c2cc15735c.tar.gz
riscv-openocd-e370e06b724f6e3a0fdd8611a3d461c2cc15735c.tar.bz2
target: Deprecate 'array2mem' and 'mem2array''
Replace 'mem2array' and 'array2mem' with a Tcl wrapper that internally uses 'read_memory' and 'write_memory'. The target-specific 'mem2array' and 'array2mem' functions remain for now. Change-Id: If24c22a76ac72d4c26916a95f7f17902b41b6d9e Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6308 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/startup.tcl26
-rw-r--r--src/target/target.c54
2 files changed, 30 insertions, 50 deletions
diff --git a/src/target/startup.tcl b/src/target/startup.tcl
index cd98d68..0e46992 100644
--- a/src/target/startup.tcl
+++ b/src/target/startup.tcl
@@ -206,6 +206,32 @@ proc init_target_events {} {
proc init_board {} {
}
+proc mem2array {arrayname bitwidth address count {phys ""}} {
+ echo "DEPRECATED! use 'read_memory' not 'mem2array'"
+
+ upvar $arrayname $arrayname
+ set $arrayname ""
+ set i 0
+
+ foreach elem [read_memory $address $bitwidth $count {*}$phys] {
+ set ${arrayname}($i) $elem
+ incr i
+ }
+}
+
+proc array2mem {arrayname bitwidth address count {phys ""}} {
+ echo "DEPRECATED! use 'write_memory' not 'array2mem'"
+
+ upvar $arrayname $arrayname
+ set data ""
+
+ for {set i 0} {$i < $count} {incr i} {
+ lappend data [expr $${arrayname}($i)]
+ }
+
+ write_memory $address $bitwidth $data {*}$phys
+}
+
# smp_on/smp_off were already DEPRECATED in v0.11.0 through http://openocd.zylin.com/4615
lappend _telnet_autocomplete_skip "aarch64 smp_on"
proc "aarch64 smp_on" {args} {
diff --git a/src/target/target.c b/src/target/target.c
index 473538a..7b82713 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4431,27 +4431,12 @@ static int new_u64_array_element(Jim_Interp *interp, const char *varname, int id
return result;
}
-static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
- struct command_context *context;
- struct target *target;
-
- context = current_command_context(interp);
- assert(context);
-
- target = get_current_target(context);
- if (!target) {
- LOG_ERROR("mem2array: no current target");
- return JIM_ERR;
- }
-
- return target_mem2array(interp, target, argc - 1, argv + 1);
-}
-
static int target_mem2array(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv)
{
int e;
+ LOG_WARNING("DEPRECATED! use 'read_memory' not 'mem2array'");
+
/* argv[0] = name of array to receive the data
* argv[1] = desired element width in bits
* argv[2] = memory address
@@ -4784,28 +4769,13 @@ static int get_u64_array_element(Jim_Interp *interp, const char *varname, size_t
return result;
}
-static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
- struct command_context *context;
- struct target *target;
-
- context = current_command_context(interp);
- assert(context);
-
- target = get_current_target(context);
- if (!target) {
- LOG_ERROR("array2mem: no current target");
- return JIM_ERR;
- }
-
- return target_array2mem(interp, target, argc-1, argv + 1);
-}
-
static int target_array2mem(Jim_Interp *interp, struct target *target,
int argc, Jim_Obj *const *argv)
{
int e;
+ LOG_WARNING("DEPRECATED! use 'write_memory' not 'array2mem'");
+
/* argv[0] = name of array from which to read the data
* argv[1] = desired element width in bits
* argv[2] = memory address
@@ -7171,22 +7141,6 @@ static const struct command_registration target_exec_command_handlers[] = {
.usage = "filename [offset [type]]",
},
{
- .name = "mem2array",
- .mode = COMMAND_EXEC,
- .jim_handler = jim_mem2array,
- .help = "read 8/16/32 bit memory and return as a TCL array "
- "for script processing",
- .usage = "arrayname bitwidth address count",
- },
- {
- .name = "array2mem",
- .mode = COMMAND_EXEC,
- .jim_handler = jim_array2mem,
- .help = "convert a TCL array to memory locations "
- "and write the 8/16/32 bit values",
- .usage = "arrayname bitwidth address count",
- },
- {
.name = "get_reg",
.mode = COMMAND_EXEC,
.jim_handler = target_jim_get_reg,