Skip to content

Commit

Permalink
target: drop deprecated code for mem2array and array2mem
Browse files Browse the repository at this point in the history
Commit e370e06 ("target: Deprecate 'array2mem' and
'mem2array''") has already replaced the deprecated root versions
of commands mem2array and array2mem with TCL proc's that use
'read_memory' and 'write_memory'. It has left the deprecated code
of the target's version of the commands because the effort to code
the TCL replacement was not considered valuable.

To drop the last jim_handler commands, I consider much easier and
less error-prone to code them in TCL instead of converting the
deprecated code to COMMAND_HANDLER.

Drop the code in target.c and extend the TCL proc's.
While there, add the TCL procs to _telnet_autocomplete_skip.

Change-Id: I97d2370d8af479434ddf5af68541f90913982bc0
Signed-off-by: Antonio Borneo <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/8052
Tested-by: jenkins
  • Loading branch information
borneoa committed Jan 13, 2024
1 parent 305f293 commit 6e6d486
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 441 deletions.
57 changes: 35 additions & 22 deletions src/target/startup.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -219,31 +219,44 @@ 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 ""
lappend _telnet_autocomplete_skip _post_init_target_array_mem
proc _post_init_target_array_mem {} {
set targets [target names]
lappend targets ""

for {set i 0} {$i < $count} {incr i} {
lappend data [expr $${arrayname}($i)]
foreach t $targets {
if {$t != ""} {
set t "$t "
}
eval [format {lappend ::_telnet_autocomplete_skip "%smem2array"} $t]
eval [format {proc {%smem2array} {arrayname bitwidth address count {phys ""}} {
echo "DEPRECATED! use 'read_memory' not 'mem2array'"

upvar $arrayname $arrayname
set $arrayname ""
set i 0

foreach elem [%sread_memory $address $bitwidth $count {*}$phys] {
set ${arrayname}($i) $elem
incr i
}
}} $t $t]
eval [format {lappend ::_telnet_autocomplete_skip "%sarray2mem"} $t]
eval [format {proc {%sarray2mem} {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)]
}

%swrite_memory $address $bitwidth $data {*}$phys
}} $t $t]
}

write_memory $address $bitwidth $data {*}$phys
}
lappend post_init_commands _post_init_target_array_mem

# smp_on/smp_off were already DEPRECATED in v0.11.0 through http://openocd.zylin.com/4615
lappend _telnet_autocomplete_skip "aarch64 smp_on"
Expand Down
Loading

0 comments on commit 6e6d486

Please sign in to comment.