1 # Defines basic Tcl procs that must exist for OpenOCD scripts to work.
3 # Embedded into OpenOCD executable
6 # Try flipping / and \ to find file if the filename does not
7 # match the precise spelling
9 if {[catch {ocd_find $filename} t]==0} {
12 if {[catch {ocd_find [string map {\ /} $filename} t]==0} {
15 if {[catch {ocd_find [string map {/ \\} $filename} t]==0} {
18 # make sure error message matches original input string
19 return -code error "Can't find $filename"
21 add_usage_text find "<file>"
22 add_help_text find "print full path to file according to OpenOCD search rules"
24 # Find and run a script
25 proc script {filename} {
26 uplevel #0 [list source [find $filename]]
28 add_help_text script "filename of OpenOCD script (tcl) to run"
29 add_usage_text script "<file>"
31 # Run a list of post-init commands
32 # Each command should be added with 'lappend post_init_commands command'
33 lappend _telnet_autocomplete_skip _run_post_init_commands
34 proc _run_post_init_commands {} {
35 if {[info exists ::post_init_commands]} {
36 foreach cmd $::post_init_commands {
42 # Run a list of pre-shutdown commands
43 # Each command should be added with 'lappend pre_shutdown_commands command'
44 lappend _telnet_autocomplete_skip _run_pre_shutdown_commands
45 proc _run_pre_shutdown_commands {} {
46 if {[info exists ::pre_shutdown_commands]} {
47 foreach cmd $::pre_shutdown_commands {