root / hw / eccmemctl.c @ f74ab486
History | View | Annotate | Download (11.2 kB)
1 | 7eb0c8e8 | blueswir1 | /*
|
---|---|---|---|
2 | 7eb0c8e8 | blueswir1 | * QEMU Sparc Sun4m ECC memory controller emulation
|
3 | 7eb0c8e8 | blueswir1 | *
|
4 | 7eb0c8e8 | blueswir1 | * Copyright (c) 2007 Robert Reif
|
5 | 7eb0c8e8 | blueswir1 | *
|
6 | 7eb0c8e8 | blueswir1 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 7eb0c8e8 | blueswir1 | * of this software and associated documentation files (the "Software"), to deal
|
8 | 7eb0c8e8 | blueswir1 | * in the Software without restriction, including without limitation the rights
|
9 | 7eb0c8e8 | blueswir1 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 7eb0c8e8 | blueswir1 | * copies of the Software, and to permit persons to whom the Software is
|
11 | 7eb0c8e8 | blueswir1 | * furnished to do so, subject to the following conditions:
|
12 | 7eb0c8e8 | blueswir1 | *
|
13 | 7eb0c8e8 | blueswir1 | * The above copyright notice and this permission notice shall be included in
|
14 | 7eb0c8e8 | blueswir1 | * all copies or substantial portions of the Software.
|
15 | 7eb0c8e8 | blueswir1 | *
|
16 | 7eb0c8e8 | blueswir1 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 7eb0c8e8 | blueswir1 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 7eb0c8e8 | blueswir1 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 7eb0c8e8 | blueswir1 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 7eb0c8e8 | blueswir1 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 7eb0c8e8 | blueswir1 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 7eb0c8e8 | blueswir1 | * THE SOFTWARE.
|
23 | 7eb0c8e8 | blueswir1 | */
|
24 | 49e66373 | Blue Swirl | |
25 | 49e66373 | Blue Swirl | #include "sysbus.h" |
26 | 7eb0c8e8 | blueswir1 | |
27 | 7eb0c8e8 | blueswir1 | //#define DEBUG_ECC
|
28 | 7eb0c8e8 | blueswir1 | |
29 | 7eb0c8e8 | blueswir1 | #ifdef DEBUG_ECC
|
30 | 001faf32 | Blue Swirl | #define DPRINTF(fmt, ...) \
|
31 | 001faf32 | Blue Swirl | do { printf("ECC: " fmt , ## __VA_ARGS__); } while (0) |
32 | 7eb0c8e8 | blueswir1 | #else
|
33 | 001faf32 | Blue Swirl | #define DPRINTF(fmt, ...)
|
34 | 7eb0c8e8 | blueswir1 | #endif
|
35 | 7eb0c8e8 | blueswir1 | |
36 | 7eb0c8e8 | blueswir1 | /* There are 3 versions of this chip used in SMP sun4m systems:
|
37 | 7eb0c8e8 | blueswir1 | * MCC (version 0, implementation 0) SS-600MP
|
38 | 7eb0c8e8 | blueswir1 | * EMC (version 0, implementation 1) SS-10
|
39 | 7eb0c8e8 | blueswir1 | * SMC (version 0, implementation 2) SS-10SX and SS-20
|
40 | 5ac574c4 | Blue Swirl | *
|
41 | 5ac574c4 | Blue Swirl | * Chipset docs:
|
42 | 5ac574c4 | Blue Swirl | * "Sun-4M System Architecture (revision 2.0) by Chuck Narad", 950-1373-01,
|
43 | 5ac574c4 | Blue Swirl | * http://mediacast.sun.com/users/Barton808/media/Sun4M_SystemArchitecture_edited2.pdf
|
44 | 7eb0c8e8 | blueswir1 | */
|
45 | 7eb0c8e8 | blueswir1 | |
46 | 0bb3602c | blueswir1 | #define ECC_MCC 0x00000000 |
47 | 0bb3602c | blueswir1 | #define ECC_EMC 0x10000000 |
48 | 0bb3602c | blueswir1 | #define ECC_SMC 0x20000000 |
49 | 0bb3602c | blueswir1 | |
50 | 8f2ad0a3 | blueswir1 | /* Register indexes */
|
51 | 8f2ad0a3 | blueswir1 | #define ECC_MER 0 /* Memory Enable Register */ |
52 | 8f2ad0a3 | blueswir1 | #define ECC_MDR 1 /* Memory Delay Register */ |
53 | 8f2ad0a3 | blueswir1 | #define ECC_MFSR 2 /* Memory Fault Status Register */ |
54 | 8f2ad0a3 | blueswir1 | #define ECC_VCR 3 /* Video Configuration Register */ |
55 | 8f2ad0a3 | blueswir1 | #define ECC_MFAR0 4 /* Memory Fault Address Register 0 */ |
56 | 8f2ad0a3 | blueswir1 | #define ECC_MFAR1 5 /* Memory Fault Address Register 1 */ |
57 | 8f2ad0a3 | blueswir1 | #define ECC_DR 6 /* Diagnostic Register */ |
58 | 8f2ad0a3 | blueswir1 | #define ECC_ECR0 7 /* Event Count Register 0 */ |
59 | 8f2ad0a3 | blueswir1 | #define ECC_ECR1 8 /* Event Count Register 1 */ |
60 | 7eb0c8e8 | blueswir1 | |
61 | 7eb0c8e8 | blueswir1 | /* ECC fault control register */
|
62 | dd53ded3 | blueswir1 | #define ECC_MER_EE 0x00000001 /* Enable ECC checking */ |
63 | 77f193da | blueswir1 | #define ECC_MER_EI 0x00000002 /* Enable Interrupts on |
64 | 77f193da | blueswir1 | correctable errors */
|
65 | dd53ded3 | blueswir1 | #define ECC_MER_MRR0 0x00000004 /* SIMM 0 */ |
66 | dd53ded3 | blueswir1 | #define ECC_MER_MRR1 0x00000008 /* SIMM 1 */ |
67 | dd53ded3 | blueswir1 | #define ECC_MER_MRR2 0x00000010 /* SIMM 2 */ |
68 | dd53ded3 | blueswir1 | #define ECC_MER_MRR3 0x00000020 /* SIMM 3 */ |
69 | dd53ded3 | blueswir1 | #define ECC_MER_MRR4 0x00000040 /* SIMM 4 */ |
70 | dd53ded3 | blueswir1 | #define ECC_MER_MRR5 0x00000080 /* SIMM 5 */ |
71 | dd53ded3 | blueswir1 | #define ECC_MER_MRR6 0x00000100 /* SIMM 6 */ |
72 | dd53ded3 | blueswir1 | #define ECC_MER_MRR7 0x00000200 /* SIMM 7 */ |
73 | 0bb3602c | blueswir1 | #define ECC_MER_REU 0x00000100 /* Memory Refresh Enable (600MP) */ |
74 | dd53ded3 | blueswir1 | #define ECC_MER_MRR 0x000003fc /* MRR mask */ |
75 | 0bb3602c | blueswir1 | #define ECC_MER_A 0x00000400 /* Memory controller addr map select */ |
76 | 77f193da | blueswir1 | #define ECC_MER_DCI 0x00000800 /* Disables Coherent Invalidate ACK */ |
77 | dd53ded3 | blueswir1 | #define ECC_MER_VER 0x0f000000 /* Version */ |
78 | dd53ded3 | blueswir1 | #define ECC_MER_IMPL 0xf0000000 /* Implementation */ |
79 | 0bb3602c | blueswir1 | #define ECC_MER_MASK_0 0x00000103 /* Version 0 (MCC) mask */ |
80 | 0bb3602c | blueswir1 | #define ECC_MER_MASK_1 0x00000bff /* Version 1 (EMC) mask */ |
81 | 0bb3602c | blueswir1 | #define ECC_MER_MASK_2 0x00000bff /* Version 2 (SMC) mask */ |
82 | dd53ded3 | blueswir1 | |
83 | dd53ded3 | blueswir1 | /* ECC memory delay register */
|
84 | dd53ded3 | blueswir1 | #define ECC_MDR_RRI 0x000003ff /* Refresh Request Interval */ |
85 | dd53ded3 | blueswir1 | #define ECC_MDR_MI 0x00001c00 /* MIH Delay */ |
86 | dd53ded3 | blueswir1 | #define ECC_MDR_CI 0x0000e000 /* Coherent Invalidate Delay */ |
87 | dd53ded3 | blueswir1 | #define ECC_MDR_MDL 0x001f0000 /* MBus Master arbitration delay */ |
88 | dd53ded3 | blueswir1 | #define ECC_MDR_MDH 0x03e00000 /* MBus Master arbitration delay */ |
89 | dd53ded3 | blueswir1 | #define ECC_MDR_GAD 0x7c000000 /* Graphics Arbitration Delay */ |
90 | dd53ded3 | blueswir1 | #define ECC_MDR_RSC 0x80000000 /* Refresh load control */ |
91 | dd53ded3 | blueswir1 | #define ECC_MDR_MASK 0x7fffffff |
92 | 7eb0c8e8 | blueswir1 | |
93 | 7eb0c8e8 | blueswir1 | /* ECC fault status register */
|
94 | dd53ded3 | blueswir1 | #define ECC_MFSR_CE 0x00000001 /* Correctable error */ |
95 | dd53ded3 | blueswir1 | #define ECC_MFSR_BS 0x00000002 /* C2 graphics bad slot access */ |
96 | dd53ded3 | blueswir1 | #define ECC_MFSR_TO 0x00000004 /* Timeout on write */ |
97 | dd53ded3 | blueswir1 | #define ECC_MFSR_UE 0x00000008 /* Uncorrectable error */ |
98 | dd53ded3 | blueswir1 | #define ECC_MFSR_DW 0x000000f0 /* Index of double word in block */ |
99 | dd53ded3 | blueswir1 | #define ECC_MFSR_SYND 0x0000ff00 /* Syndrome for correctable error */ |
100 | dd53ded3 | blueswir1 | #define ECC_MFSR_ME 0x00010000 /* Multiple errors */ |
101 | dd53ded3 | blueswir1 | #define ECC_MFSR_C2ERR 0x00020000 /* C2 graphics error */ |
102 | 7eb0c8e8 | blueswir1 | |
103 | 7eb0c8e8 | blueswir1 | /* ECC fault address register 0 */
|
104 | dd53ded3 | blueswir1 | #define ECC_MFAR0_PADDR 0x0000000f /* PA[32-35] */ |
105 | dd53ded3 | blueswir1 | #define ECC_MFAR0_TYPE 0x000000f0 /* Transaction type */ |
106 | dd53ded3 | blueswir1 | #define ECC_MFAR0_SIZE 0x00000700 /* Transaction size */ |
107 | dd53ded3 | blueswir1 | #define ECC_MFAR0_CACHE 0x00000800 /* Mapped cacheable */ |
108 | dd53ded3 | blueswir1 | #define ECC_MFAR0_LOCK 0x00001000 /* Error occurred in atomic cycle */ |
109 | dd53ded3 | blueswir1 | #define ECC_MFAR0_BMODE 0x00002000 /* Boot mode */ |
110 | dd53ded3 | blueswir1 | #define ECC_MFAR0_VADDR 0x003fc000 /* VA[12-19] (superset bits) */ |
111 | dd53ded3 | blueswir1 | #define ECC_MFAR0_S 0x08000000 /* Supervisor mode */ |
112 | dd53ded3 | blueswir1 | #define ECC_MFARO_MID 0xf0000000 /* Module ID */ |
113 | 7eb0c8e8 | blueswir1 | |
114 | 7eb0c8e8 | blueswir1 | /* ECC diagnostic register */
|
115 | dd53ded3 | blueswir1 | #define ECC_DR_CBX 0x00000001 |
116 | dd53ded3 | blueswir1 | #define ECC_DR_CB0 0x00000002 |
117 | dd53ded3 | blueswir1 | #define ECC_DR_CB1 0x00000004 |
118 | dd53ded3 | blueswir1 | #define ECC_DR_CB2 0x00000008 |
119 | dd53ded3 | blueswir1 | #define ECC_DR_CB4 0x00000010 |
120 | dd53ded3 | blueswir1 | #define ECC_DR_CB8 0x00000020 |
121 | dd53ded3 | blueswir1 | #define ECC_DR_CB16 0x00000040 |
122 | dd53ded3 | blueswir1 | #define ECC_DR_CB32 0x00000080 |
123 | dd53ded3 | blueswir1 | #define ECC_DR_DMODE 0x00000c00 |
124 | dd53ded3 | blueswir1 | |
125 | dd53ded3 | blueswir1 | #define ECC_NREGS 9 |
126 | 7eb0c8e8 | blueswir1 | #define ECC_SIZE (ECC_NREGS * sizeof(uint32_t)) |
127 | dd53ded3 | blueswir1 | |
128 | dd53ded3 | blueswir1 | #define ECC_DIAG_SIZE 4 |
129 | dd53ded3 | blueswir1 | #define ECC_DIAG_MASK (ECC_DIAG_SIZE - 1) |
130 | 7eb0c8e8 | blueswir1 | |
131 | 7eb0c8e8 | blueswir1 | typedef struct ECCState { |
132 | 49e66373 | Blue Swirl | SysBusDevice busdev; |
133 | e42c20b4 | blueswir1 | qemu_irq irq; |
134 | 7eb0c8e8 | blueswir1 | uint32_t regs[ECC_NREGS]; |
135 | dd53ded3 | blueswir1 | uint8_t diag[ECC_DIAG_SIZE]; |
136 | 0bb3602c | blueswir1 | uint32_t version; |
137 | 7eb0c8e8 | blueswir1 | } ECCState; |
138 | 7eb0c8e8 | blueswir1 | |
139 | c227f099 | Anthony Liguori | static void ecc_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) |
140 | 7eb0c8e8 | blueswir1 | { |
141 | 7eb0c8e8 | blueswir1 | ECCState *s = opaque; |
142 | 7eb0c8e8 | blueswir1 | |
143 | e64d7d59 | blueswir1 | switch (addr >> 2) { |
144 | dd53ded3 | blueswir1 | case ECC_MER:
|
145 | 0bb3602c | blueswir1 | if (s->version == ECC_MCC)
|
146 | 0bb3602c | blueswir1 | s->regs[ECC_MER] = (val & ECC_MER_MASK_0); |
147 | 0bb3602c | blueswir1 | else if (s->version == ECC_EMC) |
148 | 0bb3602c | blueswir1 | s->regs[ECC_MER] = s->version | (val & ECC_MER_MASK_1); |
149 | 0bb3602c | blueswir1 | else if (s->version == ECC_SMC) |
150 | 0bb3602c | blueswir1 | s->regs[ECC_MER] = s->version | (val & ECC_MER_MASK_2); |
151 | dd53ded3 | blueswir1 | DPRINTF("Write memory enable %08x\n", val);
|
152 | 7eb0c8e8 | blueswir1 | break;
|
153 | dd53ded3 | blueswir1 | case ECC_MDR:
|
154 | 8f2ad0a3 | blueswir1 | s->regs[ECC_MDR] = val & ECC_MDR_MASK; |
155 | dd53ded3 | blueswir1 | DPRINTF("Write memory delay %08x\n", val);
|
156 | 7eb0c8e8 | blueswir1 | break;
|
157 | dd53ded3 | blueswir1 | case ECC_MFSR:
|
158 | 8f2ad0a3 | blueswir1 | s->regs[ECC_MFSR] = val; |
159 | 0bb3602c | blueswir1 | qemu_irq_lower(s->irq); |
160 | dd53ded3 | blueswir1 | DPRINTF("Write memory fault status %08x\n", val);
|
161 | 7eb0c8e8 | blueswir1 | break;
|
162 | dd53ded3 | blueswir1 | case ECC_VCR:
|
163 | 8f2ad0a3 | blueswir1 | s->regs[ECC_VCR] = val; |
164 | dd53ded3 | blueswir1 | DPRINTF("Write slot configuration %08x\n", val);
|
165 | 7eb0c8e8 | blueswir1 | break;
|
166 | dd53ded3 | blueswir1 | case ECC_DR:
|
167 | 8f2ad0a3 | blueswir1 | s->regs[ECC_DR] = val; |
168 | 0bb3602c | blueswir1 | DPRINTF("Write diagnostic %08x\n", val);
|
169 | dd53ded3 | blueswir1 | break;
|
170 | dd53ded3 | blueswir1 | case ECC_ECR0:
|
171 | 8f2ad0a3 | blueswir1 | s->regs[ECC_ECR0] = val; |
172 | dd53ded3 | blueswir1 | DPRINTF("Write event count 1 %08x\n", val);
|
173 | 7eb0c8e8 | blueswir1 | break;
|
174 | dd53ded3 | blueswir1 | case ECC_ECR1:
|
175 | 8f2ad0a3 | blueswir1 | s->regs[ECC_ECR0] = val; |
176 | dd53ded3 | blueswir1 | DPRINTF("Write event count 2 %08x\n", val);
|
177 | 7eb0c8e8 | blueswir1 | break;
|
178 | 7eb0c8e8 | blueswir1 | } |
179 | 7eb0c8e8 | blueswir1 | } |
180 | 7eb0c8e8 | blueswir1 | |
181 | c227f099 | Anthony Liguori | static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr) |
182 | 7eb0c8e8 | blueswir1 | { |
183 | 7eb0c8e8 | blueswir1 | ECCState *s = opaque; |
184 | 7eb0c8e8 | blueswir1 | uint32_t ret = 0;
|
185 | 7eb0c8e8 | blueswir1 | |
186 | e64d7d59 | blueswir1 | switch (addr >> 2) { |
187 | dd53ded3 | blueswir1 | case ECC_MER:
|
188 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_MER]; |
189 | dd53ded3 | blueswir1 | DPRINTF("Read memory enable %08x\n", ret);
|
190 | 7eb0c8e8 | blueswir1 | break;
|
191 | dd53ded3 | blueswir1 | case ECC_MDR:
|
192 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_MDR]; |
193 | dd53ded3 | blueswir1 | DPRINTF("Read memory delay %08x\n", ret);
|
194 | 7eb0c8e8 | blueswir1 | break;
|
195 | dd53ded3 | blueswir1 | case ECC_MFSR:
|
196 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_MFSR]; |
197 | dd53ded3 | blueswir1 | DPRINTF("Read memory fault status %08x\n", ret);
|
198 | 7eb0c8e8 | blueswir1 | break;
|
199 | dd53ded3 | blueswir1 | case ECC_VCR:
|
200 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_VCR]; |
201 | dd53ded3 | blueswir1 | DPRINTF("Read slot configuration %08x\n", ret);
|
202 | 7eb0c8e8 | blueswir1 | break;
|
203 | dd53ded3 | blueswir1 | case ECC_MFAR0:
|
204 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_MFAR0]; |
205 | dd53ded3 | blueswir1 | DPRINTF("Read memory fault address 0 %08x\n", ret);
|
206 | 7eb0c8e8 | blueswir1 | break;
|
207 | dd53ded3 | blueswir1 | case ECC_MFAR1:
|
208 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_MFAR1]; |
209 | dd53ded3 | blueswir1 | DPRINTF("Read memory fault address 1 %08x\n", ret);
|
210 | 7eb0c8e8 | blueswir1 | break;
|
211 | dd53ded3 | blueswir1 | case ECC_DR:
|
212 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_DR]; |
213 | dd53ded3 | blueswir1 | DPRINTF("Read diagnostic %08x\n", ret);
|
214 | 7eb0c8e8 | blueswir1 | break;
|
215 | dd53ded3 | blueswir1 | case ECC_ECR0:
|
216 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_ECR0]; |
217 | dd53ded3 | blueswir1 | DPRINTF("Read event count 1 %08x\n", ret);
|
218 | dd53ded3 | blueswir1 | break;
|
219 | dd53ded3 | blueswir1 | case ECC_ECR1:
|
220 | 8f2ad0a3 | blueswir1 | ret = s->regs[ECC_ECR0]; |
221 | dd53ded3 | blueswir1 | DPRINTF("Read event count 2 %08x\n", ret);
|
222 | 7eb0c8e8 | blueswir1 | break;
|
223 | 7eb0c8e8 | blueswir1 | } |
224 | 7eb0c8e8 | blueswir1 | return ret;
|
225 | 7eb0c8e8 | blueswir1 | } |
226 | 7eb0c8e8 | blueswir1 | |
227 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const ecc_mem_read[3] = { |
228 | 7c560456 | blueswir1 | NULL,
|
229 | 7c560456 | blueswir1 | NULL,
|
230 | 7eb0c8e8 | blueswir1 | ecc_mem_readl, |
231 | 7eb0c8e8 | blueswir1 | }; |
232 | 7eb0c8e8 | blueswir1 | |
233 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const ecc_mem_write[3] = { |
234 | 7c560456 | blueswir1 | NULL,
|
235 | 7c560456 | blueswir1 | NULL,
|
236 | 7eb0c8e8 | blueswir1 | ecc_mem_writel, |
237 | 7eb0c8e8 | blueswir1 | }; |
238 | 7eb0c8e8 | blueswir1 | |
239 | c227f099 | Anthony Liguori | static void ecc_diag_mem_writeb(void *opaque, target_phys_addr_t addr, |
240 | dd53ded3 | blueswir1 | uint32_t val) |
241 | dd53ded3 | blueswir1 | { |
242 | dd53ded3 | blueswir1 | ECCState *s = opaque; |
243 | dd53ded3 | blueswir1 | |
244 | e64d7d59 | blueswir1 | DPRINTF("Write diagnostic[%d] = %02x\n", (int)addr, val); |
245 | dd53ded3 | blueswir1 | s->diag[addr & ECC_DIAG_MASK] = val; |
246 | dd53ded3 | blueswir1 | } |
247 | dd53ded3 | blueswir1 | |
248 | c227f099 | Anthony Liguori | static uint32_t ecc_diag_mem_readb(void *opaque, target_phys_addr_t addr) |
249 | dd53ded3 | blueswir1 | { |
250 | dd53ded3 | blueswir1 | ECCState *s = opaque; |
251 | e64d7d59 | blueswir1 | uint32_t ret = s->diag[(int)addr];
|
252 | e64d7d59 | blueswir1 | |
253 | e64d7d59 | blueswir1 | DPRINTF("Read diagnostic[%d] = %02x\n", (int)addr, ret); |
254 | dd53ded3 | blueswir1 | return ret;
|
255 | dd53ded3 | blueswir1 | } |
256 | dd53ded3 | blueswir1 | |
257 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const ecc_diag_mem_read[3] = { |
258 | dd53ded3 | blueswir1 | ecc_diag_mem_readb, |
259 | dd53ded3 | blueswir1 | NULL,
|
260 | dd53ded3 | blueswir1 | NULL,
|
261 | dd53ded3 | blueswir1 | }; |
262 | dd53ded3 | blueswir1 | |
263 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const ecc_diag_mem_write[3] = { |
264 | dd53ded3 | blueswir1 | ecc_diag_mem_writeb, |
265 | dd53ded3 | blueswir1 | NULL,
|
266 | dd53ded3 | blueswir1 | NULL,
|
267 | dd53ded3 | blueswir1 | }; |
268 | dd53ded3 | blueswir1 | |
269 | c21011a9 | Blue Swirl | static const VMStateDescription vmstate_ecc = { |
270 | c21011a9 | Blue Swirl | .name ="ECC",
|
271 | c21011a9 | Blue Swirl | .version_id = 3,
|
272 | c21011a9 | Blue Swirl | .minimum_version_id = 3,
|
273 | c21011a9 | Blue Swirl | .minimum_version_id_old = 3,
|
274 | c21011a9 | Blue Swirl | .fields = (VMStateField []) { |
275 | c21011a9 | Blue Swirl | VMSTATE_UINT32_ARRAY(regs, ECCState, ECC_NREGS), |
276 | c21011a9 | Blue Swirl | VMSTATE_BUFFER(diag, ECCState), |
277 | c21011a9 | Blue Swirl | VMSTATE_UINT32(version, ECCState), |
278 | c21011a9 | Blue Swirl | VMSTATE_END_OF_LIST() |
279 | c21011a9 | Blue Swirl | } |
280 | c21011a9 | Blue Swirl | }; |
281 | 7eb0c8e8 | blueswir1 | |
282 | 0284dc54 | Blue Swirl | static void ecc_reset(DeviceState *d) |
283 | 7eb0c8e8 | blueswir1 | { |
284 | 0284dc54 | Blue Swirl | ECCState *s = container_of(d, ECCState, busdev.qdev); |
285 | 7eb0c8e8 | blueswir1 | |
286 | 0bb3602c | blueswir1 | if (s->version == ECC_MCC)
|
287 | 0bb3602c | blueswir1 | s->regs[ECC_MER] &= ECC_MER_REU; |
288 | 0bb3602c | blueswir1 | else
|
289 | 0bb3602c | blueswir1 | s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_MRR | |
290 | 0bb3602c | blueswir1 | ECC_MER_DCI); |
291 | dd53ded3 | blueswir1 | s->regs[ECC_MDR] = 0x20;
|
292 | dd53ded3 | blueswir1 | s->regs[ECC_MFSR] = 0;
|
293 | dd53ded3 | blueswir1 | s->regs[ECC_VCR] = 0;
|
294 | dd53ded3 | blueswir1 | s->regs[ECC_MFAR0] = 0x07c00000;
|
295 | dd53ded3 | blueswir1 | s->regs[ECC_MFAR1] = 0;
|
296 | dd53ded3 | blueswir1 | s->regs[ECC_DR] = 0;
|
297 | dd53ded3 | blueswir1 | s->regs[ECC_ECR0] = 0;
|
298 | dd53ded3 | blueswir1 | s->regs[ECC_ECR1] = 0;
|
299 | 7eb0c8e8 | blueswir1 | } |
300 | 7eb0c8e8 | blueswir1 | |
301 | 81a322d4 | Gerd Hoffmann | static int ecc_init1(SysBusDevice *dev) |
302 | 7eb0c8e8 | blueswir1 | { |
303 | 7eb0c8e8 | blueswir1 | int ecc_io_memory;
|
304 | 49e66373 | Blue Swirl | ECCState *s = FROM_SYSBUS(ECCState, dev); |
305 | 7eb0c8e8 | blueswir1 | |
306 | 49e66373 | Blue Swirl | sysbus_init_irq(dev, &s->irq); |
307 | 49e66373 | Blue Swirl | s->regs[0] = s->version;
|
308 | 1eed09cb | Avi Kivity | ecc_io_memory = cpu_register_io_memory(ecc_mem_read, ecc_mem_write, s); |
309 | 49e66373 | Blue Swirl | sysbus_init_mmio(dev, ECC_SIZE, ecc_io_memory); |
310 | 49e66373 | Blue Swirl | |
311 | 49e66373 | Blue Swirl | if (s->version == ECC_MCC) { // SS-600MP only |
312 | 1eed09cb | Avi Kivity | ecc_io_memory = cpu_register_io_memory(ecc_diag_mem_read, |
313 | dd53ded3 | blueswir1 | ecc_diag_mem_write, s); |
314 | 49e66373 | Blue Swirl | sysbus_init_mmio(dev, ECC_DIAG_SIZE, ecc_io_memory); |
315 | dd53ded3 | blueswir1 | } |
316 | 0284dc54 | Blue Swirl | |
317 | 81a322d4 | Gerd Hoffmann | return 0; |
318 | 7eb0c8e8 | blueswir1 | } |
319 | 49e66373 | Blue Swirl | |
320 | ee6847d1 | Gerd Hoffmann | static SysBusDeviceInfo ecc_info = {
|
321 | ee6847d1 | Gerd Hoffmann | .init = ecc_init1, |
322 | ee6847d1 | Gerd Hoffmann | .qdev.name = "eccmemctl",
|
323 | ee6847d1 | Gerd Hoffmann | .qdev.size = sizeof(ECCState),
|
324 | 0284dc54 | Blue Swirl | .qdev.vmsd = &vmstate_ecc, |
325 | 0284dc54 | Blue Swirl | .qdev.reset = ecc_reset, |
326 | ee6847d1 | Gerd Hoffmann | .qdev.props = (Property[]) { |
327 | d210a1b4 | Gerd Hoffmann | DEFINE_PROP_HEX32("version", ECCState, version, -1), |
328 | d210a1b4 | Gerd Hoffmann | DEFINE_PROP_END_OF_LIST(), |
329 | ee6847d1 | Gerd Hoffmann | } |
330 | ee6847d1 | Gerd Hoffmann | }; |
331 | ee6847d1 | Gerd Hoffmann | |
332 | ee6847d1 | Gerd Hoffmann | |
333 | 49e66373 | Blue Swirl | static void ecc_register_devices(void) |
334 | 49e66373 | Blue Swirl | { |
335 | ee6847d1 | Gerd Hoffmann | sysbus_register_withprop(&ecc_info); |
336 | 49e66373 | Blue Swirl | } |
337 | 49e66373 | Blue Swirl | |
338 | 49e66373 | Blue Swirl | device_init(ecc_register_devices) |