root / hw / ppc.c @ 3e21ffc9
History | View | Annotate | Download (37.8 kB)
1 | a541f297 | bellard | /*
|
---|---|---|---|
2 | e9df014c | j_mayer | * QEMU generic PowerPC hardware System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 76a66253 | j_mayer | * Copyright (c) 2003-2007 Jocelyn Mayer
|
5 | 5fafdf24 | ths | *
|
6 | a541f297 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | a541f297 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | a541f297 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | a541f297 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | a541f297 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | a541f297 | bellard | * furnished to do so, subject to the following conditions:
|
12 | a541f297 | bellard | *
|
13 | a541f297 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | a541f297 | bellard | * all copies or substantial portions of the Software.
|
15 | a541f297 | bellard | *
|
16 | a541f297 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | a541f297 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | a541f297 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | a541f297 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | a541f297 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | a541f297 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | a541f297 | bellard | * THE SOFTWARE.
|
23 | a541f297 | bellard | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "ppc.h" |
26 | 87ecb68b | pbrook | #include "qemu-timer.h" |
27 | 87ecb68b | pbrook | #include "sysemu.h" |
28 | 87ecb68b | pbrook | #include "nvram.h" |
29 | 3b3fb322 | blueswir1 | #include "qemu-log.h" |
30 | ca20cf32 | Blue Swirl | #include "loader.h" |
31 | a541f297 | bellard | |
32 | e9df014c | j_mayer | //#define PPC_DEBUG_IRQ
|
33 | 4b6d0a4c | j_mayer | //#define PPC_DEBUG_TB
|
34 | e9df014c | j_mayer | |
35 | d12d51d5 | aliguori | #ifdef PPC_DEBUG_IRQ
|
36 | 93fcfe39 | aliguori | # define LOG_IRQ(...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__) |
37 | d12d51d5 | aliguori | #else
|
38 | d12d51d5 | aliguori | # define LOG_IRQ(...) do { } while (0) |
39 | d12d51d5 | aliguori | #endif
|
40 | d12d51d5 | aliguori | |
41 | d12d51d5 | aliguori | |
42 | d12d51d5 | aliguori | #ifdef PPC_DEBUG_TB
|
43 | 93fcfe39 | aliguori | # define LOG_TB(...) qemu_log(__VA_ARGS__)
|
44 | d12d51d5 | aliguori | #else
|
45 | d12d51d5 | aliguori | # define LOG_TB(...) do { } while (0) |
46 | d12d51d5 | aliguori | #endif
|
47 | d12d51d5 | aliguori | |
48 | dbdd2506 | j_mayer | static void cpu_ppc_tb_stop (CPUState *env); |
49 | dbdd2506 | j_mayer | static void cpu_ppc_tb_start (CPUState *env); |
50 | dbdd2506 | j_mayer | |
51 | 00af685f | j_mayer | static void ppc_set_irq (CPUState *env, int n_IRQ, int level) |
52 | 47103572 | j_mayer | { |
53 | 47103572 | j_mayer | if (level) {
|
54 | 47103572 | j_mayer | env->pending_interrupts |= 1 << n_IRQ;
|
55 | 47103572 | j_mayer | cpu_interrupt(env, CPU_INTERRUPT_HARD); |
56 | 47103572 | j_mayer | } else {
|
57 | 47103572 | j_mayer | env->pending_interrupts &= ~(1 << n_IRQ);
|
58 | 47103572 | j_mayer | if (env->pending_interrupts == 0) |
59 | 47103572 | j_mayer | cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); |
60 | 47103572 | j_mayer | } |
61 | d12d51d5 | aliguori | LOG_IRQ("%s: %p n_IRQ %d level %d => pending %08" PRIx32
|
62 | aae9366a | j_mayer | "req %08x\n", __func__, env, n_IRQ, level,
|
63 | a496775f | j_mayer | env->pending_interrupts, env->interrupt_request); |
64 | 47103572 | j_mayer | } |
65 | 47103572 | j_mayer | |
66 | e9df014c | j_mayer | /* PowerPC 6xx / 7xx internal IRQ controller */
|
67 | e9df014c | j_mayer | static void ppc6xx_set_irq (void *opaque, int pin, int level) |
68 | d537cf6c | pbrook | { |
69 | e9df014c | j_mayer | CPUState *env = opaque; |
70 | e9df014c | j_mayer | int cur_level;
|
71 | d537cf6c | pbrook | |
72 | d12d51d5 | aliguori | LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
|
73 | a496775f | j_mayer | env, pin, level); |
74 | e9df014c | j_mayer | cur_level = (env->irq_input_state >> pin) & 1;
|
75 | e9df014c | j_mayer | /* Don't generate spurious events */
|
76 | 24be5ae3 | j_mayer | if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { |
77 | e9df014c | j_mayer | switch (pin) {
|
78 | dbdd2506 | j_mayer | case PPC6xx_INPUT_TBEN:
|
79 | dbdd2506 | j_mayer | /* Level sensitive - active high */
|
80 | d12d51d5 | aliguori | LOG_IRQ("%s: %s the time base\n",
|
81 | dbdd2506 | j_mayer | __func__, level ? "start" : "stop"); |
82 | dbdd2506 | j_mayer | if (level) {
|
83 | dbdd2506 | j_mayer | cpu_ppc_tb_start(env); |
84 | dbdd2506 | j_mayer | } else {
|
85 | dbdd2506 | j_mayer | cpu_ppc_tb_stop(env); |
86 | dbdd2506 | j_mayer | } |
87 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_INT:
|
88 | 24be5ae3 | j_mayer | /* Level sensitive - active high */
|
89 | d12d51d5 | aliguori | LOG_IRQ("%s: set the external IRQ state to %d\n",
|
90 | a496775f | j_mayer | __func__, level); |
91 | e9df014c | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_EXT, level); |
92 | e9df014c | j_mayer | break;
|
93 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_SMI:
|
94 | e9df014c | j_mayer | /* Level sensitive - active high */
|
95 | d12d51d5 | aliguori | LOG_IRQ("%s: set the SMI IRQ state to %d\n",
|
96 | a496775f | j_mayer | __func__, level); |
97 | e9df014c | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_SMI, level); |
98 | e9df014c | j_mayer | break;
|
99 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_MCP:
|
100 | e9df014c | j_mayer | /* Negative edge sensitive */
|
101 | e9df014c | j_mayer | /* XXX: TODO: actual reaction may depends on HID0 status
|
102 | e9df014c | j_mayer | * 603/604/740/750: check HID0[EMCP]
|
103 | e9df014c | j_mayer | */
|
104 | e9df014c | j_mayer | if (cur_level == 1 && level == 0) { |
105 | d12d51d5 | aliguori | LOG_IRQ("%s: raise machine check state\n",
|
106 | a496775f | j_mayer | __func__); |
107 | e9df014c | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
|
108 | e9df014c | j_mayer | } |
109 | e9df014c | j_mayer | break;
|
110 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_CKSTP_IN:
|
111 | e9df014c | j_mayer | /* Level sensitive - active low */
|
112 | e9df014c | j_mayer | /* XXX: TODO: relay the signal to CKSTP_OUT pin */
|
113 | e63ecc6f | j_mayer | /* XXX: Note that the only way to restart the CPU is to reset it */
|
114 | e9df014c | j_mayer | if (level) {
|
115 | d12d51d5 | aliguori | LOG_IRQ("%s: stop the CPU\n", __func__);
|
116 | e9df014c | j_mayer | env->halted = 1;
|
117 | e9df014c | j_mayer | } |
118 | e9df014c | j_mayer | break;
|
119 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_HRESET:
|
120 | e9df014c | j_mayer | /* Level sensitive - active low */
|
121 | e9df014c | j_mayer | if (level) {
|
122 | d12d51d5 | aliguori | LOG_IRQ("%s: reset the CPU\n", __func__);
|
123 | ef397e88 | j_mayer | env->interrupt_request |= CPU_INTERRUPT_EXITTB; |
124 | ef397e88 | j_mayer | /* XXX: TOFIX */
|
125 | ef397e88 | j_mayer | #if 0
|
126 | d84bda46 | Blue Swirl | cpu_reset(env);
|
127 | ef397e88 | j_mayer | #else
|
128 | ef397e88 | j_mayer | qemu_system_reset_request(); |
129 | e9df014c | j_mayer | #endif
|
130 | e9df014c | j_mayer | } |
131 | e9df014c | j_mayer | break;
|
132 | 24be5ae3 | j_mayer | case PPC6xx_INPUT_SRESET:
|
133 | d12d51d5 | aliguori | LOG_IRQ("%s: set the RESET IRQ state to %d\n",
|
134 | a496775f | j_mayer | __func__, level); |
135 | e9df014c | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_RESET, level); |
136 | e9df014c | j_mayer | break;
|
137 | e9df014c | j_mayer | default:
|
138 | e9df014c | j_mayer | /* Unknown pin - do nothing */
|
139 | d12d51d5 | aliguori | LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
|
140 | e9df014c | j_mayer | return;
|
141 | e9df014c | j_mayer | } |
142 | e9df014c | j_mayer | if (level)
|
143 | e9df014c | j_mayer | env->irq_input_state |= 1 << pin;
|
144 | e9df014c | j_mayer | else
|
145 | e9df014c | j_mayer | env->irq_input_state &= ~(1 << pin);
|
146 | d537cf6c | pbrook | } |
147 | d537cf6c | pbrook | } |
148 | d537cf6c | pbrook | |
149 | e9df014c | j_mayer | void ppc6xx_irq_init (CPUState *env)
|
150 | 47103572 | j_mayer | { |
151 | 7b62a955 | j_mayer | env->irq_inputs = (void **)qemu_allocate_irqs(&ppc6xx_set_irq, env,
|
152 | 7b62a955 | j_mayer | PPC6xx_INPUT_NB); |
153 | 47103572 | j_mayer | } |
154 | 47103572 | j_mayer | |
155 | 00af685f | j_mayer | #if defined(TARGET_PPC64)
|
156 | d0dfae6e | j_mayer | /* PowerPC 970 internal IRQ controller */
|
157 | d0dfae6e | j_mayer | static void ppc970_set_irq (void *opaque, int pin, int level) |
158 | d0dfae6e | j_mayer | { |
159 | d0dfae6e | j_mayer | CPUState *env = opaque; |
160 | d0dfae6e | j_mayer | int cur_level;
|
161 | d0dfae6e | j_mayer | |
162 | d12d51d5 | aliguori | LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
|
163 | d0dfae6e | j_mayer | env, pin, level); |
164 | d0dfae6e | j_mayer | cur_level = (env->irq_input_state >> pin) & 1;
|
165 | d0dfae6e | j_mayer | /* Don't generate spurious events */
|
166 | d0dfae6e | j_mayer | if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { |
167 | d0dfae6e | j_mayer | switch (pin) {
|
168 | d0dfae6e | j_mayer | case PPC970_INPUT_INT:
|
169 | d0dfae6e | j_mayer | /* Level sensitive - active high */
|
170 | d12d51d5 | aliguori | LOG_IRQ("%s: set the external IRQ state to %d\n",
|
171 | d0dfae6e | j_mayer | __func__, level); |
172 | d0dfae6e | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_EXT, level); |
173 | d0dfae6e | j_mayer | break;
|
174 | d0dfae6e | j_mayer | case PPC970_INPUT_THINT:
|
175 | d0dfae6e | j_mayer | /* Level sensitive - active high */
|
176 | d12d51d5 | aliguori | LOG_IRQ("%s: set the SMI IRQ state to %d\n", __func__,
|
177 | d0dfae6e | j_mayer | level); |
178 | d0dfae6e | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_THERM, level); |
179 | d0dfae6e | j_mayer | break;
|
180 | d0dfae6e | j_mayer | case PPC970_INPUT_MCP:
|
181 | d0dfae6e | j_mayer | /* Negative edge sensitive */
|
182 | d0dfae6e | j_mayer | /* XXX: TODO: actual reaction may depends on HID0 status
|
183 | d0dfae6e | j_mayer | * 603/604/740/750: check HID0[EMCP]
|
184 | d0dfae6e | j_mayer | */
|
185 | d0dfae6e | j_mayer | if (cur_level == 1 && level == 0) { |
186 | d12d51d5 | aliguori | LOG_IRQ("%s: raise machine check state\n",
|
187 | d0dfae6e | j_mayer | __func__); |
188 | d0dfae6e | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
|
189 | d0dfae6e | j_mayer | } |
190 | d0dfae6e | j_mayer | break;
|
191 | d0dfae6e | j_mayer | case PPC970_INPUT_CKSTP:
|
192 | d0dfae6e | j_mayer | /* Level sensitive - active low */
|
193 | d0dfae6e | j_mayer | /* XXX: TODO: relay the signal to CKSTP_OUT pin */
|
194 | d0dfae6e | j_mayer | if (level) {
|
195 | d12d51d5 | aliguori | LOG_IRQ("%s: stop the CPU\n", __func__);
|
196 | d0dfae6e | j_mayer | env->halted = 1;
|
197 | d0dfae6e | j_mayer | } else {
|
198 | d12d51d5 | aliguori | LOG_IRQ("%s: restart the CPU\n", __func__);
|
199 | d0dfae6e | j_mayer | env->halted = 0;
|
200 | d0dfae6e | j_mayer | } |
201 | d0dfae6e | j_mayer | break;
|
202 | d0dfae6e | j_mayer | case PPC970_INPUT_HRESET:
|
203 | d0dfae6e | j_mayer | /* Level sensitive - active low */
|
204 | d0dfae6e | j_mayer | if (level) {
|
205 | d0dfae6e | j_mayer | #if 0 // XXX: TOFIX
|
206 | d12d51d5 | aliguori | LOG_IRQ("%s: reset the CPU\n", __func__);
|
207 | d0dfae6e | j_mayer | cpu_reset(env);
|
208 | d0dfae6e | j_mayer | #endif
|
209 | d0dfae6e | j_mayer | } |
210 | d0dfae6e | j_mayer | break;
|
211 | d0dfae6e | j_mayer | case PPC970_INPUT_SRESET:
|
212 | d12d51d5 | aliguori | LOG_IRQ("%s: set the RESET IRQ state to %d\n",
|
213 | d0dfae6e | j_mayer | __func__, level); |
214 | d0dfae6e | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_RESET, level); |
215 | d0dfae6e | j_mayer | break;
|
216 | d0dfae6e | j_mayer | case PPC970_INPUT_TBEN:
|
217 | d12d51d5 | aliguori | LOG_IRQ("%s: set the TBEN state to %d\n", __func__,
|
218 | d0dfae6e | j_mayer | level); |
219 | d0dfae6e | j_mayer | /* XXX: TODO */
|
220 | d0dfae6e | j_mayer | break;
|
221 | d0dfae6e | j_mayer | default:
|
222 | d0dfae6e | j_mayer | /* Unknown pin - do nothing */
|
223 | d12d51d5 | aliguori | LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
|
224 | d0dfae6e | j_mayer | return;
|
225 | d0dfae6e | j_mayer | } |
226 | d0dfae6e | j_mayer | if (level)
|
227 | d0dfae6e | j_mayer | env->irq_input_state |= 1 << pin;
|
228 | d0dfae6e | j_mayer | else
|
229 | d0dfae6e | j_mayer | env->irq_input_state &= ~(1 << pin);
|
230 | d0dfae6e | j_mayer | } |
231 | d0dfae6e | j_mayer | } |
232 | d0dfae6e | j_mayer | |
233 | d0dfae6e | j_mayer | void ppc970_irq_init (CPUState *env)
|
234 | d0dfae6e | j_mayer | { |
235 | 7b62a955 | j_mayer | env->irq_inputs = (void **)qemu_allocate_irqs(&ppc970_set_irq, env,
|
236 | 7b62a955 | j_mayer | PPC970_INPUT_NB); |
237 | d0dfae6e | j_mayer | } |
238 | 00af685f | j_mayer | #endif /* defined(TARGET_PPC64) */ |
239 | d0dfae6e | j_mayer | |
240 | 4e290a0b | j_mayer | /* PowerPC 40x internal IRQ controller */
|
241 | 4e290a0b | j_mayer | static void ppc40x_set_irq (void *opaque, int pin, int level) |
242 | 24be5ae3 | j_mayer | { |
243 | 24be5ae3 | j_mayer | CPUState *env = opaque; |
244 | 24be5ae3 | j_mayer | int cur_level;
|
245 | 24be5ae3 | j_mayer | |
246 | d12d51d5 | aliguori | LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
|
247 | 8ecc7913 | j_mayer | env, pin, level); |
248 | 24be5ae3 | j_mayer | cur_level = (env->irq_input_state >> pin) & 1;
|
249 | 24be5ae3 | j_mayer | /* Don't generate spurious events */
|
250 | 24be5ae3 | j_mayer | if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { |
251 | 24be5ae3 | j_mayer | switch (pin) {
|
252 | 4e290a0b | j_mayer | case PPC40x_INPUT_RESET_SYS:
|
253 | 8ecc7913 | j_mayer | if (level) {
|
254 | d12d51d5 | aliguori | LOG_IRQ("%s: reset the PowerPC system\n",
|
255 | 8ecc7913 | j_mayer | __func__); |
256 | 8ecc7913 | j_mayer | ppc40x_system_reset(env); |
257 | 8ecc7913 | j_mayer | } |
258 | 8ecc7913 | j_mayer | break;
|
259 | 4e290a0b | j_mayer | case PPC40x_INPUT_RESET_CHIP:
|
260 | 8ecc7913 | j_mayer | if (level) {
|
261 | d12d51d5 | aliguori | LOG_IRQ("%s: reset the PowerPC chip\n", __func__);
|
262 | 8ecc7913 | j_mayer | ppc40x_chip_reset(env); |
263 | 8ecc7913 | j_mayer | } |
264 | 8ecc7913 | j_mayer | break;
|
265 | 4e290a0b | j_mayer | case PPC40x_INPUT_RESET_CORE:
|
266 | 24be5ae3 | j_mayer | /* XXX: TODO: update DBSR[MRR] */
|
267 | 24be5ae3 | j_mayer | if (level) {
|
268 | d12d51d5 | aliguori | LOG_IRQ("%s: reset the PowerPC core\n", __func__);
|
269 | 8ecc7913 | j_mayer | ppc40x_core_reset(env); |
270 | 24be5ae3 | j_mayer | } |
271 | 24be5ae3 | j_mayer | break;
|
272 | 4e290a0b | j_mayer | case PPC40x_INPUT_CINT:
|
273 | 24be5ae3 | j_mayer | /* Level sensitive - active high */
|
274 | d12d51d5 | aliguori | LOG_IRQ("%s: set the critical IRQ state to %d\n",
|
275 | 8ecc7913 | j_mayer | __func__, level); |
276 | 4e290a0b | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_CEXT, level); |
277 | 24be5ae3 | j_mayer | break;
|
278 | 4e290a0b | j_mayer | case PPC40x_INPUT_INT:
|
279 | 24be5ae3 | j_mayer | /* Level sensitive - active high */
|
280 | d12d51d5 | aliguori | LOG_IRQ("%s: set the external IRQ state to %d\n",
|
281 | a496775f | j_mayer | __func__, level); |
282 | 24be5ae3 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_EXT, level); |
283 | 24be5ae3 | j_mayer | break;
|
284 | 4e290a0b | j_mayer | case PPC40x_INPUT_HALT:
|
285 | 24be5ae3 | j_mayer | /* Level sensitive - active low */
|
286 | 24be5ae3 | j_mayer | if (level) {
|
287 | d12d51d5 | aliguori | LOG_IRQ("%s: stop the CPU\n", __func__);
|
288 | 24be5ae3 | j_mayer | env->halted = 1;
|
289 | 24be5ae3 | j_mayer | } else {
|
290 | d12d51d5 | aliguori | LOG_IRQ("%s: restart the CPU\n", __func__);
|
291 | 24be5ae3 | j_mayer | env->halted = 0;
|
292 | 24be5ae3 | j_mayer | } |
293 | 24be5ae3 | j_mayer | break;
|
294 | 4e290a0b | j_mayer | case PPC40x_INPUT_DEBUG:
|
295 | 24be5ae3 | j_mayer | /* Level sensitive - active high */
|
296 | d12d51d5 | aliguori | LOG_IRQ("%s: set the debug pin state to %d\n",
|
297 | a496775f | j_mayer | __func__, level); |
298 | a750fc0b | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level); |
299 | 24be5ae3 | j_mayer | break;
|
300 | 24be5ae3 | j_mayer | default:
|
301 | 24be5ae3 | j_mayer | /* Unknown pin - do nothing */
|
302 | d12d51d5 | aliguori | LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
|
303 | 24be5ae3 | j_mayer | return;
|
304 | 24be5ae3 | j_mayer | } |
305 | 24be5ae3 | j_mayer | if (level)
|
306 | 24be5ae3 | j_mayer | env->irq_input_state |= 1 << pin;
|
307 | 24be5ae3 | j_mayer | else
|
308 | 24be5ae3 | j_mayer | env->irq_input_state &= ~(1 << pin);
|
309 | 24be5ae3 | j_mayer | } |
310 | 24be5ae3 | j_mayer | } |
311 | 24be5ae3 | j_mayer | |
312 | 4e290a0b | j_mayer | void ppc40x_irq_init (CPUState *env)
|
313 | 24be5ae3 | j_mayer | { |
314 | 4e290a0b | j_mayer | env->irq_inputs = (void **)qemu_allocate_irqs(&ppc40x_set_irq,
|
315 | 4e290a0b | j_mayer | env, PPC40x_INPUT_NB); |
316 | 24be5ae3 | j_mayer | } |
317 | 24be5ae3 | j_mayer | |
318 | 9fdc60bf | aurel32 | /* PowerPC E500 internal IRQ controller */
|
319 | 9fdc60bf | aurel32 | static void ppce500_set_irq (void *opaque, int pin, int level) |
320 | 9fdc60bf | aurel32 | { |
321 | 9fdc60bf | aurel32 | CPUState *env = opaque; |
322 | 9fdc60bf | aurel32 | int cur_level;
|
323 | 9fdc60bf | aurel32 | |
324 | 9fdc60bf | aurel32 | LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
|
325 | 9fdc60bf | aurel32 | env, pin, level); |
326 | 9fdc60bf | aurel32 | cur_level = (env->irq_input_state >> pin) & 1;
|
327 | 9fdc60bf | aurel32 | /* Don't generate spurious events */
|
328 | 9fdc60bf | aurel32 | if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { |
329 | 9fdc60bf | aurel32 | switch (pin) {
|
330 | 9fdc60bf | aurel32 | case PPCE500_INPUT_MCK:
|
331 | 9fdc60bf | aurel32 | if (level) {
|
332 | 9fdc60bf | aurel32 | LOG_IRQ("%s: reset the PowerPC system\n",
|
333 | 9fdc60bf | aurel32 | __func__); |
334 | 9fdc60bf | aurel32 | qemu_system_reset_request(); |
335 | 9fdc60bf | aurel32 | } |
336 | 9fdc60bf | aurel32 | break;
|
337 | 9fdc60bf | aurel32 | case PPCE500_INPUT_RESET_CORE:
|
338 | 9fdc60bf | aurel32 | if (level) {
|
339 | 9fdc60bf | aurel32 | LOG_IRQ("%s: reset the PowerPC core\n", __func__);
|
340 | 9fdc60bf | aurel32 | ppc_set_irq(env, PPC_INTERRUPT_MCK, level); |
341 | 9fdc60bf | aurel32 | } |
342 | 9fdc60bf | aurel32 | break;
|
343 | 9fdc60bf | aurel32 | case PPCE500_INPUT_CINT:
|
344 | 9fdc60bf | aurel32 | /* Level sensitive - active high */
|
345 | 9fdc60bf | aurel32 | LOG_IRQ("%s: set the critical IRQ state to %d\n",
|
346 | 9fdc60bf | aurel32 | __func__, level); |
347 | 9fdc60bf | aurel32 | ppc_set_irq(env, PPC_INTERRUPT_CEXT, level); |
348 | 9fdc60bf | aurel32 | break;
|
349 | 9fdc60bf | aurel32 | case PPCE500_INPUT_INT:
|
350 | 9fdc60bf | aurel32 | /* Level sensitive - active high */
|
351 | 9fdc60bf | aurel32 | LOG_IRQ("%s: set the core IRQ state to %d\n",
|
352 | 9fdc60bf | aurel32 | __func__, level); |
353 | 9fdc60bf | aurel32 | ppc_set_irq(env, PPC_INTERRUPT_EXT, level); |
354 | 9fdc60bf | aurel32 | break;
|
355 | 9fdc60bf | aurel32 | case PPCE500_INPUT_DEBUG:
|
356 | 9fdc60bf | aurel32 | /* Level sensitive - active high */
|
357 | 9fdc60bf | aurel32 | LOG_IRQ("%s: set the debug pin state to %d\n",
|
358 | 9fdc60bf | aurel32 | __func__, level); |
359 | 9fdc60bf | aurel32 | ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level); |
360 | 9fdc60bf | aurel32 | break;
|
361 | 9fdc60bf | aurel32 | default:
|
362 | 9fdc60bf | aurel32 | /* Unknown pin - do nothing */
|
363 | 9fdc60bf | aurel32 | LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
|
364 | 9fdc60bf | aurel32 | return;
|
365 | 9fdc60bf | aurel32 | } |
366 | 9fdc60bf | aurel32 | if (level)
|
367 | 9fdc60bf | aurel32 | env->irq_input_state |= 1 << pin;
|
368 | 9fdc60bf | aurel32 | else
|
369 | 9fdc60bf | aurel32 | env->irq_input_state &= ~(1 << pin);
|
370 | 9fdc60bf | aurel32 | } |
371 | 9fdc60bf | aurel32 | } |
372 | 9fdc60bf | aurel32 | |
373 | 9fdc60bf | aurel32 | void ppce500_irq_init (CPUState *env)
|
374 | 9fdc60bf | aurel32 | { |
375 | 9fdc60bf | aurel32 | env->irq_inputs = (void **)qemu_allocate_irqs(&ppce500_set_irq,
|
376 | 9fdc60bf | aurel32 | env, PPCE500_INPUT_NB); |
377 | 9fdc60bf | aurel32 | } |
378 | 9fddaa0c | bellard | /*****************************************************************************/
|
379 | e9df014c | j_mayer | /* PowerPC time base and decrementer emulation */
|
380 | c227f099 | Anthony Liguori | struct ppc_tb_t {
|
381 | 9fddaa0c | bellard | /* Time base management */
|
382 | dbdd2506 | j_mayer | int64_t tb_offset; /* Compensation */
|
383 | dbdd2506 | j_mayer | int64_t atb_offset; /* Compensation */
|
384 | dbdd2506 | j_mayer | uint32_t tb_freq; /* TB frequency */
|
385 | 9fddaa0c | bellard | /* Decrementer management */
|
386 | dbdd2506 | j_mayer | uint64_t decr_next; /* Tick for next decr interrupt */
|
387 | dbdd2506 | j_mayer | uint32_t decr_freq; /* decrementer frequency */
|
388 | 9fddaa0c | bellard | struct QEMUTimer *decr_timer;
|
389 | 58a7d328 | j_mayer | /* Hypervisor decrementer management */
|
390 | 58a7d328 | j_mayer | uint64_t hdecr_next; /* Tick for next hdecr interrupt */
|
391 | 58a7d328 | j_mayer | struct QEMUTimer *hdecr_timer;
|
392 | 58a7d328 | j_mayer | uint64_t purr_load; |
393 | 58a7d328 | j_mayer | uint64_t purr_start; |
394 | 47103572 | j_mayer | void *opaque;
|
395 | 9fddaa0c | bellard | }; |
396 | 9fddaa0c | bellard | |
397 | c227f099 | Anthony Liguori | static inline uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk, |
398 | 636aa200 | Blue Swirl | int64_t tb_offset) |
399 | 9fddaa0c | bellard | { |
400 | 9fddaa0c | bellard | /* TB time in tb periods */
|
401 | 6ee093c9 | Juan Quintela | return muldiv64(vmclk, tb_env->tb_freq, get_ticks_per_sec()) + tb_offset;
|
402 | 9fddaa0c | bellard | } |
403 | 9fddaa0c | bellard | |
404 | 9fddaa0c | bellard | uint32_t cpu_ppc_load_tbl (CPUState *env) |
405 | 9fddaa0c | bellard | { |
406 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
407 | 9fddaa0c | bellard | uint64_t tb; |
408 | 9fddaa0c | bellard | |
409 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); |
410 | d12d51d5 | aliguori | LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); |
411 | 9fddaa0c | bellard | |
412 | 9fddaa0c | bellard | return tb & 0xFFFFFFFF; |
413 | 9fddaa0c | bellard | } |
414 | 9fddaa0c | bellard | |
415 | 636aa200 | Blue Swirl | static inline uint32_t _cpu_ppc_load_tbu(CPUState *env) |
416 | 9fddaa0c | bellard | { |
417 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
418 | 9fddaa0c | bellard | uint64_t tb; |
419 | 9fddaa0c | bellard | |
420 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); |
421 | d12d51d5 | aliguori | LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); |
422 | 76a66253 | j_mayer | |
423 | 9fddaa0c | bellard | return tb >> 32; |
424 | 9fddaa0c | bellard | } |
425 | 9fddaa0c | bellard | |
426 | 8a84de23 | j_mayer | uint32_t cpu_ppc_load_tbu (CPUState *env) |
427 | 8a84de23 | j_mayer | { |
428 | 8a84de23 | j_mayer | return _cpu_ppc_load_tbu(env);
|
429 | 8a84de23 | j_mayer | } |
430 | 8a84de23 | j_mayer | |
431 | c227f099 | Anthony Liguori | static inline void cpu_ppc_store_tb(ppc_tb_t *tb_env, uint64_t vmclk, |
432 | 636aa200 | Blue Swirl | int64_t *tb_offsetp, uint64_t value) |
433 | 9fddaa0c | bellard | { |
434 | 6ee093c9 | Juan Quintela | *tb_offsetp = value - muldiv64(vmclk, tb_env->tb_freq, get_ticks_per_sec()); |
435 | d12d51d5 | aliguori | LOG_TB("%s: tb %016" PRIx64 " offset %08" PRIx64 "\n", |
436 | aae9366a | j_mayer | __func__, value, *tb_offsetp); |
437 | 9fddaa0c | bellard | } |
438 | 9fddaa0c | bellard | |
439 | a062e36c | j_mayer | void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
440 | a062e36c | j_mayer | { |
441 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
442 | a062e36c | j_mayer | uint64_t tb; |
443 | a062e36c | j_mayer | |
444 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); |
445 | a062e36c | j_mayer | tb &= 0xFFFFFFFF00000000ULL;
|
446 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, qemu_get_clock(vm_clock), |
447 | dbdd2506 | j_mayer | &tb_env->tb_offset, tb | (uint64_t)value); |
448 | a062e36c | j_mayer | } |
449 | a062e36c | j_mayer | |
450 | 636aa200 | Blue Swirl | static inline void _cpu_ppc_store_tbu(CPUState *env, uint32_t value) |
451 | 9fddaa0c | bellard | { |
452 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
453 | a062e36c | j_mayer | uint64_t tb; |
454 | 9fddaa0c | bellard | |
455 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); |
456 | a062e36c | j_mayer | tb &= 0x00000000FFFFFFFFULL;
|
457 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, qemu_get_clock(vm_clock), |
458 | dbdd2506 | j_mayer | &tb_env->tb_offset, ((uint64_t)value << 32) | tb);
|
459 | 9fddaa0c | bellard | } |
460 | 9fddaa0c | bellard | |
461 | 8a84de23 | j_mayer | void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
462 | 8a84de23 | j_mayer | { |
463 | 8a84de23 | j_mayer | _cpu_ppc_store_tbu(env, value); |
464 | 8a84de23 | j_mayer | } |
465 | 8a84de23 | j_mayer | |
466 | a062e36c | j_mayer | uint32_t cpu_ppc_load_atbl (CPUState *env) |
467 | a062e36c | j_mayer | { |
468 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
469 | a062e36c | j_mayer | uint64_t tb; |
470 | a062e36c | j_mayer | |
471 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); |
472 | d12d51d5 | aliguori | LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); |
473 | a062e36c | j_mayer | |
474 | a062e36c | j_mayer | return tb & 0xFFFFFFFF; |
475 | a062e36c | j_mayer | } |
476 | a062e36c | j_mayer | |
477 | a062e36c | j_mayer | uint32_t cpu_ppc_load_atbu (CPUState *env) |
478 | a062e36c | j_mayer | { |
479 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
480 | a062e36c | j_mayer | uint64_t tb; |
481 | a062e36c | j_mayer | |
482 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); |
483 | d12d51d5 | aliguori | LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); |
484 | a062e36c | j_mayer | |
485 | a062e36c | j_mayer | return tb >> 32; |
486 | a062e36c | j_mayer | } |
487 | a062e36c | j_mayer | |
488 | a062e36c | j_mayer | void cpu_ppc_store_atbl (CPUState *env, uint32_t value)
|
489 | a062e36c | j_mayer | { |
490 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
491 | a062e36c | j_mayer | uint64_t tb; |
492 | a062e36c | j_mayer | |
493 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); |
494 | a062e36c | j_mayer | tb &= 0xFFFFFFFF00000000ULL;
|
495 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, qemu_get_clock(vm_clock), |
496 | dbdd2506 | j_mayer | &tb_env->atb_offset, tb | (uint64_t)value); |
497 | a062e36c | j_mayer | } |
498 | a062e36c | j_mayer | |
499 | a062e36c | j_mayer | void cpu_ppc_store_atbu (CPUState *env, uint32_t value)
|
500 | 9fddaa0c | bellard | { |
501 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
502 | a062e36c | j_mayer | uint64_t tb; |
503 | 9fddaa0c | bellard | |
504 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); |
505 | a062e36c | j_mayer | tb &= 0x00000000FFFFFFFFULL;
|
506 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, qemu_get_clock(vm_clock), |
507 | dbdd2506 | j_mayer | &tb_env->atb_offset, ((uint64_t)value << 32) | tb);
|
508 | dbdd2506 | j_mayer | } |
509 | dbdd2506 | j_mayer | |
510 | dbdd2506 | j_mayer | static void cpu_ppc_tb_stop (CPUState *env) |
511 | dbdd2506 | j_mayer | { |
512 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
513 | dbdd2506 | j_mayer | uint64_t tb, atb, vmclk; |
514 | dbdd2506 | j_mayer | |
515 | dbdd2506 | j_mayer | /* If the time base is already frozen, do nothing */
|
516 | dbdd2506 | j_mayer | if (tb_env->tb_freq != 0) { |
517 | dbdd2506 | j_mayer | vmclk = qemu_get_clock(vm_clock); |
518 | dbdd2506 | j_mayer | /* Get the time base */
|
519 | dbdd2506 | j_mayer | tb = cpu_ppc_get_tb(tb_env, vmclk, tb_env->tb_offset); |
520 | dbdd2506 | j_mayer | /* Get the alternate time base */
|
521 | dbdd2506 | j_mayer | atb = cpu_ppc_get_tb(tb_env, vmclk, tb_env->atb_offset); |
522 | dbdd2506 | j_mayer | /* Store the time base value (ie compute the current offset) */
|
523 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, vmclk, &tb_env->tb_offset, tb); |
524 | dbdd2506 | j_mayer | /* Store the alternate time base value (compute the current offset) */
|
525 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, vmclk, &tb_env->atb_offset, atb); |
526 | dbdd2506 | j_mayer | /* Set the time base frequency to zero */
|
527 | dbdd2506 | j_mayer | tb_env->tb_freq = 0;
|
528 | dbdd2506 | j_mayer | /* Now, the time bases are frozen to tb_offset / atb_offset value */
|
529 | dbdd2506 | j_mayer | } |
530 | dbdd2506 | j_mayer | } |
531 | dbdd2506 | j_mayer | |
532 | dbdd2506 | j_mayer | static void cpu_ppc_tb_start (CPUState *env) |
533 | dbdd2506 | j_mayer | { |
534 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
535 | dbdd2506 | j_mayer | uint64_t tb, atb, vmclk; |
536 | aae9366a | j_mayer | |
537 | dbdd2506 | j_mayer | /* If the time base is not frozen, do nothing */
|
538 | dbdd2506 | j_mayer | if (tb_env->tb_freq == 0) { |
539 | dbdd2506 | j_mayer | vmclk = qemu_get_clock(vm_clock); |
540 | dbdd2506 | j_mayer | /* Get the time base from tb_offset */
|
541 | dbdd2506 | j_mayer | tb = tb_env->tb_offset; |
542 | dbdd2506 | j_mayer | /* Get the alternate time base from atb_offset */
|
543 | dbdd2506 | j_mayer | atb = tb_env->atb_offset; |
544 | dbdd2506 | j_mayer | /* Restore the tb frequency from the decrementer frequency */
|
545 | dbdd2506 | j_mayer | tb_env->tb_freq = tb_env->decr_freq; |
546 | dbdd2506 | j_mayer | /* Store the time base value */
|
547 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, vmclk, &tb_env->tb_offset, tb); |
548 | dbdd2506 | j_mayer | /* Store the alternate time base value */
|
549 | dbdd2506 | j_mayer | cpu_ppc_store_tb(tb_env, vmclk, &tb_env->atb_offset, atb); |
550 | dbdd2506 | j_mayer | } |
551 | 9fddaa0c | bellard | } |
552 | 9fddaa0c | bellard | |
553 | 636aa200 | Blue Swirl | static inline uint32_t _cpu_ppc_load_decr(CPUState *env, uint64_t next) |
554 | 9fddaa0c | bellard | { |
555 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
556 | 9fddaa0c | bellard | uint32_t decr; |
557 | 4e588a4d | bellard | int64_t diff; |
558 | 9fddaa0c | bellard | |
559 | f55e9d9a | Tristan Gingold | diff = next - qemu_get_clock(vm_clock); |
560 | 4e588a4d | bellard | if (diff >= 0) |
561 | 6ee093c9 | Juan Quintela | decr = muldiv64(diff, tb_env->decr_freq, get_ticks_per_sec()); |
562 | 4e588a4d | bellard | else
|
563 | 6ee093c9 | Juan Quintela | decr = -muldiv64(-diff, tb_env->decr_freq, get_ticks_per_sec()); |
564 | d12d51d5 | aliguori | LOG_TB("%s: %08" PRIx32 "\n", __func__, decr); |
565 | 76a66253 | j_mayer | |
566 | 9fddaa0c | bellard | return decr;
|
567 | 9fddaa0c | bellard | } |
568 | 9fddaa0c | bellard | |
569 | 58a7d328 | j_mayer | uint32_t cpu_ppc_load_decr (CPUState *env) |
570 | 58a7d328 | j_mayer | { |
571 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
572 | 58a7d328 | j_mayer | |
573 | f55e9d9a | Tristan Gingold | return _cpu_ppc_load_decr(env, tb_env->decr_next);
|
574 | 58a7d328 | j_mayer | } |
575 | 58a7d328 | j_mayer | |
576 | 58a7d328 | j_mayer | uint32_t cpu_ppc_load_hdecr (CPUState *env) |
577 | 58a7d328 | j_mayer | { |
578 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
579 | 58a7d328 | j_mayer | |
580 | f55e9d9a | Tristan Gingold | return _cpu_ppc_load_decr(env, tb_env->hdecr_next);
|
581 | 58a7d328 | j_mayer | } |
582 | 58a7d328 | j_mayer | |
583 | 58a7d328 | j_mayer | uint64_t cpu_ppc_load_purr (CPUState *env) |
584 | 58a7d328 | j_mayer | { |
585 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
586 | 58a7d328 | j_mayer | uint64_t diff; |
587 | 58a7d328 | j_mayer | |
588 | 58a7d328 | j_mayer | diff = qemu_get_clock(vm_clock) - tb_env->purr_start; |
589 | b33c17e1 | j_mayer | |
590 | 6ee093c9 | Juan Quintela | return tb_env->purr_load + muldiv64(diff, tb_env->tb_freq, get_ticks_per_sec());
|
591 | 58a7d328 | j_mayer | } |
592 | 58a7d328 | j_mayer | |
593 | 9fddaa0c | bellard | /* When decrementer expires,
|
594 | 9fddaa0c | bellard | * all we need to do is generate or queue a CPU exception
|
595 | 9fddaa0c | bellard | */
|
596 | 636aa200 | Blue Swirl | static inline void cpu_ppc_decr_excp(CPUState *env) |
597 | 9fddaa0c | bellard | { |
598 | 9fddaa0c | bellard | /* Raise it */
|
599 | d12d51d5 | aliguori | LOG_TB("raise decrementer exception\n");
|
600 | 47103572 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_DECR, 1);
|
601 | 9fddaa0c | bellard | } |
602 | 9fddaa0c | bellard | |
603 | 636aa200 | Blue Swirl | static inline void cpu_ppc_hdecr_excp(CPUState *env) |
604 | 58a7d328 | j_mayer | { |
605 | 58a7d328 | j_mayer | /* Raise it */
|
606 | d12d51d5 | aliguori | LOG_TB("raise decrementer exception\n");
|
607 | 58a7d328 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_HDECR, 1);
|
608 | 58a7d328 | j_mayer | } |
609 | 58a7d328 | j_mayer | |
610 | 58a7d328 | j_mayer | static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp, |
611 | b33c17e1 | j_mayer | struct QEMUTimer *timer,
|
612 | b33c17e1 | j_mayer | void (*raise_excp)(CPUState *),
|
613 | b33c17e1 | j_mayer | uint32_t decr, uint32_t value, |
614 | b33c17e1 | j_mayer | int is_excp)
|
615 | 9fddaa0c | bellard | { |
616 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
617 | 9fddaa0c | bellard | uint64_t now, next; |
618 | 9fddaa0c | bellard | |
619 | d12d51d5 | aliguori | LOG_TB("%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__, |
620 | aae9366a | j_mayer | decr, value); |
621 | 9fddaa0c | bellard | now = qemu_get_clock(vm_clock); |
622 | 6ee093c9 | Juan Quintela | next = now + muldiv64(value, get_ticks_per_sec(), tb_env->decr_freq); |
623 | 9fddaa0c | bellard | if (is_excp)
|
624 | 58a7d328 | j_mayer | next += *nextp - now; |
625 | 9fddaa0c | bellard | if (next == now)
|
626 | 76a66253 | j_mayer | next++; |
627 | 58a7d328 | j_mayer | *nextp = next; |
628 | 9fddaa0c | bellard | /* Adjust timer */
|
629 | 58a7d328 | j_mayer | qemu_mod_timer(timer, next); |
630 | 9fddaa0c | bellard | /* If we set a negative value and the decrementer was positive,
|
631 | 9fddaa0c | bellard | * raise an exception.
|
632 | 9fddaa0c | bellard | */
|
633 | 9fddaa0c | bellard | if ((value & 0x80000000) && !(decr & 0x80000000)) |
634 | 58a7d328 | j_mayer | (*raise_excp)(env); |
635 | 58a7d328 | j_mayer | } |
636 | 58a7d328 | j_mayer | |
637 | 636aa200 | Blue Swirl | static inline void _cpu_ppc_store_decr(CPUState *env, uint32_t decr, |
638 | 636aa200 | Blue Swirl | uint32_t value, int is_excp)
|
639 | 58a7d328 | j_mayer | { |
640 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
641 | 58a7d328 | j_mayer | |
642 | 58a7d328 | j_mayer | __cpu_ppc_store_decr(env, &tb_env->decr_next, tb_env->decr_timer, |
643 | 58a7d328 | j_mayer | &cpu_ppc_decr_excp, decr, value, is_excp); |
644 | 9fddaa0c | bellard | } |
645 | 9fddaa0c | bellard | |
646 | 9fddaa0c | bellard | void cpu_ppc_store_decr (CPUState *env, uint32_t value)
|
647 | 9fddaa0c | bellard | { |
648 | 9fddaa0c | bellard | _cpu_ppc_store_decr(env, cpu_ppc_load_decr(env), value, 0);
|
649 | 9fddaa0c | bellard | } |
650 | 9fddaa0c | bellard | |
651 | 9fddaa0c | bellard | static void cpu_ppc_decr_cb (void *opaque) |
652 | 9fddaa0c | bellard | { |
653 | 9fddaa0c | bellard | _cpu_ppc_store_decr(opaque, 0x00000000, 0xFFFFFFFF, 1); |
654 | 9fddaa0c | bellard | } |
655 | 9fddaa0c | bellard | |
656 | 636aa200 | Blue Swirl | static inline void _cpu_ppc_store_hdecr(CPUState *env, uint32_t hdecr, |
657 | 636aa200 | Blue Swirl | uint32_t value, int is_excp)
|
658 | 58a7d328 | j_mayer | { |
659 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
660 | 58a7d328 | j_mayer | |
661 | b172c56a | j_mayer | if (tb_env->hdecr_timer != NULL) { |
662 | b172c56a | j_mayer | __cpu_ppc_store_decr(env, &tb_env->hdecr_next, tb_env->hdecr_timer, |
663 | b172c56a | j_mayer | &cpu_ppc_hdecr_excp, hdecr, value, is_excp); |
664 | b172c56a | j_mayer | } |
665 | 58a7d328 | j_mayer | } |
666 | 58a7d328 | j_mayer | |
667 | 58a7d328 | j_mayer | void cpu_ppc_store_hdecr (CPUState *env, uint32_t value)
|
668 | 58a7d328 | j_mayer | { |
669 | 58a7d328 | j_mayer | _cpu_ppc_store_hdecr(env, cpu_ppc_load_hdecr(env), value, 0);
|
670 | 58a7d328 | j_mayer | } |
671 | 58a7d328 | j_mayer | |
672 | 58a7d328 | j_mayer | static void cpu_ppc_hdecr_cb (void *opaque) |
673 | 58a7d328 | j_mayer | { |
674 | 58a7d328 | j_mayer | _cpu_ppc_store_hdecr(opaque, 0x00000000, 0xFFFFFFFF, 1); |
675 | 58a7d328 | j_mayer | } |
676 | 58a7d328 | j_mayer | |
677 | 58a7d328 | j_mayer | void cpu_ppc_store_purr (CPUState *env, uint64_t value)
|
678 | 58a7d328 | j_mayer | { |
679 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
680 | 58a7d328 | j_mayer | |
681 | 58a7d328 | j_mayer | tb_env->purr_load = value; |
682 | 58a7d328 | j_mayer | tb_env->purr_start = qemu_get_clock(vm_clock); |
683 | 58a7d328 | j_mayer | } |
684 | 58a7d328 | j_mayer | |
685 | 8ecc7913 | j_mayer | static void cpu_ppc_set_tb_clk (void *opaque, uint32_t freq) |
686 | 8ecc7913 | j_mayer | { |
687 | 8ecc7913 | j_mayer | CPUState *env = opaque; |
688 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
689 | 8ecc7913 | j_mayer | |
690 | 8ecc7913 | j_mayer | tb_env->tb_freq = freq; |
691 | dbdd2506 | j_mayer | tb_env->decr_freq = freq; |
692 | 8ecc7913 | j_mayer | /* There is a bug in Linux 2.4 kernels:
|
693 | 8ecc7913 | j_mayer | * if a decrementer exception is pending when it enables msr_ee at startup,
|
694 | 8ecc7913 | j_mayer | * it's not ready to handle it...
|
695 | 8ecc7913 | j_mayer | */
|
696 | 8ecc7913 | j_mayer | _cpu_ppc_store_decr(env, 0xFFFFFFFF, 0xFFFFFFFF, 0); |
697 | 58a7d328 | j_mayer | _cpu_ppc_store_hdecr(env, 0xFFFFFFFF, 0xFFFFFFFF, 0); |
698 | 58a7d328 | j_mayer | cpu_ppc_store_purr(env, 0x0000000000000000ULL);
|
699 | 8ecc7913 | j_mayer | } |
700 | 8ecc7913 | j_mayer | |
701 | 9fddaa0c | bellard | /* Set up (once) timebase frequency (in Hz) */
|
702 | 8ecc7913 | j_mayer | clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq) |
703 | 9fddaa0c | bellard | { |
704 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
705 | 9fddaa0c | bellard | |
706 | c227f099 | Anthony Liguori | tb_env = qemu_mallocz(sizeof(ppc_tb_t));
|
707 | 9fddaa0c | bellard | env->tb_env = tb_env; |
708 | 8ecc7913 | j_mayer | /* Create new timer */
|
709 | 8ecc7913 | j_mayer | tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_ppc_decr_cb, env); |
710 | b172c56a | j_mayer | if (0) { |
711 | b172c56a | j_mayer | /* XXX: find a suitable condition to enable the hypervisor decrementer
|
712 | b172c56a | j_mayer | */
|
713 | b172c56a | j_mayer | tb_env->hdecr_timer = qemu_new_timer(vm_clock, &cpu_ppc_hdecr_cb, env); |
714 | b172c56a | j_mayer | } else {
|
715 | b172c56a | j_mayer | tb_env->hdecr_timer = NULL;
|
716 | b172c56a | j_mayer | } |
717 | 8ecc7913 | j_mayer | cpu_ppc_set_tb_clk(env, freq); |
718 | 9fddaa0c | bellard | |
719 | 8ecc7913 | j_mayer | return &cpu_ppc_set_tb_clk;
|
720 | 9fddaa0c | bellard | } |
721 | 9fddaa0c | bellard | |
722 | 76a66253 | j_mayer | /* Specific helpers for POWER & PowerPC 601 RTC */
|
723 | b1d8e52e | blueswir1 | #if 0
|
724 | b1d8e52e | blueswir1 | static clk_setup_cb cpu_ppc601_rtc_init (CPUState *env)
|
725 | 76a66253 | j_mayer | {
|
726 | 76a66253 | j_mayer | return cpu_ppc_tb_init(env, 7812500);
|
727 | 76a66253 | j_mayer | }
|
728 | b1d8e52e | blueswir1 | #endif
|
729 | 76a66253 | j_mayer | |
730 | 76a66253 | j_mayer | void cpu_ppc601_store_rtcu (CPUState *env, uint32_t value)
|
731 | 8a84de23 | j_mayer | { |
732 | 8a84de23 | j_mayer | _cpu_ppc_store_tbu(env, value); |
733 | 8a84de23 | j_mayer | } |
734 | 76a66253 | j_mayer | |
735 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcu (CPUState *env) |
736 | 8a84de23 | j_mayer | { |
737 | 8a84de23 | j_mayer | return _cpu_ppc_load_tbu(env);
|
738 | 8a84de23 | j_mayer | } |
739 | 76a66253 | j_mayer | |
740 | 76a66253 | j_mayer | void cpu_ppc601_store_rtcl (CPUState *env, uint32_t value)
|
741 | 76a66253 | j_mayer | { |
742 | 76a66253 | j_mayer | cpu_ppc_store_tbl(env, value & 0x3FFFFF80);
|
743 | 76a66253 | j_mayer | } |
744 | 76a66253 | j_mayer | |
745 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcl (CPUState *env) |
746 | 76a66253 | j_mayer | { |
747 | 76a66253 | j_mayer | return cpu_ppc_load_tbl(env) & 0x3FFFFF80; |
748 | 76a66253 | j_mayer | } |
749 | 76a66253 | j_mayer | |
750 | 636aaad7 | j_mayer | /*****************************************************************************/
|
751 | 76a66253 | j_mayer | /* Embedded PowerPC timers */
|
752 | 636aaad7 | j_mayer | |
753 | 636aaad7 | j_mayer | /* PIT, FIT & WDT */
|
754 | c227f099 | Anthony Liguori | typedef struct ppcemb_timer_t ppcemb_timer_t; |
755 | c227f099 | Anthony Liguori | struct ppcemb_timer_t {
|
756 | 636aaad7 | j_mayer | uint64_t pit_reload; /* PIT auto-reload value */
|
757 | 636aaad7 | j_mayer | uint64_t fit_next; /* Tick for next FIT interrupt */
|
758 | 636aaad7 | j_mayer | struct QEMUTimer *fit_timer;
|
759 | 636aaad7 | j_mayer | uint64_t wdt_next; /* Tick for next WDT interrupt */
|
760 | 636aaad7 | j_mayer | struct QEMUTimer *wdt_timer;
|
761 | 636aaad7 | j_mayer | }; |
762 | 3b46e624 | ths | |
763 | 636aaad7 | j_mayer | /* Fixed interval timer */
|
764 | 636aaad7 | j_mayer | static void cpu_4xx_fit_cb (void *opaque) |
765 | 636aaad7 | j_mayer | { |
766 | 636aaad7 | j_mayer | CPUState *env; |
767 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
768 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
769 | 636aaad7 | j_mayer | uint64_t now, next; |
770 | 636aaad7 | j_mayer | |
771 | 636aaad7 | j_mayer | env = opaque; |
772 | 636aaad7 | j_mayer | tb_env = env->tb_env; |
773 | 636aaad7 | j_mayer | ppcemb_timer = tb_env->opaque; |
774 | 636aaad7 | j_mayer | now = qemu_get_clock(vm_clock); |
775 | 636aaad7 | j_mayer | switch ((env->spr[SPR_40x_TCR] >> 24) & 0x3) { |
776 | 636aaad7 | j_mayer | case 0: |
777 | 636aaad7 | j_mayer | next = 1 << 9; |
778 | 636aaad7 | j_mayer | break;
|
779 | 636aaad7 | j_mayer | case 1: |
780 | 636aaad7 | j_mayer | next = 1 << 13; |
781 | 636aaad7 | j_mayer | break;
|
782 | 636aaad7 | j_mayer | case 2: |
783 | 636aaad7 | j_mayer | next = 1 << 17; |
784 | 636aaad7 | j_mayer | break;
|
785 | 636aaad7 | j_mayer | case 3: |
786 | 636aaad7 | j_mayer | next = 1 << 21; |
787 | 636aaad7 | j_mayer | break;
|
788 | 636aaad7 | j_mayer | default:
|
789 | 636aaad7 | j_mayer | /* Cannot occur, but makes gcc happy */
|
790 | 636aaad7 | j_mayer | return;
|
791 | 636aaad7 | j_mayer | } |
792 | 6ee093c9 | Juan Quintela | next = now + muldiv64(next, get_ticks_per_sec(), tb_env->tb_freq); |
793 | 636aaad7 | j_mayer | if (next == now)
|
794 | 636aaad7 | j_mayer | next++; |
795 | 636aaad7 | j_mayer | qemu_mod_timer(ppcemb_timer->fit_timer, next); |
796 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] |= 1 << 26; |
797 | 636aaad7 | j_mayer | if ((env->spr[SPR_40x_TCR] >> 23) & 0x1) |
798 | 636aaad7 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_FIT, 1);
|
799 | 90e189ec | Blue Swirl | LOG_TB("%s: ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx "\n", __func__, |
800 | 90e189ec | Blue Swirl | (int)((env->spr[SPR_40x_TCR] >> 23) & 0x1), |
801 | 90e189ec | Blue Swirl | env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); |
802 | 636aaad7 | j_mayer | } |
803 | 636aaad7 | j_mayer | |
804 | 636aaad7 | j_mayer | /* Programmable interval timer */
|
805 | c227f099 | Anthony Liguori | static void start_stop_pit (CPUState *env, ppc_tb_t *tb_env, int is_excp) |
806 | 76a66253 | j_mayer | { |
807 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
808 | 636aaad7 | j_mayer | uint64_t now, next; |
809 | 636aaad7 | j_mayer | |
810 | 636aaad7 | j_mayer | ppcemb_timer = tb_env->opaque; |
811 | 4b6d0a4c | j_mayer | if (ppcemb_timer->pit_reload <= 1 || |
812 | 4b6d0a4c | j_mayer | !((env->spr[SPR_40x_TCR] >> 26) & 0x1) || |
813 | 4b6d0a4c | j_mayer | (is_excp && !((env->spr[SPR_40x_TCR] >> 22) & 0x1))) { |
814 | 4b6d0a4c | j_mayer | /* Stop PIT */
|
815 | d12d51d5 | aliguori | LOG_TB("%s: stop PIT\n", __func__);
|
816 | 4b6d0a4c | j_mayer | qemu_del_timer(tb_env->decr_timer); |
817 | 4b6d0a4c | j_mayer | } else {
|
818 | d12d51d5 | aliguori | LOG_TB("%s: start PIT %016" PRIx64 "\n", |
819 | 4b6d0a4c | j_mayer | __func__, ppcemb_timer->pit_reload); |
820 | 4b6d0a4c | j_mayer | now = qemu_get_clock(vm_clock); |
821 | 636aaad7 | j_mayer | next = now + muldiv64(ppcemb_timer->pit_reload, |
822 | 6ee093c9 | Juan Quintela | get_ticks_per_sec(), tb_env->decr_freq); |
823 | 4b6d0a4c | j_mayer | if (is_excp)
|
824 | 4b6d0a4c | j_mayer | next += tb_env->decr_next - now; |
825 | 636aaad7 | j_mayer | if (next == now)
|
826 | 636aaad7 | j_mayer | next++; |
827 | 636aaad7 | j_mayer | qemu_mod_timer(tb_env->decr_timer, next); |
828 | 636aaad7 | j_mayer | tb_env->decr_next = next; |
829 | 636aaad7 | j_mayer | } |
830 | 4b6d0a4c | j_mayer | } |
831 | 4b6d0a4c | j_mayer | |
832 | 4b6d0a4c | j_mayer | static void cpu_4xx_pit_cb (void *opaque) |
833 | 4b6d0a4c | j_mayer | { |
834 | 4b6d0a4c | j_mayer | CPUState *env; |
835 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
836 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
837 | 4b6d0a4c | j_mayer | |
838 | 4b6d0a4c | j_mayer | env = opaque; |
839 | 4b6d0a4c | j_mayer | tb_env = env->tb_env; |
840 | 4b6d0a4c | j_mayer | ppcemb_timer = tb_env->opaque; |
841 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] |= 1 << 27; |
842 | 636aaad7 | j_mayer | if ((env->spr[SPR_40x_TCR] >> 26) & 0x1) |
843 | 636aaad7 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
|
844 | 4b6d0a4c | j_mayer | start_stop_pit(env, tb_env, 1);
|
845 | 90e189ec | Blue Swirl | LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " " |
846 | 90e189ec | Blue Swirl | "%016" PRIx64 "\n", __func__, |
847 | 90e189ec | Blue Swirl | (int)((env->spr[SPR_40x_TCR] >> 22) & 0x1), |
848 | 90e189ec | Blue Swirl | (int)((env->spr[SPR_40x_TCR] >> 26) & 0x1), |
849 | 90e189ec | Blue Swirl | env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], |
850 | 90e189ec | Blue Swirl | ppcemb_timer->pit_reload); |
851 | 636aaad7 | j_mayer | } |
852 | 636aaad7 | j_mayer | |
853 | 636aaad7 | j_mayer | /* Watchdog timer */
|
854 | 636aaad7 | j_mayer | static void cpu_4xx_wdt_cb (void *opaque) |
855 | 636aaad7 | j_mayer | { |
856 | 636aaad7 | j_mayer | CPUState *env; |
857 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
858 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
859 | 636aaad7 | j_mayer | uint64_t now, next; |
860 | 636aaad7 | j_mayer | |
861 | 636aaad7 | j_mayer | env = opaque; |
862 | 636aaad7 | j_mayer | tb_env = env->tb_env; |
863 | 636aaad7 | j_mayer | ppcemb_timer = tb_env->opaque; |
864 | 636aaad7 | j_mayer | now = qemu_get_clock(vm_clock); |
865 | 636aaad7 | j_mayer | switch ((env->spr[SPR_40x_TCR] >> 30) & 0x3) { |
866 | 636aaad7 | j_mayer | case 0: |
867 | 636aaad7 | j_mayer | next = 1 << 17; |
868 | 636aaad7 | j_mayer | break;
|
869 | 636aaad7 | j_mayer | case 1: |
870 | 636aaad7 | j_mayer | next = 1 << 21; |
871 | 636aaad7 | j_mayer | break;
|
872 | 636aaad7 | j_mayer | case 2: |
873 | 636aaad7 | j_mayer | next = 1 << 25; |
874 | 636aaad7 | j_mayer | break;
|
875 | 636aaad7 | j_mayer | case 3: |
876 | 636aaad7 | j_mayer | next = 1 << 29; |
877 | 636aaad7 | j_mayer | break;
|
878 | 636aaad7 | j_mayer | default:
|
879 | 636aaad7 | j_mayer | /* Cannot occur, but makes gcc happy */
|
880 | 636aaad7 | j_mayer | return;
|
881 | 636aaad7 | j_mayer | } |
882 | 6ee093c9 | Juan Quintela | next = now + muldiv64(next, get_ticks_per_sec(), tb_env->decr_freq); |
883 | 636aaad7 | j_mayer | if (next == now)
|
884 | 636aaad7 | j_mayer | next++; |
885 | 90e189ec | Blue Swirl | LOG_TB("%s: TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx "\n", __func__, |
886 | 90e189ec | Blue Swirl | env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); |
887 | 636aaad7 | j_mayer | switch ((env->spr[SPR_40x_TSR] >> 30) & 0x3) { |
888 | 636aaad7 | j_mayer | case 0x0: |
889 | 636aaad7 | j_mayer | case 0x1: |
890 | 636aaad7 | j_mayer | qemu_mod_timer(ppcemb_timer->wdt_timer, next); |
891 | 636aaad7 | j_mayer | ppcemb_timer->wdt_next = next; |
892 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] |= 1 << 31; |
893 | 636aaad7 | j_mayer | break;
|
894 | 636aaad7 | j_mayer | case 0x2: |
895 | 636aaad7 | j_mayer | qemu_mod_timer(ppcemb_timer->wdt_timer, next); |
896 | 636aaad7 | j_mayer | ppcemb_timer->wdt_next = next; |
897 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] |= 1 << 30; |
898 | 636aaad7 | j_mayer | if ((env->spr[SPR_40x_TCR] >> 27) & 0x1) |
899 | 636aaad7 | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_WDT, 1);
|
900 | 636aaad7 | j_mayer | break;
|
901 | 636aaad7 | j_mayer | case 0x3: |
902 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] &= ~0x30000000;
|
903 | 636aaad7 | j_mayer | env->spr[SPR_40x_TSR] |= env->spr[SPR_40x_TCR] & 0x30000000;
|
904 | 636aaad7 | j_mayer | switch ((env->spr[SPR_40x_TCR] >> 28) & 0x3) { |
905 | 636aaad7 | j_mayer | case 0x0: |
906 | 636aaad7 | j_mayer | /* No reset */
|
907 | 636aaad7 | j_mayer | break;
|
908 | 636aaad7 | j_mayer | case 0x1: /* Core reset */ |
909 | 8ecc7913 | j_mayer | ppc40x_core_reset(env); |
910 | 8ecc7913 | j_mayer | break;
|
911 | 636aaad7 | j_mayer | case 0x2: /* Chip reset */ |
912 | 8ecc7913 | j_mayer | ppc40x_chip_reset(env); |
913 | 8ecc7913 | j_mayer | break;
|
914 | 636aaad7 | j_mayer | case 0x3: /* System reset */ |
915 | 8ecc7913 | j_mayer | ppc40x_system_reset(env); |
916 | 8ecc7913 | j_mayer | break;
|
917 | 636aaad7 | j_mayer | } |
918 | 636aaad7 | j_mayer | } |
919 | 76a66253 | j_mayer | } |
920 | 76a66253 | j_mayer | |
921 | 76a66253 | j_mayer | void store_40x_pit (CPUState *env, target_ulong val)
|
922 | 76a66253 | j_mayer | { |
923 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
924 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
925 | 636aaad7 | j_mayer | |
926 | 636aaad7 | j_mayer | tb_env = env->tb_env; |
927 | 636aaad7 | j_mayer | ppcemb_timer = tb_env->opaque; |
928 | 90e189ec | Blue Swirl | LOG_TB("%s val" TARGET_FMT_lx "\n", __func__, val); |
929 | 636aaad7 | j_mayer | ppcemb_timer->pit_reload = val; |
930 | 4b6d0a4c | j_mayer | start_stop_pit(env, tb_env, 0);
|
931 | 76a66253 | j_mayer | } |
932 | 76a66253 | j_mayer | |
933 | 636aaad7 | j_mayer | target_ulong load_40x_pit (CPUState *env) |
934 | 76a66253 | j_mayer | { |
935 | 636aaad7 | j_mayer | return cpu_ppc_load_decr(env);
|
936 | 76a66253 | j_mayer | } |
937 | 76a66253 | j_mayer | |
938 | 76a66253 | j_mayer | void store_booke_tsr (CPUState *env, target_ulong val)
|
939 | 76a66253 | j_mayer | { |
940 | 90e189ec | Blue Swirl | LOG_TB("%s: val " TARGET_FMT_lx "\n", __func__, val); |
941 | 4b6d0a4c | j_mayer | env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000);
|
942 | 4b6d0a4c | j_mayer | if (val & 0x80000000) |
943 | 4b6d0a4c | j_mayer | ppc_set_irq(env, PPC_INTERRUPT_PIT, 0);
|
944 | 636aaad7 | j_mayer | } |
945 | 636aaad7 | j_mayer | |
946 | 636aaad7 | j_mayer | void store_booke_tcr (CPUState *env, target_ulong val)
|
947 | 636aaad7 | j_mayer | { |
948 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
949 | 4b6d0a4c | j_mayer | |
950 | 4b6d0a4c | j_mayer | tb_env = env->tb_env; |
951 | 90e189ec | Blue Swirl | LOG_TB("%s: val " TARGET_FMT_lx "\n", __func__, val); |
952 | 4b6d0a4c | j_mayer | env->spr[SPR_40x_TCR] = val & 0xFFC00000;
|
953 | 4b6d0a4c | j_mayer | start_stop_pit(env, tb_env, 1);
|
954 | 8ecc7913 | j_mayer | cpu_4xx_wdt_cb(env); |
955 | 636aaad7 | j_mayer | } |
956 | 636aaad7 | j_mayer | |
957 | 4b6d0a4c | j_mayer | static void ppc_emb_set_tb_clk (void *opaque, uint32_t freq) |
958 | 4b6d0a4c | j_mayer | { |
959 | 4b6d0a4c | j_mayer | CPUState *env = opaque; |
960 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env = env->tb_env; |
961 | 4b6d0a4c | j_mayer | |
962 | d12d51d5 | aliguori | LOG_TB("%s set new frequency to %" PRIu32 "\n", __func__, |
963 | aae9366a | j_mayer | freq); |
964 | 4b6d0a4c | j_mayer | tb_env->tb_freq = freq; |
965 | dbdd2506 | j_mayer | tb_env->decr_freq = freq; |
966 | 4b6d0a4c | j_mayer | /* XXX: we should also update all timers */
|
967 | 4b6d0a4c | j_mayer | } |
968 | 4b6d0a4c | j_mayer | |
969 | 8ecc7913 | j_mayer | clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq) |
970 | 636aaad7 | j_mayer | { |
971 | c227f099 | Anthony Liguori | ppc_tb_t *tb_env; |
972 | c227f099 | Anthony Liguori | ppcemb_timer_t *ppcemb_timer; |
973 | 636aaad7 | j_mayer | |
974 | c227f099 | Anthony Liguori | tb_env = qemu_mallocz(sizeof(ppc_tb_t));
|
975 | 8ecc7913 | j_mayer | env->tb_env = tb_env; |
976 | c227f099 | Anthony Liguori | ppcemb_timer = qemu_mallocz(sizeof(ppcemb_timer_t));
|
977 | 8ecc7913 | j_mayer | tb_env->tb_freq = freq; |
978 | dbdd2506 | j_mayer | tb_env->decr_freq = freq; |
979 | 636aaad7 | j_mayer | tb_env->opaque = ppcemb_timer; |
980 | d12d51d5 | aliguori | LOG_TB("%s freq %" PRIu32 "\n", __func__, freq); |
981 | 636aaad7 | j_mayer | if (ppcemb_timer != NULL) { |
982 | 636aaad7 | j_mayer | /* We use decr timer for PIT */
|
983 | 636aaad7 | j_mayer | tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_4xx_pit_cb, env); |
984 | 636aaad7 | j_mayer | ppcemb_timer->fit_timer = |
985 | 636aaad7 | j_mayer | qemu_new_timer(vm_clock, &cpu_4xx_fit_cb, env); |
986 | 636aaad7 | j_mayer | ppcemb_timer->wdt_timer = |
987 | 636aaad7 | j_mayer | qemu_new_timer(vm_clock, &cpu_4xx_wdt_cb, env); |
988 | 636aaad7 | j_mayer | } |
989 | 8ecc7913 | j_mayer | |
990 | 4b6d0a4c | j_mayer | return &ppc_emb_set_tb_clk;
|
991 | 76a66253 | j_mayer | } |
992 | 76a66253 | j_mayer | |
993 | 2e719ba3 | j_mayer | /*****************************************************************************/
|
994 | 2e719ba3 | j_mayer | /* Embedded PowerPC Device Control Registers */
|
995 | c227f099 | Anthony Liguori | typedef struct ppc_dcrn_t ppc_dcrn_t; |
996 | c227f099 | Anthony Liguori | struct ppc_dcrn_t {
|
997 | 2e719ba3 | j_mayer | dcr_read_cb dcr_read; |
998 | 2e719ba3 | j_mayer | dcr_write_cb dcr_write; |
999 | 2e719ba3 | j_mayer | void *opaque;
|
1000 | 2e719ba3 | j_mayer | }; |
1001 | 2e719ba3 | j_mayer | |
1002 | a750fc0b | j_mayer | /* XXX: on 460, DCR addresses are 32 bits wide,
|
1003 | a750fc0b | j_mayer | * using DCRIPR to get the 22 upper bits of the DCR address
|
1004 | a750fc0b | j_mayer | */
|
1005 | 2e719ba3 | j_mayer | #define DCRN_NB 1024 |
1006 | c227f099 | Anthony Liguori | struct ppc_dcr_t {
|
1007 | c227f099 | Anthony Liguori | ppc_dcrn_t dcrn[DCRN_NB]; |
1008 | 2e719ba3 | j_mayer | int (*read_error)(int dcrn); |
1009 | 2e719ba3 | j_mayer | int (*write_error)(int dcrn); |
1010 | 2e719ba3 | j_mayer | }; |
1011 | 2e719ba3 | j_mayer | |
1012 | c227f099 | Anthony Liguori | int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, target_ulong *valp) |
1013 | 2e719ba3 | j_mayer | { |
1014 | c227f099 | Anthony Liguori | ppc_dcrn_t *dcr; |
1015 | 2e719ba3 | j_mayer | |
1016 | 2e719ba3 | j_mayer | if (dcrn < 0 || dcrn >= DCRN_NB) |
1017 | 2e719ba3 | j_mayer | goto error;
|
1018 | 2e719ba3 | j_mayer | dcr = &dcr_env->dcrn[dcrn]; |
1019 | 2e719ba3 | j_mayer | if (dcr->dcr_read == NULL) |
1020 | 2e719ba3 | j_mayer | goto error;
|
1021 | 2e719ba3 | j_mayer | *valp = (*dcr->dcr_read)(dcr->opaque, dcrn); |
1022 | 2e719ba3 | j_mayer | |
1023 | 2e719ba3 | j_mayer | return 0; |
1024 | 2e719ba3 | j_mayer | |
1025 | 2e719ba3 | j_mayer | error:
|
1026 | 2e719ba3 | j_mayer | if (dcr_env->read_error != NULL) |
1027 | 2e719ba3 | j_mayer | return (*dcr_env->read_error)(dcrn);
|
1028 | 2e719ba3 | j_mayer | |
1029 | 2e719ba3 | j_mayer | return -1; |
1030 | 2e719ba3 | j_mayer | } |
1031 | 2e719ba3 | j_mayer | |
1032 | c227f099 | Anthony Liguori | int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) |
1033 | 2e719ba3 | j_mayer | { |
1034 | c227f099 | Anthony Liguori | ppc_dcrn_t *dcr; |
1035 | 2e719ba3 | j_mayer | |
1036 | 2e719ba3 | j_mayer | if (dcrn < 0 || dcrn >= DCRN_NB) |
1037 | 2e719ba3 | j_mayer | goto error;
|
1038 | 2e719ba3 | j_mayer | dcr = &dcr_env->dcrn[dcrn]; |
1039 | 2e719ba3 | j_mayer | if (dcr->dcr_write == NULL) |
1040 | 2e719ba3 | j_mayer | goto error;
|
1041 | 2e719ba3 | j_mayer | (*dcr->dcr_write)(dcr->opaque, dcrn, val); |
1042 | 2e719ba3 | j_mayer | |
1043 | 2e719ba3 | j_mayer | return 0; |
1044 | 2e719ba3 | j_mayer | |
1045 | 2e719ba3 | j_mayer | error:
|
1046 | 2e719ba3 | j_mayer | if (dcr_env->write_error != NULL) |
1047 | 2e719ba3 | j_mayer | return (*dcr_env->write_error)(dcrn);
|
1048 | 2e719ba3 | j_mayer | |
1049 | 2e719ba3 | j_mayer | return -1; |
1050 | 2e719ba3 | j_mayer | } |
1051 | 2e719ba3 | j_mayer | |
1052 | 2e719ba3 | j_mayer | int ppc_dcr_register (CPUState *env, int dcrn, void *opaque, |
1053 | 2e719ba3 | j_mayer | dcr_read_cb dcr_read, dcr_write_cb dcr_write) |
1054 | 2e719ba3 | j_mayer | { |
1055 | c227f099 | Anthony Liguori | ppc_dcr_t *dcr_env; |
1056 | c227f099 | Anthony Liguori | ppc_dcrn_t *dcr; |
1057 | 2e719ba3 | j_mayer | |
1058 | 2e719ba3 | j_mayer | dcr_env = env->dcr_env; |
1059 | 2e719ba3 | j_mayer | if (dcr_env == NULL) |
1060 | 2e719ba3 | j_mayer | return -1; |
1061 | 2e719ba3 | j_mayer | if (dcrn < 0 || dcrn >= DCRN_NB) |
1062 | 2e719ba3 | j_mayer | return -1; |
1063 | 2e719ba3 | j_mayer | dcr = &dcr_env->dcrn[dcrn]; |
1064 | 2e719ba3 | j_mayer | if (dcr->opaque != NULL || |
1065 | 2e719ba3 | j_mayer | dcr->dcr_read != NULL ||
|
1066 | 2e719ba3 | j_mayer | dcr->dcr_write != NULL)
|
1067 | 2e719ba3 | j_mayer | return -1; |
1068 | 2e719ba3 | j_mayer | dcr->opaque = opaque; |
1069 | 2e719ba3 | j_mayer | dcr->dcr_read = dcr_read; |
1070 | 2e719ba3 | j_mayer | dcr->dcr_write = dcr_write; |
1071 | 2e719ba3 | j_mayer | |
1072 | 2e719ba3 | j_mayer | return 0; |
1073 | 2e719ba3 | j_mayer | } |
1074 | 2e719ba3 | j_mayer | |
1075 | 2e719ba3 | j_mayer | int ppc_dcr_init (CPUState *env, int (*read_error)(int dcrn), |
1076 | 2e719ba3 | j_mayer | int (*write_error)(int dcrn)) |
1077 | 2e719ba3 | j_mayer | { |
1078 | c227f099 | Anthony Liguori | ppc_dcr_t *dcr_env; |
1079 | 2e719ba3 | j_mayer | |
1080 | c227f099 | Anthony Liguori | dcr_env = qemu_mallocz(sizeof(ppc_dcr_t));
|
1081 | 2e719ba3 | j_mayer | dcr_env->read_error = read_error; |
1082 | 2e719ba3 | j_mayer | dcr_env->write_error = write_error; |
1083 | 2e719ba3 | j_mayer | env->dcr_env = dcr_env; |
1084 | 2e719ba3 | j_mayer | |
1085 | 2e719ba3 | j_mayer | return 0; |
1086 | 2e719ba3 | j_mayer | } |
1087 | 2e719ba3 | j_mayer | |
1088 | 9fddaa0c | bellard | #if 0
|
1089 | 9fddaa0c | bellard | /*****************************************************************************/
|
1090 | 9fddaa0c | bellard | /* Handle system reset (for now, just stop emulation) */
|
1091 | d84bda46 | Blue Swirl | void cpu_reset(CPUState *env)
|
1092 | 9fddaa0c | bellard | {
|
1093 | 9fddaa0c | bellard | printf("Reset asked... Stop emulation\n");
|
1094 | 9fddaa0c | bellard | abort();
|
1095 | 9fddaa0c | bellard | }
|
1096 | 9fddaa0c | bellard | #endif
|
1097 | 9fddaa0c | bellard | |
1098 | 64201201 | bellard | /*****************************************************************************/
|
1099 | 64201201 | bellard | /* Debug port */
|
1100 | fd0bbb12 | bellard | void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val) |
1101 | 64201201 | bellard | { |
1102 | 64201201 | bellard | addr &= 0xF;
|
1103 | 64201201 | bellard | switch (addr) {
|
1104 | 64201201 | bellard | case 0: |
1105 | 64201201 | bellard | printf("%c", val);
|
1106 | 64201201 | bellard | break;
|
1107 | 64201201 | bellard | case 1: |
1108 | 64201201 | bellard | printf("\n");
|
1109 | 64201201 | bellard | fflush(stdout); |
1110 | 64201201 | bellard | break;
|
1111 | 64201201 | bellard | case 2: |
1112 | aae9366a | j_mayer | printf("Set loglevel to %04" PRIx32 "\n", val); |
1113 | fd0bbb12 | bellard | cpu_set_log(val | 0x100);
|
1114 | 64201201 | bellard | break;
|
1115 | 64201201 | bellard | } |
1116 | 64201201 | bellard | } |
1117 | 64201201 | bellard | |
1118 | 64201201 | bellard | /*****************************************************************************/
|
1119 | 64201201 | bellard | /* NVRAM helpers */
|
1120 | c227f099 | Anthony Liguori | static inline uint32_t nvram_read (nvram_t *nvram, uint32_t addr) |
1121 | 64201201 | bellard | { |
1122 | 3cbee15b | j_mayer | return (*nvram->read_fn)(nvram->opaque, addr);;
|
1123 | 64201201 | bellard | } |
1124 | 64201201 | bellard | |
1125 | c227f099 | Anthony Liguori | static inline void nvram_write (nvram_t *nvram, uint32_t addr, uint32_t val) |
1126 | 64201201 | bellard | { |
1127 | 3cbee15b | j_mayer | (*nvram->write_fn)(nvram->opaque, addr, val); |
1128 | 64201201 | bellard | } |
1129 | 64201201 | bellard | |
1130 | c227f099 | Anthony Liguori | void NVRAM_set_byte (nvram_t *nvram, uint32_t addr, uint8_t value)
|
1131 | 64201201 | bellard | { |
1132 | 3cbee15b | j_mayer | nvram_write(nvram, addr, value); |
1133 | 64201201 | bellard | } |
1134 | 64201201 | bellard | |
1135 | c227f099 | Anthony Liguori | uint8_t NVRAM_get_byte (nvram_t *nvram, uint32_t addr) |
1136 | 3cbee15b | j_mayer | { |
1137 | 3cbee15b | j_mayer | return nvram_read(nvram, addr);
|
1138 | 3cbee15b | j_mayer | } |
1139 | 3cbee15b | j_mayer | |
1140 | c227f099 | Anthony Liguori | void NVRAM_set_word (nvram_t *nvram, uint32_t addr, uint16_t value)
|
1141 | 3cbee15b | j_mayer | { |
1142 | 3cbee15b | j_mayer | nvram_write(nvram, addr, value >> 8);
|
1143 | 3cbee15b | j_mayer | nvram_write(nvram, addr + 1, value & 0xFF); |
1144 | 3cbee15b | j_mayer | } |
1145 | 3cbee15b | j_mayer | |
1146 | c227f099 | Anthony Liguori | uint16_t NVRAM_get_word (nvram_t *nvram, uint32_t addr) |
1147 | 64201201 | bellard | { |
1148 | 64201201 | bellard | uint16_t tmp; |
1149 | 64201201 | bellard | |
1150 | 3cbee15b | j_mayer | tmp = nvram_read(nvram, addr) << 8;
|
1151 | 3cbee15b | j_mayer | tmp |= nvram_read(nvram, addr + 1);
|
1152 | 3cbee15b | j_mayer | |
1153 | 64201201 | bellard | return tmp;
|
1154 | 64201201 | bellard | } |
1155 | 64201201 | bellard | |
1156 | c227f099 | Anthony Liguori | void NVRAM_set_lword (nvram_t *nvram, uint32_t addr, uint32_t value)
|
1157 | 64201201 | bellard | { |
1158 | 3cbee15b | j_mayer | nvram_write(nvram, addr, value >> 24);
|
1159 | 3cbee15b | j_mayer | nvram_write(nvram, addr + 1, (value >> 16) & 0xFF); |
1160 | 3cbee15b | j_mayer | nvram_write(nvram, addr + 2, (value >> 8) & 0xFF); |
1161 | 3cbee15b | j_mayer | nvram_write(nvram, addr + 3, value & 0xFF); |
1162 | 64201201 | bellard | } |
1163 | 64201201 | bellard | |
1164 | c227f099 | Anthony Liguori | uint32_t NVRAM_get_lword (nvram_t *nvram, uint32_t addr) |
1165 | 64201201 | bellard | { |
1166 | 64201201 | bellard | uint32_t tmp; |
1167 | 64201201 | bellard | |
1168 | 3cbee15b | j_mayer | tmp = nvram_read(nvram, addr) << 24;
|
1169 | 3cbee15b | j_mayer | tmp |= nvram_read(nvram, addr + 1) << 16; |
1170 | 3cbee15b | j_mayer | tmp |= nvram_read(nvram, addr + 2) << 8; |
1171 | 3cbee15b | j_mayer | tmp |= nvram_read(nvram, addr + 3);
|
1172 | 76a66253 | j_mayer | |
1173 | 64201201 | bellard | return tmp;
|
1174 | 64201201 | bellard | } |
1175 | 64201201 | bellard | |
1176 | c227f099 | Anthony Liguori | void NVRAM_set_string (nvram_t *nvram, uint32_t addr,
|
1177 | b55266b5 | blueswir1 | const char *str, uint32_t max) |
1178 | 64201201 | bellard | { |
1179 | 64201201 | bellard | int i;
|
1180 | 64201201 | bellard | |
1181 | 64201201 | bellard | for (i = 0; i < max && str[i] != '\0'; i++) { |
1182 | 3cbee15b | j_mayer | nvram_write(nvram, addr + i, str[i]); |
1183 | 64201201 | bellard | } |
1184 | 3cbee15b | j_mayer | nvram_write(nvram, addr + i, str[i]); |
1185 | 3cbee15b | j_mayer | nvram_write(nvram, addr + max - 1, '\0'); |
1186 | 64201201 | bellard | } |
1187 | 64201201 | bellard | |
1188 | c227f099 | Anthony Liguori | int NVRAM_get_string (nvram_t *nvram, uint8_t *dst, uint16_t addr, int max) |
1189 | 64201201 | bellard | { |
1190 | 64201201 | bellard | int i;
|
1191 | 64201201 | bellard | |
1192 | 64201201 | bellard | memset(dst, 0, max);
|
1193 | 64201201 | bellard | for (i = 0; i < max; i++) { |
1194 | 64201201 | bellard | dst[i] = NVRAM_get_byte(nvram, addr + i); |
1195 | 64201201 | bellard | if (dst[i] == '\0') |
1196 | 64201201 | bellard | break;
|
1197 | 64201201 | bellard | } |
1198 | 64201201 | bellard | |
1199 | 64201201 | bellard | return i;
|
1200 | 64201201 | bellard | } |
1201 | 64201201 | bellard | |
1202 | 64201201 | bellard | static uint16_t NVRAM_crc_update (uint16_t prev, uint16_t value)
|
1203 | 64201201 | bellard | { |
1204 | 64201201 | bellard | uint16_t tmp; |
1205 | 64201201 | bellard | uint16_t pd, pd1, pd2; |
1206 | 64201201 | bellard | |
1207 | 64201201 | bellard | tmp = prev >> 8;
|
1208 | 64201201 | bellard | pd = prev ^ value; |
1209 | 64201201 | bellard | pd1 = pd & 0x000F;
|
1210 | 64201201 | bellard | pd2 = ((pd >> 4) & 0x000F) ^ pd1; |
1211 | 64201201 | bellard | tmp ^= (pd1 << 3) | (pd1 << 8); |
1212 | 64201201 | bellard | tmp ^= pd2 | (pd2 << 7) | (pd2 << 12); |
1213 | 64201201 | bellard | |
1214 | 64201201 | bellard | return tmp;
|
1215 | 64201201 | bellard | } |
1216 | 64201201 | bellard | |
1217 | c227f099 | Anthony Liguori | static uint16_t NVRAM_compute_crc (nvram_t *nvram, uint32_t start, uint32_t count)
|
1218 | 64201201 | bellard | { |
1219 | 64201201 | bellard | uint32_t i; |
1220 | 64201201 | bellard | uint16_t crc = 0xFFFF;
|
1221 | 64201201 | bellard | int odd;
|
1222 | 64201201 | bellard | |
1223 | 64201201 | bellard | odd = count & 1;
|
1224 | 64201201 | bellard | count &= ~1;
|
1225 | 64201201 | bellard | for (i = 0; i != count; i++) { |
1226 | 76a66253 | j_mayer | crc = NVRAM_crc_update(crc, NVRAM_get_word(nvram, start + i)); |
1227 | 64201201 | bellard | } |
1228 | 64201201 | bellard | if (odd) {
|
1229 | 76a66253 | j_mayer | crc = NVRAM_crc_update(crc, NVRAM_get_byte(nvram, start + i) << 8);
|
1230 | 64201201 | bellard | } |
1231 | 64201201 | bellard | |
1232 | 64201201 | bellard | return crc;
|
1233 | 64201201 | bellard | } |
1234 | 64201201 | bellard | |
1235 | fd0bbb12 | bellard | #define CMDLINE_ADDR 0x017ff000 |
1236 | fd0bbb12 | bellard | |
1237 | c227f099 | Anthony Liguori | int PPC_NVRAM_set_params (nvram_t *nvram, uint16_t NVRAM_size,
|
1238 | b55266b5 | blueswir1 | const char *arch, |
1239 | 64201201 | bellard | uint32_t RAM_size, int boot_device,
|
1240 | 64201201 | bellard | uint32_t kernel_image, uint32_t kernel_size, |
1241 | fd0bbb12 | bellard | const char *cmdline, |
1242 | 64201201 | bellard | uint32_t initrd_image, uint32_t initrd_size, |
1243 | fd0bbb12 | bellard | uint32_t NVRAM_image, |
1244 | fd0bbb12 | bellard | int width, int height, int depth) |
1245 | 64201201 | bellard | { |
1246 | 64201201 | bellard | uint16_t crc; |
1247 | 64201201 | bellard | |
1248 | 64201201 | bellard | /* Set parameters for Open Hack'Ware BIOS */
|
1249 | 64201201 | bellard | NVRAM_set_string(nvram, 0x00, "QEMU_BIOS", 16); |
1250 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x10, 0x00000002); /* structure v2 */ |
1251 | 64201201 | bellard | NVRAM_set_word(nvram, 0x14, NVRAM_size);
|
1252 | 64201201 | bellard | NVRAM_set_string(nvram, 0x20, arch, 16); |
1253 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x30, RAM_size);
|
1254 | 64201201 | bellard | NVRAM_set_byte(nvram, 0x34, boot_device);
|
1255 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x38, kernel_image);
|
1256 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x3C, kernel_size);
|
1257 | fd0bbb12 | bellard | if (cmdline) {
|
1258 | fd0bbb12 | bellard | /* XXX: put the cmdline in NVRAM too ? */
|
1259 | 3c178e72 | Gerd Hoffmann | pstrcpy_targphys("cmdline", CMDLINE_ADDR, RAM_size - CMDLINE_ADDR, cmdline);
|
1260 | fd0bbb12 | bellard | NVRAM_set_lword(nvram, 0x40, CMDLINE_ADDR);
|
1261 | fd0bbb12 | bellard | NVRAM_set_lword(nvram, 0x44, strlen(cmdline));
|
1262 | fd0bbb12 | bellard | } else {
|
1263 | fd0bbb12 | bellard | NVRAM_set_lword(nvram, 0x40, 0); |
1264 | fd0bbb12 | bellard | NVRAM_set_lword(nvram, 0x44, 0); |
1265 | fd0bbb12 | bellard | } |
1266 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x48, initrd_image);
|
1267 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x4C, initrd_size);
|
1268 | 64201201 | bellard | NVRAM_set_lword(nvram, 0x50, NVRAM_image);
|
1269 | fd0bbb12 | bellard | |
1270 | fd0bbb12 | bellard | NVRAM_set_word(nvram, 0x54, width);
|
1271 | fd0bbb12 | bellard | NVRAM_set_word(nvram, 0x56, height);
|
1272 | fd0bbb12 | bellard | NVRAM_set_word(nvram, 0x58, depth);
|
1273 | fd0bbb12 | bellard | crc = NVRAM_compute_crc(nvram, 0x00, 0xF8); |
1274 | 3cbee15b | j_mayer | NVRAM_set_word(nvram, 0xFC, crc);
|
1275 | 64201201 | bellard | |
1276 | 64201201 | bellard | return 0; |
1277 | a541f297 | bellard | } |