2 * QEMU Sun4m System Emulator
4 * Copyright (c) 2003-2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #define PHYS_JJ_TCX_FB 0x50800000 /* Start address, frame buffer body */
27 #define PHYS_JJ_TCX_0E 0x5E000000 /* Top address, one byte used. */
33 #define XOFF (MAXX-XSZ)
34 #define YOFF (MAXY-YSZ)
38 typedef struct TCXState {
40 unsigned long vram_offset;
41 unsigned int vram_size;
47 static int tcx_io_memory;
49 void vga_update_display()
51 dpy_update(ts->ds, 0, 0, XSZ, YSZ);
54 static uint32_t tcx_mem_readb(void *opaque, target_phys_addr_t addr)
61 saddr = addr - PHYS_JJ_TCX_FB - YOFF*MAXX - XOFF;
64 if (x < MAXX && y < MAXY) {
67 return sptr[y * s->ds->linesize + x*4];
72 static uint32_t tcx_mem_readw(void *opaque, target_phys_addr_t addr)
75 #ifdef TARGET_WORDS_BIGENDIAN
76 v = tcx_mem_readb(opaque, addr) << 8;
77 v |= tcx_mem_readb(opaque, addr + 1);
79 v = tcx_mem_readb(opaque, addr);
80 v |= tcx_mem_readb(opaque, addr + 1) << 8;
85 static uint32_t tcx_mem_readl(void *opaque, target_phys_addr_t addr)
88 #ifdef TARGET_WORDS_BIGENDIAN
89 v = tcx_mem_readb(opaque, addr) << 24;
90 v |= tcx_mem_readb(opaque, addr + 1) << 16;
91 v |= tcx_mem_readb(opaque, addr + 2) << 8;
92 v |= tcx_mem_readb(opaque, addr + 3);
94 v = tcx_mem_readb(opaque, addr);
95 v |= tcx_mem_readb(opaque, addr + 1) << 8;
96 v |= tcx_mem_readb(opaque, addr + 2) << 16;
97 v |= tcx_mem_readb(opaque, addr + 3) << 24;
102 /* called for accesses between 0xa0000 and 0xc0000 */
103 static void tcx_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
105 TCXState *s = opaque;
110 saddr = addr - PHYS_JJ_TCX_FB - YOFF*MAXX - XOFF;
112 x = saddr - y * MAXX;
113 if (x < MAXX && y < MAXY) {
116 sptr[y * s->ds->linesize + x*4] = val;
117 sptr[y * s->ds->linesize + x*4+1] = val;
118 sptr[y * s->ds->linesize + x*4+2] = val;
119 cpu_physical_memory_set_dirty(addr);
124 static void tcx_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
126 #ifdef TARGET_WORDS_BIGENDIAN
127 tcx_mem_writeb(opaque, addr, (val >> 8) & 0xff);
128 tcx_mem_writeb(opaque, addr + 1, val & 0xff);
130 tcx_mem_writeb(opaque, addr, val & 0xff);
131 tcx_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
135 static void tcx_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
137 #ifdef TARGET_WORDS_BIGENDIAN
138 tcx_mem_writeb(opaque, addr, (val >> 24) & 0xff);
139 tcx_mem_writeb(opaque, addr + 1, (val >> 16) & 0xff);
140 tcx_mem_writeb(opaque, addr + 2, (val >> 8) & 0xff);
141 tcx_mem_writeb(opaque, addr + 3, val & 0xff);
143 tcx_mem_writeb(opaque, addr, val & 0xff);
144 tcx_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
145 tcx_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff);
146 tcx_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff);
150 static CPUReadMemoryFunc *tcx_mem_read[3] = {
156 static CPUWriteMemoryFunc *tcx_mem_write[3] = {
162 void tcx_init(DisplayState *ds)
166 s = qemu_mallocz(sizeof(TCXState));
171 tcx_io_memory = cpu_register_io_memory(0, tcx_mem_read, tcx_mem_write, s);
172 cpu_register_physical_memory(PHYS_JJ_TCX_FB, 0x100000,
174 dpy_resize(s->ds, XSZ, YSZ);