Revision 347dd79d

b/hw/ppc/e500.c
66 66
    uint32_t entry;
67 67
};
68 68

  
69
static void pci_map_create(void *fdt, uint32_t *pci_map, uint32_t mpic)
69
static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot,
70
                                int nr_slots, int *len)
70 71
{
71
    int i;
72
    const uint32_t tmp[] = {
73
                             /* IDSEL 0x11 J17 Slot 1 */
74
                             0x8800, 0x0, 0x0, 0x1, mpic, 0x2, 0x1,
75
                             0x8800, 0x0, 0x0, 0x2, mpic, 0x3, 0x1,
76
                             0x8800, 0x0, 0x0, 0x3, mpic, 0x4, 0x1,
77
                             0x8800, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
78

  
79
                             /* IDSEL 0x12 J16 Slot 2 */
80
                             0x9000, 0x0, 0x0, 0x1, mpic, 0x3, 0x1,
81
                             0x9000, 0x0, 0x0, 0x2, mpic, 0x4, 0x1,
82
                             0x9000, 0x0, 0x0, 0x3, mpic, 0x2, 0x1,
83
                             0x9000, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
84
                           };
85
    for (i = 0; i < (7 * 8); i++) {
86
        pci_map[i] = cpu_to_be32(tmp[i]);
72
    int i = 0;
73
    int slot;
74
    int pci_irq;
75
    int last_slot = first_slot + nr_slots;
76
    uint32_t *pci_map;
77

  
78
    *len = nr_slots * 4 * 7 * sizeof(uint32_t);
79
    pci_map = g_malloc(*len);
80

  
81
    for (slot = first_slot; slot < last_slot; slot++) {
82
        for (pci_irq = 0; pci_irq < 4; pci_irq++) {
83
            pci_map[i++] = cpu_to_be32(slot << 11);
84
            pci_map[i++] = cpu_to_be32(0x0);
85
            pci_map[i++] = cpu_to_be32(0x0);
86
            pci_map[i++] = cpu_to_be32(pci_irq + 1);
87
            pci_map[i++] = cpu_to_be32(mpic);
88
            pci_map[i++] = cpu_to_be32(((pci_irq + slot) % 4) + 1);
89
            pci_map[i++] = cpu_to_be32(0x1);
90
        }
87 91
    }
92

  
93
    assert((i * sizeof(uint32_t)) == *len);
94

  
95
    return pci_map;
88 96
}
89 97

  
90 98
static void dt_serial_create(void *fdt, unsigned long long offset,
......
132 140
    char gutil[128];
133 141
    char pci[128];
134 142
    char msi[128];
135
    uint32_t pci_map[7 * 8];
143
    uint32_t *pci_map = NULL;
144
    int len;
136 145
    uint32_t pci_ranges[14] =
137 146
        {
138 147
            0x2000000, 0x0, 0xc0000000,
......
329 338
    qemu_devtree_setprop_string(fdt, pci, "device_type", "pci");
330 339
    qemu_devtree_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0,
331 340
                               0x0, 0x7);
332
    pci_map_create(fdt, pci_map, qemu_devtree_get_phandle(fdt, mpic));
333
    qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, sizeof(pci_map));
341
    pci_map = pci_map_create(fdt, qemu_devtree_get_phandle(fdt, mpic),
342
                             0x11, 2, &len);
343
    qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, len);
334 344
    qemu_devtree_setprop_phandle(fdt, pci, "interrupt-parent", mpic);
335 345
    qemu_devtree_setprop_cells(fdt, pci, "interrupts", 24, 2);
336 346
    qemu_devtree_setprop_cells(fdt, pci, "bus-range", 0, 255);
......
364 374
    ret = fdt_size;
365 375

  
366 376
out:
377
    g_free(pci_map);
367 378

  
368 379
    return ret;
369 380
}

Also available in: Unified diff