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

« back to all changes in this revision

Viewing changes to hw/versatile_pci.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn, Serge Hallyn, Adam Conrad
  • Date: 2013-01-04 08:50:24 UTC
  • mfrom: (1.6.6) (10.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20130104085024-k4mr3z3zzjxemww2
Tags: 1.2.0.dfsg-1~exp1-0ubuntu1
[ Serge Hallyn ]
* debian/control:
  - update maintainer
  - remove vde2 recommends
  - build-deps: remove libusbredir, libvdeplug2-dev,
    libspice-server-dev, libspice-protocol-dev, libiscsi-dev,
    and libxen-dev.
  - qemu-keymaps: break/replace qemu-common
  - qemu-system:
    - break/replace qemu-common
    - depend on udev
    - remove openbios-ppc, openbios-sparc, and openhackware from
      Depends.  (Intend to add them back once we can build them.)
    - provides: qemu-kvm
  - qemu-utils: break/replace qemu-kvm
  - set up transitional packages for qemu-kvm, qemu-common, and kvm.
* debian/rules:
  - install kvm-ifup and kvm-ifdown
  - dh_installinit the qemu-kvm upstart job
* install a 30-qemu-kvm.conf into /etc/sysctl.c for nr_hugepages.
* qemu-kvm.upstart:
  - add qemu-system.qemu-kvm.upstart
  - add mv_confile to qemu-system.preinst, postinst, and .postrm to rename
    /etc/init/qemu-kvm.conf to qemu-system.conf
  - debian/rules: add dh_installinit to get qemu-system.upstart installed.
  - take the defaults from the old qemu-kvm.defaults, and move them into
    the upstart job
* debian/patches:
  - apply gridcentric patches from lp:~amscanne/+junk/gridcentric-qemu-patches
  - apply arm patches from git://git.linaro.org/qemu/qemu-linaro.git
  - apply nbd-fixes-to-read-only-handling.patch from upstream to
    make read-write mount after read-only mount work.  (LP: #1077838)
* ifup/down:
  - copy Ubuntu qemu-kvm's kvm-ifup/down into debian/
  - fix dh_install for kvm-ifup/down in debian/rules
  - add links for qemu-ifup/down in qemu-system.links
  - remove (debian's original) qemu-ifup from qemu-system.install
* debian/qemu-system.postinst
  - udevadm trigger to fix up /dev/kvm perms
  - make the 'qemu' symlink point to qemu-system-x86_64, not -i386.
* debian/qemu-system.links:
  - point 'kvm' to qemu-system-x86_64
  - remove pxe-virtio, pxe-e1000 and pxe-rtl8139 links (which conflict
    with ones from kvm-ipxe).  We may want to move the links from kvm-ipxe
    back to qemu-system at some point.
  - add qemu-ifdown and qemu-ifup links
* debian/qemu-system.install:
  - remove /etc/qemu-ifup link
  - add /etc/sysctl.d/30-qemu-kvm.conf

[ Adam Conrad ]
* Appease apt-get's dist-upgrade resolver by creating a qemu-common
  transitional package to upgrade more gracefully to qemu-keymaps.
* Move all the empty transitional packages to the oldlibs section. 
* Restore the versioned dep from qemu-kvm (and kvm) to qemu-system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * ARM Versatile/PB PCI host controller
3
3
 *
4
 
 * Copyright (c) 2006 CodeSourcery.
 
4
 * Copyright (c) 2006-2009 CodeSourcery.
5
5
 * Written by Paul Brook
6
6
 *
7
 
 * This code is licenced under the LGPL.
 
7
 * This code is licensed under the LGPL.
8
8
 */
9
9
 
10
 
#include "hw.h"
 
10
#include "sysbus.h"
11
11
#include "pci.h"
12
 
#include "primecell.h"
 
12
#include "pci_host.h"
 
13
#include "exec-memory.h"
 
14
 
 
15
typedef struct {
 
16
    SysBusDevice busdev;
 
17
    qemu_irq irq[4];
 
18
    int realview;
 
19
    MemoryRegion mem_config;
 
20
    MemoryRegion mem_config2;
 
21
    MemoryRegion isa;
 
22
} PCIVPBState;
13
23
 
14
24
static inline uint32_t vpb_pci_config_addr(target_phys_addr_t addr)
15
25
{
16
26
    return addr & 0xffffff;
17
27
}
18
28
 
19
 
static void pci_vpb_config_writeb (void *opaque, target_phys_addr_t addr,
20
 
                                   uint32_t val)
21
 
{
22
 
    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 1);
23
 
}
24
 
 
25
 
static void pci_vpb_config_writew (void *opaque, target_phys_addr_t addr,
26
 
                                   uint32_t val)
27
 
{
28
 
#ifdef TARGET_WORDS_BIGENDIAN
29
 
    val = bswap16(val);
30
 
#endif
31
 
    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 2);
32
 
}
33
 
 
34
 
static void pci_vpb_config_writel (void *opaque, target_phys_addr_t addr,
35
 
                                   uint32_t val)
36
 
{
37
 
#ifdef TARGET_WORDS_BIGENDIAN
38
 
    val = bswap32(val);
39
 
#endif
40
 
    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 4);
41
 
}
42
 
 
43
 
