1 \ 7.6 Client Program Debugging command group
4 \ 7.6.1 Registers display
15 \ to ( param [old-name< >] -- )
18 \ 7.6.2 Program download and execute
20 struct ( saved-program-state )
22 /n field >sps.file-size
23 /n field >sps.file-type
24 constant saved-program-state.size
25 create saved-program-state saved-program-state.size allot
32 : !load-size file-size ! ;
34 : load-size file-size @ ;
37 \ File types identified by (init-program)
51 \ Call down to the lower level for relocation etc.
52 s" (init-program)" $find if
55 s" Unable to locate (init-program)!" type cr
59 : (find-bootdevice) ( param-str param-len -- bootpath-str bootpath-len)
60 \ Parse the <param> string which is a space-separated list of one or
61 \ more potential boot devices, and return the first one that can be
62 \ successfully opened.
64 \ Space-separated bootpath string
65 bl left-split \ bootpathstr bootpathstr-len bootdevstr bootdevstr-len
68 \ None specified. As per IEEE-1275 specification, search through each value
69 \ in boot-device and use the first that returns a valid ihandle on open.
71 2drop \ drop the empty device string as we're going to use our own
73 s" boot-device" $find drop execute
78 2dup s" Trying " type type s" ..." type cr
81 2swap drop 0 \ Fake end of string so we exit loop
92 \ None specified, use default from nvram
93 2drop s" boot-file" $find drop execute
96 \ Set the bootargs property
98 " /chosen" (find-dev) if
99 " bootargs" rot (property)
103 \ Locate the boot-device opened by this ihandle (currently taken as being
104 \ the first non-interposed package in the instance chain)
106 : ihandle>boot-device-handle ( ihandle -- 0 | device-ihandle -1 )
108 begin r> dup >in.my-parent @ dup >r while
109 ( result ihandle R: ihandle.parent )
110 dup >in.interposed @ 0= if
111 \ Find the first non-interposed package
128 : $load ( devstr len )
135 " load-base" evaluate swap ( load-base ihandle )
136 dup ihandle>phandle " load" rot find-method ( xt 0|1 )
137 if swap call-package !load-size else cr ." Cannot find load for this package" 2drop then
139 \ If the boot device path doesn't contain an explicit partition id, e.g. cd:,\\:tbxi
140 \ then the interposed partition package may have auto-probed a suitable partition. If
141 \ this is the case then it will have set the " selected-partition-args" property in
142 \ the partition package to contain the new device arguments.
144 \ In order to ensure that bootpath contains the partition argument, we use the contents
145 \ of this property if it exists to override the boot device arguments when generating
146 \ the full bootpath using get-instance-path.
150 " selected-partition-args" get-inherited-property 0= if
151 decode-string 2swap 2drop
152 ( myself-save partargs-str partargs-len )
153 r@ ihandle>boot-device-handle if
154 ( myself-save partargs-str partargs-len block-ihandle )
155 \ Override the arguments before get-instance-path
156 dup >in.arguments 2@ >r >r dup >r ( R: block-ihandle arg-len arg-str )
157 >in.arguments 2! ( myself-save )
158 r@ " get-instance-path" $find if
159 execute ( myself-save bootpathstr bootpathlen )
161 \ Now write the original arguments back
162 r> r> r> rot >in.arguments 2! ( myself-save bootpathstr bootpathlen R: )
163 rot ( bootpathstr bootpathlen myself-save )
166 my-self " get-instance-path" $find if
167 execute ( myself-save bootpathstr pathlen )
168 rot ( bootpathstr bootpathlen myself-save )
173 \ Set bootpath property in /chosen
174 encode-string " /chosen" (find-dev) if
175 " bootpath" rot (property)
182 : load ( "{params}<cr>" -- )
188 : dir ( "{paths}<cr>" -- )
191 2dup open-dev dup 0= if
193 cr ." Unable to locate device " type
197 -rot 2drop -rot 2 pick
198 " dir" rot ['] $call-method catch
201 cr ." Cannot find dir for this package"
208 s" No valid state has been set by load or init-program" type cr
212 \ Call the architecture-specific code to launch the client image
216 ." go is not yet implemented"
222 \ 7.6.3 Abort and resume
284 : .instruction ( -- )
288 \ 7.6.6 Symbolic debugging
292 : sym ( "name< >" -- n )
295 : sym>value ( addr len -- addr len false | n true )
298 : value>sym ( n1 -- n1 false | n2 addr len true )