/[gxemul]/trunk/src/devices/dev_pmagja.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

Contents of /trunk/src/devices/dev_pmagja.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Mon Oct 8 16:18:00 2007 UTC (12 years, 3 months ago) by dpavlin
File MIME type: text/plain
File size: 6248 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.707 2005/04/27 16:37:33 debug Exp $
20050408	Some minor updates to the wdc. Linux now doesn't complain
		anymore if a disk is non-present.
20050409	Various minor fixes (a bintrans bug, and some other things).
		The wdc seems to work with Playstation2 emulation, but there
		is a _long_ annoying delay when disks are detected.
		Fixing a really important bintrans bug (when devices and RAM
		are mixed within 4KB pages), which was triggered with
		NetBSD/playstation2 kernels.
20050410	Adding a dummy dev_ps2_ether (just so that NetBSD doesn't
		complain as much during bootup).
		Symbols starting with '$' are now ignored.
		Renaming dev_ps2_ohci.c to dev_ohci.c, etc.
20050411	Moving the bintrans-cache-isolation check from cpu_mips.c to
		cpu_mips_coproc.c. (I thought this would give a speedup, but
		it's not noticable.)
		Better playstation2 sbus interrupt code.
		Skip ahead many ticks if the count register is read manually.
		(This increases the speed of delay-loops that simply read
		the count register.)
20050412	Updates to the playstation2 timer/interrupt code.
		Some other minor updates.
20050413	NetBSD/cobalt runs from a disk image :-) including userland;
		updating the documentation on how to install NetBSD/cobalt
		using NetBSD/pmax (!).
		Some minor bintrans updates (no real speed improvement) and
		other minor updates (playstation2 now uses the -o options).
20050414	Adding a dummy x86 (and AMD64) mode.
20050415	Adding some (32-bit and 16-bit) x86 instructions.
		Adding some initial support for non-SCSI, non-IDE floppy
		images. (The x86 mode can boot from these, more or less.)
		Moving the devices/ and include/ directories to src/devices/
		and src/include/, respectively.
20050416	Continuing on the x86 stuff. (Adding pc_bios.c and some simple
		support for software interrupts in 16-bit mode.)
20050417	Ripping out most of the x86 instruction decoding stuff, trying
		to rewrite it in a cleaner way.
		Disabling some of the least working CPU families in the
		configure script (sparc, x86, alpha, hppa), so that they are
		not enabled by default.
20050418	Trying to fix the bug which caused problems when turning on
		and off bintrans interactively, by flushing the bintrans cache
		whenever bintrans is manually (re)enabled.
20050419	Adding the 'lswi' ppc instruction.
		Minor updates to the x86 instruction decoding.
20050420	Renaming x86 register name indices from R_xx to X86_R_xx (this
		makes building on Tru64 nicer).
20050422	Adding a check for duplicate MIPS TLB entries on tlbwr/tlbwi.
20050427	Adding screenshots to guestoses.html.
		Some minor fixes and testing for the next release.

==============  RELEASE 0.3.2  ==============


