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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations)
Mon Oct 8 16:18:27 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 4401 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.815 2005/06/27 23:04:35 debug Exp $
20050617	Experimenting some more with netbooting OpenBSD/sgi. Adding
		a hack which allows emulated ethernet networks to be
		distributed across multiple emulator processes.
20050618	Minor updates (documentation, dummy YAMON emulation, etc).
20050620	strcpy/strcat -> strlcpy/strlcat updates.
		Some more progress on evbmips (Malta).
20050621	Adding a section to doc/configfiles.html about ethernet
		emulation across multiple hosts.
		Beginning the work on the ARM translation engine (using the
		dynamic-but-not-binary translation method).
		Fixing a bintrans bug: 0x9fc00000 should always be treated as
		PROM area, just as 0xbfc00000 is.
		Minor progress on Malta emulation (the PCI-ISA bus).
20050622	NetBSD/evbmips can now be installed (using another emulated
		machine) and run (including userland and so on). :-)
		Spliting up the bintrans haddr_entry field into two (one for
		read, one for write). Probably not much of a speed increase,
		though.
		Updating some NetBSD 2.0 -> 2.0.2 in the documentation.
20050623	Minor updates (documentation, the TODO file, etc).
		gzipped kernels are now always automagically gunzipped when
		loaded.
20050624	Adding a dummy Playstation Portable (PSP) mode, just barely
		enough to run Hello World (in weird colors :-).
		Removing the -b command line option; old bintrans is enabled
		by default instead. It makes more sense.
		Trying to finally fix the non-working performance measurement
		thing (instr/second etc).
20050625	Continuing on the essential basics for ARM emulation. Two
		instructions seem to work, a branch and a simple "mov". (The
		mov arguments are not correct yet.) Performance is definitely
		reasonable.
		Various other minor updates.
		Adding the ARM "bl" instruction.
		Adding support for combining multiple ARM instructions into one
		function call. ("mov" + "mov" is the only one implemented so
		far, but it seems to work.)
		Cleaning up some IP32 interrupt things (crime/mace); disabling
		the PS/2 keyboard controller on IP32, so that NetBSD/sgimips
		boots into userland again.
20050626	Finally! NetBSD/sgimips netboots. Adding instructions to
		doc/guestoses.html on how to set up an nfs server etc.
		Various other minor fixes.
		Playstation Portable ".pbp" files can now be used directly.
		(The ELF part of the .pbp is extracted transparently.)
		Converting some sprintf -> snprintf.
		Adding some more instructions to the ARM disassembler.
20050627	More ARM updates. Adding some simple ldr(b), str(b),
		cmps, and conditional branch instructions, enough to run
		a simple Hello World program.
		All ARM instructions are now inlined/generated for all possible
		condition codes.
		Adding add and sub, and more load/store instructions.
		Removing dummy files: cpu_alpha.c, cpu_hppa.c, and cpu_sparc.c.
		Some minor documentation updates; preparing for a 0.3.4
		release. Updating some URLs.

==============  RELEASE 0.3.4  ==============


1 /*
2 * Copyright (C) 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_malta.c,v 1.2 2005/06/22 00:39:45 debug Exp $
29 *
30 * Malta (evbmips) interrupt controller.
31 *
32 * TODO: This is basically a dummy device so far.
33 */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #include "cpu.h"
40 #include "device.h"
41 #include "devices.h"
42 #include "emul.h"
43 #include "machine.h"
44 #include "memory.h"
45 #include "misc.h"
46
47
48 /*
49 * dev_malta_hi_access():
50 */
51 int dev_malta_hi_access(struct cpu *cpu, struct memory *mem,
52 uint64_t relative_addr, unsigned char *data, size_t len,
53 int writeflag, void *extra)
54 {
55 struct malta_data *d = (struct malta_data *) extra;
56 uint64_t idata = 0, odata = 0;
57 int i;
58
59 idata = memory_readmax64(cpu, data, len);
60
61 switch (relative_addr) {
62 case 0: if (writeflag == MEM_READ) {
63 odata = 0;
64 for (i=0; i<7; i++)
65 if (d->assert_hi & (1<<i))
66 odata = i;
67 if (odata)
68 odata |= 0x80;
69 d->assert_hi = 0;
70 cpu_interrupt_ack(cpu, 8 + 2);
71 } else {
72 /* TODO */
73 }
74 break;
75 default:if (writeflag == MEM_WRITE) {
76 fatal("[ malta: hi unimplemented write to "
77 "offset 0x%x: data=0x%02x ]\n", (int)
78 relative_addr, (int)idata);
79 } else {
80 fatal("[ malta: hi unimplemented read from "
81 "offset 0x%x ]\n", (int)relative_addr);
82 }
83 }
84
85 if (writeflag == MEM_READ)
86 memory_writemax64(cpu, data, len, odata);
87
88 return 1;
89 }
90
91
92 /*
93 * dev_malta_access():
94 */
95 int dev_malta_access(struct cpu *cpu, struct memory *mem,
96 uint64_t relative_addr, unsigned char *data, size_t len,
97 int writeflag, void *extra)
98 {
99 struct malta_data *d = (struct malta_data *) extra;
100 uint64_t idata = 0, odata = 0;
101 int i;
102
103 idata = memory_readmax64(cpu, data, len);
104
105 switch (relative_addr) {
106 case 0: if (writeflag == MEM_READ) {
107 odata = 0;
108 for (i=0; i<7; i++)
109 if (d->assert_lo & (1<<i))
110 odata = i;
111 if (odata)
112 odata |= 0x80;
113 d->assert_lo = 0;
114 cpu_interrupt_ack(cpu, 8 + 16);
115 } else {
116 /* TODO */
117 }
118 break;
119 default:if (writeflag == MEM_WRITE) {
120 fatal("[ malta: unimplemented write to "
121 "offset 0x%x: data=0x%02x ]\n", (int)
122 relative_addr, (int)idata);
123 } else {
124 fatal("[ malta: unimplemented read from "
125 "offset 0x%x ]\n", (int)relative_addr);
126 }
127 }
128
129 if (writeflag == MEM_READ)
130 memory_writemax64(cpu, data, len, odata);
131
132 return 1;
133 }
134
135
136 /*
137 * devinit_malta():
138 */
139 int devinit_malta(struct devinit *devinit)
140 {
141 struct malta_data *d = malloc(sizeof(struct malta_data));
142
143 if (d == NULL) {
144 fprintf(stderr, "out of memory\n");
145 exit(1);
146 }
147 memset(d, 0, sizeof(struct malta_data));
148
149 memory_device_register(devinit->machine->memory, devinit->name,
150 devinit->addr, 1,
151 dev_malta_access, (void *)d, MEM_DEFAULT, NULL);
152 memory_device_register(devinit->machine->memory, devinit->name,
153 devinit->addr + 0x80, 1,
154 dev_malta_hi_access, (void *)d, MEM_DEFAULT, NULL);
155
156 devinit->return_ptr = d;
157
158 return 1;
159 }
160

  ViewVC Help
Powered by ViewVC 1.1.26