root / hw / slavio_misc.c @ a8a358bf
History | View | Annotate | Download (12.5 kB)
1 | 3475187d | bellard | /*
|
---|---|---|---|
2 | 3475187d | bellard | * QEMU Sparc SLAVIO aux io port emulation
|
3 | 5fafdf24 | ths | *
|
4 | 3475187d | bellard | * Copyright (c) 2005 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 3475187d | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 3475187d | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 3475187d | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 3475187d | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 3475187d | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 3475187d | bellard | * furnished to do so, subject to the following conditions:
|
12 | 3475187d | bellard | *
|
13 | 3475187d | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 3475187d | bellard | * all copies or substantial portions of the Software.
|
15 | 3475187d | bellard | *
|
16 | 3475187d | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 3475187d | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 3475187d | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 3475187d | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 3475187d | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 3475187d | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 3475187d | bellard | * THE SOFTWARE.
|
23 | 3475187d | bellard | */
|
24 | 2582cfa0 | Blue Swirl | |
25 | 87ecb68b | pbrook | #include "sun4m.h" |
26 | 87ecb68b | pbrook | #include "sysemu.h" |
27 | 2582cfa0 | Blue Swirl | #include "sysbus.h" |
28 | 87ecb68b | pbrook | |
29 | 3475187d | bellard | /* debug misc */
|
30 | 3475187d | bellard | //#define DEBUG_MISC
|
31 | 3475187d | bellard | |
32 | 3475187d | bellard | /*
|
33 | 3475187d | bellard | * This is the auxio port, chip control and system control part of
|
34 | 3475187d | bellard | * chip STP2001 (Slave I/O), also produced as NCR89C105. See
|
35 | 3475187d | bellard | * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
|
36 | 3475187d | bellard | *
|
37 | 3475187d | bellard | * This also includes the PMC CPU idle controller.
|
38 | 3475187d | bellard | */
|
39 | 3475187d | bellard | |
40 | 3475187d | bellard | #ifdef DEBUG_MISC
|
41 | 001faf32 | Blue Swirl | #define MISC_DPRINTF(fmt, ...) \
|
42 | 001faf32 | Blue Swirl | do { printf("MISC: " fmt , ## __VA_ARGS__); } while (0) |
43 | 3475187d | bellard | #else
|
44 | 001faf32 | Blue Swirl | #define MISC_DPRINTF(fmt, ...)
|
45 | 3475187d | bellard | #endif
|
46 | 3475187d | bellard | |
47 | 3475187d | bellard | typedef struct MiscState { |
48 | 2582cfa0 | Blue Swirl | SysBusDevice busdev; |
49 | d537cf6c | pbrook | qemu_irq irq; |
50 | 3475187d | bellard | uint8_t config; |
51 | 3475187d | bellard | uint8_t aux1, aux2; |
52 | bfa30a38 | blueswir1 | uint8_t diag, mctrl; |
53 | bfa30a38 | blueswir1 | uint32_t sysctrl; |
54 | 6a3b9cc9 | blueswir1 | uint16_t leds; |
55 | 2be17ebd | blueswir1 | qemu_irq fdc_tc; |
56 | 3475187d | bellard | } MiscState; |
57 | 3475187d | bellard | |
58 | 2582cfa0 | Blue Swirl | typedef struct APCState { |
59 | 2582cfa0 | Blue Swirl | SysBusDevice busdev; |
60 | 2582cfa0 | Blue Swirl | qemu_irq cpu_halt; |
61 | 2582cfa0 | Blue Swirl | } APCState; |
62 | 2582cfa0 | Blue Swirl | |
63 | 5aca8c3b | blueswir1 | #define MISC_SIZE 1 |
64 | a8f48dcc | blueswir1 | #define SYSCTRL_SIZE 4 |
65 | 3475187d | bellard | |
66 | 2be17ebd | blueswir1 | #define AUX1_TC 0x02 |
67 | 2be17ebd | blueswir1 | |
68 | 7debeb82 | blueswir1 | #define AUX2_PWROFF 0x01 |
69 | 7debeb82 | blueswir1 | #define AUX2_PWRINTCLR 0x02 |
70 | 7debeb82 | blueswir1 | #define AUX2_PWRFAIL 0x20 |
71 | 7debeb82 | blueswir1 | |
72 | 7debeb82 | blueswir1 | #define CFG_PWRINTEN 0x08 |
73 | 7debeb82 | blueswir1 | |
74 | 7debeb82 | blueswir1 | #define SYS_RESET 0x01 |
75 | 7debeb82 | blueswir1 | #define SYS_RESETSTAT 0x02 |
76 | 7debeb82 | blueswir1 | |
77 | 3475187d | bellard | static void slavio_misc_update_irq(void *opaque) |
78 | 3475187d | bellard | { |
79 | 3475187d | bellard | MiscState *s = opaque; |
80 | 3475187d | bellard | |
81 | 7debeb82 | blueswir1 | if ((s->aux2 & AUX2_PWRFAIL) && (s->config & CFG_PWRINTEN)) {
|
82 | d537cf6c | pbrook | MISC_DPRINTF("Raise IRQ\n");
|
83 | d537cf6c | pbrook | qemu_irq_raise(s->irq); |
84 | 3475187d | bellard | } else {
|
85 | d537cf6c | pbrook | MISC_DPRINTF("Lower IRQ\n");
|
86 | d537cf6c | pbrook | qemu_irq_lower(s->irq); |
87 | 3475187d | bellard | } |
88 | 3475187d | bellard | } |
89 | 3475187d | bellard | |
90 | 3475187d | bellard | static void slavio_misc_reset(void *opaque) |
91 | 3475187d | bellard | { |
92 | 3475187d | bellard | MiscState *s = opaque; |
93 | 3475187d | bellard | |
94 | 4e3b1ea1 | bellard | // Diagnostic and system control registers not cleared in reset
|
95 | 3475187d | bellard | s->config = s->aux1 = s->aux2 = s->mctrl = 0;
|
96 | 3475187d | bellard | } |
97 | 3475187d | bellard | |
98 | b2b6f6ec | Blue Swirl | static void slavio_set_power_fail(void *opaque, int irq, int power_failing) |
99 | 3475187d | bellard | { |
100 | 3475187d | bellard | MiscState *s = opaque; |
101 | 3475187d | bellard | |
102 | 3475187d | bellard | MISC_DPRINTF("Power fail: %d, config: %d\n", power_failing, s->config);
|
103 | 7debeb82 | blueswir1 | if (power_failing && (s->config & CFG_PWRINTEN)) {
|
104 | 7debeb82 | blueswir1 | s->aux2 |= AUX2_PWRFAIL; |
105 | 3475187d | bellard | } else {
|
106 | 7debeb82 | blueswir1 | s->aux2 &= ~AUX2_PWRFAIL; |
107 | 3475187d | bellard | } |
108 | 3475187d | bellard | slavio_misc_update_irq(s); |
109 | 3475187d | bellard | } |
110 | 3475187d | bellard | |
111 | a8f48dcc | blueswir1 | static void slavio_cfg_mem_writeb(void *opaque, target_phys_addr_t addr, |
112 | a8f48dcc | blueswir1 | uint32_t val) |
113 | a8f48dcc | blueswir1 | { |
114 | a8f48dcc | blueswir1 | MiscState *s = opaque; |
115 | a8f48dcc | blueswir1 | |
116 | a8f48dcc | blueswir1 | MISC_DPRINTF("Write config %2.2x\n", val & 0xff); |
117 | a8f48dcc | blueswir1 | s->config = val & 0xff;
|
118 | a8f48dcc | blueswir1 | slavio_misc_update_irq(s); |
119 | a8f48dcc | blueswir1 | } |
120 | a8f48dcc | blueswir1 | |
121 | a8f48dcc | blueswir1 | static uint32_t slavio_cfg_mem_readb(void *opaque, target_phys_addr_t addr) |
122 | a8f48dcc | blueswir1 | { |
123 | a8f48dcc | blueswir1 | MiscState *s = opaque; |
124 | a8f48dcc | blueswir1 | uint32_t ret = 0;
|
125 | a8f48dcc | blueswir1 | |
126 | a8f48dcc | blueswir1 | ret = s->config; |
127 | a8f48dcc | blueswir1 | MISC_DPRINTF("Read config %2.2x\n", ret);
|
128 | a8f48dcc | blueswir1 | return ret;
|
129 | a8f48dcc | blueswir1 | } |
130 | a8f48dcc | blueswir1 | |
131 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_cfg_mem_read[3] = { |
132 | a8f48dcc | blueswir1 | slavio_cfg_mem_readb, |
133 | a8f48dcc | blueswir1 | NULL,
|
134 | a8f48dcc | blueswir1 | NULL,
|
135 | a8f48dcc | blueswir1 | }; |
136 | a8f48dcc | blueswir1 | |
137 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_cfg_mem_write[3] = { |
138 | a8f48dcc | blueswir1 | slavio_cfg_mem_writeb, |
139 | a8f48dcc | blueswir1 | NULL,
|
140 | a8f48dcc | blueswir1 | NULL,
|
141 | a8f48dcc | blueswir1 | }; |
142 | a8f48dcc | blueswir1 | |
143 | a8f48dcc | blueswir1 | static void slavio_diag_mem_writeb(void *opaque, target_phys_addr_t addr, |
144 | bfa30a38 | blueswir1 | uint32_t val) |
145 | 3475187d | bellard | { |
146 | 3475187d | bellard | MiscState *s = opaque; |
147 | 3475187d | bellard | |
148 | a8f48dcc | blueswir1 | MISC_DPRINTF("Write diag %2.2x\n", val & 0xff); |
149 | a8f48dcc | blueswir1 | s->diag = val & 0xff;
|
150 | 3475187d | bellard | } |
151 | 3475187d | bellard | |
152 | a8f48dcc | blueswir1 | static uint32_t slavio_diag_mem_readb(void *opaque, target_phys_addr_t addr) |
153 | 3475187d | bellard | { |
154 | 3475187d | bellard | MiscState *s = opaque; |
155 | 3475187d | bellard | uint32_t ret = 0;
|
156 | 3475187d | bellard | |
157 | a8f48dcc | blueswir1 | ret = s->diag; |
158 | a8f48dcc | blueswir1 | MISC_DPRINTF("Read diag %2.2x\n", ret);
|
159 | a8f48dcc | blueswir1 | return ret;
|
160 | a8f48dcc | blueswir1 | } |
161 | a8f48dcc | blueswir1 | |
162 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_diag_mem_read[3] = { |
163 | a8f48dcc | blueswir1 | slavio_diag_mem_readb, |
164 | a8f48dcc | blueswir1 | NULL,
|
165 | a8f48dcc | blueswir1 | NULL,
|
166 | a8f48dcc | blueswir1 | }; |
167 | a8f48dcc | blueswir1 | |
168 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_diag_mem_write[3] = { |
169 | a8f48dcc | blueswir1 | slavio_diag_mem_writeb, |
170 | a8f48dcc | blueswir1 | NULL,
|
171 | a8f48dcc | blueswir1 | NULL,
|
172 | a8f48dcc | blueswir1 | }; |
173 | a8f48dcc | blueswir1 | |
174 | a8f48dcc | blueswir1 | static void slavio_mdm_mem_writeb(void *opaque, target_phys_addr_t addr, |
175 | a8f48dcc | blueswir1 | uint32_t val) |
176 | a8f48dcc | blueswir1 | { |
177 | a8f48dcc | blueswir1 | MiscState *s = opaque; |
178 | a8f48dcc | blueswir1 | |
179 | a8f48dcc | blueswir1 | MISC_DPRINTF("Write modem control %2.2x\n", val & 0xff); |
180 | a8f48dcc | blueswir1 | s->mctrl = val & 0xff;
|
181 | a8f48dcc | blueswir1 | } |
182 | a8f48dcc | blueswir1 | |
183 | a8f48dcc | blueswir1 | static uint32_t slavio_mdm_mem_readb(void *opaque, target_phys_addr_t addr) |
184 | a8f48dcc | blueswir1 | { |
185 | a8f48dcc | blueswir1 | MiscState *s = opaque; |
186 | a8f48dcc | blueswir1 | uint32_t ret = 0;
|
187 | a8f48dcc | blueswir1 | |
188 | a8f48dcc | blueswir1 | ret = s->mctrl; |
189 | a8f48dcc | blueswir1 | MISC_DPRINTF("Read modem control %2.2x\n", ret);
|
190 | 3475187d | bellard | return ret;
|
191 | 3475187d | bellard | } |
192 | 3475187d | bellard | |
193 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_mdm_mem_read[3] = { |
194 | a8f48dcc | blueswir1 | slavio_mdm_mem_readb, |
195 | 7c560456 | blueswir1 | NULL,
|
196 | 7c560456 | blueswir1 | NULL,
|
197 | 3475187d | bellard | }; |
198 | 3475187d | bellard | |
199 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_mdm_mem_write[3] = { |
200 | a8f48dcc | blueswir1 | slavio_mdm_mem_writeb, |
201 | 7c560456 | blueswir1 | NULL,
|
202 | 7c560456 | blueswir1 | NULL,
|
203 | 3475187d | bellard | }; |
204 | 3475187d | bellard | |
205 | 0019ad53 | blueswir1 | static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr, |
206 | 0019ad53 | blueswir1 | uint32_t val) |
207 | 0019ad53 | blueswir1 | { |
208 | 0019ad53 | blueswir1 | MiscState *s = opaque; |
209 | 0019ad53 | blueswir1 | |
210 | 0019ad53 | blueswir1 | MISC_DPRINTF("Write aux1 %2.2x\n", val & 0xff); |
211 | 2be17ebd | blueswir1 | if (val & AUX1_TC) {
|
212 | 2be17ebd | blueswir1 | // Send a pulse to floppy terminal count line
|
213 | 2be17ebd | blueswir1 | if (s->fdc_tc) {
|
214 | 2be17ebd | blueswir1 | qemu_irq_raise(s->fdc_tc); |
215 | 2be17ebd | blueswir1 | qemu_irq_lower(s->fdc_tc); |
216 | 2be17ebd | blueswir1 | } |
217 | 2be17ebd | blueswir1 | val &= ~AUX1_TC; |
218 | 2be17ebd | blueswir1 | } |
219 | 0019ad53 | blueswir1 | s->aux1 = val & 0xff;
|
220 | 0019ad53 | blueswir1 | } |
221 | 0019ad53 | blueswir1 | |
222 | 0019ad53 | blueswir1 | static uint32_t slavio_aux1_mem_readb(void *opaque, target_phys_addr_t addr) |
223 | 0019ad53 | blueswir1 | { |
224 | 0019ad53 | blueswir1 | MiscState *s = opaque; |
225 | 0019ad53 | blueswir1 | uint32_t ret = 0;
|
226 | 0019ad53 | blueswir1 | |
227 | 0019ad53 | blueswir1 | ret = s->aux1; |
228 | 0019ad53 | blueswir1 | MISC_DPRINTF("Read aux1 %2.2x\n", ret);
|
229 | 0019ad53 | blueswir1 | |
230 | 0019ad53 | blueswir1 | return ret;
|
231 | 0019ad53 | blueswir1 | } |
232 | 0019ad53 | blueswir1 | |
233 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_aux1_mem_read[3] = { |
234 | 0019ad53 | blueswir1 | slavio_aux1_mem_readb, |
235 | 0019ad53 | blueswir1 | NULL,
|
236 | 0019ad53 | blueswir1 | NULL,
|
237 | 0019ad53 | blueswir1 | }; |
238 | 0019ad53 | blueswir1 | |
239 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_aux1_mem_write[3] = { |
240 | 0019ad53 | blueswir1 | slavio_aux1_mem_writeb, |
241 | 0019ad53 | blueswir1 | NULL,
|
242 | 0019ad53 | blueswir1 | NULL,
|
243 | 0019ad53 | blueswir1 | }; |
244 | 0019ad53 | blueswir1 | |
245 | 0019ad53 | blueswir1 | static void slavio_aux2_mem_writeb(void *opaque, target_phys_addr_t addr, |
246 | 0019ad53 | blueswir1 | uint32_t val) |
247 | 0019ad53 | blueswir1 | { |
248 | 0019ad53 | blueswir1 | MiscState *s = opaque; |
249 | 0019ad53 | blueswir1 | |
250 | 0019ad53 | blueswir1 | val &= AUX2_PWRINTCLR | AUX2_PWROFF; |
251 | 0019ad53 | blueswir1 | MISC_DPRINTF("Write aux2 %2.2x\n", val);
|
252 | 0019ad53 | blueswir1 | val |= s->aux2 & AUX2_PWRFAIL; |
253 | 0019ad53 | blueswir1 | if (val & AUX2_PWRINTCLR) // Clear Power Fail int |
254 | 0019ad53 | blueswir1 | val &= AUX2_PWROFF; |
255 | 0019ad53 | blueswir1 | s->aux2 = val; |
256 | 0019ad53 | blueswir1 | if (val & AUX2_PWROFF)
|
257 | 0019ad53 | blueswir1 | qemu_system_shutdown_request(); |
258 | 0019ad53 | blueswir1 | slavio_misc_update_irq(s); |
259 | 0019ad53 | blueswir1 | } |
260 | 0019ad53 | blueswir1 | |
261 | 0019ad53 | blueswir1 | static uint32_t slavio_aux2_mem_readb(void *opaque, target_phys_addr_t addr) |
262 | 0019ad53 | blueswir1 | { |
263 | 0019ad53 | blueswir1 | MiscState *s = opaque; |
264 | 0019ad53 | blueswir1 | uint32_t ret = 0;
|
265 | 0019ad53 | blueswir1 | |
266 | 0019ad53 | blueswir1 | ret = s->aux2; |
267 | 0019ad53 | blueswir1 | MISC_DPRINTF("Read aux2 %2.2x\n", ret);
|
268 | 0019ad53 | blueswir1 | |
269 | 0019ad53 | blueswir1 | return ret;
|
270 | 0019ad53 | blueswir1 | } |
271 | 0019ad53 | blueswir1 | |
272 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_aux2_mem_read[3] = { |
273 | 0019ad53 | blueswir1 | slavio_aux2_mem_readb, |
274 | 0019ad53 | blueswir1 | NULL,
|
275 | 0019ad53 | blueswir1 | NULL,
|
276 | 0019ad53 | blueswir1 | }; |
277 | 0019ad53 | blueswir1 | |
278 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_aux2_mem_write[3] = { |
279 | 0019ad53 | blueswir1 | slavio_aux2_mem_writeb, |
280 | 0019ad53 | blueswir1 | NULL,
|
281 | 0019ad53 | blueswir1 | NULL,
|
282 | 0019ad53 | blueswir1 | }; |
283 | 0019ad53 | blueswir1 | |
284 | 0019ad53 | blueswir1 | static void apc_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) |
285 | 0019ad53 | blueswir1 | { |
286 | 2582cfa0 | Blue Swirl | APCState *s = opaque; |
287 | 0019ad53 | blueswir1 | |
288 | 0019ad53 | blueswir1 | MISC_DPRINTF("Write power management %2.2x\n", val & 0xff); |
289 | 6d0c293d | blueswir1 | qemu_irq_raise(s->cpu_halt); |
290 | 0019ad53 | blueswir1 | } |
291 | 0019ad53 | blueswir1 | |
292 | 0019ad53 | blueswir1 | static uint32_t apc_mem_readb(void *opaque, target_phys_addr_t addr) |
293 | 0019ad53 | blueswir1 | { |
294 | 0019ad53 | blueswir1 | uint32_t ret = 0;
|
295 | 0019ad53 | blueswir1 | |
296 | 0019ad53 | blueswir1 | MISC_DPRINTF("Read power management %2.2x\n", ret);
|
297 | 0019ad53 | blueswir1 | return ret;
|
298 | 0019ad53 | blueswir1 | } |
299 | 0019ad53 | blueswir1 | |
300 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const apc_mem_read[3] = { |
301 | 0019ad53 | blueswir1 | apc_mem_readb, |
302 | 0019ad53 | blueswir1 | NULL,
|
303 | 0019ad53 | blueswir1 | NULL,
|
304 | 0019ad53 | blueswir1 | }; |
305 | 0019ad53 | blueswir1 | |
306 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const apc_mem_write[3] = { |
307 | 0019ad53 | blueswir1 | apc_mem_writeb, |
308 | 0019ad53 | blueswir1 | NULL,
|
309 | 0019ad53 | blueswir1 | NULL,
|
310 | 0019ad53 | blueswir1 | }; |
311 | 0019ad53 | blueswir1 | |
312 | bfa30a38 | blueswir1 | static uint32_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr) |
313 | bfa30a38 | blueswir1 | { |
314 | bfa30a38 | blueswir1 | MiscState *s = opaque; |
315 | a8f48dcc | blueswir1 | uint32_t ret = 0;
|
316 | bfa30a38 | blueswir1 | |
317 | a8f48dcc | blueswir1 | switch (addr) {
|
318 | bfa30a38 | blueswir1 | case 0: |
319 | bfa30a38 | blueswir1 | ret = s->sysctrl; |
320 | bfa30a38 | blueswir1 | break;
|
321 | bfa30a38 | blueswir1 | default:
|
322 | bfa30a38 | blueswir1 | break;
|
323 | bfa30a38 | blueswir1 | } |
324 | 5626b017 | blueswir1 | MISC_DPRINTF("Read system control %08x\n", ret);
|
325 | bfa30a38 | blueswir1 | return ret;
|
326 | bfa30a38 | blueswir1 | } |
327 | bfa30a38 | blueswir1 | |
328 | bfa30a38 | blueswir1 | static void slavio_sysctrl_mem_writel(void *opaque, target_phys_addr_t addr, |
329 | bfa30a38 | blueswir1 | uint32_t val) |
330 | bfa30a38 | blueswir1 | { |
331 | bfa30a38 | blueswir1 | MiscState *s = opaque; |
332 | bfa30a38 | blueswir1 | |
333 | 5626b017 | blueswir1 | MISC_DPRINTF("Write system control %08x\n", val);
|
334 | a8f48dcc | blueswir1 | switch (addr) {
|
335 | bfa30a38 | blueswir1 | case 0: |
336 | 7debeb82 | blueswir1 | if (val & SYS_RESET) {
|
337 | 7debeb82 | blueswir1 | s->sysctrl = SYS_RESETSTAT; |
338 | bfa30a38 | blueswir1 | qemu_system_reset_request(); |
339 | bfa30a38 | blueswir1 | } |
340 | bfa30a38 | blueswir1 | break;
|
341 | bfa30a38 | blueswir1 | default:
|
342 | bfa30a38 | blueswir1 | break;
|
343 | bfa30a38 | blueswir1 | } |
344 | bfa30a38 | blueswir1 | } |
345 | bfa30a38 | blueswir1 | |
346 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_sysctrl_mem_read[3] = { |
347 | 7c560456 | blueswir1 | NULL,
|
348 | 7c560456 | blueswir1 | NULL,
|
349 | bfa30a38 | blueswir1 | slavio_sysctrl_mem_readl, |
350 | bfa30a38 | blueswir1 | }; |
351 | bfa30a38 | blueswir1 | |
352 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_sysctrl_mem_write[3] = { |
353 | 7c560456 | blueswir1 | NULL,
|
354 | 7c560456 | blueswir1 | NULL,
|
355 | bfa30a38 | blueswir1 | slavio_sysctrl_mem_writel, |
356 | bfa30a38 | blueswir1 | }; |
357 | bfa30a38 | blueswir1 | |
358 | 7c560456 | blueswir1 | static uint32_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr) |
359 | 6a3b9cc9 | blueswir1 | { |
360 | 6a3b9cc9 | blueswir1 | MiscState *s = opaque; |
361 | a8f48dcc | blueswir1 | uint32_t ret = 0;
|
362 | 6a3b9cc9 | blueswir1 | |
363 | a8f48dcc | blueswir1 | switch (addr) {
|
364 | 6a3b9cc9 | blueswir1 | case 0: |
365 | 6a3b9cc9 | blueswir1 | ret = s->leds; |
366 | 6a3b9cc9 | blueswir1 | break;
|
367 | 6a3b9cc9 | blueswir1 | default:
|
368 | 6a3b9cc9 | blueswir1 | break;
|
369 | 6a3b9cc9 | blueswir1 | } |
370 | 5626b017 | blueswir1 | MISC_DPRINTF("Read diagnostic LED %04x\n", ret);
|
371 | 6a3b9cc9 | blueswir1 | return ret;
|
372 | 6a3b9cc9 | blueswir1 | } |
373 | 6a3b9cc9 | blueswir1 | |
374 | 7c560456 | blueswir1 | static void slavio_led_mem_writew(void *opaque, target_phys_addr_t addr, |
375 | 6a3b9cc9 | blueswir1 | uint32_t val) |
376 | 6a3b9cc9 | blueswir1 | { |
377 | 6a3b9cc9 | blueswir1 | MiscState *s = opaque; |
378 | 6a3b9cc9 | blueswir1 | |
379 | 5626b017 | blueswir1 | MISC_DPRINTF("Write diagnostic LED %04x\n", val & 0xffff); |
380 | a8f48dcc | blueswir1 | switch (addr) {
|
381 | 6a3b9cc9 | blueswir1 | case 0: |
382 | d5296cb5 | blueswir1 | s->leds = val; |
383 | 6a3b9cc9 | blueswir1 | break;
|
384 | 6a3b9cc9 | blueswir1 | default:
|
385 | 6a3b9cc9 | blueswir1 | break;
|
386 | 6a3b9cc9 | blueswir1 | } |
387 | 6a3b9cc9 | blueswir1 | } |
388 | 6a3b9cc9 | blueswir1 | |
389 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const slavio_led_mem_read[3] = { |
390 | 7c560456 | blueswir1 | NULL,
|
391 | 7c560456 | blueswir1 | slavio_led_mem_readw, |
392 | 7c560456 | blueswir1 | NULL,
|
393 | 6a3b9cc9 | blueswir1 | }; |
394 | 6a3b9cc9 | blueswir1 | |
395 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const slavio_led_mem_write[3] = { |
396 | 7c560456 | blueswir1 | NULL,
|
397 | 7c560456 | blueswir1 | slavio_led_mem_writew, |
398 | 7c560456 | blueswir1 | NULL,
|
399 | 6a3b9cc9 | blueswir1 | }; |
400 | 6a3b9cc9 | blueswir1 | |
401 | 3475187d | bellard | static void slavio_misc_save(QEMUFile *f, void *opaque) |
402 | 3475187d | bellard | { |
403 | 3475187d | bellard | MiscState *s = opaque; |
404 | 22548760 | blueswir1 | uint32_t tmp = 0;
|
405 | bfa30a38 | blueswir1 | uint8_t tmp8; |
406 | 3475187d | bellard | |
407 | d537cf6c | pbrook | qemu_put_be32s(f, &tmp); /* ignored, was IRQ. */
|
408 | 3475187d | bellard | qemu_put_8s(f, &s->config); |
409 | 3475187d | bellard | qemu_put_8s(f, &s->aux1); |
410 | 3475187d | bellard | qemu_put_8s(f, &s->aux2); |
411 | 3475187d | bellard | qemu_put_8s(f, &s->diag); |
412 | 3475187d | bellard | qemu_put_8s(f, &s->mctrl); |
413 | bfa30a38 | blueswir1 | tmp8 = s->sysctrl & 0xff;
|
414 | bfa30a38 | blueswir1 | qemu_put_8s(f, &tmp8); |
415 | 3475187d | bellard | } |
416 | 3475187d | bellard | |
417 | 3475187d | bellard | static int slavio_misc_load(QEMUFile *f, void *opaque, int version_id) |
418 | 3475187d | bellard | { |
419 | 3475187d | bellard | MiscState *s = opaque; |
420 | 22548760 | blueswir1 | uint32_t tmp; |
421 | bfa30a38 | blueswir1 | uint8_t tmp8; |
422 | 3475187d | bellard | |
423 | 3475187d | bellard | if (version_id != 1) |
424 | 3475187d | bellard | return -EINVAL;
|
425 | 3475187d | bellard | |
426 | d537cf6c | pbrook | qemu_get_be32s(f, &tmp); |
427 | 3475187d | bellard | qemu_get_8s(f, &s->config); |
428 | 3475187d | bellard | qemu_get_8s(f, &s->aux1); |
429 | 3475187d | bellard | qemu_get_8s(f, &s->aux2); |
430 | 3475187d | bellard | qemu_get_8s(f, &s->diag); |
431 | 3475187d | bellard | qemu_get_8s(f, &s->mctrl); |
432 | bfa30a38 | blueswir1 | qemu_get_8s(f, &tmp8); |
433 | bfa30a38 | blueswir1 | s->sysctrl = (uint32_t)tmp8; |
434 | 3475187d | bellard | return 0; |
435 | 3475187d | bellard | } |
436 | 3475187d | bellard | |
437 | 2582cfa0 | Blue Swirl | static void apc_init1(SysBusDevice *dev) |
438 | 2582cfa0 | Blue Swirl | { |
439 | 2582cfa0 | Blue Swirl | APCState *s = FROM_SYSBUS(APCState, dev); |
440 | 2582cfa0 | Blue Swirl | int io;
|
441 | 3475187d | bellard | |
442 | 2582cfa0 | Blue Swirl | sysbus_init_irq(dev, &s->cpu_halt); |
443 | 2582cfa0 | Blue Swirl | |
444 | 2582cfa0 | Blue Swirl | /* Power management (APC) XXX: not a Slavio device */
|
445 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(apc_mem_read, apc_mem_write, s); |
446 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
447 | 2582cfa0 | Blue Swirl | } |
448 | 2582cfa0 | Blue Swirl | |
449 | 2582cfa0 | Blue Swirl | static void slavio_misc_init1(SysBusDevice *dev) |
450 | 2582cfa0 | Blue Swirl | { |
451 | 2582cfa0 | Blue Swirl | MiscState *s = FROM_SYSBUS(MiscState, dev); |
452 | 2582cfa0 | Blue Swirl | int io;
|
453 | 2582cfa0 | Blue Swirl | |
454 | 2582cfa0 | Blue Swirl | sysbus_init_irq(dev, &s->irq); |
455 | 2582cfa0 | Blue Swirl | sysbus_init_irq(dev, &s->fdc_tc); |
456 | 2582cfa0 | Blue Swirl | |
457 | 2582cfa0 | Blue Swirl | /* 8 bit registers */
|
458 | 2582cfa0 | Blue Swirl | /* Slavio control */
|
459 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_cfg_mem_read, |
460 | 2582cfa0 | Blue Swirl | slavio_cfg_mem_write, s); |
461 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
462 | 2582cfa0 | Blue Swirl | |
463 | 2582cfa0 | Blue Swirl | /* Diagnostics */
|
464 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_diag_mem_read, |
465 | 2582cfa0 | Blue Swirl | slavio_diag_mem_write, s); |
466 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
467 | 2582cfa0 | Blue Swirl | |
468 | 2582cfa0 | Blue Swirl | /* Modem control */
|
469 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_mdm_mem_read, |
470 | 2582cfa0 | Blue Swirl | slavio_mdm_mem_write, s); |
471 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
472 | 2582cfa0 | Blue Swirl | |
473 | 2582cfa0 | Blue Swirl | /* 16 bit registers */
|
474 | 2582cfa0 | Blue Swirl | /* ss600mp diag LEDs */
|
475 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_led_mem_read, |
476 | 2582cfa0 | Blue Swirl | slavio_led_mem_write, s); |
477 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
478 | 2582cfa0 | Blue Swirl | |
479 | 2582cfa0 | Blue Swirl | /* 32 bit registers */
|
480 | 2582cfa0 | Blue Swirl | /* System control */
|
481 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_sysctrl_mem_read, |
482 | 2582cfa0 | Blue Swirl | slavio_sysctrl_mem_write, s); |
483 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, SYSCTRL_SIZE, io); |
484 | 2582cfa0 | Blue Swirl | |
485 | 2582cfa0 | Blue Swirl | /* AUX 1 (Misc System Functions) */
|
486 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_aux1_mem_read, |
487 | 2582cfa0 | Blue Swirl | slavio_aux1_mem_write, s); |
488 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
489 | 2582cfa0 | Blue Swirl | |
490 | 2582cfa0 | Blue Swirl | /* AUX 2 (Software Powerdown Control) */
|
491 | 2582cfa0 | Blue Swirl | io = cpu_register_io_memory(slavio_aux2_mem_read, |
492 | 2582cfa0 | Blue Swirl | slavio_aux2_mem_write, s); |
493 | 2582cfa0 | Blue Swirl | sysbus_init_mmio(dev, MISC_SIZE, io); |
494 | 2582cfa0 | Blue Swirl | |
495 | b2b6f6ec | Blue Swirl | qdev_init_gpio_in(&dev->qdev, slavio_set_power_fail, 1);
|
496 | b2b6f6ec | Blue Swirl | |
497 | 2582cfa0 | Blue Swirl | register_savevm("slavio_misc", -1, 1, slavio_misc_save, slavio_misc_load, |
498 | bfa30a38 | blueswir1 | s); |
499 | a08d4367 | Jan Kiszka | qemu_register_reset(slavio_misc_reset, s); |
500 | 3475187d | bellard | slavio_misc_reset(s); |
501 | 2582cfa0 | Blue Swirl | } |
502 | 0019ad53 | blueswir1 | |
503 | 2582cfa0 | Blue Swirl | static SysBusDeviceInfo slavio_misc_info = {
|
504 | 2582cfa0 | Blue Swirl | .init = slavio_misc_init1, |
505 | 2582cfa0 | Blue Swirl | .qdev.name = "slavio_misc",
|
506 | 2582cfa0 | Blue Swirl | .qdev.size = sizeof(MiscState),
|
507 | 2582cfa0 | Blue Swirl | }; |
508 | 2582cfa0 | Blue Swirl | |
509 | 2582cfa0 | Blue Swirl | static SysBusDeviceInfo apc_info = {
|
510 | 2582cfa0 | Blue Swirl | .init = apc_init1, |
511 | 2582cfa0 | Blue Swirl | .qdev.name = "apc",
|
512 | 2582cfa0 | Blue Swirl | .qdev.size = sizeof(MiscState),
|
513 | 2582cfa0 | Blue Swirl | }; |
514 | 2582cfa0 | Blue Swirl | |
515 | 2582cfa0 | Blue Swirl | static void slavio_misc_register_devices(void) |
516 | 2582cfa0 | Blue Swirl | { |
517 | 2582cfa0 | Blue Swirl | sysbus_register_withprop(&slavio_misc_info); |
518 | 2582cfa0 | Blue Swirl | sysbus_register_withprop(&apc_info); |
519 | 3475187d | bellard | } |
520 | 2582cfa0 | Blue Swirl | |
521 | 2582cfa0 | Blue Swirl | device_init(slavio_misc_register_devices) |