1 /*
2 * Copyright (C) 2004-2005 Anders Gavare. All rights reserved.
3 *
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 * $Id: dev_pmagja.c,v 1.13 2005/02/11 09:53:48 debug Exp $
29 *
30 * TURBOchannel PMAG-JA graphics device.
31 *
32 * TODO
33 */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #include "devices.h"
40 #include "machine.h"
41 #include "memory.h"
42 #include "misc.h"
43
44
45 #define XSIZE 1280
46 #define YSIZE 1024
47
48 #define PMAGJA_FIRSTOFFSET 0x40030
49
50 /* #define JA_DEBUG */
51
52 struct pmagja_data {
53 int irq_nr;
54 struct memory *fb_mem;
55 struct vfb_data *vfb_data;
56
57 unsigned char pixeldata[XSIZE * YSIZE];
58
59 int current_r;
60 int current_g;
61 int current_b;
62
63 int pip_offset;
64 };
65
66
67 /*
68 * dev_pmagja_access():
69 */
70 int dev_pmagja_access(struct cpu *cpu, struct memory *mem,
71 uint64_t relative_addr, unsigned char *data, size_t len,
72 int writeflag, void *extra)
73 {
74 uint64_t idata = 0, odata = 0;
75 struct pmagja_data *d = extra;
76 int i, res = 1;
77
78 relative_addr += PMAGJA_FIRSTOFFSET;
79
80 idata = memory_readmax64(cpu, data, len);
81
82 #ifdef JA_DEBUG
83 {
84 int i;
85 for (i=0; i<len; i++)
86 if (data[i] != 0 && data[i] != 1 && data[i]!=0xff)
87 if (writeflag)
88 fatal("[ pmagja: write to addr 0x%08llx: 0x%08llx ]\n",
89 (long long)relative_addr, (long long)idata);
90 }
91 #endif
92
93 switch (relative_addr) {
94 case 0x0800c4: /* pip offset */
95 if (writeflag==MEM_READ) {
96 odata = d->pip_offset;
97 debug("[ pmagja: read from pip offset: 0x%08llx ]\n",
98 (long long)odata);
99 } else {
100 d->pip_offset = idata;
101 debug("[ px: write to pip offset: 0x%08llx ]\n",
102 (long long)idata);
103 }
104 break;
105 default:
106 if (relative_addr >= 0x200000) {
107 /* 8-bit access: */
108 for (i=0; i<len; i++) {
109 int ofs = relative_addr - 0x200000 + i;
110 int x, y;
111 unsigned char newdata[3];
112 y = ofs / XSIZE;
113 x = ofs - y*XSIZE;
114
115 if (writeflag) {
116 d->pixeldata[x + y*XSIZE] = data[i];
117 newdata[0] = d->vfb_data->rgb_palette[
118 data[i] * 3 + 0];
119 newdata[1] = d->vfb_data->rgb_palette[
120 data[i] * 3 + 1];
121 newdata[2] = d->vfb_data->rgb_palette[
122 data[i] * 3 + 2];
123 dev_fb_access(cpu, d->fb_mem, (x +
124 y * XSIZE) * 3, newdata, 3,
125 writeflag, d->vfb_data);
126 } else {
127 data[i] = d->pixeldata[x + y*XSIZE];
128 }
129 }
130 /* Return success. */
131 return 1;
132 } else if (relative_addr >= 0x100000 &&
133 relative_addr < 0x200000) {
134 /* 24-bit access: */
135 #if 0
136 {
137 if (writeflag)
138 if (idata != 0)
139 fatal("[ pmagja: write to addr 0x%08llx: 0x%08llx ]\n",
140 (long long)relative_addr, (long long)idata);
141 }
142 #endif
143 int x, y, ofs;
144
145 ofs = (relative_addr - 0x100000) * 2;
146 y = ofs / XSIZE;
147 x = ofs - y * XSIZE;
148
149 #if 0
150 if (writeflag == MEM_WRITE) {
151 int ix;
152 for (ix=0; ix<len*2; ix++) {
153 unsigned char data[3];
154 int ctype;
155
156 data[0] = data[1] = data[2] = 0;
157 ctype = (idata >> (ix*4)) & 0xf;
158 if (ctype == 0)
159 data[0] = 255;
160 if (ctype == 3)
161 data[1] = 255;
162 if (ctype == 0xf)
163 data[2] = 255;
164
165 res = dev_fb_access(cpu, d->fb_mem,
166 ofs * 3, data, 3, MEM_WRITE,
167 d->vfb_data);
168 ofs ++;
169 }
170 }
171 #endif
172 return 1;
173 } else {
174 /* Unknown: */
175 if (writeflag==MEM_READ) {
176 fatal("[ pmagja: read from addr 0x%x: "
177 "0x%llx ]\n", (int)relative_addr,
178 (long long)odata);
179 } else {
180 fatal("[ pmagja: write to addr 0x%x: "
181 "0x%llx ]\n", (int)relative_addr,
182 (long long)idata);
183 }
184 }
185 }
186
187 if (writeflag == MEM_READ)
188 memory_writemax64(cpu, data, len, odata);
189
190 #ifdef JA_DEBUG
191 /*
192 if (!writeflag)
193 fatal("[ pmagja: read from addr 0x%08llx: 0x%08llx ]\n",
194 (long long)relative_addr, (long long)odata);
195 */
196 #endif
197
198 return res;
199 }
200
201
202 /*
203 * dev_pmagja_init():
204 */
205 void dev_pmagja_init(struct machine *machine, struct memory *mem,
206 uint64_t baseaddr, int irq_nr)
207 {
208 struct pmagja_data *d;
209
210 d = malloc(sizeof(struct pmagja_data));
211 if (d == NULL) {
212 fprintf(stderr, "out of memory\n");
213 exit(1);
214 }
215 memset(d, 0, sizeof(struct pmagja_data));
216
217 d->irq_nr = irq_nr;
218
219 d->fb_mem = memory_new(XSIZE * YSIZE * 3);
220 if (d->fb_mem == NULL) {
221 fprintf(stderr, "dev_pmagja_init(): out of memory (1)\n");
222 exit(1);
223 }
224 d->vfb_data = dev_fb_init(machine, d->fb_mem, 0, VFB_GENERIC,
225 XSIZE, YSIZE, XSIZE, YSIZE, 24, "PMAG-JA", 1);
226 if (d->vfb_data == NULL) {
227 fprintf(stderr, "dev_pmagja_init(): out of memory (2)\n");
228 exit(2);
229 }
230
231 /* TODO: not bt459, but a bt463: */
232 dev_bt459_init(machine, mem, baseaddr + 0x40000, 0, d->vfb_data, 8,
233 irq_nr, 0); /* palette (TODO: type) */
234 dev_bt431_init(mem, baseaddr + 0x40010, d->vfb_data, 8); /* cursor */
235
236 memory_device_register(mem, "pmagja", baseaddr + PMAGJA_FIRSTOFFSET,
237 DEV_PMAGJA_LENGTH - PMAGJA_FIRSTOFFSET, dev_pmagja_access, d,
238 MEM_DEFAULT, NULL);
239 }
240

  ViewVC Help
Powered by ViewVC 1.1.26