forked from auracaster/openocd
target/tcl: Add 'read_memory' and 'write_memory'
These functions are meant as replacement for 'mem2array' and 'array2mem'. The main benefits of these new functions are: * They do not use Tcl arrays but lists which makes it easier to parse (generate) the data. See the Python Tcl RPC code in contrib as a negative example. * They do not operate on Tcl variables but instead return (accept) the Tcl list directly. This makes the C and Tcl code base smaller and cleaner. * The code is slightly more performant when reading / writing large amount of data. Tested with a simple Python Tcl RPC benchmark. Change-Id: Ibd6ece3360c0d002abaadc37f078b10a8bb606f8 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6307 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
c5a23e9687
commit
38183dc856
@@ -5036,6 +5036,45 @@ get_reg @{pc sp@}
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {$target_name write_memory} address width data ['phys']
|
||||
This function provides an efficient way to write to the target memory from a Tcl
|
||||
script.
|
||||
|
||||
@itemize
|
||||
@item @var{address} ... target memory address
|
||||
@item @var{width} ... memory access bit size, can be 8, 16, 32 or 64
|
||||
@item @var{data} ... Tcl list with the elements to write
|
||||
@item ['phys'] ... treat the memory address as physical instead of virtual address
|
||||
@end itemize
|
||||
|
||||
For example, the following command writes two 32 bit words into the target
|
||||
memory at address 0x20000000:
|
||||
|
||||
@example
|
||||
write_memory 0x20000000 32 @{0xdeadbeef 0x00230500@}
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {$target_name read_memory} address width count ['phys']
|
||||
This function provides an efficient way to read the target memory from a Tcl
|
||||
script.
|
||||
A Tcl list containing the requested memory elements is returned by this function.
|
||||
|
||||
@itemize
|
||||
@item @var{address} ... target memory address
|
||||
@item @var{width} ... memory access bit size, can be 8, 16, 32 or 64
|
||||
@item @var{count} ... number of elements to read
|
||||
@item ['phys'] ... treat the memory address as physical instead of virtual address
|
||||
@end itemize
|
||||
|
||||
For example, the following command reads two 32 bit words from the target
|
||||
memory at address 0x20000000:
|
||||
|
||||
@example
|
||||
read_memory 0x20000000 32 2
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {$target_name cget} queryparm
|
||||
Each configuration parameter accepted by
|
||||
@command{$target_name configure}
|
||||
@@ -8557,6 +8596,45 @@ get_reg @{pc sp@}
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {write_memory} address width data ['phys']
|
||||
This function provides an efficient way to write to the target memory from a Tcl
|
||||
script.
|
||||
|
||||
@itemize
|
||||
@item @var{address} ... target memory address
|
||||
@item @var{width} ... memory access bit size, can be 8, 16, 32 or 64
|
||||
@item @var{data} ... Tcl list with the elements to write
|
||||
@item ['phys'] ... treat the memory address as physical instead of virtual address
|
||||
@end itemize
|
||||
|
||||
For example, the following command writes two 32 bit words into the target
|
||||
memory at address 0x20000000:
|
||||
|
||||
@example
|
||||
write_memory 0x20000000 32 @{0xdeadbeef 0x00230500@}
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {read_memory} address width count ['phys']
|
||||
This function provides an efficient way to read the target memory from a Tcl
|
||||
script.
|
||||
A Tcl list containing the requested memory elements is returned by this function.
|
||||
|
||||
@itemize
|
||||
@item @var{address} ... target memory address
|
||||
@item @var{width} ... memory access bit size, can be 8, 16, 32 or 64
|
||||
@item @var{count} ... number of elements to read
|
||||
@item ['phys'] ... treat the memory address as physical instead of virtual address
|
||||
@end itemize
|
||||
|
||||
For example, the following command reads two 32 bit words from the target
|
||||
memory at address 0x20000000:
|
||||
|
||||
@example
|
||||
read_memory 0x20000000 32 2
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Command} {halt} [ms]
|
||||
@deffnx {Command} {wait_halt} [ms]
|
||||
The @command{halt} command first sends a halt request to the target,
|
||||
|
||||
Reference in New Issue
Block a user