Revision 97bf4851 hw/slavio_timer.c

b/hw/slavio_timer.c
25 25
#include "sun4m.h"
26 26
#include "qemu-timer.h"
27 27
#include "sysbus.h"
28

  
29
//#define DEBUG_TIMER
30

  
31
#ifdef DEBUG_TIMER
32
#define DPRINTF(fmt, ...)                                       \
33
    do { printf("TIMER: " fmt , ## __VA_ARGS__); } while (0)
34
#else
35
#define DPRINTF(fmt, ...) do {} while (0)
36
#endif
28
#include "trace.h"
37 29

  
38 30
/*
39 31
 * Registers of hardware timer in sun4m.
......
112 104
    }
113 105
    count = limit - PERIODS_TO_LIMIT(ptimer_get_count(t->timer));
114 106

  
115
    DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", t->limit, t->counthigh,
116
            t->count);
107
    trace_slavio_timer_get_out(t->limit, t->counthigh, t->count);
117 108
    t->count = count & TIMER_COUNT_MASK32;
118 109
    t->counthigh = count >> 32;
119 110
}
......
126 117
    CPUTimerState *t = &s->cputimer[tc->timer_index];
127 118

  
128 119
    slavio_timer_get_out(t);
129
    DPRINTF("callback: count %x%08x\n", t->counthigh, t->count);
120
    trace_slavio_timer_irq(t->counthigh, t->count);
130 121
    /* if limit is 0 (free-run), there will be no match */
131 122
    if (t->limit != 0) {
132 123
        t->reached = TIMER_REACHED;
......
188 179
        ret = s->cputimer_mode;
189 180
        break;
190 181
    default:
191
        DPRINTF("invalid read address " TARGET_FMT_plx "\n", addr);
182
        trace_slavio_timer_mem_readl_invalid(addr);
192 183
        ret = 0;
193 184
        break;
194 185
    }
195
    DPRINTF("read " TARGET_FMT_plx " = %08x\n", addr, ret);
196

  
186
    trace_slavio_timer_mem_readl(addr, ret);
197 187
    return ret;
198 188
}
199 189

  
......
206 196
    unsigned int timer_index = tc->timer_index;
207 197
    CPUTimerState *t = &s->cputimer[timer_index];
208 198

  
209
    DPRINTF("write " TARGET_FMT_plx " %08x\n", addr, val);
199
    trace_slavio_timer_mem_writel(addr, val);
210 200
    saddr = addr >> 2;
211 201
    switch (saddr) {
212 202
    case TIMER_LIMIT:
......
218 208
            t->counthigh = val & (TIMER_MAX_COUNT64 >> 32);
219 209
            t->reached = 0;
220 210
            count = ((uint64_t)t->counthigh << 32) | t->count;
221
            DPRINTF("processor %d user timer set to %016" PRIx64 "\n",
222
                    timer_index, count);
211
            trace_slavio_timer_mem_writel_limit(timer_index, count);
223 212
            ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count));
224 213
        } else {
225 214
            // set limit, reset counter
......
244 233
            t->count = val & TIMER_MAX_COUNT64;
245 234
            t->reached = 0;
246 235
            count = ((uint64_t)t->counthigh) << 32 | t->count;
247
            DPRINTF("processor %d user timer set to %016" PRIx64 "\n",
248
                    timer_index, count);
236
            trace_slavio_timer_mem_writel_limit(timer_index, count);
249 237
            ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count));
250
        } else
251
            DPRINTF("not user timer\n");
238
        } else {
239
            trace_slavio_timer_mem_writel_counter_invalid();
240
        }
252 241
        break;
253 242
    case TIMER_COUNTER_NORST:
254 243
        // set limit without resetting counter
......
263 252
        if (slavio_timer_is_user(tc)) {
264 253
            // start/stop user counter
265 254
            if ((val & 1) && !t->running) {
266
                DPRINTF("processor %d user timer started\n",
267
                        timer_index);
255
                trace_slavio_timer_mem_writel_status_start(timer_index);
268 256
                ptimer_run(t->timer, 0);
269 257
                t->running = 1;
270 258
            } else if (!(val & 1) && t->running) {
271
                DPRINTF("processor %d user timer stopped\n",
272
                        timer_index);
259
                trace_slavio_timer_mem_writel_status_stop(timer_index);
273 260
                ptimer_stop(t->timer);
274 261
                t->running = 0;
275 262
            }
......
298 285
                        // set this processors user timer bit in config
299 286
                        // register
300 287
                        s->cputimer_mode |= processor;
301
                        DPRINTF("processor %d changed from counter to user "
302
                                "timer\n", timer_index);
288
                        trace_slavio_timer_mem_writel_mode_user(timer_index);
303 289
                    } else { // user timer -> counter
304 290
                        // stop the user timer if it is running
305 291
                        if (curr_timer->running) {
......
311 297
                        // clear this processors user timer bit in config
312 298
                        // register
313 299
                        s->cputimer_mode &= ~processor;
314
                        DPRINTF("processor %d changed from user timer to "
315
                                "counter\n", timer_index);
300
                        trace_slavio_timer_mem_writel_mode_counter(timer_index);
316 301
                    }
317 302
                }
318 303
            }
319 304
        } else {
320
            DPRINTF("not system timer\n");
305
            trace_slavio_timer_mem_writel_mode_invalid();
321 306
        }
322 307
        break;
323 308
    default:
324
        DPRINTF("invalid write address " TARGET_FMT_plx "\n", addr);
309
        trace_slavio_timer_mem_writel_invalid(addr);
325 310
        break;
326 311
    }
327 312
}

Also available in: Unified diff