TCL scripts: collect duplicated procedures
TCL procedures mrw and mmw, originally in DaVinci target code, are duplicated in other TCL scripts. Moved in a common helper file, and added help/usage description. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>__archive__
parent
ea48794210
commit
edefee9880
|
@ -0,0 +1,22 @@
|
||||||
|
# Helper for common memory read/modify/write procedures
|
||||||
|
|
||||||
|
# mrw: "memory read word", returns value of $reg
|
||||||
|
proc mrw {reg} {
|
||||||
|
set value ""
|
||||||
|
ocd_mem2array value 32 $reg 1
|
||||||
|
return $value(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
add_usage_text mrw "address"
|
||||||
|
add_help_text mrw "Returns value of word in memory."
|
||||||
|
|
||||||
|
# mmw: "memory modify word", updates value of $reg
|
||||||
|
# $reg <== ((value & ~$clearbits) | $setbits)
|
||||||
|
proc mmw {reg setbits clearbits} {
|
||||||
|
set old [mrw $reg]
|
||||||
|
set new [expr ($old & ~$clearbits) | $setbits]
|
||||||
|
mww $reg $new
|
||||||
|
}
|
||||||
|
|
||||||
|
add_usage_text mmw "address setbits clearbits"
|
||||||
|
add_help_text mmw "Modify word in memory. new_val = (old_val & ~clearbits) | setbits;"
|
|
@ -25,13 +25,7 @@ proc helpC100 {} {
|
||||||
puts "22) flashUBOOT: will prgram NOR sectors 0-3 with u-boot.bin"
|
puts "22) flashUBOOT: will prgram NOR sectors 0-3 with u-boot.bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
# mrw,mmw from davinci.cfg
|
source [find mem_helper.tcl]
|
||||||
# mrw: "memory read word", returns value of $reg
|
|
||||||
proc mrw {reg} {
|
|
||||||
set value ""
|
|
||||||
mem2array value 32 $reg 1
|
|
||||||
return $value(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
# read a 64-bit register (memory mapped)
|
# read a 64-bit register (memory mapped)
|
||||||
proc mr64bit {reg} {
|
proc mr64bit {reg} {
|
||||||
|
@ -50,14 +44,6 @@ proc mw64bit {reg value} {
|
||||||
mww [expr $reg+4] $high
|
mww [expr $reg+4] $high
|
||||||
}
|
}
|
||||||
|
|
||||||
# mmw: "memory modify word", updates value of $reg
|
|
||||||
# $reg <== ((value & ~$clearbits) | $setbits)
|
|
||||||
proc mmw {reg setbits clearbits} {
|
|
||||||
set old [mrw $reg]
|
|
||||||
set new [expr ($old & ~$clearbits) | $setbits]
|
|
||||||
mww $reg $new
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
proc showNOR {} {
|
proc showNOR {} {
|
||||||
puts "This is the current NOR setup"
|
puts "This is the current NOR setup"
|
||||||
|
|
|
@ -7,20 +7,7 @@ proc davinci_pinmux {soc reg value} {
|
||||||
mww [expr [dict get $soc sysbase] + 4 * $reg] $value
|
mww [expr [dict get $soc sysbase] + 4 * $reg] $value
|
||||||
}
|
}
|
||||||
|
|
||||||
# mrw: "memory read word", returns value of $reg
|
source [find mem_helper.tcl]
|
||||||
proc mrw {reg} {
|
|
||||||
set value ""
|
|
||||||
mem2array value 32 $reg 1
|
|
||||||
return $value(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
# mmw: "memory modify word", updates value of $reg
|
|
||||||
# $reg <== ((value & ~$clearbits) | $setbits)
|
|
||||||
proc mmw {reg setbits clearbits} {
|
|
||||||
set old [mrw $reg]
|
|
||||||
set new [expr ($old & ~$clearbits) | $setbits]
|
|
||||||
mww $reg $new
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# pll_setup: initialize PLL
|
# pll_setup: initialize PLL
|
||||||
|
|
|
@ -46,12 +46,7 @@ $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE
|
||||||
# this, if you're using a slower clock.
|
# this, if you're using a slower clock.
|
||||||
adapter_khz 500
|
adapter_khz 500
|
||||||
|
|
||||||
# mrw: "memory read word", returns value of $reg
|
source [find mem_helper.tcl]
|
||||||
proc mrw {reg} {
|
|
||||||
set value ""
|
|
||||||
mem2array value 32 $reg 1
|
|
||||||
return $value(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
$_TARGETNAME configure -event reset-start {
|
$_TARGETNAME configure -event reset-start {
|
||||||
adapter_khz 500
|
adapter_khz 500
|
||||||
|
|
Loading…
Reference in New Issue