Revision a496775f hw/ppc.c

b/hw/ppc.c
40 40
            cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
41 41
    }
42 42
#if defined(PPC_DEBUG_IRQ)
43
    printf("%s: %p n_IRQ %d level %d => pending %08x req %08x\n", __func__,
44
           env, n_IRQ, level, env->pending_interrupts, env->interrupt_request);
43
    if (loglevel & CPU_LOG_INT) {
44
        fprintf(logfile, "%s: %p n_IRQ %d level %d => pending %08x req %08x\n",
45
                __func__, env, n_IRQ, level,
46
                env->pending_interrupts, env->interrupt_request);
47
    }
45 48
#endif
46 49
}
47 50

  
......
52 55
    int cur_level;
53 56

  
54 57
#if defined(PPC_DEBUG_IRQ)
55
    printf("%s: env %p pin %d level %d\n", __func__, env, pin, level);
58
    if (loglevel & CPU_LOG_INT) {
59
        fprintf(logfile, "%s: env %p pin %d level %d\n", __func__,
60
                env, pin, level);
61
    }
56 62
#endif
57 63
    cur_level = (env->irq_input_state >> pin) & 1;
58 64
    /* Don't generate spurious events */
......
61 67
        case PPC6xx_INPUT_INT:
62 68
            /* Level sensitive - active high */
63 69
#if defined(PPC_DEBUG_IRQ)
64
            printf("%s: set the external IRQ state to %d\n", __func__, level);
70
            if (loglevel & CPU_LOG_INT) {
71
                fprintf(logfile, "%s: set the external IRQ state to %d\n",
72
                        __func__, level);
73
            }
65 74
#endif
66 75
            ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
67 76
            break;
68 77
        case PPC6xx_INPUT_SMI:
69 78
            /* Level sensitive - active high */
70 79
#if defined(PPC_DEBUG_IRQ)
71
            printf("%s: set the SMI IRQ state to %d\n", __func__, level);
80
            if (loglevel & CPU_LOG_INT) {
81
                fprintf(logfile, "%s: set the SMI IRQ state to %d\n",
82
                        __func__, level);
83
            }
72 84
#endif
73 85
            ppc_set_irq(env, PPC_INTERRUPT_SMI, level);
74 86
            break;
......
79 91
             */
80 92
            if (cur_level == 1 && level == 0) {
81 93
#if defined(PPC_DEBUG_IRQ)
82
                printf("%s: raise machine check state\n", __func__);
94
                if (loglevel & CPU_LOG_INT) {
95
                    fprintf(logfile, "%s: raise machine check state\n",
96
                            __func__);
97
                }
83 98
#endif
84 99
                ppc_set_irq(env, PPC_INTERRUPT_MCK, 1);
85 100
            }
......
89 104
            /* XXX: TODO: relay the signal to CKSTP_OUT pin */
90 105
            if (level) {
91 106
#if defined(PPC_DEBUG_IRQ)
92
                printf("%s: stop the CPU\n", __func__);
107
                if (loglevel & CPU_LOG_INT) {
108
                    fprintf(logfile, "%s: stop the CPU\n", __func__);
109
                }
93 110
#endif
94 111
                env->halted = 1;
95 112
            } else {
96 113
#if defined(PPC_DEBUG_IRQ)
97
                printf("%s: restart the CPU\n", __func__);
114
                if (loglevel & CPU_LOG_INT) {
115
                    fprintf(logfile, "%s: restart the CPU\n", __func__);
116
                }
98 117
#endif
99 118
                env->halted = 0;
100 119
            }
......
104 123
            if (level) {
105 124
#if 0 // XXX: TOFIX
106 125
#if defined(PPC_DEBUG_IRQ)
107
                printf("%s: reset the CPU\n", __func__);
126
                if (loglevel & CPU_LOG_INT) {
127
                    fprintf(logfile, "%s: reset the CPU\n", __func__);
128
                }
108 129
#endif
109 130
                cpu_reset(env);
110 131
#endif
......
112 133
            break;
113 134
        case PPC6xx_INPUT_SRESET:
114 135
#if defined(PPC_DEBUG_IRQ)
115
            printf("%s: set the RESET IRQ state to %d\n", __func__, level);
136
            if (loglevel & CPU_LOG_INT) {
137
                fprintf(logfile, "%s: set the RESET IRQ state to %d\n",
138
                        __func__, level);
139
            }
116 140
#endif
117 141
            ppc_set_irq(env, PPC_INTERRUPT_RESET, level);
118 142
            break;
119 143
        default:
120 144
            /* Unknown pin - do nothing */
121 145
#if defined(PPC_DEBUG_IRQ)
122
            printf("%s: unknown IRQ pin %d\n", __func__, pin);
146
            if (loglevel & CPU_LOG_INT) {
147
                fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
148
            }
123 149
#endif
124 150
            return;
125 151
        }
......
176 202
        case PPC405_INPUT_INT:
177 203
            /* Level sensitive - active high */
178 204
#if defined(PPC_DEBUG_IRQ)
179
            printf("%s: set the external IRQ state to %d\n", __func__, level);
205
            if (loglevel & CPU_LOG_INT) {
206
                fprintf(logfile, "%s: set the external IRQ state to %d\n",
207
                        __func__, level);
208
            }
180 209
#endif
181 210
            ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
182 211
            break;
......
184 213
            /* Level sensitive - active low */
