1 \ *****************************************************************************
2 \ * Copyright (c) 2015 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 : map-in " map-in" my-phandle parent $call-static ;
21 : map-out " map-out" my-phandle parent $call-static ;
23 \ Determine base address
24 0 0 my-space h# 02000010 + 1 map-in VALUE fb-base
25 0 0 my-space h# 02000018 + 1 map-in VALUE reg-base
27 \ We support only one instance
28 false VALUE is-installed?
30 : vga-w! ( value port -- )
31 3c0 - reg-base 400 + + rw!-le
34 : vga-w@ ( port -- value )
35 3c0 - reg-base 400 + + rw@-le
38 : vga-b! ( value port -- )
39 3c0 - reg-base 400 + + rb!
42 : vga-b@ ( port -- value )
43 3c0 - reg-base 400 + + rb@
46 : vbe! ( value index -- )
47 1 << reg-base 500 + + rw!-le
50 : vbe@ ( index -- value )
51 1 << reg-base 500 + + rw@-le
54 : color! ( r g b number -- )
61 : color@ ( number -- r g b )
68 : set-colors ( adr number #numbers -- )
78 : get-colors ( adr number #numbers -- )
84 \ qemu fake VBE IO registers
85 0 CONSTANT VBE_DISPI_INDEX_ID
86 1 CONSTANT VBE_DISPI_INDEX_XRES
87 2 CONSTANT VBE_DISPI_INDEX_YRES
88 3 CONSTANT VBE_DISPI_INDEX_BPP
89 4 CONSTANT VBE_DISPI_INDEX_ENABLE
90 5 CONSTANT VBE_DISPI_INDEX_BANK
91 6 CONSTANT VBE_DISPI_INDEX_VIRT_WIDTH
92 7 CONSTANT VBE_DISPI_INDEX_VIRT_HEIGHT
93 8 CONSTANT VBE_DISPI_INDEX_X_OFFSET
94 9 CONSTANT VBE_DISPI_INDEX_Y_OFFSET
95 a CONSTANT VBE_DISPI_INDEX_NB
98 00 CONSTANT VBE_DISPI_DISABLED
99 01 CONSTANT VBE_DISPI_ENABLED
100 02 CONSTANT VBE_DISPI_GETCAPS
101 20 CONSTANT VBE_DISPI_8BIT_DAC
102 40 CONSTANT VBE_DISPI_LFB_ENABLED
103 80 CONSTANT VBE_DISPI_NOCLEARMEM
107 VBE_DISPI_DISABLED VBE_DISPI_INDEX_ENABLE vbe!
108 0 VBE_DISPI_INDEX_X_OFFSET vbe!
109 0 VBE_DISPI_INDEX_Y_OFFSET vbe!
110 disp-width VBE_DISPI_INDEX_XRES vbe!
111 disp-height VBE_DISPI_INDEX_YRES vbe!
112 disp-depth VBE_DISPI_INDEX_BPP vbe!
113 VBE_DISPI_ENABLED VBE_DISPI_8BIT_DAC or VBE_DISPI_INDEX_ENABLE vbe!
119 fb-base disp-width disp-height disp-depth 7 + 8 / * * 0 rfill
123 s" qemu,graphic-width" get-chosen IF
124 decode-int to disp-width 2drop
126 s" qemu,graphic-height" get-chosen IF
127 decode-int to disp-height 2drop
129 s" qemu,graphic-depth" get-chosen IF
137 ." Unsupported bit depth, using 8bpp " drop cr
143 \ Shouldn't this be done from open ?
144 disp-width encode-int s" width" property
145 disp-height encode-int s" height" property
146 disp-width disp-depth 7 + 8 / * encode-int s" linebytes" property
147 disp-depth encode-int s" depth" property
148 s" ISO8859-1" encode-string s" character-set" property \ i hope this is ok...
149 \ add "device_type" property
150 s" display" device-type
151 s" qemu,std-vga" encode-string s" compatible" property
152 \ XXX We don't create an "address" property because Linux doesn't know what
153 \ to do with it for >32-bit
156 \ words for installation/removal, needed by is-install/is-remove, see display.fs
157 : display-remove ( -- )
160 : slow-blink-screen ( -- )
161 \ 32 msec delay for visually noticing the blink
162 invert-screen 20 ms invert-screen
165 : display-install ( -- )
167 ." Installing QEMU fb" cr
168 fb-base to frame-buffer-adr
172 disp-width disp-height
173 disp-width char-width / disp-height char-height /
174 disp-depth 7 + 8 / ( width height #lines #cols depth )
176 ['] slow-blink-screen to blink-screen
177 true to is-installed?
182 s" screen" find-alias 0= IF
183 \ no previous screen alias defined, define it...
184 s" screen" get-node node>path set-alias
196 ' display-install is-install
197 ' display-remove is-remove