/[gxemul]/trunk/src/devices/dev_sgi_gbe.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/src/devices/dev_sgi_gbe.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (hide annotations)
Mon Oct 8 16:22:32 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 12465 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1613 2007/06/15 20:11:26 debug Exp $
20070501	Continuing a little on m88k disassembly (control registers,
		more instructions).
		Adding a dummy mvme88k machine mode.
20070502	Re-adding MIPS load/store alignment exceptions.
20070503	Implementing more of the M88K disassembly code.
20070504	Adding disassembly of some more M88K load/store instructions.
		Implementing some relatively simple M88K instructions (br.n,
		xor[.u] imm, and[.u] imm).
20070505	Implementing M88K three-register and, or, xor, and jmp[.n],
		bsr[.n] including function call trace stuff.
		Applying a patch from Bruce M. Simpson which implements the
		SYSCON_BOARD_CPU_CLOCK_FREQ_ID object of the syscon call in
		the yamon PROM emulation.
20070506	Implementing M88K bb0[.n] and bb1[.n], and skeletons for
		ldcr and stcr (although no control regs are implemented yet).
20070509	Found and fixed the bug which caused Linux for QEMU_MIPS to
		stop working in 0.4.5.1: It was a faulty change to the MIPS
		'sc' and 'scd' instructions I made while going through gcc -W
		warnings on 20070428.
20070510	Updating the Linux/QEMU_MIPS section in guestoses.html to
		use mips-test-0.2.tar.gz instead of 0.1.
		A big thank you to Miod Vallat for sending me M88K manuals.
		Implementing more M88K instructions (addu, subu, div[u], mulu,
		ext[u], clr, set, cmp).
20070511	Fixing bugs in the M88K "and" and "and.u" instructions (found
		by comparing against the manual).
		Implementing more M88K instructions (mask[.u], mak, bcnd (auto-
		generated)) and some more control register details.
		Cleanup: Removing the experimental AVR emulation mode and
		corresponding devices; AVR emulation wasn't really meaningful.
		Implementing autogeneration of most M88K loads/stores. The
		rectangle drawing demo (with -O0) for M88K runs :-)
		Beginning on M88K exception handling.
		More M88K instructions: tb0, tb1, rte, sub, jsr[.n].
		Adding some skeleton MVME PROM ("BUG") emulation.
20070512	Fixing a bug in the M88K cmp instruction.
		Adding the M88K lda (scaled register) instruction.
		Fixing bugs in 64-bit (32-bit pairs) M88K loads/stores.
		Removing the unused tick_hz stuff from the machine struct.
		Implementing the M88K xmem instruction. OpenBSD/mvme88k gets
		far enough to display the Copyright banner :-)
		Implementing subu.co (guess), addu.co, addu.ci, ff0, and ff1.
		Adding a dev_mvme187, for MVME187-specific devices/registers.
		OpenBSD/mvme88k prints more boot messages. :)
20070515	Continuing on MVME187 emulation (adding more devices, beginning
		on the CMMUs, etc).
		Adding the M88K and.c, xor.c, and or.c instructions, and making
		sure that mul, div, etc cause exceptions if executed when SFD1
		is disabled.
20070517	Continuing on M88K and MVME187 emulation in general; moving
		the CMMU registers to the CPU struct, separating dev_pcc2 from
		dev_mvme187, and beginning on memory_m88k.c (BATC and PATC).
		Fixing a bug in 64-bit (32-bit pairs) M88K fast stores.
		Implementing the clock part of dev_mk48txx.
		Implementing the M88K fstcr and xcr instructions.
		Implementing m88k_cpu_tlbdump().
		Beginning on the implementation of a separate address space
		for M88K .usr loads/stores.
20070520	Removing the non-working (skeleton) Sandpoint, SonyNEWS, SHARK
		Dnard, and Zaurus machine modes.
		Experimenting with dyntrans to_be_translated read-ahead. It
		seems to give a very small performance increase for MIPS
		emulation, but a large performance degradation for SuperH. Hm.
20070522	Disabling correct SuperH ITLB emulation; it does not seem to be
		necessary in order to let SH4 guest OSes run, and it slows down
		userspace code.
		Implementing "samepage" branches for SuperH emulation, and some
		other minor speed hacks.
