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