/[gxemul]/upstream/0.3.3.2/src/devices/dev_sgi_ip20.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 /upstream/0.3.3.2/src/devices/dev_sgi_ip20.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (show annotations)
Mon Oct 8 16:18:22 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 3685 byte(s)
0.3.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_sgi_ip20.c,v 1.10 2005/02/22 05:52:58 debug Exp $
29 *
30 * SGI IP20 stuff.
31 */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include "devices.h"
38 #include "memory.h"
39 #include "misc.h"
40
41
42 extern int quiet_mode;
43
44
45 /*
46 * dev_sgi_ip20_access():
47 */
48 int dev_sgi_ip20_access(struct cpu *cpu, struct memory *mem,
49 uint64_t relative_addr, unsigned char *data, size_t len,
50 int writeflag, void *extra)
51 {
52 /* struct sgi_ip20_data *d = (struct sgi_ip20_data *) extra; */
53 uint64_t idata = 0, odata = 0;
54
55 idata = memory_readmax64(cpu, data, len);
56
57 switch (relative_addr) {
58 case 0x38:
59 if (writeflag == MEM_WRITE) {
60 debug("[ sgi_ip20: write to address 0x%x, "
61 "data=0x%02x ]\n", (int)relative_addr, (int)idata);
62 } else {
63 /*
64 * TODO:
65 *
66 * I haven't had time to figure out what values should
67 * be returned by this device. Simple bit patterns
68 * don't seem to be enough, but using random() is
69 * obviously pretty bad. This must be fixed some day.
70 */
71
72 /* instruction_trace = 1; quiet_mode = 0; */
73 odata = random() & 0xff;
74
75 debug("[ sgi_ip20: read from address 0x%x: 0x%x ]\n",
76 (int)relative_addr, (int)odata);
77 }
78 break;
79 default:
80 if (writeflag == MEM_WRITE) {
81 debug("[ sgi_ip20: unimplemented write to address "
82 "0x%x, data=0x%02x ]\n", (int)relative_addr,
83 (int)idata);
84 } else {
85 debug("[ sgi_ip20: unimplemented read from address "
86 "0x%x ]\n", (int)relative_addr);
87 }
88 }
89
90 if (writeflag == MEM_READ)
91 memory_writemax64(cpu, data, len, odata);
92
93 return 1;
94 }
95
96
97 /*
98 * dev_sgi_ip20_init():
99 */
100 struct sgi_ip20_data *dev_sgi_ip20_init(struct cpu *cpu, struct memory *mem,
101 uint64_t baseaddr)
102 {
103 struct sgi_ip20_data *d = malloc(sizeof(struct sgi_ip20_data));
104 if (d == NULL) {
105 fprintf(stderr, "out of memory\n");
106 exit(1);
107 }
108 memset(d, 0, sizeof(struct sgi_ip20_data));
109
110 /*
111 * This device is detected as int0 by NetBSD 2.0_BETA, so I call it
112 * "sgi_ip20_int".
113 */
114 memory_device_register(mem, "sgi_ip20_int", baseaddr,
115 DEV_SGI_IP20_LENGTH, dev_sgi_ip20_access, (void *)d,
116 MEM_DEFAULT, NULL);
117
118 return d;
119 }
120

  ViewVC Help
Powered by ViewVC 1.1.26