Revision 8935a442

b/hw/intc/openpic.c
57 57
    } while (0)
58 58

  
59 59
#define MAX_CPU     32
60
#define MAX_SRC     256
61
#define MAX_TMR     4
62
#define MAX_IPI     4
63 60
#define MAX_MSI     8
64
#define MAX_IRQ     (MAX_SRC + MAX_IPI + MAX_TMR)
65 61
#define VID         0x03 /* MPIC version ID */
66 62

  
67 63
/* OpenPIC capability flags */
......
78 74
#define OPENPIC_SUMMARY_REG_START   0x3800
79 75
#define OPENPIC_SUMMARY_REG_SIZE    0x800
80 76
#define OPENPIC_SRC_REG_START        0x10000
81
#define OPENPIC_SRC_REG_SIZE         (MAX_SRC * 0x20)
77
#define OPENPIC_SRC_REG_SIZE         (OPENPIC_MAX_SRC * 0x20)
82 78
#define OPENPIC_CPU_REG_START        0x20000
83 79
#define OPENPIC_CPU_REG_SIZE         0x100 + ((MAX_CPU - 1) * 0x1000)
84 80

  
......
86 82
#define RAVEN_MAX_CPU      2
87 83
#define RAVEN_MAX_EXT     48
88 84
#define RAVEN_MAX_IRQ     64
89
#define RAVEN_MAX_TMR      MAX_TMR
90
#define RAVEN_MAX_IPI      MAX_IPI
85
#define RAVEN_MAX_TMR      OPENPIC_MAX_TMR
86
#define RAVEN_MAX_IPI      OPENPIC_MAX_IPI
91 87

  
92 88
/* Interrupt definitions */
93 89
#define RAVEN_FE_IRQ     (RAVEN_MAX_EXT)     /* Internal functional IRQ */
......
209 205
    /* Round up to the nearest 64 IRQs so that the queue length
210 206
     * won't change when moving between 32 and 64 bit hosts.
211 207
     */
212
    unsigned long queue[BITS_TO_LONGS((MAX_IRQ + 63) & ~63)];
208
    unsigned long queue[BITS_TO_LONGS((OPENPIC_MAX_IRQ + 63) & ~63)];
213 209
    int next;
214 210
    int priority;
215 211
} IRQQueue;
......
283 279
    uint32_t spve; /* Spurious vector register */
284 280
    uint32_t tfrr; /* Timer frequency reporting register */
285 281
    /* Source registers */
286
    IRQSource src[MAX_IRQ];
282
    IRQSource src[OPENPIC_MAX_IRQ];
287 283
    /* Local registers per output pin */
288 284
    IRQDest dst[MAX_CPU];
289 285
    uint32_t nb_cpus;
......
291 287
    struct {
292 288
        uint32_t tccr;  /* Global timer current count register */
293 289
        uint32_t tbcr;  /* Global timer base count register */
294
    } timers[MAX_TMR];
290
    } timers[OPENPIC_MAX_TMR];
295 291
    /* Shared MSI registers */