185 214
            if (level) {
186 215
#if defined(PPC_DEBUG_IRQ)
187
                printf("%s: stop the CPU\n", __func__);
216
                if (loglevel & CPU_LOG_INT) {
217
                    fprintf(logfile, "%s: stop the CPU\n", __func__);
218
                }
188 219
#endif
189 220
                env->halted = 1;
190 221
            } else {
191 222
#if defined(PPC_DEBUG_IRQ)
192
                printf("%s: restart the CPU\n", __func__);
223
                if (loglevel & CPU_LOG_INT) {
224
                    fprintf(logfile, "%s: restart the CPU\n", __func__);
225
                }
193 226
#endif
194 227
                env->halted = 0;
195 228
            }
......
197 230
        case PPC405_INPUT_DEBUG:
198 231
            /* Level sensitive - active high */
199 232
#if defined(PPC_DEBUG_IRQ)
200
            printf("%s: set the external IRQ state to %d\n", __func__, level);
233
            if (loglevel & CPU_LOG_INT) {
234
                fprintf(logfile, "%s: set the external IRQ state to %d\n",
235
                        __func__, level);
236
            }
201 237
#endif
202 238
            ppc_set_irq(env, EXCP_40x_DEBUG, level);
203 239
            break;
204 240
        default:
205 241
            /* Unknown pin - do nothing */
206 242
#if defined(PPC_DEBUG_IRQ)
207
            printf("%s: unknown IRQ pin %d\n", __func__, pin);
243
            if (loglevel & CPU_LOG_INT) {
244
                fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin);
245
            }
208 246
#endif
209 247
            return;
210 248
        }
......
217 255

  
218 256
void ppc405_irq_init (CPUState *env)
219 257
{
220
    printf("%s\n", __func__);
221 258
    env->irq_inputs = (void **)qemu_allocate_irqs(&ppc405_set_irq, env, 7);
222 259
}
223 260

  
......
255 292
        now = time(NULL);
256 293
        if (last_time != now) {
257 294
            last_time = now;
258
            printf("%s: tb=0x%016lx %d %08lx\n",
259
                   __func__, tb, now, tb_env->tb_offset);
295
            if (loglevel) {
296
                fprintf(logfile, "%s: tb=0x%016lx %d %08lx\n",
297
                        __func__, tb, now, tb_env->tb_offset);
298
            }
260 299
        }
261 300
    }
262 301
#endif
......
271 310

  
272 311
    tb = cpu_ppc_get_tb(tb_env);
273 312
#ifdef DEBUG_TB
274
    printf("%s: tb=0x%016lx\n", __func__, tb);
313
    if (loglevel) {
314
        fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
315
    }
275 316
#endif
276 317

  
277 318
    return tb >> 32;
......
282 323
    tb_env->tb_offset = muldiv64(value, ticks_per_sec, tb_env->tb_freq)
283 324
        - qemu_get_clock(vm_clock);
284 325
#ifdef DEBUG_TB
285
    printf("%s: tb=0x%016lx offset=%08x\n", __func__, value);
326
    if (loglevel) {
327
        fprintf(logfile, "%s: tb=0x%016lx offset=%08x\n", __func__, value);
328
    }
286 329
#endif
287 330
}
288 331

  
......
314 357
    else
315 358
        decr = -muldiv64(-diff, tb_env->tb_freq, ticks_per_sec);
316 359
#if defined(DEBUG_TB)
317
    printf("%s: 0x%08x\n", __func__, decr);
360
    if (loglevel) {
361
        fprintf(logfile, "%s: 0x%08x\n", __func__, decr);
362
    }
318 363
#endif
319 364

  
320 365
    return decr;
......
327 372
{
328 373
    /* Raise it */
329 374
#ifdef DEBUG_TB
330
    printf("raise decrementer exception\n");
375
    if (loglevel) {
376
        fprintf(logfile, "raise decrementer exception\n");
377
    }
331 378
#endif
332 379
    ppc_set_irq(env, PPC_INTERRUPT_DECR, 1);
333 380
}
......
339 386
    uint64_t now, next;
340 387

  
341 388
#ifdef DEBUG_TB
342
    printf("%s: 0x%08x => 0x%08x\n", __func__, decr, value);
389
    if (loglevel) {
390
        fprintf(logfile, "%s: 0x%08x => 0x%08x\n", __func__, decr, value);
391
    }
343 392
#endif
344 393
    now = qemu_get_clock(vm_clock);
345 394
    next = now + muldiv64(value, ticks_per_sec, tb_env->tb_freq);
......
578 627

  
579 628
    tb_env = env->tb_env;
580 629
    ppcemb_timer = tb_env->opaque;
581
    if (loglevel)
630
    if (loglevel) {
582 631
        fprintf(logfile, "%s %p %p\n", __func__, tb_env, ppcemb_timer);
632
    }
583 633
    ppcemb_timer->pit_reload = val;
584 634
    if (val == 0) {
585 635
        /* Stop PIT */
586
        if (loglevel)
636
        if (loglevel) {
587 637
            fprintf(logfile, "%s: stop PIT\n", __func__);
638
        }
588 639
        qemu_del_timer(tb_env->decr_timer);
589 640
    } else {
590
        if (loglevel)
641
        if (loglevel) {
591 642
            fprintf(logfile, "%s: start PIT 0x" ADDRX "\n", __func__, val);
643
        }
592 644
        now = qemu_get_clock(vm_clock);
593 645
        next = now + muldiv64(val, ticks_per_sec, tb_env->tb_freq);
594 646
         if (next == now)

Also available in: Unified diff