1 \ *****************************************************************************
2 \ * Copyright (c) 2011 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
13 my-space pci-device-generic-setup
15 \ Defaults, overriden from qemu
16 d# 800 VALUE disp-width
17 d# 600 VALUE disp-height
20 \ Determine base address
21 10 config-l@ translate-my-address f not AND VALUE fb-base
26 \ We support only one instance
27 false VALUE is-installed?
29 : vga-io-xlate ( port -- addr )
31 dup translate-my-address fff not and to io-base
36 : vga-w! ( value port -- )
40 : vga-w@ ( port -- value )
44 : vga-b! ( value port -- )
48 : vga-b@ ( port -- value )
52 : vga-crt@ ( index -- value )
57 : vga-crt! ( value index -- )
62 : vga-seq@ ( index -- value )
67 : vga-seq! ( value index -- )
72 : vga-att@ ( index -- value )
77 : vga-att! ( value index -- )
82 : vga-gfx@ ( index -- value )
87 : vga-gfx! ( value index -- )
92 : color! ( r g b number -- )
99 : color@ ( number -- r g b )
106 : set-colors ( adr number #numbers -- )
116 : get-colors ( adr number #numbers -- )
123 3da vga-b@ drop \ reset flip flop
124 0f 3c2 vga-b! \ color mode, ram enable, ...
125 12 06 vga-seq! \ unlock extensions
126 05 06 vga-gfx! \ graphic mode
127 \ set bit depth. Note: we should set the hidden
128 \ dac register to differenciate 15 and 16bpp, but
129 \ it's annoying and in practice we don't care as
130 \ we are only displaying in black & white atm
131 disp-depth CASE \ set depth
132 8 OF 01 07 vga-seq! ENDOF
133 f OF 07 07 vga-seq! ENDOF
134 10 OF 07 07 vga-seq! ENDOF
135 20 OF 09 07 vga-seq! ENDOF
137 ff 02 vga-seq! \ enable plane write
138 0a 04 vga-seq! \ memory mode
139 03 17 vga-crt! \ disable display
140 \ calculate line offset & split
141 disp-width disp-depth 7 + 8 / * 3 >>
142 dup ff and 13 vga-crt! \ bottom bits
143 4 >> 10 and 1b vga-crt! \ top bit
144 disp-width 3 >> 1 - 01 vga-crt! \ H_DISP
145 disp-height 1 - ff and 12 vga-crt! \ V_DISP
146 disp-height 1 - 7 >> 2 and
147 disp-height 1 - 3 >> 40 and
148 or 10 or 07 vga-crt! \ OFLOW
149 ff 18 vga-crt! \ LINE_COMPARE
150 40 09 vga-crt! \ MAX_SCAN
151 08 04 vga-crt! \ SYNC_START
152 0f 02 vga-crt! \ BLANK_START
155 40 05 vga-gfx! \ gfx mode
156 83 17 vga-crt! \ enable display
157 33 3c0 vga-b! \ gfx in ar index
159 01 01 vga-seq! \ enable seq
163 fb-base disp-width disp-height disp-depth 7 + 8 / * * 0 rfill
167 s" qemu,graphic-width" get-chosen IF
168 decode-int to disp-width 2drop
170 s" qemu,graphic-height" get-chosen IF
171 decode-int to disp-height 2drop
173 s" qemu,graphic-depth" get-chosen IF
181 ." Unsupported bit depth, using 8bpp " drop cr
187 \ add legacy I/O Ports / Memory regions to assigned-addresses
188 \ see PCI Bus Binding Revision 2.1 Section 7.
189 s" reg" get-node get-property IF
190 \ "reg" does not exist, create new
193 \ "reg" does exist, copy it
196 \ I/O Range 0x1ce-0x1d2
197 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
198 1ce encode-64+ 4 encode-64+ \ addr size
199 \ I/O Range 0x3B0-0x3BB
200 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
201 3b0 encode-64+ c encode-64+ \ addr size
202 \ I/O Range 0x3C0-0x3DF
203 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
204 3c0 encode-64+ 20 encode-64+ \ addr size
205 \ Memory Range 0xA0000-0xBFFFF
206 my-space a2000000 or encode-int+ \ non-relocatable, <1MB Memory space
207 a0000 encode-64+ 20000 encode-64+ \ addr size
208 s" reg" property \ store "reg" property
212 \ Shouldn't this be done from open ?
213 disp-width encode-int s" width" property
214 disp-height encode-int s" height" property
215 disp-width disp-depth 7 + 8 / * encode-int s" linebytes" property
216 disp-depth encode-int s" depth" property
217 s" ISO8859-1" encode-string s" character-set" property \ i hope this is ok...
218 \ add "device_type" property
219 s" display" device-type
220 \ XXX We don't create an "address" property because Linux doesn't know what
221 \ to do with it for >32-bit
224 \ words for installation/removal, needed by is-install/is-remove, see display.fs
225 : display-remove ( -- )
228 : display-install ( -- )
230 ." Installing QEMU fb" cr
231 fb-base to frame-buffer-adr
234 disp-width disp-height
235 disp-width char-width / disp-height char-height /
236 disp-depth 7 + 8 / ( width height #lines #cols depth )
238 true to is-installed?
243 s" screen" find-alias 0= IF
244 \ no previous screen alias defined, define it...
245 s" screen" get-node node>path set-alias
263 ' display-install is-install
264 ' display-remove is-remove