static uint32_t pci_vpb_config_readb (void *opaque, target_phys_addr_t addr)
44
 
{
45
 
    uint32_t val;
46
 
    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 1);
47
 
    return val;
48
 
}
49
 
 
50
 
static uint32_t pci_vpb_config_readw (void *opaque, target_phys_addr_t addr)
51
 
{
52
 
    uint32_t val;
53
 
    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 2);
54
 
#ifdef TARGET_WORDS_BIGENDIAN
55
 
    val = bswap16(val);
56
 
#endif
57
 
    return val;
58
 
}
59
 
 
60
 
static uint32_t pci_vpb_config_readl (void *opaque, target_phys_addr_t addr)
61
 
{
62
 
    uint32_t val;
63
 
    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 4);
64
 
#ifdef TARGET_WORDS_BIGENDIAN
65
 
    val = bswap32(val);
66
 
#endif
67
 
    return val;
68
 
}
69
 
 
70
 
static CPUWriteMemoryFunc *pci_vpb_config_write[] = {
71
 
    &pci_vpb_config_writeb,
72
 
    &pci_vpb_config_writew,
73
 
    &pci_vpb_config_writel,
74
 
};
75
 
 
76
 
static CPUReadMemoryFunc *pci_vpb_config_read[] = {
77
 
    &pci_vpb_config_readb,
78
 
    &pci_vpb_config_readw,
79
 
    &pci_vpb_config_readl,
80
 
};
81
 
 
82
 
static int pci_vpb_irq;
 
29
static void pci_vpb_config_write(void *opaque, target_phys_addr_t addr,
 
30
                                 uint64_t val, unsigned size)
 
31
{
 
32
    pci_data_write(opaque, vpb_pci_config_addr(addr), val, size);
 
33
}
 
34
 
 
35
static uint64_t pci_vpb_config_read(void *opaque, target_phys_addr_t addr,
 
36
                                    unsigned size)
 
37
{
 
38
    uint32_t val;
 
39
    val = pci_data_read(opaque, vpb_pci_config_addr(addr), size);
 
40
    return val;
 
41
}
 
42
 
 
43
static const MemoryRegionOps pci_vpb_config_ops = {
 
44
    .read = pci_vpb_config_read,
 
45
    .write = pci_vpb_config_write,
 
46
    .endianness = DEVICE_NATIVE_ENDIAN,
 
47
};
83
48
 
84
49
static int pci_vpb_map_irq(PCIDevice *d, int irq_num)
85
50
{
86
51
    return irq_num;
87
52
}
88
53
 
89
 
static void pci_vpb_set_irq(qemu_irq *pic, int irq_num, int level)
 
54
static void pci_vpb_set_irq(void *opaque, int irq_num, int level)
90
55
{
91
 
    qemu_set_irq(pic[pci_vpb_irq + irq_num], level);
 
56
    qemu_irq *pic = opaque;
 
57
 
 
58
    qemu_set_irq(pic[irq_num], level);
92
59
}
93
60
 
94
 
PCIBus *pci_vpb_init(qemu_irq *pic, int irq, int realview)
 
61
static int pci_vpb_init(SysBusDevice *dev)
95
62
{
96
 
    PCIBus *s;
97
 
    PCIDevice *d;
98
 
    int mem_config;
99
 
    uint32_t base;
100
 
    const char * name;
 
63
    PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev);
 
64
    PCIBus *bus;
 
65
    int i;
101
66
 
102
 
    pci_vpb_irq = irq;