20070525	Continuing on M88K memory-related stuff: exceptions, memory
		transaction register contents, etc.
		Implementing the M88K subu.ci instruction.
		Removing the non-working (skeleton) Iyonix machine mode.
		OpenBSD/mvme88k reaches userland :-), starts executing
		/sbin/init's instructions, and issues a few syscalls, before
		crashing.
20070526	Fixing bugs in dev_mk48txx, so that OpenBSD/mvme88k detects
		the correct time-of-day.
		Implementing a generic IRQ controller for the test machines
		(dev_irqc), similar to a proposed patch from Petr Stepan.
		Experimenting some more with translation read-ahead.
		Adding an "expect" script for automated OpenBSD/landisk
		install regression/performance tests.
20070527	Adding a dummy mmEye (SH3) machine mode skeleton.
		FINALLY found the strange M88K bug I have been hunting: I had
		not emulated the SNIP value for exceptions occurring in
		branch delay slots correctly.
		Implementing correct exceptions for 64-bit M88K loads/stores.
		Address to symbol lookups are now disabled when M88K is
		running in usermode (because usermode addresses don't have
		anything to do with supervisor addresses).
20070531	Removing the mmEye machine mode skeleton.
20070604	Some minor code cleanup.
20070605	Moving src/useremul.c into a subdir (src/useremul/), and
		cleaning up some more legacy constructs.
		Adding -Wstrict-aliasing and -fstrict-aliasing detection to
		the configure script.
20070606	Adding a check for broken GCC on Solaris to the configure
		script. (GCC 3.4.3 on Solaris cannot handle static variables
		which are initialized to 0 or NULL. :-/)
		Removing the old (non-working) ARC emulation modes: NEC RD94,
		R94, R96, and R98, and the last traces of Olivetti M700 and
		Deskstation Tyne.
		Removing the non-working skeleton WDSC device (dev_wdsc).
20070607	Thinking about how to use the host's cc + ld at runtime to
		generate native code. (See experiments/native_cc_ld_test.i
		for an example.)
20070608	Adding a program counter sampling timer, which could be useful
		for native code generation experiments.
		The KN02_CSR_NRMMOD bit in the DECstation 5000/200 (KN02) CSR
		should always be set, to allow a 5000/200 PROM to boot.
20070609	Moving out breakpoint details from the machine struct into
		a helper struct, and removing the limit on max nr of
		breakpoints.
20070610	Moving out tick functions into a helper struct as well (which
		also gets rid of the max limit).
20070612	FINALLY figured out why Debian/DECstation stopped working when
		translation read-ahead was enabled: in src/memory_rw.c, the
		call to invalidate_code_translation was made also if the
		memory access was an instruction load (if the page was mapped
		as writable); it shouldn't be called in that case.
20070613	Implementing some more MIPS32/64 revision 2 instructions: di,
		ei, ext, dext, dextm, dextu, and ins.
20070614	Implementing an instruction combination for the NetBSD/arm
		idle loop (making the host not use any cpu if NetBSD/arm
		inside the emulator is not using any cpu).
		Increasing the nr of ARM VPH entries from 128 to 384.
20070615	Removing the ENABLE_arch stuff from the configure script, so
		that all included architectures are included in both release
		and development builds.
		Moving memory related helper functions from misc.c to memory.c.
		Adding preliminary instructions for netbooting NetBSD/pmppc to
		guestoses.html; it doesn't work yet, there are weird timeouts.
		Beginning a total rewrite of the userland emulation modes
		(removing all emulation modes, beginning from scratch with
		NetBSD/MIPS and FreeBSD/Alpha only).
20070616	After fixing a bug in the DEC21143 NIC (the TDSTAT_OWN bit was
		only cleared for the last segment when transmitting, not all
		segments), NetBSD/pmppc boots with root-on-nfs without the
		timeouts. Updating guestoses.html.
		Removing the skeleton PSP (Playstation Portable) mode.
		Moving X11-related stuff in the machine struct into a helper
		struct.
		Cleanup of out-of-memory checks, to use a new CHECK_ALLOCATION
		macro (which prints a meaningful error message).
		Adding a COMMENT to each machine and device (for automagic
		.index comment generation).
		Doing regression testing for the next release.

==============  RELEASE 0.4.6  ==============


