~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/apb_pci.c

  • Committer: pbrook
  • Date: 2007-03-04 00:52:16 UTC
  • Revision ID: git-v1:7a2d6d9650ed16b2cdb0b4876fe9efce7ef8ea6d
64bit->win32 cross build fix.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2467 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * QEMU Ultrasparc APB PCI host
3
3
 *
4
4
 * Copyright (c) 2006 Fabrice Bellard
5
 
 *
 
5
 * 
6
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
 * of this software and associated documentation files (the "Software"), to deal
8
8
 * in the Software without restriction, including without limitation the rights
26
26
   Ultrasparc PCI host is called the PCI Bus Module (PBM).  The APB is
27
27
   the secondary PCI bridge.  */
28
28
 
29
 
#include "hw.h"
30
 
#include "pci.h"
 
29
#include "vl.h"
31
30
typedef target_phys_addr_t pci_addr_t;
32
31
#include "pci_host.h"
33
32
 
71
70
};
72
71
 
73
72
static void apb_config_writel (void *opaque, target_phys_addr_t addr,
74
 
                               uint32_t val)
 
73
                               uint32_t val)
75
74
{
76
75
    //PCIBus *s = opaque;
77
76
 
81
80
    case 0x18: // AFAR
82
81
    case 0x20: // Diagnostic
83
82
    case 0x28: // Target address space
84
 
        // XXX
 
83
        // XXX
85
84
    default:
86
 
        break;
 
85
        break;
87
86
    }
88
87
}
89
88
 
90
89
static uint32_t apb_config_readl (void *opaque,
91
 
                                  target_phys_addr_t addr)
 
90
                                  target_phys_addr_t addr)
92
91
{
93
92
    //PCIBus *s = opaque;
94
93
    uint32_t val;
99
98
    case 0x18: // AFAR
100
99
    case 0x20: // Diagnostic
101
100
    case 0x28: // Target address space
102
 
        // XXX
 
101
        // XXX
103
102
    default:
104
 
        val = 0;
105
 
        break;
 
103
        val = 0;
 
104
        break;
106
105
    }
107
106
    return val;
108
107
}
201
200
    return bus_offset + irq_num;
202
201
}
203
202
 
204
 
static void pci_apb_set_irq(qemu_irq *pic, int irq_num, int level)
 
203
static void pci_apb_set_irq(void *pic, int irq_num, int level)
205
204
{
206
205
    /* PCI IRQ map onto the first 32 INO.  */
207
 
    qemu_set_irq(pic[irq_num], level);
 
206
    pic_set_irq_new(pic, irq_num, level);
208
207
}
209
208
 
210
 
PCIBus *pci_apb_init(target_phys_addr_t special_base,
211
 
                     target_phys_addr_t mem_base,
212
 
                     qemu_irq *pic)
 
209
PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base,
 
210
                     void *pic)
213
211
{
214
212
    APBState *s;
215
213
    PCIDevice *d;
216
214
    int pci_mem_config, pci_mem_data, apb_config, pci_ioport;
 
215
    PCIDevice *apb;
217
216
    PCIBus *secondary;
218
217
 
219
218
    s = qemu_mallocz(sizeof(APBState));
223
222
    pci_mem_config = cpu_register_io_memory(0, pci_apb_config_read,
224
223
                                            pci_apb_config_write, s);
225
224
    apb_config = cpu_register_io_memory(0, apb_config_read,
226
 
                                        apb_config_write, s);
 
225
                                        apb_config_write, s);
227
226
    pci_mem_data = cpu_register_io_memory(0, pci_apb_read,
228
227
                                          pci_apb_write, s);
229
228
    pci_ioport = cpu_register_io_memory(0, pci_apb_ioread,
230
229
                                          pci_apb_iowrite, s);
231
230
 
232
231
    cpu_register_physical_memory(special_base + 0x2000ULL, 0x40, apb_config);
233
 
    cpu_register_physical_memory(special_base + 0x1000000ULL, 0x10,
234
 
                                 pci_mem_config);
235
 
    cpu_register_physical_memory(special_base + 0x2000000ULL, 0x10000,
236
 
                                 pci_ioport);
237
 
    cpu_register_physical_memory(mem_base, 0x10000000,
238
 
                                 pci_mem_data); // XXX size should be 4G-prom
 
232
    cpu_register_physical_memory(special_base + 0x1000000ULL, 0x10, pci_mem_config);
 
233
    cpu_register_physical_memory(special_base + 0x2000000ULL, 0x10000, pci_ioport);
 
234
    cpu_register_physical_memory(mem_base, 0x10000000, pci_mem_data); // XXX size should be 4G-prom
239
235
 
240
 
    d = pci_register_device(s->bus, "Advanced PCI Bus", sizeof(PCIDevice),
 
236
    d = pci_register_device(s->bus, "Advanced PCI Bus", sizeof(PCIDevice), 
241
237
                            0, NULL, NULL);
242
238
    d->config[0x00] = 0x8e; // vendor_id : Sun
243
239
    d->config[0x01] = 0x10;
255
251
    d->config[0x0E] = 0x00; // header_type
256
252
 
257
253
    /* APB secondary busses */
258
 
    secondary = pci_bridge_init(s->bus, 8, 0x108e5000, pci_apb_map_irq,
259
 
                                "Advanced PCI Bus secondary bridge 1");
260
 
    pci_bridge_init(s->bus, 9, 0x108e5000, pci_apb_map_irq,
261
 
                    "Advanced PCI Bus secondary bridge 2");
 
254
    secondary = pci_bridge_init(s->bus, 8, 0x108e5000, pci_apb_map_irq, "Advanced PCI Bus secondary bridge 1");
 
255
    pci_bridge_init(s->bus, 9, 0x108e5000, pci_apb_map_irq, "Advanced PCI Bus secondary bridge 2");
262
256
    return secondary;
263
257
}
264
258