blob: b3900730113f1177258f67710c44186e2f742f52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
\ tag: Other FCode functions
\
\ this code implements IEEE 1275-1994 ch. 5.3.7
\
\ Copyright (C) 2003 Stefan Reinauer
\
\ See the file "COPYING" for further information about
\ the copyright and warranty status of this work.
\
\ The current diagnostic setting
defer _diag-switch?
\
\ 5.3.7 Other FCode functions
\
hex
\ 5.3.7.1 Peek/poke
defer (peek)
:noname
execute true
; to (peek)
: cpeek ( addr -- false | byte true )
['] c@ (peek)
;
: wpeek ( waddr -- false | w true )
['] w@ (peek)
;
: lpeek ( qaddr -- false | quad true )
['] l@ (peek)
;
defer (poke)
:noname
execute true
; to (poke)
: cpoke ( byte addr -- okay? )
['] c! (poke)
;
: wpoke ( w waddr -- okay? )
['] w! (poke)
;
: lpoke ( quad qaddr -- okay? )
['] l! (poke)
;
\ 5.3.7.2 Device-register access
: rb@ ( addr -- byte )
;
: rw@ ( waddr -- w )
;
: rl@ ( qaddr -- quad )
;
: rb! ( byte addr -- )
;
: rw! ( w waddr -- )
;
: rl! ( quad qaddr -- )
;
: rx@ ( oaddr - o )
state @ if
h# 22e get-token if , else execute then
else
h# 22e get-token drop execute
then
; immediate
: rx! ( o oaddr -- )
state @ if
h# 22f get-token if , else execute then
else
h# 22f get-token drop execute
then
; immediate
\ 5.3.7.3 Time
\ Pointer to OBP tick value updated by timer interrupt
variable obp-ticks
\ Dummy implementation for platforms without a timer interrupt
0 value dummy-msecs
: get-msecs ( -- n )
\ If obp-ticks pointer is set, use it. Otherwise fall back to
\ dummy implementation
obp-ticks @ 0<> if
obp-ticks @
else
dummy-msecs dup 1+ to dummy-msecs
then
;
: ms ( n -- )
get-msecs +
begin dup get-msecs < until
drop
;
: alarm ( xt n -- )
2drop
;
: user-abort ( ... -- ) ( R: ... -- )
;
\ 5.3.7.4 System information
0003.0000 value fcode-revision ( -- n )
: mac-address ( -- mac-str mac-len )
;
\ 5.3.7.5 FCode self-test
: display-status ( n -- )
;
: memory-test-suite ( addr len -- fail? )
;
: mask ( -- a-addr )
;
: diagnostic-mode? ( -- diag? )
\ Return the NVRAM diag-switch? setting
_diag-switch?
;
\ 5.3.7.6 Start and end.
\ Begin program with spread 0 followed by FCode-header.
: start0 ( -- )
0 fcode-spread !
offset16
fcode-header
;
\ Begin program with spread 1 followed by FCode-header.
: start1 ( -- )
1 to fcode-spread
offset16
fcode-header
;
\ Begin program with spread 2 followed by FCode-header.
: start2 ( -- )
2 to fcode-spread
offset16
fcode-header
;
\ Begin program with spread 4 followed by FCode-header.
: start4 ( -- )
4 to fcode-spread
offset16
fcode-header
;
\ Begin program with spread 1 followed by FCode-header.
: version1 ( -- )
1 to fcode-spread
fcode-header
;
\ Cease evaluating this FCode program.
: end0 ( -- )
true fcode-end !
; immediate
\ Cease evaluating this FCode program.
: end1 ( -- )
end0
;
\ Standard FCode number for undefined FCode functions.
: ferror ( -- )
." undefined fcode# encountered." cr
true fcode-end !
;
\ Pause FCode evaluation if desired; can resume later.
: suspend-fcode ( -- )
\ NOT YET IMPLEMENTED.
;
\ Evaluate FCode beginning at location addr.
\ : byte-load ( addr xt -- )
\ \ this word is implemented in feval.fs
\ ;
\ Set address and arguments of new device node.
: set-args ( arg-str arg-len unit-str unit-len -- )
?my-self drop
depth 1- >r
" decode-unit" ['] $call-parent catch if
2drop 2drop
then
my-self ihandle>phandle >dn.probe-addr \ offset
begin depth r@ > while
dup na1+ >r ! r>
repeat
r> 2drop
my-self >in.arguments 2@ free-mem
strdup my-self >in.arguments 2!
;
: dma-alloc
s" dma-alloc" $call-parent
;
|