296 292
    struct {
297 293
        uint32_t msir;   /* Shared Message Signaled Interrupt Register */
......
503 499
    OpenPICState *opp = opaque;
504 500
    IRQSource *src;
505 501

  
506
    if (n_IRQ >= MAX_IRQ) {
502
    if (n_IRQ >= OPENPIC_MAX_IRQ) {
507 503
        fprintf(stderr, "%s: IRQ %d out of range\n", __func__, n_IRQ);
508 504
        abort();
509 505
    }
......
576 572
        opp->dst[i].servicing.next = -1;
577 573
    }
578 574
    /* Initialise timers */
579
    for (i = 0; i < MAX_TMR; i++) {
575
    for (i = 0; i < OPENPIC_MAX_TMR; i++) {
580 576
        opp->timers[i].tccr = 0;
581 577
        opp->timers[i].tbcr = TBCR_CI;
582 578
    }
......
1182 1178
        IRQ_resetbit(&dst->raised, irq);
1183 1179
    }
1184 1180

  
1185
    if ((irq >= opp->irq_ipi0) &&  (irq < (opp->irq_ipi0 + MAX_IPI))) {
1181
    if ((irq >= opp->irq_ipi0) &&  (irq < (opp->irq_ipi0 + OPENPIC_MAX_IPI))) {
1186 1182
        src->destmask &= ~(1 << cpu);
1187 1183
        if (src->destmask && !src->level) {
1188 1184
            /* trigger on CPUs that didn't know about it yet */
......
1381 1377
                        sizeof(opp->dst[i].outputs_active));
1382 1378
    }
1383 1379

  
1384
    for (i = 0; i < MAX_TMR; i++) {
1380
    for (i = 0; i < OPENPIC_MAX_TMR; i++) {
1385 1381
        qemu_put_be32s(f, &opp->timers[i].tccr);
1386 1382
        qemu_put_be32s(f, &opp->timers[i].tbcr);
1387 1383
    }
......
1440 1436
                        sizeof(opp->dst[i].outputs_active));
1441 1437
    }
1442 1438

  
1443
    for (i = 0; i < MAX_TMR; i++) {
1439
    for (i = 0; i < OPENPIC_MAX_TMR; i++) {
1444 1440
        qemu_get_be32s(f, &opp->timers[i].tccr);
1445 1441
        qemu_get_be32s(f, &opp->timers[i].tbcr);
1446 1442
    }
......
1473 1469
static void fsl_common_init(OpenPICState *opp)
1474 1470
{
1475 1471
    int i;
1476
    int virq = MAX_SRC;
1472
    int virq = OPENPIC_MAX_SRC;
1477 1473

  
1478 1474
    opp->vid = VID_REVISION_1_2;
1479 1475
    opp->vir = VIR_GENERIC;
......
1481 1477
    opp->tfrr_reset = 0;
1482 1478
    opp->ivpr_reset = IVPR_MASK_MASK;
1483 1479
    opp->idr_reset = 1 << 0;
1484
    opp->max_irq = MAX_IRQ;
1480
    opp->max_irq = OPENPIC_MAX_IRQ;
1485 1481

  
1486 1482
    opp->irq_ipi0 = virq;
1487
    virq += MAX_IPI;
1483
    virq += OPENPIC_MAX_IPI;
1488 1484
    opp->irq_tim0 = virq;
1489
    virq += MAX_TMR;
1485
    virq += OPENPIC_MAX_TMR;
1490 1486

  
1491
    assert(virq <= MAX_IRQ);
1487
    assert(virq <= OPENPIC_MAX_IRQ);
1492 1488

  
1493 1489
    opp->irq_msi = 224;
1494 1490

  
......
1498 1494
    }
1499 1495

  
1500 1496
    /* Internal interrupts, including message and MSI */
1501
    for (i = 16; i < MAX_SRC; i++) {
1497
    for (i = 16; i < OPENPIC_MAX_SRC; i++) {
1502 1498
        opp->src[i].type = IRQ_TYPE_FSLINT;
1503 1499
        opp->src[i].level = true;
1504 1500
    }
1505 1501

  
1506 1502
    /* timers and IPIs */
1507
    for (i = MAX_SRC; i < virq; i++) {
1503
    for (i = OPENPIC_MAX_SRC; i < virq; i++) {
1508 1504
        opp->src[i].type = IRQ_TYPE_FSLSPECIAL;
1509 1505
        opp->src[i].level = false;
1510 1506
    }
b/include/hw/ppc/openpic.h
1 1
#if !defined(__OPENPIC_H__)
2 2
#define __OPENPIC_H__
3 3

  
4
#include "qemu-common.h"
5
#include "hw/qdev.h"
6

  
4 7
/* OpenPIC have 5 outputs per CPU connected and one IRQ out single output */
5 8
enum {
6 9
    OPENPIC_OUTPUT_INT = 0, /* IRQ                       */
......
15 18
#define OPENPIC_MODEL_FSL_MPIC_20 1
16 19
#define OPENPIC_MODEL_FSL_MPIC_42 2
17 20

  
21
#define OPENPIC_MAX_SRC     256
22
#define OPENPIC_MAX_TMR     4
23
#define OPENPIC_MAX_IPI     4
24
#define OPENPIC_MAX_IRQ     (OPENPIC_MAX_SRC + OPENPIC_MAX_IPI + \
25
                             OPENPIC_MAX_TMR)
26

  
27
DeviceState *kvm_openpic_create(BusState *bus, int model);
28

  
18 29
#endif /* __OPENPIC_H__ */

Also available in: Unified diff