root / hw / pl110.c @ 71fb2348
History | View | Annotate | Download (10.5 kB)
1 | 5fafdf24 | ths | /*
|
---|---|---|---|
2 | bdd5003a | pbrook | * Arm PrimeCell PL110 Color LCD Controller
|
3 | bdd5003a | pbrook | *
|
4 | cdbdb648 | pbrook | * Copyright (c) 2005-2006 CodeSourcery.
|
5 | bdd5003a | pbrook | * Written by Paul Brook
|
6 | bdd5003a | pbrook | *
|
7 | bdd5003a | pbrook | * This code is licenced under the GNU LGPL
|
8 | bdd5003a | pbrook | */
|
9 | bdd5003a | pbrook | |
10 | 87ecb68b | pbrook | #include "hw.h" |
11 | 87ecb68b | pbrook | #include "primecell.h" |
12 | 87ecb68b | pbrook | #include "console.h" |
13 | bdd5003a | pbrook | |
14 | bdd5003a | pbrook | #define PL110_CR_EN 0x001 |
15 | e9c05b42 | balrog | #define PL110_CR_BGR 0x100 |
16 | bdd5003a | pbrook | #define PL110_CR_BEBO 0x200 |
17 | bdd5003a | pbrook | #define PL110_CR_BEPO 0x400 |
18 | bdd5003a | pbrook | #define PL110_CR_PWR 0x800 |
19 | bdd5003a | pbrook | |
20 | bdd5003a | pbrook | enum pl110_bppmode
|
21 | bdd5003a | pbrook | { |
22 | bdd5003a | pbrook | BPP_1, |
23 | bdd5003a | pbrook | BPP_2, |
24 | bdd5003a | pbrook | BPP_4, |
25 | bdd5003a | pbrook | BPP_8, |
26 | bdd5003a | pbrook | BPP_16, |
27 | bdd5003a | pbrook | BPP_32 |
28 | bdd5003a | pbrook | }; |
29 | bdd5003a | pbrook | |
30 | bdd5003a | pbrook | typedef struct { |
31 | bdd5003a | pbrook | uint32_t base; |
32 | bdd5003a | pbrook | DisplayState *ds; |
33 | c60e08d9 | pbrook | QEMUConsole *console; |
34 | c60e08d9 | pbrook | |
35 | cdbdb648 | pbrook | /* The Versatile/PB uses a slightly modified PL110 controller. */
|
36 | cdbdb648 | pbrook | int versatile;
|
37 | bdd5003a | pbrook | uint32_t timing[4];
|
38 | bdd5003a | pbrook | uint32_t cr; |
39 | bdd5003a | pbrook | uint32_t upbase; |
40 | bdd5003a | pbrook | uint32_t lpbase; |
41 | bdd5003a | pbrook | uint32_t int_status; |
42 | bdd5003a | pbrook | uint32_t int_mask; |
43 | bdd5003a | pbrook | int cols;
|
44 | bdd5003a | pbrook | int rows;
|
45 | bdd5003a | pbrook | enum pl110_bppmode bpp;
|
46 | bdd5003a | pbrook | int invalidate;
|
47 | bdd5003a | pbrook | uint32_t pallette[256];
|
48 | bdd5003a | pbrook | uint32_t raw_pallette[128];
|
49 | d537cf6c | pbrook | qemu_irq irq; |
50 | bdd5003a | pbrook | } pl110_state; |
51 | bdd5003a | pbrook | |
52 | bdd5003a | pbrook | static const unsigned char pl110_id[] = |
53 | bdd5003a | pbrook | { 0x10, 0x11, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; |
54 | bdd5003a | pbrook | |
55 | cdbdb648 | pbrook | /* The Arm documentation (DDI0224C) says the CLDC on the Versatile board
|
56 | cdbdb648 | pbrook | has a different ID. However Linux only looks for the normal ID. */
|
57 | cdbdb648 | pbrook | #if 0
|
58 | cdbdb648 | pbrook | static const unsigned char pl110_versatile_id[] =
|
59 | cdbdb648 | pbrook | { 0x93, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
|
60 | cdbdb648 | pbrook | #else
|
61 | cdbdb648 | pbrook | #define pl110_versatile_id pl110_id
|
62 | cdbdb648 | pbrook | #endif
|
63 | cdbdb648 | pbrook | |
64 | bdd5003a | pbrook | static inline uint32_t rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b) |
65 | bdd5003a | pbrook | { |
66 | bdd5003a | pbrook | return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); |
67 | bdd5003a | pbrook | } |
68 | bdd5003a | pbrook | |
69 | bdd5003a | pbrook | static inline uint32_t rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b) |
70 | bdd5003a | pbrook | { |
71 | bdd5003a | pbrook | return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); |
72 | bdd5003a | pbrook | } |
73 | bdd5003a | pbrook | |
74 | bdd5003a | pbrook | static inline uint32_t rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b) |
75 | bdd5003a | pbrook | { |
76 | bdd5003a | pbrook | return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); |
77 | bdd5003a | pbrook | } |
78 | bdd5003a | pbrook | |
79 | bdd5003a | pbrook | static inline uint32_t rgb_to_pixel24(unsigned int r, unsigned int g, unsigned b) |
80 | bdd5003a | pbrook | { |
81 | bdd5003a | pbrook | return (r << 16) | (g << 8) | b; |
82 | bdd5003a | pbrook | } |
83 | bdd5003a | pbrook | |
84 | bdd5003a | pbrook | static inline uint32_t rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b) |
85 | bdd5003a | pbrook | { |
86 | bdd5003a | pbrook | return (r << 16) | (g << 8) | b; |
87 | bdd5003a | pbrook | } |
88 | bdd5003a | pbrook | |
89 | bdd5003a | pbrook | typedef void (*drawfn)(uint32_t *, uint8_t *, const uint8_t *, int); |
90 | bdd5003a | pbrook | |
91 | bdd5003a | pbrook | #define BITS 8 |
92 | bdd5003a | pbrook | #include "pl110_template.h" |
93 | bdd5003a | pbrook | #define BITS 15 |
94 | bdd5003a | pbrook | #include "pl110_template.h" |
95 | bdd5003a | pbrook | #define BITS 16 |
96 | bdd5003a | pbrook | #include "pl110_template.h" |
97 | bdd5003a | pbrook | #define BITS 24 |
98 | bdd5003a | pbrook | #include "pl110_template.h" |
99 | bdd5003a | pbrook | #define BITS 32 |
100 | bdd5003a | pbrook | #include "pl110_template.h" |
101 | bdd5003a | pbrook | |
102 | bdd5003a | pbrook | static int pl110_enabled(pl110_state *s) |
103 | bdd5003a | pbrook | { |
104 | bdd5003a | pbrook | return (s->cr & PL110_CR_EN) && (s->cr & PL110_CR_PWR);
|
105 | bdd5003a | pbrook | } |
106 | bdd5003a | pbrook | |
107 | 95219897 | pbrook | static void pl110_update_display(void *opaque) |
108 | bdd5003a | pbrook | { |
109 | bdd5003a | pbrook | pl110_state *s = (pl110_state *)opaque; |
110 | bdd5003a | pbrook | drawfn* fntable; |
111 | bdd5003a | pbrook | drawfn fn; |
112 | bdd5003a | pbrook | uint32_t *pallette; |
113 | bdd5003a | pbrook | uint32_t addr; |
114 | bdd5003a | pbrook | uint32_t base; |
115 | bdd5003a | pbrook | int dest_width;
|
116 | bdd5003a | pbrook | int src_width;
|
117 | bdd5003a | pbrook | uint8_t *dest; |
118 | bdd5003a | pbrook | uint8_t *src; |
119 | cdbdb648 | pbrook | int first, last = 0; |
120 | bdd5003a | pbrook | int dirty, new_dirty;
|
121 | bdd5003a | pbrook | int i;
|
122 | e9c05b42 | balrog | int bpp_offset;
|
123 | bdd5003a | pbrook | |
124 | bdd5003a | pbrook | if (!pl110_enabled(s))
|
125 | bdd5003a | pbrook | return;
|
126 | 3b46e624 | ths | |
127 | bdd5003a | pbrook | switch (s->ds->depth) {
|
128 | af2f6733 | pbrook | case 0: |
129 | af2f6733 | pbrook | return;
|
130 | bdd5003a | pbrook | case 8: |
131 | bdd5003a | pbrook | fntable = pl110_draw_fn_8; |
132 | bdd5003a | pbrook | dest_width = 1;
|
133 | bdd5003a | pbrook | break;
|
134 | bdd5003a | pbrook | case 15: |
135 | bdd5003a | pbrook | fntable = pl110_draw_fn_15; |
136 | bdd5003a | pbrook | dest_width = 2;
|
137 | bdd5003a | pbrook | break;
|
138 | bdd5003a | pbrook | case 16: |
139 | bdd5003a | pbrook | fntable = pl110_draw_fn_16; |
140 | bdd5003a | pbrook | dest_width = 2;
|
141 | bdd5003a | pbrook | break;
|
142 | bdd5003a | pbrook | case 24: |
143 | bdd5003a | pbrook | fntable = pl110_draw_fn_24; |
144 | bdd5003a | pbrook | dest_width = 3;
|
145 | bdd5003a | pbrook | break;
|
146 | bdd5003a | pbrook | case 32: |
147 | bdd5003a | pbrook | fntable = pl110_draw_fn_32; |
148 | bdd5003a | pbrook | dest_width = 4;
|
149 | bdd5003a | pbrook | break;
|
150 | bdd5003a | pbrook | default:
|
151 | af2f6733 | pbrook | fprintf(stderr, "pl110: Bad color depth\n");
|
152 | bdd5003a | pbrook | exit(1);
|
153 | bdd5003a | pbrook | } |
154 | e9c05b42 | balrog | if (s->cr & PL110_CR_BGR)
|
155 | e9c05b42 | balrog | bpp_offset = 0;
|
156 | e9c05b42 | balrog | else
|
157 | e9c05b42 | balrog | bpp_offset = 18;
|
158 | e9c05b42 | balrog | |
159 | bdd5003a | pbrook | if (s->cr & PL110_CR_BEBO)
|
160 | e9c05b42 | balrog | fn = fntable[s->bpp + 6 + bpp_offset];
|
161 | bdd5003a | pbrook | else if (s->cr & PL110_CR_BEPO) |
162 | e9c05b42 | balrog | fn = fntable[s->bpp + 12 + bpp_offset];
|
163 | bdd5003a | pbrook | else
|
164 | e9c05b42 | balrog | fn = fntable[s->bpp + bpp_offset]; |
165 | 3b46e624 | ths | |
166 | bdd5003a | pbrook | src_width = s->cols; |
167 | bdd5003a | pbrook | switch (s->bpp) {
|
168 | bdd5003a | pbrook | case BPP_1:
|
169 | bdd5003a | pbrook | src_width >>= 3;
|
170 | bdd5003a | pbrook | break;
|
171 | bdd5003a | pbrook | case BPP_2:
|
172 | bdd5003a | pbrook | src_width >>= 2;
|
173 | bdd5003a | pbrook | break;
|
174 | bdd5003a | pbrook | case BPP_4:
|
175 | bdd5003a | pbrook | src_width >>= 1;
|
176 | bdd5003a | pbrook | break;
|
177 | bdd5003a | pbrook | case BPP_8:
|
178 | bdd5003a | pbrook | break;
|
179 | bdd5003a | pbrook | case BPP_16:
|
180 | bdd5003a | pbrook | src_width <<= 1;
|
181 | bdd5003a | pbrook | break;
|
182 | bdd5003a | pbrook | case BPP_32:
|
183 | bdd5003a | pbrook | src_width <<= 2;
|
184 | bdd5003a | pbrook | break;
|
185 | bdd5003a | pbrook | } |
186 | bdd5003a | pbrook | dest_width *= s->cols; |
187 | bdd5003a | pbrook | pallette = s->pallette; |
188 | bdd5003a | pbrook | base = s->upbase; |
189 | bdd5003a | pbrook | /* HACK: Arm aliases physical memory at 0x80000000. */
|
190 | bdd5003a | pbrook | if (base > 0x80000000) |
191 | bdd5003a | pbrook | base -= 0x80000000;
|
192 | bdd5003a | pbrook | src = phys_ram_base + base; |
193 | bdd5003a | pbrook | dest = s->ds->data; |
194 | bdd5003a | pbrook | first = -1;
|
195 | bdd5003a | pbrook | addr = base; |
196 | bdd5003a | pbrook | |
197 | bdd5003a | pbrook | dirty = cpu_physical_memory_get_dirty(addr, VGA_DIRTY_FLAG); |
198 | e6e5906b | pbrook | new_dirty = dirty; |
199 | bdd5003a | pbrook | for (i = 0; i < s->rows; i++) { |
200 | e6e5906b | pbrook | if ((addr & ~TARGET_PAGE_MASK) + src_width >= TARGET_PAGE_SIZE) {
|
201 | bdd5003a | pbrook | uint32_t tmp; |
202 | e6e5906b | pbrook | new_dirty = 0;
|
203 | bdd5003a | pbrook | for (tmp = 0; tmp < src_width; tmp += TARGET_PAGE_SIZE) { |
204 | bdd5003a | pbrook | new_dirty |= cpu_physical_memory_get_dirty(addr + tmp, |
205 | bdd5003a | pbrook | VGA_DIRTY_FLAG); |
206 | bdd5003a | pbrook | } |
207 | bdd5003a | pbrook | } |
208 | bdd5003a | pbrook | |
209 | bdd5003a | pbrook | if (dirty || new_dirty || s->invalidate) {
|
210 | bdd5003a | pbrook | fn(pallette, dest, src, s->cols); |
211 | bdd5003a | pbrook | if (first == -1) |
212 | bdd5003a | pbrook | first = i; |
213 | bdd5003a | pbrook | last = i; |
214 | bdd5003a | pbrook | } |
215 | bdd5003a | pbrook | dirty = new_dirty; |
216 | bdd5003a | pbrook | addr += src_width; |
217 | bdd5003a | pbrook | dest += dest_width; |
218 | bdd5003a | pbrook | src += src_width; |
219 | bdd5003a | pbrook | } |
220 | bdd5003a | pbrook | if (first < 0) |
221 | bdd5003a | pbrook | return;
|
222 | bdd5003a | pbrook | |
223 | bdd5003a | pbrook | s->invalidate = 0;
|
224 | bdd5003a | pbrook | cpu_physical_memory_reset_dirty(base + first * src_width, |
225 | bdd5003a | pbrook | base + (last + 1) * src_width,
|
226 | bdd5003a | pbrook | VGA_DIRTY_FLAG); |
227 | bdd5003a | pbrook | dpy_update(s->ds, 0, first, s->cols, last - first + 1); |
228 | bdd5003a | pbrook | } |
229 | bdd5003a | pbrook | |
230 | 95219897 | pbrook | static void pl110_invalidate_display(void * opaque) |
231 | bdd5003a | pbrook | { |
232 | bdd5003a | pbrook | pl110_state *s = (pl110_state *)opaque; |
233 | bdd5003a | pbrook | s->invalidate = 1;
|
234 | bdd5003a | pbrook | } |
235 | bdd5003a | pbrook | |
236 | bdd5003a | pbrook | static void pl110_update_pallette(pl110_state *s, int n) |
237 | bdd5003a | pbrook | { |
238 | bdd5003a | pbrook | int i;
|
239 | bdd5003a | pbrook | uint32_t raw; |
240 | bdd5003a | pbrook | unsigned int r, g, b; |
241 | bdd5003a | pbrook | |
242 | bdd5003a | pbrook | raw = s->raw_pallette[n]; |
243 | bdd5003a | pbrook | n <<= 1;
|
244 | bdd5003a | pbrook | for (i = 0; i < 2; i++) { |
245 | bdd5003a | pbrook | r = (raw & 0x1f) << 3; |
246 | bdd5003a | pbrook | raw >>= 5;
|
247 | bdd5003a | pbrook | g = (raw & 0x1f) << 3; |
248 | bdd5003a | pbrook | raw >>= 5;
|
249 | bdd5003a | pbrook | b = (raw & 0x1f) << 3; |
250 | bdd5003a | pbrook | /* The I bit is ignored. */
|
251 | bdd5003a | pbrook | raw >>= 6;
|
252 | bdd5003a | pbrook | switch (s->ds->depth) {
|
253 | bdd5003a | pbrook | case 8: |
254 | bdd5003a | pbrook | s->pallette[n] = rgb_to_pixel8(r, g, b); |
255 | bdd5003a | pbrook | break;
|
256 | bdd5003a | pbrook | case 15: |
257 | bdd5003a | pbrook | s->pallette[n] = rgb_to_pixel15(r, g, b); |
258 | bdd5003a | pbrook | break;
|
259 | bdd5003a | pbrook | case 16: |
260 | bdd5003a | pbrook | s->pallette[n] = rgb_to_pixel16(r, g, b); |
261 | bdd5003a | pbrook | break;
|
262 | bdd5003a | pbrook | case 24: |
263 | bdd5003a | pbrook | case 32: |
264 | bdd5003a | pbrook | s->pallette[n] = rgb_to_pixel32(r, g, b); |
265 | bdd5003a | pbrook | break;
|
266 | bdd5003a | pbrook | } |
267 | bdd5003a | pbrook | n++; |
268 | bdd5003a | pbrook | } |
269 | bdd5003a | pbrook | } |
270 | bdd5003a | pbrook | |
271 | bdd5003a | pbrook | static void pl110_resize(pl110_state *s, int width, int height) |
272 | bdd5003a | pbrook | { |
273 | bdd5003a | pbrook | if (width != s->cols || height != s->rows) {
|
274 | bdd5003a | pbrook | if (pl110_enabled(s)) {
|
275 | c60e08d9 | pbrook | qemu_console_resize(s->console, width, height); |
276 | bdd5003a | pbrook | } |
277 | bdd5003a | pbrook | } |
278 | bdd5003a | pbrook | s->cols = width; |
279 | bdd5003a | pbrook | s->rows = height; |
280 | bdd5003a | pbrook | } |
281 | bdd5003a | pbrook | |
282 | bdd5003a | pbrook | /* Update interrupts. */
|
283 | bdd5003a | pbrook | static void pl110_update(pl110_state *s) |
284 | bdd5003a | pbrook | { |
285 | bdd5003a | pbrook | /* TODO: Implement interrupts. */
|
286 | bdd5003a | pbrook | } |
287 | bdd5003a | pbrook | |
288 | bdd5003a | pbrook | static uint32_t pl110_read(void *opaque, target_phys_addr_t offset) |
289 | bdd5003a | pbrook | { |
290 | bdd5003a | pbrook | pl110_state *s = (pl110_state *)opaque; |
291 | bdd5003a | pbrook | |
292 | bdd5003a | pbrook | offset -= s->base; |
293 | bdd5003a | pbrook | if (offset >= 0xfe0 && offset < 0x1000) { |
294 | cdbdb648 | pbrook | if (s->versatile)
|
295 | cdbdb648 | pbrook | return pl110_versatile_id[(offset - 0xfe0) >> 2]; |
296 | cdbdb648 | pbrook | else
|
297 | cdbdb648 | pbrook | return pl110_id[(offset - 0xfe0) >> 2]; |
298 | bdd5003a | pbrook | } |
299 | bdd5003a | pbrook | if (offset >= 0x200 && offset < 0x400) { |
300 | bdd5003a | pbrook | return s->raw_pallette[(offset - 0x200) >> 2]; |
301 | bdd5003a | pbrook | } |
302 | bdd5003a | pbrook | switch (offset >> 2) { |
303 | bdd5003a | pbrook | case 0: /* LCDTiming0 */ |
304 | bdd5003a | pbrook | return s->timing[0]; |
305 | bdd5003a | pbrook | case 1: /* LCDTiming1 */ |
306 | bdd5003a | pbrook | return s->timing[1]; |
307 | bdd5003a | pbrook | case 2: /* LCDTiming2 */ |
308 | bdd5003a | pbrook | return s->timing[2]; |
309 | bdd5003a | pbrook | case 3: /* LCDTiming3 */ |
310 | bdd5003a | pbrook | return s->timing[3]; |
311 | bdd5003a | pbrook | case 4: /* LCDUPBASE */ |
312 | bdd5003a | pbrook | return s->upbase;
|
313 | bdd5003a | pbrook | case 5: /* LCDLPBASE */ |
314 | bdd5003a | pbrook | return s->lpbase;
|
315 | bdd5003a | pbrook | case 6: /* LCDIMSC */ |
316 | 64075cd7 | pbrook | if (s->versatile)
|
317 | 64075cd7 | pbrook | return s->cr;
|
318 | bdd5003a | pbrook | return s->int_mask;
|
319 | bdd5003a | pbrook | case 7: /* LCDControl */ |
320 | 64075cd7 | pbrook | if (s->versatile)
|
321 | 64075cd7 | pbrook | return s->int_mask;
|
322 | bdd5003a | pbrook | return s->cr;
|
323 | bdd5003a | pbrook | case 8: /* LCDRIS */ |
324 | bdd5003a | pbrook | return s->int_status;
|
325 | bdd5003a | pbrook | case 9: /* LCDMIS */ |
326 | bdd5003a | pbrook | return s->int_status & s->int_mask;
|
327 | bdd5003a | pbrook | case 11: /* LCDUPCURR */ |
328 | bdd5003a | pbrook | /* TODO: Implement vertical refresh. */
|
329 | bdd5003a | pbrook | return s->upbase;
|
330 | bdd5003a | pbrook | case 12: /* LCDLPCURR */ |
331 | bdd5003a | pbrook | return s->lpbase;
|
332 | bdd5003a | pbrook | default:
|
333 | 4d1165fa | pbrook | cpu_abort (cpu_single_env, "pl110_read: Bad offset %x\n", (int)offset); |
334 | bdd5003a | pbrook | return 0; |
335 | bdd5003a | pbrook | } |
336 | bdd5003a | pbrook | } |
337 | bdd5003a | pbrook | |
338 | bdd5003a | pbrook | static void pl110_write(void *opaque, target_phys_addr_t offset, |
339 | bdd5003a | pbrook | uint32_t val) |
340 | bdd5003a | pbrook | { |
341 | bdd5003a | pbrook | pl110_state *s = (pl110_state *)opaque; |
342 | bdd5003a | pbrook | int n;
|
343 | bdd5003a | pbrook | |
344 | bdd5003a | pbrook | /* For simplicity invalidate the display whenever a control register
|
345 | bdd5003a | pbrook | is writen to. */
|
346 | bdd5003a | pbrook | s->invalidate = 1;
|
347 | bdd5003a | pbrook | offset -= s->base; |
348 | bdd5003a | pbrook | if (offset >= 0x200 && offset < 0x400) { |
349 | bdd5003a | pbrook | /* Pallette. */
|
350 | bdd5003a | pbrook | n = (offset - 0x200) >> 2; |
351 | bdd5003a | pbrook | s->raw_pallette[(offset - 0x200) >> 2] = val; |
352 | bdd5003a | pbrook | pl110_update_pallette(s, n); |
353 | e10c2bfb | pbrook | return;
|
354 | bdd5003a | pbrook | } |
355 | bdd5003a | pbrook | switch (offset >> 2) { |
356 | bdd5003a | pbrook | case 0: /* LCDTiming0 */ |
357 | bdd5003a | pbrook | s->timing[0] = val;
|
358 | bdd5003a | pbrook | n = ((val & 0xfc) + 4) * 4; |
359 | bdd5003a | pbrook | pl110_resize(s, n, s->rows); |
360 | bdd5003a | pbrook | break;
|
361 | bdd5003a | pbrook | case 1: /* LCDTiming1 */ |
362 | bdd5003a | pbrook | s->timing[1] = val;
|
363 | bdd5003a | pbrook | n = (val & 0x3ff) + 1; |
364 | bdd5003a | pbrook | pl110_resize(s, s->cols, n); |
365 | bdd5003a | pbrook | break;
|
366 | bdd5003a | pbrook | case 2: /* LCDTiming2 */ |
367 | bdd5003a | pbrook | s->timing[2] = val;
|
368 | bdd5003a | pbrook | break;
|
369 | bdd5003a | pbrook | case 3: /* LCDTiming3 */ |
370 | bdd5003a | pbrook | s->timing[3] = val;
|
371 | bdd5003a | pbrook | break;
|
372 | bdd5003a | pbrook | case 4: /* LCDUPBASE */ |
373 | bdd5003a | pbrook | s->upbase = val; |
374 | bdd5003a | pbrook | break;
|
375 | bdd5003a | pbrook | case 5: /* LCDLPBASE */ |
376 | bdd5003a | pbrook | s->lpbase = val; |
377 | bdd5003a | pbrook | break;
|
378 | bdd5003a | pbrook | case 6: /* LCDIMSC */ |
379 | cdbdb648 | pbrook | if (s->versatile)
|
380 | cdbdb648 | pbrook | goto control;
|
381 | cdbdb648 | pbrook | imsc:
|
382 | bdd5003a | pbrook | s->int_mask = val; |
383 | bdd5003a | pbrook | pl110_update(s); |
384 | bdd5003a | pbrook | break;
|
385 | bdd5003a | pbrook | case 7: /* LCDControl */ |
386 | cdbdb648 | pbrook | if (s->versatile)
|
387 | cdbdb648 | pbrook | goto imsc;
|
388 | cdbdb648 | pbrook | control:
|
389 | bdd5003a | pbrook | s->cr = val; |
390 | bdd5003a | pbrook | s->bpp = (val >> 1) & 7; |
391 | bdd5003a | pbrook | if (pl110_enabled(s)) {
|
392 | c60e08d9 | pbrook | qemu_console_resize(s->console, s->cols, s->rows); |
393 | bdd5003a | pbrook | } |
394 | bdd5003a | pbrook | break;
|
395 | bdd5003a | pbrook | case 10: /* LCDICR */ |
396 | bdd5003a | pbrook | s->int_status &= ~val; |
397 | bdd5003a | pbrook | pl110_update(s); |
398 | bdd5003a | pbrook | break;
|
399 | bdd5003a | pbrook | default:
|
400 | 4d1165fa | pbrook | cpu_abort (cpu_single_env, "pl110_write: Bad offset %x\n", (int)offset); |
401 | bdd5003a | pbrook | } |
402 | bdd5003a | pbrook | } |
403 | bdd5003a | pbrook | |
404 | bdd5003a | pbrook | static CPUReadMemoryFunc *pl110_readfn[] = {
|
405 | bdd5003a | pbrook | pl110_read, |
406 | bdd5003a | pbrook | pl110_read, |
407 | bdd5003a | pbrook | pl110_read |
408 | bdd5003a | pbrook | }; |
409 | bdd5003a | pbrook | |
410 | bdd5003a | pbrook | static CPUWriteMemoryFunc *pl110_writefn[] = {
|
411 | bdd5003a | pbrook | pl110_write, |
412 | bdd5003a | pbrook | pl110_write, |
413 | bdd5003a | pbrook | pl110_write |
414 | bdd5003a | pbrook | }; |
415 | bdd5003a | pbrook | |
416 | d537cf6c | pbrook | void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
|
417 | 95219897 | pbrook | int versatile)
|
418 | bdd5003a | pbrook | { |
419 | bdd5003a | pbrook | pl110_state *s; |
420 | bdd5003a | pbrook | int iomemtype;
|
421 | bdd5003a | pbrook | |
422 | bdd5003a | pbrook | s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
|
423 | bdd5003a | pbrook | iomemtype = cpu_register_io_memory(0, pl110_readfn,
|
424 | bdd5003a | pbrook | pl110_writefn, s); |
425 | 187337f8 | pbrook | cpu_register_physical_memory(base, 0x00001000, iomemtype);
|
426 | bdd5003a | pbrook | s->base = base; |
427 | bdd5003a | pbrook | s->ds = ds; |
428 | cdbdb648 | pbrook | s->versatile = versatile; |
429 | bdd5003a | pbrook | s->irq = irq; |
430 | c60e08d9 | pbrook | s->console = graphic_console_init(ds, pl110_update_display, |
431 | c60e08d9 | pbrook | pl110_invalidate_display, |
432 | c60e08d9 | pbrook | NULL, NULL, s); |
433 | bdd5003a | pbrook | /* ??? Save/restore. */
|
434 | bdd5003a | pbrook | return s;
|
435 | bdd5003a | pbrook | } |