dev_sgi_ip20.cc Source File

Back to the index.

dev_sgi_ip20.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-2009 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  * COMMENT: SGI IP20 stuff
29  *
30  * TODO.
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 DEVICE_ACCESS(sgi_ip20)
46 {
47  /* struct sgi_ip20_data *d = extra; */
48  uint64_t idata = 0, odata = 0;
49 
50  if (writeflag == MEM_WRITE)
51  idata = memory_readmax64(cpu, data, len);
52 
53  switch (relative_addr) {
54 
55  case 0x38:
56  if (writeflag == MEM_WRITE) {
57  debug("[ sgi_ip20: write to address 0x%x, "
58  "data=0x%02x ]\n", (int)relative_addr, (int)idata);
59  } else {
60  /*
61  * TODO:
62  *
63  * I haven't had time to figure out what values should
64  * be returned by this device. Simple bit patterns
65  * don't seem to be enough, but using random() is
66  * obviously pretty bad. This must be fixed some day.
67  */
68 
69  /* instruction_trace = 1; quiet_mode = 0; */
70  odata = random() & 0xff;
71 
72  debug("[ sgi_ip20: read from address 0x%x: 0x%x ]\n",
73  (int)relative_addr, (int)odata);
74  }
75  break;
76 
77  default:
78  if (writeflag == MEM_WRITE) {
79  debug("[ sgi_ip20: unimplemented write to address "
80  "0x%x, data=0x%02x ]\n", (int)relative_addr,
81  (int)idata);
82  } else {
83  debug("[ sgi_ip20: unimplemented read from address "
84  "0x%x ]\n", (int)relative_addr);
85  }
86  }
87 
88  if (writeflag == MEM_READ)
89  memory_writemax64(cpu, data, len, odata);
90 
91  return 1;
92 }
93 
94 
95 struct sgi_ip20_data *dev_sgi_ip20_init(struct cpu *cpu, struct memory *mem,
96  uint64_t baseaddr)
97 {
98  struct sgi_ip20_data *d;
99 
100  CHECK_ALLOCATION(d = (struct sgi_ip20_data *) malloc(sizeof(struct sgi_ip20_data)));
101  memset(d, 0, sizeof(struct sgi_ip20_data));
102 
103  /*
104  * This device is detected as int0 by NetBSD 2.0_BETA, so I call it
105  * "sgi_ip20_int".
106  */
107  memory_device_register(mem, "sgi_ip20_int", baseaddr,
109  DM_DEFAULT, NULL);
110 
111  return d;
112 }
113 
uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len)
Definition: memory.cc:55
#define DM_DEFAULT
Definition: memory.h:130
#define MEM_READ
Definition: memory.h:116
int quiet_mode
Definition: main.cc:78
struct sgi_ip20_data * dev_sgi_ip20_init(struct cpu *cpu, struct memory *mem, uint64_t baseaddr)
Definition: dev_sgi_ip20.cc:95
DEVICE_ACCESS(sgi_ip20)
Definition: dev_sgi_ip20.cc:45
#define CHECK_ALLOCATION(ptr)
Definition: misc.h:239
u_short data
Definition: siireg.h:79
#define MEM_WRITE
Definition: memory.h:117
int dev_sgi_ip20_access(struct cpu *cpu, struct memory *mem, uint64_t relative_addr, unsigned char *data, size_t len, int writeflag, void *)
#define debug
Definition: dev_adb.cc:57
Definition: cpu.h:326
void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len, uint64_t data)
Definition: memory.cc:89
void memory_device_register(struct memory *mem, const char *, uint64_t baseaddr, uint64_t len, int(*f)(struct cpu *, struct memory *, uint64_t, unsigned char *, size_t, int, void *), void *extra, int flags, unsigned char *dyntrans_data)
Definition: memory.cc:339
Definition: memory.h:75
#define DEV_SGI_IP20_LENGTH
Definition: devices.h:425

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13