root / hw / sm501.c @ 0b7ade1d
History | View | Annotate | Download (41.2 kB)
1 | ffd39257 | blueswir1 | /*
|
---|---|---|---|
2 | ffd39257 | blueswir1 | * QEMU SM501 Device
|
3 | ffd39257 | blueswir1 | *
|
4 | ffd39257 | blueswir1 | * Copyright (c) 2008 Shin-ichiro KAWASAKI
|
5 | ffd39257 | blueswir1 | *
|
6 | ffd39257 | blueswir1 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | ffd39257 | blueswir1 | * of this software and associated documentation files (the "Software"), to deal
|
8 | ffd39257 | blueswir1 | * in the Software without restriction, including without limitation the rights
|
9 | ffd39257 | blueswir1 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | ffd39257 | blueswir1 | * copies of the Software, and to permit persons to whom the Software is
|
11 | ffd39257 | blueswir1 | * furnished to do so, subject to the following conditions:
|
12 | ffd39257 | blueswir1 | *
|
13 | ffd39257 | blueswir1 | * The above copyright notice and this permission notice shall be included in
|
14 | ffd39257 | blueswir1 | * all copies or substantial portions of the Software.
|
15 | ffd39257 | blueswir1 | *
|
16 | ffd39257 | blueswir1 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | ffd39257 | blueswir1 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | ffd39257 | blueswir1 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | ffd39257 | blueswir1 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | ffd39257 | blueswir1 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | ffd39257 | blueswir1 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | ffd39257 | blueswir1 | * THE SOFTWARE.
|
23 | ffd39257 | blueswir1 | */
|
24 | ffd39257 | blueswir1 | |
25 | ffd39257 | blueswir1 | #include <stdio.h> |
26 | ffd39257 | blueswir1 | #include "hw.h" |
27 | ffd39257 | blueswir1 | #include "pc.h" |
28 | ffd39257 | blueswir1 | #include "console.h" |
29 | b79e1752 | aurel32 | #include "devices.h" |
30 | 61d3cf93 | Paul Brook | #include "sysbus.h" |
31 | 61d3cf93 | Paul Brook | #include "qdev-addr.h" |
32 | 45416789 | Blue Swirl | #include "range.h" |
33 | ffd39257 | blueswir1 | |
34 | ffd39257 | blueswir1 | /*
|
35 | 604be200 | Shin-ichiro KAWASAKI | * Status: 2010/05/07
|
36 | ffd39257 | blueswir1 | * - Minimum implementation for Linux console : mmio regs and CRT layer.
|
37 | 604be200 | Shin-ichiro KAWASAKI | * - 2D grapihcs acceleration partially supported : only fill rectangle.
|
38 | ffd39257 | blueswir1 | *
|
39 | ffd39257 | blueswir1 | * TODO:
|
40 | ffd39257 | blueswir1 | * - Panel support
|
41 | ffd39257 | blueswir1 | * - Touch panel support
|
42 | ffd39257 | blueswir1 | * - USB support
|
43 | ffd39257 | blueswir1 | * - UART support
|
44 | 604be200 | Shin-ichiro KAWASAKI | * - More 2D graphics engine support
|
45 | ffd39257 | blueswir1 | * - Performance tuning
|
46 | ffd39257 | blueswir1 | */
|
47 | ffd39257 | blueswir1 | |
48 | ffd39257 | blueswir1 | //#define DEBUG_SM501
|
49 | ffd39257 | blueswir1 | //#define DEBUG_BITBLT
|
50 | ffd39257 | blueswir1 | |
51 | ffd39257 | blueswir1 | #ifdef DEBUG_SM501
|
52 | 001faf32 | Blue Swirl | #define SM501_DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__) |
53 | ffd39257 | blueswir1 | #else
|
54 | 001faf32 | Blue Swirl | #define SM501_DPRINTF(fmt, ...) do {} while(0) |
55 | ffd39257 | blueswir1 | #endif
|
56 | ffd39257 | blueswir1 | |
57 | ffd39257 | blueswir1 | |
58 | ffd39257 | blueswir1 | #define MMIO_BASE_OFFSET 0x3e00000 |
59 | ffd39257 | blueswir1 | |
60 | ffd39257 | blueswir1 | /* SM501 register definitions taken from "linux/include/linux/sm501-regs.h" */
|
61 | ffd39257 | blueswir1 | |
62 | ffd39257 | blueswir1 | /* System Configuration area */
|
63 | ffd39257 | blueswir1 | /* System config base */
|
64 | ffd39257 | blueswir1 | #define SM501_SYS_CONFIG (0x000000) |
65 | ffd39257 | blueswir1 | |
66 | ffd39257 | blueswir1 | /* config 1 */
|
67 | ffd39257 | blueswir1 | #define SM501_SYSTEM_CONTROL (0x000000) |
68 | ffd39257 | blueswir1 | |
69 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PANEL_TRISTATE (1<<0) |
70 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_MEM_TRISTATE (1<<1) |
71 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_CRT_TRISTATE (1<<2) |
72 | ffd39257 | blueswir1 | |
73 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SLAVE_BURST_MASK (3<<4) |
74 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SLAVE_BURST_1 (0<<4) |
75 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SLAVE_BURST_2 (1<<4) |
76 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SLAVE_BURST_4 (2<<4) |
77 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SLAVE_BURST_8 (3<<4) |
78 | ffd39257 | blueswir1 | |
79 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_CLOCK_RUN_EN (1<<6) |
80 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_RETRY_DISABLE (1<<7) |
81 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_SUBSYS_LOCK (1<<11) |
82 | ffd39257 | blueswir1 | #define SM501_SYSCTRL_PCI_BURST_READ_EN (1<<15) |
83 | ffd39257 | blueswir1 | |
84 | ffd39257 | blueswir1 | /* miscellaneous control */
|
85 | ffd39257 | blueswir1 | |
86 | ffd39257 | blueswir1 | #define SM501_MISC_CONTROL (0x000004) |
87 | ffd39257 | blueswir1 | |
88 | ffd39257 | blueswir1 | #define SM501_MISC_BUS_SH (0x0) |
89 | ffd39257 | blueswir1 | #define SM501_MISC_BUS_PCI (0x1) |
90 | ffd39257 | blueswir1 | #define SM501_MISC_BUS_XSCALE (0x2) |
91 | ffd39257 | blueswir1 | #define SM501_MISC_BUS_NEC (0x6) |
92 | ffd39257 | blueswir1 | #define SM501_MISC_BUS_MASK (0x7) |
93 | ffd39257 | blueswir1 | |
94 | ffd39257 | blueswir1 | #define SM501_MISC_VR_62MB (1<<3) |
95 | ffd39257 | blueswir1 | #define SM501_MISC_CDR_RESET (1<<7) |
96 | ffd39257 | blueswir1 | #define SM501_MISC_USB_LB (1<<8) |
97 | ffd39257 | blueswir1 | #define SM501_MISC_USB_SLAVE (1<<9) |
98 | ffd39257 | blueswir1 | #define SM501_MISC_BL_1 (1<<10) |
99 | ffd39257 | blueswir1 | #define SM501_MISC_MC (1<<11) |
100 | ffd39257 | blueswir1 | #define SM501_MISC_DAC_POWER (1<<12) |
101 | ffd39257 | blueswir1 | #define SM501_MISC_IRQ_INVERT (1<<16) |
102 | ffd39257 | blueswir1 | #define SM501_MISC_SH (1<<17) |
103 | ffd39257 | blueswir1 | |
104 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_EMPTY (0<<18) |
105 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_8 (1<<18) |
106 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_16 (2<<18) |
107 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_24 (3<<18) |
108 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_32 (4<<18) |
109 | ffd39257 | blueswir1 | #define SM501_MISC_HOLD_MASK (7<<18) |
110 | ffd39257 | blueswir1 | |
111 | ffd39257 | blueswir1 | #define SM501_MISC_FREQ_12 (1<<24) |
112 | ffd39257 | blueswir1 | #define SM501_MISC_PNL_24BIT (1<<25) |
113 | ffd39257 | blueswir1 | #define SM501_MISC_8051_LE (1<<26) |
114 | ffd39257 | blueswir1 | |
115 | ffd39257 | blueswir1 | |
116 | ffd39257 | blueswir1 | |
117 | ffd39257 | blueswir1 | #define SM501_GPIO31_0_CONTROL (0x000008) |
118 | ffd39257 | blueswir1 | #define SM501_GPIO63_32_CONTROL (0x00000C) |
119 | ffd39257 | blueswir1 | #define SM501_DRAM_CONTROL (0x000010) |
120 | ffd39257 | blueswir1 | |
121 | ffd39257 | blueswir1 | /* command list */
|
122 | ffd39257 | blueswir1 | #define SM501_ARBTRTN_CONTROL (0x000014) |
123 | ffd39257 | blueswir1 | |
124 | ffd39257 | blueswir1 | /* command list */
|
125 | ffd39257 | blueswir1 | #define SM501_COMMAND_LIST_STATUS (0x000024) |
126 | ffd39257 | blueswir1 | |
127 | ffd39257 | blueswir1 | /* interrupt debug */
|
128 | ffd39257 | blueswir1 | #define SM501_RAW_IRQ_STATUS (0x000028) |
129 | ffd39257 | blueswir1 | #define SM501_RAW_IRQ_CLEAR (0x000028) |
130 | ffd39257 | blueswir1 | #define SM501_IRQ_STATUS (0x00002C) |
131 | ffd39257 | blueswir1 | #define SM501_IRQ_MASK (0x000030) |
132 | ffd39257 | blueswir1 | #define SM501_DEBUG_CONTROL (0x000034) |
133 | ffd39257 | blueswir1 | |
134 | ffd39257 | blueswir1 | /* power management */
|
135 | ffd39257 | blueswir1 | #define SM501_POWERMODE_P2X_SRC (1<<29) |
136 | ffd39257 | blueswir1 | #define SM501_POWERMODE_V2X_SRC (1<<20) |
137 | ffd39257 | blueswir1 | #define SM501_POWERMODE_M_SRC (1<<12) |
138 | ffd39257 | blueswir1 | #define SM501_POWERMODE_M1_SRC (1<<4) |
139 | ffd39257 | blueswir1 | |
140 | ffd39257 | blueswir1 | #define SM501_CURRENT_GATE (0x000038) |
141 | ffd39257 | blueswir1 | #define SM501_CURRENT_CLOCK (0x00003C) |
142 | ffd39257 | blueswir1 | #define SM501_POWER_MODE_0_GATE (0x000040) |
143 | ffd39257 | blueswir1 | #define SM501_POWER_MODE_0_CLOCK (0x000044) |
144 | ffd39257 | blueswir1 | #define SM501_POWER_MODE_1_GATE (0x000048) |
145 | ffd39257 | blueswir1 | #define SM501_POWER_MODE_1_CLOCK (0x00004C) |
146 | ffd39257 | blueswir1 | #define SM501_SLEEP_MODE_GATE (0x000050) |
147 | ffd39257 | blueswir1 | #define SM501_POWER_MODE_CONTROL (0x000054) |
148 | ffd39257 | blueswir1 | |
149 | ffd39257 | blueswir1 | /* power gates for units within the 501 */
|
150 | ffd39257 | blueswir1 | #define SM501_GATE_HOST (0) |
151 | ffd39257 | blueswir1 | #define SM501_GATE_MEMORY (1) |
152 | ffd39257 | blueswir1 | #define SM501_GATE_DISPLAY (2) |
153 | ffd39257 | blueswir1 | #define SM501_GATE_2D_ENGINE (3) |
154 | ffd39257 | blueswir1 | #define SM501_GATE_CSC (4) |
155 | ffd39257 | blueswir1 | #define SM501_GATE_ZVPORT (5) |
156 | ffd39257 | blueswir1 | #define SM501_GATE_GPIO (6) |
157 | ffd39257 | blueswir1 | #define SM501_GATE_UART0 (7) |
158 | ffd39257 | blueswir1 | #define SM501_GATE_UART1 (8) |
159 | ffd39257 | blueswir1 | #define SM501_GATE_SSP (10) |
160 | ffd39257 | blueswir1 | #define SM501_GATE_USB_HOST (11) |
161 | ffd39257 | blueswir1 | #define SM501_GATE_USB_GADGET (12) |
162 | ffd39257 | blueswir1 | #define SM501_GATE_UCONTROLLER (17) |
163 | ffd39257 | blueswir1 | #define SM501_GATE_AC97 (18) |
164 | ffd39257 | blueswir1 | |
165 | ffd39257 | blueswir1 | /* panel clock */
|
166 | ffd39257 | blueswir1 | #define SM501_CLOCK_P2XCLK (24) |
167 | ffd39257 | blueswir1 | /* crt clock */
|
168 | ffd39257 | blueswir1 | #define SM501_CLOCK_V2XCLK (16) |
169 | ffd39257 | blueswir1 | /* main clock */
|
170 | ffd39257 | blueswir1 | #define SM501_CLOCK_MCLK (8) |
171 | ffd39257 | blueswir1 | /* SDRAM controller clock */
|
172 | ffd39257 | blueswir1 | #define SM501_CLOCK_M1XCLK (0) |
173 | ffd39257 | blueswir1 | |
174 | ffd39257 | blueswir1 | /* config 2 */
|
175 | ffd39257 | blueswir1 | #define SM501_PCI_MASTER_BASE (0x000058) |
176 | ffd39257 | blueswir1 | #define SM501_ENDIAN_CONTROL (0x00005C) |
177 | ffd39257 | blueswir1 | #define SM501_DEVICEID (0x000060) |
178 | ffd39257 | blueswir1 | /* 0x050100A0 */
|
179 | ffd39257 | blueswir1 | |
180 | ffd39257 | blueswir1 | #define SM501_DEVICEID_SM501 (0x05010000) |
181 | ffd39257 | blueswir1 | #define SM501_DEVICEID_IDMASK (0xffff0000) |
182 | ffd39257 | blueswir1 | #define SM501_DEVICEID_REVMASK (0x000000ff) |
183 | ffd39257 | blueswir1 | |
184 | ffd39257 | blueswir1 | #define SM501_PLLCLOCK_COUNT (0x000064) |
185 | ffd39257 | blueswir1 | #define SM501_MISC_TIMING (0x000068) |
186 | ffd39257 | blueswir1 | #define SM501_CURRENT_SDRAM_CLOCK (0x00006C) |
187 | ffd39257 | blueswir1 | |
188 | ffd39257 | blueswir1 | #define SM501_PROGRAMMABLE_PLL_CONTROL (0x000074) |
189 | ffd39257 | blueswir1 | |
190 | ffd39257 | blueswir1 | /* GPIO base */
|
191 | ffd39257 | blueswir1 | #define SM501_GPIO (0x010000) |
192 | ffd39257 | blueswir1 | #define SM501_GPIO_DATA_LOW (0x00) |
193 | ffd39257 | blueswir1 | #define SM501_GPIO_DATA_HIGH (0x04) |
194 | ffd39257 | blueswir1 | #define SM501_GPIO_DDR_LOW (0x08) |
195 | ffd39257 | blueswir1 | #define SM501_GPIO_DDR_HIGH (0x0C) |
196 | ffd39257 | blueswir1 | #define SM501_GPIO_IRQ_SETUP (0x10) |
197 | ffd39257 | blueswir1 | #define SM501_GPIO_IRQ_STATUS (0x14) |
198 | ffd39257 | blueswir1 | #define SM501_GPIO_IRQ_RESET (0x14) |
199 | ffd39257 | blueswir1 | |
200 | ffd39257 | blueswir1 | /* I2C controller base */
|
201 | ffd39257 | blueswir1 | #define SM501_I2C (0x010040) |
202 | ffd39257 | blueswir1 | #define SM501_I2C_BYTE_COUNT (0x00) |
203 | ffd39257 | blueswir1 | #define SM501_I2C_CONTROL (0x01) |
204 | ffd39257 | blueswir1 | #define SM501_I2C_STATUS (0x02) |
205 | ffd39257 | blueswir1 | #define SM501_I2C_RESET (0x02) |
206 | ffd39257 | blueswir1 | #define SM501_I2C_SLAVE_ADDRESS (0x03) |
207 | ffd39257 | blueswir1 | #define SM501_I2C_DATA (0x04) |
208 | ffd39257 | blueswir1 | |
209 | ffd39257 | blueswir1 | /* SSP base */
|
210 | ffd39257 | blueswir1 | #define SM501_SSP (0x020000) |
211 | ffd39257 | blueswir1 | |
212 | ffd39257 | blueswir1 | /* Uart 0 base */
|
213 | ffd39257 | blueswir1 | #define SM501_UART0 (0x030000) |
214 | ffd39257 | blueswir1 | |
215 | ffd39257 | blueswir1 | /* Uart 1 base */
|
216 | ffd39257 | blueswir1 | #define SM501_UART1 (0x030020) |
217 | ffd39257 | blueswir1 | |
218 | ffd39257 | blueswir1 | /* USB host port base */
|
219 | ffd39257 | blueswir1 | #define SM501_USB_HOST (0x040000) |
220 | ffd39257 | blueswir1 | |
221 | ffd39257 | blueswir1 | /* USB slave/gadget base */
|
222 | ffd39257 | blueswir1 | #define SM501_USB_GADGET (0x060000) |
223 | ffd39257 | blueswir1 | |
224 | ffd39257 | blueswir1 | /* USB slave/gadget data port base */
|
225 | ffd39257 | blueswir1 | #define SM501_USB_GADGET_DATA (0x070000) |
226 | ffd39257 | blueswir1 | |
227 | ffd39257 | blueswir1 | /* Display controller/video engine base */
|
228 | ffd39257 | blueswir1 | #define SM501_DC (0x080000) |
229 | ffd39257 | blueswir1 | |
230 | ffd39257 | blueswir1 | /* common defines for the SM501 address registers */
|
231 | ffd39257 | blueswir1 | #define SM501_ADDR_FLIP (1<<31) |
232 | ffd39257 | blueswir1 | #define SM501_ADDR_EXT (1<<27) |
233 | ffd39257 | blueswir1 | #define SM501_ADDR_CS1 (1<<26) |
234 | ffd39257 | blueswir1 | #define SM501_ADDR_MASK (0x3f << 26) |
235 | ffd39257 | blueswir1 | |
236 | ffd39257 | blueswir1 | #define SM501_FIFO_MASK (0x3 << 16) |
237 | ffd39257 | blueswir1 | #define SM501_FIFO_1 (0x0 << 16) |
238 | ffd39257 | blueswir1 | #define SM501_FIFO_3 (0x1 << 16) |
239 | ffd39257 | blueswir1 | #define SM501_FIFO_7 (0x2 << 16) |
240 | ffd39257 | blueswir1 | #define SM501_FIFO_11 (0x3 << 16) |
241 | ffd39257 | blueswir1 | |
242 | ffd39257 | blueswir1 | /* common registers for panel and the crt */
|
243 | ffd39257 | blueswir1 | #define SM501_OFF_DC_H_TOT (0x000) |
244 | ffd39257 | blueswir1 | #define SM501_OFF_DC_V_TOT (0x008) |
245 | ffd39257 | blueswir1 | #define SM501_OFF_DC_H_SYNC (0x004) |
246 | ffd39257 | blueswir1 | #define SM501_OFF_DC_V_SYNC (0x00C) |
247 | ffd39257 | blueswir1 | |
248 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL (0x000) |
249 | ffd39257 | blueswir1 | |
250 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_FPEN (1<<27) |
251 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_BIAS (1<<26) |
252 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_DATA (1<<25) |
253 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_VDD (1<<24) |
254 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_DP (1<<23) |
255 | ffd39257 | blueswir1 | |
256 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_TFT_888 (0<<21) |
257 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_TFT_333 (1<<21) |
258 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_TFT_444 (2<<21) |
259 | ffd39257 | blueswir1 | |
260 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_DE (1<<20) |
261 | ffd39257 | blueswir1 | |
262 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_LCD_TFT (0<<18) |
263 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_LCD_STN8 (1<<18) |
264 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_LCD_STN12 (2<<18) |
265 | ffd39257 | blueswir1 | |
266 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_CP (1<<14) |
267 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_VSP (1<<13) |
268 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_HSP (1<<12) |
269 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_CK (1<<9) |
270 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_TE (1<<8) |
271 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_VPD (1<<7) |
272 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_VP (1<<6) |
273 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_HPD (1<<5) |
274 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_HP (1<<4) |
275 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_GAMMA (1<<3) |
276 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_EN (1<<2) |
277 | ffd39257 | blueswir1 | |
278 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_8BPP (0<<0) |
279 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_16BPP (1<<0) |
280 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CONTROL_32BPP (2<<0) |
281 | ffd39257 | blueswir1 | |
282 | ffd39257 | blueswir1 | |
283 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_PANNING_CONTROL (0x004) |
284 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_COLOR_KEY (0x008) |
285 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_FB_ADDR (0x00C) |
286 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_FB_OFFSET (0x010) |
287 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_FB_WIDTH (0x014) |
288 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_FB_HEIGHT (0x018) |
289 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_TL_LOC (0x01C) |
290 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_BR_LOC (0x020) |
291 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_H_TOT (0x024) |
292 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_H_SYNC (0x028) |
293 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_V_TOT (0x02C) |
294 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_V_SYNC (0x030) |
295 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_CUR_LINE (0x034) |
296 | ffd39257 | blueswir1 | |
297 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_CONTROL (0x040) |
298 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_FB0_ADDR (0x044) |
299 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_FB_WIDTH (0x048) |
300 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_FB0_LAST_ADDR (0x04C) |
301 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_TL_LOC (0x050) |
302 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_BR_LOC (0x054) |
303 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_SCALE (0x058) |
304 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_INIT_SCALE (0x05C) |
305 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_YUV_CONSTANTS (0x060) |
306 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_FB1_ADDR (0x064) |
307 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_FB1_LAST_ADDR (0x068) |
308 | ffd39257 | blueswir1 | |
309 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_CONTROL (0x080) |
310 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_FB_ADDR (0x084) |
311 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_FB_OFFSET (0x088) |
312 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_FB_LAST_ADDR (0x08C) |
313 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_TL_LOC (0x090) |
314 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_BR_LOC (0x094) |
315 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_SCALE (0x098) |
316 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_INIT_SCALE (0x09C) |
317 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_CHROMA_KEY (0x0A0) |
318 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_ALPHA_COLOR_LOOKUP (0x0A4) |
319 | ffd39257 | blueswir1 | |
320 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_HWC_BASE (0x0F0) |
321 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_HWC_ADDR (0x0F0) |
322 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_HWC_LOC (0x0F4) |
323 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_HWC_COLOR_1_2 (0x0F8) |
324 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_HWC_COLOR_3 (0x0FC) |
325 | ffd39257 | blueswir1 | |
326 | ffd39257 | blueswir1 | #define SM501_HWC_EN (1<<31) |
327 | ffd39257 | blueswir1 | |
328 | ffd39257 | blueswir1 | #define SM501_OFF_HWC_ADDR (0x00) |
329 | ffd39257 | blueswir1 | #define SM501_OFF_HWC_LOC (0x04) |
330 | ffd39257 | blueswir1 | #define SM501_OFF_HWC_COLOR_1_2 (0x08) |
331 | ffd39257 | blueswir1 | #define SM501_OFF_HWC_COLOR_3 (0x0C) |
332 | ffd39257 | blueswir1 | |
333 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_CONTROL (0x100) |
334 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_FB_ADDR (0x104) |
335 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_FB_OFFSET (0x108) |
336 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_TL_LOC (0x10C) |
337 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_BR_LOC (0x110) |
338 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_CHROMA_KEY (0x114) |
339 | ffd39257 | blueswir1 | #define SM501_DC_ALPHA_COLOR_LOOKUP (0x118) |
340 | ffd39257 | blueswir1 | |
341 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL (0x200) |
342 | ffd39257 | blueswir1 | |
343 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_TVP (1<<15) |
344 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_CP (1<<14) |
345 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_VSP (1<<13) |
346 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_HSP (1<<12) |
347 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_VS (1<<11) |
348 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_BLANK (1<<10) |
349 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_SEL (1<<9) |
350 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_TE (1<<8) |
351 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_PIXEL_MASK (0xF << 4) |
352 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_GAMMA (1<<3) |
353 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_ENABLE (1<<2) |
354 | ffd39257 | blueswir1 | |
355 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_8BPP (0<<0) |
356 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_16BPP (1<<0) |
357 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CONTROL_32BPP (2<<0) |
358 | ffd39257 | blueswir1 | |
359 | ffd39257 | blueswir1 | #define SM501_DC_CRT_FB_ADDR (0x204) |
360 | ffd39257 | blueswir1 | #define SM501_DC_CRT_FB_OFFSET (0x208) |
361 | ffd39257 | blueswir1 | #define SM501_DC_CRT_H_TOT (0x20C) |
362 | ffd39257 | blueswir1 | #define SM501_DC_CRT_H_SYNC (0x210) |
363 | ffd39257 | blueswir1 | #define SM501_DC_CRT_V_TOT (0x214) |
364 | ffd39257 | blueswir1 | #define SM501_DC_CRT_V_SYNC (0x218) |
365 | ffd39257 | blueswir1 | #define SM501_DC_CRT_SIGNATURE_ANALYZER (0x21C) |
366 | ffd39257 | blueswir1 | #define SM501_DC_CRT_CUR_LINE (0x220) |
367 | ffd39257 | blueswir1 | #define SM501_DC_CRT_MONITOR_DETECT (0x224) |
368 | ffd39257 | blueswir1 | |
369 | ffd39257 | blueswir1 | #define SM501_DC_CRT_HWC_BASE (0x230) |
370 | ffd39257 | blueswir1 | #define SM501_DC_CRT_HWC_ADDR (0x230) |
371 | ffd39257 | blueswir1 | #define SM501_DC_CRT_HWC_LOC (0x234) |
372 | ffd39257 | blueswir1 | #define SM501_DC_CRT_HWC_COLOR_1_2 (0x238) |
373 | ffd39257 | blueswir1 | #define SM501_DC_CRT_HWC_COLOR_3 (0x23C) |
374 | ffd39257 | blueswir1 | |
375 | ffd39257 | blueswir1 | #define SM501_DC_PANEL_PALETTE (0x400) |
376 | ffd39257 | blueswir1 | |
377 | ffd39257 | blueswir1 | #define SM501_DC_VIDEO_PALETTE (0x800) |
378 | ffd39257 | blueswir1 | |
379 | ffd39257 | blueswir1 | #define SM501_DC_CRT_PALETTE (0xC00) |
380 | ffd39257 | blueswir1 | |
381 | ffd39257 | blueswir1 | /* Zoom Video port base */
|
382 | ffd39257 | blueswir1 | #define SM501_ZVPORT (0x090000) |
383 | ffd39257 | blueswir1 | |
384 | ffd39257 | blueswir1 | /* AC97/I2S base */
|
385 | ffd39257 | blueswir1 | #define SM501_AC97 (0x0A0000) |
386 | ffd39257 | blueswir1 | |
387 | ffd39257 | blueswir1 | /* 8051 micro controller base */
|
388 | ffd39257 | blueswir1 | #define SM501_UCONTROLLER (0x0B0000) |
389 | ffd39257 | blueswir1 | |
390 | ffd39257 | blueswir1 | /* 8051 micro controller SRAM base */
|
391 | ffd39257 | blueswir1 | #define SM501_UCONTROLLER_SRAM (0x0C0000) |
392 | ffd39257 | blueswir1 | |
393 | ffd39257 | blueswir1 | /* DMA base */
|
394 | ffd39257 | blueswir1 | #define SM501_DMA (0x0D0000) |
395 | ffd39257 | blueswir1 | |
396 | ffd39257 | blueswir1 | /* 2d engine base */
|
397 | ffd39257 | blueswir1 | #define SM501_2D_ENGINE (0x100000) |
398 | ffd39257 | blueswir1 | #define SM501_2D_SOURCE (0x00) |
399 | ffd39257 | blueswir1 | #define SM501_2D_DESTINATION (0x04) |
400 | ffd39257 | blueswir1 | #define SM501_2D_DIMENSION (0x08) |
401 | ffd39257 | blueswir1 | #define SM501_2D_CONTROL (0x0C) |
402 | ffd39257 | blueswir1 | #define SM501_2D_PITCH (0x10) |
403 | ffd39257 | blueswir1 | #define SM501_2D_FOREGROUND (0x14) |
404 | ffd39257 | blueswir1 | #define SM501_2D_BACKGROUND (0x18) |
405 | ffd39257 | blueswir1 | #define SM501_2D_STRETCH (0x1C) |
406 | ffd39257 | blueswir1 | #define SM501_2D_COLOR_COMPARE (0x20) |
407 | ffd39257 | blueswir1 | #define SM501_2D_COLOR_COMPARE_MASK (0x24) |
408 | ffd39257 | blueswir1 | #define SM501_2D_MASK (0x28) |
409 | ffd39257 | blueswir1 | #define SM501_2D_CLIP_TL (0x2C) |
410 | ffd39257 | blueswir1 | #define SM501_2D_CLIP_BR (0x30) |
411 | ffd39257 | blueswir1 | #define SM501_2D_MONO_PATTERN_LOW (0x34) |
412 | ffd39257 | blueswir1 | #define SM501_2D_MONO_PATTERN_HIGH (0x38) |
413 | ffd39257 | blueswir1 | #define SM501_2D_WINDOW_WIDTH (0x3C) |
414 | ffd39257 | blueswir1 | #define SM501_2D_SOURCE_BASE (0x40) |
415 | ffd39257 | blueswir1 | #define SM501_2D_DESTINATION_BASE (0x44) |
416 | ffd39257 | blueswir1 | #define SM501_2D_ALPHA (0x48) |
417 | ffd39257 | blueswir1 | #define SM501_2D_WRAP (0x4C) |
418 | ffd39257 | blueswir1 | #define SM501_2D_STATUS (0x50) |
419 | ffd39257 | blueswir1 | |
420 | ffd39257 | blueswir1 | #define SM501_CSC_Y_SOURCE_BASE (0xC8) |
421 | ffd39257 | blueswir1 | #define SM501_CSC_CONSTANTS (0xCC) |
422 | ffd39257 | blueswir1 | #define SM501_CSC_Y_SOURCE_X (0xD0) |
423 | ffd39257 | blueswir1 | #define SM501_CSC_Y_SOURCE_Y (0xD4) |
424 | ffd39257 | blueswir1 | #define SM501_CSC_U_SOURCE_BASE (0xD8) |
425 | ffd39257 | blueswir1 | #define SM501_CSC_V_SOURCE_BASE (0xDC) |
426 | ffd39257 | blueswir1 | #define SM501_CSC_SOURCE_DIMENSION (0xE0) |
427 | ffd39257 | blueswir1 | #define SM501_CSC_SOURCE_PITCH (0xE4) |
428 | ffd39257 | blueswir1 | #define SM501_CSC_DESTINATION (0xE8) |
429 | ffd39257 | blueswir1 | #define SM501_CSC_DESTINATION_DIMENSION (0xEC) |
430 | ffd39257 | blueswir1 | #define SM501_CSC_DESTINATION_PITCH (0xF0) |
431 | ffd39257 | blueswir1 | #define SM501_CSC_SCALE_FACTOR (0xF4) |
432 | ffd39257 | blueswir1 | #define SM501_CSC_DESTINATION_BASE (0xF8) |
433 | ffd39257 | blueswir1 | #define SM501_CSC_CONTROL (0xFC) |
434 | ffd39257 | blueswir1 | |
435 | ffd39257 | blueswir1 | /* 2d engine data port base */
|
436 | ffd39257 | blueswir1 | #define SM501_2D_ENGINE_DATA (0x110000) |
437 | ffd39257 | blueswir1 | |
438 | ffd39257 | blueswir1 | /* end of register definitions */
|
439 | ffd39257 | blueswir1 | |
440 | 0a4e7cd2 | Shin-ichiro KAWASAKI | #define SM501_HWC_WIDTH (64) |
441 | 0a4e7cd2 | Shin-ichiro KAWASAKI | #define SM501_HWC_HEIGHT (64) |
442 | ffd39257 | blueswir1 | |
443 | ffd39257 | blueswir1 | /* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */
|
444 | ffd39257 | blueswir1 | static const uint32_t sm501_mem_local_size[] = { |
445 | ffd39257 | blueswir1 | [0] = 4*1024*1024, |
446 | ffd39257 | blueswir1 | [1] = 8*1024*1024, |
447 | ffd39257 | blueswir1 | [2] = 16*1024*1024, |
448 | ffd39257 | blueswir1 | [3] = 32*1024*1024, |
449 | ffd39257 | blueswir1 | [4] = 64*1024*1024, |
450 | ffd39257 | blueswir1 | [5] = 2*1024*1024, |
451 | ffd39257 | blueswir1 | }; |
452 | ffd39257 | blueswir1 | #define get_local_mem_size(s) sm501_mem_local_size[(s)->local_mem_size_index]
|
453 | ffd39257 | blueswir1 | |
454 | ffd39257 | blueswir1 | typedef struct SM501State { |
455 | ffd39257 | blueswir1 | /* graphic console status */
|
456 | ffd39257 | blueswir1 | DisplayState *ds; |
457 | ffd39257 | blueswir1 | |
458 | ffd39257 | blueswir1 | /* status & internal resources */
|
459 | c227f099 | Anthony Liguori | target_phys_addr_t base; |
460 | ffd39257 | blueswir1 | uint32_t local_mem_size_index; |
461 | ffd39257 | blueswir1 | uint8_t * local_mem; |
462 | 25793bfa | Avi Kivity | MemoryRegion local_mem_region; |
463 | ffd39257 | blueswir1 | uint32_t last_width; |
464 | ffd39257 | blueswir1 | uint32_t last_height; |
465 | ffd39257 | blueswir1 | |
466 | ffd39257 | blueswir1 | /* mmio registers */
|
467 | ffd39257 | blueswir1 | uint32_t system_control; |
468 | ffd39257 | blueswir1 | uint32_t misc_control; |
469 | ffd39257 | blueswir1 | uint32_t gpio_31_0_control; |
470 | ffd39257 | blueswir1 | uint32_t gpio_63_32_control; |
471 | ffd39257 | blueswir1 | uint32_t dram_control; |
472 | ffd39257 | blueswir1 | uint32_t irq_mask; |
473 | ffd39257 | blueswir1 | uint32_t misc_timing; |
474 | ffd39257 | blueswir1 | uint32_t power_mode_control; |
475 | ffd39257 | blueswir1 | |
476 | ffd39257 | blueswir1 | uint32_t uart0_ier; |
477 | ffd39257 | blueswir1 | uint32_t uart0_lcr; |
478 | ffd39257 | blueswir1 | uint32_t uart0_mcr; |
479 | ffd39257 | blueswir1 | uint32_t uart0_scr; |
480 | ffd39257 | blueswir1 | |
481 | ffd39257 | blueswir1 | uint8_t dc_palette[0x400 * 3]; |
482 | ffd39257 | blueswir1 | |
483 | ffd39257 | blueswir1 | uint32_t dc_panel_control; |
484 | ffd39257 | blueswir1 | uint32_t dc_panel_panning_control; |
485 | ffd39257 | blueswir1 | uint32_t dc_panel_fb_addr; |
486 | ffd39257 | blueswir1 | uint32_t dc_panel_fb_offset; |
487 | ffd39257 | blueswir1 | uint32_t dc_panel_fb_width; |
488 | ffd39257 | blueswir1 | uint32_t dc_panel_fb_height; |
489 | ffd39257 | blueswir1 | uint32_t dc_panel_tl_location; |
490 | ffd39257 | blueswir1 | uint32_t dc_panel_br_location; |
491 | ffd39257 | blueswir1 | uint32_t dc_panel_h_total; |
492 | ffd39257 | blueswir1 | uint32_t dc_panel_h_sync; |
493 | ffd39257 | blueswir1 | uint32_t dc_panel_v_total; |
494 | ffd39257 | blueswir1 | uint32_t dc_panel_v_sync; |
495 | ffd39257 | blueswir1 | |
496 | ffd39257 | blueswir1 | uint32_t dc_panel_hwc_addr; |
497 | ffd39257 | blueswir1 | uint32_t dc_panel_hwc_location; |
498 | ffd39257 | blueswir1 | uint32_t dc_panel_hwc_color_1_2; |
499 | ffd39257 | blueswir1 | uint32_t dc_panel_hwc_color_3; |
500 | ffd39257 | blueswir1 | |
501 | ffd39257 | blueswir1 | uint32_t dc_crt_control; |
502 | ffd39257 | blueswir1 | uint32_t dc_crt_fb_addr; |
503 | ffd39257 | blueswir1 | uint32_t dc_crt_fb_offset; |
504 | ffd39257 | blueswir1 | uint32_t dc_crt_h_total; |
505 | ffd39257 | blueswir1 | uint32_t dc_crt_h_sync; |
506 | ffd39257 | blueswir1 | uint32_t dc_crt_v_total; |
507 | ffd39257 | blueswir1 | uint32_t dc_crt_v_sync; |
508 | ffd39257 | blueswir1 | |
509 | ffd39257 | blueswir1 | uint32_t dc_crt_hwc_addr; |
510 | ffd39257 | blueswir1 | uint32_t dc_crt_hwc_location; |
511 | ffd39257 | blueswir1 | uint32_t dc_crt_hwc_color_1_2; |
512 | ffd39257 | blueswir1 | uint32_t dc_crt_hwc_color_3; |
513 | ffd39257 | blueswir1 | |
514 | 07d8a50c | Aurelien Jarno | uint32_t twoD_source; |
515 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_destination; |
516 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_dimension; |
517 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_control; |
518 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_pitch; |
519 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_foreground; |
520 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_stretch; |
521 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_color_compare_mask; |
522 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_mask; |
523 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_window_width; |
524 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_source_base; |
525 | 604be200 | Shin-ichiro KAWASAKI | uint32_t twoD_destination_base; |
526 | 604be200 | Shin-ichiro KAWASAKI | |
527 | ffd39257 | blueswir1 | } SM501State; |
528 | ffd39257 | blueswir1 | |
529 | ffd39257 | blueswir1 | static uint32_t get_local_mem_size_index(uint32_t size)
|
530 | ffd39257 | blueswir1 | { |
531 | ffd39257 | blueswir1 | uint32_t norm_size = 0;
|
532 | ffd39257 | blueswir1 | int i, index = 0; |
533 | ffd39257 | blueswir1 | |
534 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(sm501_mem_local_size); i++) { |
535 | ffd39257 | blueswir1 | uint32_t new_size = sm501_mem_local_size[i]; |
536 | ffd39257 | blueswir1 | if (new_size >= size) {
|
537 | ffd39257 | blueswir1 | if (norm_size == 0 || norm_size > new_size) { |
538 | ffd39257 | blueswir1 | norm_size = new_size; |
539 | ffd39257 | blueswir1 | index = i; |
540 | ffd39257 | blueswir1 | } |
541 | ffd39257 | blueswir1 | } |
542 | ffd39257 | blueswir1 | } |
543 | ffd39257 | blueswir1 | |
544 | ffd39257 | blueswir1 | return index;
|
545 | ffd39257 | blueswir1 | } |
546 | ffd39257 | blueswir1 | |
547 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /**
|
548 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * Check the availability of hardware cursor.
|
549 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param crt 0 for PANEL, 1 for CRT.
|
550 | 0a4e7cd2 | Shin-ichiro KAWASAKI | */
|
551 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static inline int is_hwc_enabled(SM501State *state, int crt) |
552 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
553 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint32_t addr = crt ? state->dc_crt_hwc_addr : state->dc_panel_hwc_addr; |
554 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return addr & 0x80000000; |
555 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
556 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
557 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /**
|
558 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * Get the address which holds cursor pattern data.
|
559 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param crt 0 for PANEL, 1 for CRT.
|
560 | 0a4e7cd2 | Shin-ichiro KAWASAKI | */
|
561 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static inline uint32_t get_hwc_address(SM501State *state, int crt) |
562 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
563 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint32_t addr = crt ? state->dc_crt_hwc_addr : state->dc_panel_hwc_addr; |
564 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return (addr & 0x03FFFFF0)/* >> 4*/; |
565 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
566 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
567 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /**
|
568 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * Get the cursor position in y coordinate.
|
569 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param crt 0 for PANEL, 1 for CRT.
|
570 | 0a4e7cd2 | Shin-ichiro KAWASAKI | */
|
571 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static inline uint32_t get_hwc_y(SM501State *state, int crt) |
572 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
573 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint32_t location = crt ? state->dc_crt_hwc_location |
574 | 0a4e7cd2 | Shin-ichiro KAWASAKI | : state->dc_panel_hwc_location; |
575 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return (location & 0x07FF0000) >> 16; |
576 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
577 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
578 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /**
|
579 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * Get the cursor position in x coordinate.
|
580 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param crt 0 for PANEL, 1 for CRT.
|
581 | 0a4e7cd2 | Shin-ichiro KAWASAKI | */
|
582 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static inline uint32_t get_hwc_x(SM501State *state, int crt) |
583 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
584 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint32_t location = crt ? state->dc_crt_hwc_location |
585 | 0a4e7cd2 | Shin-ichiro KAWASAKI | : state->dc_panel_hwc_location; |
586 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return location & 0x000007FF; |
587 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
588 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
589 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /**
|
590 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * Get the cursor position in x coordinate.
|
591 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param crt 0 for PANEL, 1 for CRT.
|
592 | 0a4e7cd2 | Shin-ichiro KAWASAKI | * @param index 0, 1, 2 or 3 which specifies color of corsor dot.
|
593 | 0a4e7cd2 | Shin-ichiro KAWASAKI | */
|
594 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static inline uint16_t get_hwc_color(SM501State *state, int crt, int index) |
595 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
596 | c2780865 | Stefan Weil | uint32_t color_reg = 0;
|
597 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint16_t color_565 = 0;
|
598 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
599 | 0a4e7cd2 | Shin-ichiro KAWASAKI | if (index == 0) { |
600 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return 0; |
601 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
602 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
603 | 0a4e7cd2 | Shin-ichiro KAWASAKI | switch (index) {
|
604 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 1: |
605 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 2: |
606 | 0a4e7cd2 | Shin-ichiro KAWASAKI | color_reg = crt ? state->dc_crt_hwc_color_1_2 |
607 | 0a4e7cd2 | Shin-ichiro KAWASAKI | : state->dc_panel_hwc_color_1_2; |
608 | 0a4e7cd2 | Shin-ichiro KAWASAKI | break;
|
609 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 3: |
610 | 0a4e7cd2 | Shin-ichiro KAWASAKI | color_reg = crt ? state->dc_crt_hwc_color_3 |
611 | 0a4e7cd2 | Shin-ichiro KAWASAKI | : state->dc_panel_hwc_color_3; |
612 | 0a4e7cd2 | Shin-ichiro KAWASAKI | break;
|
613 | 0a4e7cd2 | Shin-ichiro KAWASAKI | default:
|
614 | 0a4e7cd2 | Shin-ichiro KAWASAKI | printf("invalid hw cursor color.\n");
|
615 | 43dc2a64 | Blue Swirl | abort(); |
616 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
617 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
618 | 0a4e7cd2 | Shin-ichiro KAWASAKI | switch (index) {
|
619 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 1: |
620 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 3: |
621 | 0a4e7cd2 | Shin-ichiro KAWASAKI | color_565 = (uint16_t)(color_reg & 0xFFFF);
|
622 | 0a4e7cd2 | Shin-ichiro KAWASAKI | break;
|
623 | 0a4e7cd2 | Shin-ichiro KAWASAKI | case 2: |
624 | 0a4e7cd2 | Shin-ichiro KAWASAKI | color_565 = (uint16_t)((color_reg >> 16) & 0xFFFF); |
625 | 0a4e7cd2 | Shin-ichiro KAWASAKI | break;
|
626 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
627 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return color_565;
|
628 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
629 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
630 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static int within_hwc_y_range(SM501State *state, int y, int crt) |
631 | 0a4e7cd2 | Shin-ichiro KAWASAKI | { |
632 | 0a4e7cd2 | Shin-ichiro KAWASAKI | int hwc_y = get_hwc_y(state, crt);
|
633 | 0a4e7cd2 | Shin-ichiro KAWASAKI | return (hwc_y <= y && y < hwc_y + SM501_HWC_HEIGHT);
|
634 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
635 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
636 | 604be200 | Shin-ichiro KAWASAKI | static void sm501_2d_operation(SM501State * s) |
637 | 604be200 | Shin-ichiro KAWASAKI | { |
638 | 604be200 | Shin-ichiro KAWASAKI | /* obtain operation parameters */
|
639 | 604be200 | Shin-ichiro KAWASAKI | int operation = (s->twoD_control >> 16) & 0x1f; |
640 | 07d8a50c | Aurelien Jarno | int rtl = s->twoD_control & 0x8000000; |
641 | 07d8a50c | Aurelien Jarno | int src_x = (s->twoD_source >> 16) & 0x01FFF; |
642 | 07d8a50c | Aurelien Jarno | int src_y = s->twoD_source & 0xFFFF; |
643 | 604be200 | Shin-ichiro KAWASAKI | int dst_x = (s->twoD_destination >> 16) & 0x01FFF; |
644 | 604be200 | Shin-ichiro KAWASAKI | int dst_y = s->twoD_destination & 0xFFFF; |
645 | 604be200 | Shin-ichiro KAWASAKI | int operation_width = (s->twoD_dimension >> 16) & 0x1FFF; |
646 | 604be200 | Shin-ichiro KAWASAKI | int operation_height = s->twoD_dimension & 0xFFFF; |
647 | 604be200 | Shin-ichiro KAWASAKI | uint32_t color = s->twoD_foreground; |
648 | 604be200 | Shin-ichiro KAWASAKI | int format_flags = (s->twoD_stretch >> 20) & 0x3; |
649 | 604be200 | Shin-ichiro KAWASAKI | int addressing = (s->twoD_stretch >> 16) & 0xF; |
650 | 604be200 | Shin-ichiro KAWASAKI | |
651 | 604be200 | Shin-ichiro KAWASAKI | /* get frame buffer info */
|
652 | 604be200 | Shin-ichiro KAWASAKI | uint8_t * src = s->local_mem + (s->twoD_source_base & 0x03FFFFFF);
|
653 | 604be200 | Shin-ichiro KAWASAKI | uint8_t * dst = s->local_mem + (s->twoD_destination_base & 0x03FFFFFF);
|
654 | 07d8a50c | Aurelien Jarno | int src_width = (s->dc_crt_h_total & 0x00000FFF) + 1; |
655 | 604be200 | Shin-ichiro KAWASAKI | int dst_width = (s->dc_crt_h_total & 0x00000FFF) + 1; |
656 | 604be200 | Shin-ichiro KAWASAKI | |
657 | 604be200 | Shin-ichiro KAWASAKI | if (addressing != 0x0) { |
658 | 604be200 | Shin-ichiro KAWASAKI | printf("%s: only XY addressing is supported.\n", __func__);
|
659 | 604be200 | Shin-ichiro KAWASAKI | abort(); |
660 | 604be200 | Shin-ichiro KAWASAKI | } |
661 | 604be200 | Shin-ichiro KAWASAKI | |
662 | 604be200 | Shin-ichiro KAWASAKI | if ((s->twoD_source_base & 0x08000000) || |
663 | 604be200 | Shin-ichiro KAWASAKI | (s->twoD_destination_base & 0x08000000)) {
|
664 | 604be200 | Shin-ichiro KAWASAKI | printf("%s: only local memory is supported.\n", __func__);
|
665 | 604be200 | Shin-ichiro KAWASAKI | abort(); |
666 | 604be200 | Shin-ichiro KAWASAKI | } |
667 | 604be200 | Shin-ichiro KAWASAKI | |
668 | 604be200 | Shin-ichiro KAWASAKI | switch (operation) {
|
669 | 07d8a50c | Aurelien Jarno | case 0x00: /* copy area */ |
670 | 07d8a50c | Aurelien Jarno | #define COPY_AREA(_bpp, _pixel_type, rtl) { \
|
671 | 07d8a50c | Aurelien Jarno | int y, x, index_d, index_s; \
|
672 | 07d8a50c | Aurelien Jarno | for (y = 0; y < operation_height; y++) { \ |
673 | 07d8a50c | Aurelien Jarno | for (x = 0; x < operation_width; x++) { \ |
674 | 07d8a50c | Aurelien Jarno | if (rtl) { \
|
675 | 07d8a50c | Aurelien Jarno | index_s = ((src_y - y) * src_width + src_x - x) * _bpp; \ |
676 | 07d8a50c | Aurelien Jarno | index_d = ((dst_y - y) * dst_width + dst_x - x) * _bpp; \ |
677 | 07d8a50c | Aurelien Jarno | } else { \
|
678 | 07d8a50c | Aurelien Jarno | index_s = ((src_y + y) * src_width + src_x + x) * _bpp; \ |
679 | 07d8a50c | Aurelien Jarno | index_d = ((dst_y + y) * dst_width + dst_x + x) * _bpp; \ |
680 | 07d8a50c | Aurelien Jarno | } \ |
681 | 07d8a50c | Aurelien Jarno | *(_pixel_type*)&dst[index_d] = *(_pixel_type*)&src[index_s];\ |
682 | 07d8a50c | Aurelien Jarno | } \ |
683 | 07d8a50c | Aurelien Jarno | } \ |
684 | 07d8a50c | Aurelien Jarno | } |
685 | 07d8a50c | Aurelien Jarno | switch (format_flags) {
|
686 | 07d8a50c | Aurelien Jarno | case 0: |
687 | 07d8a50c | Aurelien Jarno | COPY_AREA(1, uint8_t, rtl);
|
688 | 07d8a50c | Aurelien Jarno | break;
|
689 | 07d8a50c | Aurelien Jarno | case 1: |
690 | 07d8a50c | Aurelien Jarno | COPY_AREA(2, uint16_t, rtl);
|
691 | 07d8a50c | Aurelien Jarno | break;
|
692 | 07d8a50c | Aurelien Jarno | case 2: |
693 | 07d8a50c | Aurelien Jarno | COPY_AREA(4, uint32_t, rtl);
|
694 | 07d8a50c | Aurelien Jarno | break;
|
695 | 07d8a50c | Aurelien Jarno | } |
696 | 07d8a50c | Aurelien Jarno | break;
|
697 | 604be200 | Shin-ichiro KAWASAKI | |
698 | 07d8a50c | Aurelien Jarno | case 0x01: /* fill rectangle */ |
699 | 604be200 | Shin-ichiro KAWASAKI | #define FILL_RECT(_bpp, _pixel_type) { \
|
700 | 604be200 | Shin-ichiro KAWASAKI | int y, x; \
|
701 | 604be200 | Shin-ichiro KAWASAKI | for (y = 0; y < operation_height; y++) { \ |
702 | 604be200 | Shin-ichiro KAWASAKI | for (x = 0; x < operation_width; x++) { \ |
703 | 604be200 | Shin-ichiro KAWASAKI | int index = ((dst_y + y) * dst_width + dst_x + x) * _bpp; \
|
704 | 604be200 | Shin-ichiro KAWASAKI | *(_pixel_type*)&dst[index] = (_pixel_type)color; \ |
705 | 604be200 | Shin-ichiro KAWASAKI | } \ |
706 | 604be200 | Shin-ichiro KAWASAKI | } \ |
707 | 604be200 | Shin-ichiro KAWASAKI | } |
708 | 604be200 | Shin-ichiro KAWASAKI | |
709 | 604be200 | Shin-ichiro KAWASAKI | switch (format_flags) {
|
710 | 604be200 | Shin-ichiro KAWASAKI | case 0: |
711 | 604be200 | Shin-ichiro KAWASAKI | FILL_RECT(1, uint8_t);
|
712 | 604be200 | Shin-ichiro KAWASAKI | break;
|
713 | 604be200 | Shin-ichiro KAWASAKI | case 1: |
714 | 604be200 | Shin-ichiro KAWASAKI | FILL_RECT(2, uint16_t);
|
715 | 604be200 | Shin-ichiro KAWASAKI | break;
|
716 | 604be200 | Shin-ichiro KAWASAKI | case 2: |
717 | 604be200 | Shin-ichiro KAWASAKI | FILL_RECT(4, uint32_t);
|
718 | 604be200 | Shin-ichiro KAWASAKI | break;
|
719 | 604be200 | Shin-ichiro KAWASAKI | } |
720 | 604be200 | Shin-ichiro KAWASAKI | break;
|
721 | 604be200 | Shin-ichiro KAWASAKI | |
722 | 604be200 | Shin-ichiro KAWASAKI | default:
|
723 | 604be200 | Shin-ichiro KAWASAKI | printf("non-implemented SM501 2D operation. %d\n", operation);
|
724 | 604be200 | Shin-ichiro KAWASAKI | abort(); |
725 | 604be200 | Shin-ichiro KAWASAKI | break;
|
726 | 604be200 | Shin-ichiro KAWASAKI | } |
727 | 604be200 | Shin-ichiro KAWASAKI | } |
728 | 604be200 | Shin-ichiro KAWASAKI | |
729 | 25793bfa | Avi Kivity | static uint64_t sm501_system_config_read(void *opaque, target_phys_addr_t addr, |
730 | 25793bfa | Avi Kivity | unsigned size)
|
731 | ffd39257 | blueswir1 | { |
732 | ffd39257 | blueswir1 | SM501State * s = (SM501State *)opaque; |
733 | ffd39257 | blueswir1 | uint32_t ret = 0;
|
734 | 8da3ff18 | pbrook | SM501_DPRINTF("sm501 system config regs : read addr=%x\n", (int)addr); |
735 | ffd39257 | blueswir1 | |
736 | 8da3ff18 | pbrook | switch(addr) {
|
737 | ffd39257 | blueswir1 | case SM501_SYSTEM_CONTROL:
|
738 | ffd39257 | blueswir1 | ret = s->system_control; |
739 | ffd39257 | blueswir1 | break;
|
740 | ffd39257 | blueswir1 | case SM501_MISC_CONTROL:
|
741 | ffd39257 | blueswir1 | ret = s->misc_control; |
742 | ffd39257 | blueswir1 | break;
|
743 | ffd39257 | blueswir1 | case SM501_GPIO31_0_CONTROL:
|
744 | ffd39257 | blueswir1 | ret = s->gpio_31_0_control; |
745 | ffd39257 | blueswir1 | break;
|
746 | ffd39257 | blueswir1 | case SM501_GPIO63_32_CONTROL:
|
747 | ffd39257 | blueswir1 | ret = s->gpio_63_32_control; |
748 | ffd39257 | blueswir1 | break;
|
749 | ffd39257 | blueswir1 | case SM501_DEVICEID:
|
750 | ffd39257 | blueswir1 | ret = 0x050100A0;
|
751 | ffd39257 | blueswir1 | break;
|
752 | ffd39257 | blueswir1 | case SM501_DRAM_CONTROL:
|
753 | ffd39257 | blueswir1 | ret = (s->dram_control & 0x07F107C0) | s->local_mem_size_index << 13; |
754 | ffd39257 | blueswir1 | break;
|
755 | ffd39257 | blueswir1 | case SM501_IRQ_MASK:
|
756 | ffd39257 | blueswir1 | ret = s->irq_mask; |
757 | ffd39257 | blueswir1 | break;
|
758 | ffd39257 | blueswir1 | case SM501_MISC_TIMING:
|
759 | ffd39257 | blueswir1 | /* TODO : simulate gate control */
|
760 | ffd39257 | blueswir1 | ret = s->misc_timing; |
761 | ffd39257 | blueswir1 | break;
|
762 | ffd39257 | blueswir1 | case SM501_CURRENT_GATE:
|
763 | ffd39257 | blueswir1 | /* TODO : simulate gate control */
|
764 | ffd39257 | blueswir1 | ret = 0x00021807;
|
765 | ffd39257 | blueswir1 | break;
|
766 | ffd39257 | blueswir1 | case SM501_CURRENT_CLOCK:
|
767 | ffd39257 | blueswir1 | ret = 0x2A1A0A09;
|
768 | ffd39257 | blueswir1 | break;
|
769 | ffd39257 | blueswir1 | case SM501_POWER_MODE_CONTROL:
|
770 | ffd39257 | blueswir1 | ret = s->power_mode_control; |
771 | ffd39257 | blueswir1 | break;
|
772 | ffd39257 | blueswir1 | |
773 | ffd39257 | blueswir1 | default:
|
774 | ffd39257 | blueswir1 | printf("sm501 system config : not implemented register read."
|
775 | 8da3ff18 | pbrook | " addr=%x\n", (int)addr); |
776 | 43dc2a64 | Blue Swirl | abort(); |
777 | ffd39257 | blueswir1 | } |
778 | ffd39257 | blueswir1 | |
779 | ffd39257 | blueswir1 | return ret;
|
780 | ffd39257 | blueswir1 | } |
781 | ffd39257 | blueswir1 | |
782 | 25793bfa | Avi Kivity | static void sm501_system_config_write(void *opaque, target_phys_addr_t addr, |
783 | 25793bfa | Avi Kivity | uint64_t value, unsigned size)
|
784 | ffd39257 | blueswir1 | { |
785 | ffd39257 | blueswir1 | SM501State * s = (SM501State *)opaque; |
786 | 8da3ff18 | pbrook | SM501_DPRINTF("sm501 system config regs : write addr=%x, val=%x\n",
|
787 | 25793bfa | Avi Kivity | (uint32_t)addr, (uint32_t)value); |
788 | ffd39257 | blueswir1 | |
789 | 8da3ff18 | pbrook | switch(addr) {
|
790 | ffd39257 | blueswir1 | case SM501_SYSTEM_CONTROL:
|
791 | ffd39257 | blueswir1 | s->system_control = value & 0xE300B8F7;
|
792 | ffd39257 | blueswir1 | break;
|
793 | ffd39257 | blueswir1 | case SM501_MISC_CONTROL:
|
794 | ffd39257 | blueswir1 | s->misc_control = value & 0xFF7FFF20;
|
795 | ffd39257 | blueswir1 | break;
|
796 | ffd39257 | blueswir1 | case SM501_GPIO31_0_CONTROL:
|
797 | ffd39257 | blueswir1 | s->gpio_31_0_control = value; |
798 | ffd39257 | blueswir1 | break;
|
799 | ffd39257 | blueswir1 | case SM501_GPIO63_32_CONTROL:
|
800 | ffd39257 | blueswir1 | s->gpio_63_32_control = value; |
801 | ffd39257 | blueswir1 | break;
|
802 | ffd39257 | blueswir1 | case SM501_DRAM_CONTROL:
|
803 | ffd39257 | blueswir1 | s->local_mem_size_index = (value >> 13) & 0x7; |
804 | ffd39257 | blueswir1 | /* rODO : check validity of size change */
|
805 | ffd39257 | blueswir1 | s->dram_control |= value & 0x7FFFFFC3;
|
806 | ffd39257 | blueswir1 | break;
|
807 | ffd39257 | blueswir1 | case SM501_IRQ_MASK:
|
808 | ffd39257 | blueswir1 | s->irq_mask = value; |
809 | ffd39257 | blueswir1 | break;
|
810 | ffd39257 | blueswir1 | case SM501_MISC_TIMING:
|
811 | ffd39257 | blueswir1 | s->misc_timing = value & 0xF31F1FFF;
|
812 | ffd39257 | blueswir1 | break;
|
813 | ffd39257 | blueswir1 | case SM501_POWER_MODE_0_GATE:
|
814 | ffd39257 | blueswir1 | case SM501_POWER_MODE_1_GATE:
|
815 | ffd39257 | blueswir1 | case SM501_POWER_MODE_0_CLOCK:
|
816 | ffd39257 | blueswir1 | case SM501_POWER_MODE_1_CLOCK:
|
817 | ffd39257 | blueswir1 | /* TODO : simulate gate & clock control */
|
818 | ffd39257 | blueswir1 | break;
|
819 | ffd39257 | blueswir1 | case SM501_POWER_MODE_CONTROL:
|
820 | ffd39257 | blueswir1 | s->power_mode_control = value & 0x00000003;
|
821 | ffd39257 | blueswir1 | break;
|
822 | ffd39257 | blueswir1 | |
823 | ffd39257 | blueswir1 | default:
|
824 | ffd39257 | blueswir1 | printf("sm501 system config : not implemented register write."
|
825 | 25793bfa | Avi Kivity | " addr=%x, val=%x\n", (int)addr, (uint32_t)value); |
826 | 43dc2a64 | Blue Swirl | abort(); |
827 | ffd39257 | blueswir1 | } |
828 | ffd39257 | blueswir1 | } |
829 | ffd39257 | blueswir1 | |
830 | 25793bfa | Avi Kivity | static const MemoryRegionOps sm501_system_config_ops = { |
831 | 25793bfa | Avi Kivity | .read = sm501_system_config_read, |
832 | 25793bfa | Avi Kivity | .write = sm501_system_config_write, |
833 | 25793bfa | Avi Kivity | .valid = { |
834 | 25793bfa | Avi Kivity | .min_access_size = 4,
|
835 | 25793bfa | Avi Kivity | .max_access_size = 4,
|
836 | 25793bfa | Avi Kivity | }, |
837 | 25793bfa | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
838 | ffd39257 | blueswir1 | }; |
839 | ffd39257 | blueswir1 | |
840 | c227f099 | Anthony Liguori | static uint32_t sm501_palette_read(void *opaque, target_phys_addr_t addr) |
841 | 486579de | balrog | { |
842 | 486579de | balrog | SM501State * s = (SM501State *)opaque; |
843 | 486579de | balrog | SM501_DPRINTF("sm501 palette read addr=%x\n", (int)addr); |
844 | 486579de | balrog | |
845 | 486579de | balrog | /* TODO : consider BYTE/WORD access */
|
846 | 486579de | balrog | /* TODO : consider endian */
|
847 | 486579de | balrog | |
848 | 45416789 | Blue Swirl | assert(range_covers_byte(0, 0x400 * 3, addr)); |
849 | 486579de | balrog | return *(uint32_t*)&s->dc_palette[addr];
|
850 | 486579de | balrog | } |
851 | 486579de | balrog | |
852 | 486579de | balrog | static void sm501_palette_write(void *opaque, |
853 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
854 | 486579de | balrog | { |
855 | 486579de | balrog | SM501State * s = (SM501State *)opaque; |
856 | 486579de | balrog | SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",
|
857 | 486579de | balrog | (int)addr, value);
|
858 | 486579de | balrog | |
859 | 486579de | balrog | /* TODO : consider BYTE/WORD access */
|
860 | 486579de | balrog | /* TODO : consider endian */
|
861 | 486579de | balrog | |
862 | 45416789 | Blue Swirl | assert(range_covers_byte(0, 0x400 * 3, addr)); |
863 | 486579de | balrog | *(uint32_t*)&s->dc_palette[addr] = value; |
864 | 486579de | balrog | } |
865 | 486579de | balrog | |
866 | 25793bfa | Avi Kivity | static uint64_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr, |
867 | 25793bfa | Avi Kivity | unsigned size)
|
868 | ffd39257 | blueswir1 | { |
869 | ffd39257 | blueswir1 | SM501State * s = (SM501State *)opaque; |
870 | ffd39257 | blueswir1 | uint32_t ret = 0;
|
871 | 8da3ff18 | pbrook | SM501_DPRINTF("sm501 disp ctrl regs : read addr=%x\n", (int)addr); |
872 | ffd39257 | blueswir1 | |
873 | 8da3ff18 | pbrook | switch(addr) {
|
874 | ffd39257 | blueswir1 | |
875 | ffd39257 | blueswir1 | case SM501_DC_PANEL_CONTROL:
|
876 | ffd39257 | blueswir1 | ret = s->dc_panel_control; |
877 | ffd39257 | blueswir1 | break;
|
878 | ffd39257 | blueswir1 | case SM501_DC_PANEL_PANNING_CONTROL:
|
879 | ffd39257 | blueswir1 | ret = s->dc_panel_panning_control; |
880 | ffd39257 | blueswir1 | break;
|
881 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_ADDR:
|
882 | ffd39257 | blueswir1 | ret = s->dc_panel_fb_addr; |
883 | ffd39257 | blueswir1 | break;
|
884 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_OFFSET:
|
885 | ffd39257 | blueswir1 | ret = s->dc_panel_fb_offset; |
886 | ffd39257 | blueswir1 | break;
|
887 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_WIDTH:
|
888 | ffd39257 | blueswir1 | ret = s->dc_panel_fb_width; |
889 | ffd39257 | blueswir1 | break;
|
890 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_HEIGHT:
|
891 | ffd39257 | blueswir1 | ret = s->dc_panel_fb_height; |
892 | ffd39257 | blueswir1 | break;
|
893 | ffd39257 | blueswir1 | case SM501_DC_PANEL_TL_LOC:
|
894 | ffd39257 | blueswir1 | ret = s->dc_panel_tl_location; |
895 | ffd39257 | blueswir1 | break;
|
896 | ffd39257 | blueswir1 | case SM501_DC_PANEL_BR_LOC:
|
897 | ffd39257 | blueswir1 | ret = s->dc_panel_br_location; |
898 | ffd39257 | blueswir1 | break;
|
899 | ffd39257 | blueswir1 | |
900 | ffd39257 | blueswir1 | case SM501_DC_PANEL_H_TOT:
|
901 | ffd39257 | blueswir1 | ret = s->dc_panel_h_total; |
902 | ffd39257 | blueswir1 | break;
|
903 | ffd39257 | blueswir1 | case SM501_DC_PANEL_H_SYNC:
|
904 | ffd39257 | blueswir1 | ret = s->dc_panel_h_sync; |
905 | ffd39257 | blueswir1 | break;
|
906 | ffd39257 | blueswir1 | case SM501_DC_PANEL_V_TOT:
|
907 | ffd39257 | blueswir1 | ret = s->dc_panel_v_total; |
908 | ffd39257 | blueswir1 | break;
|
909 | ffd39257 | blueswir1 | case SM501_DC_PANEL_V_SYNC:
|
910 | ffd39257 | blueswir1 | ret = s->dc_panel_v_sync; |
911 | ffd39257 | blueswir1 | break;
|
912 | ffd39257 | blueswir1 | |
913 | ffd39257 | blueswir1 | case SM501_DC_CRT_CONTROL:
|
914 | ffd39257 | blueswir1 | ret = s->dc_crt_control; |
915 | ffd39257 | blueswir1 | break;
|
916 | ffd39257 | blueswir1 | case SM501_DC_CRT_FB_ADDR:
|
917 | ffd39257 | blueswir1 | ret = s->dc_crt_fb_addr; |
918 | ffd39257 | blueswir1 | break;
|
919 | ffd39257 | blueswir1 | case SM501_DC_CRT_FB_OFFSET:
|
920 | ffd39257 | blueswir1 | ret = s->dc_crt_fb_offset; |
921 | ffd39257 | blueswir1 | break;
|
922 | ffd39257 | blueswir1 | case SM501_DC_CRT_H_TOT:
|
923 | ffd39257 | blueswir1 | ret = s->dc_crt_h_total; |
924 | ffd39257 | blueswir1 | break;
|
925 | ffd39257 | blueswir1 | case SM501_DC_CRT_H_SYNC:
|
926 | ffd39257 | blueswir1 | ret = s->dc_crt_h_sync; |
927 | ffd39257 | blueswir1 | break;
|
928 | ffd39257 | blueswir1 | case SM501_DC_CRT_V_TOT:
|
929 | ffd39257 | blueswir1 | ret = s->dc_crt_v_total; |
930 | ffd39257 | blueswir1 | break;
|
931 | ffd39257 | blueswir1 | case SM501_DC_CRT_V_SYNC:
|
932 | ffd39257 | blueswir1 | ret = s->dc_crt_v_sync; |
933 | ffd39257 | blueswir1 | break;
|
934 | ffd39257 | blueswir1 | |
935 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_ADDR:
|
936 | ffd39257 | blueswir1 | ret = s->dc_crt_hwc_addr; |
937 | ffd39257 | blueswir1 | break;
|
938 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_LOC:
|
939 | 0a4e7cd2 | Shin-ichiro KAWASAKI | ret = s->dc_crt_hwc_location; |
940 | ffd39257 | blueswir1 | break;
|
941 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_COLOR_1_2:
|
942 | 0a4e7cd2 | Shin-ichiro KAWASAKI | ret = s->dc_crt_hwc_color_1_2; |
943 | ffd39257 | blueswir1 | break;
|
944 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_COLOR_3:
|
945 | 0a4e7cd2 | Shin-ichiro KAWASAKI | ret = s->dc_crt_hwc_color_3; |
946 | ffd39257 | blueswir1 | break;
|
947 | ffd39257 | blueswir1 | |
948 | 486579de | balrog | case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4: |
949 | 486579de | balrog | ret = sm501_palette_read(opaque, addr - SM501_DC_PANEL_PALETTE); |
950 | 486579de | balrog | break;
|
951 | 486579de | balrog | |
952 | ffd39257 | blueswir1 | default:
|
953 | ffd39257 | blueswir1 | printf("sm501 disp ctrl : not implemented register read."
|
954 | 8da3ff18 | pbrook | " addr=%x\n", (int)addr); |
955 | 43dc2a64 | Blue Swirl | abort(); |
956 | ffd39257 | blueswir1 | } |
957 | ffd39257 | blueswir1 | |
958 | ffd39257 | blueswir1 | return ret;
|
959 | ffd39257 | blueswir1 | } |
960 | ffd39257 | blueswir1 | |
961 | 25793bfa | Avi Kivity | static void sm501_disp_ctrl_write(void *opaque, target_phys_addr_t addr, |
962 | 25793bfa | Avi Kivity | uint64_t value, unsigned size)
|
963 | ffd39257 | blueswir1 | { |
964 | ffd39257 | blueswir1 | SM501State * s = (SM501State *)opaque; |
965 | 8da3ff18 | pbrook | SM501_DPRINTF("sm501 disp ctrl regs : write addr=%x, val=%x\n",
|
966 | 25793bfa | Avi Kivity | (unsigned)addr, (unsigned)value); |
967 | ffd39257 | blueswir1 | |
968 | 8da3ff18 | pbrook | switch(addr) {
|
969 | ffd39257 | blueswir1 | case SM501_DC_PANEL_CONTROL:
|
970 | ffd39257 | blueswir1 | s->dc_panel_control = value & 0x0FFF73FF;
|
971 | ffd39257 | blueswir1 | break;
|
972 | ffd39257 | blueswir1 | case SM501_DC_PANEL_PANNING_CONTROL:
|
973 | ffd39257 | blueswir1 | s->dc_panel_panning_control = value & 0xFF3FFF3F;
|
974 | ffd39257 | blueswir1 | break;
|
975 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_ADDR:
|
976 | ffd39257 | blueswir1 | s->dc_panel_fb_addr = value & 0x8FFFFFF0;
|
977 | ffd39257 | blueswir1 | break;
|
978 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_OFFSET:
|
979 | ffd39257 | blueswir1 | s->dc_panel_fb_offset = value & 0x3FF03FF0;
|
980 | ffd39257 | blueswir1 | break;
|
981 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_WIDTH:
|
982 | ffd39257 | blueswir1 | s->dc_panel_fb_width = value & 0x0FFF0FFF;
|
983 | ffd39257 | blueswir1 | break;
|
984 | ffd39257 | blueswir1 | case SM501_DC_PANEL_FB_HEIGHT:
|
985 | ffd39257 | blueswir1 | s->dc_panel_fb_height = value & 0x0FFF0FFF;
|
986 | ffd39257 | blueswir1 | break;
|
987 | ffd39257 | blueswir1 | case SM501_DC_PANEL_TL_LOC:
|
988 | ffd39257 | blueswir1 | s->dc_panel_tl_location = value & 0x07FF07FF;
|
989 | ffd39257 | blueswir1 | break;
|
990 | ffd39257 | blueswir1 | case SM501_DC_PANEL_BR_LOC:
|
991 | ffd39257 | blueswir1 | s->dc_panel_br_location = value & 0x07FF07FF;
|
992 | ffd39257 | blueswir1 | break;
|
993 | ffd39257 | blueswir1 | |
994 | ffd39257 | blueswir1 | case SM501_DC_PANEL_H_TOT:
|
995 | ffd39257 | blueswir1 | s->dc_panel_h_total = value & 0x0FFF0FFF;
|
996 | ffd39257 | blueswir1 | break;
|
997 | ffd39257 | blueswir1 | case SM501_DC_PANEL_H_SYNC:
|
998 | ffd39257 | blueswir1 | s->dc_panel_h_sync = value & 0x00FF0FFF;
|
999 | ffd39257 | blueswir1 | break;
|
1000 | ffd39257 | blueswir1 | case SM501_DC_PANEL_V_TOT:
|
1001 | ffd39257 | blueswir1 | s->dc_panel_v_total = value & 0x0FFF0FFF;
|
1002 | ffd39257 | blueswir1 | break;
|
1003 | ffd39257 | blueswir1 | case SM501_DC_PANEL_V_SYNC:
|
1004 | ffd39257 | blueswir1 | s->dc_panel_v_sync = value & 0x003F0FFF;
|
1005 | ffd39257 | blueswir1 | break;
|
1006 | ffd39257 | blueswir1 | |
1007 | ffd39257 | blueswir1 | case SM501_DC_PANEL_HWC_ADDR:
|
1008 | ffd39257 | blueswir1 | s->dc_panel_hwc_addr = value & 0x8FFFFFF0;
|
1009 | ffd39257 | blueswir1 | break;
|
1010 | ffd39257 | blueswir1 | case SM501_DC_PANEL_HWC_LOC:
|
1011 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_panel_hwc_location = value & 0x0FFF0FFF;
|
1012 | ffd39257 | blueswir1 | break;
|
1013 | ffd39257 | blueswir1 | case SM501_DC_PANEL_HWC_COLOR_1_2:
|
1014 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_panel_hwc_color_1_2 = value; |
1015 | ffd39257 | blueswir1 | break;
|
1016 | ffd39257 | blueswir1 | case SM501_DC_PANEL_HWC_COLOR_3:
|
1017 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_panel_hwc_color_3 = value & 0x0000FFFF;
|
1018 | ffd39257 | blueswir1 | break;
|
1019 | ffd39257 | blueswir1 | |
1020 | ffd39257 | blueswir1 | case SM501_DC_CRT_CONTROL:
|
1021 | ffd39257 | blueswir1 | s->dc_crt_control = value & 0x0003FFFF;
|
1022 | ffd39257 | blueswir1 | break;
|
1023 | ffd39257 | blueswir1 | case SM501_DC_CRT_FB_ADDR:
|
1024 | ffd39257 | blueswir1 | s->dc_crt_fb_addr = value & 0x8FFFFFF0;
|
1025 | ffd39257 | blueswir1 | break;
|
1026 | ffd39257 | blueswir1 | case SM501_DC_CRT_FB_OFFSET:
|
1027 | ffd39257 | blueswir1 | s->dc_crt_fb_offset = value & 0x3FF03FF0;
|
1028 | ffd39257 | blueswir1 | break;
|
1029 | ffd39257 | blueswir1 | case SM501_DC_CRT_H_TOT:
|
1030 | ffd39257 | blueswir1 | s->dc_crt_h_total = value & 0x0FFF0FFF;
|
1031 | ffd39257 | blueswir1 | break;
|
1032 | ffd39257 | blueswir1 | case SM501_DC_CRT_H_SYNC:
|
1033 | ffd39257 | blueswir1 | s->dc_crt_h_sync = value & 0x00FF0FFF;
|
1034 | ffd39257 | blueswir1 | break;
|
1035 | ffd39257 | blueswir1 | case SM501_DC_CRT_V_TOT:
|
1036 | ffd39257 | blueswir1 | s->dc_crt_v_total = value & 0x0FFF0FFF;
|
1037 | ffd39257 | blueswir1 | break;
|
1038 | ffd39257 | blueswir1 | case SM501_DC_CRT_V_SYNC:
|
1039 | ffd39257 | blueswir1 | s->dc_crt_v_sync = value & 0x003F0FFF;
|
1040 | ffd39257 | blueswir1 | break;
|
1041 | ffd39257 | blueswir1 | |
1042 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_ADDR:
|
1043 | ffd39257 | blueswir1 | s->dc_crt_hwc_addr = value & 0x8FFFFFF0;
|
1044 | ffd39257 | blueswir1 | break;
|
1045 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_LOC:
|
1046 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_crt_hwc_location = value & 0x0FFF0FFF;
|
1047 | ffd39257 | blueswir1 | break;
|
1048 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_COLOR_1_2:
|
1049 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_crt_hwc_color_1_2 = value; |
1050 | ffd39257 | blueswir1 | break;
|
1051 | ffd39257 | blueswir1 | case SM501_DC_CRT_HWC_COLOR_3:
|
1052 | 0a4e7cd2 | Shin-ichiro KAWASAKI | s->dc_crt_hwc_color_3 = value & 0x0000FFFF;
|
1053 | ffd39257 | blueswir1 | break;
|
1054 | ffd39257 | blueswir1 | |
1055 | 486579de | balrog | case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4: |
1056 | 486579de | balrog | sm501_palette_write(opaque, addr - SM501_DC_PANEL_PALETTE, value); |
1057 | 486579de | balrog | break;
|
1058 | 486579de | balrog | |
1059 | ffd39257 | blueswir1 | default:
|
1060 | ffd39257 | blueswir1 | printf("sm501 disp ctrl : not implemented register write."
|
1061 | 25793bfa | Avi Kivity | " addr=%x, val=%x\n", (int)addr, (unsigned)value); |
1062 | 43dc2a64 | Blue Swirl | abort(); |
1063 | ffd39257 | blueswir1 | } |
1064 | ffd39257 | blueswir1 | } |
1065 | ffd39257 | blueswir1 | |
1066 | 25793bfa | Avi Kivity | static const MemoryRegionOps sm501_disp_ctrl_ops = { |
1067 | 25793bfa | Avi Kivity | .read = sm501_disp_ctrl_read, |
1068 | 25793bfa | Avi Kivity | .write = sm501_disp_ctrl_write, |
1069 | 25793bfa | Avi Kivity | .valid = { |
1070 | 25793bfa | Avi Kivity | .min_access_size = 4,
|
1071 | 25793bfa | Avi Kivity | .max_access_size = 4,
|
1072 | 25793bfa | Avi Kivity | }, |
1073 | 25793bfa | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
1074 | ffd39257 | blueswir1 | }; |
1075 | ffd39257 | blueswir1 | |
1076 | 25793bfa | Avi Kivity | static uint64_t sm501_2d_engine_read(void *opaque, target_phys_addr_t addr, |
1077 | 25793bfa | Avi Kivity | unsigned size)
|
1078 | 604be200 | Shin-ichiro KAWASAKI | { |
1079 | 604be200 | Shin-ichiro KAWASAKI | SM501State * s = (SM501State *)opaque; |
1080 | 604be200 | Shin-ichiro KAWASAKI | uint32_t ret = 0;
|
1081 | 604be200 | Shin-ichiro KAWASAKI | SM501_DPRINTF("sm501 2d engine regs : read addr=%x\n", (int)addr); |
1082 | 604be200 | Shin-ichiro KAWASAKI | |
1083 | 604be200 | Shin-ichiro KAWASAKI | switch(addr) {
|
1084 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_SOURCE_BASE:
|
1085 | 604be200 | Shin-ichiro KAWASAKI | ret = s->twoD_source_base; |
1086 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1087 | 604be200 | Shin-ichiro KAWASAKI | default:
|
1088 | 604be200 | Shin-ichiro KAWASAKI | printf("sm501 disp ctrl : not implemented register read."
|
1089 | 604be200 | Shin-ichiro KAWASAKI | " addr=%x\n", (int)addr); |
1090 | 604be200 | Shin-ichiro KAWASAKI | abort(); |
1091 | 604be200 | Shin-ichiro KAWASAKI | } |
1092 | 604be200 | Shin-ichiro KAWASAKI | |
1093 | 604be200 | Shin-ichiro KAWASAKI | return ret;
|
1094 | 604be200 | Shin-ichiro KAWASAKI | } |
1095 | 604be200 | Shin-ichiro KAWASAKI | |
1096 | 25793bfa | Avi Kivity | static void sm501_2d_engine_write(void *opaque, target_phys_addr_t addr, |
1097 | 25793bfa | Avi Kivity | uint64_t value, unsigned size)
|
1098 | 604be200 | Shin-ichiro KAWASAKI | { |
1099 | 604be200 | Shin-ichiro KAWASAKI | SM501State * s = (SM501State *)opaque; |
1100 | 604be200 | Shin-ichiro KAWASAKI | SM501_DPRINTF("sm501 2d engine regs : write addr=%x, val=%x\n",
|
1101 | 25793bfa | Avi Kivity | (unsigned)addr, (unsigned)value); |
1102 | 604be200 | Shin-ichiro KAWASAKI | |
1103 | 604be200 | Shin-ichiro KAWASAKI | switch(addr) {
|
1104 | 07d8a50c | Aurelien Jarno | case SM501_2D_SOURCE:
|
1105 | 07d8a50c | Aurelien Jarno | s->twoD_source = value; |
1106 | 07d8a50c | Aurelien Jarno | break;
|
1107 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_DESTINATION:
|
1108 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_destination = value; |
1109 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1110 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_DIMENSION:
|
1111 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_dimension = value; |
1112 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1113 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_CONTROL:
|
1114 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_control = value; |
1115 | 604be200 | Shin-ichiro KAWASAKI | |
1116 | 604be200 | Shin-ichiro KAWASAKI | /* do 2d operation if start flag is set. */
|
1117 | 604be200 | Shin-ichiro KAWASAKI | if (value & 0x80000000) { |
1118 | 604be200 | Shin-ichiro KAWASAKI | sm501_2d_operation(s); |
1119 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_control &= ~0x80000000; /* start flag down */ |
1120 | 604be200 | Shin-ichiro KAWASAKI | } |
1121 | 604be200 | Shin-ichiro KAWASAKI | |
1122 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1123 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_PITCH:
|
1124 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_pitch = value; |
1125 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1126 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_FOREGROUND:
|
1127 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_foreground = value; |
1128 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1129 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_STRETCH:
|
1130 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_stretch = value; |
1131 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1132 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_COLOR_COMPARE_MASK:
|
1133 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_color_compare_mask = value; |
1134 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1135 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_MASK:
|
1136 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_mask = value; |
1137 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1138 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_WINDOW_WIDTH:
|
1139 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_window_width = value; |
1140 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1141 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_SOURCE_BASE:
|
1142 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_source_base = value; |
1143 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1144 | 604be200 | Shin-ichiro KAWASAKI | case SM501_2D_DESTINATION_BASE:
|
1145 | 604be200 | Shin-ichiro KAWASAKI | s->twoD_destination_base = value; |
1146 | 604be200 | Shin-ichiro KAWASAKI | break;
|
1147 | 604be200 | Shin-ichiro KAWASAKI | default:
|
1148 | 604be200 | Shin-ichiro KAWASAKI | printf("sm501 2d engine : not implemented register write."
|
1149 | 25793bfa | Avi Kivity | " addr=%x, val=%x\n", (int)addr, (unsigned)value); |
1150 | 604be200 | Shin-ichiro KAWASAKI | abort(); |
1151 | 604be200 | Shin-ichiro KAWASAKI | } |
1152 | 604be200 | Shin-ichiro KAWASAKI | } |
1153 | 604be200 | Shin-ichiro KAWASAKI | |
1154 | 25793bfa | Avi Kivity | static const MemoryRegionOps sm501_2d_engine_ops = { |
1155 | 25793bfa | Avi Kivity | .read = sm501_2d_engine_read, |
1156 | 25793bfa | Avi Kivity | .write = sm501_2d_engine_write, |
1157 | 25793bfa | Avi Kivity | .valid = { |
1158 | 25793bfa | Avi Kivity | .min_access_size = 4,
|
1159 | 25793bfa | Avi Kivity | .max_access_size = 4,
|
1160 | 25793bfa | Avi Kivity | }, |
1161 | 25793bfa | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
1162 | 604be200 | Shin-ichiro KAWASAKI | }; |
1163 | 604be200 | Shin-ichiro KAWASAKI | |
1164 | ffd39257 | blueswir1 | /* draw line functions for all console modes */
|
1165 | ffd39257 | blueswir1 | |
1166 | ffd39257 | blueswir1 | #include "pixel_ops.h" |
1167 | ffd39257 | blueswir1 | |
1168 | ffd39257 | blueswir1 | typedef void draw_line_func(uint8_t *d, const uint8_t *s, |
1169 | ffd39257 | blueswir1 | int width, const uint32_t *pal); |
1170 | ffd39257 | blueswir1 | |
1171 | 0a4e7cd2 | Shin-ichiro KAWASAKI | typedef void draw_hwc_line_func(SM501State * s, int crt, uint8_t * palette, |
1172 | 0a4e7cd2 | Shin-ichiro KAWASAKI | int c_y, uint8_t *d, int width); |
1173 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1174 | ffd39257 | blueswir1 | #define DEPTH 8 |
1175 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1176 | ffd39257 | blueswir1 | |
1177 | ffd39257 | blueswir1 | #define DEPTH 15 |
1178 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1179 | ffd39257 | blueswir1 | |
1180 | ffd39257 | blueswir1 | #define BGR_FORMAT
|
1181 | ffd39257 | blueswir1 | #define DEPTH 15 |
1182 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1183 | ffd39257 | blueswir1 | |
1184 | ffd39257 | blueswir1 | #define DEPTH 16 |
1185 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1186 | ffd39257 | blueswir1 | |
1187 | ffd39257 | blueswir1 | #define BGR_FORMAT
|
1188 | ffd39257 | blueswir1 | #define DEPTH 16 |
1189 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1190 | ffd39257 | blueswir1 | |
1191 | ffd39257 | blueswir1 | #define DEPTH 32 |
1192 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1193 | ffd39257 | blueswir1 | |
1194 | ffd39257 | blueswir1 | #define BGR_FORMAT
|
1195 | ffd39257 | blueswir1 | #define DEPTH 32 |
1196 | ffd39257 | blueswir1 | #include "sm501_template.h" |
1197 | ffd39257 | blueswir1 | |
1198 | ffd39257 | blueswir1 | static draw_line_func * draw_line8_funcs[] = {
|
1199 | ffd39257 | blueswir1 | draw_line8_8, |
1200 | ffd39257 | blueswir1 | draw_line8_15, |
1201 | ffd39257 | blueswir1 | draw_line8_16, |
1202 | ffd39257 | blueswir1 | draw_line8_32, |
1203 | ffd39257 | blueswir1 | draw_line8_32bgr, |
1204 | ffd39257 | blueswir1 | draw_line8_15bgr, |
1205 | ffd39257 | blueswir1 | draw_line8_16bgr, |
1206 | ffd39257 | blueswir1 | }; |
1207 | ffd39257 | blueswir1 | |
1208 | ffd39257 | blueswir1 | static draw_line_func * draw_line16_funcs[] = {
|
1209 | ffd39257 | blueswir1 | draw_line16_8, |
1210 | ffd39257 | blueswir1 | draw_line16_15, |
1211 | ffd39257 | blueswir1 | draw_line16_16, |
1212 | ffd39257 | blueswir1 | draw_line16_32, |
1213 | ffd39257 | blueswir1 | draw_line16_32bgr, |
1214 | ffd39257 | blueswir1 | draw_line16_15bgr, |
1215 | ffd39257 | blueswir1 | draw_line16_16bgr, |
1216 | ffd39257 | blueswir1 | }; |
1217 | ffd39257 | blueswir1 | |
1218 | ffd39257 | blueswir1 | static draw_line_func * draw_line32_funcs[] = {
|
1219 | ffd39257 | blueswir1 | draw_line32_8, |
1220 | ffd39257 | blueswir1 | draw_line32_15, |
1221 | ffd39257 | blueswir1 | draw_line32_16, |
1222 | ffd39257 | blueswir1 | draw_line32_32, |
1223 | ffd39257 | blueswir1 | draw_line32_32bgr, |
1224 | ffd39257 | blueswir1 | draw_line32_15bgr, |
1225 | ffd39257 | blueswir1 | draw_line32_16bgr, |
1226 | ffd39257 | blueswir1 | }; |
1227 | ffd39257 | blueswir1 | |
1228 | 0a4e7cd2 | Shin-ichiro KAWASAKI | static draw_hwc_line_func * draw_hwc_line_funcs[] = {
|
1229 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_8, |
1230 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_15, |
1231 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_16, |
1232 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_32, |
1233 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_32bgr, |
1234 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_15bgr, |
1235 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_16bgr, |
1236 | 0a4e7cd2 | Shin-ichiro KAWASAKI | }; |
1237 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1238 | ffd39257 | blueswir1 | static inline int get_depth_index(DisplayState *s) |
1239 | ffd39257 | blueswir1 | { |
1240 | 8927bcfd | aliguori | switch(ds_get_bits_per_pixel(s)) {
|
1241 | ffd39257 | blueswir1 | default:
|
1242 | ffd39257 | blueswir1 | case 8: |
1243 | ffd39257 | blueswir1 | return 0; |
1244 | ffd39257 | blueswir1 | case 15: |
1245 | 8927bcfd | aliguori | return 1; |
1246 | ffd39257 | blueswir1 | case 16: |
1247 | 8927bcfd | aliguori | return 2; |
1248 | ffd39257 | blueswir1 | case 32: |
1249 | 7b5d76da | aliguori | if (is_surface_bgr(s->surface))
|
1250 | 7b5d76da | aliguori | return 4; |
1251 | 7b5d76da | aliguori | else
|
1252 | 7b5d76da | aliguori | return 3; |
1253 | ffd39257 | blueswir1 | } |
1254 | ffd39257 | blueswir1 | } |
1255 | ffd39257 | blueswir1 | |
1256 | ffd39257 | blueswir1 | static void sm501_draw_crt(SM501State * s) |
1257 | ffd39257 | blueswir1 | { |
1258 | ffd39257 | blueswir1 | int y;
|
1259 | ffd39257 | blueswir1 | int width = (s->dc_crt_h_total & 0x00000FFF) + 1; |
1260 | ffd39257 | blueswir1 | int height = (s->dc_crt_v_total & 0x00000FFF) + 1; |
1261 | ffd39257 | blueswir1 | |
1262 | ffd39257 | blueswir1 | uint8_t * src = s->local_mem; |
1263 | ffd39257 | blueswir1 | int src_bpp = 0; |
1264 | 8927bcfd | aliguori | int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0); |
1265 | ffd39257 | blueswir1 | uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE |
1266 | ffd39257 | blueswir1 | - SM501_DC_PANEL_PALETTE]; |
1267 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint8_t hwc_palette[3 * 3]; |
1268 | ffd39257 | blueswir1 | int ds_depth_index = get_depth_index(s->ds);
|
1269 | ffd39257 | blueswir1 | draw_line_func * draw_line = NULL;
|
1270 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line_func * draw_hwc_line = NULL;
|
1271 | ffd39257 | blueswir1 | int full_update = 0; |
1272 | ffd39257 | blueswir1 | int y_start = -1; |
1273 | 543c4c94 | Aurelien Jarno | ram_addr_t page_min = ~0l;
|
1274 | 543c4c94 | Aurelien Jarno | ram_addr_t page_max = 0l;
|
1275 | 25793bfa | Avi Kivity | ram_addr_t offset = 0;
|
1276 | ffd39257 | blueswir1 | |
1277 | ffd39257 | blueswir1 | /* choose draw_line function */
|
1278 | ffd39257 | blueswir1 | switch (s->dc_crt_control & 3) { |
1279 | ffd39257 | blueswir1 | case SM501_DC_CRT_CONTROL_8BPP:
|
1280 | ffd39257 | blueswir1 | src_bpp = 1;
|
1281 | ffd39257 | blueswir1 | draw_line = draw_line8_funcs[ds_depth_index]; |
1282 | ffd39257 | blueswir1 | break;
|
1283 | ffd39257 | blueswir1 | case SM501_DC_CRT_CONTROL_16BPP:
|
1284 | ffd39257 | blueswir1 | src_bpp = 2;
|
1285 | ffd39257 | blueswir1 | draw_line = draw_line16_funcs[ds_depth_index]; |
1286 | ffd39257 | blueswir1 | break;
|
1287 | ffd39257 | blueswir1 | case SM501_DC_CRT_CONTROL_32BPP:
|
1288 | ffd39257 | blueswir1 | src_bpp = 4;
|
1289 | ffd39257 | blueswir1 | draw_line = draw_line32_funcs[ds_depth_index]; |
1290 | ffd39257 | blueswir1 | break;
|
1291 | ffd39257 | blueswir1 | default:
|
1292 | ffd39257 | blueswir1 | printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
|
1293 | ffd39257 | blueswir1 | s->dc_crt_control); |
1294 | 43dc2a64 | Blue Swirl | abort(); |
1295 | ffd39257 | blueswir1 | break;
|
1296 | ffd39257 | blueswir1 | } |
1297 | ffd39257 | blueswir1 | |
1298 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /* set up to draw hardware cursor */
|
1299 | 0a4e7cd2 | Shin-ichiro KAWASAKI | if (is_hwc_enabled(s, 1)) { |
1300 | 0a4e7cd2 | Shin-ichiro KAWASAKI | int i;
|
1301 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1302 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /* get cursor palette */
|
1303 | 0a4e7cd2 | Shin-ichiro KAWASAKI | for (i = 0; i < 3; i++) { |
1304 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint16_t rgb565 = get_hwc_color(s, 1, i + 1); |
1305 | 0a4e7cd2 | Shin-ichiro KAWASAKI | hwc_palette[i * 3 + 0] = (rgb565 & 0xf800) >> 8; /* red */ |
1306 | 0a4e7cd2 | Shin-ichiro KAWASAKI | hwc_palette[i * 3 + 1] = (rgb565 & 0x07e0) >> 3; /* green */ |
1307 | 0a4e7cd2 | Shin-ichiro KAWASAKI | hwc_palette[i * 3 + 2] = (rgb565 & 0x001f) << 3; /* blue */ |
1308 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
1309 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1310 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /* choose cursor draw line function */
|
1311 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line = draw_hwc_line_funcs[ds_depth_index]; |
1312 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
1313 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1314 | ffd39257 | blueswir1 | /* adjust console size */
|
1315 | ffd39257 | blueswir1 | if (s->last_width != width || s->last_height != height) {
|
1316 | 3023f332 | aliguori | qemu_console_resize(s->ds, width, height); |
1317 | ffd39257 | blueswir1 | s->last_width = width; |
1318 | ffd39257 | blueswir1 | s->last_height = height; |
1319 | ffd39257 | blueswir1 | full_update = 1;
|
1320 | ffd39257 | blueswir1 | } |
1321 | ffd39257 | blueswir1 | |
1322 | ffd39257 | blueswir1 | /* draw each line according to conditions */
|
1323 | ffd39257 | blueswir1 | for (y = 0; y < height; y++) { |
1324 | 0a4e7cd2 | Shin-ichiro KAWASAKI | int update_hwc = draw_hwc_line ? within_hwc_y_range(s, y, 1) : 0; |
1325 | 0a4e7cd2 | Shin-ichiro KAWASAKI | int update = full_update || update_hwc;
|
1326 | cd7a45c9 | Blue Swirl | ram_addr_t page0 = offset; |
1327 | cd7a45c9 | Blue Swirl | ram_addr_t page1 = offset + width * src_bpp - 1;
|
1328 | ffd39257 | blueswir1 | |
1329 | ffd39257 | blueswir1 | /* check dirty flags for each line */
|
1330 | d1f3dd34 | Blue Swirl | update = memory_region_get_dirty(&s->local_mem_region, page0, |
1331 | d1f3dd34 | Blue Swirl | page1 - page0, DIRTY_MEMORY_VGA); |
1332 | ffd39257 | blueswir1 | |
1333 | ffd39257 | blueswir1 | /* draw line and change status */
|
1334 | ffd39257 | blueswir1 | if (update) {
|
1335 | 0a4e7cd2 | Shin-ichiro KAWASAKI | uint8_t * d = &(ds_get_data(s->ds)[y * width * dst_bpp]); |
1336 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1337 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /* draw graphics layer */
|
1338 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_line(d, src, width, palette); |
1339 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1340 | 0a4e7cd2 | Shin-ichiro KAWASAKI | /* draw haredware cursor */
|
1341 | 0a4e7cd2 | Shin-ichiro KAWASAKI | if (update_hwc) {
|
1342 | 0a4e7cd2 | Shin-ichiro KAWASAKI | draw_hwc_line(s, 1, hwc_palette, y - get_hwc_y(s, 1), d, width); |
1343 | 0a4e7cd2 | Shin-ichiro KAWASAKI | } |
1344 | 0a4e7cd2 | Shin-ichiro KAWASAKI | |
1345 | ffd39257 | blueswir1 | if (y_start < 0) |
1346 | ffd39257 | blueswir1 | y_start = y; |
1347 | ffd39257 | blueswir1 | if (page0 < page_min)
|
1348 | ffd39257 | blueswir1 | page_min = page0; |
1349 | ffd39257 | blueswir1 | if (page1 > page_max)
|
1350 | ffd39257 | blueswir1 | page_max = page1; |
1351 | ffd39257 | blueswir1 | } else {
|
1352 | ffd39257 | blueswir1 | if (y_start >= 0) { |
1353 | ffd39257 | blueswir1 | /* flush to display */
|
1354 | ffd39257 | blueswir1 | dpy_update(s->ds, 0, y_start, width, y - y_start);
|
1355 | ffd39257 | blueswir1 | y_start = -1;
|
1356 | ffd39257 | blueswir1 | } |
1357 | ffd39257 | blueswir1 | } |
1358 | ffd39257 | blueswir1 | |
1359 | ffd39257 | blueswir1 | src += width * src_bpp; |
1360 | 44654490 | pbrook | offset += width * src_bpp; |
1361 | ffd39257 | blueswir1 | } |
1362 | ffd39257 | blueswir1 | |
1363 | ffd39257 | blueswir1 | /* complete flush to display */
|
1364 | ffd39257 | blueswir1 | if (y_start >= 0) |
1365 | ffd39257 | blueswir1 | dpy_update(s->ds, 0, y_start, width, y - y_start);
|
1366 | ffd39257 | blueswir1 | |
1367 | ffd39257 | blueswir1 | /* clear dirty flags */
|
1368 | 543c4c94 | Aurelien Jarno | if (page_min != ~0l) { |
1369 | 25793bfa | Avi Kivity | memory_region_reset_dirty(&s->local_mem_region, |
1370 | 25793bfa | Avi Kivity | page_min, page_max + TARGET_PAGE_SIZE, |
1371 | 25793bfa | Avi Kivity | DIRTY_MEMORY_VGA); |
1372 | 543c4c94 | Aurelien Jarno | } |
1373 | ffd39257 | blueswir1 | } |
1374 | ffd39257 | blueswir1 | |
1375 | ffd39257 | blueswir1 | static void sm501_update_display(void *opaque) |
1376 | ffd39257 | blueswir1 | { |
1377 | ffd39257 | blueswir1 | SM501State * s = (SM501State *)opaque; |
1378 | ffd39257 | blueswir1 | |
1379 | ffd39257 | blueswir1 | if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE)
|
1380 | ffd39257 | blueswir1 | sm501_draw_crt(s); |
1381 | ffd39257 | blueswir1 | } |
1382 | ffd39257 | blueswir1 | |
1383 | 27a9d2ea | Richard Henderson | void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
|
1384 | 27a9d2ea | Richard Henderson | uint32_t local_mem_bytes, qemu_irq irq, CharDriverState *chr) |
1385 | ffd39257 | blueswir1 | { |
1386 | ffd39257 | blueswir1 | SM501State * s; |
1387 | 61d3cf93 | Paul Brook | DeviceState *dev; |
1388 | 25793bfa | Avi Kivity | MemoryRegion *sm501_system_config = g_new(MemoryRegion, 1);
|
1389 | 25793bfa | Avi Kivity | MemoryRegion *sm501_disp_ctrl = g_new(MemoryRegion, 1);
|
1390 | 25793bfa | Avi Kivity | MemoryRegion *sm501_2d_engine = g_new(MemoryRegion, 1);
|
1391 | ffd39257 | blueswir1 | |
1392 | ffd39257 | blueswir1 | /* allocate management data region */
|
1393 | 7267c094 | Anthony Liguori | s = (SM501State *)g_malloc0(sizeof(SM501State));
|
1394 | ffd39257 | blueswir1 | s->base = base; |
1395 | ffd39257 | blueswir1 | s->local_mem_size_index |
1396 | ffd39257 | blueswir1 | = get_local_mem_size_index(local_mem_bytes); |
1397 | ffd39257 | blueswir1 | SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s),
|
1398 | ffd39257 | blueswir1 | s->local_mem_size_index); |
1399 | ffd39257 | blueswir1 | s->system_control = 0x00100000;
|
1400 | ffd39257 | blueswir1 | s->misc_control = 0x00001000; /* assumes SH, active=low */ |
1401 | ffd39257 | blueswir1 | s->dc_panel_control = 0x00010000;
|
1402 | ffd39257 | blueswir1 | s->dc_crt_control = 0x00010000;
|
1403 | ffd39257 | blueswir1 | |
1404 | ffd39257 | blueswir1 | /* allocate local memory */
|
1405 | c5705a77 | Avi Kivity | memory_region_init_ram(&s->local_mem_region, "sm501.local",
|
1406 | 25793bfa | Avi Kivity | local_mem_bytes); |
1407 | c5705a77 | Avi Kivity | vmstate_register_ram_global(&s->local_mem_region); |
1408 | 25793bfa | Avi Kivity | s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region); |
1409 | 25793bfa | Avi Kivity | memory_region_add_subregion(address_space_mem, base, &s->local_mem_region); |
1410 | ffd39257 | blueswir1 | |
1411 | ffd39257 | blueswir1 | /* map mmio */
|
1412 | 25793bfa | Avi Kivity | memory_region_init_io(sm501_system_config, &sm501_system_config_ops, s, |
1413 | 25793bfa | Avi Kivity | "sm501-system-config", 0x6c); |
1414 | 25793bfa | Avi Kivity | memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET, |
1415 | 25793bfa | Avi Kivity | sm501_system_config); |
1416 | 25793bfa | Avi Kivity | memory_region_init_io(sm501_disp_ctrl, &sm501_disp_ctrl_ops, s, |
1417 | 25793bfa | Avi Kivity | "sm501-disp-ctrl", 0x1000); |
1418 | 25793bfa | Avi Kivity | memory_region_add_subregion(address_space_mem, |
1419 | 25793bfa | Avi Kivity | base + MMIO_BASE_OFFSET + SM501_DC, |
1420 | 25793bfa | Avi Kivity | sm501_disp_ctrl); |
1421 | 25793bfa | Avi Kivity | memory_region_init_io(sm501_2d_engine, &sm501_2d_engine_ops, s, |
1422 | 25793bfa | Avi Kivity | "sm501-2d-engine", 0x54); |
1423 | 25793bfa | Avi Kivity | memory_region_add_subregion(address_space_mem, |
1424 | 25793bfa | Avi Kivity | base + MMIO_BASE_OFFSET + SM501_2D_ENGINE, |
1425 | 25793bfa | Avi Kivity | sm501_2d_engine); |
1426 | ffd39257 | blueswir1 | |
1427 | ac611340 | aurel32 | /* bridge to usb host emulation module */
|
1428 | 61d3cf93 | Paul Brook | dev = qdev_create(NULL, "sysbus-ohci"); |
1429 | 61d3cf93 | Paul Brook | qdev_prop_set_uint32(dev, "num-ports", 2); |
1430 | 61d3cf93 | Paul Brook | qdev_prop_set_taddr(dev, "dma-offset", base);
|
1431 | 61d3cf93 | Paul Brook | qdev_init_nofail(dev); |
1432 | 61d3cf93 | Paul Brook | sysbus_mmio_map(sysbus_from_qdev(dev), 0,
|
1433 | 61d3cf93 | Paul Brook | base + MMIO_BASE_OFFSET + SM501_USB_HOST); |
1434 | 61d3cf93 | Paul Brook | sysbus_connect_irq(sysbus_from_qdev(dev), 0, irq);
|
1435 | ac611340 | aurel32 | |
1436 | ffd39257 | blueswir1 | /* bridge to serial emulation module */
|
1437 | 2d48377a | Blue Swirl | if (chr) {
|
1438 | 27a9d2ea | Richard Henderson | serial_mm_init(address_space_mem, |
1439 | 39186d8a | Richard Henderson | base + MMIO_BASE_OFFSET + SM501_UART0, 2,
|
1440 | 2d48377a | Blue Swirl | NULL, /* TODO : chain irq to IRL */ |
1441 | 2ff0c7c3 | Richard Henderson | 115200, chr, DEVICE_NATIVE_ENDIAN);
|
1442 | 2d48377a | Blue Swirl | } |
1443 | ffd39257 | blueswir1 | |
1444 | ffd39257 | blueswir1 | /* create qemu graphic console */
|
1445 | 3023f332 | aliguori | s->ds = graphic_console_init(sm501_update_display, NULL,
|
1446 | 3023f332 | aliguori | NULL, NULL, s); |
1447 | ffd39257 | blueswir1 | } |