blob: af8991fd0768d239a6b3a1b282efb43becf5ff1c (
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
\
\ Fcode payload for QEMU TCX graphics card
\
\ This is the Forth source for an Fcode payload to initialise
\ the QEMU TCX graphics card.
\
\ (C) Copyright 2013 Mark Cave-Ayland
\
fcode-version3
\
\ Instead of using fixed values for the framebuffer address and the width
\ and height, grab the ones passed in by QEMU/generated by OpenBIOS
\
: (find-xt) \ ( str len -- xt | -1 )
$find if
exit
else
2drop
-1
then
;
: (is-openbios) \ ( -- true | false )
" openbios-video-width" (find-xt) -1 <> if
-1
else
0
then
;
" openbios-video-width" (find-xt) cell+ value openbios-video-width-xt
" openbios-video-height" (find-xt) cell+ value openbios-video-height-xt
" depth-bits" (find-xt) cell+ value depth-bits-xt
" line-bytes" (find-xt) cell+ value line-bytes-xt
: openbios-video-width
(is-openbios) if
openbios-video-width-xt @
else
h# 400
then
;
: openbios-video-height
(is-openbios) if
openbios-video-height-xt @
else
h# 300
then
;
: depth-bits
(is-openbios) if
depth-bits-xt @
else
h# 8
then
;
: line-bytes
(is-openbios) if
line-bytes-xt @
else
h# 400
then
;
\
\ Registers
\
h# 0 constant tcx-off-rom
h# 10000 constant /tcx-off-rom
h# 200000 constant tcx-off-cmap
h# 4000 constant /tcx-off-cmap-24
h# 4 constant /tcx-off-cmap-8
h# 240000 constant tcx-off-dhc
h# 4000 constant /tcx-off-dhc-24
h# 4 constant /tcx-off-dhc-8
h# 280000 constant tcx-off-alt
h# 8000 constant /tcx-off-alt-24
h# 1 constant /tcx-off-alt-8
h# 301000 constant tcx-off-thc-24
h# 300000 constant tcx-off-thc-8
h# 1000 constant /tcx-off-thc-24
h# 81c constant /tcx-off-thc-8
h# 701000 constant tcx-off-tec
h# 1000 constant /tcx-off-tec
h# 800000 constant tcx-off-dfb8
h# 100000 constant /tcx-off-dfb8
h# 2000000 constant tcx-off-dfb24
h# 400000 constant /tcx-off-dfb24-24
h# 1 constant /tcx-off-dfb24-8
h# 4000000 constant tcx-off-stip
h# 800000 constant /tcx-off-stip
h# 6000000 constant tcx-off-blit
h# 800000 constant /tcx-off-blit
h# a000000 constant tcx-off-rdfb32
h# 400000 constant /tcx-off-rdfb32-24
h# 1 constant /tcx-off-rdfb32-8
h# c000000 constant tcx-off-rstip
h# 800000 constant /tcx-off-rstip-24
h# 1 constant /tcx-off-rstip-8
h# e000000 constant tcx-off-rblit
h# 800000 constant /tcx-off-rblit-24
h# 1 constant /tcx-off-rblit-8
: >tcx-reg-spec ( offset size -- encoded-reg )
>r 0 my-address d+ my-space encode-phys r> encode-int encode+
;
: tcx-8bit-reg
\ WARNING: order is important (at least to Solaris)
tcx-off-dfb8 /tcx-off-dfb8 >tcx-reg-spec
tcx-off-dfb24 /tcx-off-dfb24-8 >tcx-reg-spec encode+
tcx-off-stip /tcx-off-stip >tcx-reg-spec encode+
tcx-off-blit /tcx-off-blit >tcx-reg-spec encode+
tcx-off-rdfb32 /tcx-off-rdfb32-8 >tcx-reg-spec encode+
tcx-off-rstip /tcx-off-rstip-8 >tcx-reg-spec encode+
tcx-off-rblit /tcx-off-rblit-8 >tcx-reg-spec encode+
tcx-off-tec /tcx-off-tec >tcx-reg-spec encode+
tcx-off-cmap /tcx-off-cmap-8 >tcx-reg-spec encode+
tcx-off-thc-8 /tcx-off-thc-8 >tcx-reg-spec encode+
tcx-off-rom /tcx-off-rom >tcx-reg-spec encode+
tcx-off-dhc /tcx-off-dhc-8 >tcx-reg-spec encode+
tcx-off-alt /tcx-off-alt-8 >tcx-reg-spec encode+
" reg" property
;
: tcx-24bit-reg
\ WARNING: order is important (at least to Solaris)
tcx-off-dfb8 /tcx-off-dfb8 >tcx-reg-spec
tcx-off-dfb24 /tcx-off-dfb24-24 >tcx-reg-spec encode+
tcx-off-stip /tcx-off-stip >tcx-reg-spec encode+
tcx-off-blit /tcx-off-blit >tcx-reg-spec encode+
tcx-off-rdfb32 /tcx-off-rdfb32-24 >tcx-reg-spec encode+
tcx-off-rstip /tcx-off-rstip-24 >tcx-reg-spec encode+
tcx-off-rblit /tcx-off-rblit-24 >tcx-reg-spec encode+
tcx-off-tec /tcx-off-tec >tcx-reg-spec encode+
tcx-off-cmap /tcx-off-cmap-24 >tcx-reg-spec encode+
tcx-off-thc-24 /tcx-off-thc-24 >tcx-reg-spec encode+
tcx-off-rom /tcx-off-rom >tcx-reg-spec encode+
tcx-off-dhc /tcx-off-dhc-24 >tcx-reg-spec encode+
tcx-off-alt /tcx-off-alt-24 >tcx-reg-spec encode+
" reg" property
;
: do-map-in ( offset size -- virt )
>r my-space r> " map-in" $call-parent
;
: do-map-out ( virt size )
" map-out" $call-parent
;
\
\ DAC
\
-1 value tcx-dac
-1 value /tcx-dac
-1 value fb-addr
: dac! ( data reg# -- )
>r dup 2dup bljoin r> tcx-dac + l!
;
external
: color! ( r g b c# -- )
0 dac! ( r g b )
swap rot ( b g r )
4 dac! ( b g )
4 dac! ( b )
4 dac! ( )
;
headerless
\
\ Mapping
\
: dac-map
tcx-off-cmap /tcx-dac do-map-in to tcx-dac
;
: fb-map
tcx-off-dfb8 h# c0000 do-map-in to fb-addr
;
: map-regs
dac-map fb-map
;
\
\ Installation
\
" SUNW,tcx" device-name
" display" device-type
: qemu-tcx-driver-install ( -- )
tcx-dac -1 = if
map-regs
\ Initial pallette taken from Sun's "Writing FCode Programs"
h# ff h# ff h# ff h# 0 color! \ Background white
h# 0 h# 0 h# 0 h# ff color! \ Foreground black
h# 64 h# 41 h# b4 h# 1 color! \ SUN-blue logo
fb-addr to frame-buffer-adr
default-font set-font
\ Sun TCX adapters don't have an address property, but it is useful for
\ OpenBIOS developers. Unfortunately NetBSD SPARC32 has a bug that causes
\ it to fail initialising TCX if the address property is present; so work
\ around this by adding an underscore prefix
frame-buffer-adr encode-int " _address" property
openbios-video-width openbios-video-height over char-width / over char-height /
fb8-install
then
;
: qemu-tcx-driver-init
\ Handle differences between 8-bit/24-bit mode
depth-bits 8 = if
tcx-8bit-reg
/tcx-off-cmap-8 to /tcx-dac
" true" encode-string " tcx-8-bit" property
else
tcx-24bit-reg
/tcx-off-cmap-24 to /tcx-dac
\ Even with a 24-bit enabled TCX card, the control plane is
\ used in 8-bit mode. So force the video subsystem into 8-bit
\ mode before initialisation.
8 depth-bits-xt !
openbios-video-width line-bytes-xt !
then
h# 1d encode-int " vbporch" property
h# a0 encode-int " hbporch" property
h# 06 encode-int " vsync" property
h# 88 encode-int " hsync" property
h# 03 encode-int " vfporch" property
h# 18 encode-int " hfporch" property
h# 03dfd240 encode-int " pixfreq" property
h# 3c encode-int " vfreq" property
openbios-video-height encode-int " height" property
openbios-video-width encode-int " width" property
line-bytes encode-int " linebytes" property
h# 39 encode-int 0 encode-int encode+ " intr" property
5 encode-int " interrupts" property
['] qemu-tcx-driver-install is-install
;
qemu-tcx-driver-init
end0
|