/[gxemul]/upstream/0.4.6/src/devices/dev_mvme187.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.4.6/src/devices/dev_mvme187.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 43 - (show annotations)
Mon Oct 8 16:22:43 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 4475 byte(s)
0.4.6
1 /*
2 * Copyright (C) 2007 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_mvme187.c,v 1.6 2007/06/15 19:57:33 debug Exp $
29 *
30 * COMMENT: MVME187-specific devices and control registers
31 */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include "cpu.h"
38 #include "device.h"
39 #include "emul.h"
40 #include "machine.h"
41 #include "memory.h"
42 #include "misc.h"
43
44
45 #include "mvme187.h"
46 #include "mvme_memcreg.h"
47 #include "m8820x.h"
48
49
50 struct mvme187_data {
51 struct memcreg memcreg;
52 };
53
54
55 DEVICE_ACCESS(mvme187_memc)
56 {
57 uint64_t idata = 0, odata = 0;
58 struct mvme187_data *d = extra;
59 int controller = 0;
60
61 if (writeflag == MEM_WRITE)
62 idata = memory_readmax64(cpu, data, len);
63
64 if (relative_addr & 0x100) {
65 controller = 1;
66 relative_addr &= ~0x100;
67 }
68
69 switch (relative_addr) {
70
71 case 0x08: /* memconf */
72 if (writeflag == MEM_READ) {
73 odata = ((uint8_t*)&d->memcreg)[relative_addr];
74 } else {
75 fatal("mvme187_memc: Write to relative_addr %i not yet"
76 " implemented!\n");
77 exit(1);
78 }
79 break;
80
81 default:fatal("[ mvme187_memc: unimplemented %s offset 0x%x",
82 writeflag == MEM_WRITE? "write to" : "read from",
83 (int) relative_addr);
84 if (writeflag == MEM_WRITE)
85 fatal(": 0x%x", (int)idata);
86 fatal(" ]\n");
87 exit(1);
88 }
89
90 if (writeflag == MEM_READ)
91 memory_writemax64(cpu, data, len, odata);
92
93 return 1;
94 }
95
96
97 DEVINIT(mvme187)
98 {
99 struct mvme187_data *d;
100 char tmpstr[300];
101 struct m8820x_cmmu *cmmu;
102 int size_per_memc, r;
103
104 CHECK_ALLOCATION(d = malloc(sizeof(struct mvme187_data)));
105 memset(d, 0, sizeof(struct mvme187_data));
106
107
108 /*
109 * Two memory controllers per MVME187 machine:
110 */
111
112 size_per_memc = devinit->machine->physical_ram_in_mb / 2 * 1048576;
113 for (r=0; ; r++) {
114 if (MEMC_MEMCONF_RTOB(r) > size_per_memc) {
115 r--;
116 break;
117 }
118 }
119
120 d->memcreg.memc_chipid = MEMC_CHIPID;
121 d->memcreg.memc_chiprev = 1;
122 d->memcreg.memc_memconf = r;
123
124 memory_device_register(devinit->machine->memory, devinit->name,
125 MVME187_MEM_CTLR, 0x200, dev_mvme187_memc_access, (void *)d,
126 DM_DEFAULT, NULL);
127
128
129 /* Instruction CMMU: */
130 CHECK_ALLOCATION(cmmu = malloc(sizeof(struct m8820x_cmmu)));
131 memset(cmmu, 0, sizeof(struct m8820x_cmmu));
132
133 devinit->machine->cpus[devinit->machine->bootstrap_cpu]->
134 cd.m88k.cmmu[0] = cmmu;
135 /* This is a 88200, revision 9: */
136 cmmu->reg[CMMU_IDR] = (M88200_ID << 21) | (9 << 16);
137 snprintf(tmpstr, sizeof(tmpstr),
138 "m8820x addr=0x%x addr2=0", MVME187_SBC_CMMU_I);
139 device_add(devinit->machine, tmpstr);
140
141 /* ... and data CMMU: */
142 CHECK_ALLOCATION(cmmu = malloc(sizeof(struct m8820x_cmmu)));
143 memset(cmmu, 0, sizeof(struct m8820x_cmmu));
144
145 devinit->machine->cpus[devinit->machine->bootstrap_cpu]->
146 cd.m88k.cmmu[1] = cmmu;
147 /* This is also a 88200, revision 9: */
148 cmmu->reg[CMMU_IDR] = (M88200_ID << 21) | (9 << 16);
149 cmmu->batc[8] = BATC8;
150 cmmu->batc[9] = BATC9;
151 snprintf(tmpstr, sizeof(tmpstr),
152 "m8820x addr=0x%x addr2=1", MVME187_SBC_CMMU_D);
153 device_add(devinit->machine, tmpstr);
154
155
156 return 1;
157 }
158

  ViewVC Help
Powered by ViewVC 1.1.26