root / hw / sh7750.c @ 00dbbb03
History | View | Annotate | Download (19.1 kB)
1 | 27c7ca7e | bellard | /*
|
---|---|---|---|
2 | 27c7ca7e | bellard | * SH7750 device
|
3 | 5fafdf24 | ths | *
|
4 | 80f515e6 | balrog | * Copyright (c) 2007 Magnus Damm
|
5 | 27c7ca7e | bellard | * Copyright (c) 2005 Samuel Tardieu
|
6 | 5fafdf24 | ths | *
|
7 | 27c7ca7e | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | 27c7ca7e | bellard | * of this software and associated documentation files (the "Software"), to deal
|
9 | 27c7ca7e | bellard | * in the Software without restriction, including without limitation the rights
|
10 | 27c7ca7e | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | 27c7ca7e | bellard | * copies of the Software, and to permit persons to whom the Software is
|
12 | 27c7ca7e | bellard | * furnished to do so, subject to the following conditions:
|
13 | 27c7ca7e | bellard | *
|
14 | 27c7ca7e | bellard | * The above copyright notice and this permission notice shall be included in
|
15 | 27c7ca7e | bellard | * all copies or substantial portions of the Software.
|
16 | 27c7ca7e | bellard | *
|
17 | 27c7ca7e | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | 27c7ca7e | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | 27c7ca7e | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | 27c7ca7e | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | 27c7ca7e | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | 27c7ca7e | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | 27c7ca7e | bellard | * THE SOFTWARE.
|
24 | 27c7ca7e | bellard | */
|
25 | 27c7ca7e | bellard | #include <stdio.h> |
26 | 27c7ca7e | bellard | #include <assert.h> |
27 | 87ecb68b | pbrook | #include "hw.h" |
28 | 87ecb68b | pbrook | #include "sh.h" |
29 | 87ecb68b | pbrook | #include "sysemu.h" |
30 | 27c7ca7e | bellard | #include "sh7750_regs.h" |
31 | 27c7ca7e | bellard | #include "sh7750_regnames.h" |
32 | 80f515e6 | balrog | #include "sh_intc.h" |
33 | 06afe2c8 | aurel32 | #include "exec-all.h" |
34 | 29e179bc | aurel32 | #include "cpu.h" |
35 | 27c7ca7e | bellard | |
36 | 27c7ca7e | bellard | #define NB_DEVICES 4 |
37 | 27c7ca7e | bellard | |
38 | 27c7ca7e | bellard | typedef struct SH7750State { |
39 | 27c7ca7e | bellard | /* CPU */
|
40 | 27c7ca7e | bellard | CPUSH4State *cpu; |
41 | 27c7ca7e | bellard | /* Peripheral frequency in Hz */
|
42 | 27c7ca7e | bellard | uint32_t periph_freq; |
43 | 27c7ca7e | bellard | /* SDRAM controller */
|
44 | 27c7ca7e | bellard | uint16_t rfcr; |
45 | 27c7ca7e | bellard | /* IO ports */
|
46 | 27c7ca7e | bellard | uint16_t gpioic; |
47 | 27c7ca7e | bellard | uint32_t pctra; |
48 | 27c7ca7e | bellard | uint32_t pctrb; |
49 | 27c7ca7e | bellard | uint16_t portdira; /* Cached */
|
50 | 27c7ca7e | bellard | uint16_t portpullupa; /* Cached */
|
51 | 27c7ca7e | bellard | uint16_t portdirb; /* Cached */
|
52 | 27c7ca7e | bellard | uint16_t portpullupb; /* Cached */
|
53 | 27c7ca7e | bellard | uint16_t pdtra; |
54 | 27c7ca7e | bellard | uint16_t pdtrb; |
55 | 27c7ca7e | bellard | uint16_t periph_pdtra; /* Imposed by the peripherals */
|
56 | 27c7ca7e | bellard | uint16_t periph_portdira; /* Direction seen from the peripherals */
|
57 | 27c7ca7e | bellard | uint16_t periph_pdtrb; /* Imposed by the peripherals */
|
58 | 27c7ca7e | bellard | uint16_t periph_portdirb; /* Direction seen from the peripherals */
|
59 | 27c7ca7e | bellard | sh7750_io_device *devices[NB_DEVICES]; /* External peripherals */
|
60 | 3464c589 | ths | |
61 | 3464c589 | ths | uint16_t icr; |
62 | 27c7ca7e | bellard | /* Cache */
|
63 | 27c7ca7e | bellard | uint32_t ccr; |
64 | 27c7ca7e | bellard | |
65 | 80f515e6 | balrog | struct intc_desc intc;
|
66 | cd1a3f68 | ths | } SH7750State; |
67 | 27c7ca7e | bellard | |
68 | 27c7ca7e | bellard | |
69 | 27c7ca7e | bellard | /**********************************************************************
|
70 | 27c7ca7e | bellard | I/O ports
|
71 | 27c7ca7e | bellard | **********************************************************************/
|
72 | 27c7ca7e | bellard | |
73 | 27c7ca7e | bellard | int sh7750_register_io_device(SH7750State * s, sh7750_io_device * device)
|
74 | 27c7ca7e | bellard | { |
75 | 27c7ca7e | bellard | int i;
|
76 | 27c7ca7e | bellard | |
77 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
78 | 27c7ca7e | bellard | if (s->devices[i] == NULL) { |
79 | 27c7ca7e | bellard | s->devices[i] = device; |
80 | 27c7ca7e | bellard | return 0; |
81 | 27c7ca7e | bellard | } |
82 | 27c7ca7e | bellard | } |
83 | 27c7ca7e | bellard | return -1; |
84 | 27c7ca7e | bellard | } |
85 | 27c7ca7e | bellard | |
86 | 27c7ca7e | bellard | static uint16_t portdir(uint32_t v)
|
87 | 27c7ca7e | bellard | { |
88 | 27c7ca7e | bellard | #define EVENPORTMASK(n) ((v & (1<<((n)<<1))) >> (n)) |
89 | 27c7ca7e | bellard | return
|
90 | 27c7ca7e | bellard | EVENPORTMASK(15) | EVENPORTMASK(14) | EVENPORTMASK(13) | |
91 | 27c7ca7e | bellard | EVENPORTMASK(12) | EVENPORTMASK(11) | EVENPORTMASK(10) | |
92 | 27c7ca7e | bellard | EVENPORTMASK(9) | EVENPORTMASK(8) | EVENPORTMASK(7) | |
93 | 27c7ca7e | bellard | EVENPORTMASK(6) | EVENPORTMASK(5) | EVENPORTMASK(4) | |
94 | 27c7ca7e | bellard | EVENPORTMASK(3) | EVENPORTMASK(2) | EVENPORTMASK(1) | |
95 | 27c7ca7e | bellard | EVENPORTMASK(0);
|
96 | 27c7ca7e | bellard | } |
97 | 27c7ca7e | bellard | |
98 | 27c7ca7e | bellard | static uint16_t portpullup(uint32_t v)
|
99 | 27c7ca7e | bellard | { |
100 | 27c7ca7e | bellard | #define ODDPORTMASK(n) ((v & (1<<(((n)<<1)+1))) >> (n)) |
101 | 27c7ca7e | bellard | return
|
102 | 27c7ca7e | bellard | ODDPORTMASK(15) | ODDPORTMASK(14) | ODDPORTMASK(13) | |
103 | 27c7ca7e | bellard | ODDPORTMASK(12) | ODDPORTMASK(11) | ODDPORTMASK(10) | |
104 | 27c7ca7e | bellard | ODDPORTMASK(9) | ODDPORTMASK(8) | ODDPORTMASK(7) | ODDPORTMASK(6) | |
105 | 27c7ca7e | bellard | ODDPORTMASK(5) | ODDPORTMASK(4) | ODDPORTMASK(3) | ODDPORTMASK(2) | |
106 | 27c7ca7e | bellard | ODDPORTMASK(1) | ODDPORTMASK(0); |
107 | 27c7ca7e | bellard | } |
108 | 27c7ca7e | bellard | |
109 | 27c7ca7e | bellard | static uint16_t porta_lines(SH7750State * s)
|
110 | 27c7ca7e | bellard | { |
111 | 27c7ca7e | bellard | return (s->portdira & s->pdtra) | /* CPU */ |
112 | 27c7ca7e | bellard | (s->periph_portdira & s->periph_pdtra) | /* Peripherals */
|
113 | 27c7ca7e | bellard | (~(s->portdira | s->periph_portdira) & s->portpullupa); /* Pullups */
|
114 | 27c7ca7e | bellard | } |
115 | 27c7ca7e | bellard | |
116 | 27c7ca7e | bellard | static uint16_t portb_lines(SH7750State * s)
|
117 | 27c7ca7e | bellard | { |
118 | 27c7ca7e | bellard | return (s->portdirb & s->pdtrb) | /* CPU */ |
119 | 27c7ca7e | bellard | (s->periph_portdirb & s->periph_pdtrb) | /* Peripherals */
|
120 | 27c7ca7e | bellard | (~(s->portdirb | s->periph_portdirb) & s->portpullupb); /* Pullups */
|
121 | 27c7ca7e | bellard | } |
122 | 27c7ca7e | bellard | |
123 | 27c7ca7e | bellard | static void gen_port_interrupts(SH7750State * s) |
124 | 27c7ca7e | bellard | { |
125 | 27c7ca7e | bellard | /* XXXXX interrupts not generated */
|
126 | 27c7ca7e | bellard | } |
127 | 27c7ca7e | bellard | |
128 | 27c7ca7e | bellard | static void porta_changed(SH7750State * s, uint16_t prev) |
129 | 27c7ca7e | bellard | { |
130 | 27c7ca7e | bellard | uint16_t currenta, changes; |
131 | 27c7ca7e | bellard | int i, r = 0; |
132 | 27c7ca7e | bellard | |
133 | 27c7ca7e | bellard | #if 0
|
134 | 27c7ca7e | bellard | fprintf(stderr, "porta changed from 0x%04x to 0x%04x\n",
|
135 | 27c7ca7e | bellard | prev, porta_lines(s));
|
136 | 27c7ca7e | bellard | fprintf(stderr, "pdtra=0x%04x, pctra=0x%08x\n", s->pdtra, s->pctra);
|
137 | 27c7ca7e | bellard | #endif
|
138 | 27c7ca7e | bellard | currenta = porta_lines(s); |
139 | 27c7ca7e | bellard | if (currenta == prev)
|
140 | 27c7ca7e | bellard | return;
|
141 | 27c7ca7e | bellard | changes = currenta ^ prev; |
142 | 27c7ca7e | bellard | |
143 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
144 | 27c7ca7e | bellard | if (s->devices[i] && (s->devices[i]->portamask_trigger & changes)) {
|
145 | 27c7ca7e | bellard | r |= s->devices[i]->port_change_cb(currenta, portb_lines(s), |
146 | 27c7ca7e | bellard | &s->periph_pdtra, |
147 | 27c7ca7e | bellard | &s->periph_portdira, |
148 | 27c7ca7e | bellard | &s->periph_pdtrb, |
149 | 27c7ca7e | bellard | &s->periph_portdirb); |
150 | 27c7ca7e | bellard | } |
151 | 27c7ca7e | bellard | } |
152 | 27c7ca7e | bellard | |
153 | 27c7ca7e | bellard | if (r)
|
154 | 27c7ca7e | bellard | gen_port_interrupts(s); |
155 | 27c7ca7e | bellard | } |
156 | 27c7ca7e | bellard | |
157 | 27c7ca7e | bellard | static void portb_changed(SH7750State * s, uint16_t prev) |
158 | 27c7ca7e | bellard | { |
159 | 27c7ca7e | bellard | uint16_t currentb, changes; |
160 | 27c7ca7e | bellard | int i, r = 0; |
161 | 27c7ca7e | bellard | |
162 | 27c7ca7e | bellard | currentb = portb_lines(s); |
163 | 27c7ca7e | bellard | if (currentb == prev)
|
164 | 27c7ca7e | bellard | return;
|
165 | 27c7ca7e | bellard | changes = currentb ^ prev; |
166 | 27c7ca7e | bellard | |
167 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
168 | 27c7ca7e | bellard | if (s->devices[i] && (s->devices[i]->portbmask_trigger & changes)) {
|
169 | 27c7ca7e | bellard | r |= s->devices[i]->port_change_cb(portb_lines(s), currentb, |
170 | 27c7ca7e | bellard | &s->periph_pdtra, |
171 | 27c7ca7e | bellard | &s->periph_portdira, |
172 | 27c7ca7e | bellard | &s->periph_pdtrb, |
173 | 27c7ca7e | bellard | &s->periph_portdirb); |
174 | 27c7ca7e | bellard | } |
175 | 27c7ca7e | bellard | } |
176 | 27c7ca7e | bellard | |
177 | 27c7ca7e | bellard | if (r)
|
178 | 27c7ca7e | bellard | gen_port_interrupts(s); |
179 | 27c7ca7e | bellard | } |
180 | 27c7ca7e | bellard | |
181 | 27c7ca7e | bellard | /**********************************************************************
|
182 | 27c7ca7e | bellard | Memory
|
183 | 27c7ca7e | bellard | **********************************************************************/
|
184 | 27c7ca7e | bellard | |
185 | 27c7ca7e | bellard | static void error_access(const char *kind, target_phys_addr_t addr) |
186 | 27c7ca7e | bellard | { |
187 | 526ccb7a | balrog | fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") not supported\n", |
188 | 27c7ca7e | bellard | kind, regname(addr), addr); |
189 | 27c7ca7e | bellard | } |
190 | 27c7ca7e | bellard | |
191 | 27c7ca7e | bellard | static void ignore_access(const char *kind, target_phys_addr_t addr) |
192 | 27c7ca7e | bellard | { |
193 | 526ccb7a | balrog | fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") ignored\n", |
194 | 27c7ca7e | bellard | kind, regname(addr), addr); |
195 | 27c7ca7e | bellard | } |
196 | 27c7ca7e | bellard | |
197 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readb(void *opaque, target_phys_addr_t addr) |
198 | 27c7ca7e | bellard | { |
199 | 27c7ca7e | bellard | switch (addr) {
|
200 | 27c7ca7e | bellard | default:
|
201 | 27c7ca7e | bellard | error_access("byte read", addr);
|
202 | 27c7ca7e | bellard | assert(0);
|
203 | 27c7ca7e | bellard | } |
204 | 27c7ca7e | bellard | } |
205 | 27c7ca7e | bellard | |
206 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readw(void *opaque, target_phys_addr_t addr) |
207 | 27c7ca7e | bellard | { |
208 | 27c7ca7e | bellard | SH7750State *s = opaque; |
209 | 27c7ca7e | bellard | |
210 | 27c7ca7e | bellard | switch (addr) {
|
211 | ed8e0a4d | ths | case SH7750_FRQCR_A7:
|
212 | ed8e0a4d | ths | return 0; |
213 | 27c7ca7e | bellard | case SH7750_RFCR_A7:
|
214 | 27c7ca7e | bellard | fprintf(stderr, |
215 | 27c7ca7e | bellard | "Read access to refresh count register, incrementing\n");
|
216 | 27c7ca7e | bellard | return s->rfcr++;
|
217 | 27c7ca7e | bellard | case SH7750_PDTRA_A7:
|
218 | 27c7ca7e | bellard | return porta_lines(s);
|
219 | 27c7ca7e | bellard | case SH7750_PDTRB_A7:
|
220 | 27c7ca7e | bellard | return portb_lines(s);
|
221 | 3464c589 | ths | case 0x1fd00000: |
222 | 3464c589 | ths | return s->icr;
|
223 | 27c7ca7e | bellard | default:
|
224 | 27c7ca7e | bellard | error_access("word read", addr);
|
225 | 27c7ca7e | bellard | assert(0);
|
226 | 27c7ca7e | bellard | } |
227 | 27c7ca7e | bellard | } |
228 | 27c7ca7e | bellard | |
229 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readl(void *opaque, target_phys_addr_t addr) |
230 | 27c7ca7e | bellard | { |
231 | 27c7ca7e | bellard | SH7750State *s = opaque; |
232 | 27c7ca7e | bellard | |
233 | 27c7ca7e | bellard | switch (addr) {
|
234 | 27c7ca7e | bellard | case SH7750_MMUCR_A7:
|
235 | 27c7ca7e | bellard | return s->cpu->mmucr;
|
236 | 27c7ca7e | bellard | case SH7750_PTEH_A7:
|
237 | 27c7ca7e | bellard | return s->cpu->pteh;
|
238 | 27c7ca7e | bellard | case SH7750_PTEL_A7:
|
239 | 27c7ca7e | bellard | return s->cpu->ptel;
|
240 | 27c7ca7e | bellard | case SH7750_TTB_A7:
|
241 | 27c7ca7e | bellard | return s->cpu->ttb;
|
242 | 27c7ca7e | bellard | case SH7750_TEA_A7:
|
243 | 27c7ca7e | bellard | return s->cpu->tea;
|
244 | 27c7ca7e | bellard | case SH7750_TRA_A7:
|
245 | 27c7ca7e | bellard | return s->cpu->tra;
|
246 | 27c7ca7e | bellard | case SH7750_EXPEVT_A7:
|
247 | 27c7ca7e | bellard | return s->cpu->expevt;
|
248 | 27c7ca7e | bellard | case SH7750_INTEVT_A7:
|
249 | 27c7ca7e | bellard | return s->cpu->intevt;
|
250 | 27c7ca7e | bellard | case SH7750_CCR_A7:
|
251 | 27c7ca7e | bellard | return s->ccr;
|
252 | 0fd3ca30 | aurel32 | case 0x1f000030: /* Processor version */ |
253 | 0fd3ca30 | aurel32 | return s->cpu->pvr;
|
254 | 0fd3ca30 | aurel32 | case 0x1f000040: /* Cache version */ |
255 | 0fd3ca30 | aurel32 | return s->cpu->cvr;
|
256 | 0fd3ca30 | aurel32 | case 0x1f000044: /* Processor revision */ |
257 | 0fd3ca30 | aurel32 | return s->cpu->prr;
|
258 | 27c7ca7e | bellard | default:
|
259 | 27c7ca7e | bellard | error_access("long read", addr);
|
260 | 27c7ca7e | bellard | assert(0);
|
261 | 27c7ca7e | bellard | } |
262 | 27c7ca7e | bellard | } |
263 | 27c7ca7e | bellard | |
264 | 27c7ca7e | bellard | static void sh7750_mem_writeb(void *opaque, target_phys_addr_t addr, |
265 | 27c7ca7e | bellard | uint32_t mem_value) |
266 | 27c7ca7e | bellard | { |
267 | 27c7ca7e | bellard | switch (addr) {
|
268 | 27c7ca7e | bellard | /* PRECHARGE ? XXXXX */
|
269 | 27c7ca7e | bellard | case SH7750_PRECHARGE0_A7:
|
270 | 27c7ca7e | bellard | case SH7750_PRECHARGE1_A7:
|
271 | 27c7ca7e | bellard | ignore_access("byte write", addr);
|
272 | 27c7ca7e | bellard | return;
|
273 | 27c7ca7e | bellard | default:
|
274 | 27c7ca7e | bellard | error_access("byte write", addr);
|
275 | 27c7ca7e | bellard | assert(0);
|
276 | 27c7ca7e | bellard | } |
277 | 27c7ca7e | bellard | } |
278 | 27c7ca7e | bellard | |
279 | 27c7ca7e | bellard | static void sh7750_mem_writew(void *opaque, target_phys_addr_t addr, |
280 | 27c7ca7e | bellard | uint32_t mem_value) |
281 | 27c7ca7e | bellard | { |
282 | 27c7ca7e | bellard | SH7750State *s = opaque; |
283 | 27c7ca7e | bellard | uint16_t temp; |
284 | 27c7ca7e | bellard | |
285 | 27c7ca7e | bellard | switch (addr) {
|
286 | 27c7ca7e | bellard | /* SDRAM controller */
|
287 | 27c7ca7e | bellard | case SH7750_BCR2_A7:
|
288 | 27c7ca7e | bellard | case SH7750_BCR3_A7:
|
289 | 27c7ca7e | bellard | case SH7750_RTCOR_A7:
|
290 | 27c7ca7e | bellard | case SH7750_RTCNT_A7:
|
291 | 27c7ca7e | bellard | case SH7750_RTCSR_A7:
|
292 | 27c7ca7e | bellard | ignore_access("word write", addr);
|
293 | 27c7ca7e | bellard | return;
|
294 | 27c7ca7e | bellard | /* IO ports */
|
295 | 27c7ca7e | bellard | case SH7750_PDTRA_A7:
|
296 | 27c7ca7e | bellard | temp = porta_lines(s); |
297 | 27c7ca7e | bellard | s->pdtra = mem_value; |
298 | 27c7ca7e | bellard | porta_changed(s, temp); |
299 | 27c7ca7e | bellard | return;
|
300 | 27c7ca7e | bellard | case SH7750_PDTRB_A7:
|
301 | 27c7ca7e | bellard | temp = portb_lines(s); |
302 | 27c7ca7e | bellard | s->pdtrb = mem_value; |
303 | 27c7ca7e | bellard | portb_changed(s, temp); |
304 | 27c7ca7e | bellard | return;
|
305 | 27c7ca7e | bellard | case SH7750_RFCR_A7:
|
306 | 27c7ca7e | bellard | fprintf(stderr, "Write access to refresh count register\n");
|
307 | 27c7ca7e | bellard | s->rfcr = mem_value; |
308 | 27c7ca7e | bellard | return;
|
309 | 27c7ca7e | bellard | case SH7750_GPIOIC_A7:
|
310 | 27c7ca7e | bellard | s->gpioic = mem_value; |
311 | 27c7ca7e | bellard | if (mem_value != 0) { |
312 | 27c7ca7e | bellard | fprintf(stderr, "I/O interrupts not implemented\n");
|
313 | 27c7ca7e | bellard | assert(0);
|
314 | 27c7ca7e | bellard | } |
315 | 27c7ca7e | bellard | return;
|
316 | 3464c589 | ths | case 0x1fd00000: |
317 | 3464c589 | ths | s->icr = mem_value; |
318 | 3464c589 | ths | return;
|
319 | 27c7ca7e | bellard | default:
|
320 | 27c7ca7e | bellard | error_access("word write", addr);
|
321 | 27c7ca7e | bellard | assert(0);
|
322 | 27c7ca7e | bellard | } |
323 | 27c7ca7e | bellard | } |
324 | 27c7ca7e | bellard | |
325 | 27c7ca7e | bellard | static void sh7750_mem_writel(void *opaque, target_phys_addr_t addr, |
326 | 27c7ca7e | bellard | uint32_t mem_value) |
327 | 27c7ca7e | bellard | { |
328 | 27c7ca7e | bellard | SH7750State *s = opaque; |
329 | 27c7ca7e | bellard | uint16_t temp; |
330 | 27c7ca7e | bellard | |
331 | 27c7ca7e | bellard | switch (addr) {
|
332 | 27c7ca7e | bellard | /* SDRAM controller */
|
333 | 27c7ca7e | bellard | case SH7750_BCR1_A7:
|
334 | 27c7ca7e | bellard | case SH7750_BCR4_A7:
|
335 | 27c7ca7e | bellard | case SH7750_WCR1_A7:
|
336 | 27c7ca7e | bellard | case SH7750_WCR2_A7:
|
337 | 27c7ca7e | bellard | case SH7750_WCR3_A7:
|
338 | 27c7ca7e | bellard | case SH7750_MCR_A7:
|
339 | 27c7ca7e | bellard | ignore_access("long write", addr);
|
340 | 27c7ca7e | bellard | return;
|
341 | 27c7ca7e | bellard | /* IO ports */
|
342 | 27c7ca7e | bellard | case SH7750_PCTRA_A7:
|
343 | 27c7ca7e | bellard | temp = porta_lines(s); |
344 | 27c7ca7e | bellard | s->pctra = mem_value; |
345 | 27c7ca7e | bellard | s->portdira = portdir(mem_value); |
346 | 27c7ca7e | bellard | s->portpullupa = portpullup(mem_value); |
347 | 27c7ca7e | bellard | porta_changed(s, temp); |
348 | 27c7ca7e | bellard | return;
|
349 | 27c7ca7e | bellard | case SH7750_PCTRB_A7:
|
350 | 27c7ca7e | bellard | temp = portb_lines(s); |
351 | 27c7ca7e | bellard | s->pctrb = mem_value; |
352 | 27c7ca7e | bellard | s->portdirb = portdir(mem_value); |
353 | 27c7ca7e | bellard | s->portpullupb = portpullup(mem_value); |
354 | 27c7ca7e | bellard | portb_changed(s, temp); |
355 | 27c7ca7e | bellard | return;
|
356 | 27c7ca7e | bellard | case SH7750_MMUCR_A7:
|
357 | 27c7ca7e | bellard | s->cpu->mmucr = mem_value; |
358 | 27c7ca7e | bellard | return;
|
359 | 27c7ca7e | bellard | case SH7750_PTEH_A7:
|
360 | 06afe2c8 | aurel32 | /* If asid changes, clear all registered tlb entries. */
|
361 | 06afe2c8 | aurel32 | if ((s->cpu->pteh & 0xff) != (mem_value & 0xff)) |
362 | 06afe2c8 | aurel32 | tlb_flush(s->cpu, 1);
|
363 | 27c7ca7e | bellard | s->cpu->pteh = mem_value; |
364 | 27c7ca7e | bellard | return;
|
365 | 27c7ca7e | bellard | case SH7750_PTEL_A7:
|
366 | 27c7ca7e | bellard | s->cpu->ptel = mem_value; |
367 | 27c7ca7e | bellard | return;
|
368 | ea2b542a | aurel32 | case SH7750_PTEA_A7:
|
369 | ea2b542a | aurel32 | s->cpu->ptea = mem_value & 0x0000000f;
|
370 | ea2b542a | aurel32 | return;
|
371 | 27c7ca7e | bellard | case SH7750_TTB_A7:
|
372 | 27c7ca7e | bellard | s->cpu->ttb = mem_value; |
373 | 27c7ca7e | bellard | return;
|
374 | 27c7ca7e | bellard | case SH7750_TEA_A7:
|
375 | 27c7ca7e | bellard | s->cpu->tea = mem_value; |
376 | 27c7ca7e | bellard | return;
|
377 | 27c7ca7e | bellard | case SH7750_TRA_A7:
|
378 | 27c7ca7e | bellard | s->cpu->tra = mem_value & 0x000007ff;
|
379 | 27c7ca7e | bellard | return;
|
380 | 27c7ca7e | bellard | case SH7750_EXPEVT_A7:
|
381 | 27c7ca7e | bellard | s->cpu->expevt = mem_value & 0x000007ff;
|
382 | 27c7ca7e | bellard | return;
|
383 | 27c7ca7e | bellard | case SH7750_INTEVT_A7:
|
384 | 27c7ca7e | bellard | s->cpu->intevt = mem_value & 0x000007ff;
|
385 | 27c7ca7e | bellard | return;
|
386 | 27c7ca7e | bellard | case SH7750_CCR_A7:
|
387 | 27c7ca7e | bellard | s->ccr = mem_value; |
388 | 27c7ca7e | bellard | return;
|
389 | 27c7ca7e | bellard | default:
|
390 | 27c7ca7e | bellard | error_access("long write", addr);
|
391 | 27c7ca7e | bellard | assert(0);
|
392 | 27c7ca7e | bellard | } |
393 | 27c7ca7e | bellard | } |
394 | 27c7ca7e | bellard | |
395 | 27c7ca7e | bellard | static CPUReadMemoryFunc *sh7750_mem_read[] = {
|
396 | 27c7ca7e | bellard | sh7750_mem_readb, |
397 | 27c7ca7e | bellard | sh7750_mem_readw, |
398 | 27c7ca7e | bellard | sh7750_mem_readl |
399 | 27c7ca7e | bellard | }; |
400 | 27c7ca7e | bellard | |
401 | 27c7ca7e | bellard | static CPUWriteMemoryFunc *sh7750_mem_write[] = {
|
402 | 27c7ca7e | bellard | sh7750_mem_writeb, |
403 | 27c7ca7e | bellard | sh7750_mem_writew, |
404 | 27c7ca7e | bellard | sh7750_mem_writel |
405 | 27c7ca7e | bellard | }; |
406 | 27c7ca7e | bellard | |
407 | 80f515e6 | balrog | /* sh775x interrupt controller tables for sh_intc.c
|
408 | 80f515e6 | balrog | * stolen from linux/arch/sh/kernel/cpu/sh4/setup-sh7750.c
|
409 | 80f515e6 | balrog | */
|
410 | 80f515e6 | balrog | |
411 | 80f515e6 | balrog | enum {
|
412 | 80f515e6 | balrog | UNUSED = 0,
|
413 | 80f515e6 | balrog | |
414 | 80f515e6 | balrog | /* interrupt sources */
|
415 | 80f515e6 | balrog | IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
|
416 | 80f515e6 | balrog | HUDI, GPIOI, |
417 | 80f515e6 | balrog | DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2, DMAC_DMTE3, |
418 | 80f515e6 | balrog | DMAC_DMTE4, DMAC_DMTE5, DMAC_DMTE6, DMAC_DMTE7, |
419 | 80f515e6 | balrog | DMAC_DMAE, |
420 | 80f515e6 | balrog | PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON, |
421 | 80f515e6 | balrog | PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3, |
422 | 80f515e6 | balrog | TMU3, TMU4, TMU0, TMU1, TMU2_TUNI, TMU2_TICPI, |
423 | 80f515e6 | balrog | RTC_ATI, RTC_PRI, RTC_CUI, |
424 | 80f515e6 | balrog | SCI1_ERI, SCI1_RXI, SCI1_TXI, SCI1_TEI, |
425 | 80f515e6 | balrog | SCIF_ERI, SCIF_RXI, SCIF_BRI, SCIF_TXI, |
426 | 80f515e6 | balrog | WDT, |
427 | 80f515e6 | balrog | REF_RCMI, REF_ROVI, |
428 | 80f515e6 | balrog | |
429 | 80f515e6 | balrog | /* interrupt groups */
|
430 | 80f515e6 | balrog | DMAC, PCIC1, TMU2, RTC, SCI1, SCIF, REF, |
431 | 80f515e6 | balrog | |
432 | 80f515e6 | balrog | NR_SOURCES, |
433 | 80f515e6 | balrog | }; |
434 | 80f515e6 | balrog | |
435 | 80f515e6 | balrog | static struct intc_vect vectors[] = { |
436 | 80f515e6 | balrog | INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620), |
437 | 80f515e6 | balrog | INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), |
438 | 80f515e6 | balrog | INTC_VECT(TMU2_TUNI, 0x440), INTC_VECT(TMU2_TICPI, 0x460), |
439 | 80f515e6 | balrog | INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0), |
440 | 80f515e6 | balrog | INTC_VECT(RTC_CUI, 0x4c0),
|
441 | 80f515e6 | balrog | INTC_VECT(SCI1_ERI, 0x4e0), INTC_VECT(SCI1_RXI, 0x500), |
442 | 80f515e6 | balrog | INTC_VECT(SCI1_TXI, 0x520), INTC_VECT(SCI1_TEI, 0x540), |
443 | 80f515e6 | balrog | INTC_VECT(SCIF_ERI, 0x700), INTC_VECT(SCIF_RXI, 0x720), |
444 | 80f515e6 | balrog | INTC_VECT(SCIF_BRI, 0x740), INTC_VECT(SCIF_TXI, 0x760), |
445 | 80f515e6 | balrog | INTC_VECT(WDT, 0x560),
|
446 | 80f515e6 | balrog | INTC_VECT(REF_RCMI, 0x580), INTC_VECT(REF_ROVI, 0x5a0), |
447 | 80f515e6 | balrog | }; |
448 | 80f515e6 | balrog | |
449 | 80f515e6 | balrog | static struct intc_group groups[] = { |
450 | 80f515e6 | balrog | INTC_GROUP(TMU2, TMU2_TUNI, TMU2_TICPI), |
451 | 80f515e6 | balrog | INTC_GROUP(RTC, RTC_ATI, RTC_PRI, RTC_CUI), |
452 | 80f515e6 | balrog | INTC_GROUP(SCI1, SCI1_ERI, SCI1_RXI, SCI1_TXI, SCI1_TEI), |
453 | 80f515e6 | balrog | INTC_GROUP(SCIF, SCIF_ERI, SCIF_RXI, SCIF_BRI, SCIF_TXI), |
454 | 80f515e6 | balrog | INTC_GROUP(REF, REF_RCMI, REF_ROVI), |
455 | 80f515e6 | balrog | }; |
456 | 80f515e6 | balrog | |
457 | 80f515e6 | balrog | static struct intc_prio_reg prio_registers[] = { |
458 | 80f515e6 | balrog | { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } }, |
459 | 80f515e6 | balrog | { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } }, |
460 | 80f515e6 | balrog | { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } }, |
461 | 80f515e6 | balrog | { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } }, |
462 | 80f515e6 | balrog | { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0, |
463 | 80f515e6 | balrog | TMU4, TMU3, |
464 | 80f515e6 | balrog | PCIC1, PCIC0_PCISERR } }, |
465 | 80f515e6 | balrog | }; |
466 | 80f515e6 | balrog | |
467 | 80f515e6 | balrog | /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
|
468 | 80f515e6 | balrog | |
469 | 80f515e6 | balrog | static struct intc_vect vectors_dma4[] = { |
470 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE0, 0x640), INTC_VECT(DMAC_DMTE1, 0x660), |
471 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE2, 0x680), INTC_VECT(DMAC_DMTE3, 0x6a0), |
472 | 80f515e6 | balrog | INTC_VECT(DMAC_DMAE, 0x6c0),
|
473 | 80f515e6 | balrog | }; |
474 | 80f515e6 | balrog | |
475 | 80f515e6 | balrog | static struct intc_group groups_dma4[] = { |
476 | 80f515e6 | balrog | INTC_GROUP(DMAC, DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2, |
477 | 80f515e6 | balrog | DMAC_DMTE3, DMAC_DMAE), |
478 | 80f515e6 | balrog | }; |
479 | 80f515e6 | balrog | |
480 | 80f515e6 | balrog | /* SH7750R and SH7751R both have 8-channel DMA controllers */
|
481 | 80f515e6 | balrog | |
482 | 80f515e6 | balrog | static struct intc_vect vectors_dma8[] = { |
483 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE0, 0x640), INTC_VECT(DMAC_DMTE1, 0x660), |
484 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE2, 0x680), INTC_VECT(DMAC_DMTE3, 0x6a0), |
485 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE4, 0x780), INTC_VECT(DMAC_DMTE5, 0x7a0), |
486 | 80f515e6 | balrog | INTC_VECT(DMAC_DMTE6, 0x7c0), INTC_VECT(DMAC_DMTE7, 0x7e0), |
487 | 80f515e6 | balrog | INTC_VECT(DMAC_DMAE, 0x6c0),
|
488 | 80f515e6 | balrog | }; |
489 | 80f515e6 | balrog | |
490 | 80f515e6 | balrog | static struct intc_group groups_dma8[] = { |
491 | 80f515e6 | balrog | INTC_GROUP(DMAC, DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2, |
492 | 80f515e6 | balrog | DMAC_DMTE3, DMAC_DMTE4, DMAC_DMTE5, |
493 | 80f515e6 | balrog | DMAC_DMTE6, DMAC_DMTE7, DMAC_DMAE), |
494 | 80f515e6 | balrog | }; |
495 | 80f515e6 | balrog | |
496 | 80f515e6 | balrog | /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
|
497 | 80f515e6 | balrog | |
498 | 80f515e6 | balrog | static struct intc_vect vectors_tmu34[] = { |
499 | 80f515e6 | balrog | INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80), |
500 | 80f515e6 | balrog | }; |
501 | 80f515e6 | balrog | |
502 | 80f515e6 | balrog | static struct intc_mask_reg mask_registers[] = { |
503 | 80f515e6 | balrog | { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */ |
504 | 80f515e6 | balrog | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
505 | 80f515e6 | balrog | 0, 0, 0, 0, 0, 0, TMU4, TMU3, |
506 | 80f515e6 | balrog | PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON, |
507 | 80f515e6 | balrog | PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, |
508 | 80f515e6 | balrog | PCIC1_PCIDMA3, PCIC0_PCISERR } }, |
509 | 80f515e6 | balrog | }; |
510 | 80f515e6 | balrog | |
511 | 80f515e6 | balrog | /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
|
512 | 80f515e6 | balrog | |
513 | 80f515e6 | balrog | static struct intc_vect vectors_irlm[] = { |
514 | 80f515e6 | balrog | INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0), |
515 | 80f515e6 | balrog | INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360), |
516 | 80f515e6 | balrog | }; |
517 | 80f515e6 | balrog | |
518 | 80f515e6 | balrog | /* SH7751 and SH7751R both have PCI */
|
519 | 80f515e6 | balrog | |
520 | 80f515e6 | balrog | static struct intc_vect vectors_pci[] = { |
521 | 80f515e6 | balrog | INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0), |
522 | 80f515e6 | balrog | INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0), |
523 | 80f515e6 | balrog | INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60), |
524 | 80f515e6 | balrog | INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20), |
525 | 80f515e6 | balrog | }; |
526 | 80f515e6 | balrog | |
527 | 80f515e6 | balrog | static struct intc_group groups_pci[] = { |
528 | 80f515e6 | balrog | INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON, |
529 | 80f515e6 | balrog | PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3), |
530 | 80f515e6 | balrog | }; |
531 | 80f515e6 | balrog | |
532 | 29e179bc | aurel32 | /**********************************************************************
|
533 | 29e179bc | aurel32 | Memory mapped cache and TLB
|
534 | 29e179bc | aurel32 | **********************************************************************/
|
535 | 29e179bc | aurel32 | |
536 | 29e179bc | aurel32 | #define MM_REGION_MASK 0x07000000 |
537 | 29e179bc | aurel32 | #define MM_ICACHE_ADDR (0) |
538 | 29e179bc | aurel32 | #define MM_ICACHE_DATA (1) |
539 | 29e179bc | aurel32 | #define MM_ITLB_ADDR (2) |
540 | 29e179bc | aurel32 | #define MM_ITLB_DATA (3) |
541 | 29e179bc | aurel32 | #define MM_OCACHE_ADDR (4) |
542 | 29e179bc | aurel32 | #define MM_OCACHE_DATA (5) |
543 | 29e179bc | aurel32 | #define MM_UTLB_ADDR (6) |
544 | 29e179bc | aurel32 | #define MM_UTLB_DATA (7) |
545 | 29e179bc | aurel32 | #define MM_REGION_TYPE(addr) ((addr & MM_REGION_MASK) >> 24) |
546 | 29e179bc | aurel32 | |
547 | 29e179bc | aurel32 | static uint32_t invalid_read(void *opaque, target_phys_addr_t addr) |
548 | 29e179bc | aurel32 | { |
549 | 29e179bc | aurel32 | assert(0);
|
550 | 29e179bc | aurel32 | |
551 | 29e179bc | aurel32 | return 0; |
552 | 29e179bc | aurel32 | } |
553 | 29e179bc | aurel32 | |
554 | 29e179bc | aurel32 | static uint32_t sh7750_mmct_readl(void *opaque, target_phys_addr_t addr) |
555 | 29e179bc | aurel32 | { |
556 | 29e179bc | aurel32 | uint32_t ret = 0;
|
557 | 29e179bc | aurel32 | |
558 | 29e179bc | aurel32 | switch (MM_REGION_TYPE(addr)) {
|
559 | 29e179bc | aurel32 | case MM_ICACHE_ADDR:
|
560 | 29e179bc | aurel32 | case MM_ICACHE_DATA:
|
561 | 29e179bc | aurel32 | /* do nothing */
|
562 | 29e179bc | aurel32 | break;
|
563 | 29e179bc | aurel32 | case MM_ITLB_ADDR:
|
564 | 29e179bc | aurel32 | case MM_ITLB_DATA:
|
565 | 29e179bc | aurel32 | /* XXXXX */
|
566 | 29e179bc | aurel32 | assert(0);
|
567 | 29e179bc | aurel32 | break;
|
568 | 29e179bc | aurel32 | case MM_OCACHE_ADDR:
|
569 | 29e179bc | aurel32 | case MM_OCACHE_DATA:
|
570 | 29e179bc | aurel32 | /* do nothing */
|
571 | 29e179bc | aurel32 | break;
|
572 | 29e179bc | aurel32 | case MM_UTLB_ADDR:
|
573 | 29e179bc | aurel32 | case MM_UTLB_DATA:
|
574 | 29e179bc | aurel32 | /* XXXXX */
|
575 | 29e179bc | aurel32 | assert(0);
|
576 | 29e179bc | aurel32 | break;
|
577 | 29e179bc | aurel32 | default:
|
578 | 29e179bc | aurel32 | assert(0);
|
579 | 29e179bc | aurel32 | } |
580 | 29e179bc | aurel32 | |
581 | 29e179bc | aurel32 | return ret;
|
582 | 29e179bc | aurel32 | } |
583 | 29e179bc | aurel32 | |
584 | 29e179bc | aurel32 | static void invalid_write(void *opaque, target_phys_addr_t addr, |
585 | 29e179bc | aurel32 | uint32_t mem_value) |
586 | 29e179bc | aurel32 | { |
587 | 29e179bc | aurel32 | assert(0);
|
588 | 29e179bc | aurel32 | } |
589 | 29e179bc | aurel32 | |
590 | 29e179bc | aurel32 | static void sh7750_mmct_writel(void *opaque, target_phys_addr_t addr, |
591 | 29e179bc | aurel32 | uint32_t mem_value) |
592 | 29e179bc | aurel32 | { |
593 | 29e179bc | aurel32 | SH7750State *s = opaque; |
594 | 29e179bc | aurel32 | |
595 | 29e179bc | aurel32 | switch (MM_REGION_TYPE(addr)) {
|
596 | 29e179bc | aurel32 | case MM_ICACHE_ADDR:
|
597 | 29e179bc | aurel32 | case MM_ICACHE_DATA:
|
598 | 29e179bc | aurel32 | /* do nothing */
|
599 | 29e179bc | aurel32 | break;
|
600 | 29e179bc | aurel32 | case MM_ITLB_ADDR:
|
601 | 29e179bc | aurel32 | case MM_ITLB_DATA:
|
602 | 29e179bc | aurel32 | /* XXXXX */
|
603 | 29e179bc | aurel32 | assert(0);
|
604 | 29e179bc | aurel32 | break;
|
605 | 29e179bc | aurel32 | case MM_OCACHE_ADDR:
|
606 | 29e179bc | aurel32 | case MM_OCACHE_DATA:
|
607 | 29e179bc | aurel32 | /* do nothing */
|
608 | 29e179bc | aurel32 | break;
|
609 | 29e179bc | aurel32 | case MM_UTLB_ADDR:
|
610 | 29e179bc | aurel32 | cpu_sh4_write_mmaped_utlb_addr(s->cpu, addr, mem_value); |
611 | 29e179bc | aurel32 | break;
|
612 | 29e179bc | aurel32 | case MM_UTLB_DATA:
|
613 | 29e179bc | aurel32 | /* XXXXX */
|
614 | 29e179bc | aurel32 | assert(0);
|
615 | 29e179bc | aurel32 | break;
|
616 | 29e179bc | aurel32 | default:
|
617 | 29e179bc | aurel32 | assert(0);
|
618 | 29e179bc | aurel32 | break;
|
619 | 29e179bc | aurel32 | } |
620 | 29e179bc | aurel32 | } |
621 | 29e179bc | aurel32 | |
622 | 29e179bc | aurel32 | static CPUReadMemoryFunc *sh7750_mmct_read[] = {
|
623 | 29e179bc | aurel32 | invalid_read, |
624 | 29e179bc | aurel32 | invalid_read, |
625 | 29e179bc | aurel32 | sh7750_mmct_readl |
626 | 29e179bc | aurel32 | }; |
627 | 29e179bc | aurel32 | |
628 | 29e179bc | aurel32 | static CPUWriteMemoryFunc *sh7750_mmct_write[] = {
|
629 | 29e179bc | aurel32 | invalid_write, |
630 | 29e179bc | aurel32 | invalid_write, |
631 | 29e179bc | aurel32 | sh7750_mmct_writel |
632 | 29e179bc | aurel32 | }; |
633 | 29e179bc | aurel32 | |
634 | 27c7ca7e | bellard | SH7750State *sh7750_init(CPUSH4State * cpu) |
635 | 27c7ca7e | bellard | { |
636 | 27c7ca7e | bellard | SH7750State *s; |
637 | 27c7ca7e | bellard | int sh7750_io_memory;
|
638 | 29e179bc | aurel32 | int sh7750_mm_cache_and_tlb; /* memory mapped cache and tlb */ |
639 | 27c7ca7e | bellard | |
640 | 27c7ca7e | bellard | s = qemu_mallocz(sizeof(SH7750State));
|
641 | 27c7ca7e | bellard | s->cpu = cpu; |
642 | 27c7ca7e | bellard | s->periph_freq = 60000000; /* 60MHz */ |
643 | 27c7ca7e | bellard | sh7750_io_memory = cpu_register_io_memory(0,
|
644 | 27c7ca7e | bellard | sh7750_mem_read, |
645 | 27c7ca7e | bellard | sh7750_mem_write, s); |
646 | 27c7ca7e | bellard | cpu_register_physical_memory(0x1c000000, 0x04000000, sh7750_io_memory); |
647 | 2f062c72 | ths | |
648 | 29e179bc | aurel32 | sh7750_mm_cache_and_tlb = cpu_register_io_memory(0,
|
649 | 29e179bc | aurel32 | sh7750_mmct_read, |
650 | 29e179bc | aurel32 | sh7750_mmct_write, s); |
651 | 29e179bc | aurel32 | cpu_register_physical_memory(0xf0000000, 0x08000000, |
652 | 29e179bc | aurel32 | sh7750_mm_cache_and_tlb); |
653 | 29e179bc | aurel32 | |
654 | 80f515e6 | balrog | sh_intc_init(&s->intc, NR_SOURCES, |
655 | 80f515e6 | balrog | _INTC_ARRAY(mask_registers), |
656 | 80f515e6 | balrog | _INTC_ARRAY(prio_registers)); |
657 | 80f515e6 | balrog | |
658 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
659 | 80f515e6 | balrog | _INTC_ARRAY(vectors), |
660 | 80f515e6 | balrog | _INTC_ARRAY(groups)); |
661 | 80f515e6 | balrog | |
662 | e96e2044 | ths | cpu->intc_handle = &s->intc; |
663 | e96e2044 | ths | |
664 | bf5b7423 | aurel32 | sh_serial_init(0x1fe00000, 0, s->periph_freq, serial_hds[0], |
665 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCI1_ERI), |
666 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCI1_RXI), |
667 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCI1_TXI), |
668 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCI1_TEI), |
669 | bf5b7423 | aurel32 | NULL);
|
670 | 2f062c72 | ths | sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF,
|
671 | bf5b7423 | aurel32 | s->periph_freq, serial_hds[1],
|
672 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCIF_ERI), |
673 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCIF_RXI), |
674 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCIF_TXI), |
675 | bf5b7423 | aurel32 | NULL,
|
676 | bf5b7423 | aurel32 | sh_intc_source(&s->intc, SCIF_BRI)); |
677 | cd1a3f68 | ths | |
678 | cd1a3f68 | ths | tmu012_init(0x1fd80000,
|
679 | cd1a3f68 | ths | TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK, |
680 | 703243a0 | balrog | s->periph_freq, |
681 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU0), |
682 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU1), |
683 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU2_TUNI), |
684 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU2_TICPI)); |
685 | 80f515e6 | balrog | |
686 | 0fd3ca30 | aurel32 | if (cpu->id & (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7751)) {
|
687 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
688 | 80f515e6 | balrog | _INTC_ARRAY(vectors_dma4), |
689 | 80f515e6 | balrog | _INTC_ARRAY(groups_dma4)); |
690 | 80f515e6 | balrog | } |
691 | 80f515e6 | balrog | |
692 | 0fd3ca30 | aurel32 | if (cpu->id & (SH_CPU_SH7750R | SH_CPU_SH7751R)) {
|
693 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
694 | 80f515e6 | balrog | _INTC_ARRAY(vectors_dma8), |
695 | 80f515e6 | balrog | _INTC_ARRAY(groups_dma8)); |
696 | 80f515e6 | balrog | } |
697 | 80f515e6 | balrog | |
698 | 0fd3ca30 | aurel32 | if (cpu->id & (SH_CPU_SH7750R | SH_CPU_SH7751 | SH_CPU_SH7751R)) {
|
699 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
700 | 80f515e6 | balrog | _INTC_ARRAY(vectors_tmu34), |
701 | f26ae302 | bellard | NULL, 0); |
702 | 703243a0 | balrog | tmu012_init(0x1e100000, 0, s->periph_freq, |
703 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU3), |
704 | 703243a0 | balrog | sh_intc_source(&s->intc, TMU4), |
705 | 703243a0 | balrog | NULL, NULL); |
706 | 80f515e6 | balrog | } |
707 | 80f515e6 | balrog | |
708 | 0fd3ca30 | aurel32 | if (cpu->id & (SH_CPU_SH7751_ALL)) {
|
709 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
710 | 80f515e6 | balrog | _INTC_ARRAY(vectors_pci), |
711 | 80f515e6 | balrog | _INTC_ARRAY(groups_pci)); |
712 | 80f515e6 | balrog | } |
713 | 80f515e6 | balrog | |
714 | 0fd3ca30 | aurel32 | if (cpu->id & (SH_CPU_SH7750S | SH_CPU_SH7750R | SH_CPU_SH7751_ALL)) {
|
715 | 0fd3ca30 | aurel32 | sh_intc_register_sources(&s->intc, |
716 | 80f515e6 | balrog | _INTC_ARRAY(vectors_irlm), |
717 | f26ae302 | bellard | NULL, 0); |
718 | 80f515e6 | balrog | } |
719 | 80f515e6 | balrog | |
720 | 27c7ca7e | bellard | return s;
|
721 | 27c7ca7e | bellard | } |