root / hw / sh7750.c @ 868d585a
History | View | Annotate | Download (11.5 kB)
1 | 27c7ca7e | bellard | /*
|
---|---|---|---|
2 | 27c7ca7e | bellard | * SH7750 device
|
3 | 5fafdf24 | ths | *
|
4 | 27c7ca7e | bellard | * Copyright (c) 2005 Samuel Tardieu
|
5 | 5fafdf24 | ths | *
|
6 | 27c7ca7e | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 27c7ca7e | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 27c7ca7e | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 27c7ca7e | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 27c7ca7e | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 27c7ca7e | bellard | * furnished to do so, subject to the following conditions:
|
12 | 27c7ca7e | bellard | *
|
13 | 27c7ca7e | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 27c7ca7e | bellard | * all copies or substantial portions of the Software.
|
15 | 27c7ca7e | bellard | *
|
16 | 27c7ca7e | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 27c7ca7e | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 27c7ca7e | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 27c7ca7e | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 27c7ca7e | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 27c7ca7e | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 27c7ca7e | bellard | * THE SOFTWARE.
|
23 | 27c7ca7e | bellard | */
|
24 | 27c7ca7e | bellard | #include <stdio.h> |
25 | 27c7ca7e | bellard | #include <assert.h> |
26 | 27c7ca7e | bellard | #include "vl.h" |
27 | 27c7ca7e | bellard | #include "sh7750_regs.h" |
28 | 27c7ca7e | bellard | #include "sh7750_regnames.h" |
29 | 27c7ca7e | bellard | |
30 | 27c7ca7e | bellard | #define NB_DEVICES 4 |
31 | 27c7ca7e | bellard | |
32 | 27c7ca7e | bellard | typedef struct SH7750State { |
33 | 27c7ca7e | bellard | /* CPU */
|
34 | 27c7ca7e | bellard | CPUSH4State *cpu; |
35 | 27c7ca7e | bellard | /* Peripheral frequency in Hz */
|
36 | 27c7ca7e | bellard | uint32_t periph_freq; |
37 | 27c7ca7e | bellard | /* SDRAM controller */
|
38 | 27c7ca7e | bellard | uint16_t rfcr; |
39 | 27c7ca7e | bellard | /* IO ports */
|
40 | 27c7ca7e | bellard | uint16_t gpioic; |
41 | 27c7ca7e | bellard | uint32_t pctra; |
42 | 27c7ca7e | bellard | uint32_t pctrb; |
43 | 27c7ca7e | bellard | uint16_t portdira; /* Cached */
|
44 | 27c7ca7e | bellard | uint16_t portpullupa; /* Cached */
|
45 | 27c7ca7e | bellard | uint16_t portdirb; /* Cached */
|
46 | 27c7ca7e | bellard | uint16_t portpullupb; /* Cached */
|
47 | 27c7ca7e | bellard | uint16_t pdtra; |
48 | 27c7ca7e | bellard | uint16_t pdtrb; |
49 | 27c7ca7e | bellard | uint16_t periph_pdtra; /* Imposed by the peripherals */
|
50 | 27c7ca7e | bellard | uint16_t periph_portdira; /* Direction seen from the peripherals */
|
51 | 27c7ca7e | bellard | uint16_t periph_pdtrb; /* Imposed by the peripherals */
|
52 | 27c7ca7e | bellard | uint16_t periph_portdirb; /* Direction seen from the peripherals */
|
53 | 27c7ca7e | bellard | sh7750_io_device *devices[NB_DEVICES]; /* External peripherals */
|
54 | 3464c589 | ths | |
55 | 3464c589 | ths | uint16_t icr; |
56 | 3464c589 | ths | uint16_t ipra; |
57 | 3464c589 | ths | uint16_t iprb; |
58 | 3464c589 | ths | uint16_t iprc; |
59 | 3464c589 | ths | uint16_t iprd; |
60 | 3464c589 | ths | uint32_t intpri00; |
61 | 3464c589 | ths | uint32_t intmsk00; |
62 | 27c7ca7e | bellard | /* Cache */
|
63 | 27c7ca7e | bellard | uint32_t ccr; |
64 | 27c7ca7e | bellard | |
65 | cd1a3f68 | ths | } SH7750State; |
66 | 27c7ca7e | bellard | |
67 | 27c7ca7e | bellard | |
68 | 27c7ca7e | bellard | /**********************************************************************
|
69 | 27c7ca7e | bellard | I/O ports
|
70 | 27c7ca7e | bellard | **********************************************************************/
|
71 | 27c7ca7e | bellard | |
72 | 27c7ca7e | bellard | int sh7750_register_io_device(SH7750State * s, sh7750_io_device * device)
|
73 | 27c7ca7e | bellard | { |
74 | 27c7ca7e | bellard | int i;
|
75 | 27c7ca7e | bellard | |
76 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
77 | 27c7ca7e | bellard | if (s->devices[i] == NULL) { |
78 | 27c7ca7e | bellard | s->devices[i] = device; |
79 | 27c7ca7e | bellard | return 0; |
80 | 27c7ca7e | bellard | } |
81 | 27c7ca7e | bellard | } |
82 | 27c7ca7e | bellard | return -1; |
83 | 27c7ca7e | bellard | } |
84 | 27c7ca7e | bellard | |
85 | 27c7ca7e | bellard | static uint16_t portdir(uint32_t v)
|
86 | 27c7ca7e | bellard | { |
87 | 27c7ca7e | bellard | #define EVENPORTMASK(n) ((v & (1<<((n)<<1))) >> (n)) |
88 | 27c7ca7e | bellard | return
|
89 | 27c7ca7e | bellard | EVENPORTMASK(15) | EVENPORTMASK(14) | EVENPORTMASK(13) | |
90 | 27c7ca7e | bellard | EVENPORTMASK(12) | EVENPORTMASK(11) | EVENPORTMASK(10) | |
91 | 27c7ca7e | bellard | EVENPORTMASK(9) | EVENPORTMASK(8) | EVENPORTMASK(7) | |
92 | 27c7ca7e | bellard | EVENPORTMASK(6) | EVENPORTMASK(5) | EVENPORTMASK(4) | |
93 | 27c7ca7e | bellard | EVENPORTMASK(3) | EVENPORTMASK(2) | EVENPORTMASK(1) | |
94 | 27c7ca7e | bellard | EVENPORTMASK(0);
|
95 | 27c7ca7e | bellard | } |
96 | 27c7ca7e | bellard | |
97 | 27c7ca7e | bellard | static uint16_t portpullup(uint32_t v)
|
98 | 27c7ca7e | bellard | { |
99 | 27c7ca7e | bellard | #define ODDPORTMASK(n) ((v & (1<<(((n)<<1)+1))) >> (n)) |
100 | 27c7ca7e | bellard | return
|
101 | 27c7ca7e | bellard | ODDPORTMASK(15) | ODDPORTMASK(14) | ODDPORTMASK(13) | |
102 | 27c7ca7e | bellard | ODDPORTMASK(12) | ODDPORTMASK(11) | ODDPORTMASK(10) | |
103 | 27c7ca7e | bellard | ODDPORTMASK(9) | ODDPORTMASK(8) | ODDPORTMASK(7) | ODDPORTMASK(6) | |
104 | 27c7ca7e | bellard | ODDPORTMASK(5) | ODDPORTMASK(4) | ODDPORTMASK(3) | ODDPORTMASK(2) | |
105 | 27c7ca7e | bellard | ODDPORTMASK(1) | ODDPORTMASK(0); |
106 | 27c7ca7e | bellard | } |
107 | 27c7ca7e | bellard | |
108 | 27c7ca7e | bellard | static uint16_t porta_lines(SH7750State * s)
|
109 | 27c7ca7e | bellard | { |
110 | 27c7ca7e | bellard | return (s->portdira & s->pdtra) | /* CPU */ |
111 | 27c7ca7e | bellard | (s->periph_portdira & s->periph_pdtra) | /* Peripherals */
|
112 | 27c7ca7e | bellard | (~(s->portdira | s->periph_portdira) & s->portpullupa); /* Pullups */
|
113 | 27c7ca7e | bellard | } |
114 | 27c7ca7e | bellard | |
115 | 27c7ca7e | bellard | static uint16_t portb_lines(SH7750State * s)
|
116 | 27c7ca7e | bellard | { |
117 | 27c7ca7e | bellard | return (s->portdirb & s->pdtrb) | /* CPU */ |
118 | 27c7ca7e | bellard | (s->periph_portdirb & s->periph_pdtrb) | /* Peripherals */
|
119 | 27c7ca7e | bellard | (~(s->portdirb | s->periph_portdirb) & s->portpullupb); /* Pullups */
|
120 | 27c7ca7e | bellard | } |
121 | 27c7ca7e | bellard | |
122 | 27c7ca7e | bellard | static void gen_port_interrupts(SH7750State * s) |
123 | 27c7ca7e | bellard | { |
124 | 27c7ca7e | bellard | /* XXXXX interrupts not generated */
|
125 | 27c7ca7e | bellard | } |
126 | 27c7ca7e | bellard | |
127 | 27c7ca7e | bellard | static void porta_changed(SH7750State * s, uint16_t prev) |
128 | 27c7ca7e | bellard | { |
129 | 27c7ca7e | bellard | uint16_t currenta, changes; |
130 | 27c7ca7e | bellard | int i, r = 0; |
131 | 27c7ca7e | bellard | |
132 | 27c7ca7e | bellard | #if 0
|
133 | 27c7ca7e | bellard | fprintf(stderr, "porta changed from 0x%04x to 0x%04x\n",
|
134 | 27c7ca7e | bellard | prev, porta_lines(s));
|
135 | 27c7ca7e | bellard | fprintf(stderr, "pdtra=0x%04x, pctra=0x%08x\n", s->pdtra, s->pctra);
|
136 | 27c7ca7e | bellard | #endif
|
137 | 27c7ca7e | bellard | currenta = porta_lines(s); |
138 | 27c7ca7e | bellard | if (currenta == prev)
|
139 | 27c7ca7e | bellard | return;
|
140 | 27c7ca7e | bellard | changes = currenta ^ prev; |
141 | 27c7ca7e | bellard | |
142 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
143 | 27c7ca7e | bellard | if (s->devices[i] && (s->devices[i]->portamask_trigger & changes)) {
|
144 | 27c7ca7e | bellard | r |= s->devices[i]->port_change_cb(currenta, portb_lines(s), |
145 | 27c7ca7e | bellard | &s->periph_pdtra, |
146 | 27c7ca7e | bellard | &s->periph_portdira, |
147 | 27c7ca7e | bellard | &s->periph_pdtrb, |
148 | 27c7ca7e | bellard | &s->periph_portdirb); |
149 | 27c7ca7e | bellard | } |
150 | 27c7ca7e | bellard | } |
151 | 27c7ca7e | bellard | |
152 | 27c7ca7e | bellard | if (r)
|
153 | 27c7ca7e | bellard | gen_port_interrupts(s); |
154 | 27c7ca7e | bellard | } |
155 | 27c7ca7e | bellard | |
156 | 27c7ca7e | bellard | static void portb_changed(SH7750State * s, uint16_t prev) |
157 | 27c7ca7e | bellard | { |
158 | 27c7ca7e | bellard | uint16_t currentb, changes; |
159 | 27c7ca7e | bellard | int i, r = 0; |
160 | 27c7ca7e | bellard | |
161 | 27c7ca7e | bellard | currentb = portb_lines(s); |
162 | 27c7ca7e | bellard | if (currentb == prev)
|
163 | 27c7ca7e | bellard | return;
|
164 | 27c7ca7e | bellard | changes = currentb ^ prev; |
165 | 27c7ca7e | bellard | |
166 | 27c7ca7e | bellard | for (i = 0; i < NB_DEVICES; i++) { |
167 | 27c7ca7e | bellard | if (s->devices[i] && (s->devices[i]->portbmask_trigger & changes)) {
|
168 | 27c7ca7e | bellard | r |= s->devices[i]->port_change_cb(portb_lines(s), currentb, |
169 | 27c7ca7e | bellard | &s->periph_pdtra, |
170 | 27c7ca7e | bellard | &s->periph_portdira, |
171 | 27c7ca7e | bellard | &s->periph_pdtrb, |
172 | 27c7ca7e | bellard | &s->periph_portdirb); |
173 | 27c7ca7e | bellard | } |
174 | 27c7ca7e | bellard | } |
175 | 27c7ca7e | bellard | |
176 | 27c7ca7e | bellard | if (r)
|
177 | 27c7ca7e | bellard | gen_port_interrupts(s); |
178 | 27c7ca7e | bellard | } |
179 | 27c7ca7e | bellard | |
180 | 27c7ca7e | bellard | /**********************************************************************
|
181 | 27c7ca7e | bellard | Memory
|
182 | 27c7ca7e | bellard | **********************************************************************/
|
183 | 27c7ca7e | bellard | |
184 | 27c7ca7e | bellard | static void error_access(const char *kind, target_phys_addr_t addr) |
185 | 27c7ca7e | bellard | { |
186 | 27c7ca7e | bellard | fprintf(stderr, "%s to %s (0x%08x) not supported\n",
|
187 | 27c7ca7e | bellard | kind, regname(addr), addr); |
188 | 27c7ca7e | bellard | } |
189 | 27c7ca7e | bellard | |
190 | 27c7ca7e | bellard | static void ignore_access(const char *kind, target_phys_addr_t addr) |
191 | 27c7ca7e | bellard | { |
192 | 27c7ca7e | bellard | fprintf(stderr, "%s to %s (0x%08x) ignored\n",
|
193 | 27c7ca7e | bellard | kind, regname(addr), addr); |
194 | 27c7ca7e | bellard | } |
195 | 27c7ca7e | bellard | |
196 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readb(void *opaque, target_phys_addr_t addr) |
197 | 27c7ca7e | bellard | { |
198 | 27c7ca7e | bellard | switch (addr) {
|
199 | 27c7ca7e | bellard | default:
|
200 | 27c7ca7e | bellard | error_access("byte read", addr);
|
201 | 27c7ca7e | bellard | assert(0);
|
202 | 27c7ca7e | bellard | } |
203 | 27c7ca7e | bellard | } |
204 | 27c7ca7e | bellard | |
205 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readw(void *opaque, target_phys_addr_t addr) |
206 | 27c7ca7e | bellard | { |
207 | 27c7ca7e | bellard | SH7750State *s = opaque; |
208 | 27c7ca7e | bellard | |
209 | 27c7ca7e | bellard | switch (addr) {
|
210 | ed8e0a4d | ths | case SH7750_FRQCR_A7:
|
211 | ed8e0a4d | ths | return 0; |
212 | 27c7ca7e | bellard | case SH7750_RFCR_A7:
|
213 | 27c7ca7e | bellard | fprintf(stderr, |
214 | 27c7ca7e | bellard | "Read access to refresh count register, incrementing\n");
|
215 | 27c7ca7e | bellard | return s->rfcr++;
|
216 | 27c7ca7e | bellard | case SH7750_PDTRA_A7:
|
217 | 27c7ca7e | bellard | return porta_lines(s);
|
218 | 27c7ca7e | bellard | case SH7750_PDTRB_A7:
|
219 | 27c7ca7e | bellard | return portb_lines(s);
|
220 | 3464c589 | ths | case 0x1fd00000: |
221 | 3464c589 | ths | return s->icr;
|
222 | 3464c589 | ths | case 0x1fd00004: |
223 | 3464c589 | ths | return s->ipra;
|
224 | 3464c589 | ths | case 0x1fd00008: |
225 | 3464c589 | ths | return s->iprb;
|
226 | 3464c589 | ths | case 0x1fd0000c: |
227 | 3464c589 | ths | return s->iprc;
|
228 | 3464c589 | ths | case 0x1fd00010: |
229 | 3464c589 | ths | return s->iprd;
|
230 | 27c7ca7e | bellard | default:
|
231 | 27c7ca7e | bellard | error_access("word read", addr);
|
232 | 27c7ca7e | bellard | assert(0);
|
233 | 27c7ca7e | bellard | } |
234 | 27c7ca7e | bellard | } |
235 | 27c7ca7e | bellard | |
236 | 27c7ca7e | bellard | static uint32_t sh7750_mem_readl(void *opaque, target_phys_addr_t addr) |
237 | 27c7ca7e | bellard | { |
238 | 27c7ca7e | bellard | SH7750State *s = opaque; |
239 | 27c7ca7e | bellard | |
240 | 27c7ca7e | bellard | switch (addr) {
|
241 | 27c7ca7e | bellard | case SH7750_MMUCR_A7:
|
242 | 27c7ca7e | bellard | return s->cpu->mmucr;
|
243 | 27c7ca7e | bellard | case SH7750_PTEH_A7:
|
244 | 27c7ca7e | bellard | return s->cpu->pteh;
|
245 | 27c7ca7e | bellard | case SH7750_PTEL_A7:
|
246 | 27c7ca7e | bellard | return s->cpu->ptel;
|
247 | 27c7ca7e | bellard | case SH7750_TTB_A7:
|
248 | 27c7ca7e | bellard | return s->cpu->ttb;
|
249 | 27c7ca7e | bellard | case SH7750_TEA_A7:
|
250 | 27c7ca7e | bellard | return s->cpu->tea;
|
251 | 27c7ca7e | bellard | case SH7750_TRA_A7:
|
252 | 27c7ca7e | bellard | return s->cpu->tra;
|
253 | 27c7ca7e | bellard | case SH7750_EXPEVT_A7:
|
254 | 27c7ca7e | bellard | return s->cpu->expevt;
|
255 | 27c7ca7e | bellard | case SH7750_INTEVT_A7:
|
256 | 27c7ca7e | bellard | return s->cpu->intevt;
|
257 | 27c7ca7e | bellard | case SH7750_CCR_A7:
|
258 | 27c7ca7e | bellard | return s->ccr;
|
259 | 27c7ca7e | bellard | case 0x1f000030: /* Processor version PVR */ |
260 | 27c7ca7e | bellard | return 0x00050000; /* SH7750R */ |
261 | 27c7ca7e | bellard | case 0x1f000040: /* Processor version CVR */ |
262 | 27c7ca7e | bellard | return 0x00110000; /* Minimum caches */ |
263 | 27c7ca7e | bellard | case 0x1f000044: /* Processor version PRR */ |
264 | 27c7ca7e | bellard | return 0x00000100; /* SH7750R */ |
265 | 3464c589 | ths | case 0x1e080000: |
266 | 3464c589 | ths | return s->intpri00;
|
267 | 3464c589 | ths | case 0x1e080020: |
268 | 3464c589 | ths | return 0; |
269 | 3464c589 | ths | case 0x1e080040: |
270 | 3464c589 | ths | return s->intmsk00;
|
271 | 3464c589 | ths | case 0x1e080060: |
272 | 3464c589 | ths | return 0; |
273 | 27c7ca7e | bellard | default:
|
274 | 27c7ca7e | bellard | error_access("long read", addr);
|
275 | 27c7ca7e | bellard | assert(0);
|
276 | 27c7ca7e | bellard | } |
277 | 27c7ca7e | bellard | } |
278 | 27c7ca7e | bellard | |
279 | 27c7ca7e | bellard | static void sh7750_mem_writeb(void *opaque, target_phys_addr_t addr, |
280 | 27c7ca7e | bellard | uint32_t mem_value) |
281 | 27c7ca7e | bellard | { |
282 | 27c7ca7e | bellard | switch (addr) {
|
283 | 27c7ca7e | bellard | /* PRECHARGE ? XXXXX */
|
284 | 27c7ca7e | bellard | case SH7750_PRECHARGE0_A7:
|
285 | 27c7ca7e | bellard | case SH7750_PRECHARGE1_A7:
|
286 | 27c7ca7e | bellard | ignore_access("byte write", addr);
|
287 | 27c7ca7e | bellard | return;
|
288 | 27c7ca7e | bellard | default:
|
289 | 27c7ca7e | bellard | error_access("byte write", addr);
|
290 | 27c7ca7e | bellard | assert(0);
|
291 | 27c7ca7e | bellard | } |
292 | 27c7ca7e | bellard | } |
293 | 27c7ca7e | bellard | |
294 | 27c7ca7e | bellard | static void sh7750_mem_writew(void *opaque, target_phys_addr_t addr, |
295 | 27c7ca7e | bellard | uint32_t mem_value) |
296 | 27c7ca7e | bellard | { |
297 | 27c7ca7e | bellard | SH7750State *s = opaque; |
298 | 27c7ca7e | bellard | uint16_t temp; |
299 | 27c7ca7e | bellard | |
300 | 27c7ca7e | bellard | switch (addr) {
|
301 | 27c7ca7e | bellard | /* SDRAM controller */
|
302 | 27c7ca7e | bellard | case SH7750_BCR2_A7:
|
303 | 27c7ca7e | bellard | case SH7750_BCR3_A7:
|
304 | 27c7ca7e | bellard | case SH7750_RTCOR_A7:
|
305 | 27c7ca7e | bellard | case SH7750_RTCNT_A7:
|
306 | 27c7ca7e | bellard | case SH7750_RTCSR_A7:
|
307 | 27c7ca7e | bellard | ignore_access("word write", addr);
|
308 | 27c7ca7e | bellard | return;
|
309 | 27c7ca7e | bellard | /* IO ports */
|
310 | 27c7ca7e | bellard | case SH7750_PDTRA_A7:
|
311 | 27c7ca7e | bellard | temp = porta_lines(s); |
312 | 27c7ca7e | bellard | s->pdtra = mem_value; |
313 | 27c7ca7e | bellard | porta_changed(s, temp); |
314 | 27c7ca7e | bellard | return;
|
315 | 27c7ca7e | bellard | case SH7750_PDTRB_A7:
|
316 | 27c7ca7e | bellard | temp = portb_lines(s); |
317 | 27c7ca7e | bellard | s->pdtrb = mem_value; |
318 | 27c7ca7e | bellard | portb_changed(s, temp); |
319 | 27c7ca7e | bellard | return;
|
320 | 27c7ca7e | bellard | case SH7750_RFCR_A7:
|
321 | 27c7ca7e | bellard | fprintf(stderr, "Write access to refresh count register\n");
|
322 | 27c7ca7e | bellard | s->rfcr = mem_value; |
323 | 27c7ca7e | bellard | return;
|
324 | 27c7ca7e | bellard | case SH7750_GPIOIC_A7:
|
325 | 27c7ca7e | bellard | s->gpioic = mem_value; |
326 | 27c7ca7e | bellard | if (mem_value != 0) { |
327 | 27c7ca7e | bellard | fprintf(stderr, "I/O interrupts not implemented\n");
|
328 | 27c7ca7e | bellard | assert(0);
|
329 | 27c7ca7e | bellard | } |
330 | 27c7ca7e | bellard | return;
|
331 | 3464c589 | ths | case 0x1fd00000: |
332 | 3464c589 | ths | s->icr = mem_value; |
333 | 3464c589 | ths | return;
|
334 | 3464c589 | ths | case 0x1fd00004: |
335 | 3464c589 | ths | s->ipra = mem_value; |
336 | 3464c589 | ths | return;
|
337 | 3464c589 | ths | case 0x1fd00008: |
338 | 3464c589 | ths | s->iprb = mem_value; |
339 | 3464c589 | ths | return;
|
340 | 3464c589 | ths | case 0x1fd0000c: |
341 | 3464c589 | ths | s->iprc = mem_value; |
342 | 3464c589 | ths | return;
|
343 | 3464c589 | ths | case 0x1fd00010: |
344 | 3464c589 | ths | s->iprd = mem_value; |
345 | 3464c589 | ths | return;
|
346 | 27c7ca7e | bellard | default:
|
347 | 27c7ca7e | bellard | error_access("word write", addr);
|
348 | 27c7ca7e | bellard | assert(0);
|
349 | 27c7ca7e | bellard | } |
350 | 27c7ca7e | bellard | } |
351 | 27c7ca7e | bellard | |
352 | 27c7ca7e | bellard | static void sh7750_mem_writel(void *opaque, target_phys_addr_t addr, |
353 | 27c7ca7e | bellard | uint32_t mem_value) |
354 | 27c7ca7e | bellard | { |
355 | 27c7ca7e | bellard | SH7750State *s = opaque; |
356 | 27c7ca7e | bellard | uint16_t temp; |
357 | 27c7ca7e | bellard | |
358 | 27c7ca7e | bellard | switch (addr) {
|
359 | 27c7ca7e | bellard | /* SDRAM controller */
|
360 | 27c7ca7e | bellard | case SH7750_BCR1_A7:
|
361 | 27c7ca7e | bellard | case SH7750_BCR4_A7:
|
362 | 27c7ca7e | bellard | case SH7750_WCR1_A7:
|
363 | 27c7ca7e | bellard | case SH7750_WCR2_A7:
|
364 | 27c7ca7e | bellard | case SH7750_WCR3_A7:
|
365 | 27c7ca7e | bellard | case SH7750_MCR_A7:
|
366 | 27c7ca7e | bellard | ignore_access("long write", addr);
|
367 | 27c7ca7e | bellard | return;
|
368 | 27c7ca7e | bellard | /* IO ports */
|
369 | 27c7ca7e | bellard | case SH7750_PCTRA_A7:
|
370 | 27c7ca7e | bellard | temp = porta_lines(s); |
371 | 27c7ca7e | bellard | s->pctra = mem_value; |
372 | 27c7ca7e | bellard | s->portdira = portdir(mem_value); |
373 | 27c7ca7e | bellard | s->portpullupa = portpullup(mem_value); |
374 | 27c7ca7e | bellard | porta_changed(s, temp); |
375 | 27c7ca7e | bellard | return;
|
376 | 27c7ca7e | bellard | case SH7750_PCTRB_A7:
|
377 | 27c7ca7e | bellard | temp = portb_lines(s); |
378 | 27c7ca7e | bellard | s->pctrb = mem_value; |
379 | 27c7ca7e | bellard | s->portdirb = portdir(mem_value); |
380 | 27c7ca7e | bellard | s->portpullupb = portpullup(mem_value); |
381 | 27c7ca7e | bellard | portb_changed(s, temp); |
382 | 27c7ca7e | bellard | return;
|
383 | 27c7ca7e | bellard | case SH7750_MMUCR_A7:
|
384 | 27c7ca7e | bellard | s->cpu->mmucr = mem_value; |
385 | 27c7ca7e | bellard | return;
|
386 | 27c7ca7e | bellard | case SH7750_PTEH_A7:
|
387 | 27c7ca7e | bellard | s->cpu->pteh = mem_value; |
388 | 27c7ca7e | bellard | return;
|
389 | 27c7ca7e | bellard | case SH7750_PTEL_A7:
|
390 | 27c7ca7e | bellard | s->cpu->ptel = mem_value; |
391 | 27c7ca7e | bellard | return;
|
392 | 27c7ca7e | bellard | case SH7750_TTB_A7:
|
393 | 27c7ca7e | bellard | s->cpu->ttb = mem_value; |
394 | 27c7ca7e | bellard | return;
|
395 | 27c7ca7e | bellard | case SH7750_TEA_A7:
|
396 | 27c7ca7e | bellard | s->cpu->tea = mem_value; |
397 | 27c7ca7e | bellard | return;
|
398 | 27c7ca7e | bellard | case SH7750_TRA_A7:
|
399 | 27c7ca7e | bellard | s->cpu->tra = mem_value & 0x000007ff;
|
400 | 27c7ca7e | bellard | return;
|
401 | 27c7ca7e | bellard | case SH7750_EXPEVT_A7:
|
402 | 27c7ca7e | bellard | s->cpu->expevt = mem_value & 0x000007ff;
|
403 | 27c7ca7e | bellard | return;
|
404 | 27c7ca7e | bellard | case SH7750_INTEVT_A7:
|
405 | 27c7ca7e | bellard | s->cpu->intevt = mem_value & 0x000007ff;
|
406 | 27c7ca7e | bellard | return;
|
407 | 27c7ca7e | bellard | case SH7750_CCR_A7:
|
408 | 27c7ca7e | bellard | s->ccr = mem_value; |
409 | 27c7ca7e | bellard | return;
|
410 | 3464c589 | ths | case 0x1e080000: |
411 | 3464c589 | ths | s->intpri00 = mem_value; |
412 | 3464c589 | ths | return;
|
413 | 3464c589 | ths | case 0x1e080020: |
414 | 3464c589 | ths | return;
|
415 | 3464c589 | ths | case 0x1e080040: |
416 | 3464c589 | ths | s->intmsk00 = mem_value; |
417 | 3464c589 | ths | return;
|
418 | 3464c589 | ths | case 0x1e080060: |
419 | 3464c589 | ths | return;
|
420 | 27c7ca7e | bellard | default:
|
421 | 27c7ca7e | bellard | error_access("long write", addr);
|
422 | 27c7ca7e | bellard | assert(0);
|
423 | 27c7ca7e | bellard | } |
424 | 27c7ca7e | bellard | } |
425 | 27c7ca7e | bellard | |
426 | 27c7ca7e | bellard | static CPUReadMemoryFunc *sh7750_mem_read[] = {
|
427 | 27c7ca7e | bellard | sh7750_mem_readb, |
428 | 27c7ca7e | bellard | sh7750_mem_readw, |
429 | 27c7ca7e | bellard | sh7750_mem_readl |
430 | 27c7ca7e | bellard | }; |
431 | 27c7ca7e | bellard | |
432 | 27c7ca7e | bellard | static CPUWriteMemoryFunc *sh7750_mem_write[] = {
|
433 | 27c7ca7e | bellard | sh7750_mem_writeb, |
434 | 27c7ca7e | bellard | sh7750_mem_writew, |
435 | 27c7ca7e | bellard | sh7750_mem_writel |
436 | 27c7ca7e | bellard | }; |
437 | 27c7ca7e | bellard | |
438 | 27c7ca7e | bellard | SH7750State *sh7750_init(CPUSH4State * cpu) |
439 | 27c7ca7e | bellard | { |
440 | 27c7ca7e | bellard | SH7750State *s; |
441 | 27c7ca7e | bellard | int sh7750_io_memory;
|
442 | 27c7ca7e | bellard | |
443 | 27c7ca7e | bellard | s = qemu_mallocz(sizeof(SH7750State));
|
444 | 27c7ca7e | bellard | s->cpu = cpu; |
445 | 27c7ca7e | bellard | s->periph_freq = 60000000; /* 60MHz */ |
446 | 27c7ca7e | bellard | sh7750_io_memory = cpu_register_io_memory(0,
|
447 | 27c7ca7e | bellard | sh7750_mem_read, |
448 | 27c7ca7e | bellard | sh7750_mem_write, s); |
449 | 27c7ca7e | bellard | cpu_register_physical_memory(0x1c000000, 0x04000000, sh7750_io_memory); |
450 | 2f062c72 | ths | |
451 | 2f062c72 | ths | sh_serial_init(0x1fe00000, 0, s->periph_freq, serial_hds[0]); |
452 | 2f062c72 | ths | sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF,
|
453 | 2f062c72 | ths | s->periph_freq, serial_hds[1]);
|
454 | cd1a3f68 | ths | |
455 | cd1a3f68 | ths | tmu012_init(0x1fd80000,
|
456 | cd1a3f68 | ths | TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK, |
457 | cd1a3f68 | ths | s->periph_freq); |
458 | cd1a3f68 | ths | tmu012_init(0x1e100000, 0, s->periph_freq); |
459 | 27c7ca7e | bellard | return s;
|
460 | 27c7ca7e | bellard | } |