Tidy cell types and format strings
[openbios.git] / forth / device / other.fs
blobf221a252356d24fe4c40c31e6293760e8fa3573e
1 \ tag: Other FCode functions
2 \
3 \ this code implements IEEE 1275-1994 ch. 5.3.7
4 \
5 \ Copyright (C) 2003 Stefan Reinauer
6 \
7 \ See the file "COPYING" for further information about
8 \ the copyright and warranty status of this work.
9 \
11 \ The current diagnostic setting
12 defer _diag-switch?
16 \ 5.3.7 Other FCode functions
19 hex
21 \ 5.3.7.1 Peek/poke
23 : cpeek ( addr -- false | byte true )
24 c@ true
27 : wpeek ( waddr -- false | w true )
28 w@ true
31 : lpeek ( qaddr -- false | quad true )
32 l@ true
35 : cpoke ( byte addr -- okay? )
36 c! true
39 : wpoke ( w waddr -- okay? )
40 w! true
43 : lpoke ( quad qaddr -- okay? )
44 l! true
48 \ 5.3.7.2 Device-register access
50 : rb@ ( addr -- byte )
53 : rw@ ( waddr -- w )
56 : rl@ ( qaddr -- quad )
59 : rb! ( byte addr -- )
62 : rw! ( w waddr -- )
65 : rl! ( quad qaddr -- )
68 : rx@ ( oaddr - o )
69 state @ if
70 h# 22e get-token if , else execute then
71 else
72 h# 22e get-token drop execute
73 then
74 ; immediate
76 : rx! ( o oaddr -- )
77 state @ if
78 h# 22f get-token if , else execute then
79 else
80 h# 22f get-token drop execute
81 then
82 ; immediate
84 \ 5.3.7.3 Time
86 0 value dummy-msecs
88 : get-msecs ( -- n )
89 dummy-msecs dup 1+ to dummy-msecs
92 : ms ( n -- )
93 get-msecs +
94 begin dup get-msecs < until
95 drop
98 : alarm ( xt n -- )
99 2drop
102 : user-abort ( ... -- ) ( R: ... -- )
106 \ 5.3.7.4 System information
107 0003.0000 value fcode-revision ( -- n )
109 : mac-address ( -- mac-str mac-len )
113 \ 5.3.7.5 FCode self-test
114 : display-status ( n -- )
117 : memory-test-suite ( addr len -- fail? )
120 : mask ( -- a-addr )
123 : diagnostic-mode? ( -- diag? )
124 \ Return the NVRAM diag-switch? setting
125 _diag-switch?
128 \ 5.3.7.6 Start and end.
130 \ Begin program with spread 0 followed by FCode-header.
131 : start0 ( -- )
132 0 fcode-spread !
133 offset16
134 fcode-header
137 \ Begin program with spread 1 followed by FCode-header.
138 : start1 ( -- )
139 1 to fcode-spread
140 offset16
141 fcode-header
144 \ Begin program with spread 2 followed by FCode-header.
145 : start2 ( -- )
146 2 to fcode-spread
147 offset16
148 fcode-header
151 \ Begin program with spread 4 followed by FCode-header.
152 : start4 ( -- )
153 4 to fcode-spread
154 offset16
155 fcode-header
158 \ Begin program with spread 1 followed by FCode-header.
159 : version1 ( -- )
160 1 to fcode-spread
161 fcode-header
164 \ Cease evaluating this FCode program.
165 : end0 ( -- )
166 true fcode-end !
169 \ Cease evaluating this FCode program.
170 : end1 ( -- )
171 end0
174 \ Standard FCode number for undefined FCode functions.
175 : ferror ( -- )
176 ." undefined fcode# encountered." cr
177 true fcode-end !
180 \ Pause FCode evaluation if desired; can resume later.
181 : suspend-fcode ( -- )
182 \ NOT YET IMPLEMENTED.
186 \ Evaluate FCode beginning at location addr.
188 \ : byte-load ( addr xt -- )
189 \ \ this word is implemented in feval.fs
192 \ Set address and arguments of new device node.
193 : set-args ( arg-str arg-len unit-str unit-len -- )
194 ?my-self drop
196 depth 1- >r
197 " decode-unit" ['] $call-parent catch if
198 2drop 2drop
199 then
201 my-self ihandle>phandle >dn.probe-addr \ offset
202 begin depth r@ > while
203 dup na1+ >r ! r>
204 repeat
205 r> 2drop
207 my-self >in.arguments 2@ free-mem
208 strdup my-self >in.arguments 2!
211 : dma-alloc
212 s" dma-alloc" $call-parent