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