~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/apb_pci.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-22 10:13:17 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090322101317-iigjtnu5qil35dtb
Tags: 0.10.1-1
[ Aurelien Jarno ]
* New upstream stable release:
  - patches/80_stable-branch.patch: remove.
* debian/control: 
  - Remove depends on proll.
  - Move depends on device-tree-compiler to build-depends.
  - Bump Standards-Version to 3.8.1 (no changes).
* patches/82_qemu-img_decimal.patch: new patch from upstream to make
  qemu-img accept sizes with decimal values (closes: bug#501400).

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 * THE SOFTWARE.
23
23
 */
24
24
 
25
 
/* XXX This file and most of its contests are somewhat misnamed.  The
 
25
/* XXX This file and most of its contents are somewhat misnamed.  The
26
26
   Ultrasparc PCI host is called the PCI Bus Module (PBM).  The APB is
27
27
   the secondary PCI bridge.  */
28
28
 
29
29
#include "hw.h"
30
30
#include "pci.h"
 
31
 
 
32
/* debug APB */
 
33
//#define DEBUG_APB
 
34
 
 
35
#ifdef DEBUG_APB
 
36
#define APB_DPRINTF(fmt, args...) \
 
37
do { printf("APB: " fmt , ##args); } while (0)
 
38
#else
 
39
#define APB_DPRINTF(fmt, args...)
 
40
#endif
 
41
 
31
42
typedef target_phys_addr_t pci_addr_t;
32
43
#include "pci_host.h"
33
44
 
37
48
                                         uint32_t val)
38
49
{
39
50
    APBState *s = opaque;
40
 
    int i;
41
51
 
42
 
    for (i = 11; i < 32; i++) {
43
 
        if ((val & (1 << i)) != 0)
44
 
            break;
45
 
    }
46
 
    s->config_reg = (1 << 16) | (val & 0x7FC) | (i << 11);
 
52
#ifdef TARGET_WORDS_BIGENDIAN
 
53
    val = bswap32(val);
 
54
#endif
 
55
    APB_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr,
 
56
                val);
 
57
    s->config_reg = val;
47
58
}
48
59
 
49
60
static uint32_t pci_apb_config_readl (void *opaque,
51
62
{
52
63
    APBState *s = opaque;
53
64
    uint32_t val;
54
 
    int devfn;
55
65
 
56
 
    devfn = (s->config_reg >> 8) & 0xFF;
57
 
    val = (1 << (devfn >> 3)) | ((devfn & 0x07) << 8) | (s->config_reg & 0xFC);
 
66
    val = s->config_reg;
 
67
#ifdef TARGET_WORDS_BIGENDIAN
 
68
    val = bswap32(val);
 
69
#endif
 
70
    APB_DPRINTF("config_readl addr " TARGET_FMT_plx " val %x\n", addr,
 
71
                val);
58
72
    return val;
59
73
}
60
74
 
209
223
 
210
224
PCIBus *pci_apb_init(target_phys_addr_t special_base,
211
225
                     target_phys_addr_t mem_base,
212
 
                     qemu_irq *pic)
 
226
                     qemu_irq *pic, PCIBus **bus2, PCIBus **bus3)
213
227
{
214
228
    APBState *s;
215
229
    PCIDevice *d;
216
230
    int pci_mem_config, pci_mem_data, apb_config, pci_ioport;
217
 
    PCIBus *secondary;
218
231
 
219
232
    s = qemu_mallocz(sizeof(APBState));
220
233
    /* Ultrasparc PBM main bus */
230
243
                                          pci_apb_iowrite, s);
231
244
 
232
245
    cpu_register_physical_memory(special_base + 0x2000ULL, 0x40, apb_config);
233
 
    cpu_register_physical_memory(special_base + 0x1000000ULL, 0x10, pci_mem_config);
234
 
    cpu_register_physical_memory(special_base + 0x2000000ULL, 0x10000, pci_ioport);
235
 
    cpu_register_physical_memory(mem_base, 0x10000000, pci_mem_data); // XXX size should be 4G-prom
 
246
    cpu_register_physical_memory(special_base + 0x1000000ULL, 0x10,
 
247
                                 pci_mem_config);
 
248
    cpu_register_physical_memory(special_base + 0x2000000ULL, 0x10000,
 
249
                                 pci_ioport);
 
250
    cpu_register_physical_memory(mem_base, 0x10000000,
 
251
                                 pci_mem_data); // XXX size should be 4G-prom
236
252
 
237
253
    d = pci_register_device(s->bus, "Advanced PCI Bus", sizeof(PCIDevice),
238
254
                            0, NULL, NULL);
239
 
    d->config[0x00] = 0x8e; // vendor_id : Sun
240
 
    d->config[0x01] = 0x10;
241
 
    d->config[0x02] = 0x00; // device_id
242
 
    d->config[0x03] = 0xa0;
 
255
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_SUN);
 
256
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_SUN_SABRE);
243
257
    d->config[0x04] = 0x06; // command = bus master, pci mem
244
258
    d->config[0x05] = 0x00;
245
259
    d->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error
246
260
    d->config[0x07] = 0x03; // status = medium devsel
247
261
    d->config[0x08] = 0x00; // revision
248
262
    d->config[0x09] = 0x00; // programming i/f
249
 
    d->config[0x0A] = 0x00; // class_sub = pci host
250
 
    d->config[0x0B] = 0x06; // class_base = PCI_bridge
 
263
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
251
264
    d->config[0x0D] = 0x10; // latency_timer
252
265
    d->config[0x0E] = 0x00; // header_type
253
266
 
254
267
    /* APB secondary busses */
255
 
    secondary = pci_bridge_init(s->bus, 8, 0x108e5000, pci_apb_map_irq, "Advanced PCI Bus secondary bridge 1");
256
 
    pci_bridge_init(s->bus, 9, 0x108e5000, pci_apb_map_irq, "Advanced PCI Bus secondary bridge 2");
257
 
    return secondary;
 
268
    *bus2 = pci_bridge_init(s->bus, 8, PCI_VENDOR_ID_SUN,
 
269
                            PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
 
270
                            "Advanced PCI Bus secondary bridge 1");
 
271
    *bus3 = pci_bridge_init(s->bus, 9, PCI_VENDOR_ID_SUN,
 
272
                            PCI_DEVICE_ID_SUN_SIMBA, pci_apb_map_irq,
 
273
                            "Advanced PCI Bus secondary bridge 2");
 
274
    return s->bus;
258
275
}
259
 
 
260