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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Mon Oct 8 16:18:00 2007 UTC (13 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 6226 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_bt431.c,v 1.8 2005/02/22 12:15:29 debug Exp $
29 *
30 * Brooktree 431, used by TURBOchannel graphics cards.
31 *
32 * TODO.
33 */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #include "devices.h"
40 #include "memory.h"
41 #include "misc.h"
42
43 #include "bt431reg.h"
44
45
46 struct bt431_data {
47 uint32_t bt431_reg[DEV_BT431_NREGS];
48
49 unsigned char cur_addr_hi;
50 unsigned char cur_addr_lo;
51
52 int planes;
53 int cursor_on;
54 int cursor_x;
55 int cursor_y;
56 int cursor_xsize;
57 int cursor_ysize;
58
59 struct vfb_data *vfb_data;
60 };
61
62
63 /*
64 * dev_bt431_access():
65 */
66 int dev_bt431_access(struct cpu *cpu, struct memory *mem,
67 uint64_t relative_addr, unsigned char *data, size_t len,
68 int writeflag, void *extra)
69 {
70 struct bt431_data *d = (struct bt431_data *) extra;
71 uint64_t idata = 0, odata = 0;
72 int btaddr;
73 #if 0
74 int on, new_cursor_x, new_cursor_y;
75 #endif
76
77
78 idata = memory_readmax64(cpu, data, len);
79
80 btaddr = ((d->cur_addr_hi << 8) + d->cur_addr_lo) % DEV_BT431_NREGS;
81
82 /* TODO */
83
84 /* Read from/write to the bt431: */
85 switch (relative_addr) {
86 case 0x00: /* Low byte of address: */
87 if (writeflag == MEM_WRITE) {
88 debug("[ bt431: write to Low Address Byte, "
89 "0x%02x ]\n", (int)idata);
90 d->cur_addr_lo = idata;
91 } else {
92 odata = d->cur_addr_lo;
93 debug("[ bt431: read from Low Address Byte: "
94 "0x%0x ]\n", (int)odata);
95 }
96 break;
97 case 0x04: /* High byte of address: */
98 if (writeflag == MEM_WRITE) {
99 debug("[ bt431: write to High Address Byte, "
100 "0x%02x ]\n", (int)idata);
101 d->cur_addr_hi = idata;
102 } else {
103 odata = d->cur_addr_hi;
104 debug("[ bt431: read from High Address Byte: "
105 "0x%0x ]\n", (int)odata);
106 }
107 break;
108 case 0x08: /* Register access: */
109 if (writeflag == MEM_WRITE) {
110 debug("[ bt431: write to BT431 register 0x%04x, "
111 "value 0x%02x ]\n", btaddr, (int)idata);
112 d->bt431_reg[btaddr] = idata;
113
114 #if 0
115 /* Write to cursor bitmap: */
116 if (btaddr >= 0x400)
117 bt431_sync_xysize(d);
118 #endif
119 } else {
120 odata = d->bt431_reg[btaddr];
121 debug("[ bt431: read from BT431 register 0x%04x, "
122 "value 0x%02x ]\n", btaddr, (int)odata);
123 }
124
125 /* Go to next register: */
126 d->cur_addr_lo ++;
127 if (d->cur_addr_lo == 0)
128 d->cur_addr_hi ++;
129 break;
130 default:
131 if (writeflag == MEM_WRITE) {
132 debug("[ bt431: unimplemented write to address "
133 "0x%x, data=0x%02x ]\n", (int)relative_addr,
134 (int)idata);
135 } else {
136 debug("[ bt431: unimplemented read from address "
137 "0x%x ]\n", (int)relative_addr);
138 }
139 }
140
141 #if 0
142
143 TODO: This is from bt459!
144
145 /* NetBSD uses 370,37 as magic values. */
146 new_cursor_x = (d->bt431_reg[BT431_REG_CXLO] & 255) +
147 ((d->bt431_reg[BT431_REG_CXHI] & 255) << 8) - 370;
148 new_cursor_y = (d->bt431_reg[BT431_REG_CYLO] & 255) +
149 ((d->bt431_reg[BT431_REG_CYHI] & 255) << 8) - 37;
150
151 /* TODO: what do the bits in the CCR do? */
152 on = d->bt431_reg[BT431_REG_CCR] ? 1 : 0;
153
154 on = 1;
155
156 if (new_cursor_x != d->cursor_x || new_cursor_y != d->cursor_y ||
157 on != d->cursor_on) {
158 int ysize_mul = 1;
159
160 d->cursor_x = new_cursor_x;
161 d->cursor_y = new_cursor_y;
162 d->cursor_on = on;
163
164 /*
165 * Ugly hack for Ultrix:
166 *
167 * Ultrix and NetBSD assume that the cursor works differently.
168 * Ultrix uses the 370,38 coordinates, but draws the cursor
169 * upwards. NetBSD draws it downwards. Ultrix also makes the
170 * cursor smaller (?).
171 *
172 * TODO: This actually depends on which ultrix kernel you use.
173 * Clearly, the BT459 emulation is not implemented well
174 * enough yet.
175 *
176 * TODO: Find out why? Is it because of special BT459
177 * commands?
178 *
179 * TODO: Is the above text even valid anymore? :-)
180 */
181 if (!(d->bt431_reg[BT431_REG_CCR] & 1)) {
182 /* ysize_mul = 4; */
183 d->cursor_y += 5 - (d->cursor_ysize * ysize_mul);
184 }
185
186 debug("[ bt431: cursor = %03i,%03i ]\n", d->cursor_x,
187 d->cursor_y);
188 dev_fb_setcursor(d->vfb_data, d->cursor_x, d->cursor_y, on,
189 d->cursor_xsize, d->cursor_ysize * ysize_mul);
190 }
191 #endif
192
193 if (writeflag == MEM_READ)
194 memory_writemax64(cpu, data, len, odata);
195
196 return 1;
197 }
198
199
200 /*
201 * dev_bt431_init():
202 */
203 void dev_bt431_init(struct memory *mem, uint64_t baseaddr,
204 struct vfb_data *vfb_data, int planes)
205 {
206 struct bt431_data *d = malloc(sizeof(struct bt431_data));
207 if (d == NULL) {
208 fprintf(stderr, "out of memory\n");
209 exit(1);
210 }
211 memset(d, 0, sizeof(struct bt431_data));
212 d->vfb_data = vfb_data;
213 d->planes = planes;
214 d->cursor_x = -1;
215 d->cursor_y = -1;
216 d->cursor_xsize = d->cursor_ysize = 8; /* anything */
217
218 memory_device_register(mem, "bt431", baseaddr, DEV_BT431_LENGTH,
219 dev_bt431_access, (void *)d, MEM_DEFAULT, NULL);
220 }
221

  ViewVC Help
Powered by ViewVC 1.1.26