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 : vbe! ( value index -- )
56 : vbe@ ( index -- value )
60 : color! ( r g b number -- )
67 : color@ ( number -- r g b )
74 : set-colors ( adr number #numbers -- )
84 : get-colors ( adr number #numbers -- )
90 \ qemu fake VBE IO registers
91 0 CONSTANT VBE_DISPI_INDEX_ID
92 1 CONSTANT VBE_DISPI_INDEX_XRES
93 2 CONSTANT VBE_DISPI_INDEX_YRES
94 3 CONSTANT VBE_DISPI_INDEX_BPP
95 4 CONSTANT VBE_DISPI_INDEX_ENABLE
96 5 CONSTANT VBE_DISPI_INDEX_BANK
97 6 CONSTANT VBE_DISPI_INDEX_VIRT_WIDTH
98 7 CONSTANT VBE_DISPI_INDEX_VIRT_HEIGHT
99 8 CONSTANT VBE_DISPI_INDEX_X_OFFSET
100 9 CONSTANT VBE_DISPI_INDEX_Y_OFFSET
101 a CONSTANT VBE_DISPI_INDEX_NB
104 00 CONSTANT VBE_DISPI_DISABLED
105 01 CONSTANT VBE_DISPI_ENABLED
106 02 CONSTANT VBE_DISPI_GETCAPS
107 20 CONSTANT VBE_DISPI_8BIT_DAC
108 40 CONSTANT VBE_DISPI_LFB_ENABLED
109 80 CONSTANT VBE_DISPI_NOCLEARMEM
113 VBE_DISPI_DISABLED VBE_DISPI_INDEX_ENABLE vbe!
114 0 VBE_DISPI_INDEX_X_OFFSET vbe!
115 0 VBE_DISPI_INDEX_Y_OFFSET vbe!
116 disp-width VBE_DISPI_INDEX_XRES vbe!
117 disp-height VBE_DISPI_INDEX_YRES vbe!
118 disp-depth VBE_DISPI_INDEX_BPP vbe!
119 VBE_DISPI_ENABLED VBE_DISPI_8BIT_DAC or VBE_DISPI_INDEX_ENABLE vbe!
125 fb-base disp-width disp-height disp-depth 7 + 8 / * * 0 rfill
129 s" qemu,graphic-width" get-chosen IF
130 decode-int to disp-width 2drop
132 s" qemu,graphic-height" get-chosen IF
133 decode-int to disp-height 2drop
135 s" qemu,graphic-depth" get-chosen IF
143 ." Unsupported bit depth, using 8bpp " drop cr
149 \ add legacy I/O Ports / Memory regions to assigned-addresses
150 \ see PCI Bus Binding Revision 2.1 Section 7.
151 s" reg" get-node get-property IF
152 \ "reg" does not exist, create new
155 \ "reg" does exist, copy it
158 \ I/O Range 0x1ce-0x1d2
159 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
160 1ce encode-64+ 4 encode-64+ \ addr size
161 \ I/O Range 0x3B0-0x3BB
162 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
163 3b0 encode-64+ c encode-64+ \ addr size
164 \ I/O Range 0x3C0-0x3DF
165 my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
166 3c0 encode-64+ 20 encode-64+ \ addr size
167 \ Memory Range 0xA0000-0xBFFFF
168 my-space a2000000 or encode-int+ \ non-relocatable, <1MB Memory space
169 a0000 encode-64+ 20000 encode-64+ \ addr size
170 s" reg" property \ store "reg" property
174 \ Shouldn't this be done from open ?
175 disp-width encode-int s" width" property
176 disp-height encode-int s" height" property
177 disp-width disp-depth 7 + 8 / * encode-int s" linebytes" property
178 disp-depth encode-int s" depth" property
179 s" ISO8859-1" encode-string s" character-set" property \ i hope this is ok...
180 \ add "device_type" property
181 s" display" device-type
182 s" qemu,std-vga" encode-string s" compatible" property
183 \ XXX We don't create an "address" property because Linux doesn't know what
184 \ to do with it for >32-bit
187 \ words for installation/removal, needed by is-install/is-remove, see display.fs
188 : display-remove ( -- )
191 : hcall-invert-screen ( -- )
192 frame-buffer-adr frame-buffer-adr 3
193 screen-height screen-width * screen-depth * /x /
198 : hcall-blink-screen ( -- )
199 \ 32 msec delay for visually noticing the blink
200 hcall-invert-screen 20 ms hcall-invert-screen
203 : display-install ( -- )
205 ." Installing QEMU fb" cr
206 fb-base to frame-buffer-adr
210 disp-width disp-height
211 disp-width char-width / disp-height char-height /
212 disp-depth 7 + 8 / ( width height #lines #cols depth )
214 ['] hcall-invert-screen to invert-screen
215 ['] hcall-blink-screen to blink-screen
216 true to is-installed?
221 s" screen" find-alias 0= IF
222 \ no previous screen alias defined, define it...
223 s" screen" get-node node>path set-alias
240 ' display-install is-install
241 ' display-remove is-remove