1 dpavlin 4 /*
2 dpavlin 34 * Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
3 dpavlin 4 *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are met:
6     *
7     * 1. Redistributions of source code must retain the above copyright
8     * notice, this list of conditions and the following disclaimer.
9     * 2. Redistributions in binary form must reproduce the above copyright
10     * notice, this list of conditions and the following disclaimer in the
11     * documentation and/or other materials provided with the distribution.
12     * 3. The name of the author may not be used to endorse or promote products
13     * derived from this software without specific prior written permission.
14     *
15     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25     * SUCH DAMAGE.
26     *
27     *
28 dpavlin 42 * $Id: dev_sgi_gbe.c,v 1.37 2007/06/15 19:57:34 debug Exp $
29 dpavlin 4 *
30 dpavlin 42 * COMMENT: SGI "gbe", graphics controller + framebuffer
31     *
32 dpavlin 4 * Loosely inspired by Linux code.
33     */
34    
35     #include <stdio.h>
36     #include <stdlib.h>
37     #include <string.h>
38    
39     #include "console.h"
40     #include "cpu.h"
41     #include "devices.h"
42     #include "machine.h"
43     #include "memory.h"
44     #include "misc.h"
45    
46    
47     /* Let's hope nothing is there already... */
48     #define FAKE_GBE_FB_ADDRESS 0x38000000
49    
50     #define GBE_DEBUG
51 dpavlin 12 /* #define debug fatal */
52 dpavlin 4
53 dpavlin 14 #define MTE_TEST
54 dpavlin 12
55 dpavlin 4 #define GBE_DEFAULT_XRES 640
56     #define GBE_DEFAULT_YRES 480
57    
58    
59     struct sgi_gbe_data {
60     int xres, yres;
61    
62     uint32_t control; /* 0x00000 */
63     uint32_t dotclock; /* 0x00004 */
64     uint32_t i2c; /* 0x00008 */
65     uint32_t i2cfp; /* 0x00010 */
66     uint32_t plane0ctrl; /* 0x30000 */
67     uint32_t frm_control; /* 0x3000c */
68     int freeze;
69    
70     int bitdepth;
71     struct vfb_data *fb_data;
72     };
73    
74    
75     /*
76     * dev_sgi_gbe_tick():
77     *
78     * Every now and then, copy data from the framebuffer in normal ram
79     * to the actual framebuffer (which will then redraw the window).
80     * TODO: This is utterly slow, even slower than the normal framebuffer
81     * which is really slow as it is.
82     *
83     * frm_control (bits 31..9) is a pointer to an array of uint16_t.
84     * These numbers (when << 16 bits) are pointers to the tiles. Tiles are
85     * 512x128 in 8-bit mode, 256x128 in 16-bit mode, and 128x128 in 32-bit mode.
86     */
87 dpavlin 42 DEVICE_TICK(sgi_gbe)
88 dpavlin 4 {
89     struct sgi_gbe_data *d = extra;
90     int tile_nr = 0, on_screen = 1, xbase = 0, ybase = 0;
91     unsigned char tileptr_buf[sizeof(uint16_t)];
92     uint64_t tileptr, tiletable;
93     int lines_to_copy, pixels_per_line, y;
94 dpavlin 12 unsigned char buf[16384]; /* must be power of 2, at most 65536 */
95 dpavlin 4 int copy_len, copy_offset;
96     uint64_t old_fb_offset = 0;
97     int tweaked = 1;
98    
99 dpavlin 12 #ifdef MTE_TEST
100 dpavlin 24 /* Actually just a return, but this fools the Compaq compiler... */
101     if (cpu != NULL)
102 dpavlin 12 return;
103     #endif
104    
105 dpavlin 4 /* debug("[ sgi_gbe: dev_sgi_gbe_tick() ]\n"); */
106    
107     tiletable = (d->frm_control & 0xfffffe00);
108     if (tiletable == 0)
109     on_screen = 0;
110 dpavlin 12 /*
111     tweaked = 0;
112     */
113 dpavlin 4 while (on_screen) {
114     /* Get pointer to a tile: */
115     cpu->memory_rw(cpu, cpu->mem, tiletable +
116     sizeof(tileptr_buf) * tile_nr,
117     tileptr_buf, sizeof(tileptr_buf), MEM_READ,
118     NO_EXCEPTIONS | PHYSICAL);
119     tileptr = 256 * tileptr_buf[0] + tileptr_buf[1];
120     /* TODO: endianness */
121     tileptr <<= 16;
122    
123     /* tileptr is now a physical address of a tile. */
124     debug("[ sgi_gbe: tile_nr = %2i, tileptr = 0x%08lx, xbase"
125     " = %4i, ybase = %4i ]\n", tile_nr, tileptr, xbase, ybase);
126    
127     if (tweaked) {
128     /* Tweaked (linear) mode: */
129    
130 dpavlin 22 /*
131     * Copy data from this 64KB physical RAM block to the
132     * framebuffer:
133     *
134     * NOTE: Copy it in smaller chunks than 64KB, in case
135     * the framebuffer device can optimize away
136     * portions that aren't modified that way.
137     */
138 dpavlin 4 copy_len = sizeof(buf);
139     copy_offset = 0;
140    
141     while (on_screen && copy_offset < 65536) {
142 dpavlin 22 if (old_fb_offset + copy_len > (uint64_t)
143     (d->xres * d->yres * d->bitdepth / 8)) {
144     copy_len = d->xres * d->yres *
145     d->bitdepth / 8 - old_fb_offset;
146 dpavlin 4 /* Stop after copying this block... */
147     on_screen = 0;
148     }
149    
150     /* debug("old_fb_offset = %08x copylen"
151     "=%i\n", old_fb_offset, copy_len); */
152    
153     cpu->memory_rw(cpu, cpu->mem, tileptr +
154     copy_offset, buf, copy_len, MEM_READ,
155     NO_EXCEPTIONS | PHYSICAL);
156     dev_fb_access(cpu, cpu->mem, old_fb_offset,
157     buf, copy_len, MEM_WRITE, d->fb_data);
158     copy_offset += sizeof(buf);
159     old_fb_offset += sizeof(buf);
160     }
161     } else {
162 dpavlin 22 /* This is for non-tweaked (tiled) mode. Not really
163     tested with correct image data, but might work: */
164 dpavlin 4
165     lines_to_copy = 128;
166     if (ybase + lines_to_copy > d->yres)
167     lines_to_copy = d->yres - ybase;
168    
169     pixels_per_line = 512 * 8 / d->bitdepth;
170     if (xbase + pixels_per_line > d->xres)
171     pixels_per_line = d->xres - xbase;
172    
173     for (y=0; y<lines_to_copy; y++) {
174     cpu->memory_rw(cpu, cpu->mem, tileptr + 512 * y,
175     buf, pixels_per_line * d->bitdepth / 8,
176     MEM_READ, NO_EXCEPTIONS | PHYSICAL);
177 dpavlin 12 #if 0
178     {
179     int i;
180     for (i=0; i<pixels_per_line * d->bitdepth / 8; i++)
181     buf[i] ^= (random() & 0x20);
182     }
183     #endif
184 dpavlin 4 dev_fb_access(cpu, cpu->mem, ((ybase + y) *
185     d->xres + xbase) * d->bitdepth / 8,
186     buf, pixels_per_line * d->bitdepth / 8,
187     MEM_WRITE, d->fb_data);
188     }
189    
190     /* Go to next tile: */
191     xbase += (512 * 8 / d->bitdepth);
192     if (xbase >= d->xres) {
193     xbase = 0;
194     ybase += 128;
195     if (ybase >= d->yres)
196     on_screen = 0;
197     }
198     }
199    
200     /* Go to next tile: */
201     tile_nr ++;
202     }
203    
204     /* debug("[ sgi_gbe: dev_sgi_gbe_tick() end]\n"); */
205     }
206    
207    
208 dpavlin 22 DEVICE_ACCESS(sgi_gbe)
209 dpavlin 4 {
210     struct sgi_gbe_data *d = extra;
211     uint64_t idata = 0, odata = 0;
212    
213 dpavlin 18 if (writeflag == MEM_WRITE)
214     idata = memory_readmax64(cpu, data, len);
215 dpavlin 4
216     #ifdef GBE_DEBUG
217     if (writeflag == MEM_WRITE)
218 dpavlin 22 debug("[ sgi_gbe: DEBUG: write to address 0x%llx, data"
219     "=0x%llx ]\n", (long long)relative_addr, (long long)idata);
220 dpavlin 4 #endif
221    
222     switch (relative_addr) {
223    
224     case 0x0:
225     if (writeflag == MEM_WRITE)
226     d->control = idata;
227     else
228     odata = d->control;
229     break;
230    
231     case 0x4:
232     if (writeflag == MEM_WRITE)
233     d->dotclock = idata;
234     else
235     odata = d->dotclock;
236     break;
237    
238     case 0x8: /* i2c? */
239     /*
240     * "CRT I2C control".
241     *
242     * I'm not sure what this does. It isn't really commented
243     * in the linux sources. The IP32 prom writes the values
244     * 0x03, 0x01, and then 0x00 to this address, and then
245     * reads back a value.
246     */
247     if (writeflag == MEM_WRITE) {
248     d->i2c = idata;
249     } else {
250     odata = d->i2c;
251     odata |= 1; /* ? The IP32 prom wants this? */
252     }
253     break;
254    
255     case 0x10: /* i2cfp, flat panel control */
256     if (writeflag == MEM_WRITE) {
257     d->i2cfp = idata;
258     } else {
259     odata = d->i2cfp;
260     odata |= 1; /* ? The IP32 prom wants this? */
261     }
262     break;
263    
264     case 0x10000: /* vt_xy, according to Linux */
265     if (writeflag == MEM_WRITE)
266     d->freeze = idata & ((uint32_t)1<<31)? 1 : 0;
267     else {
268     /* bit 31 = freeze, 23..12 = cury, 11.0 = curx */
269     odata = ((random() % (d->yres + 10)) << 12)
270 dpavlin 22 + (random() % (d->xres + 10)) +
271     (d->freeze? ((uint32_t)1 << 31) : 0);
272 dpavlin 4 odata = random(); /* testhack for the ip32 prom */
273     }
274     break;
275    
276     case 0x10004: /* vt_xymax, according to Linux */
277 dpavlin 22 odata = ((d->yres-1) << 12) + d->xres-1;
278     /* ... 12 bits maxy, 12 bits maxx. */
279 dpavlin 4 break;
280    
281     case 0x10034: /* vt_hpixen, according to Linux */
282 dpavlin 22 odata = (0 << 12) + d->xres-1;
283     /* ... 12 bits on, 12 bits off. */
284 dpavlin 4 break;
285    
286     case 0x10038: /* vt_vpixen, according to Linux */
287 dpavlin 22 odata = (0 << 12) + d->yres-1;
288     /* ... 12 bits on, 12 bits off. */
289 dpavlin 4 break;
290    
291     case 0x20004:
292     odata = random(); /* IP32 prom test hack. TODO */
293     /* IRIX wants 0x20, it seems. */
294     if (random() & 1)
295     odata = 0x20;
296     break;
297    
298     case 0x30000: /* normal plane ctrl 0 */
299 dpavlin 22 /* bit 15 = fifo reset, 14..13 = depth,
300     12..5 = tile width, 4..0 = rhs */
301 dpavlin 4 if (writeflag == MEM_WRITE) {
302     d->plane0ctrl = idata;
303     d->bitdepth = 8 << ((d->plane0ctrl >> 13) & 3);
304 dpavlin 22 debug("[ sgi_gbe: setting color depth to %i bits ]\n",
305     d->bitdepth);
306 dpavlin 4 if (d->bitdepth != 8)
307 dpavlin 22 fatal("sgi_gbe: warning: bitdepth %i not "
308     "really implemented yet\n", d->bitdepth);
309 dpavlin 4 } else
310     odata = d->plane0ctrl;
311     break;
312    
313     case 0x30008: /* normal plane ctrl 2 */
314     odata = random(); /* IP32 prom test hack. TODO */
315     /* IRIX wants 0x20, it seems. */
316     if (random() & 1)
317     odata = 0x20;
318     break;
319    
320     case 0x3000c: /* normal plane ctrl 3 */
321 dpavlin 22 /*
322     * Writes to 3000c should be readable back at 30008?
323     * At least bit 0 (dma) ctrl 3.
324     *
325     * Bits 31..9 = tile table pointer bits,
326     * Bit 1 = linear
327     * Bit 0 = dma
328     */
329 dpavlin 4 if (writeflag == MEM_WRITE) {
330     d->frm_control = idata;
331 dpavlin 22 debug("[ sgi_gbe: frm_control = 0x%08x ]\n",
332     d->frm_control);
333 dpavlin 4 } else
334     odata = d->frm_control;
335     break;
336    
337     case 0x40000:
338     odata = random(); /* IP32 prom test hack. TODO */
339     /* IRIX wants 0x20, it seems. */
340     if (random() & 1)
341     odata = 0x20;
342     break;
343    
344     /*
345 dpavlin 22 * Linux/sgimips seems to write color palette data to offset 0x50000
346     * to 0x503xx, and gamma correction data to 0x60000 - 0x603ff, as
347     * 32-bit values at addresses divisible by 4 (formated as 0xrrggbb00).
348 dpavlin 4 *
349     * sgio2fb: initializing
350     * sgio2fb: I/O at 0xffffffffb6000000
351     * sgio2fb: tiles at ffffffffa2ef5000
352     * sgio2fb: framebuffer at ffffffffa1000000
353     * sgio2fb: 8192kB memory
354     * Console: switching to colour frame buffer device 80x30
355     */
356    
357     default:
358     /* Gamma correction: */
359     if (relative_addr >= 0x60000 && relative_addr <= 0x603ff) {
360     /* ignore gamma correction for now */
361     break;
362     }
363    
364     /* RGB Palette: */
365     if (relative_addr >= 0x50000 && relative_addr <= 0x503ff) {
366     int color_nr, r, g, b;
367     int old_r, old_g, old_b;
368    
369     color_nr = (relative_addr & 0x3ff) / 4;
370     r = (idata >> 24) & 0xff;
371     g = (idata >> 16) & 0xff;
372     b = (idata >> 8) & 0xff;
373    
374     old_r = d->fb_data->rgb_palette[color_nr * 3 + 0];
375     old_g = d->fb_data->rgb_palette[color_nr * 3 + 1];
376     old_b = d->fb_data->rgb_palette[color_nr * 3 + 2];
377    
378     d->fb_data->rgb_palette[color_nr * 3 + 0] = r;
379     d->fb_data->rgb_palette[color_nr * 3 + 1] = g;
380     d->fb_data->rgb_palette[color_nr * 3 + 2] = b;
381    
382     if (r != old_r || g != old_g || b != old_b) {
383 dpavlin 22 /* If the palette has been changed, the entire
384     image needs to be redrawn... :-/ */
385 dpavlin 4 d->fb_data->update_x1 = 0;
386     d->fb_data->update_x2 = d->fb_data->xsize - 1;
387     d->fb_data->update_y1 = 0;
388     d->fb_data->update_y2 = d->fb_data->ysize - 1;
389     }
390     break;
391     }
392    
393     if (writeflag == MEM_WRITE)
394 dpavlin 22 debug("[ sgi_gbe: unimplemented write to address "
395     "0x%llx, data=0x%llx ]\n",
396     (long long)relative_addr, (long long)idata);
397 dpavlin 4 else
398 dpavlin 22 debug("[ sgi_gbe: unimplemented read from address "
399     "0x%llx ]\n", (long long)relative_addr);
400 dpavlin 4 }
401    
402     if (writeflag == MEM_READ) {
403     #ifdef GBE_DEBUG
404 dpavlin 22 debug("[ sgi_gbe: DEBUG: read from address 0x%llx: 0x%llx ]\n",
405     (long long)relative_addr, (long long)odata);
406 dpavlin 4 #endif
407     memory_writemax64(cpu, data, len, odata);
408     }
409    
410     return 1;
411     }
412    
413    
414     void dev_sgi_gbe_init(struct machine *machine, struct memory *mem,
415     uint64_t baseaddr)
416     {
417     struct sgi_gbe_data *d;
418    
419 dpavlin 42 CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_gbe_data)));
420 dpavlin 4 memset(d, 0, sizeof(struct sgi_gbe_data));
421 dpavlin 14
422     /* 640x480 for Linux: */
423 dpavlin 4 d->xres = GBE_DEFAULT_XRES;
424     d->yres = GBE_DEFAULT_YRES;
425     d->bitdepth = 8;
426     d->control = 0x20aa000; /* or 0x00000001? */
427 dpavlin 14
428     /* 1280x1024 for booting the O2's PROM: */
429     d->xres = 1280; d->yres = 1024;
430    
431 dpavlin 4 d->fb_data = dev_fb_init(machine, mem, FAKE_GBE_FB_ADDRESS,
432 dpavlin 12 VFB_GENERIC, d->xres, d->yres, d->xres, d->yres, 8, "SGI GBE");
433 dpavlin 4 set_grayscale_palette(d->fb_data, 256);
434    
435     memory_device_register(mem, "sgi_gbe", baseaddr, DEV_SGI_GBE_LENGTH,
436 dpavlin 20 dev_sgi_gbe_access, d, DM_DEFAULT, NULL);
437 dpavlin 42 machine_add_tickfunction(machine, dev_sgi_gbe_tick, d, 18);
438 dpavlin 4 }
439    

  ViewVC Help
Powered by ViewVC 1.1.26