root / hw / cirrus_vga.c @ 513f789f
History | View | Annotate | Download (100 kB)
1 | e6e5ad80 | bellard | /*
|
---|---|---|---|
2 | aeb3c85f | bellard | * QEMU Cirrus CLGD 54xx VGA Emulator.
|
3 | 5fafdf24 | ths | *
|
4 | e6e5ad80 | bellard | * Copyright (c) 2004 Fabrice Bellard
|
5 | aeb3c85f | bellard | * Copyright (c) 2004 Makoto Suzuki (suzu)
|
6 | 5fafdf24 | ths | *
|
7 | e6e5ad80 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | e6e5ad80 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
9 | e6e5ad80 | bellard | * in the Software without restriction, including without limitation the rights
|
10 | e6e5ad80 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | e6e5ad80 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
12 | e6e5ad80 | bellard | * furnished to do so, subject to the following conditions:
|
13 | e6e5ad80 | bellard | *
|
14 | e6e5ad80 | bellard | * The above copyright notice and this permission notice shall be included in
|
15 | e6e5ad80 | bellard | * all copies or substantial portions of the Software.
|
16 | e6e5ad80 | bellard | *
|
17 | e6e5ad80 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | e6e5ad80 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | e6e5ad80 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | e6e5ad80 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | e6e5ad80 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | e6e5ad80 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | e6e5ad80 | bellard | * THE SOFTWARE.
|
24 | e6e5ad80 | bellard | */
|
25 | aeb3c85f | bellard | /*
|
26 | aeb3c85f | bellard | * Reference: Finn Thogersons' VGADOC4b
|
27 | aeb3c85f | bellard | * available at http://home.worldonline.dk/~finth/
|
28 | aeb3c85f | bellard | */
|
29 | 87ecb68b | pbrook | #include "hw.h" |
30 | 87ecb68b | pbrook | #include "pc.h" |
31 | 87ecb68b | pbrook | #include "pci.h" |
32 | 87ecb68b | pbrook | #include "console.h" |
33 | e6e5ad80 | bellard | #include "vga_int.h" |
34 | 2bec46dc | aliguori | #include "kvm.h" |
35 | e6e5ad80 | bellard | |
36 | a5082316 | bellard | /*
|
37 | a5082316 | bellard | * TODO:
|
38 | ad81218e | bellard | * - destination write mask support not complete (bits 5..7)
|
39 | a5082316 | bellard | * - optimize linear mappings
|
40 | a5082316 | bellard | * - optimize bitblt functions
|
41 | a5082316 | bellard | */
|
42 | a5082316 | bellard | |
43 | e36f36e1 | bellard | //#define DEBUG_CIRRUS
|
44 | a21ae81d | bellard | //#define DEBUG_BITBLT
|
45 | e36f36e1 | bellard | |
46 | e6e5ad80 | bellard | /***************************************
|
47 | e6e5ad80 | bellard | *
|
48 | e6e5ad80 | bellard | * definitions
|
49 | e6e5ad80 | bellard | *
|
50 | e6e5ad80 | bellard | ***************************************/
|
51 | e6e5ad80 | bellard | |
52 | e6e5ad80 | bellard | #define qemu_MIN(a,b) ((a) < (b) ? (a) : (b))
|
53 | e6e5ad80 | bellard | |
54 | e6e5ad80 | bellard | // ID
|
55 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5422 (0x23<<2) |
56 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5426 (0x24<<2) |
57 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5424 (0x25<<2) |
58 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5428 (0x26<<2) |
59 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5430 (0x28<<2) |
60 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5434 (0x2A<<2) |
61 | a21ae81d | bellard | #define CIRRUS_ID_CLGD5436 (0x2B<<2) |
62 | e6e5ad80 | bellard | #define CIRRUS_ID_CLGD5446 (0x2E<<2) |
63 | e6e5ad80 | bellard | |
64 | e6e5ad80 | bellard | // sequencer 0x07
|
65 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_VGA 0x00 |
66 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_SVGA 0x01 |
67 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_MASK 0x0e |
68 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_8 0x00 |
69 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_16_DOUBLEVCLK 0x02 |
70 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_24 0x04 |
71 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_16 0x06 |
72 | e6e5ad80 | bellard | #define CIRRUS_SR7_BPP_32 0x08 |
73 | e6e5ad80 | bellard | #define CIRRUS_SR7_ISAADDR_MASK 0xe0 |
74 | e6e5ad80 | bellard | |
75 | e6e5ad80 | bellard | // sequencer 0x0f
|
76 | e6e5ad80 | bellard | #define CIRRUS_MEMSIZE_512k 0x08 |
77 | e6e5ad80 | bellard | #define CIRRUS_MEMSIZE_1M 0x10 |
78 | e6e5ad80 | bellard | #define CIRRUS_MEMSIZE_2M 0x18 |
79 | e6e5ad80 | bellard | #define CIRRUS_MEMFLAGS_BANKSWITCH 0x80 // bank switching is enabled. |
80 | e6e5ad80 | bellard | |
81 | e6e5ad80 | bellard | // sequencer 0x12
|
82 | e6e5ad80 | bellard | #define CIRRUS_CURSOR_SHOW 0x01 |
83 | e6e5ad80 | bellard | #define CIRRUS_CURSOR_HIDDENPEL 0x02 |
84 | e6e5ad80 | bellard | #define CIRRUS_CURSOR_LARGE 0x04 // 64x64 if set, 32x32 if clear |
85 | e6e5ad80 | bellard | |
86 | e6e5ad80 | bellard | // sequencer 0x17
|
87 | e6e5ad80 | bellard | #define CIRRUS_BUSTYPE_VLBFAST 0x10 |
88 | e6e5ad80 | bellard | #define CIRRUS_BUSTYPE_PCI 0x20 |
89 | e6e5ad80 | bellard | #define CIRRUS_BUSTYPE_VLBSLOW 0x30 |
90 | e6e5ad80 | bellard | #define CIRRUS_BUSTYPE_ISA 0x38 |
91 | e6e5ad80 | bellard | #define CIRRUS_MMIO_ENABLE 0x04 |
92 | e6e5ad80 | bellard | #define CIRRUS_MMIO_USE_PCIADDR 0x40 // 0xb8000 if cleared. |
93 | e6e5ad80 | bellard | #define CIRRUS_MEMSIZEEXT_DOUBLE 0x80 |
94 | e6e5ad80 | bellard | |
95 | e6e5ad80 | bellard | // control 0x0b
|
96 | e6e5ad80 | bellard | #define CIRRUS_BANKING_DUAL 0x01 |
97 | e6e5ad80 | bellard | #define CIRRUS_BANKING_GRANULARITY_16K 0x20 // set:16k, clear:4k |
98 | e6e5ad80 | bellard | |
99 | e6e5ad80 | bellard | // control 0x30
|
100 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_BACKWARDS 0x01 |
101 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_MEMSYSDEST 0x02 |
102 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_MEMSYSSRC 0x04 |
103 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_TRANSPARENTCOMP 0x08 |
104 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PATTERNCOPY 0x40 |
105 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_COLOREXPAND 0x80 |
106 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PIXELWIDTHMASK 0x30 |
107 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PIXELWIDTH8 0x00 |
108 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PIXELWIDTH16 0x10 |
109 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PIXELWIDTH24 0x20 |
110 | e6e5ad80 | bellard | #define CIRRUS_BLTMODE_PIXELWIDTH32 0x30 |
111 | e6e5ad80 | bellard | |
112 | e6e5ad80 | bellard | // control 0x31
|
113 | e6e5ad80 | bellard | #define CIRRUS_BLT_BUSY 0x01 |
114 | e6e5ad80 | bellard | #define CIRRUS_BLT_START 0x02 |
115 | e6e5ad80 | bellard | #define CIRRUS_BLT_RESET 0x04 |
116 | e6e5ad80 | bellard | #define CIRRUS_BLT_FIFOUSED 0x10 |
117 | a5082316 | bellard | #define CIRRUS_BLT_AUTOSTART 0x80 |
118 | e6e5ad80 | bellard | |
119 | e6e5ad80 | bellard | // control 0x32
|
120 | e6e5ad80 | bellard | #define CIRRUS_ROP_0 0x00 |
121 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_AND_DST 0x05 |
122 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOP 0x06 |
123 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_AND_NOTDST 0x09 |
124 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTDST 0x0b |
125 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC 0x0d |
126 | e6e5ad80 | bellard | #define CIRRUS_ROP_1 0x0e |
127 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTSRC_AND_DST 0x50 |
128 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_XOR_DST 0x59 |
129 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_OR_DST 0x6d |
130 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTSRC_OR_NOTDST 0x90 |
131 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_NOTXOR_DST 0x95 |
132 | e6e5ad80 | bellard | #define CIRRUS_ROP_SRC_OR_NOTDST 0xad |
133 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTSRC 0xd0 |
134 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTSRC_OR_DST 0xd6 |
135 | e6e5ad80 | bellard | #define CIRRUS_ROP_NOTSRC_AND_NOTDST 0xda |
136 | e6e5ad80 | bellard | |
137 | a5082316 | bellard | #define CIRRUS_ROP_NOP_INDEX 2 |
138 | a5082316 | bellard | #define CIRRUS_ROP_SRC_INDEX 5 |
139 | a5082316 | bellard | |
140 | a21ae81d | bellard | // control 0x33
|
141 | a5082316 | bellard | #define CIRRUS_BLTMODEEXT_SOLIDFILL 0x04 |
142 | 4c8732d7 | bellard | #define CIRRUS_BLTMODEEXT_COLOREXPINV 0x02 |
143 | a5082316 | bellard | #define CIRRUS_BLTMODEEXT_DWORDGRANULARITY 0x01 |
144 | a21ae81d | bellard | |
145 | e6e5ad80 | bellard | // memory-mapped IO
|
146 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTBGCOLOR 0x00 // dword |
147 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTFGCOLOR 0x04 // dword |
148 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTWIDTH 0x08 // word |
149 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTHEIGHT 0x0a // word |
150 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTDESTPITCH 0x0c // word |
151 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTSRCPITCH 0x0e // word |
152 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTDESTADDR 0x10 // dword |
153 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTSRCADDR 0x14 // dword |
154 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTWRITEMASK 0x17 // byte |
155 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTMODE 0x18 // byte |
156 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTROP 0x1a // byte |
157 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTMODEEXT 0x1b // byte |
158 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTTRANSPARENTCOLOR 0x1c // word? |
159 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK 0x20 // word? |
160 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_START_X 0x24 // word |
161 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_START_Y 0x26 // word |
162 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_END_X 0x28 // word |
163 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_END_Y 0x2a // word |
164 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_LINESTYLE_INC 0x2c // byte |
165 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_LINESTYLE_ROLLOVER 0x2d // byte |
166 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_LINESTYLE_MASK 0x2e // byte |
167 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEARDRAW_LINESTYLE_ACCUM 0x2f // byte |
168 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BRESENHAM_K1 0x30 // word |
169 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BRESENHAM_K3 0x32 // word |
170 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BRESENHAM_ERROR 0x34 // word |
171 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BRESENHAM_DELTA_MAJOR 0x36 // word |
172 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BRESENHAM_DIRECTION 0x38 // byte |
173 | e6e5ad80 | bellard | #define CIRRUS_MMIO_LINEDRAW_MODE 0x39 // byte |
174 | e6e5ad80 | bellard | #define CIRRUS_MMIO_BLTSTATUS 0x40 // byte |
175 | e6e5ad80 | bellard | |
176 | deb54399 | aliguori | // PCI 0x02: device
|
177 | e6e5ad80 | bellard | #define PCI_DEVICE_CLGD5462 0x00d0 |
178 | e6e5ad80 | bellard | #define PCI_DEVICE_CLGD5465 0x00d6 |
179 | a21ae81d | bellard | |
180 | e6e5ad80 | bellard | // PCI 0x04: command(word), 0x06(word): status
|
181 | e6e5ad80 | bellard | #define PCI_COMMAND_IOACCESS 0x0001 |
182 | e6e5ad80 | bellard | #define PCI_COMMAND_MEMACCESS 0x0002 |
183 | e6e5ad80 | bellard | #define PCI_COMMAND_BUSMASTER 0x0004 |
184 | e6e5ad80 | bellard | #define PCI_COMMAND_SPECIALCYCLE 0x0008 |
185 | e6e5ad80 | bellard | #define PCI_COMMAND_MEMWRITEINVALID 0x0010 |
186 | e6e5ad80 | bellard | #define PCI_COMMAND_PALETTESNOOPING 0x0020 |
187 | e6e5ad80 | bellard | #define PCI_COMMAND_PARITYDETECTION 0x0040 |
188 | e6e5ad80 | bellard | #define PCI_COMMAND_ADDRESSDATASTEPPING 0x0080 |
189 | e6e5ad80 | bellard | #define PCI_COMMAND_SERR 0x0100 |
190 | e6e5ad80 | bellard | #define PCI_COMMAND_BACKTOBACKTRANS 0x0200 |
191 | e6e5ad80 | bellard | // PCI 0x08, 0xff000000 (0x09-0x0b:class,0x08:rev)
|
192 | e6e5ad80 | bellard | #define PCI_CLASS_BASE_DISPLAY 0x03 |
193 | e6e5ad80 | bellard | // PCI 0x08, 0x00ff0000
|
194 | e6e5ad80 | bellard | #define PCI_CLASS_SUB_VGA 0x00 |
195 | e6e5ad80 | bellard | // PCI 0x0c, 0x00ff0000 (0x0c:cacheline,0x0d:latency,0x0e:headertype,0x0f:Built-in self test)
|
196 | e6e5ad80 | bellard | #define PCI_CLASS_HEADERTYPE_00h 0x00 |
197 | e6e5ad80 | bellard | // 0x10-0x3f (headertype 00h)
|
198 | e6e5ad80 | bellard | // PCI 0x10,0x14,0x18,0x1c,0x20,0x24: base address mapping registers
|
199 | e6e5ad80 | bellard | // 0x10: MEMBASE, 0x14: IOBASE(hard-coded in XFree86 3.x)
|
200 | e6e5ad80 | bellard | #define PCI_MAP_MEM 0x0 |
201 | e6e5ad80 | bellard | #define PCI_MAP_IO 0x1 |
202 | e6e5ad80 | bellard | #define PCI_MAP_MEM_ADDR_MASK (~0xf) |
203 | e6e5ad80 | bellard | #define PCI_MAP_IO_ADDR_MASK (~0x3) |
204 | e6e5ad80 | bellard | #define PCI_MAP_MEMFLAGS_32BIT 0x0 |
205 | e6e5ad80 | bellard | #define PCI_MAP_MEMFLAGS_32BIT_1M 0x1 |
206 | e6e5ad80 | bellard | #define PCI_MAP_MEMFLAGS_64BIT 0x4 |
207 | e6e5ad80 | bellard | #define PCI_MAP_MEMFLAGS_CACHEABLE 0x8 |
208 | e6e5ad80 | bellard | // PCI 0x28: cardbus CIS pointer
|
209 | e6e5ad80 | bellard | // PCI 0x2c: subsystem vendor id, 0x2e: subsystem id
|
210 | e6e5ad80 | bellard | // PCI 0x30: expansion ROM base address
|
211 | e6e5ad80 | bellard | #define PCI_ROMBIOS_ENABLED 0x1 |
212 | e6e5ad80 | bellard | // PCI 0x34: 0xffffff00=reserved, 0x000000ff=capabilities pointer
|
213 | e6e5ad80 | bellard | // PCI 0x38: reserved
|
214 | e6e5ad80 | bellard | // PCI 0x3c: 0x3c=int-line, 0x3d=int-pin, 0x3e=min-gnt, 0x3f=maax-lat
|
215 | e6e5ad80 | bellard | |
216 | a21ae81d | bellard | #define CIRRUS_PNPMMIO_SIZE 0x1000 |
217 | e6e5ad80 | bellard | |
218 | e6e5ad80 | bellard | |
219 | e6e5ad80 | bellard | /* I/O and memory hook */
|
220 | e6e5ad80 | bellard | #define CIRRUS_HOOK_NOT_HANDLED 0 |
221 | e6e5ad80 | bellard | #define CIRRUS_HOOK_HANDLED 1 |
222 | e6e5ad80 | bellard | |
223 | b2b183c2 | aliguori | #define ABS(a) ((signed)(a) > 0 ? a : -a) |
224 | b2b183c2 | aliguori | |
225 | b2eb849d | aurel32 | #define BLTUNSAFE(s) \
|
226 | b2eb849d | aurel32 | ( \ |
227 | b2eb849d | aurel32 | ( /* check dst is within bounds */ \
|
228 | b2b183c2 | aliguori | (s)->cirrus_blt_height * ABS((s)->cirrus_blt_dstpitch) \ |
229 | b2eb849d | aurel32 | + ((s)->cirrus_blt_dstaddr & (s)->cirrus_addr_mask) > \ |
230 | b2eb849d | aurel32 | (s)->vram_size \ |
231 | b2eb849d | aurel32 | ) || \ |
232 | b2eb849d | aurel32 | ( /* check src is within bounds */ \
|
233 | b2b183c2 | aliguori | (s)->cirrus_blt_height * ABS((s)->cirrus_blt_srcpitch) \ |
234 | b2eb849d | aurel32 | + ((s)->cirrus_blt_srcaddr & (s)->cirrus_addr_mask) > \ |
235 | b2eb849d | aurel32 | (s)->vram_size \ |
236 | b2eb849d | aurel32 | ) \ |
237 | b2eb849d | aurel32 | ) |
238 | b2eb849d | aurel32 | |
239 | a5082316 | bellard | struct CirrusVGAState;
|
240 | a5082316 | bellard | typedef void (*cirrus_bitblt_rop_t) (struct CirrusVGAState *s, |
241 | a5082316 | bellard | uint8_t * dst, const uint8_t * src,
|
242 | e6e5ad80 | bellard | int dstpitch, int srcpitch, |
243 | e6e5ad80 | bellard | int bltwidth, int bltheight); |
244 | a5082316 | bellard | typedef void (*cirrus_fill_t)(struct CirrusVGAState *s, |
245 | a5082316 | bellard | uint8_t *dst, int dst_pitch, int width, int height); |
246 | e6e5ad80 | bellard | |
247 | e6e5ad80 | bellard | typedef struct CirrusVGAState { |
248 | 4e3e9d0b | bellard | VGA_STATE_COMMON |
249 | e6e5ad80 | bellard | |
250 | e6e5ad80 | bellard | int cirrus_linear_io_addr;
|
251 | a5082316 | bellard | int cirrus_linear_bitblt_io_addr;
|
252 | e6e5ad80 | bellard | int cirrus_mmio_io_addr;
|
253 | e6e5ad80 | bellard | uint32_t cirrus_addr_mask; |
254 | 78e127ef | bellard | uint32_t linear_mmio_mask; |
255 | e6e5ad80 | bellard | uint8_t cirrus_shadow_gr0; |
256 | e6e5ad80 | bellard | uint8_t cirrus_shadow_gr1; |
257 | e6e5ad80 | bellard | uint8_t cirrus_hidden_dac_lockindex; |
258 | e6e5ad80 | bellard | uint8_t cirrus_hidden_dac_data; |
259 | e6e5ad80 | bellard | uint32_t cirrus_bank_base[2];
|
260 | e6e5ad80 | bellard | uint32_t cirrus_bank_limit[2];
|
261 | e6e5ad80 | bellard | uint8_t cirrus_hidden_palette[48];
|
262 | a5082316 | bellard | uint32_t hw_cursor_x; |
263 | a5082316 | bellard | uint32_t hw_cursor_y; |
264 | e6e5ad80 | bellard | int cirrus_blt_pixelwidth;
|
265 | e6e5ad80 | bellard | int cirrus_blt_width;
|
266 | e6e5ad80 | bellard | int cirrus_blt_height;
|
267 | e6e5ad80 | bellard | int cirrus_blt_dstpitch;
|
268 | e6e5ad80 | bellard | int cirrus_blt_srcpitch;
|
269 | a5082316 | bellard | uint32_t cirrus_blt_fgcol; |
270 | a5082316 | bellard | uint32_t cirrus_blt_bgcol; |
271 | e6e5ad80 | bellard | uint32_t cirrus_blt_dstaddr; |
272 | e6e5ad80 | bellard | uint32_t cirrus_blt_srcaddr; |
273 | e6e5ad80 | bellard | uint8_t cirrus_blt_mode; |
274 | a5082316 | bellard | uint8_t cirrus_blt_modeext; |
275 | e6e5ad80 | bellard | cirrus_bitblt_rop_t cirrus_rop; |
276 | a5082316 | bellard | #define CIRRUS_BLTBUFSIZE (2048 * 4) /* one line width */ |
277 | e6e5ad80 | bellard | uint8_t cirrus_bltbuf[CIRRUS_BLTBUFSIZE]; |
278 | e6e5ad80 | bellard | uint8_t *cirrus_srcptr; |
279 | e6e5ad80 | bellard | uint8_t *cirrus_srcptr_end; |
280 | e6e5ad80 | bellard | uint32_t cirrus_srccounter; |
281 | a5082316 | bellard | /* hwcursor display state */
|
282 | a5082316 | bellard | int last_hw_cursor_size;
|
283 | a5082316 | bellard | int last_hw_cursor_x;
|
284 | a5082316 | bellard | int last_hw_cursor_y;
|
285 | a5082316 | bellard | int last_hw_cursor_y_start;
|
286 | a5082316 | bellard | int last_hw_cursor_y_end;
|
287 | 78e127ef | bellard | int real_vram_size; /* XXX: suppress that */ |
288 | 8926b517 | bellard | CPUWriteMemoryFunc **cirrus_linear_write; |
289 | 4abc796d | blueswir1 | int device_id;
|
290 | 4abc796d | blueswir1 | int bustype;
|
291 | e6e5ad80 | bellard | } CirrusVGAState; |
292 | e6e5ad80 | bellard | |
293 | e6e5ad80 | bellard | typedef struct PCICirrusVGAState { |
294 | e6e5ad80 | bellard | PCIDevice dev; |
295 | e6e5ad80 | bellard | CirrusVGAState cirrus_vga; |
296 | e6e5ad80 | bellard | } PCICirrusVGAState; |
297 | e6e5ad80 | bellard | |
298 | a5082316 | bellard | static uint8_t rop_to_index[256]; |
299 | 3b46e624 | ths | |
300 | e6e5ad80 | bellard | /***************************************
|
301 | e6e5ad80 | bellard | *
|
302 | e6e5ad80 | bellard | * prototypes.
|
303 | e6e5ad80 | bellard | *
|
304 | e6e5ad80 | bellard | ***************************************/
|
305 | e6e5ad80 | bellard | |
306 | e6e5ad80 | bellard | |
307 | 8926b517 | bellard | static void cirrus_bitblt_reset(CirrusVGAState *s); |
308 | 8926b517 | bellard | static void cirrus_update_memory_access(CirrusVGAState *s); |
309 | e6e5ad80 | bellard | |
310 | e6e5ad80 | bellard | /***************************************
|
311 | e6e5ad80 | bellard | *
|
312 | e6e5ad80 | bellard | * raster operations
|
313 | e6e5ad80 | bellard | *
|
314 | e6e5ad80 | bellard | ***************************************/
|
315 | e6e5ad80 | bellard | |
316 | a5082316 | bellard | static void cirrus_bitblt_rop_nop(CirrusVGAState *s, |
317 | a5082316 | bellard | uint8_t *dst,const uint8_t *src,
|
318 | a5082316 | bellard | int dstpitch,int srcpitch, |
319 | a5082316 | bellard | int bltwidth,int bltheight) |
320 | a5082316 | bellard | { |
321 | e6e5ad80 | bellard | } |
322 | e6e5ad80 | bellard | |
323 | a5082316 | bellard | static void cirrus_bitblt_fill_nop(CirrusVGAState *s, |
324 | a5082316 | bellard | uint8_t *dst, |
325 | a5082316 | bellard | int dstpitch, int bltwidth,int bltheight) |
326 | e6e5ad80 | bellard | { |
327 | a5082316 | bellard | } |
328 | e6e5ad80 | bellard | |
329 | a5082316 | bellard | #define ROP_NAME 0 |
330 | a5082316 | bellard | #define ROP_OP(d, s) d = 0 |
331 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
332 | e6e5ad80 | bellard | |
333 | a5082316 | bellard | #define ROP_NAME src_and_dst
|
334 | a5082316 | bellard | #define ROP_OP(d, s) d = (s) & (d)
|
335 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
336 | e6e5ad80 | bellard | |
337 | a5082316 | bellard | #define ROP_NAME src_and_notdst
|
338 | a5082316 | bellard | #define ROP_OP(d, s) d = (s) & (~(d))
|
339 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
340 | e6e5ad80 | bellard | |
341 | a5082316 | bellard | #define ROP_NAME notdst
|
342 | a5082316 | bellard | #define ROP_OP(d, s) d = ~(d)
|
343 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
344 | e6e5ad80 | bellard | |
345 | a5082316 | bellard | #define ROP_NAME src
|
346 | a5082316 | bellard | #define ROP_OP(d, s) d = s
|
347 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
348 | e6e5ad80 | bellard | |
349 | a5082316 | bellard | #define ROP_NAME 1 |
350 | 4c8732d7 | bellard | #define ROP_OP(d, s) d = ~0 |
351 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
352 | a5082316 | bellard | |
353 | a5082316 | bellard | #define ROP_NAME notsrc_and_dst
|
354 | a5082316 | bellard | #define ROP_OP(d, s) d = (~(s)) & (d)
|
355 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
356 | a5082316 | bellard | |
357 | a5082316 | bellard | #define ROP_NAME src_xor_dst
|
358 | a5082316 | bellard | #define ROP_OP(d, s) d = (s) ^ (d)
|
359 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
360 | a5082316 | bellard | |
361 | a5082316 | bellard | #define ROP_NAME src_or_dst
|
362 | a5082316 | bellard | #define ROP_OP(d, s) d = (s) | (d)
|
363 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
364 | a5082316 | bellard | |
365 | a5082316 | bellard | #define ROP_NAME notsrc_or_notdst
|
366 | a5082316 | bellard | #define ROP_OP(d, s) d = (~(s)) | (~(d))
|
367 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
368 | a5082316 | bellard | |
369 | a5082316 | bellard | #define ROP_NAME src_notxor_dst
|
370 | a5082316 | bellard | #define ROP_OP(d, s) d = ~((s) ^ (d))
|
371 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
372 | e6e5ad80 | bellard | |
373 | a5082316 | bellard | #define ROP_NAME src_or_notdst
|
374 | a5082316 | bellard | #define ROP_OP(d, s) d = (s) | (~(d))
|
375 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
376 | a5082316 | bellard | |
377 | a5082316 | bellard | #define ROP_NAME notsrc
|
378 | a5082316 | bellard | #define ROP_OP(d, s) d = (~(s))
|
379 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
380 | a5082316 | bellard | |
381 | a5082316 | bellard | #define ROP_NAME notsrc_or_dst
|
382 | a5082316 | bellard | #define ROP_OP(d, s) d = (~(s)) | (d)
|
383 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
384 | a5082316 | bellard | |
385 | a5082316 | bellard | #define ROP_NAME notsrc_and_notdst
|
386 | a5082316 | bellard | #define ROP_OP(d, s) d = (~(s)) & (~(d))
|
387 | a5082316 | bellard | #include "cirrus_vga_rop.h" |
388 | a5082316 | bellard | |
389 | a5082316 | bellard | static const cirrus_bitblt_rop_t cirrus_fwd_rop[16] = { |
390 | a5082316 | bellard | cirrus_bitblt_rop_fwd_0, |
391 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_and_dst, |
392 | a5082316 | bellard | cirrus_bitblt_rop_nop, |
393 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_and_notdst, |
394 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notdst, |
395 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src, |
396 | a5082316 | bellard | cirrus_bitblt_rop_fwd_1, |
397 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notsrc_and_dst, |
398 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_xor_dst, |
399 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_or_dst, |
400 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notsrc_or_notdst, |
401 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_notxor_dst, |
402 | a5082316 | bellard | cirrus_bitblt_rop_fwd_src_or_notdst, |
403 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notsrc, |
404 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notsrc_or_dst, |
405 | a5082316 | bellard | cirrus_bitblt_rop_fwd_notsrc_and_notdst, |
406 | a5082316 | bellard | }; |
407 | a5082316 | bellard | |
408 | a5082316 | bellard | static const cirrus_bitblt_rop_t cirrus_bkwd_rop[16] = { |
409 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_0, |
410 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_and_dst, |
411 | a5082316 | bellard | cirrus_bitblt_rop_nop, |
412 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_and_notdst, |
413 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notdst, |
414 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src, |
415 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_1, |
416 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notsrc_and_dst, |
417 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_xor_dst, |
418 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_or_dst, |
419 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notsrc_or_notdst, |
420 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_notxor_dst, |
421 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_src_or_notdst, |
422 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notsrc, |
423 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notsrc_or_dst, |
424 | a5082316 | bellard | cirrus_bitblt_rop_bkwd_notsrc_and_notdst, |
425 | a5082316 | bellard | }; |
426 | 96cf2df8 | ths | |
427 | 96cf2df8 | ths | #define TRANSP_ROP(name) {\
|
428 | 96cf2df8 | ths | name ## _8,\ |
429 | 96cf2df8 | ths | name ## _16,\ |
430 | 96cf2df8 | ths | } |
431 | 96cf2df8 | ths | #define TRANSP_NOP(func) {\
|
432 | 96cf2df8 | ths | func,\ |
433 | 96cf2df8 | ths | func,\ |
434 | 96cf2df8 | ths | } |
435 | 96cf2df8 | ths | |
436 | 96cf2df8 | ths | static const cirrus_bitblt_rop_t cirrus_fwd_transp_rop[16][2] = { |
437 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_0), |
438 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_and_dst), |
439 | 96cf2df8 | ths | TRANSP_NOP(cirrus_bitblt_rop_nop), |
440 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_and_notdst), |
441 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notdst), |
442 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src), |
443 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_1), |
444 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notsrc_and_dst), |
445 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_xor_dst), |
446 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_or_dst), |
447 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notsrc_or_notdst), |
448 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_notxor_dst), |
449 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_src_or_notdst), |
450 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notsrc), |
451 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notsrc_or_dst), |
452 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_fwd_transp_notsrc_and_notdst), |
453 | 96cf2df8 | ths | }; |
454 | 96cf2df8 | ths | |
455 | 96cf2df8 | ths | static const cirrus_bitblt_rop_t cirrus_bkwd_transp_rop[16][2] = { |
456 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_0), |
457 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_and_dst), |
458 | 96cf2df8 | ths | TRANSP_NOP(cirrus_bitblt_rop_nop), |
459 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_and_notdst), |
460 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notdst), |
461 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src), |
462 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_1), |
463 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notsrc_and_dst), |
464 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_xor_dst), |
465 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_or_dst), |
466 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notsrc_or_notdst), |
467 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_notxor_dst), |
468 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_src_or_notdst), |
469 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notsrc), |
470 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notsrc_or_dst), |
471 | 96cf2df8 | ths | TRANSP_ROP(cirrus_bitblt_rop_bkwd_transp_notsrc_and_notdst), |
472 | 96cf2df8 | ths | }; |
473 | 96cf2df8 | ths | |
474 | a5082316 | bellard | #define ROP2(name) {\
|
475 | a5082316 | bellard | name ## _8,\ |
476 | a5082316 | bellard | name ## _16,\ |
477 | a5082316 | bellard | name ## _24,\ |
478 | a5082316 | bellard | name ## _32,\ |
479 | a5082316 | bellard | } |
480 | a5082316 | bellard | |
481 | a5082316 | bellard | #define ROP_NOP2(func) {\
|
482 | a5082316 | bellard | func,\ |
483 | a5082316 | bellard | func,\ |
484 | a5082316 | bellard | func,\ |
485 | a5082316 | bellard | func,\ |
486 | a5082316 | bellard | } |
487 | a5082316 | bellard | |
488 | e69390ce | bellard | static const cirrus_bitblt_rop_t cirrus_patternfill[16][4] = { |
489 | e69390ce | bellard | ROP2(cirrus_patternfill_0), |
490 | e69390ce | bellard | ROP2(cirrus_patternfill_src_and_dst), |
491 | e69390ce | bellard | ROP_NOP2(cirrus_bitblt_rop_nop), |
492 | e69390ce | bellard | ROP2(cirrus_patternfill_src_and_notdst), |
493 | e69390ce | bellard | ROP2(cirrus_patternfill_notdst), |
494 | e69390ce | bellard | ROP2(cirrus_patternfill_src), |
495 | e69390ce | bellard | ROP2(cirrus_patternfill_1), |
496 | e69390ce | bellard | ROP2(cirrus_patternfill_notsrc_and_dst), |
497 | e69390ce | bellard | ROP2(cirrus_patternfill_src_xor_dst), |
498 | e69390ce | bellard | ROP2(cirrus_patternfill_src_or_dst), |
499 | e69390ce | bellard | ROP2(cirrus_patternfill_notsrc_or_notdst), |
500 | e69390ce | bellard | ROP2(cirrus_patternfill_src_notxor_dst), |
501 | e69390ce | bellard | ROP2(cirrus_patternfill_src_or_notdst), |
502 | e69390ce | bellard | ROP2(cirrus_patternfill_notsrc), |
503 | e69390ce | bellard | ROP2(cirrus_patternfill_notsrc_or_dst), |
504 | e69390ce | bellard | ROP2(cirrus_patternfill_notsrc_and_notdst), |
505 | e69390ce | bellard | }; |
506 | e69390ce | bellard | |
507 | a5082316 | bellard | static const cirrus_bitblt_rop_t cirrus_colorexpand_transp[16][4] = { |
508 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_0), |
509 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_and_dst), |
510 | a5082316 | bellard | ROP_NOP2(cirrus_bitblt_rop_nop), |
511 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_and_notdst), |
512 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notdst), |
513 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src), |
514 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_1), |
515 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notsrc_and_dst), |
516 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_xor_dst), |
517 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_or_dst), |
518 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notsrc_or_notdst), |
519 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_notxor_dst), |
520 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_src_or_notdst), |
521 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notsrc), |
522 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notsrc_or_dst), |
523 | a5082316 | bellard | ROP2(cirrus_colorexpand_transp_notsrc_and_notdst), |
524 | a5082316 | bellard | }; |
525 | a5082316 | bellard | |
526 | a5082316 | bellard | static const cirrus_bitblt_rop_t cirrus_colorexpand[16][4] = { |
527 | a5082316 | bellard | ROP2(cirrus_colorexpand_0), |
528 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_and_dst), |
529 | a5082316 | bellard | ROP_NOP2(cirrus_bitblt_rop_nop), |
530 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_and_notdst), |
531 | a5082316 | bellard | ROP2(cirrus_colorexpand_notdst), |
532 | a5082316 | bellard | ROP2(cirrus_colorexpand_src), |
533 | a5082316 | bellard | ROP2(cirrus_colorexpand_1), |
534 | a5082316 | bellard | ROP2(cirrus_colorexpand_notsrc_and_dst), |
535 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_xor_dst), |
536 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_or_dst), |
537 | a5082316 | bellard | ROP2(cirrus_colorexpand_notsrc_or_notdst), |
538 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_notxor_dst), |
539 | a5082316 | bellard | ROP2(cirrus_colorexpand_src_or_notdst), |
540 | a5082316 | bellard | ROP2(cirrus_colorexpand_notsrc), |
541 | a5082316 | bellard | ROP2(cirrus_colorexpand_notsrc_or_dst), |
542 | a5082316 | bellard | ROP2(cirrus_colorexpand_notsrc_and_notdst), |
543 | a5082316 | bellard | }; |
544 | a5082316 | bellard | |
545 | b30d4608 | bellard | static const cirrus_bitblt_rop_t cirrus_colorexpand_pattern_transp[16][4] = { |
546 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_0), |
547 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_and_dst), |
548 | b30d4608 | bellard | ROP_NOP2(cirrus_bitblt_rop_nop), |
549 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_and_notdst), |
550 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notdst), |
551 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src), |
552 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_1), |
553 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notsrc_and_dst), |
554 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_xor_dst), |
555 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_or_dst), |
556 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notsrc_or_notdst), |
557 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_notxor_dst), |
558 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_src_or_notdst), |
559 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notsrc), |
560 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notsrc_or_dst), |
561 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_transp_notsrc_and_notdst), |
562 | b30d4608 | bellard | }; |
563 | b30d4608 | bellard | |
564 | b30d4608 | bellard | static const cirrus_bitblt_rop_t cirrus_colorexpand_pattern[16][4] = { |
565 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_0), |
566 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_and_dst), |
567 | b30d4608 | bellard | ROP_NOP2(cirrus_bitblt_rop_nop), |
568 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_and_notdst), |
569 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notdst), |
570 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src), |
571 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_1), |
572 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notsrc_and_dst), |
573 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_xor_dst), |
574 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_or_dst), |
575 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notsrc_or_notdst), |
576 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_notxor_dst), |
577 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_src_or_notdst), |
578 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notsrc), |
579 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notsrc_or_dst), |
580 | b30d4608 | bellard | ROP2(cirrus_colorexpand_pattern_notsrc_and_notdst), |
581 | b30d4608 | bellard | }; |
582 | b30d4608 | bellard | |
583 | a5082316 | bellard | static const cirrus_fill_t cirrus_fill[16][4] = { |
584 | a5082316 | bellard | ROP2(cirrus_fill_0), |
585 | a5082316 | bellard | ROP2(cirrus_fill_src_and_dst), |
586 | a5082316 | bellard | ROP_NOP2(cirrus_bitblt_fill_nop), |
587 | a5082316 | bellard | ROP2(cirrus_fill_src_and_notdst), |
588 | a5082316 | bellard | ROP2(cirrus_fill_notdst), |
589 | a5082316 | bellard | ROP2(cirrus_fill_src), |
590 | a5082316 | bellard | ROP2(cirrus_fill_1), |
591 | a5082316 | bellard | ROP2(cirrus_fill_notsrc_and_dst), |
592 | a5082316 | bellard | ROP2(cirrus_fill_src_xor_dst), |
593 | a5082316 | bellard | ROP2(cirrus_fill_src_or_dst), |
594 | a5082316 | bellard | ROP2(cirrus_fill_notsrc_or_notdst), |
595 | a5082316 | bellard | ROP2(cirrus_fill_src_notxor_dst), |
596 | a5082316 | bellard | ROP2(cirrus_fill_src_or_notdst), |
597 | a5082316 | bellard | ROP2(cirrus_fill_notsrc), |
598 | a5082316 | bellard | ROP2(cirrus_fill_notsrc_or_dst), |
599 | a5082316 | bellard | ROP2(cirrus_fill_notsrc_and_notdst), |
600 | a5082316 | bellard | }; |
601 | a5082316 | bellard | |
602 | a5082316 | bellard | static inline void cirrus_bitblt_fgcol(CirrusVGAState *s) |
603 | e6e5ad80 | bellard | { |
604 | a5082316 | bellard | unsigned int color; |
605 | a5082316 | bellard | switch (s->cirrus_blt_pixelwidth) {
|
606 | a5082316 | bellard | case 1: |
607 | a5082316 | bellard | s->cirrus_blt_fgcol = s->cirrus_shadow_gr1; |
608 | a5082316 | bellard | break;
|
609 | a5082316 | bellard | case 2: |
610 | a5082316 | bellard | color = s->cirrus_shadow_gr1 | (s->gr[0x11] << 8); |
611 | a5082316 | bellard | s->cirrus_blt_fgcol = le16_to_cpu(color); |
612 | a5082316 | bellard | break;
|
613 | a5082316 | bellard | case 3: |
614 | 5fafdf24 | ths | s->cirrus_blt_fgcol = s->cirrus_shadow_gr1 | |
615 | a5082316 | bellard | (s->gr[0x11] << 8) | (s->gr[0x13] << 16); |
616 | a5082316 | bellard | break;
|
617 | a5082316 | bellard | default:
|
618 | a5082316 | bellard | case 4: |
619 | a5082316 | bellard | color = s->cirrus_shadow_gr1 | (s->gr[0x11] << 8) | |
620 | a5082316 | bellard | (s->gr[0x13] << 16) | (s->gr[0x15] << 24); |
621 | a5082316 | bellard | s->cirrus_blt_fgcol = le32_to_cpu(color); |
622 | a5082316 | bellard | break;
|
623 | e6e5ad80 | bellard | } |
624 | e6e5ad80 | bellard | } |
625 | e6e5ad80 | bellard | |
626 | a5082316 | bellard | static inline void cirrus_bitblt_bgcol(CirrusVGAState *s) |
627 | e6e5ad80 | bellard | { |
628 | a5082316 | bellard | unsigned int color; |
629 | e6e5ad80 | bellard | switch (s->cirrus_blt_pixelwidth) {
|
630 | e6e5ad80 | bellard | case 1: |
631 | a5082316 | bellard | s->cirrus_blt_bgcol = s->cirrus_shadow_gr0; |
632 | a5082316 | bellard | break;
|
633 | e6e5ad80 | bellard | case 2: |
634 | a5082316 | bellard | color = s->cirrus_shadow_gr0 | (s->gr[0x10] << 8); |
635 | a5082316 | bellard | s->cirrus_blt_bgcol = le16_to_cpu(color); |
636 | a5082316 | bellard | break;
|
637 | e6e5ad80 | bellard | case 3: |
638 | 5fafdf24 | ths | s->cirrus_blt_bgcol = s->cirrus_shadow_gr0 | |
639 | a5082316 | bellard | (s->gr[0x10] << 8) | (s->gr[0x12] << 16); |
640 | a5082316 | bellard | break;
|
641 | e6e5ad80 | bellard | default:
|
642 | a5082316 | bellard | case 4: |
643 | a5082316 | bellard | color = s->cirrus_shadow_gr0 | (s->gr[0x10] << 8) | |
644 | a5082316 | bellard | (s->gr[0x12] << 16) | (s->gr[0x14] << 24); |
645 | a5082316 | bellard | s->cirrus_blt_bgcol = le32_to_cpu(color); |
646 | a5082316 | bellard | break;
|
647 | e6e5ad80 | bellard | } |
648 | e6e5ad80 | bellard | } |
649 | e6e5ad80 | bellard | |
650 | e6e5ad80 | bellard | static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin, |
651 | e6e5ad80 | bellard | int off_pitch, int bytesperline, |
652 | e6e5ad80 | bellard | int lines)
|
653 | e6e5ad80 | bellard | { |
654 | e6e5ad80 | bellard | int y;
|
655 | e6e5ad80 | bellard | int off_cur;
|
656 | e6e5ad80 | bellard | int off_cur_end;
|
657 | e6e5ad80 | bellard | |
658 | e6e5ad80 | bellard | for (y = 0; y < lines; y++) { |
659 | e6e5ad80 | bellard | off_cur = off_begin; |
660 | b2eb849d | aurel32 | off_cur_end = (off_cur + bytesperline) & s->cirrus_addr_mask; |
661 | e6e5ad80 | bellard | off_cur &= TARGET_PAGE_MASK; |
662 | e6e5ad80 | bellard | while (off_cur < off_cur_end) {
|
663 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + off_cur); |
664 | e6e5ad80 | bellard | off_cur += TARGET_PAGE_SIZE; |
665 | e6e5ad80 | bellard | } |
666 | e6e5ad80 | bellard | off_begin += off_pitch; |
667 | e6e5ad80 | bellard | } |
668 | e6e5ad80 | bellard | } |
669 | e6e5ad80 | bellard | |
670 | e6e5ad80 | bellard | static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, |
671 | e6e5ad80 | bellard | const uint8_t * src)
|
672 | e6e5ad80 | bellard | { |
673 | e6e5ad80 | bellard | uint8_t *dst; |
674 | e6e5ad80 | bellard | |
675 | b2eb849d | aurel32 | dst = s->vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask); |
676 | b2eb849d | aurel32 | |
677 | b2eb849d | aurel32 | if (BLTUNSAFE(s))
|
678 | b2eb849d | aurel32 | return 0; |
679 | b2eb849d | aurel32 | |
680 | e69390ce | bellard | (*s->cirrus_rop) (s, dst, src, |
681 | 5fafdf24 | ths | s->cirrus_blt_dstpitch, 0,
|
682 | e69390ce | bellard | s->cirrus_blt_width, s->cirrus_blt_height); |
683 | e6e5ad80 | bellard | cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, |
684 | e69390ce | bellard | s->cirrus_blt_dstpitch, s->cirrus_blt_width, |
685 | e69390ce | bellard | s->cirrus_blt_height); |
686 | e6e5ad80 | bellard | return 1; |
687 | e6e5ad80 | bellard | } |
688 | e6e5ad80 | bellard | |
689 | a21ae81d | bellard | /* fill */
|
690 | a21ae81d | bellard | |
691 | a5082316 | bellard | static int cirrus_bitblt_solidfill(CirrusVGAState *s, int blt_rop) |
692 | a21ae81d | bellard | { |
693 | a5082316 | bellard | cirrus_fill_t rop_func; |
694 | a21ae81d | bellard | |
695 | b2eb849d | aurel32 | if (BLTUNSAFE(s))
|
696 | b2eb849d | aurel32 | return 0; |
697 | a5082316 | bellard | rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
698 | b2eb849d | aurel32 | rop_func(s, s->vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), |
699 | a5082316 | bellard | s->cirrus_blt_dstpitch, |
700 | a5082316 | bellard | s->cirrus_blt_width, s->cirrus_blt_height); |
701 | a21ae81d | bellard | cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, |
702 | a21ae81d | bellard | s->cirrus_blt_dstpitch, s->cirrus_blt_width, |
703 | a21ae81d | bellard | s->cirrus_blt_height); |
704 | a21ae81d | bellard | cirrus_bitblt_reset(s); |
705 | a21ae81d | bellard | return 1; |
706 | a21ae81d | bellard | } |
707 | a21ae81d | bellard | |
708 | e6e5ad80 | bellard | /***************************************
|
709 | e6e5ad80 | bellard | *
|
710 | e6e5ad80 | bellard | * bitblt (video-to-video)
|
711 | e6e5ad80 | bellard | *
|
712 | e6e5ad80 | bellard | ***************************************/
|
713 | e6e5ad80 | bellard | |
714 | e6e5ad80 | bellard | static int cirrus_bitblt_videotovideo_patterncopy(CirrusVGAState * s) |
715 | e6e5ad80 | bellard | { |
716 | e6e5ad80 | bellard | return cirrus_bitblt_common_patterncopy(s,
|
717 | b2eb849d | aurel32 | s->vram_ptr + ((s->cirrus_blt_srcaddr & ~7) &
|
718 | b2eb849d | aurel32 | s->cirrus_addr_mask)); |
719 | e6e5ad80 | bellard | } |
720 | e6e5ad80 | bellard | |
721 | 24236869 | bellard | static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h) |
722 | e6e5ad80 | bellard | { |
723 | 24236869 | bellard | int sx, sy;
|
724 | 24236869 | bellard | int dx, dy;
|
725 | 24236869 | bellard | int width, height;
|
726 | 24236869 | bellard | int depth;
|
727 | 24236869 | bellard | int notify = 0; |
728 | 24236869 | bellard | |
729 | 24236869 | bellard | depth = s->get_bpp((VGAState *)s) / 8;
|
730 | 24236869 | bellard | s->get_resolution((VGAState *)s, &width, &height); |
731 | 24236869 | bellard | |
732 | 24236869 | bellard | /* extra x, y */
|
733 | d85d0d38 | aliguori | sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth; |
734 | d85d0d38 | aliguori | sy = (src / ABS(s->cirrus_blt_srcpitch)); |
735 | d85d0d38 | aliguori | dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth; |
736 | d85d0d38 | aliguori | dy = (dst / ABS(s->cirrus_blt_dstpitch)); |
737 | 24236869 | bellard | |
738 | 24236869 | bellard | /* normalize width */
|
739 | 24236869 | bellard | w /= depth; |
740 | 24236869 | bellard | |
741 | 24236869 | bellard | /* if we're doing a backward copy, we have to adjust
|
742 | 24236869 | bellard | our x/y to be the upper left corner (instead of the lower
|
743 | 24236869 | bellard | right corner) */
|
744 | 24236869 | bellard | if (s->cirrus_blt_dstpitch < 0) { |
745 | 24236869 | bellard | sx -= (s->cirrus_blt_width / depth) - 1;
|
746 | 24236869 | bellard | dx -= (s->cirrus_blt_width / depth) - 1;
|
747 | 24236869 | bellard | sy -= s->cirrus_blt_height - 1;
|
748 | 24236869 | bellard | dy -= s->cirrus_blt_height - 1;
|
749 | 24236869 | bellard | } |
750 | 24236869 | bellard | |
751 | 24236869 | bellard | /* are we in the visible portion of memory? */
|
752 | 24236869 | bellard | if (sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 && |
753 | 24236869 | bellard | (sx + w) <= width && (sy + h) <= height && |
754 | 24236869 | bellard | (dx + w) <= width && (dy + h) <= height) { |
755 | 24236869 | bellard | notify = 1;
|
756 | 24236869 | bellard | } |
757 | 24236869 | bellard | |
758 | 24236869 | bellard | /* make to sure only copy if it's a plain copy ROP */
|
759 | 24236869 | bellard | if (*s->cirrus_rop != cirrus_bitblt_rop_fwd_src &&
|
760 | 24236869 | bellard | *s->cirrus_rop != cirrus_bitblt_rop_bkwd_src) |
761 | 24236869 | bellard | notify = 0;
|
762 | 24236869 | bellard | |
763 | 24236869 | bellard | /* we have to flush all pending changes so that the copy
|
764 | 24236869 | bellard | is generated at the appropriate moment in time */
|
765 | 24236869 | bellard | if (notify)
|
766 | 24236869 | bellard | vga_hw_update(); |
767 | 24236869 | bellard | |
768 | b2eb849d | aurel32 | (*s->cirrus_rop) (s, s->vram_ptr + |
769 | b2eb849d | aurel32 | (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), |
770 | b2eb849d | aurel32 | s->vram_ptr + |
771 | b2eb849d | aurel32 | (s->cirrus_blt_srcaddr & s->cirrus_addr_mask), |
772 | e6e5ad80 | bellard | s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch, |
773 | e6e5ad80 | bellard | s->cirrus_blt_width, s->cirrus_blt_height); |
774 | 24236869 | bellard | |
775 | 24236869 | bellard | if (notify)
|
776 | 3023f332 | aliguori | qemu_console_copy(s->ds, |
777 | 38334f76 | balrog | sx, sy, dx, dy, |
778 | 38334f76 | balrog | s->cirrus_blt_width / depth, |
779 | 38334f76 | balrog | s->cirrus_blt_height); |
780 | 24236869 | bellard | |
781 | 24236869 | bellard | /* we don't have to notify the display that this portion has
|
782 | 38334f76 | balrog | changed since qemu_console_copy implies this */
|
783 | 24236869 | bellard | |
784 | 31c05501 | aliguori | cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, |
785 | 31c05501 | aliguori | s->cirrus_blt_dstpitch, s->cirrus_blt_width, |
786 | 31c05501 | aliguori | s->cirrus_blt_height); |
787 | 24236869 | bellard | } |
788 | 24236869 | bellard | |
789 | 24236869 | bellard | static int cirrus_bitblt_videotovideo_copy(CirrusVGAState * s) |
790 | 24236869 | bellard | { |
791 | 65d35a09 | aurel32 | if (BLTUNSAFE(s))
|
792 | 65d35a09 | aurel32 | return 0; |
793 | 65d35a09 | aurel32 | |
794 | 7d957bd8 | aliguori | cirrus_do_copy(s, s->cirrus_blt_dstaddr - s->start_addr, |
795 | 7d957bd8 | aliguori | s->cirrus_blt_srcaddr - s->start_addr, |
796 | 7d957bd8 | aliguori | s->cirrus_blt_width, s->cirrus_blt_height); |
797 | 24236869 | bellard | |
798 | e6e5ad80 | bellard | return 1; |
799 | e6e5ad80 | bellard | } |
800 | e6e5ad80 | bellard | |
801 | e6e5ad80 | bellard | /***************************************
|
802 | e6e5ad80 | bellard | *
|
803 | e6e5ad80 | bellard | * bitblt (cpu-to-video)
|
804 | e6e5ad80 | bellard | *
|
805 | e6e5ad80 | bellard | ***************************************/
|
806 | e6e5ad80 | bellard | |
807 | e6e5ad80 | bellard | static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s) |
808 | e6e5ad80 | bellard | { |
809 | e6e5ad80 | bellard | int copy_count;
|
810 | a5082316 | bellard | uint8_t *end_ptr; |
811 | 3b46e624 | ths | |
812 | e6e5ad80 | bellard | if (s->cirrus_srccounter > 0) { |
813 | a5082316 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) {
|
814 | a5082316 | bellard | cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf); |
815 | a5082316 | bellard | the_end:
|
816 | a5082316 | bellard | s->cirrus_srccounter = 0;
|
817 | a5082316 | bellard | cirrus_bitblt_reset(s); |
818 | a5082316 | bellard | } else {
|
819 | a5082316 | bellard | /* at least one scan line */
|
820 | a5082316 | bellard | do {
|
821 | b2eb849d | aurel32 | (*s->cirrus_rop)(s, s->vram_ptr + |
822 | b2eb849d | aurel32 | (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), |
823 | b2eb849d | aurel32 | s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); |
824 | a5082316 | bellard | cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0,
|
825 | a5082316 | bellard | s->cirrus_blt_width, 1);
|
826 | a5082316 | bellard | s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch; |
827 | a5082316 | bellard | s->cirrus_srccounter -= s->cirrus_blt_srcpitch; |
828 | a5082316 | bellard | if (s->cirrus_srccounter <= 0) |
829 | a5082316 | bellard | goto the_end;
|
830 | a5082316 | bellard | /* more bytes than needed can be transfered because of
|
831 | a5082316 | bellard | word alignment, so we keep them for the next line */
|
832 | a5082316 | bellard | /* XXX: keep alignment to speed up transfer */
|
833 | a5082316 | bellard | end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; |
834 | a5082316 | bellard | copy_count = s->cirrus_srcptr_end - end_ptr; |
835 | a5082316 | bellard | memmove(s->cirrus_bltbuf, end_ptr, copy_count); |
836 | a5082316 | bellard | s->cirrus_srcptr = s->cirrus_bltbuf + copy_count; |
837 | a5082316 | bellard | s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; |
838 | a5082316 | bellard | } while (s->cirrus_srcptr >= s->cirrus_srcptr_end);
|
839 | a5082316 | bellard | } |
840 | e6e5ad80 | bellard | } |
841 | e6e5ad80 | bellard | } |
842 | e6e5ad80 | bellard | |
843 | e6e5ad80 | bellard | /***************************************
|
844 | e6e5ad80 | bellard | *
|
845 | e6e5ad80 | bellard | * bitblt wrapper
|
846 | e6e5ad80 | bellard | *
|
847 | e6e5ad80 | bellard | ***************************************/
|
848 | e6e5ad80 | bellard | |
849 | e6e5ad80 | bellard | static void cirrus_bitblt_reset(CirrusVGAState * s) |
850 | e6e5ad80 | bellard | { |
851 | f8b237af | aliguori | int need_update;
|
852 | f8b237af | aliguori | |
853 | e6e5ad80 | bellard | s->gr[0x31] &=
|
854 | e6e5ad80 | bellard | ~(CIRRUS_BLT_START | CIRRUS_BLT_BUSY | CIRRUS_BLT_FIFOUSED); |
855 | f8b237af | aliguori | need_update = s->cirrus_srcptr != &s->cirrus_bltbuf[0]
|
856 | f8b237af | aliguori | || s->cirrus_srcptr_end != &s->cirrus_bltbuf[0];
|
857 | e6e5ad80 | bellard | s->cirrus_srcptr = &s->cirrus_bltbuf[0];
|
858 | e6e5ad80 | bellard | s->cirrus_srcptr_end = &s->cirrus_bltbuf[0];
|
859 | e6e5ad80 | bellard | s->cirrus_srccounter = 0;
|
860 | f8b237af | aliguori | if (!need_update)
|
861 | f8b237af | aliguori | return;
|
862 | 8926b517 | bellard | cirrus_update_memory_access(s); |
863 | e6e5ad80 | bellard | } |
864 | e6e5ad80 | bellard | |
865 | e6e5ad80 | bellard | static int cirrus_bitblt_cputovideo(CirrusVGAState * s) |
866 | e6e5ad80 | bellard | { |
867 | a5082316 | bellard | int w;
|
868 | a5082316 | bellard | |
869 | e6e5ad80 | bellard | s->cirrus_blt_mode &= ~CIRRUS_BLTMODE_MEMSYSSRC; |
870 | e6e5ad80 | bellard | s->cirrus_srcptr = &s->cirrus_bltbuf[0];
|
871 | e6e5ad80 | bellard | s->cirrus_srcptr_end = &s->cirrus_bltbuf[0];
|
872 | e6e5ad80 | bellard | |
873 | e6e5ad80 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) {
|
874 | e6e5ad80 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) {
|
875 | a5082316 | bellard | s->cirrus_blt_srcpitch = 8;
|
876 | e6e5ad80 | bellard | } else {
|
877 | b30d4608 | bellard | /* XXX: check for 24 bpp */
|
878 | a5082316 | bellard | s->cirrus_blt_srcpitch = 8 * 8 * s->cirrus_blt_pixelwidth; |
879 | e6e5ad80 | bellard | } |
880 | a5082316 | bellard | s->cirrus_srccounter = s->cirrus_blt_srcpitch; |
881 | e6e5ad80 | bellard | } else {
|
882 | e6e5ad80 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) {
|
883 | a5082316 | bellard | w = s->cirrus_blt_width / s->cirrus_blt_pixelwidth; |
884 | 5fafdf24 | ths | if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_DWORDGRANULARITY)
|
885 | a5082316 | bellard | s->cirrus_blt_srcpitch = ((w + 31) >> 5); |
886 | a5082316 | bellard | else
|
887 | a5082316 | bellard | s->cirrus_blt_srcpitch = ((w + 7) >> 3); |
888 | e6e5ad80 | bellard | } else {
|
889 | c9c0eae8 | bellard | /* always align input size to 32 bits */
|
890 | c9c0eae8 | bellard | s->cirrus_blt_srcpitch = (s->cirrus_blt_width + 3) & ~3; |
891 | e6e5ad80 | bellard | } |
892 | a5082316 | bellard | s->cirrus_srccounter = s->cirrus_blt_srcpitch * s->cirrus_blt_height; |
893 | e6e5ad80 | bellard | } |
894 | a5082316 | bellard | s->cirrus_srcptr = s->cirrus_bltbuf; |
895 | a5082316 | bellard | s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; |
896 | 8926b517 | bellard | cirrus_update_memory_access(s); |
897 | e6e5ad80 | bellard | return 1; |
898 | e6e5ad80 | bellard | } |
899 | e6e5ad80 | bellard | |
900 | e6e5ad80 | bellard | static int cirrus_bitblt_videotocpu(CirrusVGAState * s) |
901 | e6e5ad80 | bellard | { |
902 | e6e5ad80 | bellard | /* XXX */
|
903 | a5082316 | bellard | #ifdef DEBUG_BITBLT
|
904 | e6e5ad80 | bellard | printf("cirrus: bitblt (video to cpu) is not implemented yet\n");
|
905 | e6e5ad80 | bellard | #endif
|
906 | e6e5ad80 | bellard | return 0; |
907 | e6e5ad80 | bellard | } |
908 | e6e5ad80 | bellard | |
909 | e6e5ad80 | bellard | static int cirrus_bitblt_videotovideo(CirrusVGAState * s) |
910 | e6e5ad80 | bellard | { |
911 | e6e5ad80 | bellard | int ret;
|
912 | e6e5ad80 | bellard | |
913 | e6e5ad80 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) {
|
914 | e6e5ad80 | bellard | ret = cirrus_bitblt_videotovideo_patterncopy(s); |
915 | e6e5ad80 | bellard | } else {
|
916 | e6e5ad80 | bellard | ret = cirrus_bitblt_videotovideo_copy(s); |
917 | e6e5ad80 | bellard | } |
918 | e6e5ad80 | bellard | if (ret)
|
919 | e6e5ad80 | bellard | cirrus_bitblt_reset(s); |
920 | e6e5ad80 | bellard | return ret;
|
921 | e6e5ad80 | bellard | } |
922 | e6e5ad80 | bellard | |
923 | e6e5ad80 | bellard | static void cirrus_bitblt_start(CirrusVGAState * s) |
924 | e6e5ad80 | bellard | { |
925 | e6e5ad80 | bellard | uint8_t blt_rop; |
926 | e6e5ad80 | bellard | |
927 | a5082316 | bellard | s->gr[0x31] |= CIRRUS_BLT_BUSY;
|
928 | a5082316 | bellard | |
929 | e6e5ad80 | bellard | s->cirrus_blt_width = (s->gr[0x20] | (s->gr[0x21] << 8)) + 1; |
930 | e6e5ad80 | bellard | s->cirrus_blt_height = (s->gr[0x22] | (s->gr[0x23] << 8)) + 1; |
931 | e6e5ad80 | bellard | s->cirrus_blt_dstpitch = (s->gr[0x24] | (s->gr[0x25] << 8)); |
932 | e6e5ad80 | bellard | s->cirrus_blt_srcpitch = (s->gr[0x26] | (s->gr[0x27] << 8)); |
933 | e6e5ad80 | bellard | s->cirrus_blt_dstaddr = |
934 | e6e5ad80 | bellard | (s->gr[0x28] | (s->gr[0x29] << 8) | (s->gr[0x2a] << 16)); |
935 | e6e5ad80 | bellard | s->cirrus_blt_srcaddr = |
936 | e6e5ad80 | bellard | (s->gr[0x2c] | (s->gr[0x2d] << 8) | (s->gr[0x2e] << 16)); |
937 | e6e5ad80 | bellard | s->cirrus_blt_mode = s->gr[0x30];
|
938 | a5082316 | bellard | s->cirrus_blt_modeext = s->gr[0x33];
|
939 | e6e5ad80 | bellard | blt_rop = s->gr[0x32];
|
940 | e6e5ad80 | bellard | |
941 | a21ae81d | bellard | #ifdef DEBUG_BITBLT
|
942 | 0b74ed78 | bellard | printf("rop=0x%02x mode=0x%02x modeext=0x%02x w=%d h=%d dpitch=%d spitch=%d daddr=0x%08x saddr=0x%08x writemask=0x%02x\n",
|
943 | 5fafdf24 | ths | blt_rop, |
944 | a21ae81d | bellard | s->cirrus_blt_mode, |
945 | a5082316 | bellard | s->cirrus_blt_modeext, |
946 | a21ae81d | bellard | s->cirrus_blt_width, |
947 | a21ae81d | bellard | s->cirrus_blt_height, |
948 | a21ae81d | bellard | s->cirrus_blt_dstpitch, |
949 | a21ae81d | bellard | s->cirrus_blt_srcpitch, |
950 | a21ae81d | bellard | s->cirrus_blt_dstaddr, |
951 | a5082316 | bellard | s->cirrus_blt_srcaddr, |
952 | e3a4e4b6 | bellard | s->gr[0x2f]);
|
953 | a21ae81d | bellard | #endif
|
954 | a21ae81d | bellard | |
955 | e6e5ad80 | bellard | switch (s->cirrus_blt_mode & CIRRUS_BLTMODE_PIXELWIDTHMASK) {
|
956 | e6e5ad80 | bellard | case CIRRUS_BLTMODE_PIXELWIDTH8:
|
957 | e6e5ad80 | bellard | s->cirrus_blt_pixelwidth = 1;
|
958 | e6e5ad80 | bellard | break;
|
959 | e6e5ad80 | bellard | case CIRRUS_BLTMODE_PIXELWIDTH16:
|
960 | e6e5ad80 | bellard | s->cirrus_blt_pixelwidth = 2;
|
961 | e6e5ad80 | bellard | break;
|
962 | e6e5ad80 | bellard | case CIRRUS_BLTMODE_PIXELWIDTH24:
|
963 | e6e5ad80 | bellard | s->cirrus_blt_pixelwidth = 3;
|
964 | e6e5ad80 | bellard | break;
|
965 | e6e5ad80 | bellard | case CIRRUS_BLTMODE_PIXELWIDTH32:
|
966 | e6e5ad80 | bellard | s->cirrus_blt_pixelwidth = 4;
|
967 | e6e5ad80 | bellard | break;
|
968 | e6e5ad80 | bellard | default:
|
969 | a5082316 | bellard | #ifdef DEBUG_BITBLT
|
970 | e6e5ad80 | bellard | printf("cirrus: bitblt - pixel width is unknown\n");
|
971 | e6e5ad80 | bellard | #endif
|
972 | e6e5ad80 | bellard | goto bitblt_ignore;
|
973 | e6e5ad80 | bellard | } |
974 | e6e5ad80 | bellard | s->cirrus_blt_mode &= ~CIRRUS_BLTMODE_PIXELWIDTHMASK; |
975 | e6e5ad80 | bellard | |
976 | e6e5ad80 | bellard | if ((s->
|
977 | e6e5ad80 | bellard | cirrus_blt_mode & (CIRRUS_BLTMODE_MEMSYSSRC | |
978 | e6e5ad80 | bellard | CIRRUS_BLTMODE_MEMSYSDEST)) |
979 | e6e5ad80 | bellard | == (CIRRUS_BLTMODE_MEMSYSSRC | CIRRUS_BLTMODE_MEMSYSDEST)) { |
980 | a5082316 | bellard | #ifdef DEBUG_BITBLT
|
981 | e6e5ad80 | bellard | printf("cirrus: bitblt - memory-to-memory copy is requested\n");
|
982 | e6e5ad80 | bellard | #endif
|
983 | e6e5ad80 | bellard | goto bitblt_ignore;
|
984 | e6e5ad80 | bellard | } |
985 | e6e5ad80 | bellard | |
986 | a5082316 | bellard | if ((s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_SOLIDFILL) &&
|
987 | 5fafdf24 | ths | (s->cirrus_blt_mode & (CIRRUS_BLTMODE_MEMSYSDEST | |
988 | a21ae81d | bellard | CIRRUS_BLTMODE_TRANSPARENTCOMP | |
989 | 5fafdf24 | ths | CIRRUS_BLTMODE_PATTERNCOPY | |
990 | 5fafdf24 | ths | CIRRUS_BLTMODE_COLOREXPAND)) == |
991 | a21ae81d | bellard | (CIRRUS_BLTMODE_PATTERNCOPY | CIRRUS_BLTMODE_COLOREXPAND)) { |
992 | a5082316 | bellard | cirrus_bitblt_fgcol(s); |
993 | a5082316 | bellard | cirrus_bitblt_solidfill(s, blt_rop); |
994 | e6e5ad80 | bellard | } else {
|
995 | 5fafdf24 | ths | if ((s->cirrus_blt_mode & (CIRRUS_BLTMODE_COLOREXPAND |
|
996 | 5fafdf24 | ths | CIRRUS_BLTMODE_PATTERNCOPY)) == |
997 | a5082316 | bellard | CIRRUS_BLTMODE_COLOREXPAND) { |
998 | a5082316 | bellard | |
999 | a5082316 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) {
|
1000 | b30d4608 | bellard | if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV)
|
1001 | 4c8732d7 | bellard | cirrus_bitblt_bgcol(s); |
1002 | b30d4608 | bellard | else
|
1003 | 4c8732d7 | bellard | cirrus_bitblt_fgcol(s); |
1004 | b30d4608 | bellard | s->cirrus_rop = cirrus_colorexpand_transp[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1005 | a5082316 | bellard | } else {
|
1006 | a5082316 | bellard | cirrus_bitblt_fgcol(s); |
1007 | a5082316 | bellard | cirrus_bitblt_bgcol(s); |
1008 | a5082316 | bellard | s->cirrus_rop = cirrus_colorexpand[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1009 | a5082316 | bellard | } |
1010 | e69390ce | bellard | } else if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { |
1011 | b30d4608 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) {
|
1012 | b30d4608 | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) {
|
1013 | b30d4608 | bellard | if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV)
|
1014 | b30d4608 | bellard | cirrus_bitblt_bgcol(s); |
1015 | b30d4608 | bellard | else
|
1016 | b30d4608 | bellard | cirrus_bitblt_fgcol(s); |
1017 | b30d4608 | bellard | s->cirrus_rop = cirrus_colorexpand_pattern_transp[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1018 | b30d4608 | bellard | } else {
|
1019 | b30d4608 | bellard | cirrus_bitblt_fgcol(s); |
1020 | b30d4608 | bellard | cirrus_bitblt_bgcol(s); |
1021 | b30d4608 | bellard | s->cirrus_rop = cirrus_colorexpand_pattern[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1022 | b30d4608 | bellard | } |
1023 | b30d4608 | bellard | } else {
|
1024 | b30d4608 | bellard | s->cirrus_rop = cirrus_patternfill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1025 | b30d4608 | bellard | } |
1026 | a21ae81d | bellard | } else {
|
1027 | 96cf2df8 | ths | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) {
|
1028 | 96cf2df8 | ths | if (s->cirrus_blt_pixelwidth > 2) { |
1029 | 96cf2df8 | ths | printf("src transparent without colorexpand must be 8bpp or 16bpp\n");
|
1030 | 96cf2df8 | ths | goto bitblt_ignore;
|
1031 | 96cf2df8 | ths | } |
1032 | 96cf2df8 | ths | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_BACKWARDS) {
|
1033 | 96cf2df8 | ths | s->cirrus_blt_dstpitch = -s->cirrus_blt_dstpitch; |
1034 | 96cf2df8 | ths | s->cirrus_blt_srcpitch = -s->cirrus_blt_srcpitch; |
1035 | 96cf2df8 | ths | s->cirrus_rop = cirrus_bkwd_transp_rop[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1036 | 96cf2df8 | ths | } else {
|
1037 | 96cf2df8 | ths | s->cirrus_rop = cirrus_fwd_transp_rop[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1];
|
1038 | 96cf2df8 | ths | } |
1039 | 96cf2df8 | ths | } else {
|
1040 | 96cf2df8 | ths | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_BACKWARDS) {
|
1041 | 96cf2df8 | ths | s->cirrus_blt_dstpitch = -s->cirrus_blt_dstpitch; |
1042 | 96cf2df8 | ths | s->cirrus_blt_srcpitch = -s->cirrus_blt_srcpitch; |
1043 | 96cf2df8 | ths | s->cirrus_rop = cirrus_bkwd_rop[rop_to_index[blt_rop]]; |
1044 | 96cf2df8 | ths | } else {
|
1045 | 96cf2df8 | ths | s->cirrus_rop = cirrus_fwd_rop[rop_to_index[blt_rop]]; |
1046 | 96cf2df8 | ths | } |
1047 | 96cf2df8 | ths | } |
1048 | 96cf2df8 | ths | } |
1049 | a21ae81d | bellard | // setup bitblt engine.
|
1050 | a21ae81d | bellard | if (s->cirrus_blt_mode & CIRRUS_BLTMODE_MEMSYSSRC) {
|
1051 | a21ae81d | bellard | if (!cirrus_bitblt_cputovideo(s))
|
1052 | a21ae81d | bellard | goto bitblt_ignore;
|
1053 | a21ae81d | bellard | } else if (s->cirrus_blt_mode & CIRRUS_BLTMODE_MEMSYSDEST) { |
1054 | a21ae81d | bellard | if (!cirrus_bitblt_videotocpu(s))
|
1055 | a21ae81d | bellard | goto bitblt_ignore;
|
1056 | a21ae81d | bellard | } else {
|
1057 | a21ae81d | bellard | if (!cirrus_bitblt_videotovideo(s))
|
1058 | a21ae81d | bellard | goto bitblt_ignore;
|
1059 | a21ae81d | bellard | } |
1060 | e6e5ad80 | bellard | } |
1061 | e6e5ad80 | bellard | return;
|
1062 | e6e5ad80 | bellard | bitblt_ignore:;
|
1063 | e6e5ad80 | bellard | cirrus_bitblt_reset(s); |
1064 | e6e5ad80 | bellard | } |
1065 | e6e5ad80 | bellard | |
1066 | e6e5ad80 | bellard | static void cirrus_write_bitblt(CirrusVGAState * s, unsigned reg_value) |
1067 | e6e5ad80 | bellard | { |
1068 | e6e5ad80 | bellard | unsigned old_value;
|
1069 | e6e5ad80 | bellard | |
1070 | e6e5ad80 | bellard | old_value = s->gr[0x31];
|
1071 | e6e5ad80 | bellard | s->gr[0x31] = reg_value;
|
1072 | e6e5ad80 | bellard | |
1073 | e6e5ad80 | bellard | if (((old_value & CIRRUS_BLT_RESET) != 0) && |
1074 | e6e5ad80 | bellard | ((reg_value & CIRRUS_BLT_RESET) == 0)) {
|
1075 | e6e5ad80 | bellard | cirrus_bitblt_reset(s); |
1076 | e6e5ad80 | bellard | } else if (((old_value & CIRRUS_BLT_START) == 0) && |
1077 | e6e5ad80 | bellard | ((reg_value & CIRRUS_BLT_START) != 0)) {
|
1078 | e6e5ad80 | bellard | cirrus_bitblt_start(s); |
1079 | e6e5ad80 | bellard | } |
1080 | e6e5ad80 | bellard | } |
1081 | e6e5ad80 | bellard | |
1082 | e6e5ad80 | bellard | |
1083 | e6e5ad80 | bellard | /***************************************
|
1084 | e6e5ad80 | bellard | *
|
1085 | e6e5ad80 | bellard | * basic parameters
|
1086 | e6e5ad80 | bellard | *
|
1087 | e6e5ad80 | bellard | ***************************************/
|
1088 | e6e5ad80 | bellard | |
1089 | 5fafdf24 | ths | static void cirrus_get_offsets(VGAState *s1, |
1090 | 83acc96b | bellard | uint32_t *pline_offset, |
1091 | 83acc96b | bellard | uint32_t *pstart_addr, |
1092 | 83acc96b | bellard | uint32_t *pline_compare) |
1093 | e6e5ad80 | bellard | { |
1094 | e6e5ad80 | bellard | CirrusVGAState * s = (CirrusVGAState *)s1; |
1095 | 83acc96b | bellard | uint32_t start_addr, line_offset, line_compare; |
1096 | e6e5ad80 | bellard | |
1097 | e6e5ad80 | bellard | line_offset = s->cr[0x13]
|
1098 | e36f36e1 | bellard | | ((s->cr[0x1b] & 0x10) << 4); |
1099 | e6e5ad80 | bellard | line_offset <<= 3;
|
1100 | e6e5ad80 | bellard | *pline_offset = line_offset; |
1101 | e6e5ad80 | bellard | |
1102 | e6e5ad80 | bellard | start_addr = (s->cr[0x0c] << 8) |
1103 | e6e5ad80 | bellard | | s->cr[0x0d]
|
1104 | e6e5ad80 | bellard | | ((s->cr[0x1b] & 0x01) << 16) |
1105 | e6e5ad80 | bellard | | ((s->cr[0x1b] & 0x0c) << 15) |
1106 | e6e5ad80 | bellard | | ((s->cr[0x1d] & 0x80) << 12); |
1107 | e6e5ad80 | bellard | *pstart_addr = start_addr; |
1108 | 83acc96b | bellard | |
1109 | 5fafdf24 | ths | line_compare = s->cr[0x18] |
|
1110 | 83acc96b | bellard | ((s->cr[0x07] & 0x10) << 4) | |
1111 | 83acc96b | bellard | ((s->cr[0x09] & 0x40) << 3); |
1112 | 83acc96b | bellard | *pline_compare = line_compare; |
1113 | e6e5ad80 | bellard | } |
1114 | e6e5ad80 | bellard | |
1115 | e6e5ad80 | bellard | static uint32_t cirrus_get_bpp16_depth(CirrusVGAState * s)
|
1116 | e6e5ad80 | bellard | { |
1117 | e6e5ad80 | bellard | uint32_t ret = 16;
|
1118 | e6e5ad80 | bellard | |
1119 | e6e5ad80 | bellard | switch (s->cirrus_hidden_dac_data & 0xf) { |
1120 | e6e5ad80 | bellard | case 0: |
1121 | e6e5ad80 | bellard | ret = 15;
|
1122 | e6e5ad80 | bellard | break; /* Sierra HiColor */ |
1123 | e6e5ad80 | bellard | case 1: |
1124 | e6e5ad80 | bellard | ret = 16;
|
1125 | e6e5ad80 | bellard | break; /* XGA HiColor */ |
1126 | e6e5ad80 | bellard | default:
|
1127 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1128 | e6e5ad80 | bellard | printf("cirrus: invalid DAC value %x in 16bpp\n",
|
1129 | e6e5ad80 | bellard | (s->cirrus_hidden_dac_data & 0xf));
|
1130 | e6e5ad80 | bellard | #endif
|
1131 | e6e5ad80 | bellard | ret = 15; /* XXX */ |
1132 | e6e5ad80 | bellard | break;
|
1133 | e6e5ad80 | bellard | } |
1134 | e6e5ad80 | bellard | return ret;
|
1135 | e6e5ad80 | bellard | } |
1136 | e6e5ad80 | bellard | |
1137 | e6e5ad80 | bellard | static int cirrus_get_bpp(VGAState *s1) |
1138 | e6e5ad80 | bellard | { |
1139 | e6e5ad80 | bellard | CirrusVGAState * s = (CirrusVGAState *)s1; |
1140 | e6e5ad80 | bellard | uint32_t ret = 8;
|
1141 | e6e5ad80 | bellard | |
1142 | e6e5ad80 | bellard | if ((s->sr[0x07] & 0x01) != 0) { |
1143 | e6e5ad80 | bellard | /* Cirrus SVGA */
|
1144 | e6e5ad80 | bellard | switch (s->sr[0x07] & CIRRUS_SR7_BPP_MASK) { |
1145 | e6e5ad80 | bellard | case CIRRUS_SR7_BPP_8:
|
1146 | e6e5ad80 | bellard | ret = 8;
|
1147 | e6e5ad80 | bellard | break;
|
1148 | e6e5ad80 | bellard | case CIRRUS_SR7_BPP_16_DOUBLEVCLK:
|
1149 | e6e5ad80 | bellard | ret = cirrus_get_bpp16_depth(s); |
1150 | e6e5ad80 | bellard | break;
|
1151 | e6e5ad80 | bellard | case CIRRUS_SR7_BPP_24:
|
1152 | e6e5ad80 | bellard | ret = 24;
|
1153 | e6e5ad80 | bellard | break;
|
1154 | e6e5ad80 | bellard | case CIRRUS_SR7_BPP_16:
|
1155 | e6e5ad80 | bellard | ret = cirrus_get_bpp16_depth(s); |
1156 | e6e5ad80 | bellard | break;
|
1157 | e6e5ad80 | bellard | case CIRRUS_SR7_BPP_32:
|
1158 | e6e5ad80 | bellard | ret = 32;
|
1159 | e6e5ad80 | bellard | break;
|
1160 | e6e5ad80 | bellard | default:
|
1161 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1162 | e6e5ad80 | bellard | printf("cirrus: unknown bpp - sr7=%x\n", s->sr[0x7]); |
1163 | e6e5ad80 | bellard | #endif
|
1164 | e6e5ad80 | bellard | ret = 8;
|
1165 | e6e5ad80 | bellard | break;
|
1166 | e6e5ad80 | bellard | } |
1167 | e6e5ad80 | bellard | } else {
|
1168 | e6e5ad80 | bellard | /* VGA */
|
1169 | aeb3c85f | bellard | ret = 0;
|
1170 | e6e5ad80 | bellard | } |
1171 | e6e5ad80 | bellard | |
1172 | e6e5ad80 | bellard | return ret;
|
1173 | e6e5ad80 | bellard | } |
1174 | e6e5ad80 | bellard | |
1175 | 78e127ef | bellard | static void cirrus_get_resolution(VGAState *s, int *pwidth, int *pheight) |
1176 | 78e127ef | bellard | { |
1177 | 78e127ef | bellard | int width, height;
|
1178 | 3b46e624 | ths | |
1179 | 78e127ef | bellard | width = (s->cr[0x01] + 1) * 8; |
1180 | 5fafdf24 | ths | height = s->cr[0x12] |
|
1181 | 5fafdf24 | ths | ((s->cr[0x07] & 0x02) << 7) | |
1182 | 78e127ef | bellard | ((s->cr[0x07] & 0x40) << 3); |
1183 | 78e127ef | bellard | height = (height + 1);
|
1184 | 78e127ef | bellard | /* interlace support */
|
1185 | 78e127ef | bellard | if (s->cr[0x1a] & 0x01) |
1186 | 78e127ef | bellard | height = height * 2;
|
1187 | 78e127ef | bellard | *pwidth = width; |
1188 | 78e127ef | bellard | *pheight = height; |
1189 | 78e127ef | bellard | } |
1190 | 78e127ef | bellard | |
1191 | e6e5ad80 | bellard | /***************************************
|
1192 | e6e5ad80 | bellard | *
|
1193 | e6e5ad80 | bellard | * bank memory
|
1194 | e6e5ad80 | bellard | *
|
1195 | e6e5ad80 | bellard | ***************************************/
|
1196 | e6e5ad80 | bellard | |
1197 | e6e5ad80 | bellard | static void cirrus_update_bank_ptr(CirrusVGAState * s, unsigned bank_index) |
1198 | e6e5ad80 | bellard | { |
1199 | e6e5ad80 | bellard | unsigned offset;
|
1200 | e6e5ad80 | bellard | unsigned limit;
|
1201 | e6e5ad80 | bellard | |
1202 | e6e5ad80 | bellard | if ((s->gr[0x0b] & 0x01) != 0) /* dual bank */ |
1203 | e6e5ad80 | bellard | offset = s->gr[0x09 + bank_index];
|
1204 | e6e5ad80 | bellard | else /* single bank */ |
1205 | e6e5ad80 | bellard | offset = s->gr[0x09];
|
1206 | e6e5ad80 | bellard | |
1207 | e6e5ad80 | bellard | if ((s->gr[0x0b] & 0x20) != 0) |
1208 | e6e5ad80 | bellard | offset <<= 14;
|
1209 | e6e5ad80 | bellard | else
|
1210 | e6e5ad80 | bellard | offset <<= 12;
|
1211 | e6e5ad80 | bellard | |
1212 | e3a4e4b6 | bellard | if (s->real_vram_size <= offset)
|
1213 | e6e5ad80 | bellard | limit = 0;
|
1214 | e6e5ad80 | bellard | else
|
1215 | e3a4e4b6 | bellard | limit = s->real_vram_size - offset; |
1216 | e6e5ad80 | bellard | |
1217 | e6e5ad80 | bellard | if (((s->gr[0x0b] & 0x01) == 0) && (bank_index != 0)) { |
1218 | e6e5ad80 | bellard | if (limit > 0x8000) { |
1219 | e6e5ad80 | bellard | offset += 0x8000;
|
1220 | e6e5ad80 | bellard | limit -= 0x8000;
|
1221 | e6e5ad80 | bellard | } else {
|
1222 | e6e5ad80 | bellard | limit = 0;
|
1223 | e6e5ad80 | bellard | } |
1224 | e6e5ad80 | bellard | } |
1225 | e6e5ad80 | bellard | |
1226 | e6e5ad80 | bellard | if (limit > 0) { |
1227 | 2bec46dc | aliguori | /* Thinking about changing bank base? First, drop the dirty bitmap information
|
1228 | 2bec46dc | aliguori | * on the current location, otherwise we lose this pointer forever */
|
1229 | 2bec46dc | aliguori | if (s->lfb_vram_mapped) {
|
1230 | 2bec46dc | aliguori | target_phys_addr_t base_addr = isa_mem_base + 0xa0000 + bank_index * 0x8000; |
1231 | 2bec46dc | aliguori | cpu_physical_sync_dirty_bitmap(base_addr, base_addr + 0x8000);
|
1232 | 2bec46dc | aliguori | } |
1233 | e6e5ad80 | bellard | s->cirrus_bank_base[bank_index] = offset; |
1234 | e6e5ad80 | bellard | s->cirrus_bank_limit[bank_index] = limit; |
1235 | e6e5ad80 | bellard | } else {
|
1236 | e6e5ad80 | bellard | s->cirrus_bank_base[bank_index] = 0;
|
1237 | e6e5ad80 | bellard | s->cirrus_bank_limit[bank_index] = 0;
|
1238 | e6e5ad80 | bellard | } |
1239 | e6e5ad80 | bellard | } |
1240 | e6e5ad80 | bellard | |
1241 | e6e5ad80 | bellard | /***************************************
|
1242 | e6e5ad80 | bellard | *
|
1243 | e6e5ad80 | bellard | * I/O access between 0x3c4-0x3c5
|
1244 | e6e5ad80 | bellard | *
|
1245 | e6e5ad80 | bellard | ***************************************/
|
1246 | e6e5ad80 | bellard | |
1247 | e6e5ad80 | bellard | static int |
1248 | e6e5ad80 | bellard | cirrus_hook_read_sr(CirrusVGAState * s, unsigned reg_index, int *reg_value) |
1249 | e6e5ad80 | bellard | { |
1250 | e6e5ad80 | bellard | switch (reg_index) {
|
1251 | e6e5ad80 | bellard | case 0x00: // Standard VGA |
1252 | e6e5ad80 | bellard | case 0x01: // Standard VGA |
1253 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1254 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1255 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1256 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1257 | e6e5ad80 | bellard | case 0x06: // Unlock Cirrus extensions |
1258 | e6e5ad80 | bellard | *reg_value = s->sr[reg_index]; |
1259 | e6e5ad80 | bellard | break;
|
1260 | e6e5ad80 | bellard | case 0x10: |
1261 | e6e5ad80 | bellard | case 0x30: |
1262 | e6e5ad80 | bellard | case 0x50: |
1263 | e6e5ad80 | bellard | case 0x70: // Graphics Cursor X |
1264 | e6e5ad80 | bellard | case 0x90: |
1265 | e6e5ad80 | bellard | case 0xb0: |
1266 | e6e5ad80 | bellard | case 0xd0: |
1267 | e6e5ad80 | bellard | case 0xf0: // Graphics Cursor X |
1268 | aeb3c85f | bellard | *reg_value = s->sr[0x10];
|
1269 | aeb3c85f | bellard | break;
|
1270 | e6e5ad80 | bellard | case 0x11: |
1271 | e6e5ad80 | bellard | case 0x31: |
1272 | e6e5ad80 | bellard | case 0x51: |
1273 | e6e5ad80 | bellard | case 0x71: // Graphics Cursor Y |
1274 | e6e5ad80 | bellard | case 0x91: |
1275 | e6e5ad80 | bellard | case 0xb1: |
1276 | e6e5ad80 | bellard | case 0xd1: |
1277 | a5082316 | bellard | case 0xf1: // Graphics Cursor Y |
1278 | aeb3c85f | bellard | *reg_value = s->sr[0x11];
|
1279 | aeb3c85f | bellard | break;
|
1280 | aeb3c85f | bellard | case 0x05: // ??? |
1281 | aeb3c85f | bellard | case 0x07: // Extended Sequencer Mode |
1282 | aeb3c85f | bellard | case 0x08: // EEPROM Control |
1283 | aeb3c85f | bellard | case 0x09: // Scratch Register 0 |
1284 | aeb3c85f | bellard | case 0x0a: // Scratch Register 1 |
1285 | aeb3c85f | bellard | case 0x0b: // VCLK 0 |
1286 | aeb3c85f | bellard | case 0x0c: // VCLK 1 |
1287 | aeb3c85f | bellard | case 0x0d: // VCLK 2 |
1288 | aeb3c85f | bellard | case 0x0e: // VCLK 3 |
1289 | aeb3c85f | bellard | case 0x0f: // DRAM Control |
1290 | e6e5ad80 | bellard | case 0x12: // Graphics Cursor Attribute |
1291 | e6e5ad80 | bellard | case 0x13: // Graphics Cursor Pattern Address |
1292 | e6e5ad80 | bellard | case 0x14: // Scratch Register 2 |
1293 | e6e5ad80 | bellard | case 0x15: // Scratch Register 3 |
1294 | e6e5ad80 | bellard | case 0x16: // Performance Tuning Register |
1295 | e6e5ad80 | bellard | case 0x17: // Configuration Readback and Extended Control |
1296 | e6e5ad80 | bellard | case 0x18: // Signature Generator Control |
1297 | e6e5ad80 | bellard | case 0x19: // Signal Generator Result |
1298 | e6e5ad80 | bellard | case 0x1a: // Signal Generator Result |
1299 | e6e5ad80 | bellard | case 0x1b: // VCLK 0 Denominator & Post |
1300 | e6e5ad80 | bellard | case 0x1c: // VCLK 1 Denominator & Post |
1301 | e6e5ad80 | bellard | case 0x1d: // VCLK 2 Denominator & Post |
1302 | e6e5ad80 | bellard | case 0x1e: // VCLK 3 Denominator & Post |
1303 | e6e5ad80 | bellard | case 0x1f: // BIOS Write Enable and MCLK select |
1304 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1305 | e6e5ad80 | bellard | printf("cirrus: handled inport sr_index %02x\n", reg_index);
|
1306 | e6e5ad80 | bellard | #endif
|
1307 | e6e5ad80 | bellard | *reg_value = s->sr[reg_index]; |
1308 | e6e5ad80 | bellard | break;
|
1309 | e6e5ad80 | bellard | default:
|
1310 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1311 | e6e5ad80 | bellard | printf("cirrus: inport sr_index %02x\n", reg_index);
|
1312 | e6e5ad80 | bellard | #endif
|
1313 | e6e5ad80 | bellard | *reg_value = 0xff;
|
1314 | e6e5ad80 | bellard | break;
|
1315 | e6e5ad80 | bellard | } |
1316 | e6e5ad80 | bellard | |
1317 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1318 | e6e5ad80 | bellard | } |
1319 | e6e5ad80 | bellard | |
1320 | e6e5ad80 | bellard | static int |
1321 | e6e5ad80 | bellard | cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value) |
1322 | e6e5ad80 | bellard | { |
1323 | e6e5ad80 | bellard | switch (reg_index) {
|
1324 | e6e5ad80 | bellard | case 0x00: // Standard VGA |
1325 | e6e5ad80 | bellard | case 0x01: // Standard VGA |
1326 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1327 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1328 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1329 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1330 | e6e5ad80 | bellard | case 0x06: // Unlock Cirrus extensions |
1331 | e6e5ad80 | bellard | reg_value &= 0x17;
|
1332 | e6e5ad80 | bellard | if (reg_value == 0x12) { |
1333 | e6e5ad80 | bellard | s->sr[reg_index] = 0x12;
|
1334 | e6e5ad80 | bellard | } else {
|
1335 | e6e5ad80 | bellard | s->sr[reg_index] = 0x0f;
|
1336 | e6e5ad80 | bellard | } |
1337 | e6e5ad80 | bellard | break;
|
1338 | e6e5ad80 | bellard | case 0x10: |
1339 | e6e5ad80 | bellard | case 0x30: |
1340 | e6e5ad80 | bellard | case 0x50: |
1341 | e6e5ad80 | bellard | case 0x70: // Graphics Cursor X |
1342 | e6e5ad80 | bellard | case 0x90: |
1343 | e6e5ad80 | bellard | case 0xb0: |
1344 | e6e5ad80 | bellard | case 0xd0: |
1345 | e6e5ad80 | bellard | case 0xf0: // Graphics Cursor X |
1346 | e6e5ad80 | bellard | s->sr[0x10] = reg_value;
|
1347 | a5082316 | bellard | s->hw_cursor_x = (reg_value << 3) | (reg_index >> 5); |
1348 | e6e5ad80 | bellard | break;
|
1349 | e6e5ad80 | bellard | case 0x11: |
1350 | e6e5ad80 | bellard | case 0x31: |
1351 | e6e5ad80 | bellard | case 0x51: |
1352 | e6e5ad80 | bellard | case 0x71: // Graphics Cursor Y |
1353 | e6e5ad80 | bellard | case 0x91: |
1354 | e6e5ad80 | bellard | case 0xb1: |
1355 | e6e5ad80 | bellard | case 0xd1: |
1356 | e6e5ad80 | bellard | case 0xf1: // Graphics Cursor Y |
1357 | e6e5ad80 | bellard | s->sr[0x11] = reg_value;
|
1358 | a5082316 | bellard | s->hw_cursor_y = (reg_value << 3) | (reg_index >> 5); |
1359 | e6e5ad80 | bellard | break;
|
1360 | e6e5ad80 | bellard | case 0x07: // Extended Sequencer Mode |
1361 | 2bec46dc | aliguori | cirrus_update_memory_access(s); |
1362 | e6e5ad80 | bellard | case 0x08: // EEPROM Control |
1363 | e6e5ad80 | bellard | case 0x09: // Scratch Register 0 |
1364 | e6e5ad80 | bellard | case 0x0a: // Scratch Register 1 |
1365 | e6e5ad80 | bellard | case 0x0b: // VCLK 0 |
1366 | e6e5ad80 | bellard | case 0x0c: // VCLK 1 |
1367 | e6e5ad80 | bellard | case 0x0d: // VCLK 2 |
1368 | e6e5ad80 | bellard | case 0x0e: // VCLK 3 |
1369 | e6e5ad80 | bellard | case 0x0f: // DRAM Control |
1370 | e6e5ad80 | bellard | case 0x12: // Graphics Cursor Attribute |
1371 | e6e5ad80 | bellard | case 0x13: // Graphics Cursor Pattern Address |
1372 | e6e5ad80 | bellard | case 0x14: // Scratch Register 2 |
1373 | e6e5ad80 | bellard | case 0x15: // Scratch Register 3 |
1374 | e6e5ad80 | bellard | case 0x16: // Performance Tuning Register |
1375 | e6e5ad80 | bellard | case 0x18: // Signature Generator Control |
1376 | e6e5ad80 | bellard | case 0x19: // Signature Generator Result |
1377 | e6e5ad80 | bellard | case 0x1a: // Signature Generator Result |
1378 | e6e5ad80 | bellard | case 0x1b: // VCLK 0 Denominator & Post |
1379 | e6e5ad80 | bellard | case 0x1c: // VCLK 1 Denominator & Post |
1380 | e6e5ad80 | bellard | case 0x1d: // VCLK 2 Denominator & Post |
1381 | e6e5ad80 | bellard | case 0x1e: // VCLK 3 Denominator & Post |
1382 | e6e5ad80 | bellard | case 0x1f: // BIOS Write Enable and MCLK select |
1383 | e6e5ad80 | bellard | s->sr[reg_index] = reg_value; |
1384 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1385 | e6e5ad80 | bellard | printf("cirrus: handled outport sr_index %02x, sr_value %02x\n",
|
1386 | e6e5ad80 | bellard | reg_index, reg_value); |
1387 | e6e5ad80 | bellard | #endif
|
1388 | e6e5ad80 | bellard | break;
|
1389 | 8926b517 | bellard | case 0x17: // Configuration Readback and Extended Control |
1390 | e3a4e4b6 | bellard | s->sr[reg_index] = (s->sr[reg_index] & 0x38) | (reg_value & 0xc7); |
1391 | 8926b517 | bellard | cirrus_update_memory_access(s); |
1392 | 8926b517 | bellard | break;
|
1393 | e6e5ad80 | bellard | default:
|
1394 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1395 | e6e5ad80 | bellard | printf("cirrus: outport sr_index %02x, sr_value %02x\n", reg_index,
|
1396 | e6e5ad80 | bellard | reg_value); |
1397 | e6e5ad80 | bellard | #endif
|
1398 | e6e5ad80 | bellard | break;
|
1399 | e6e5ad80 | bellard | } |
1400 | e6e5ad80 | bellard | |
1401 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1402 | e6e5ad80 | bellard | } |
1403 | e6e5ad80 | bellard | |
1404 | e6e5ad80 | bellard | /***************************************
|
1405 | e6e5ad80 | bellard | *
|
1406 | e6e5ad80 | bellard | * I/O access at 0x3c6
|
1407 | e6e5ad80 | bellard | *
|
1408 | e6e5ad80 | bellard | ***************************************/
|
1409 | e6e5ad80 | bellard | |
1410 | e6e5ad80 | bellard | static void cirrus_read_hidden_dac(CirrusVGAState * s, int *reg_value) |
1411 | e6e5ad80 | bellard | { |
1412 | e6e5ad80 | bellard | *reg_value = 0xff;
|
1413 | a21ae81d | bellard | if (++s->cirrus_hidden_dac_lockindex == 5) { |
1414 | a21ae81d | bellard | *reg_value = s->cirrus_hidden_dac_data; |
1415 | a21ae81d | bellard | s->cirrus_hidden_dac_lockindex = 0;
|
1416 | e6e5ad80 | bellard | } |
1417 | e6e5ad80 | bellard | } |
1418 | e6e5ad80 | bellard | |
1419 | e6e5ad80 | bellard | static void cirrus_write_hidden_dac(CirrusVGAState * s, int reg_value) |
1420 | e6e5ad80 | bellard | { |
1421 | e6e5ad80 | bellard | if (s->cirrus_hidden_dac_lockindex == 4) { |
1422 | e6e5ad80 | bellard | s->cirrus_hidden_dac_data = reg_value; |
1423 | a21ae81d | bellard | #if defined(DEBUG_CIRRUS)
|
1424 | e6e5ad80 | bellard | printf("cirrus: outport hidden DAC, value %02x\n", reg_value);
|
1425 | e6e5ad80 | bellard | #endif
|
1426 | e6e5ad80 | bellard | } |
1427 | e6e5ad80 | bellard | s->cirrus_hidden_dac_lockindex = 0;
|
1428 | e6e5ad80 | bellard | } |
1429 | e6e5ad80 | bellard | |
1430 | e6e5ad80 | bellard | /***************************************
|
1431 | e6e5ad80 | bellard | *
|
1432 | e6e5ad80 | bellard | * I/O access at 0x3c9
|
1433 | e6e5ad80 | bellard | *
|
1434 | e6e5ad80 | bellard | ***************************************/
|
1435 | e6e5ad80 | bellard | |
1436 | e6e5ad80 | bellard | static int cirrus_hook_read_palette(CirrusVGAState * s, int *reg_value) |
1437 | e6e5ad80 | bellard | { |
1438 | e6e5ad80 | bellard | if (!(s->sr[0x12] & CIRRUS_CURSOR_HIDDENPEL)) |
1439 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1440 | a5082316 | bellard | *reg_value = |
1441 | a5082316 | bellard | s->cirrus_hidden_palette[(s->dac_read_index & 0x0f) * 3 + |
1442 | a5082316 | bellard | s->dac_sub_index]; |
1443 | e6e5ad80 | bellard | if (++s->dac_sub_index == 3) { |
1444 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
1445 | e6e5ad80 | bellard | s->dac_read_index++; |
1446 | e6e5ad80 | bellard | } |
1447 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1448 | e6e5ad80 | bellard | } |
1449 | e6e5ad80 | bellard | |
1450 | e6e5ad80 | bellard | static int cirrus_hook_write_palette(CirrusVGAState * s, int reg_value) |
1451 | e6e5ad80 | bellard | { |
1452 | e6e5ad80 | bellard | if (!(s->sr[0x12] & CIRRUS_CURSOR_HIDDENPEL)) |
1453 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1454 | e6e5ad80 | bellard | s->dac_cache[s->dac_sub_index] = reg_value; |
1455 | e6e5ad80 | bellard | if (++s->dac_sub_index == 3) { |
1456 | a5082316 | bellard | memcpy(&s->cirrus_hidden_palette[(s->dac_write_index & 0x0f) * 3], |
1457 | a5082316 | bellard | s->dac_cache, 3);
|
1458 | a5082316 | bellard | /* XXX update cursor */
|
1459 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
1460 | e6e5ad80 | bellard | s->dac_write_index++; |
1461 | e6e5ad80 | bellard | } |
1462 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1463 | e6e5ad80 | bellard | } |
1464 | e6e5ad80 | bellard | |
1465 | e6e5ad80 | bellard | /***************************************
|
1466 | e6e5ad80 | bellard | *
|
1467 | e6e5ad80 | bellard | * I/O access between 0x3ce-0x3cf
|
1468 | e6e5ad80 | bellard | *
|
1469 | e6e5ad80 | bellard | ***************************************/
|
1470 | e6e5ad80 | bellard | |
1471 | e6e5ad80 | bellard | static int |
1472 | e6e5ad80 | bellard | cirrus_hook_read_gr(CirrusVGAState * s, unsigned reg_index, int *reg_value) |
1473 | e6e5ad80 | bellard | { |
1474 | e6e5ad80 | bellard | switch (reg_index) {
|
1475 | aeb3c85f | bellard | case 0x00: // Standard VGA, BGCOLOR 0x000000ff |
1476 | aeb3c85f | bellard | *reg_value = s->cirrus_shadow_gr0; |
1477 | aeb3c85f | bellard | return CIRRUS_HOOK_HANDLED;
|
1478 | aeb3c85f | bellard | case 0x01: // Standard VGA, FGCOLOR 0x000000ff |
1479 | aeb3c85f | bellard | *reg_value = s->cirrus_shadow_gr1; |
1480 | aeb3c85f | bellard | return CIRRUS_HOOK_HANDLED;
|
1481 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1482 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1483 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1484 | e6e5ad80 | bellard | case 0x06: // Standard VGA |
1485 | e6e5ad80 | bellard | case 0x07: // Standard VGA |
1486 | e6e5ad80 | bellard | case 0x08: // Standard VGA |
1487 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1488 | e6e5ad80 | bellard | case 0x05: // Standard VGA, Cirrus extended mode |
1489 | e6e5ad80 | bellard | default:
|
1490 | e6e5ad80 | bellard | break;
|
1491 | e6e5ad80 | bellard | } |
1492 | e6e5ad80 | bellard | |
1493 | e6e5ad80 | bellard | if (reg_index < 0x3a) { |
1494 | e6e5ad80 | bellard | *reg_value = s->gr[reg_index]; |
1495 | e6e5ad80 | bellard | } else {
|
1496 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1497 | e6e5ad80 | bellard | printf("cirrus: inport gr_index %02x\n", reg_index);
|
1498 | e6e5ad80 | bellard | #endif
|
1499 | e6e5ad80 | bellard | *reg_value = 0xff;
|
1500 | e6e5ad80 | bellard | } |
1501 | e6e5ad80 | bellard | |
1502 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1503 | e6e5ad80 | bellard | } |
1504 | e6e5ad80 | bellard | |
1505 | e6e5ad80 | bellard | static int |
1506 | e6e5ad80 | bellard | cirrus_hook_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value) |
1507 | e6e5ad80 | bellard | { |
1508 | a5082316 | bellard | #if defined(DEBUG_BITBLT) && 0 |
1509 | a5082316 | bellard | printf("gr%02x: %02x\n", reg_index, reg_value);
|
1510 | a5082316 | bellard | #endif
|
1511 | e6e5ad80 | bellard | switch (reg_index) {
|
1512 | e6e5ad80 | bellard | case 0x00: // Standard VGA, BGCOLOR 0x000000ff |
1513 | aeb3c85f | bellard | s->cirrus_shadow_gr0 = reg_value; |
1514 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1515 | e6e5ad80 | bellard | case 0x01: // Standard VGA, FGCOLOR 0x000000ff |
1516 | aeb3c85f | bellard | s->cirrus_shadow_gr1 = reg_value; |
1517 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1518 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1519 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1520 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1521 | e6e5ad80 | bellard | case 0x06: // Standard VGA |
1522 | e6e5ad80 | bellard | case 0x07: // Standard VGA |
1523 | e6e5ad80 | bellard | case 0x08: // Standard VGA |
1524 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1525 | e6e5ad80 | bellard | case 0x05: // Standard VGA, Cirrus extended mode |
1526 | e6e5ad80 | bellard | s->gr[reg_index] = reg_value & 0x7f;
|
1527 | 8926b517 | bellard | cirrus_update_memory_access(s); |
1528 | e6e5ad80 | bellard | break;
|
1529 | e6e5ad80 | bellard | case 0x09: // bank offset #0 |
1530 | e6e5ad80 | bellard | case 0x0A: // bank offset #1 |
1531 | 8926b517 | bellard | s->gr[reg_index] = reg_value; |
1532 | 8926b517 | bellard | cirrus_update_bank_ptr(s, 0);
|
1533 | 8926b517 | bellard | cirrus_update_bank_ptr(s, 1);
|
1534 | 2bec46dc | aliguori | cirrus_update_memory_access(s); |
1535 | 8926b517 | bellard | break;
|
1536 | e6e5ad80 | bellard | case 0x0B: |
1537 | e6e5ad80 | bellard | s->gr[reg_index] = reg_value; |
1538 | e6e5ad80 | bellard | cirrus_update_bank_ptr(s, 0);
|
1539 | e6e5ad80 | bellard | cirrus_update_bank_ptr(s, 1);
|
1540 | 8926b517 | bellard | cirrus_update_memory_access(s); |
1541 | e6e5ad80 | bellard | break;
|
1542 | e6e5ad80 | bellard | case 0x10: // BGCOLOR 0x0000ff00 |
1543 | e6e5ad80 | bellard | case 0x11: // FGCOLOR 0x0000ff00 |
1544 | e6e5ad80 | bellard | case 0x12: // BGCOLOR 0x00ff0000 |
1545 | e6e5ad80 | bellard | case 0x13: // FGCOLOR 0x00ff0000 |
1546 | e6e5ad80 | bellard | case 0x14: // BGCOLOR 0xff000000 |
1547 | e6e5ad80 | bellard | case 0x15: // FGCOLOR 0xff000000 |
1548 | e6e5ad80 | bellard | case 0x20: // BLT WIDTH 0x0000ff |
1549 | e6e5ad80 | bellard | case 0x22: // BLT HEIGHT 0x0000ff |
1550 | e6e5ad80 | bellard | case 0x24: // BLT DEST PITCH 0x0000ff |
1551 | e6e5ad80 | bellard | case 0x26: // BLT SRC PITCH 0x0000ff |
1552 | e6e5ad80 | bellard | case 0x28: // BLT DEST ADDR 0x0000ff |
1553 | e6e5ad80 | bellard | case 0x29: // BLT DEST ADDR 0x00ff00 |
1554 | e6e5ad80 | bellard | case 0x2c: // BLT SRC ADDR 0x0000ff |
1555 | e6e5ad80 | bellard | case 0x2d: // BLT SRC ADDR 0x00ff00 |
1556 | a5082316 | bellard | case 0x2f: // BLT WRITEMASK |
1557 | e6e5ad80 | bellard | case 0x30: // BLT MODE |
1558 | e6e5ad80 | bellard | case 0x32: // RASTER OP |
1559 | a21ae81d | bellard | case 0x33: // BLT MODEEXT |
1560 | e6e5ad80 | bellard | case 0x34: // BLT TRANSPARENT COLOR 0x00ff |
1561 | e6e5ad80 | bellard | case 0x35: // BLT TRANSPARENT COLOR 0xff00 |
1562 | e6e5ad80 | bellard | case 0x38: // BLT TRANSPARENT COLOR MASK 0x00ff |
1563 | e6e5ad80 | bellard | case 0x39: // BLT TRANSPARENT COLOR MASK 0xff00 |
1564 | e6e5ad80 | bellard | s->gr[reg_index] = reg_value; |
1565 | e6e5ad80 | bellard | break;
|
1566 | e6e5ad80 | bellard | case 0x21: // BLT WIDTH 0x001f00 |
1567 | e6e5ad80 | bellard | case 0x23: // BLT HEIGHT 0x001f00 |
1568 | e6e5ad80 | bellard | case 0x25: // BLT DEST PITCH 0x001f00 |
1569 | e6e5ad80 | bellard | case 0x27: // BLT SRC PITCH 0x001f00 |
1570 | e6e5ad80 | bellard | s->gr[reg_index] = reg_value & 0x1f;
|
1571 | e6e5ad80 | bellard | break;
|
1572 | e6e5ad80 | bellard | case 0x2a: // BLT DEST ADDR 0x3f0000 |
1573 | a5082316 | bellard | s->gr[reg_index] = reg_value & 0x3f;
|
1574 | a5082316 | bellard | /* if auto start mode, starts bit blt now */
|
1575 | a5082316 | bellard | if (s->gr[0x31] & CIRRUS_BLT_AUTOSTART) { |
1576 | a5082316 | bellard | cirrus_bitblt_start(s); |
1577 | a5082316 | bellard | } |
1578 | a5082316 | bellard | break;
|
1579 | e6e5ad80 | bellard | case 0x2e: // BLT SRC ADDR 0x3f0000 |
1580 | e6e5ad80 | bellard | s->gr[reg_index] = reg_value & 0x3f;
|
1581 | e6e5ad80 | bellard | break;
|
1582 | e6e5ad80 | bellard | case 0x31: // BLT STATUS/START |
1583 | e6e5ad80 | bellard | cirrus_write_bitblt(s, reg_value); |
1584 | e6e5ad80 | bellard | break;
|
1585 | e6e5ad80 | bellard | default:
|
1586 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1587 | e6e5ad80 | bellard | printf("cirrus: outport gr_index %02x, gr_value %02x\n", reg_index,
|
1588 | e6e5ad80 | bellard | reg_value); |
1589 | e6e5ad80 | bellard | #endif
|
1590 | e6e5ad80 | bellard | break;
|
1591 | e6e5ad80 | bellard | } |
1592 | e6e5ad80 | bellard | |
1593 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1594 | e6e5ad80 | bellard | } |
1595 | e6e5ad80 | bellard | |
1596 | e6e5ad80 | bellard | /***************************************
|
1597 | e6e5ad80 | bellard | *
|
1598 | e6e5ad80 | bellard | * I/O access between 0x3d4-0x3d5
|
1599 | e6e5ad80 | bellard | *
|
1600 | e6e5ad80 | bellard | ***************************************/
|
1601 | e6e5ad80 | bellard | |
1602 | e6e5ad80 | bellard | static int |
1603 | e6e5ad80 | bellard | cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value) |
1604 | e6e5ad80 | bellard | { |
1605 | e6e5ad80 | bellard | switch (reg_index) {
|
1606 | e6e5ad80 | bellard | case 0x00: // Standard VGA |
1607 | e6e5ad80 | bellard | case 0x01: // Standard VGA |
1608 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1609 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1610 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1611 | e6e5ad80 | bellard | case 0x05: // Standard VGA |
1612 | e6e5ad80 | bellard | case 0x06: // Standard VGA |
1613 | e6e5ad80 | bellard | case 0x07: // Standard VGA |
1614 | e6e5ad80 | bellard | case 0x08: // Standard VGA |
1615 | e6e5ad80 | bellard | case 0x09: // Standard VGA |
1616 | e6e5ad80 | bellard | case 0x0a: // Standard VGA |
1617 | e6e5ad80 | bellard | case 0x0b: // Standard VGA |
1618 | e6e5ad80 | bellard | case 0x0c: // Standard VGA |
1619 | e6e5ad80 | bellard | case 0x0d: // Standard VGA |
1620 | e6e5ad80 | bellard | case 0x0e: // Standard VGA |
1621 | e6e5ad80 | bellard | case 0x0f: // Standard VGA |
1622 | e6e5ad80 | bellard | case 0x10: // Standard VGA |
1623 | e6e5ad80 | bellard | case 0x11: // Standard VGA |
1624 | e6e5ad80 | bellard | case 0x12: // Standard VGA |
1625 | e6e5ad80 | bellard | case 0x13: // Standard VGA |
1626 | e6e5ad80 | bellard | case 0x14: // Standard VGA |
1627 | e6e5ad80 | bellard | case 0x15: // Standard VGA |
1628 | e6e5ad80 | bellard | case 0x16: // Standard VGA |
1629 | e6e5ad80 | bellard | case 0x17: // Standard VGA |
1630 | e6e5ad80 | bellard | case 0x18: // Standard VGA |
1631 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1632 | ca896ef3 | aurel32 | case 0x24: // Attribute Controller Toggle Readback (R) |
1633 | ca896ef3 | aurel32 | *reg_value = (s->ar_flip_flop << 7);
|
1634 | ca896ef3 | aurel32 | break;
|
1635 | e6e5ad80 | bellard | case 0x19: // Interlace End |
1636 | e6e5ad80 | bellard | case 0x1a: // Miscellaneous Control |
1637 | e6e5ad80 | bellard | case 0x1b: // Extended Display Control |
1638 | e6e5ad80 | bellard | case 0x1c: // Sync Adjust and Genlock |
1639 | e6e5ad80 | bellard | case 0x1d: // Overlay Extended Control |
1640 | e6e5ad80 | bellard | case 0x22: // Graphics Data Latches Readback (R) |
1641 | e6e5ad80 | bellard | case 0x25: // Part Status |
1642 | e6e5ad80 | bellard | case 0x27: // Part ID (R) |
1643 | e6e5ad80 | bellard | *reg_value = s->cr[reg_index]; |
1644 | e6e5ad80 | bellard | break;
|
1645 | e6e5ad80 | bellard | case 0x26: // Attribute Controller Index Readback (R) |
1646 | e6e5ad80 | bellard | *reg_value = s->ar_index & 0x3f;
|
1647 | e6e5ad80 | bellard | break;
|
1648 | e6e5ad80 | bellard | default:
|
1649 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1650 | e6e5ad80 | bellard | printf("cirrus: inport cr_index %02x\n", reg_index);
|
1651 | e6e5ad80 | bellard | *reg_value = 0xff;
|
1652 | e6e5ad80 | bellard | #endif
|
1653 | e6e5ad80 | bellard | break;
|
1654 | e6e5ad80 | bellard | } |
1655 | e6e5ad80 | bellard | |
1656 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1657 | e6e5ad80 | bellard | } |
1658 | e6e5ad80 | bellard | |
1659 | e6e5ad80 | bellard | static int |
1660 | e6e5ad80 | bellard | cirrus_hook_write_cr(CirrusVGAState * s, unsigned reg_index, int reg_value) |
1661 | e6e5ad80 | bellard | { |
1662 | e6e5ad80 | bellard | switch (reg_index) {
|
1663 | e6e5ad80 | bellard | case 0x00: // Standard VGA |
1664 | e6e5ad80 | bellard | case 0x01: // Standard VGA |
1665 | e6e5ad80 | bellard | case 0x02: // Standard VGA |
1666 | e6e5ad80 | bellard | case 0x03: // Standard VGA |
1667 | e6e5ad80 | bellard | case 0x04: // Standard VGA |
1668 | e6e5ad80 | bellard | case 0x05: // Standard VGA |
1669 | e6e5ad80 | bellard | case 0x06: // Standard VGA |
1670 | e6e5ad80 | bellard | case 0x07: // Standard VGA |
1671 | e6e5ad80 | bellard | case 0x08: // Standard VGA |
1672 | e6e5ad80 | bellard | case 0x09: // Standard VGA |
1673 | e6e5ad80 | bellard | case 0x0a: // Standard VGA |
1674 | e6e5ad80 | bellard | case 0x0b: // Standard VGA |
1675 | e6e5ad80 | bellard | case 0x0c: // Standard VGA |
1676 | e6e5ad80 | bellard | case 0x0d: // Standard VGA |
1677 | e6e5ad80 | bellard | case 0x0e: // Standard VGA |
1678 | e6e5ad80 | bellard | case 0x0f: // Standard VGA |
1679 | e6e5ad80 | bellard | case 0x10: // Standard VGA |
1680 | e6e5ad80 | bellard | case 0x11: // Standard VGA |
1681 | e6e5ad80 | bellard | case 0x12: // Standard VGA |
1682 | e6e5ad80 | bellard | case 0x13: // Standard VGA |
1683 | e6e5ad80 | bellard | case 0x14: // Standard VGA |
1684 | e6e5ad80 | bellard | case 0x15: // Standard VGA |
1685 | e6e5ad80 | bellard | case 0x16: // Standard VGA |
1686 | e6e5ad80 | bellard | case 0x17: // Standard VGA |
1687 | e6e5ad80 | bellard | case 0x18: // Standard VGA |
1688 | e6e5ad80 | bellard | return CIRRUS_HOOK_NOT_HANDLED;
|
1689 | e6e5ad80 | bellard | case 0x19: // Interlace End |
1690 | e6e5ad80 | bellard | case 0x1a: // Miscellaneous Control |
1691 | e6e5ad80 | bellard | case 0x1b: // Extended Display Control |
1692 | e6e5ad80 | bellard | case 0x1c: // Sync Adjust and Genlock |
1693 | ae184e4a | bellard | case 0x1d: // Overlay Extended Control |
1694 | e6e5ad80 | bellard | s->cr[reg_index] = reg_value; |
1695 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1696 | e6e5ad80 | bellard | printf("cirrus: handled outport cr_index %02x, cr_value %02x\n",
|
1697 | e6e5ad80 | bellard | reg_index, reg_value); |
1698 | e6e5ad80 | bellard | #endif
|
1699 | e6e5ad80 | bellard | break;
|
1700 | e6e5ad80 | bellard | case 0x22: // Graphics Data Latches Readback (R) |
1701 | e6e5ad80 | bellard | case 0x24: // Attribute Controller Toggle Readback (R) |
1702 | e6e5ad80 | bellard | case 0x26: // Attribute Controller Index Readback (R) |
1703 | e6e5ad80 | bellard | case 0x27: // Part ID (R) |
1704 | e6e5ad80 | bellard | break;
|
1705 | e6e5ad80 | bellard | case 0x25: // Part Status |
1706 | e6e5ad80 | bellard | default:
|
1707 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1708 | e6e5ad80 | bellard | printf("cirrus: outport cr_index %02x, cr_value %02x\n", reg_index,
|
1709 | e6e5ad80 | bellard | reg_value); |
1710 | e6e5ad80 | bellard | #endif
|
1711 | e6e5ad80 | bellard | break;
|
1712 | e6e5ad80 | bellard | } |
1713 | e6e5ad80 | bellard | |
1714 | e6e5ad80 | bellard | return CIRRUS_HOOK_HANDLED;
|
1715 | e6e5ad80 | bellard | } |
1716 | e6e5ad80 | bellard | |
1717 | e6e5ad80 | bellard | /***************************************
|
1718 | e6e5ad80 | bellard | *
|
1719 | e6e5ad80 | bellard | * memory-mapped I/O (bitblt)
|
1720 | e6e5ad80 | bellard | *
|
1721 | e6e5ad80 | bellard | ***************************************/
|
1722 | e6e5ad80 | bellard | |
1723 | e6e5ad80 | bellard | static uint8_t cirrus_mmio_blt_read(CirrusVGAState * s, unsigned address) |
1724 | e6e5ad80 | bellard | { |
1725 | e6e5ad80 | bellard | int value = 0xff; |
1726 | e6e5ad80 | bellard | |
1727 | e6e5ad80 | bellard | switch (address) {
|
1728 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 0): |
1729 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x00, &value);
|
1730 | e6e5ad80 | bellard | break;
|
1731 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 1): |
1732 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x10, &value);
|
1733 | e6e5ad80 | bellard | break;
|
1734 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 2): |
1735 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x12, &value);
|
1736 | e6e5ad80 | bellard | break;
|
1737 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 3): |
1738 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x14, &value);
|
1739 | e6e5ad80 | bellard | break;
|
1740 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 0): |
1741 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x01, &value);
|
1742 | e6e5ad80 | bellard | break;
|
1743 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 1): |
1744 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x11, &value);
|
1745 | e6e5ad80 | bellard | break;
|
1746 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 2): |
1747 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x13, &value);
|
1748 | e6e5ad80 | bellard | break;
|
1749 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 3): |
1750 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x15, &value);
|
1751 | e6e5ad80 | bellard | break;
|
1752 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTWIDTH + 0): |
1753 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x20, &value);
|
1754 | e6e5ad80 | bellard | break;
|
1755 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTWIDTH + 1): |
1756 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x21, &value);
|
1757 | e6e5ad80 | bellard | break;
|
1758 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTHEIGHT + 0): |
1759 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x22, &value);
|
1760 | e6e5ad80 | bellard | break;
|
1761 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTHEIGHT + 1): |
1762 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x23, &value);
|
1763 | e6e5ad80 | bellard | break;
|
1764 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTPITCH + 0): |
1765 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x24, &value);
|
1766 | e6e5ad80 | bellard | break;
|
1767 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTPITCH + 1): |
1768 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x25, &value);
|
1769 | e6e5ad80 | bellard | break;
|
1770 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCPITCH + 0): |
1771 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x26, &value);
|
1772 | e6e5ad80 | bellard | break;
|
1773 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCPITCH + 1): |
1774 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x27, &value);
|
1775 | e6e5ad80 | bellard | break;
|
1776 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 0): |
1777 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x28, &value);
|
1778 | e6e5ad80 | bellard | break;
|
1779 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 1): |
1780 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x29, &value);
|
1781 | e6e5ad80 | bellard | break;
|
1782 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 2): |
1783 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x2a, &value);
|
1784 | e6e5ad80 | bellard | break;
|
1785 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 0): |
1786 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x2c, &value);
|
1787 | e6e5ad80 | bellard | break;
|
1788 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 1): |
1789 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x2d, &value);
|
1790 | e6e5ad80 | bellard | break;
|
1791 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 2): |
1792 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x2e, &value);
|
1793 | e6e5ad80 | bellard | break;
|
1794 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTWRITEMASK:
|
1795 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x2f, &value);
|
1796 | e6e5ad80 | bellard | break;
|
1797 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTMODE:
|
1798 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x30, &value);
|
1799 | e6e5ad80 | bellard | break;
|
1800 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTROP:
|
1801 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x32, &value);
|
1802 | e6e5ad80 | bellard | break;
|
1803 | a21ae81d | bellard | case CIRRUS_MMIO_BLTMODEEXT:
|
1804 | a21ae81d | bellard | cirrus_hook_read_gr(s, 0x33, &value);
|
1805 | a21ae81d | bellard | break;
|
1806 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 0): |
1807 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x34, &value);
|
1808 | e6e5ad80 | bellard | break;
|
1809 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 1): |
1810 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x35, &value);
|
1811 | e6e5ad80 | bellard | break;
|
1812 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 0): |
1813 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x38, &value);
|
1814 | e6e5ad80 | bellard | break;
|
1815 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 1): |
1816 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x39, &value);
|
1817 | e6e5ad80 | bellard | break;
|
1818 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTSTATUS:
|
1819 | e6e5ad80 | bellard | cirrus_hook_read_gr(s, 0x31, &value);
|
1820 | e6e5ad80 | bellard | break;
|
1821 | e6e5ad80 | bellard | default:
|
1822 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1823 | e6e5ad80 | bellard | printf("cirrus: mmio read - address 0x%04x\n", address);
|
1824 | e6e5ad80 | bellard | #endif
|
1825 | e6e5ad80 | bellard | break;
|
1826 | e6e5ad80 | bellard | } |
1827 | e6e5ad80 | bellard | |
1828 | e6e5ad80 | bellard | return (uint8_t) value;
|
1829 | e6e5ad80 | bellard | } |
1830 | e6e5ad80 | bellard | |
1831 | e6e5ad80 | bellard | static void cirrus_mmio_blt_write(CirrusVGAState * s, unsigned address, |
1832 | e6e5ad80 | bellard | uint8_t value) |
1833 | e6e5ad80 | bellard | { |
1834 | e6e5ad80 | bellard | switch (address) {
|
1835 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 0): |
1836 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x00, value);
|
1837 | e6e5ad80 | bellard | break;
|
1838 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 1): |
1839 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x10, value);
|
1840 | e6e5ad80 | bellard | break;
|
1841 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 2): |
1842 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x12, value);
|
1843 | e6e5ad80 | bellard | break;
|
1844 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTBGCOLOR + 3): |
1845 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x14, value);
|
1846 | e6e5ad80 | bellard | break;
|
1847 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 0): |
1848 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x01, value);
|
1849 | e6e5ad80 | bellard | break;
|
1850 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 1): |
1851 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x11, value);
|
1852 | e6e5ad80 | bellard | break;
|
1853 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 2): |
1854 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x13, value);
|
1855 | e6e5ad80 | bellard | break;
|
1856 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTFGCOLOR + 3): |
1857 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x15, value);
|
1858 | e6e5ad80 | bellard | break;
|
1859 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTWIDTH + 0): |
1860 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x20, value);
|
1861 | e6e5ad80 | bellard | break;
|
1862 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTWIDTH + 1): |
1863 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x21, value);
|
1864 | e6e5ad80 | bellard | break;
|
1865 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTHEIGHT + 0): |
1866 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x22, value);
|
1867 | e6e5ad80 | bellard | break;
|
1868 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTHEIGHT + 1): |
1869 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x23, value);
|
1870 | e6e5ad80 | bellard | break;
|
1871 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTPITCH + 0): |
1872 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x24, value);
|
1873 | e6e5ad80 | bellard | break;
|
1874 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTPITCH + 1): |
1875 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x25, value);
|
1876 | e6e5ad80 | bellard | break;
|
1877 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCPITCH + 0): |
1878 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x26, value);
|
1879 | e6e5ad80 | bellard | break;
|
1880 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCPITCH + 1): |
1881 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x27, value);
|
1882 | e6e5ad80 | bellard | break;
|
1883 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 0): |
1884 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x28, value);
|
1885 | e6e5ad80 | bellard | break;
|
1886 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 1): |
1887 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x29, value);
|
1888 | e6e5ad80 | bellard | break;
|
1889 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 2): |
1890 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x2a, value);
|
1891 | e6e5ad80 | bellard | break;
|
1892 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTDESTADDR + 3): |
1893 | e6e5ad80 | bellard | /* ignored */
|
1894 | e6e5ad80 | bellard | break;
|
1895 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 0): |
1896 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x2c, value);
|
1897 | e6e5ad80 | bellard | break;
|
1898 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 1): |
1899 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x2d, value);
|
1900 | e6e5ad80 | bellard | break;
|
1901 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTSRCADDR + 2): |
1902 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x2e, value);
|
1903 | e6e5ad80 | bellard | break;
|
1904 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTWRITEMASK:
|
1905 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x2f, value);
|
1906 | e6e5ad80 | bellard | break;
|
1907 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTMODE:
|
1908 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x30, value);
|
1909 | e6e5ad80 | bellard | break;
|
1910 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTROP:
|
1911 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x32, value);
|
1912 | e6e5ad80 | bellard | break;
|
1913 | a21ae81d | bellard | case CIRRUS_MMIO_BLTMODEEXT:
|
1914 | a21ae81d | bellard | cirrus_hook_write_gr(s, 0x33, value);
|
1915 | a21ae81d | bellard | break;
|
1916 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 0): |
1917 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x34, value);
|
1918 | e6e5ad80 | bellard | break;
|
1919 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 1): |
1920 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x35, value);
|
1921 | e6e5ad80 | bellard | break;
|
1922 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 0): |
1923 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x38, value);
|
1924 | e6e5ad80 | bellard | break;
|
1925 | e6e5ad80 | bellard | case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 1): |
1926 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x39, value);
|
1927 | e6e5ad80 | bellard | break;
|
1928 | e6e5ad80 | bellard | case CIRRUS_MMIO_BLTSTATUS:
|
1929 | e6e5ad80 | bellard | cirrus_hook_write_gr(s, 0x31, value);
|
1930 | e6e5ad80 | bellard | break;
|
1931 | e6e5ad80 | bellard | default:
|
1932 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
1933 | e6e5ad80 | bellard | printf("cirrus: mmio write - addr 0x%04x val 0x%02x (ignored)\n",
|
1934 | e6e5ad80 | bellard | address, value); |
1935 | e6e5ad80 | bellard | #endif
|
1936 | e6e5ad80 | bellard | break;
|
1937 | e6e5ad80 | bellard | } |
1938 | e6e5ad80 | bellard | } |
1939 | e6e5ad80 | bellard | |
1940 | e6e5ad80 | bellard | /***************************************
|
1941 | e6e5ad80 | bellard | *
|
1942 | e6e5ad80 | bellard | * write mode 4/5
|
1943 | e6e5ad80 | bellard | *
|
1944 | e6e5ad80 | bellard | * assume TARGET_PAGE_SIZE >= 16
|
1945 | e6e5ad80 | bellard | *
|
1946 | e6e5ad80 | bellard | ***************************************/
|
1947 | e6e5ad80 | bellard | |
1948 | e6e5ad80 | bellard | static void cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s, |
1949 | e6e5ad80 | bellard | unsigned mode,
|
1950 | e6e5ad80 | bellard | unsigned offset,
|
1951 | e6e5ad80 | bellard | uint32_t mem_value) |
1952 | e6e5ad80 | bellard | { |
1953 | e6e5ad80 | bellard | int x;
|
1954 | e6e5ad80 | bellard | unsigned val = mem_value;
|
1955 | e6e5ad80 | bellard | uint8_t *dst; |
1956 | e6e5ad80 | bellard | |
1957 | b2eb849d | aurel32 | dst = s->vram_ptr + (offset &= s->cirrus_addr_mask); |
1958 | e6e5ad80 | bellard | for (x = 0; x < 8; x++) { |
1959 | e6e5ad80 | bellard | if (val & 0x80) { |
1960 | 0b74ed78 | bellard | *dst = s->cirrus_shadow_gr1; |
1961 | e6e5ad80 | bellard | } else if (mode == 5) { |
1962 | 0b74ed78 | bellard | *dst = s->cirrus_shadow_gr0; |
1963 | e6e5ad80 | bellard | } |
1964 | e6e5ad80 | bellard | val <<= 1;
|
1965 | 0b74ed78 | bellard | dst++; |
1966 | e6e5ad80 | bellard | } |
1967 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + offset); |
1968 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + offset + 7);
|
1969 | e6e5ad80 | bellard | } |
1970 | e6e5ad80 | bellard | |
1971 | e6e5ad80 | bellard | static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s, |
1972 | e6e5ad80 | bellard | unsigned mode,
|
1973 | e6e5ad80 | bellard | unsigned offset,
|
1974 | e6e5ad80 | bellard | uint32_t mem_value) |
1975 | e6e5ad80 | bellard | { |
1976 | e6e5ad80 | bellard | int x;
|
1977 | e6e5ad80 | bellard | unsigned val = mem_value;
|
1978 | e6e5ad80 | bellard | uint8_t *dst; |
1979 | e6e5ad80 | bellard | |
1980 | b2eb849d | aurel32 | dst = s->vram_ptr + (offset &= s->cirrus_addr_mask); |
1981 | e6e5ad80 | bellard | for (x = 0; x < 8; x++) { |
1982 | e6e5ad80 | bellard | if (val & 0x80) { |
1983 | 0b74ed78 | bellard | *dst = s->cirrus_shadow_gr1; |
1984 | 0b74ed78 | bellard | *(dst + 1) = s->gr[0x11]; |
1985 | e6e5ad80 | bellard | } else if (mode == 5) { |
1986 | 0b74ed78 | bellard | *dst = s->cirrus_shadow_gr0; |
1987 | 0b74ed78 | bellard | *(dst + 1) = s->gr[0x10]; |
1988 | e6e5ad80 | bellard | } |
1989 | e6e5ad80 | bellard | val <<= 1;
|
1990 | 0b74ed78 | bellard | dst += 2;
|
1991 | e6e5ad80 | bellard | } |
1992 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + offset); |
1993 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + offset + 15);
|
1994 | e6e5ad80 | bellard | } |
1995 | e6e5ad80 | bellard | |
1996 | e6e5ad80 | bellard | /***************************************
|
1997 | e6e5ad80 | bellard | *
|
1998 | e6e5ad80 | bellard | * memory access between 0xa0000-0xbffff
|
1999 | e6e5ad80 | bellard | *
|
2000 | e6e5ad80 | bellard | ***************************************/
|
2001 | e6e5ad80 | bellard | |
2002 | e6e5ad80 | bellard | static uint32_t cirrus_vga_mem_readb(void *opaque, target_phys_addr_t addr) |
2003 | e6e5ad80 | bellard | { |
2004 | e6e5ad80 | bellard | CirrusVGAState *s = opaque; |
2005 | e6e5ad80 | bellard | unsigned bank_index;
|
2006 | e6e5ad80 | bellard | unsigned bank_offset;
|
2007 | e6e5ad80 | bellard | uint32_t val; |
2008 | e6e5ad80 | bellard | |
2009 | e6e5ad80 | bellard | if ((s->sr[0x07] & 0x01) == 0) { |
2010 | e6e5ad80 | bellard | return vga_mem_readb(s, addr);
|
2011 | e6e5ad80 | bellard | } |
2012 | e6e5ad80 | bellard | |
2013 | aeb3c85f | bellard | addr &= 0x1ffff;
|
2014 | aeb3c85f | bellard | |
2015 | e6e5ad80 | bellard | if (addr < 0x10000) { |
2016 | e6e5ad80 | bellard | /* XXX handle bitblt */
|
2017 | e6e5ad80 | bellard | /* video memory */
|
2018 | e6e5ad80 | bellard | bank_index = addr >> 15;
|
2019 | e6e5ad80 | bellard | bank_offset = addr & 0x7fff;
|
2020 | e6e5ad80 | bellard | if (bank_offset < s->cirrus_bank_limit[bank_index]) {
|
2021 | e6e5ad80 | bellard | bank_offset += s->cirrus_bank_base[bank_index]; |
2022 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) == 0x14) { |
2023 | e6e5ad80 | bellard | bank_offset <<= 4;
|
2024 | e6e5ad80 | bellard | } else if (s->gr[0x0B] & 0x02) { |
2025 | e6e5ad80 | bellard | bank_offset <<= 3;
|
2026 | e6e5ad80 | bellard | } |
2027 | e6e5ad80 | bellard | bank_offset &= s->cirrus_addr_mask; |
2028 | e6e5ad80 | bellard | val = *(s->vram_ptr + bank_offset); |
2029 | e6e5ad80 | bellard | } else
|
2030 | e6e5ad80 | bellard | val = 0xff;
|
2031 | e6e5ad80 | bellard | } else if (addr >= 0x18000 && addr < 0x18100) { |
2032 | e6e5ad80 | bellard | /* memory-mapped I/O */
|
2033 | e6e5ad80 | bellard | val = 0xff;
|
2034 | e6e5ad80 | bellard | if ((s->sr[0x17] & 0x44) == 0x04) { |
2035 | e6e5ad80 | bellard | val = cirrus_mmio_blt_read(s, addr & 0xff);
|
2036 | e6e5ad80 | bellard | } |
2037 | e6e5ad80 | bellard | } else {
|
2038 | e6e5ad80 | bellard | val = 0xff;
|
2039 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
2040 | e6e5ad80 | bellard | printf("cirrus: mem_readb %06x\n", addr);
|
2041 | e6e5ad80 | bellard | #endif
|
2042 | e6e5ad80 | bellard | } |
2043 | e6e5ad80 | bellard | return val;
|
2044 | e6e5ad80 | bellard | } |
2045 | e6e5ad80 | bellard | |
2046 | e6e5ad80 | bellard | static uint32_t cirrus_vga_mem_readw(void *opaque, target_phys_addr_t addr) |
2047 | e6e5ad80 | bellard | { |
2048 | e6e5ad80 | bellard | uint32_t v; |
2049 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2050 | e6e5ad80 | bellard | v = cirrus_vga_mem_readb(opaque, addr) << 8;
|
2051 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 1);
|
2052 | e6e5ad80 | bellard | #else
|
2053 | e6e5ad80 | bellard | v = cirrus_vga_mem_readb(opaque, addr); |
2054 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 1) << 8; |
2055 | e6e5ad80 | bellard | #endif
|
2056 | e6e5ad80 | bellard | return v;
|
2057 | e6e5ad80 | bellard | } |
2058 | e6e5ad80 | bellard | |
2059 | e6e5ad80 | bellard | static uint32_t cirrus_vga_mem_readl(void *opaque, target_phys_addr_t addr) |
2060 | e6e5ad80 | bellard | { |
2061 | e6e5ad80 | bellard | uint32_t v; |
2062 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2063 | e6e5ad80 | bellard | v = cirrus_vga_mem_readb(opaque, addr) << 24;
|
2064 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 1) << 16; |
2065 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 2) << 8; |
2066 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 3);
|
2067 | e6e5ad80 | bellard | #else
|
2068 | e6e5ad80 | bellard | v = cirrus_vga_mem_readb(opaque, addr); |
2069 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 1) << 8; |
2070 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 2) << 16; |
2071 | e6e5ad80 | bellard | v |= cirrus_vga_mem_readb(opaque, addr + 3) << 24; |
2072 | e6e5ad80 | bellard | #endif
|
2073 | e6e5ad80 | bellard | return v;
|
2074 | e6e5ad80 | bellard | } |
2075 | e6e5ad80 | bellard | |
2076 | 5fafdf24 | ths | static void cirrus_vga_mem_writeb(void *opaque, target_phys_addr_t addr, |
2077 | e6e5ad80 | bellard | uint32_t mem_value) |
2078 | e6e5ad80 | bellard | { |
2079 | e6e5ad80 | bellard | CirrusVGAState *s = opaque; |
2080 | e6e5ad80 | bellard | unsigned bank_index;
|
2081 | e6e5ad80 | bellard | unsigned bank_offset;
|
2082 | e6e5ad80 | bellard | unsigned mode;
|
2083 | e6e5ad80 | bellard | |
2084 | e6e5ad80 | bellard | if ((s->sr[0x07] & 0x01) == 0) { |
2085 | e6e5ad80 | bellard | vga_mem_writeb(s, addr, mem_value); |
2086 | e6e5ad80 | bellard | return;
|
2087 | e6e5ad80 | bellard | } |
2088 | e6e5ad80 | bellard | |
2089 | aeb3c85f | bellard | addr &= 0x1ffff;
|
2090 | aeb3c85f | bellard | |
2091 | e6e5ad80 | bellard | if (addr < 0x10000) { |
2092 | e6e5ad80 | bellard | if (s->cirrus_srcptr != s->cirrus_srcptr_end) {
|
2093 | e6e5ad80 | bellard | /* bitblt */
|
2094 | e6e5ad80 | bellard | *s->cirrus_srcptr++ = (uint8_t) mem_value; |
2095 | a5082316 | bellard | if (s->cirrus_srcptr >= s->cirrus_srcptr_end) {
|
2096 | e6e5ad80 | bellard | cirrus_bitblt_cputovideo_next(s); |
2097 | e6e5ad80 | bellard | } |
2098 | e6e5ad80 | bellard | } else {
|
2099 | e6e5ad80 | bellard | /* video memory */
|
2100 | e6e5ad80 | bellard | bank_index = addr >> 15;
|
2101 | e6e5ad80 | bellard | bank_offset = addr & 0x7fff;
|
2102 | e6e5ad80 | bellard | if (bank_offset < s->cirrus_bank_limit[bank_index]) {
|
2103 | e6e5ad80 | bellard | bank_offset += s->cirrus_bank_base[bank_index]; |
2104 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) == 0x14) { |
2105 | e6e5ad80 | bellard | bank_offset <<= 4;
|
2106 | e6e5ad80 | bellard | } else if (s->gr[0x0B] & 0x02) { |
2107 | e6e5ad80 | bellard | bank_offset <<= 3;
|
2108 | e6e5ad80 | bellard | } |
2109 | e6e5ad80 | bellard | bank_offset &= s->cirrus_addr_mask; |
2110 | e6e5ad80 | bellard | mode = s->gr[0x05] & 0x7; |
2111 | e6e5ad80 | bellard | if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) { |
2112 | e6e5ad80 | bellard | *(s->vram_ptr + bank_offset) = mem_value; |
2113 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + |
2114 | e6e5ad80 | bellard | bank_offset); |
2115 | e6e5ad80 | bellard | } else {
|
2116 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) != 0x14) { |
2117 | e6e5ad80 | bellard | cirrus_mem_writeb_mode4and5_8bpp(s, mode, |
2118 | e6e5ad80 | bellard | bank_offset, |
2119 | e6e5ad80 | bellard | mem_value); |
2120 | e6e5ad80 | bellard | } else {
|
2121 | e6e5ad80 | bellard | cirrus_mem_writeb_mode4and5_16bpp(s, mode, |
2122 | e6e5ad80 | bellard | bank_offset, |
2123 | e6e5ad80 | bellard | mem_value); |
2124 | e6e5ad80 | bellard | } |
2125 | e6e5ad80 | bellard | } |
2126 | e6e5ad80 | bellard | } |
2127 | e6e5ad80 | bellard | } |
2128 | e6e5ad80 | bellard | } else if (addr >= 0x18000 && addr < 0x18100) { |
2129 | e6e5ad80 | bellard | /* memory-mapped I/O */
|
2130 | e6e5ad80 | bellard | if ((s->sr[0x17] & 0x44) == 0x04) { |
2131 | e6e5ad80 | bellard | cirrus_mmio_blt_write(s, addr & 0xff, mem_value);
|
2132 | e6e5ad80 | bellard | } |
2133 | e6e5ad80 | bellard | } else {
|
2134 | e6e5ad80 | bellard | #ifdef DEBUG_CIRRUS
|
2135 | e6e5ad80 | bellard | printf("cirrus: mem_writeb %06x value %02x\n", addr, mem_value);
|
2136 | e6e5ad80 | bellard | #endif
|
2137 | e6e5ad80 | bellard | } |
2138 | e6e5ad80 | bellard | } |
2139 | e6e5ad80 | bellard | |
2140 | e6e5ad80 | bellard | static void cirrus_vga_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) |
2141 | e6e5ad80 | bellard | { |
2142 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2143 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr, (val >> 8) & 0xff); |
2144 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 1, val & 0xff); |
2145 | e6e5ad80 | bellard | #else
|
2146 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr, val & 0xff);
|
2147 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2148 | e6e5ad80 | bellard | #endif
|
2149 | e6e5ad80 | bellard | } |
2150 | e6e5ad80 | bellard | |
2151 | e6e5ad80 | bellard | static void cirrus_vga_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) |
2152 | e6e5ad80 | bellard | { |
2153 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2154 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr, (val >> 24) & 0xff); |
2155 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 1, (val >> 16) & 0xff); |
2156 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 2, (val >> 8) & 0xff); |
2157 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 3, val & 0xff); |
2158 | e6e5ad80 | bellard | #else
|
2159 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr, val & 0xff);
|
2160 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2161 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff); |
2162 | e6e5ad80 | bellard | cirrus_vga_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff); |
2163 | e6e5ad80 | bellard | #endif
|
2164 | e6e5ad80 | bellard | } |
2165 | e6e5ad80 | bellard | |
2166 | e6e5ad80 | bellard | static CPUReadMemoryFunc *cirrus_vga_mem_read[3] = { |
2167 | e6e5ad80 | bellard | cirrus_vga_mem_readb, |
2168 | e6e5ad80 | bellard | cirrus_vga_mem_readw, |
2169 | e6e5ad80 | bellard | cirrus_vga_mem_readl, |
2170 | e6e5ad80 | bellard | }; |
2171 | e6e5ad80 | bellard | |
2172 | e6e5ad80 | bellard | static CPUWriteMemoryFunc *cirrus_vga_mem_write[3] = { |
2173 | e6e5ad80 | bellard | cirrus_vga_mem_writeb, |
2174 | e6e5ad80 | bellard | cirrus_vga_mem_writew, |
2175 | e6e5ad80 | bellard | cirrus_vga_mem_writel, |
2176 | e6e5ad80 | bellard | }; |
2177 | e6e5ad80 | bellard | |
2178 | e6e5ad80 | bellard | /***************************************
|
2179 | e6e5ad80 | bellard | *
|
2180 | a5082316 | bellard | * hardware cursor
|
2181 | a5082316 | bellard | *
|
2182 | a5082316 | bellard | ***************************************/
|
2183 | a5082316 | bellard | |
2184 | a5082316 | bellard | static inline void invalidate_cursor1(CirrusVGAState *s) |
2185 | a5082316 | bellard | { |
2186 | a5082316 | bellard | if (s->last_hw_cursor_size) {
|
2187 | 5fafdf24 | ths | vga_invalidate_scanlines((VGAState *)s, |
2188 | a5082316 | bellard | s->last_hw_cursor_y + s->last_hw_cursor_y_start, |
2189 | a5082316 | bellard | s->last_hw_cursor_y + s->last_hw_cursor_y_end); |
2190 | a5082316 | bellard | } |
2191 | a5082316 | bellard | } |
2192 | a5082316 | bellard | |
2193 | a5082316 | bellard | static inline void cirrus_cursor_compute_yrange(CirrusVGAState *s) |
2194 | a5082316 | bellard | { |
2195 | a5082316 | bellard | const uint8_t *src;
|
2196 | a5082316 | bellard | uint32_t content; |
2197 | a5082316 | bellard | int y, y_min, y_max;
|
2198 | a5082316 | bellard | |
2199 | 78e127ef | bellard | src = s->vram_ptr + s->real_vram_size - 16 * 1024; |
2200 | a5082316 | bellard | if (s->sr[0x12] & CIRRUS_CURSOR_LARGE) { |
2201 | a5082316 | bellard | src += (s->sr[0x13] & 0x3c) * 256; |
2202 | a5082316 | bellard | y_min = 64;
|
2203 | a5082316 | bellard | y_max = -1;
|
2204 | a5082316 | bellard | for(y = 0; y < 64; y++) { |
2205 | a5082316 | bellard | content = ((uint32_t *)src)[0] |
|
2206 | a5082316 | bellard | ((uint32_t *)src)[1] |
|
2207 | a5082316 | bellard | ((uint32_t *)src)[2] |
|
2208 | a5082316 | bellard | ((uint32_t *)src)[3];
|
2209 | a5082316 | bellard | if (content) {
|
2210 | a5082316 | bellard | if (y < y_min)
|
2211 | a5082316 | bellard | y_min = y; |
2212 | a5082316 | bellard | if (y > y_max)
|
2213 | a5082316 | bellard | y_max = y; |
2214 | a5082316 | bellard | } |
2215 | a5082316 | bellard | src += 16;
|
2216 | a5082316 | bellard | } |
2217 | a5082316 | bellard | } else {
|
2218 | a5082316 | bellard | src += (s->sr[0x13] & 0x3f) * 256; |
2219 | a5082316 | bellard | y_min = 32;
|
2220 | a5082316 | bellard | y_max = -1;
|
2221 | a5082316 | bellard | for(y = 0; y < 32; y++) { |
2222 | a5082316 | bellard | content = ((uint32_t *)src)[0] |
|
2223 | a5082316 | bellard | ((uint32_t *)(src + 128))[0]; |
2224 | a5082316 | bellard | if (content) {
|
2225 | a5082316 | bellard | if (y < y_min)
|
2226 | a5082316 | bellard | y_min = y; |
2227 | a5082316 | bellard | if (y > y_max)
|
2228 | a5082316 | bellard | y_max = y; |
2229 | a5082316 | bellard | } |
2230 | a5082316 | bellard | src += 4;
|
2231 | a5082316 | bellard | } |
2232 | a5082316 | bellard | } |
2233 | a5082316 | bellard | if (y_min > y_max) {
|
2234 | a5082316 | bellard | s->last_hw_cursor_y_start = 0;
|
2235 | a5082316 | bellard | s->last_hw_cursor_y_end = 0;
|
2236 | a5082316 | bellard | } else {
|
2237 | a5082316 | bellard | s->last_hw_cursor_y_start = y_min; |
2238 | a5082316 | bellard | s->last_hw_cursor_y_end = y_max + 1;
|
2239 | a5082316 | bellard | } |
2240 | a5082316 | bellard | } |
2241 | a5082316 | bellard | |
2242 | a5082316 | bellard | /* NOTE: we do not currently handle the cursor bitmap change, so we
|
2243 | a5082316 | bellard | update the cursor only if it moves. */
|
2244 | a5082316 | bellard | static void cirrus_cursor_invalidate(VGAState *s1) |
2245 | a5082316 | bellard | { |
2246 | a5082316 | bellard | CirrusVGAState *s = (CirrusVGAState *)s1; |
2247 | a5082316 | bellard | int size;
|
2248 | a5082316 | bellard | |
2249 | 70c14705 | blueswir1 | if (!(s->sr[0x12] & CIRRUS_CURSOR_SHOW)) { |
2250 | a5082316 | bellard | size = 0;
|
2251 | a5082316 | bellard | } else {
|
2252 | a5082316 | bellard | if (s->sr[0x12] & CIRRUS_CURSOR_LARGE) |
2253 | a5082316 | bellard | size = 64;
|
2254 | a5082316 | bellard | else
|
2255 | a5082316 | bellard | size = 32;
|
2256 | a5082316 | bellard | } |
2257 | a5082316 | bellard | /* invalidate last cursor and new cursor if any change */
|
2258 | a5082316 | bellard | if (s->last_hw_cursor_size != size ||
|
2259 | a5082316 | bellard | s->last_hw_cursor_x != s->hw_cursor_x || |
2260 | a5082316 | bellard | s->last_hw_cursor_y != s->hw_cursor_y) { |
2261 | a5082316 | bellard | |
2262 | a5082316 | bellard | invalidate_cursor1(s); |
2263 | 3b46e624 | ths | |
2264 | a5082316 | bellard | s->last_hw_cursor_size = size; |
2265 | a5082316 | bellard | s->last_hw_cursor_x = s->hw_cursor_x; |
2266 | a5082316 | bellard | s->last_hw_cursor_y = s->hw_cursor_y; |
2267 | a5082316 | bellard | /* compute the real cursor min and max y */
|
2268 | a5082316 | bellard | cirrus_cursor_compute_yrange(s); |
2269 | a5082316 | bellard | invalidate_cursor1(s); |
2270 | a5082316 | bellard | } |
2271 | a5082316 | bellard | } |
2272 | a5082316 | bellard | |
2273 | a5082316 | bellard | static void cirrus_cursor_draw_line(VGAState *s1, uint8_t *d1, int scr_y) |
2274 | a5082316 | bellard | { |
2275 | a5082316 | bellard | CirrusVGAState *s = (CirrusVGAState *)s1; |
2276 | a5082316 | bellard | int w, h, bpp, x1, x2, poffset;
|
2277 | a5082316 | bellard | unsigned int color0, color1; |
2278 | a5082316 | bellard | const uint8_t *palette, *src;
|
2279 | a5082316 | bellard | uint32_t content; |
2280 | 3b46e624 | ths | |
2281 | 5fafdf24 | ths | if (!(s->sr[0x12] & CIRRUS_CURSOR_SHOW)) |
2282 | a5082316 | bellard | return;
|
2283 | a5082316 | bellard | /* fast test to see if the cursor intersects with the scan line */
|
2284 | a5082316 | bellard | if (s->sr[0x12] & CIRRUS_CURSOR_LARGE) { |
2285 | a5082316 | bellard | h = 64;
|
2286 | a5082316 | bellard | } else {
|
2287 | a5082316 | bellard | h = 32;
|
2288 | a5082316 | bellard | } |
2289 | a5082316 | bellard | if (scr_y < s->hw_cursor_y ||
|
2290 | a5082316 | bellard | scr_y >= (s->hw_cursor_y + h)) |
2291 | a5082316 | bellard | return;
|
2292 | 3b46e624 | ths | |
2293 | 78e127ef | bellard | src = s->vram_ptr + s->real_vram_size - 16 * 1024; |
2294 | a5082316 | bellard | if (s->sr[0x12] & CIRRUS_CURSOR_LARGE) { |
2295 | a5082316 | bellard | src += (s->sr[0x13] & 0x3c) * 256; |
2296 | a5082316 | bellard | src += (scr_y - s->hw_cursor_y) * 16;
|
2297 | a5082316 | bellard | poffset = 8;
|
2298 | a5082316 | bellard | content = ((uint32_t *)src)[0] |
|
2299 | a5082316 | bellard | ((uint32_t *)src)[1] |
|
2300 | a5082316 | bellard | ((uint32_t *)src)[2] |
|
2301 | a5082316 | bellard | ((uint32_t *)src)[3];
|
2302 | a5082316 | bellard | } else {
|
2303 | a5082316 | bellard | src += (s->sr[0x13] & 0x3f) * 256; |
2304 | a5082316 | bellard | src += (scr_y - s->hw_cursor_y) * 4;
|
2305 | a5082316 | bellard | poffset = 128;
|
2306 | a5082316 | bellard | content = ((uint32_t *)src)[0] |
|
2307 | a5082316 | bellard | ((uint32_t *)(src + 128))[0]; |
2308 | a5082316 | bellard | } |
2309 | a5082316 | bellard | /* if nothing to draw, no need to continue */
|
2310 | a5082316 | bellard | if (!content)
|
2311 | a5082316 | bellard | return;
|
2312 | a5082316 | bellard | w = h; |
2313 | a5082316 | bellard | |
2314 | a5082316 | bellard | x1 = s->hw_cursor_x; |
2315 | a5082316 | bellard | if (x1 >= s->last_scr_width)
|
2316 | a5082316 | bellard | return;
|
2317 | a5082316 | bellard | x2 = s->hw_cursor_x + w; |
2318 | a5082316 | bellard | if (x2 > s->last_scr_width)
|
2319 | a5082316 | bellard | x2 = s->last_scr_width; |
2320 | a5082316 | bellard | w = x2 - x1; |
2321 | a5082316 | bellard | palette = s->cirrus_hidden_palette; |
2322 | 5fafdf24 | ths | color0 = s->rgb_to_pixel(c6_to_8(palette[0x0 * 3]), |
2323 | 5fafdf24 | ths | c6_to_8(palette[0x0 * 3 + 1]), |
2324 | a5082316 | bellard | c6_to_8(palette[0x0 * 3 + 2])); |
2325 | 5fafdf24 | ths | color1 = s->rgb_to_pixel(c6_to_8(palette[0xf * 3]), |
2326 | 5fafdf24 | ths | c6_to_8(palette[0xf * 3 + 1]), |
2327 | a5082316 | bellard | c6_to_8(palette[0xf * 3 + 2])); |
2328 | 0e1f5a0c | aliguori | bpp = ((ds_get_bits_per_pixel(s->ds) + 7) >> 3); |
2329 | a5082316 | bellard | d1 += x1 * bpp; |
2330 | 0e1f5a0c | aliguori | switch(ds_get_bits_per_pixel(s->ds)) {
|
2331 | a5082316 | bellard | default:
|
2332 | a5082316 | bellard | break;
|
2333 | a5082316 | bellard | case 8: |
2334 | a5082316 | bellard | vga_draw_cursor_line_8(d1, src, poffset, w, color0, color1, 0xff);
|
2335 | a5082316 | bellard | break;
|
2336 | a5082316 | bellard | case 15: |
2337 | a5082316 | bellard | vga_draw_cursor_line_16(d1, src, poffset, w, color0, color1, 0x7fff);
|
2338 | a5082316 | bellard | break;
|
2339 | a5082316 | bellard | case 16: |
2340 | a5082316 | bellard | vga_draw_cursor_line_16(d1, src, poffset, w, color0, color1, 0xffff);
|
2341 | a5082316 | bellard | break;
|
2342 | a5082316 | bellard | case 32: |
2343 | a5082316 | bellard | vga_draw_cursor_line_32(d1, src, poffset, w, color0, color1, 0xffffff);
|
2344 | a5082316 | bellard | break;
|
2345 | a5082316 | bellard | } |
2346 | a5082316 | bellard | } |
2347 | a5082316 | bellard | |
2348 | a5082316 | bellard | /***************************************
|
2349 | a5082316 | bellard | *
|
2350 | e6e5ad80 | bellard | * LFB memory access
|
2351 | e6e5ad80 | bellard | *
|
2352 | e6e5ad80 | bellard | ***************************************/
|
2353 | e6e5ad80 | bellard | |
2354 | e6e5ad80 | bellard | static uint32_t cirrus_linear_readb(void *opaque, target_phys_addr_t addr) |
2355 | e6e5ad80 | bellard | { |
2356 | e6e5ad80 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2357 | e6e5ad80 | bellard | uint32_t ret; |
2358 | e6e5ad80 | bellard | |
2359 | e6e5ad80 | bellard | addr &= s->cirrus_addr_mask; |
2360 | e6e5ad80 | bellard | |
2361 | 5fafdf24 | ths | if (((s->sr[0x17] & 0x44) == 0x44) && |
2362 | 78e127ef | bellard | ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { |
2363 | e6e5ad80 | bellard | /* memory-mapped I/O */
|
2364 | e6e5ad80 | bellard | ret = cirrus_mmio_blt_read(s, addr & 0xff);
|
2365 | e6e5ad80 | bellard | } else if (0) { |
2366 | e6e5ad80 | bellard | /* XXX handle bitblt */
|
2367 | e6e5ad80 | bellard | ret = 0xff;
|
2368 | e6e5ad80 | bellard | } else {
|
2369 | e6e5ad80 | bellard | /* video memory */
|
2370 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) == 0x14) { |
2371 | e6e5ad80 | bellard | addr <<= 4;
|
2372 | e6e5ad80 | bellard | } else if (s->gr[0x0B] & 0x02) { |
2373 | e6e5ad80 | bellard | addr <<= 3;
|
2374 | e6e5ad80 | bellard | } |
2375 | e6e5ad80 | bellard | addr &= s->cirrus_addr_mask; |
2376 | e6e5ad80 | bellard | ret = *(s->vram_ptr + addr); |
2377 | e6e5ad80 | bellard | } |
2378 | e6e5ad80 | bellard | |
2379 | e6e5ad80 | bellard | return ret;
|
2380 | e6e5ad80 | bellard | } |
2381 | e6e5ad80 | bellard | |
2382 | e6e5ad80 | bellard | static uint32_t cirrus_linear_readw(void *opaque, target_phys_addr_t addr) |
2383 | e6e5ad80 | bellard | { |
2384 | e6e5ad80 | bellard | uint32_t v; |
2385 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2386 | e6e5ad80 | bellard | v = cirrus_linear_readb(opaque, addr) << 8;
|
2387 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 1);
|
2388 | e6e5ad80 | bellard | #else
|
2389 | e6e5ad80 | bellard | v = cirrus_linear_readb(opaque, addr); |
2390 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 1) << 8; |
2391 | e6e5ad80 | bellard | #endif
|
2392 | e6e5ad80 | bellard | return v;
|
2393 | e6e5ad80 | bellard | } |
2394 | e6e5ad80 | bellard | |
2395 | e6e5ad80 | bellard | static uint32_t cirrus_linear_readl(void *opaque, target_phys_addr_t addr) |
2396 | e6e5ad80 | bellard | { |
2397 | e6e5ad80 | bellard | uint32_t v; |
2398 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2399 | e6e5ad80 | bellard | v = cirrus_linear_readb(opaque, addr) << 24;
|
2400 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 1) << 16; |
2401 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 2) << 8; |
2402 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 3);
|
2403 | e6e5ad80 | bellard | #else
|
2404 | e6e5ad80 | bellard | v = cirrus_linear_readb(opaque, addr); |
2405 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 1) << 8; |
2406 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 2) << 16; |
2407 | e6e5ad80 | bellard | v |= cirrus_linear_readb(opaque, addr + 3) << 24; |
2408 | e6e5ad80 | bellard | #endif
|
2409 | e6e5ad80 | bellard | return v;
|
2410 | e6e5ad80 | bellard | } |
2411 | e6e5ad80 | bellard | |
2412 | e6e5ad80 | bellard | static void cirrus_linear_writeb(void *opaque, target_phys_addr_t addr, |
2413 | e6e5ad80 | bellard | uint32_t val) |
2414 | e6e5ad80 | bellard | { |
2415 | e6e5ad80 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2416 | e6e5ad80 | bellard | unsigned mode;
|
2417 | e6e5ad80 | bellard | |
2418 | e6e5ad80 | bellard | addr &= s->cirrus_addr_mask; |
2419 | 3b46e624 | ths | |
2420 | 5fafdf24 | ths | if (((s->sr[0x17] & 0x44) == 0x44) && |
2421 | 78e127ef | bellard | ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { |
2422 | e6e5ad80 | bellard | /* memory-mapped I/O */
|
2423 | e6e5ad80 | bellard | cirrus_mmio_blt_write(s, addr & 0xff, val);
|
2424 | e6e5ad80 | bellard | } else if (s->cirrus_srcptr != s->cirrus_srcptr_end) { |
2425 | e6e5ad80 | bellard | /* bitblt */
|
2426 | e6e5ad80 | bellard | *s->cirrus_srcptr++ = (uint8_t) val; |
2427 | a5082316 | bellard | if (s->cirrus_srcptr >= s->cirrus_srcptr_end) {
|
2428 | e6e5ad80 | bellard | cirrus_bitblt_cputovideo_next(s); |
2429 | e6e5ad80 | bellard | } |
2430 | e6e5ad80 | bellard | } else {
|
2431 | e6e5ad80 | bellard | /* video memory */
|
2432 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) == 0x14) { |
2433 | e6e5ad80 | bellard | addr <<= 4;
|
2434 | e6e5ad80 | bellard | } else if (s->gr[0x0B] & 0x02) { |
2435 | e6e5ad80 | bellard | addr <<= 3;
|
2436 | e6e5ad80 | bellard | } |
2437 | e6e5ad80 | bellard | addr &= s->cirrus_addr_mask; |
2438 | e6e5ad80 | bellard | |
2439 | e6e5ad80 | bellard | mode = s->gr[0x05] & 0x7; |
2440 | e6e5ad80 | bellard | if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) { |
2441 | e6e5ad80 | bellard | *(s->vram_ptr + addr) = (uint8_t) val; |
2442 | e6e5ad80 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + addr); |
2443 | e6e5ad80 | bellard | } else {
|
2444 | e6e5ad80 | bellard | if ((s->gr[0x0B] & 0x14) != 0x14) { |
2445 | e6e5ad80 | bellard | cirrus_mem_writeb_mode4and5_8bpp(s, mode, addr, val); |
2446 | e6e5ad80 | bellard | } else {
|
2447 | e6e5ad80 | bellard | cirrus_mem_writeb_mode4and5_16bpp(s, mode, addr, val); |
2448 | e6e5ad80 | bellard | } |
2449 | e6e5ad80 | bellard | } |
2450 | e6e5ad80 | bellard | } |
2451 | e6e5ad80 | bellard | } |
2452 | e6e5ad80 | bellard | |
2453 | e6e5ad80 | bellard | static void cirrus_linear_writew(void *opaque, target_phys_addr_t addr, |
2454 | e6e5ad80 | bellard | uint32_t val) |
2455 | e6e5ad80 | bellard | { |
2456 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2457 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr, (val >> 8) & 0xff); |
2458 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 1, val & 0xff); |
2459 | e6e5ad80 | bellard | #else
|
2460 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr, val & 0xff);
|
2461 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2462 | e6e5ad80 | bellard | #endif
|
2463 | e6e5ad80 | bellard | } |
2464 | e6e5ad80 | bellard | |
2465 | e6e5ad80 | bellard | static void cirrus_linear_writel(void *opaque, target_phys_addr_t addr, |
2466 | e6e5ad80 | bellard | uint32_t val) |
2467 | e6e5ad80 | bellard | { |
2468 | e6e5ad80 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2469 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr, (val >> 24) & 0xff); |
2470 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 1, (val >> 16) & 0xff); |
2471 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 2, (val >> 8) & 0xff); |
2472 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 3, val & 0xff); |
2473 | e6e5ad80 | bellard | #else
|
2474 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr, val & 0xff);
|
2475 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2476 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 2, (val >> 16) & 0xff); |
2477 | e6e5ad80 | bellard | cirrus_linear_writeb(opaque, addr + 3, (val >> 24) & 0xff); |
2478 | e6e5ad80 | bellard | #endif
|
2479 | e6e5ad80 | bellard | } |
2480 | e6e5ad80 | bellard | |
2481 | e6e5ad80 | bellard | |
2482 | e6e5ad80 | bellard | static CPUReadMemoryFunc *cirrus_linear_read[3] = { |
2483 | e6e5ad80 | bellard | cirrus_linear_readb, |
2484 | e6e5ad80 | bellard | cirrus_linear_readw, |
2485 | e6e5ad80 | bellard | cirrus_linear_readl, |
2486 | e6e5ad80 | bellard | }; |
2487 | e6e5ad80 | bellard | |
2488 | e6e5ad80 | bellard | static CPUWriteMemoryFunc *cirrus_linear_write[3] = { |
2489 | e6e5ad80 | bellard | cirrus_linear_writeb, |
2490 | e6e5ad80 | bellard | cirrus_linear_writew, |
2491 | e6e5ad80 | bellard | cirrus_linear_writel, |
2492 | e6e5ad80 | bellard | }; |
2493 | e6e5ad80 | bellard | |
2494 | 8926b517 | bellard | static void cirrus_linear_mem_writeb(void *opaque, target_phys_addr_t addr, |
2495 | 8926b517 | bellard | uint32_t val) |
2496 | 8926b517 | bellard | { |
2497 | 8926b517 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2498 | 8926b517 | bellard | |
2499 | 8926b517 | bellard | addr &= s->cirrus_addr_mask; |
2500 | 8926b517 | bellard | *(s->vram_ptr + addr) = val; |
2501 | 8926b517 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + addr); |
2502 | 8926b517 | bellard | } |
2503 | 8926b517 | bellard | |
2504 | 8926b517 | bellard | static void cirrus_linear_mem_writew(void *opaque, target_phys_addr_t addr, |
2505 | 8926b517 | bellard | uint32_t val) |
2506 | 8926b517 | bellard | { |
2507 | 8926b517 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2508 | 8926b517 | bellard | |
2509 | 8926b517 | bellard | addr &= s->cirrus_addr_mask; |
2510 | 8926b517 | bellard | cpu_to_le16w((uint16_t *)(s->vram_ptr + addr), val); |
2511 | 8926b517 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + addr); |
2512 | 8926b517 | bellard | } |
2513 | 8926b517 | bellard | |
2514 | 8926b517 | bellard | static void cirrus_linear_mem_writel(void *opaque, target_phys_addr_t addr, |
2515 | 8926b517 | bellard | uint32_t val) |
2516 | 8926b517 | bellard | { |
2517 | 8926b517 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2518 | 8926b517 | bellard | |
2519 | 8926b517 | bellard | addr &= s->cirrus_addr_mask; |
2520 | 8926b517 | bellard | cpu_to_le32w((uint32_t *)(s->vram_ptr + addr), val); |
2521 | 8926b517 | bellard | cpu_physical_memory_set_dirty(s->vram_offset + addr); |
2522 | 8926b517 | bellard | } |
2523 | 8926b517 | bellard | |
2524 | a5082316 | bellard | /***************************************
|
2525 | a5082316 | bellard | *
|
2526 | a5082316 | bellard | * system to screen memory access
|
2527 | a5082316 | bellard | *
|
2528 | a5082316 | bellard | ***************************************/
|
2529 | a5082316 | bellard | |
2530 | a5082316 | bellard | |
2531 | a5082316 | bellard | static uint32_t cirrus_linear_bitblt_readb(void *opaque, target_phys_addr_t addr) |
2532 | a5082316 | bellard | { |
2533 | a5082316 | bellard | uint32_t ret; |
2534 | a5082316 | bellard | |
2535 | a5082316 | bellard | /* XXX handle bitblt */
|
2536 | a5082316 | bellard | ret = 0xff;
|
2537 | a5082316 | bellard | return ret;
|
2538 | a5082316 | bellard | } |
2539 | a5082316 | bellard | |
2540 | a5082316 | bellard | static uint32_t cirrus_linear_bitblt_readw(void *opaque, target_phys_addr_t addr) |
2541 | a5082316 | bellard | { |
2542 | a5082316 | bellard | uint32_t v; |
2543 | a5082316 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2544 | a5082316 | bellard | v = cirrus_linear_bitblt_readb(opaque, addr) << 8;
|
2545 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 1);
|
2546 | a5082316 | bellard | #else
|
2547 | a5082316 | bellard | v = cirrus_linear_bitblt_readb(opaque, addr); |
2548 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 1) << 8; |
2549 | a5082316 | bellard | #endif
|
2550 | a5082316 | bellard | return v;
|
2551 | a5082316 | bellard | } |
2552 | a5082316 | bellard | |
2553 | a5082316 | bellard | static uint32_t cirrus_linear_bitblt_readl(void *opaque, target_phys_addr_t addr) |
2554 | a5082316 | bellard | { |
2555 | a5082316 | bellard | uint32_t v; |
2556 | a5082316 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2557 | a5082316 | bellard | v = cirrus_linear_bitblt_readb(opaque, addr) << 24;
|
2558 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 1) << 16; |
2559 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 2) << 8; |
2560 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 3);
|
2561 | a5082316 | bellard | #else
|
2562 | a5082316 | bellard | v = cirrus_linear_bitblt_readb(opaque, addr); |
2563 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 1) << 8; |
2564 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 2) << 16; |
2565 | a5082316 | bellard | v |= cirrus_linear_bitblt_readb(opaque, addr + 3) << 24; |
2566 | a5082316 | bellard | #endif
|
2567 | a5082316 | bellard | return v;
|
2568 | a5082316 | bellard | } |
2569 | a5082316 | bellard | |
2570 | a5082316 | bellard | static void cirrus_linear_bitblt_writeb(void *opaque, target_phys_addr_t addr, |
2571 | a5082316 | bellard | uint32_t val) |
2572 | a5082316 | bellard | { |
2573 | a5082316 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2574 | a5082316 | bellard | |
2575 | a5082316 | bellard | if (s->cirrus_srcptr != s->cirrus_srcptr_end) {
|
2576 | a5082316 | bellard | /* bitblt */
|
2577 | a5082316 | bellard | *s->cirrus_srcptr++ = (uint8_t) val; |
2578 | a5082316 | bellard | if (s->cirrus_srcptr >= s->cirrus_srcptr_end) {
|
2579 | a5082316 | bellard | cirrus_bitblt_cputovideo_next(s); |
2580 | a5082316 | bellard | } |
2581 | a5082316 | bellard | } |
2582 | a5082316 | bellard | } |
2583 | a5082316 | bellard | |
2584 | a5082316 | bellard | static void cirrus_linear_bitblt_writew(void *opaque, target_phys_addr_t addr, |
2585 | a5082316 | bellard | uint32_t val) |
2586 | a5082316 | bellard | { |
2587 | a5082316 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2588 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr, (val >> 8) & 0xff); |
2589 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 1, val & 0xff); |
2590 | a5082316 | bellard | #else
|
2591 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr, val & 0xff);
|
2592 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2593 | a5082316 | bellard | #endif
|
2594 | a5082316 | bellard | } |
2595 | a5082316 | bellard | |
2596 | a5082316 | bellard | static void cirrus_linear_bitblt_writel(void *opaque, target_phys_addr_t addr, |
2597 | a5082316 | bellard | uint32_t val) |
2598 | a5082316 | bellard | { |
2599 | a5082316 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2600 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr, (val >> 24) & 0xff); |
2601 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 1, (val >> 16) & 0xff); |
2602 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 2, (val >> 8) & 0xff); |
2603 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 3, val & 0xff); |
2604 | a5082316 | bellard | #else
|
2605 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr, val & 0xff);
|
2606 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
2607 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 2, (val >> 16) & 0xff); |
2608 | a5082316 | bellard | cirrus_linear_bitblt_writeb(opaque, addr + 3, (val >> 24) & 0xff); |
2609 | a5082316 | bellard | #endif
|
2610 | a5082316 | bellard | } |
2611 | a5082316 | bellard | |
2612 | a5082316 | bellard | |
2613 | a5082316 | bellard | static CPUReadMemoryFunc *cirrus_linear_bitblt_read[3] = { |
2614 | a5082316 | bellard | cirrus_linear_bitblt_readb, |
2615 | a5082316 | bellard | cirrus_linear_bitblt_readw, |
2616 | a5082316 | bellard | cirrus_linear_bitblt_readl, |
2617 | a5082316 | bellard | }; |
2618 | a5082316 | bellard | |
2619 | a5082316 | bellard | static CPUWriteMemoryFunc *cirrus_linear_bitblt_write[3] = { |
2620 | a5082316 | bellard | cirrus_linear_bitblt_writeb, |
2621 | a5082316 | bellard | cirrus_linear_bitblt_writew, |
2622 | a5082316 | bellard | cirrus_linear_bitblt_writel, |
2623 | a5082316 | bellard | }; |
2624 | a5082316 | bellard | |
2625 | 2bec46dc | aliguori | static void map_linear_vram(CirrusVGAState *s) |
2626 | 2bec46dc | aliguori | { |
2627 | ba7349cd | aliguori | vga_dirty_log_stop((VGAState *)s); |
2628 | 2bec46dc | aliguori | |
2629 | 2bec46dc | aliguori | if (!s->map_addr && s->lfb_addr && s->lfb_end) {
|
2630 | 2bec46dc | aliguori | s->map_addr = s->lfb_addr; |
2631 | 2bec46dc | aliguori | s->map_end = s->lfb_end; |
2632 | 2bec46dc | aliguori | cpu_register_physical_memory(s->map_addr, s->map_end - s->map_addr, s->vram_offset); |
2633 | 2bec46dc | aliguori | } |
2634 | 2bec46dc | aliguori | |
2635 | 2bec46dc | aliguori | if (!s->map_addr)
|
2636 | 2bec46dc | aliguori | return;
|
2637 | 2bec46dc | aliguori | |
2638 | 2bec46dc | aliguori | s->lfb_vram_mapped = 0;
|
2639 | 2bec46dc | aliguori | |
2640 | 2bec46dc | aliguori | if (!(s->cirrus_srcptr != s->cirrus_srcptr_end)
|
2641 | 2bec46dc | aliguori | && !((s->sr[0x07] & 0x01) == 0) |
2642 | 2bec46dc | aliguori | && !((s->gr[0x0B] & 0x14) == 0x14) |
2643 | 2bec46dc | aliguori | && !(s->gr[0x0B] & 0x02)) { |
2644 | 2bec46dc | aliguori | |
2645 | 2bec46dc | aliguori | cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x8000, |
2646 | 2bec46dc | aliguori | (s->vram_offset + s->cirrus_bank_base[0]) | IO_MEM_RAM);
|
2647 | 2bec46dc | aliguori | cpu_register_physical_memory(isa_mem_base + 0xa8000, 0x8000, |
2648 | 2bec46dc | aliguori | (s->vram_offset + s->cirrus_bank_base[1]) | IO_MEM_RAM);
|
2649 | 2bec46dc | aliguori | |
2650 | 2bec46dc | aliguori | s->lfb_vram_mapped = 1;
|
2651 | 2bec46dc | aliguori | } |
2652 | 2bec46dc | aliguori | else {
|
2653 | 7cff316e | aliguori | cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000, |
2654 | 7cff316e | aliguori | s->vga_io_memory); |
2655 | 2bec46dc | aliguori | } |
2656 | 2bec46dc | aliguori | |
2657 | ba7349cd | aliguori | vga_dirty_log_start((VGAState *)s); |
2658 | 2bec46dc | aliguori | } |
2659 | 2bec46dc | aliguori | |
2660 | 2bec46dc | aliguori | static void unmap_linear_vram(CirrusVGAState *s) |
2661 | 2bec46dc | aliguori | { |
2662 | ba7349cd | aliguori | vga_dirty_log_stop((VGAState *)s); |
2663 | ba7349cd | aliguori | |
2664 | ba7349cd | aliguori | if (s->map_addr && s->lfb_addr && s->lfb_end)
|
2665 | 2bec46dc | aliguori | s->map_addr = s->map_end = 0;
|
2666 | 2bec46dc | aliguori | |
2667 | 2bec46dc | aliguori | cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000, |
2668 | 2bec46dc | aliguori | s->vga_io_memory); |
2669 | ba7349cd | aliguori | |
2670 | ba7349cd | aliguori | vga_dirty_log_start((VGAState *)s); |
2671 | 2bec46dc | aliguori | } |
2672 | 2bec46dc | aliguori | |
2673 | 8926b517 | bellard | /* Compute the memory access functions */
|
2674 | 8926b517 | bellard | static void cirrus_update_memory_access(CirrusVGAState *s) |
2675 | 8926b517 | bellard | { |
2676 | 8926b517 | bellard | unsigned mode;
|
2677 | 8926b517 | bellard | |
2678 | 8926b517 | bellard | if ((s->sr[0x17] & 0x44) == 0x44) { |
2679 | 8926b517 | bellard | goto generic_io;
|
2680 | 8926b517 | bellard | } else if (s->cirrus_srcptr != s->cirrus_srcptr_end) { |
2681 | 8926b517 | bellard | goto generic_io;
|
2682 | 8926b517 | bellard | } else {
|
2683 | 8926b517 | bellard | if ((s->gr[0x0B] & 0x14) == 0x14) { |
2684 | 8926b517 | bellard | goto generic_io;
|
2685 | 8926b517 | bellard | } else if (s->gr[0x0B] & 0x02) { |
2686 | 8926b517 | bellard | goto generic_io;
|
2687 | 8926b517 | bellard | } |
2688 | 3b46e624 | ths | |
2689 | 8926b517 | bellard | mode = s->gr[0x05] & 0x7; |
2690 | 8926b517 | bellard | if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) { |
2691 | 2bec46dc | aliguori | map_linear_vram(s); |
2692 | 8926b517 | bellard | s->cirrus_linear_write[0] = cirrus_linear_mem_writeb;
|
2693 | 8926b517 | bellard | s->cirrus_linear_write[1] = cirrus_linear_mem_writew;
|
2694 | 8926b517 | bellard | s->cirrus_linear_write[2] = cirrus_linear_mem_writel;
|
2695 | 8926b517 | bellard | } else {
|
2696 | 8926b517 | bellard | generic_io:
|
2697 | 2bec46dc | aliguori | unmap_linear_vram(s); |
2698 | 8926b517 | bellard | s->cirrus_linear_write[0] = cirrus_linear_writeb;
|
2699 | 8926b517 | bellard | s->cirrus_linear_write[1] = cirrus_linear_writew;
|
2700 | 8926b517 | bellard | s->cirrus_linear_write[2] = cirrus_linear_writel;
|
2701 | 8926b517 | bellard | } |
2702 | 8926b517 | bellard | } |
2703 | 8926b517 | bellard | } |
2704 | 8926b517 | bellard | |
2705 | 8926b517 | bellard | |
2706 | e6e5ad80 | bellard | /* I/O ports */
|
2707 | e6e5ad80 | bellard | |
2708 | e6e5ad80 | bellard | static uint32_t vga_ioport_read(void *opaque, uint32_t addr) |
2709 | e6e5ad80 | bellard | { |
2710 | e6e5ad80 | bellard | CirrusVGAState *s = opaque; |
2711 | e6e5ad80 | bellard | int val, index;
|
2712 | e6e5ad80 | bellard | |
2713 | e6e5ad80 | bellard | /* check port range access depending on color/monochrome mode */
|
2714 | e6e5ad80 | bellard | if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) |
2715 | e6e5ad80 | bellard | || (addr >= 0x3d0 && addr <= 0x3df |
2716 | e6e5ad80 | bellard | && !(s->msr & MSR_COLOR_EMULATION))) { |
2717 | e6e5ad80 | bellard | val = 0xff;
|
2718 | e6e5ad80 | bellard | } else {
|
2719 | e6e5ad80 | bellard | switch (addr) {
|
2720 | e6e5ad80 | bellard | case 0x3c0: |
2721 | e6e5ad80 | bellard | if (s->ar_flip_flop == 0) { |
2722 | e6e5ad80 | bellard | val = s->ar_index; |
2723 | e6e5ad80 | bellard | } else {
|
2724 | e6e5ad80 | bellard | val = 0;
|
2725 | e6e5ad80 | bellard | } |
2726 | e6e5ad80 | bellard | break;
|
2727 | e6e5ad80 | bellard | case 0x3c1: |
2728 | e6e5ad80 | bellard | index = s->ar_index & 0x1f;
|
2729 | e6e5ad80 | bellard | if (index < 21) |
2730 | e6e5ad80 | bellard | val = s->ar[index]; |
2731 | e6e5ad80 | bellard | else
|
2732 | e6e5ad80 | bellard | val = 0;
|
2733 | e6e5ad80 | bellard | break;
|
2734 | e6e5ad80 | bellard | case 0x3c2: |
2735 | e6e5ad80 | bellard | val = s->st00; |
2736 | e6e5ad80 | bellard | break;
|
2737 | e6e5ad80 | bellard | case 0x3c4: |
2738 | e6e5ad80 | bellard | val = s->sr_index; |
2739 | e6e5ad80 | bellard | break;
|
2740 | e6e5ad80 | bellard | case 0x3c5: |
2741 | e6e5ad80 | bellard | if (cirrus_hook_read_sr(s, s->sr_index, &val))
|
2742 | e6e5ad80 | bellard | break;
|
2743 | e6e5ad80 | bellard | val = s->sr[s->sr_index]; |
2744 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2745 | e6e5ad80 | bellard | printf("vga: read SR%x = 0x%02x\n", s->sr_index, val);
|
2746 | e6e5ad80 | bellard | #endif
|
2747 | e6e5ad80 | bellard | break;
|
2748 | e6e5ad80 | bellard | case 0x3c6: |
2749 | e6e5ad80 | bellard | cirrus_read_hidden_dac(s, &val); |
2750 | e6e5ad80 | bellard | break;
|
2751 | e6e5ad80 | bellard | case 0x3c7: |
2752 | e6e5ad80 | bellard | val = s->dac_state; |
2753 | e6e5ad80 | bellard | break;
|
2754 | ae184e4a | bellard | case 0x3c8: |
2755 | ae184e4a | bellard | val = s->dac_write_index; |
2756 | ae184e4a | bellard | s->cirrus_hidden_dac_lockindex = 0;
|
2757 | ae184e4a | bellard | break;
|
2758 | ae184e4a | bellard | case 0x3c9: |
2759 | e6e5ad80 | bellard | if (cirrus_hook_read_palette(s, &val))
|
2760 | e6e5ad80 | bellard | break;
|
2761 | e6e5ad80 | bellard | val = s->palette[s->dac_read_index * 3 + s->dac_sub_index];
|
2762 | e6e5ad80 | bellard | if (++s->dac_sub_index == 3) { |
2763 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
2764 | e6e5ad80 | bellard | s->dac_read_index++; |
2765 | e6e5ad80 | bellard | } |
2766 | e6e5ad80 | bellard | break;
|
2767 | e6e5ad80 | bellard | case 0x3ca: |
2768 | e6e5ad80 | bellard | val = s->fcr; |
2769 | e6e5ad80 | bellard | break;
|
2770 | e6e5ad80 | bellard | case 0x3cc: |
2771 | e6e5ad80 | bellard | val = s->msr; |
2772 | e6e5ad80 | bellard | break;
|
2773 | e6e5ad80 | bellard | case 0x3ce: |
2774 | e6e5ad80 | bellard | val = s->gr_index; |
2775 | e6e5ad80 | bellard | break;
|
2776 | e6e5ad80 | bellard | case 0x3cf: |
2777 | e6e5ad80 | bellard | if (cirrus_hook_read_gr(s, s->gr_index, &val))
|
2778 | e6e5ad80 | bellard | break;
|
2779 | e6e5ad80 | bellard | val = s->gr[s->gr_index]; |
2780 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2781 | e6e5ad80 | bellard | printf("vga: read GR%x = 0x%02x\n", s->gr_index, val);
|
2782 | e6e5ad80 | bellard | #endif
|
2783 | e6e5ad80 | bellard | break;
|
2784 | e6e5ad80 | bellard | case 0x3b4: |
2785 | e6e5ad80 | bellard | case 0x3d4: |
2786 | e6e5ad80 | bellard | val = s->cr_index; |
2787 | e6e5ad80 | bellard | break;
|
2788 | e6e5ad80 | bellard | case 0x3b5: |
2789 | e6e5ad80 | bellard | case 0x3d5: |
2790 | e6e5ad80 | bellard | if (cirrus_hook_read_cr(s, s->cr_index, &val))
|
2791 | e6e5ad80 | bellard | break;
|
2792 | e6e5ad80 | bellard | val = s->cr[s->cr_index]; |
2793 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2794 | e6e5ad80 | bellard | printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
|
2795 | e6e5ad80 | bellard | #endif
|
2796 | e6e5ad80 | bellard | break;
|
2797 | e6e5ad80 | bellard | case 0x3ba: |
2798 | e6e5ad80 | bellard | case 0x3da: |
2799 | e6e5ad80 | bellard | /* just toggle to fool polling */
|
2800 | cb5a7aa8 | malc | val = s->st01 = s->retrace((VGAState *) s); |
2801 | e6e5ad80 | bellard | s->ar_flip_flop = 0;
|
2802 | e6e5ad80 | bellard | break;
|
2803 | e6e5ad80 | bellard | default:
|
2804 | e6e5ad80 | bellard | val = 0x00;
|
2805 | e6e5ad80 | bellard | break;
|
2806 | e6e5ad80 | bellard | } |
2807 | e6e5ad80 | bellard | } |
2808 | e6e5ad80 | bellard | #if defined(DEBUG_VGA)
|
2809 | e6e5ad80 | bellard | printf("VGA: read addr=0x%04x data=0x%02x\n", addr, val);
|
2810 | e6e5ad80 | bellard | #endif
|
2811 | e6e5ad80 | bellard | return val;
|
2812 | e6e5ad80 | bellard | } |
2813 | e6e5ad80 | bellard | |
2814 | e6e5ad80 | bellard | static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
2815 | e6e5ad80 | bellard | { |
2816 | e6e5ad80 | bellard | CirrusVGAState *s = opaque; |
2817 | e6e5ad80 | bellard | int index;
|
2818 | e6e5ad80 | bellard | |
2819 | e6e5ad80 | bellard | /* check port range access depending on color/monochrome mode */
|
2820 | e6e5ad80 | bellard | if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) |
2821 | e6e5ad80 | bellard | || (addr >= 0x3d0 && addr <= 0x3df |
2822 | e6e5ad80 | bellard | && !(s->msr & MSR_COLOR_EMULATION))) |
2823 | e6e5ad80 | bellard | return;
|
2824 | e6e5ad80 | bellard | |
2825 | e6e5ad80 | bellard | #ifdef DEBUG_VGA
|
2826 | e6e5ad80 | bellard | printf("VGA: write addr=0x%04x data=0x%02x\n", addr, val);
|
2827 | e6e5ad80 | bellard | #endif
|
2828 | e6e5ad80 | bellard | |
2829 | e6e5ad80 | bellard | switch (addr) {
|
2830 | e6e5ad80 | bellard | case 0x3c0: |
2831 | e6e5ad80 | bellard | if (s->ar_flip_flop == 0) { |
2832 | e6e5ad80 | bellard | val &= 0x3f;
|
2833 | e6e5ad80 | bellard | s->ar_index = val; |
2834 | e6e5ad80 | bellard | } else {
|
2835 | e6e5ad80 | bellard | index = s->ar_index & 0x1f;
|
2836 | e6e5ad80 | bellard | switch (index) {
|
2837 | e6e5ad80 | bellard | case 0x00 ... 0x0f: |
2838 | e6e5ad80 | bellard | s->ar[index] = val & 0x3f;
|
2839 | e6e5ad80 | bellard | break;
|
2840 | e6e5ad80 | bellard | case 0x10: |
2841 | e6e5ad80 | bellard | s->ar[index] = val & ~0x10;
|
2842 | e6e5ad80 | bellard | break;
|
2843 | e6e5ad80 | bellard | case 0x11: |
2844 | e6e5ad80 | bellard | s->ar[index] = val; |
2845 | e6e5ad80 | bellard | break;
|
2846 | e6e5ad80 | bellard | case 0x12: |
2847 | e6e5ad80 | bellard | s->ar[index] = val & ~0xc0;
|
2848 | e6e5ad80 | bellard | break;
|
2849 | e6e5ad80 | bellard | case 0x13: |
2850 | e6e5ad80 | bellard | s->ar[index] = val & ~0xf0;
|
2851 | e6e5ad80 | bellard | break;
|
2852 | e6e5ad80 | bellard | case 0x14: |
2853 | e6e5ad80 | bellard | s->ar[index] = val & ~0xf0;
|
2854 | e6e5ad80 | bellard | break;
|
2855 | e6e5ad80 | bellard | default:
|
2856 | e6e5ad80 | bellard | break;
|
2857 | e6e5ad80 | bellard | } |
2858 | e6e5ad80 | bellard | } |
2859 | e6e5ad80 | bellard | s->ar_flip_flop ^= 1;
|
2860 | e6e5ad80 | bellard | break;
|
2861 | e6e5ad80 | bellard | case 0x3c2: |
2862 | e6e5ad80 | bellard | s->msr = val & ~0x10;
|
2863 | cb5a7aa8 | malc | s->update_retrace_info((VGAState *) s); |
2864 | e6e5ad80 | bellard | break;
|
2865 | e6e5ad80 | bellard | case 0x3c4: |
2866 | e6e5ad80 | bellard | s->sr_index = val; |
2867 | e6e5ad80 | bellard | break;
|
2868 | e6e5ad80 | bellard | case 0x3c5: |
2869 | e6e5ad80 | bellard | if (cirrus_hook_write_sr(s, s->sr_index, val))
|
2870 | e6e5ad80 | bellard | break;
|
2871 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2872 | e6e5ad80 | bellard | printf("vga: write SR%x = 0x%02x\n", s->sr_index, val);
|
2873 | e6e5ad80 | bellard | #endif
|
2874 | e6e5ad80 | bellard | s->sr[s->sr_index] = val & sr_mask[s->sr_index]; |
2875 | cb5a7aa8 | malc | if (s->sr_index == 1) s->update_retrace_info((VGAState *) s); |
2876 | e6e5ad80 | bellard | break;
|
2877 | e6e5ad80 | bellard | case 0x3c6: |
2878 | e6e5ad80 | bellard | cirrus_write_hidden_dac(s, val); |
2879 | e6e5ad80 | bellard | break;
|
2880 | e6e5ad80 | bellard | case 0x3c7: |
2881 | e6e5ad80 | bellard | s->dac_read_index = val; |
2882 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
2883 | e6e5ad80 | bellard | s->dac_state = 3;
|
2884 | e6e5ad80 | bellard | break;
|
2885 | e6e5ad80 | bellard | case 0x3c8: |
2886 | e6e5ad80 | bellard | s->dac_write_index = val; |
2887 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
2888 | e6e5ad80 | bellard | s->dac_state = 0;
|
2889 | e6e5ad80 | bellard | break;
|
2890 | e6e5ad80 | bellard | case 0x3c9: |
2891 | e6e5ad80 | bellard | if (cirrus_hook_write_palette(s, val))
|
2892 | e6e5ad80 | bellard | break;
|
2893 | e6e5ad80 | bellard | s->dac_cache[s->dac_sub_index] = val; |
2894 | e6e5ad80 | bellard | if (++s->dac_sub_index == 3) { |
2895 | e6e5ad80 | bellard | memcpy(&s->palette[s->dac_write_index * 3], s->dac_cache, 3); |
2896 | e6e5ad80 | bellard | s->dac_sub_index = 0;
|
2897 | e6e5ad80 | bellard | s->dac_write_index++; |
2898 | e6e5ad80 | bellard | } |
2899 | e6e5ad80 | bellard | break;
|
2900 | e6e5ad80 | bellard | case 0x3ce: |
2901 | e6e5ad80 | bellard | s->gr_index = val; |
2902 | e6e5ad80 | bellard | break;
|
2903 | e6e5ad80 | bellard | case 0x3cf: |
2904 | e6e5ad80 | bellard | if (cirrus_hook_write_gr(s, s->gr_index, val))
|
2905 | e6e5ad80 | bellard | break;
|
2906 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2907 | e6e5ad80 | bellard | printf("vga: write GR%x = 0x%02x\n", s->gr_index, val);
|
2908 | e6e5ad80 | bellard | #endif
|
2909 | e6e5ad80 | bellard | s->gr[s->gr_index] = val & gr_mask[s->gr_index]; |
2910 | e6e5ad80 | bellard | break;
|
2911 | e6e5ad80 | bellard | case 0x3b4: |
2912 | e6e5ad80 | bellard | case 0x3d4: |
2913 | e6e5ad80 | bellard | s->cr_index = val; |
2914 | e6e5ad80 | bellard | break;
|
2915 | e6e5ad80 | bellard | case 0x3b5: |
2916 | e6e5ad80 | bellard | case 0x3d5: |
2917 | e6e5ad80 | bellard | if (cirrus_hook_write_cr(s, s->cr_index, val))
|
2918 | e6e5ad80 | bellard | break;
|
2919 | e6e5ad80 | bellard | #ifdef DEBUG_VGA_REG
|
2920 | e6e5ad80 | bellard | printf("vga: write CR%x = 0x%02x\n", s->cr_index, val);
|
2921 | e6e5ad80 | bellard | #endif
|
2922 | e6e5ad80 | bellard | /* handle CR0-7 protection */
|
2923 | 9bb34eac | bellard | if ((s->cr[0x11] & 0x80) && s->cr_index <= 7) { |
2924 | e6e5ad80 | bellard | /* can always write bit 4 of CR7 */
|
2925 | e6e5ad80 | bellard | if (s->cr_index == 7) |
2926 | e6e5ad80 | bellard | s->cr[7] = (s->cr[7] & ~0x10) | (val & 0x10); |
2927 | e6e5ad80 | bellard | return;
|
2928 | e6e5ad80 | bellard | } |
2929 | e6e5ad80 | bellard | switch (s->cr_index) {
|
2930 | e6e5ad80 | bellard | case 0x01: /* horizontal display end */ |
2931 | e6e5ad80 | bellard | case 0x07: |
2932 | e6e5ad80 | bellard | case 0x09: |
2933 | e6e5ad80 | bellard | case 0x0c: |
2934 | e6e5ad80 | bellard | case 0x0d: |
2935 | e91c8a77 | ths | case 0x12: /* vertical display end */ |
2936 | e6e5ad80 | bellard | s->cr[s->cr_index] = val; |
2937 | e6e5ad80 | bellard | break;
|
2938 | e6e5ad80 | bellard | |
2939 | e6e5ad80 | bellard | default:
|
2940 | e6e5ad80 | bellard | s->cr[s->cr_index] = val; |
2941 | e6e5ad80 | bellard | break;
|
2942 | e6e5ad80 | bellard | } |
2943 | cb5a7aa8 | malc | |
2944 | cb5a7aa8 | malc | switch(s->cr_index) {
|
2945 | cb5a7aa8 | malc | case 0x00: |
2946 | cb5a7aa8 | malc | case 0x04: |
2947 | cb5a7aa8 | malc | case 0x05: |
2948 | cb5a7aa8 | malc | case 0x06: |
2949 | cb5a7aa8 | malc | case 0x07: |
2950 | cb5a7aa8 | malc | case 0x11: |
2951 | cb5a7aa8 | malc | case 0x17: |
2952 | cb5a7aa8 | malc | s->update_retrace_info((VGAState *) s); |
2953 | cb5a7aa8 | malc | break;
|
2954 | cb5a7aa8 | malc | } |
2955 | e6e5ad80 | bellard | break;
|
2956 | e6e5ad80 | bellard | case 0x3ba: |
2957 | e6e5ad80 | bellard | case 0x3da: |
2958 | e6e5ad80 | bellard | s->fcr = val & 0x10;
|
2959 | e6e5ad80 | bellard | break;
|
2960 | e6e5ad80 | bellard | } |
2961 | e6e5ad80 | bellard | } |
2962 | e6e5ad80 | bellard | |
2963 | e6e5ad80 | bellard | /***************************************
|
2964 | e6e5ad80 | bellard | *
|
2965 | e36f36e1 | bellard | * memory-mapped I/O access
|
2966 | e36f36e1 | bellard | *
|
2967 | e36f36e1 | bellard | ***************************************/
|
2968 | e36f36e1 | bellard | |
2969 | e36f36e1 | bellard | static uint32_t cirrus_mmio_readb(void *opaque, target_phys_addr_t addr) |
2970 | e36f36e1 | bellard | { |
2971 | e36f36e1 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
2972 | e36f36e1 | bellard | |
2973 | e36f36e1 | bellard | addr &= CIRRUS_PNPMMIO_SIZE - 1;
|
2974 | e36f36e1 | bellard | |
2975 | e36f36e1 | bellard | if (addr >= 0x100) { |
2976 | e36f36e1 | bellard | return cirrus_mmio_blt_read(s, addr - 0x100); |
2977 | e36f36e1 | bellard | } else {
|
2978 | e36f36e1 | bellard | return vga_ioport_read(s, addr + 0x3c0); |
2979 | e36f36e1 | bellard | } |
2980 | e36f36e1 | bellard | } |
2981 | e36f36e1 | bellard | |
2982 | e36f36e1 | bellard | static uint32_t cirrus_mmio_readw(void *opaque, target_phys_addr_t addr) |
2983 | e36f36e1 | bellard | { |
2984 | e36f36e1 | bellard | uint32_t v; |
2985 | e36f36e1 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2986 | e36f36e1 | bellard | v = cirrus_mmio_readb(opaque, addr) << 8;
|
2987 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 1);
|
2988 | e36f36e1 | bellard | #else
|
2989 | e36f36e1 | bellard | v = cirrus_mmio_readb(opaque, addr); |
2990 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 1) << 8; |
2991 | e36f36e1 | bellard | #endif
|
2992 | e36f36e1 | bellard | return v;
|
2993 | e36f36e1 | bellard | } |
2994 | e36f36e1 | bellard | |
2995 | e36f36e1 | bellard | static uint32_t cirrus_mmio_readl(void *opaque, target_phys_addr_t addr) |
2996 | e36f36e1 | bellard | { |
2997 | e36f36e1 | bellard | uint32_t v; |
2998 | e36f36e1 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
2999 | e36f36e1 | bellard | v = cirrus_mmio_readb(opaque, addr) << 24;
|
3000 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 1) << 16; |
3001 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 2) << 8; |
3002 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 3);
|
3003 | e36f36e1 | bellard | #else
|
3004 | e36f36e1 | bellard | v = cirrus_mmio_readb(opaque, addr); |
3005 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 1) << 8; |
3006 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 2) << 16; |
3007 | e36f36e1 | bellard | v |= cirrus_mmio_readb(opaque, addr + 3) << 24; |
3008 | e36f36e1 | bellard | #endif
|
3009 | e36f36e1 | bellard | return v;
|
3010 | e36f36e1 | bellard | } |
3011 | e36f36e1 | bellard | |
3012 | e36f36e1 | bellard | static void cirrus_mmio_writeb(void *opaque, target_phys_addr_t addr, |
3013 | e36f36e1 | bellard | uint32_t val) |
3014 | e36f36e1 | bellard | { |
3015 | e36f36e1 | bellard | CirrusVGAState *s = (CirrusVGAState *) opaque; |
3016 | e36f36e1 | bellard | |
3017 | e36f36e1 | bellard | addr &= CIRRUS_PNPMMIO_SIZE - 1;
|
3018 | e36f36e1 | bellard | |
3019 | e36f36e1 | bellard | if (addr >= 0x100) { |
3020 | e36f36e1 | bellard | cirrus_mmio_blt_write(s, addr - 0x100, val);
|
3021 | e36f36e1 | bellard | } else {
|
3022 | e36f36e1 | bellard | vga_ioport_write(s, addr + 0x3c0, val);
|
3023 | e36f36e1 | bellard | } |
3024 | e36f36e1 | bellard | } |
3025 | e36f36e1 | bellard | |
3026 | e36f36e1 | bellard | static void cirrus_mmio_writew(void *opaque, target_phys_addr_t addr, |
3027 | e36f36e1 | bellard | uint32_t val) |
3028 | e36f36e1 | bellard | { |
3029 | e36f36e1 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
3030 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr, (val >> 8) & 0xff); |
3031 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 1, val & 0xff); |
3032 | e36f36e1 | bellard | #else
|
3033 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr, val & 0xff);
|
3034 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
3035 | e36f36e1 | bellard | #endif
|
3036 | e36f36e1 | bellard | } |
3037 | e36f36e1 | bellard | |
3038 | e36f36e1 | bellard | static void cirrus_mmio_writel(void *opaque, target_phys_addr_t addr, |
3039 | e36f36e1 | bellard | uint32_t val) |
3040 | e36f36e1 | bellard | { |
3041 | e36f36e1 | bellard | #ifdef TARGET_WORDS_BIGENDIAN
|
3042 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr, (val >> 24) & 0xff); |
3043 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 1, (val >> 16) & 0xff); |
3044 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 2, (val >> 8) & 0xff); |
3045 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 3, val & 0xff); |
3046 | e36f36e1 | bellard | #else
|
3047 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr, val & 0xff);
|
3048 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 1, (val >> 8) & 0xff); |
3049 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 2, (val >> 16) & 0xff); |
3050 | e36f36e1 | bellard | cirrus_mmio_writeb(opaque, addr + 3, (val >> 24) & 0xff); |
3051 | e36f36e1 | bellard | #endif
|
3052 | e36f36e1 | bellard | } |
3053 | e36f36e1 | bellard | |
3054 | e36f36e1 | bellard | |
3055 | e36f36e1 | bellard | static CPUReadMemoryFunc *cirrus_mmio_read[3] = { |
3056 | e36f36e1 | bellard | cirrus_mmio_readb, |
3057 | e36f36e1 | bellard | cirrus_mmio_readw, |
3058 | e36f36e1 | bellard | cirrus_mmio_readl, |
3059 | e36f36e1 | bellard | }; |
3060 | e36f36e1 | bellard | |
3061 | e36f36e1 | bellard | static CPUWriteMemoryFunc *cirrus_mmio_write[3] = { |
3062 | e36f36e1 | bellard | cirrus_mmio_writeb, |
3063 | e36f36e1 | bellard | cirrus_mmio_writew, |
3064 | e36f36e1 | bellard | cirrus_mmio_writel, |
3065 | e36f36e1 | bellard | }; |
3066 | e36f36e1 | bellard | |
3067 | 2c6ab832 | bellard | /* load/save state */
|
3068 | 2c6ab832 | bellard | |
3069 | 2c6ab832 | bellard | static void cirrus_vga_save(QEMUFile *f, void *opaque) |
3070 | 2c6ab832 | bellard | { |
3071 | 2c6ab832 | bellard | CirrusVGAState *s = opaque; |
3072 | 2c6ab832 | bellard | |
3073 | d2269f6f | bellard | if (s->pci_dev)
|
3074 | d2269f6f | bellard | pci_device_save(s->pci_dev, f); |
3075 | d2269f6f | bellard | |
3076 | 2c6ab832 | bellard | qemu_put_be32s(f, &s->latch); |
3077 | 2c6ab832 | bellard | qemu_put_8s(f, &s->sr_index); |
3078 | 2c6ab832 | bellard | qemu_put_buffer(f, s->sr, 256);
|
3079 | 2c6ab832 | bellard | qemu_put_8s(f, &s->gr_index); |
3080 | 2c6ab832 | bellard | qemu_put_8s(f, &s->cirrus_shadow_gr0); |
3081 | 2c6ab832 | bellard | qemu_put_8s(f, &s->cirrus_shadow_gr1); |
3082 | 2c6ab832 | bellard | qemu_put_buffer(f, s->gr + 2, 254); |
3083 | 2c6ab832 | bellard | qemu_put_8s(f, &s->ar_index); |
3084 | 2c6ab832 | bellard | qemu_put_buffer(f, s->ar, 21);
|
3085 | bee8d684 | ths | qemu_put_be32(f, s->ar_flip_flop); |
3086 | 2c6ab832 | bellard | qemu_put_8s(f, &s->cr_index); |
3087 | 2c6ab832 | bellard | qemu_put_buffer(f, s->cr, 256);
|
3088 | 2c6ab832 | bellard | qemu_put_8s(f, &s->msr); |
3089 | 2c6ab832 | bellard | qemu_put_8s(f, &s->fcr); |
3090 | 2c6ab832 | bellard | qemu_put_8s(f, &s->st00); |
3091 | 2c6ab832 | bellard | qemu_put_8s(f, &s->st01); |
3092 | 2c6ab832 | bellard | |
3093 | 2c6ab832 | bellard | qemu_put_8s(f, &s->dac_state); |
3094 | 2c6ab832 | bellard | qemu_put_8s(f, &s->dac_sub_index); |
3095 | 2c6ab832 | bellard | qemu_put_8s(f, &s->dac_read_index); |
3096 | 2c6ab832 | bellard | qemu_put_8s(f, &s->dac_write_index); |
3097 | 2c6ab832 | bellard | qemu_put_buffer(f, s->dac_cache, 3);
|
3098 | 2c6ab832 | bellard | qemu_put_buffer(f, s->palette, 768);
|
3099 | 2c6ab832 | bellard | |
3100 | bee8d684 | ths | qemu_put_be32(f, s->bank_offset); |
3101 | 2c6ab832 | bellard | |
3102 | 2c6ab832 | bellard | qemu_put_8s(f, &s->cirrus_hidden_dac_lockindex); |
3103 | 2c6ab832 | bellard | qemu_put_8s(f, &s->cirrus_hidden_dac_data); |
3104 | 2c6ab832 | bellard | |
3105 | 2c6ab832 | bellard | qemu_put_be32s(f, &s->hw_cursor_x); |
3106 | 2c6ab832 | bellard | qemu_put_be32s(f, &s->hw_cursor_y); |
3107 | 2c6ab832 | bellard | /* XXX: we do not save the bitblt state - we assume we do not save
|
3108 | 2c6ab832 | bellard | the state when the blitter is active */
|
3109 | 2c6ab832 | bellard | } |
3110 | 2c6ab832 | bellard | |
3111 | 2c6ab832 | bellard | static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id) |
3112 | 2c6ab832 | bellard | { |
3113 | 2c6ab832 | bellard | CirrusVGAState *s = opaque; |
3114 | d2269f6f | bellard | int ret;
|
3115 | 2c6ab832 | bellard | |
3116 | d2269f6f | bellard | if (version_id > 2) |
3117 | 2c6ab832 | bellard | return -EINVAL;
|
3118 | 2c6ab832 | bellard | |
3119 | d2269f6f | bellard | if (s->pci_dev && version_id >= 2) { |
3120 | d2269f6f | bellard | ret = pci_device_load(s->pci_dev, f); |
3121 | d2269f6f | bellard | if (ret < 0) |
3122 | d2269f6f | bellard | return ret;
|
3123 | d2269f6f | bellard | } |
3124 | d2269f6f | bellard | |
3125 | 2c6ab832 | bellard | qemu_get_be32s(f, &s->latch); |
3126 | 2c6ab832 | bellard | qemu_get_8s(f, &s->sr_index); |
3127 | 2c6ab832 | bellard | qemu_get_buffer(f, s->sr, 256);
|
3128 | 2c6ab832 | bellard | qemu_get_8s(f, &s->gr_index); |
3129 | 2c6ab832 | bellard | qemu_get_8s(f, &s->cirrus_shadow_gr0); |
3130 | 2c6ab832 | bellard | qemu_get_8s(f, &s->cirrus_shadow_gr1); |
3131 | 2c6ab832 | bellard | s->gr[0x00] = s->cirrus_shadow_gr0 & 0x0f; |
3132 | 2c6ab832 | bellard | s->gr[0x01] = s->cirrus_shadow_gr1 & 0x0f; |
3133 | 2c6ab832 | bellard | qemu_get_buffer(f, s->gr + 2, 254); |
3134 | 2c6ab832 | bellard | qemu_get_8s(f, &s->ar_index); |
3135 | 2c6ab832 | bellard | qemu_get_buffer(f, s->ar, 21);
|
3136 | bee8d684 | ths | s->ar_flip_flop=qemu_get_be32(f); |
3137 | 2c6ab832 | bellard | qemu_get_8s(f, &s->cr_index); |
3138 | 2c6ab832 | bellard | qemu_get_buffer(f, s->cr, 256);
|
3139 | 2c6ab832 | bellard | qemu_get_8s(f, &s->msr); |
3140 | 2c6ab832 | bellard | qemu_get_8s(f, &s->fcr); |
3141 | 2c6ab832 | bellard | qemu_get_8s(f, &s->st00); |
3142 | 2c6ab832 | bellard | qemu_get_8s(f, &s->st01); |
3143 | 2c6ab832 | bellard | |
3144 | 2c6ab832 | bellard | qemu_get_8s(f, &s->dac_state); |
3145 | 2c6ab832 | bellard | qemu_get_8s(f, &s->dac_sub_index); |
3146 | 2c6ab832 | bellard | qemu_get_8s(f, &s->dac_read_index); |
3147 | 2c6ab832 | bellard | qemu_get_8s(f, &s->dac_write_index); |
3148 | 2c6ab832 | bellard | qemu_get_buffer(f, s->dac_cache, 3);
|
3149 | 2c6ab832 | bellard | qemu_get_buffer(f, s->palette, 768);
|
3150 | 2c6ab832 | bellard | |
3151 | bee8d684 | ths | s->bank_offset=qemu_get_be32(f); |
3152 | 2c6ab832 | bellard | |
3153 | 2c6ab832 | bellard | qemu_get_8s(f, &s->cirrus_hidden_dac_lockindex); |
3154 | 2c6ab832 | bellard | qemu_get_8s(f, &s->cirrus_hidden_dac_data); |
3155 | 2c6ab832 | bellard | |
3156 | 2c6ab832 | bellard | qemu_get_be32s(f, &s->hw_cursor_x); |
3157 | 2c6ab832 | bellard | qemu_get_be32s(f, &s->hw_cursor_y); |
3158 | 2c6ab832 | bellard | |
3159 | 2bec46dc | aliguori | cirrus_update_memory_access(s); |
3160 | 2c6ab832 | bellard | /* force refresh */
|
3161 | 2c6ab832 | bellard | s->graphic_mode = -1;
|
3162 | 2c6ab832 | bellard | cirrus_update_bank_ptr(s, 0);
|
3163 | 2c6ab832 | bellard | cirrus_update_bank_ptr(s, 1);
|
3164 | 2c6ab832 | bellard | return 0; |
3165 | 2c6ab832 | bellard | } |
3166 | 2c6ab832 | bellard | |
3167 | e36f36e1 | bellard | /***************************************
|
3168 | e36f36e1 | bellard | *
|
3169 | e6e5ad80 | bellard | * initialize
|
3170 | e6e5ad80 | bellard | *
|
3171 | e6e5ad80 | bellard | ***************************************/
|
3172 | e6e5ad80 | bellard | |
3173 | 4abc796d | blueswir1 | static void cirrus_reset(void *opaque) |
3174 | e6e5ad80 | bellard | { |
3175 | 4abc796d | blueswir1 | CirrusVGAState *s = opaque; |
3176 | e6e5ad80 | bellard | |
3177 | 4abc796d | blueswir1 | vga_reset(s); |
3178 | ee50c6bc | aliguori | unmap_linear_vram(s); |
3179 | e6e5ad80 | bellard | s->sr[0x06] = 0x0f; |
3180 | 4abc796d | blueswir1 | if (s->device_id == CIRRUS_ID_CLGD5446) {
|
3181 | 78e127ef | bellard | /* 4MB 64 bit memory config, always PCI */
|
3182 | b30d4608 | bellard | s->sr[0x1F] = 0x2d; // MemClock |
3183 | b30d4608 | bellard | s->gr[0x18] = 0x0f; // fastest memory configuration |
3184 | 78e127ef | bellard | s->sr[0x0f] = 0x98; |
3185 | 78e127ef | bellard | s->sr[0x17] = 0x20; |
3186 | 78e127ef | bellard | s->sr[0x15] = 0x04; /* memory size, 3=2MB, 4=4MB */ |
3187 | 78e127ef | bellard | } else {
|
3188 | b30d4608 | bellard | s->sr[0x1F] = 0x22; // MemClock |
3189 | 78e127ef | bellard | s->sr[0x0F] = CIRRUS_MEMSIZE_2M;
|
3190 | 4abc796d | blueswir1 | s->sr[0x17] = s->bustype;
|
3191 | 78e127ef | bellard | s->sr[0x15] = 0x03; /* memory size, 3=2MB, 4=4MB */ |
3192 | 78e127ef | bellard | } |
3193 | 4abc796d | blueswir1 | s->cr[0x27] = s->device_id;
|
3194 | e6e5ad80 | bellard | |
3195 | 78e127ef | bellard | /* Win2K seems to assume that the pattern buffer is at 0xff
|
3196 | 78e127ef | bellard | initially ! */
|
3197 | 78e127ef | bellard | memset(s->vram_ptr, 0xff, s->real_vram_size);
|
3198 | 78e127ef | bellard | |
3199 | e6e5ad80 | bellard | s->cirrus_hidden_dac_lockindex = 5;
|
3200 | e6e5ad80 | bellard | s->cirrus_hidden_dac_data = 0;
|
3201 | 4abc796d | blueswir1 | } |
3202 | 4abc796d | blueswir1 | |
3203 | 4abc796d | blueswir1 | static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci) |
3204 | 4abc796d | blueswir1 | { |
3205 | 4abc796d | blueswir1 | int i;
|
3206 | 4abc796d | blueswir1 | static int inited; |
3207 | 4abc796d | blueswir1 | |
3208 | 4abc796d | blueswir1 | if (!inited) {
|
3209 | 4abc796d | blueswir1 | inited = 1;
|
3210 | 4abc796d | blueswir1 | for(i = 0;i < 256; i++) |
3211 | 4abc796d | blueswir1 | rop_to_index[i] = CIRRUS_ROP_NOP_INDEX; /* nop rop */
|
3212 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_0] = 0;
|
3213 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_AND_DST] = 1;
|
3214 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOP] = 2;
|
3215 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_AND_NOTDST] = 3;
|
3216 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTDST] = 4;
|
3217 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC] = 5;
|
3218 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_1] = 6;
|
3219 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTSRC_AND_DST] = 7;
|
3220 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_XOR_DST] = 8;
|
3221 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_OR_DST] = 9;
|
3222 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTSRC_OR_NOTDST] = 10;
|
3223 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_NOTXOR_DST] = 11;
|
3224 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_SRC_OR_NOTDST] = 12;
|
3225 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTSRC] = 13;
|
3226 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTSRC_OR_DST] = 14;
|
3227 | 4abc796d | blueswir1 | rop_to_index[CIRRUS_ROP_NOTSRC_AND_NOTDST] = 15;
|
3228 | 4abc796d | blueswir1 | s->device_id = device_id; |
3229 | 4abc796d | blueswir1 | if (is_pci)
|
3230 | 4abc796d | blueswir1 | s->bustype = CIRRUS_BUSTYPE_PCI; |
3231 | 4abc796d | blueswir1 | else
|
3232 | 4abc796d | blueswir1 | s->bustype = CIRRUS_BUSTYPE_ISA; |
3233 | 4abc796d | blueswir1 | } |
3234 | 4abc796d | blueswir1 | |
3235 | 4abc796d | blueswir1 | register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s); |
3236 | 4abc796d | blueswir1 | |
3237 | 4abc796d | blueswir1 | register_ioport_write(0x3b4, 2, 1, vga_ioport_write, s); |
3238 | 4abc796d | blueswir1 | register_ioport_write(0x3d4, 2, 1, vga_ioport_write, s); |
3239 | 4abc796d | blueswir1 | register_ioport_write(0x3ba, 1, 1, vga_ioport_write, s); |
3240 | 4abc796d | blueswir1 | register_ioport_write(0x3da, 1, 1, vga_ioport_write, s); |
3241 | 4abc796d | blueswir1 | |
3242 | 4abc796d | blueswir1 | register_ioport_read(0x3c0, 16, 1, vga_ioport_read, s); |
3243 | 4abc796d | blueswir1 | |
3244 | 4abc796d | blueswir1 | register_ioport_read(0x3b4, 2, 1, vga_ioport_read, s); |
3245 | 4abc796d | blueswir1 | register_ioport_read(0x3d4, 2, 1, vga_ioport_read, s); |
3246 | 4abc796d | blueswir1 | register_ioport_read(0x3ba, 1, 1, vga_ioport_read, s); |
3247 | 4abc796d | blueswir1 | register_ioport_read(0x3da, 1, 1, vga_ioport_read, s); |
3248 | 4abc796d | blueswir1 | |
3249 | 4abc796d | blueswir1 | s->vga_io_memory = cpu_register_io_memory(0, cirrus_vga_mem_read,
|
3250 | 4abc796d | blueswir1 | cirrus_vga_mem_write, s); |
3251 | 4abc796d | blueswir1 | cpu_register_physical_memory(isa_mem_base + 0x000a0000, 0x20000, |
3252 | 4abc796d | blueswir1 | s->vga_io_memory); |
3253 | 4abc796d | blueswir1 | qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000); |
3254 | 2c6ab832 | bellard | |
3255 | fefe54e3 | aliguori | /* I/O handler for LFB */
|
3256 | fefe54e3 | aliguori | s->cirrus_linear_io_addr = |
3257 | fefe54e3 | aliguori | cpu_register_io_memory(0, cirrus_linear_read, cirrus_linear_write, s);
|
3258 | fefe54e3 | aliguori | s->cirrus_linear_write = cpu_get_io_memory_write(s->cirrus_linear_io_addr); |
3259 | fefe54e3 | aliguori | |
3260 | fefe54e3 | aliguori | /* I/O handler for LFB */
|
3261 | fefe54e3 | aliguori | s->cirrus_linear_bitblt_io_addr = |
3262 | fefe54e3 | aliguori | cpu_register_io_memory(0, cirrus_linear_bitblt_read,
|
3263 | fefe54e3 | aliguori | cirrus_linear_bitblt_write, s); |
3264 | fefe54e3 | aliguori | |
3265 | fefe54e3 | aliguori | /* I/O handler for memory-mapped I/O */
|
3266 | fefe54e3 | aliguori | s->cirrus_mmio_io_addr = |
3267 | fefe54e3 | aliguori | cpu_register_io_memory(0, cirrus_mmio_read, cirrus_mmio_write, s);
|
3268 | fefe54e3 | aliguori | |
3269 | fefe54e3 | aliguori | s->real_vram_size = |
3270 | fefe54e3 | aliguori | (s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024; |
3271 | fefe54e3 | aliguori | |
3272 | fefe54e3 | aliguori | /* XXX: s->vram_size must be a power of two */
|
3273 | fefe54e3 | aliguori | s->cirrus_addr_mask = s->real_vram_size - 1;
|
3274 | fefe54e3 | aliguori | s->linear_mmio_mask = s->real_vram_size - 256;
|
3275 | fefe54e3 | aliguori | |
3276 | fefe54e3 | aliguori | s->get_bpp = cirrus_get_bpp; |
3277 | fefe54e3 | aliguori | s->get_offsets = cirrus_get_offsets; |
3278 | fefe54e3 | aliguori | s->get_resolution = cirrus_get_resolution; |
3279 | fefe54e3 | aliguori | s->cursor_invalidate = cirrus_cursor_invalidate; |
3280 | fefe54e3 | aliguori | s->cursor_draw_line = cirrus_cursor_draw_line; |
3281 | fefe54e3 | aliguori | |
3282 | 4abc796d | blueswir1 | qemu_register_reset(cirrus_reset, s); |
3283 | 4abc796d | blueswir1 | cirrus_reset(s); |
3284 | d2269f6f | bellard | register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s); |
3285 | e6e5ad80 | bellard | } |
3286 | e6e5ad80 | bellard | |
3287 | e6e5ad80 | bellard | /***************************************
|
3288 | e6e5ad80 | bellard | *
|
3289 | e6e5ad80 | bellard | * ISA bus support
|
3290 | e6e5ad80 | bellard | *
|
3291 | e6e5ad80 | bellard | ***************************************/
|
3292 | e6e5ad80 | bellard | |
3293 | 3023f332 | aliguori | void isa_cirrus_vga_init(uint8_t *vga_ram_base,
|
3294 | 4efe2755 | aliguori | ram_addr_t vga_ram_offset, int vga_ram_size)
|
3295 | e6e5ad80 | bellard | { |
3296 | e6e5ad80 | bellard | CirrusVGAState *s; |
3297 | e6e5ad80 | bellard | |
3298 | e6e5ad80 | bellard | s = qemu_mallocz(sizeof(CirrusVGAState));
|
3299 | 3b46e624 | ths | |
3300 | 5fafdf24 | ths | vga_common_init((VGAState *)s, |
3301 | 3023f332 | aliguori | vga_ram_base, vga_ram_offset, vga_ram_size); |
3302 | 78e127ef | bellard | cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
|
3303 | 3023f332 | aliguori | s->ds = graphic_console_init(s->update, s->invalidate, |
3304 | 3023f332 | aliguori | s->screen_dump, s->text_update, s); |
3305 | e6e5ad80 | bellard | /* XXX ISA-LFB support */
|
3306 | e6e5ad80 | bellard | } |
3307 | e6e5ad80 | bellard | |
3308 | e6e5ad80 | bellard | /***************************************
|
3309 | e6e5ad80 | bellard | *
|
3310 | e6e5ad80 | bellard | * PCI bus support
|
3311 | e6e5ad80 | bellard | *
|
3312 | e6e5ad80 | bellard | ***************************************/
|
3313 | e6e5ad80 | bellard | |
3314 | e6e5ad80 | bellard | static void cirrus_pci_lfb_map(PCIDevice *d, int region_num, |
3315 | e6e5ad80 | bellard | uint32_t addr, uint32_t size, int type)
|
3316 | e6e5ad80 | bellard | { |
3317 | e6e5ad80 | bellard | CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga; |
3318 | e6e5ad80 | bellard | |
3319 | ba7349cd | aliguori | vga_dirty_log_stop((VGAState *)s); |
3320 | ba7349cd | aliguori | |
3321 | a5082316 | bellard | /* XXX: add byte swapping apertures */
|
3322 | e6e5ad80 | bellard | cpu_register_physical_memory(addr, s->vram_size, |
3323 | e6e5ad80 | bellard | s->cirrus_linear_io_addr); |
3324 | a5082316 | bellard | cpu_register_physical_memory(addr + 0x1000000, 0x400000, |
3325 | a5082316 | bellard | s->cirrus_linear_bitblt_io_addr); |
3326 | 2bec46dc | aliguori | |
3327 | 2bec46dc | aliguori | s->map_addr = s->map_end = 0;
|
3328 | 2bec46dc | aliguori | s->lfb_addr = addr & TARGET_PAGE_MASK; |
3329 | 2bec46dc | aliguori | s->lfb_end = ((addr + VGA_RAM_SIZE) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
|
3330 | 2bec46dc | aliguori | /* account for overflow */
|
3331 | 2bec46dc | aliguori | if (s->lfb_end < addr + VGA_RAM_SIZE)
|
3332 | 2bec46dc | aliguori | s->lfb_end = addr + VGA_RAM_SIZE; |
3333 | ba7349cd | aliguori | |
3334 | ba7349cd | aliguori | vga_dirty_log_start((VGAState *)s); |
3335 | e6e5ad80 | bellard | } |
3336 | e6e5ad80 | bellard | |
3337 | e6e5ad80 | bellard | static void cirrus_pci_mmio_map(PCIDevice *d, int region_num, |
3338 | e6e5ad80 | bellard | uint32_t addr, uint32_t size, int type)
|
3339 | e6e5ad80 | bellard | { |
3340 | e6e5ad80 | bellard | CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga; |
3341 | e6e5ad80 | bellard | |
3342 | e6e5ad80 | bellard | cpu_register_physical_memory(addr, CIRRUS_PNPMMIO_SIZE, |
3343 | e6e5ad80 | bellard | s->cirrus_mmio_io_addr); |
3344 | e6e5ad80 | bellard | } |
3345 | e6e5ad80 | bellard | |
3346 | ba7349cd | aliguori | static void pci_cirrus_write_config(PCIDevice *d, |
3347 | ba7349cd | aliguori | uint32_t address, uint32_t val, int len)
|
3348 | ba7349cd | aliguori | { |
3349 | ba7349cd | aliguori | PCICirrusVGAState *pvs = container_of(d, PCICirrusVGAState, dev); |
3350 | ba7349cd | aliguori | CirrusVGAState *s = &pvs->cirrus_vga; |
3351 | ba7349cd | aliguori | |
3352 | ba7349cd | aliguori | vga_dirty_log_stop((VGAState *)s); |
3353 | ba7349cd | aliguori | |
3354 | ba7349cd | aliguori | pci_default_write_config(d, address, val, len); |
3355 | ba7349cd | aliguori | if (s->map_addr && pvs->dev.io_regions[0].addr == -1) |
3356 | ba7349cd | aliguori | s->map_addr = 0;
|
3357 | ba7349cd | aliguori | cirrus_update_memory_access(s); |
3358 | ba7349cd | aliguori | |
3359 | ba7349cd | aliguori | vga_dirty_log_start((VGAState *)s); |
3360 | ba7349cd | aliguori | } |
3361 | ba7349cd | aliguori | |
3362 | 3023f332 | aliguori | void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
|
3363 | 4efe2755 | aliguori | ram_addr_t vga_ram_offset, int vga_ram_size)
|
3364 | e6e5ad80 | bellard | { |
3365 | e6e5ad80 | bellard | PCICirrusVGAState *d; |
3366 | e6e5ad80 | bellard | uint8_t *pci_conf; |
3367 | e6e5ad80 | bellard | CirrusVGAState *s; |
3368 | 20ba3ae1 | bellard | int device_id;
|
3369 | 3b46e624 | ths | |
3370 | 20ba3ae1 | bellard | device_id = CIRRUS_ID_CLGD5446; |
3371 | e6e5ad80 | bellard | |
3372 | e6e5ad80 | bellard | /* setup PCI configuration registers */
|
3373 | 5fafdf24 | ths | d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
|
3374 | 5fafdf24 | ths | sizeof(PCICirrusVGAState),
|
3375 | ba7349cd | aliguori | -1, NULL, pci_cirrus_write_config); |
3376 | e6e5ad80 | bellard | pci_conf = d->dev.config; |
3377 | deb54399 | aliguori | pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS); |
3378 | deb54399 | aliguori | pci_config_set_device_id(pci_conf, device_id); |
3379 | e6e5ad80 | bellard | pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
|
3380 | 173a543b | blueswir1 | pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA); |
3381 | e6e5ad80 | bellard | pci_conf[0x0e] = PCI_CLASS_HEADERTYPE_00h;
|
3382 | e6e5ad80 | bellard | |
3383 | e6e5ad80 | bellard | /* setup VGA */
|
3384 | e6e5ad80 | bellard | s = &d->cirrus_vga; |
3385 | 5fafdf24 | ths | vga_common_init((VGAState *)s, |
3386 | 3023f332 | aliguori | vga_ram_base, vga_ram_offset, vga_ram_size); |
3387 | 78e127ef | bellard | cirrus_init_common(s, device_id, 1);
|
3388 | d34cab9f | ths | |
3389 | 3023f332 | aliguori | s->ds = graphic_console_init(s->update, s->invalidate, |
3390 | 3023f332 | aliguori | s->screen_dump, s->text_update, s); |
3391 | d34cab9f | ths | |
3392 | d2269f6f | bellard | s->pci_dev = (PCIDevice *)d; |
3393 | e6e5ad80 | bellard | |
3394 | e6e5ad80 | bellard | /* setup memory space */
|
3395 | e6e5ad80 | bellard | /* memory #0 LFB */
|
3396 | e6e5ad80 | bellard | /* memory #1 memory-mapped I/O */
|
3397 | e6e5ad80 | bellard | /* XXX: s->vram_size must be a power of two */
|
3398 | a5082316 | bellard | pci_register_io_region((PCIDevice *)d, 0, 0x2000000, |
3399 | a21ae81d | bellard | PCI_ADDRESS_SPACE_MEM_PREFETCH, cirrus_pci_lfb_map); |
3400 | 20ba3ae1 | bellard | if (device_id == CIRRUS_ID_CLGD5446) {
|
3401 | a21ae81d | bellard | pci_register_io_region((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
|
3402 | a21ae81d | bellard | PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map); |
3403 | a21ae81d | bellard | } |
3404 | e6e5ad80 | bellard | /* XXX: ROM BIOS */
|
3405 | e6e5ad80 | bellard | } |