103
 
    if (realview) {
104
 
        base = 0x60000000;
105
 
        name = "RealView EB PCI Controller";
106
 
    } else {
107
 
        base = 0x40000000;
108
 
        name = "Versatile/PB PCI Controller";
 
67
    for (i = 0; i < 4; i++) {
 
68
        sysbus_init_irq(dev, &s->irq[i]);
109
69
    }
110
 
    s = pci_register_bus(pci_vpb_set_irq, pci_vpb_map_irq, pic, 11 << 3, 4);
 
70
    bus = pci_register_bus(&dev->qdev, "pci",
 
71
                           pci_vpb_set_irq, pci_vpb_map_irq, s->irq,
 
72
                           get_system_memory(), get_system_io(),
 
73
                           PCI_DEVFN(11, 0), 4);
 
74
 
111
75
    /* ??? Register memory space.  */
112
76
 
113
 
    mem_config = cpu_register_io_memory(0, pci_vpb_config_read,
114
 
                                        pci_vpb_config_write, s);
115
 
    /* Selfconfig area.  */
116
 
    cpu_register_physical_memory(base + 0x01000000, 0x1000000, mem_config);
117
 
    /* Normal config area.  */
118
 
    cpu_register_physical_memory(base + 0x02000000, 0x1000000, mem_config);
119
 
 
120
 
    d = pci_register_device(s, name, sizeof(PCIDevice), -1, NULL, NULL);
121
 
 
122
 
    if (realview) {
123
 
        /* IO memory area.  */
124
 
        isa_mmio_init(base + 0x03000000, 0x00100000);
 
77
    /* Our memory regions are:
 
78
     * 0 : PCI self config window
 
79
     * 1 : PCI config window
 
80
     * 2 : PCI IO window (realview_pci only)
 
81
     */
 
82
    memory_region_init_io(&s->mem_config, &pci_vpb_config_ops, bus,
 
83
                          "pci-vpb-selfconfig", 0x1000000);
 
84
    sysbus_init_mmio(dev, &s->mem_config);
 
85
    memory_region_init_io(&s->mem_config2, &pci_vpb_config_ops, bus,
 
86
                          "pci-vpb-config", 0x1000000);
 
87
    sysbus_init_mmio(dev, &s->mem_config2);
 
88
    if (s->realview) {
 
89
        isa_mmio_setup(&s->isa, 0x0100000);
 
90
        sysbus_init_mmio(dev, &s->isa);
125
91
    }
126
92
 
127
 
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_XILINX);
128
 
    /* Both boards have the same device ID.  Oh well.  */
129
 
    pci_config_set_device_id(d->config, 0x0300); // device_id
130
 
    d->config[0x04] = 0x00;
131
 
    d->config[0x05] = 0x00;
132
 
    d->config[0x06] = 0x20;
133
 
    d->config[0x07] = 0x02;
134
 
    d->config[0x08] = 0x00; // revision
135
 
    d->config[0x09] = 0x00; // programming i/f
136
 
    pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_CO);
137
 
    d->config[0x0D] = 0x10; // latency_timer
138
 
 
139
 
    return s;
140
 
}
 
93
    pci_create_simple(bus, -1, "versatile_pci_host");
 
94
    return 0;
 
95
}
 
96
 
 
97
static int pci_realview_init(SysBusDevice *dev)
 
98
{
 
99
    PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev);
 
100
    s->realview = 1;
 
101
    return pci_vpb_init(dev);
 
102
}
 
103
 
 
104
static int versatile_pci_host_init(PCIDevice *d)
 
105
{
 
106
    pci_set_word(d->config + PCI_STATUS,
 
107
                 PCI_STATUS_66MHZ | PCI_STATUS_DEVSEL_MEDIUM);
 
108
    pci_set_byte(d->config + PCI_LATENCY_TIMER, 0x10);
 
109
    return 0;
 
110
}
 
111
 
 
112
static void versatile_pci_host_class_init(ObjectClass *klass, void *data)
 
113
{
 
114
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
115
 
 
116
    k->init = versatile_pci_host_init;
 
117
    k->vendor_id = PCI_VENDOR_ID_XILINX;
 
118
    k->device_id = PCI_DEVICE_ID_XILINX_XC2VP30;
 
119
    k->class_id = PCI_CLASS_PROCESSOR_CO;
 
120
}
 
121
 
 
122
static TypeInfo versatile_pci_host_info = {
 
123
    .name          = "versatile_pci_host",
 
124
    .parent        = TYPE_PCI_DEVICE,
 
125
    .instance_size = sizeof(PCIDevice),
 
126
    .class_init    = versatile_pci_host_class_init,
 
127
};
 
128
 
 
129
static void pci_vpb_class_init(ObjectClass *klass, void *data)
 
130
{
 
131
    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
 
132
 
 
133
    sdc->init = pci_vpb_init;
 
134
}
 
135
 
 
136
static TypeInfo pci_vpb_info = {
 
137
    .name          = "versatile_pci",
 
138
    .parent        = TYPE_SYS_BUS_DEVICE,
 
139
    .instance_size = sizeof(PCIVPBState),
 
140
    .class_init    = pci_vpb_class_init,
 
141
};
 
142
 
 
143
static void pci_realview_class_init(ObjectClass *klass, void *data)
 
144
{
 
145
    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
 
146
 
 
147
    sdc->init = pci_realview_init;
 
148
}
 
149
 
 
150
static TypeInfo pci_realview_info = {
 
151
    .name          = "realview_pci",
 
152
    .parent        = TYPE_SYS_BUS_DEVICE,
 
153
    .instance_size = sizeof(PCIVPBState),
 
154
    .class_init    = pci_realview_class_init,
 
155
};
 
156
 
 
157
static void versatile_pci_register_types(void)
 
158
{
 
159
    type_register_static(&pci_vpb_info);
 
160
    type_register_static(&pci_realview_info);
 
161
    type_register_static(&versatile_pci_host_info);
 
162
}
 
163
 
 
164
type_init(versatile_pci_register_types)