2006-05-13 18:11:23 +02:00
|
|
|
/*
|
|
|
|
* QEMU PREP PCI host
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Fabrice Bellard
|
2012-05-26 19:14:52 +02:00
|
|
|
* Copyright (c) 2011-2013 Andreas Färber
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2006-05-13 18:11:23 +02:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/hw.h"
|
|
|
|
#include "hw/pci/pci.h"
|
|
|
|
#include "hw/pci/pci_bus.h"
|
|
|
|
#include "hw/pci/pci_host.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/i386/pc.h"
|
2013-11-05 00:09:45 +01:00
|
|
|
#include "hw/loader.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/address-spaces.h"
|
2013-11-05 00:09:45 +01:00
|
|
|
#include "elf.h"
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2012-05-26 19:14:52 +02:00
|
|
|
#define TYPE_RAVEN_PCI_DEVICE "raven"
|
2012-08-20 19:08:04 +02:00
|
|
|
#define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost"
|
|
|
|
|
2012-05-26 19:14:52 +02:00
|
|
|
#define RAVEN_PCI_DEVICE(obj) \
|
|
|
|
OBJECT_CHECK(RavenPCIState, (obj), TYPE_RAVEN_PCI_DEVICE)
|
|
|
|
|
|
|
|
typedef struct RavenPCIState {
|
|
|
|
PCIDevice dev;
|
2013-11-05 00:09:45 +01:00
|
|
|
|
|
|
|
uint32_t elf_machine;
|
|
|
|
char *bios_name;
|
|
|
|
MemoryRegion bios;
|
2012-05-26 19:14:52 +02:00
|
|
|
} RavenPCIState;
|
|
|
|
|
2012-08-20 19:08:04 +02:00
|
|
|
#define RAVEN_PCI_HOST_BRIDGE(obj) \
|
|
|
|
OBJECT_CHECK(PREPPCIState, (obj), TYPE_RAVEN_PCI_HOST_BRIDGE)
|
|
|
|
|
2012-01-03 02:42:46 +01:00
|
|
|
typedef struct PRePPCIState {
|
2012-08-20 19:08:09 +02:00
|
|
|
PCIHostState parent_obj;
|
2012-08-20 19:08:04 +02:00
|
|
|
|
2013-11-05 00:09:44 +01:00
|
|
|
qemu_irq irq[PCI_NUM_PINS];
|
2012-05-26 19:14:52 +02:00
|
|
|
PCIBus pci_bus;
|
2014-03-17 23:00:20 +01:00
|
|
|
AddressSpace pci_io_as;
|
2014-03-17 23:00:21 +01:00
|
|
|
MemoryRegion pci_io;
|
2014-03-17 23:00:20 +01:00
|
|
|
MemoryRegion pci_io_non_contiguous;
|
2014-03-17 23:00:22 +01:00
|
|
|
MemoryRegion pci_memory;
|
2014-03-17 23:00:19 +01:00
|
|
|
MemoryRegion pci_intack;
|
2014-03-17 23:00:23 +01:00
|
|
|
MemoryRegion bm;
|
|
|
|
MemoryRegion bm_ram_alias;
|
|
|
|
MemoryRegion bm_pci_memory_alias;
|
|
|
|
AddressSpace bm_as;
|
2012-05-26 19:14:52 +02:00
|
|
|
RavenPCIState pci_dev;
|
2014-03-17 23:00:20 +01:00
|
|
|
|
|
|
|
int contiguous_map;
|
2012-01-03 02:42:46 +01:00
|
|
|
} PREPPCIState;
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2013-11-05 00:09:45 +01:00
|
|
|
#define BIOS_SIZE (1024 * 1024)
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static inline uint32_t PPC_PCIIO_config(hwaddr addr)
|
2006-05-13 18:11:23 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-08-20 19:08:04 +02:00
|
|
|
for (i = 0; i < 11; i++) {
|
|
|
|
if ((addr & (1 << (11 + i))) != 0) {
|
2006-05-13 18:11:23 +02:00
|
|
|
break;
|
2012-08-20 19:08:04 +02:00
|
|
|
}
|
2006-05-13 18:11:23 +02:00
|
|
|
}
|
|
|
|
return (addr & 0x7ff) | (i << 11);
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void ppc_pci_io_write(void *opaque, hwaddr addr,
|
2012-01-07 08:28:53 +01:00
|
|
|
uint64_t val, unsigned int size)
|
2006-05-13 18:11:23 +02:00
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
2012-08-20 19:08:09 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s);
|
|
|
|
pci_data_write(phb->bus, PPC_PCIIO_config(addr), val, size);
|
2006-05-13 18:11:23 +02:00
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t ppc_pci_io_read(void *opaque, hwaddr addr,
|
2012-01-07 08:28:53 +01:00
|
|
|
unsigned int size)
|
2006-05-13 18:11:23 +02:00
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
2012-08-20 19:08:09 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s);
|
|
|
|
return pci_data_read(phb->bus, PPC_PCIIO_config(addr), size);
|
2006-05-13 18:11:23 +02:00
|
|
|
}
|
|
|
|
|
2011-11-21 16:16:57 +01:00
|
|
|
static const MemoryRegionOps PPC_PCIIO_ops = {
|
2012-01-07 08:28:53 +01:00
|
|
|
.read = ppc_pci_io_read,
|
|
|
|
.write = ppc_pci_io_write,
|
2012-01-12 03:44:42 +01:00
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
2006-05-13 18:11:23 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t ppc_intack_read(void *opaque, hwaddr addr,
|
2012-04-14 22:48:37 +02:00
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
return pic_read_irq(isa_pic);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps PPC_intack_ops = {
|
|
|
|
.read = ppc_intack_read,
|
|
|
|
.valid = {
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2014-03-17 23:00:20 +01:00
|
|
|
static inline hwaddr raven_io_address(PREPPCIState *s,
|
|
|
|
hwaddr addr)
|
|
|
|
{
|
|
|
|
if (s->contiguous_map == 0) {
|
|
|
|
/* 64 KB contiguous space for IOs */
|
|
|
|
addr &= 0xFFFF;
|
|
|
|
} else {
|
|
|
|
/* 8 MB non-contiguous space for IOs */
|
|
|
|
addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: handle endianness switch */
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t raven_io_read(void *opaque, hwaddr addr,
|
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
|
|
|
uint8_t buf[4];
|
|
|
|
|
|
|
|
addr = raven_io_address(s, addr);
|
2014-03-17 23:00:21 +01:00
|
|
|
address_space_read(&s->pci_io_as, addr + 0x80000000, buf, size);
|
2014-03-17 23:00:20 +01:00
|
|
|
|
|
|
|
if (size == 1) {
|
|
|
|
return buf[0];
|
|
|
|
} else if (size == 2) {
|
|
|
|
return lduw_p(buf);
|
|
|
|
} else if (size == 4) {
|
|
|
|
return ldl_p(buf);
|
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void raven_io_write(void *opaque, hwaddr addr,
|
|
|
|
uint64_t val, unsigned int size)
|
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
|
|
|
uint8_t buf[4];
|
|
|
|
|
|
|
|
addr = raven_io_address(s, addr);
|
|
|
|
|
|
|
|
if (size == 1) {
|
|
|
|
buf[0] = val;
|
|
|
|
} else if (size == 2) {
|
|
|
|
stw_p(buf, val);
|
|
|
|
} else if (size == 4) {
|
|
|
|
stl_p(buf, val);
|
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
2014-03-17 23:00:21 +01:00
|
|
|
address_space_write(&s->pci_io_as, addr + 0x80000000, buf, size);
|
2014-03-17 23:00:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps raven_io_ops = {
|
|
|
|
.read = raven_io_read,
|
|
|
|
.write = raven_io_write,
|
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
|
.impl.max_access_size = 4,
|
|
|
|
.valid.unaligned = true,
|
|
|
|
};
|
|
|
|
|
2006-09-24 02:16:34 +02:00
|
|
|
static int prep_map_irq(PCIDevice *pci_dev, int irq_num)
|
2006-05-13 18:11:23 +02:00
|
|
|
{
|
2006-09-24 19:01:44 +02:00
|
|
|
return (irq_num + (pci_dev->devfn >> 3)) & 1;
|
2006-09-24 02:16:34 +02:00
|
|
|
}
|
|
|
|
|
2009-08-28 15:28:17 +02:00
|
|
|
static void prep_set_irq(void *opaque, int irq_num, int level)
|
2006-09-24 02:16:34 +02:00
|
|
|
{
|
2009-08-28 15:28:17 +02:00
|
|
|
qemu_irq *pic = opaque;
|
|
|
|
|
2012-01-03 02:42:46 +01:00
|
|
|
qemu_set_irq(pic[irq_num] , level);
|
2006-05-13 18:11:23 +02:00
|
|
|
}
|
|
|
|
|
2014-03-17 23:00:23 +01:00
|
|
|
static AddressSpace *raven_pcihost_set_iommu(PCIBus *bus, void *opaque,
|
|
|
|
int devfn)
|
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
|
|
|
|
|
|
|
return &s->bm_as;
|
|
|
|
}
|
|
|
|
|
2014-03-17 23:00:20 +01:00
|
|
|
static void raven_change_gpio(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
PREPPCIState *s = opaque;
|
|
|
|
|
|
|
|
s->contiguous_map = level;
|
|
|
|
}
|
|
|
|
|
2013-01-16 15:45:34 +01:00
|
|
|
static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
|
2006-05-13 18:11:23 +02:00
|
|
|
{
|
2013-01-16 15:45:34 +01:00
|
|
|
SysBusDevice *dev = SYS_BUS_DEVICE(d);
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(dev);
|
2012-08-20 19:08:04 +02:00
|
|
|
PREPPCIState *s = RAVEN_PCI_HOST_BRIDGE(dev);
|
2012-01-03 02:42:46 +01:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
|
|
|
int i;
|
|
|
|
|
2013-11-05 00:09:44 +01:00
|
|
|
for (i = 0; i < PCI_NUM_PINS; i++) {
|
2012-01-03 02:42:46 +01:00
|
|
|
sysbus_init_irq(dev, &s->irq[i]);
|
|
|
|
}
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2014-03-17 23:00:20 +01:00
|
|
|
qdev_init_gpio_in(d, raven_change_gpio, 1);
|
|
|
|
|
2013-11-05 00:09:44 +01:00
|
|
|
pci_bus_irqs(&s->pci_bus, prep_set_irq, prep_map_irq, s->irq, PCI_NUM_PINS);
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_be_ops, s,
|
2011-07-24 16:47:18 +02:00
|
|
|
"pci-conf-idx", 1);
|
2014-03-17 23:00:21 +01:00
|
|
|
memory_region_add_subregion(&s->pci_io, 0xcf8, &h->conf_mem);
|
2011-07-24 16:47:18 +02:00
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_be_ops, s,
|
2011-07-24 16:47:18 +02:00
|
|
|
"pci-conf-data", 1);
|
2014-03-17 23:00:21 +01:00
|
|
|
memory_region_add_subregion(&s->pci_io, 0xcfc, &h->data_mem);
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&h->mmcfg, OBJECT(s), &PPC_PCIIO_ops, s, "pciio", 0x00400000);
|
2012-01-03 02:42:46 +01:00
|
|
|
memory_region_add_subregion(address_space_mem, 0x80800000, &h->mmcfg);
|
2006-05-13 18:11:23 +02:00
|
|
|
|
2014-03-17 23:00:19 +01:00
|
|
|
memory_region_init_io(&s->pci_intack, OBJECT(s), &PPC_intack_ops, s,
|
|
|
|
"pci-intack", 1);
|
|
|
|
memory_region_add_subregion(address_space_mem, 0xbffffff0, &s->pci_intack);
|
2012-01-03 01:50:07 +01:00
|
|
|
|
2012-05-26 19:14:52 +02:00
|
|
|
/* TODO Remove once realize propagates to child devices. */
|
2013-01-16 15:45:34 +01:00
|
|
|
object_property_set_bool(OBJECT(&s->pci_dev), true, "realized", errp);
|
2012-05-26 19:14:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void raven_pcihost_initfn(Object *obj)
|
|
|
|
{
|
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(obj);
|
|
|
|
PREPPCIState *s = RAVEN_PCI_HOST_BRIDGE(obj);
|
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
|
|
|
DeviceState *pci_dev;
|
|
|
|
|
2014-03-17 23:00:21 +01:00
|
|
|
memory_region_init(&s->pci_io, obj, "pci-io", 0x3f800000);
|
2014-03-17 23:00:20 +01:00
|
|
|
memory_region_init_io(&s->pci_io_non_contiguous, obj, &raven_io_ops, s,
|
|
|
|
"pci-io-non-contiguous", 0x00800000);
|
2014-03-17 23:00:22 +01:00
|
|
|
/* Open Hack'Ware hack: real size should be only 0x3f000000 bytes */
|
|
|
|
memory_region_init(&s->pci_memory, obj, "pci-memory",
|
|
|
|
0x3f000000 + 0xc0000000ULL);
|
2014-03-17 23:00:21 +01:00
|
|
|
address_space_init(&s->pci_io_as, &s->pci_io, "raven-io");
|
2014-03-17 23:00:20 +01:00
|
|
|
|
|
|
|
/* CPU address space */
|
2014-03-17 23:00:21 +01:00
|
|
|
memory_region_add_subregion(address_space_mem, 0x80000000, &s->pci_io);
|
2014-03-17 23:00:20 +01:00
|
|
|
memory_region_add_subregion_overlap(address_space_mem, 0x80000000,
|
|
|
|
&s->pci_io_non_contiguous, 1);
|
2014-03-17 23:00:22 +01:00
|
|
|
memory_region_add_subregion(address_space_mem, 0xc0000000, &s->pci_memory);
|
2013-08-23 20:23:55 +02:00
|
|
|
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), NULL,
|
2014-03-17 23:00:22 +01:00
|
|
|
&s->pci_memory, &s->pci_io, 0, TYPE_PCI_BUS);
|
2014-03-17 23:00:21 +01:00
|
|
|
|
2014-03-17 23:00:23 +01:00
|
|
|
/* Bus master address space */
|
|
|
|
memory_region_init(&s->bm, obj, "bm-raven", UINT32_MAX);
|
|
|
|
memory_region_init_alias(&s->bm_pci_memory_alias, obj, "bm-pci-memory",
|
|
|
|
&s->pci_memory, 0,
|
|
|
|
memory_region_size(&s->pci_memory));
|
|
|
|
memory_region_init_alias(&s->bm_ram_alias, obj, "bm-system",
|
|
|
|
get_system_memory(), 0, 0x80000000);
|
|
|
|
memory_region_add_subregion(&s->bm, 0 , &s->bm_pci_memory_alias);
|
|
|
|
memory_region_add_subregion(&s->bm, 0x80000000, &s->bm_ram_alias);
|
|
|
|
address_space_init(&s->bm_as, &s->bm, "raven-bm");
|
|
|
|
pci_setup_iommu(&s->pci_bus, raven_pcihost_set_iommu, s);
|
|
|
|
|
2012-05-26 19:14:52 +02:00
|
|
|
h->bus = &s->pci_bus;
|
|
|
|
|
2013-08-23 19:37:12 +02:00
|
|
|
object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE);
|
2012-05-26 19:14:52 +02:00
|
|
|
pci_dev = DEVICE(&s->pci_dev);
|
|
|
|
qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus));
|
|
|
|
object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr",
|
|
|
|
NULL);
|
|
|
|
qdev_prop_set_bit(pci_dev, "multifunction", false);
|
2012-01-03 01:50:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int raven_init(PCIDevice *d)
|
|
|
|
{
|
2013-11-05 00:09:45 +01:00
|
|
|
RavenPCIState *s = RAVEN_PCI_DEVICE(d);
|
|
|
|
char *filename;
|
|
|
|
int bios_size = -1;
|
|
|
|
|
2006-05-13 18:11:23 +02:00
|
|
|
d->config[0x0C] = 0x08; // cache_line_size
|
|
|
|
d->config[0x0D] = 0x10; // latency_timer
|
|
|
|
d->config[0x34] = 0x00; // capabilities_pointer
|
|
|
|
|
2013-11-05 00:09:45 +01:00
|
|
|
memory_region_init_ram(&s->bios, OBJECT(s), "bios", BIOS_SIZE);
|
|
|
|
memory_region_set_readonly(&s->bios, true);
|
|
|
|
memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),
|
|
|
|
&s->bios);
|
|
|
|
vmstate_register_ram_global(&s->bios);
|
|
|
|
if (s->bios_name) {
|
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name);
|
|
|
|
if (filename) {
|
|
|
|
if (s->elf_machine != EM_NONE) {
|
|
|
|
bios_size = load_elf(filename, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, 1, s->elf_machine, 0);
|
|
|
|
}
|
|
|
|
if (bios_size < 0) {
|
|
|
|
bios_size = get_image_size(filename);
|
|
|
|
if (bios_size > 0 && bios_size <= BIOS_SIZE) {
|
|
|
|
hwaddr bios_addr;
|
|
|
|
bios_size = (bios_size + 0xfff) & ~0xfff;
|
|
|
|
bios_addr = (uint32_t)(-BIOS_SIZE);
|
|
|
|
bios_size = load_image_targphys(filename, bios_addr,
|
|
|
|
bios_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bios_size < 0 || bios_size > BIOS_SIZE) {
|
|
|
|
hw_error("qemu: could not load bios image '%s'\n", s->bios_name);
|
|
|
|
}
|
|
|
|
if (filename) {
|
|
|
|
g_free(filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-03 01:50:07 +01:00
|
|
|
return 0;
|
2006-05-13 18:11:23 +02:00
|
|
|
}
|
2012-01-03 01:50:07 +01:00
|
|
|
|
|
|
|
static const VMStateDescription vmstate_raven = {
|
|
|
|
.name = "raven",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_PCI_DEVICE(dev, RavenPCIState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void raven_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
|
|
|
|
k->init = raven_init;
|
|
|
|
k->vendor_id = PCI_VENDOR_ID_MOTOROLA;
|
|
|
|
k->device_id = PCI_DEVICE_ID_MOTOROLA_RAVEN;
|
|
|
|
k->revision = 0x00;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->desc = "PReP Host Bridge - Motorola Raven";
|
|
|
|
dc->vmsd = &vmstate_raven;
|
pci-host: Consistently set cannot_instantiate_with_device_add_yet
Many PCI host bridges consist of a sysbus device and a PCI device.
You need both for the thing to work. Arguably, these bridges should
be modelled as a single, composite devices instead of pairs of
seemingly independent devices you can only use together, but we're not
there, yet.
Since the sysbus part can't be instantiated with device_add, yet,
permitting it with the PCI part is useless. We shouldn't offer
useless options to the user, so let's set
cannot_instantiate_with_device_add_yet for them.
It's already set for Bonito, Grackle, i440FX and Raven. Document why.
Set it for the others: dec-21154, e500-host-bridge, gt64120_pci, mch,
pbm-pci, ppc4xx-host-bridge, sh_pci_host, u3-agp, uni-north-agp,
uni-north-internal-pci, uni-north-pci, and versatile_pci_host.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-28 17:26:58 +01:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
|
|
|
dc->cannot_instantiate_with_device_add_yet = true;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo raven_info = {
|
2012-05-26 19:14:52 +02:00
|
|
|
.name = TYPE_RAVEN_PCI_DEVICE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(RavenPCIState),
|
2011-12-04 19:22:06 +01:00
|
|
|
.class_init = raven_class_init,
|
2012-01-03 01:50:07 +01:00
|
|
|
};
|
|
|
|
|
2013-11-05 00:09:45 +01:00
|
|
|
static Property raven_pcihost_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
|
|
|
|
EM_NONE),
|
|
|
|
DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static void raven_pcihost_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2013-07-29 16:17:45 +02:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2013-01-16 15:45:34 +01:00
|
|
|
dc->realize = raven_pcihost_realizefn;
|
2013-11-05 00:09:45 +01:00
|
|
|
dc->props = raven_pcihost_properties;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->fw_name = "pci";
|
2012-01-24 20:12:29 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo raven_pcihost_info = {
|
2012-08-20 19:08:04 +02:00
|
|
|
.name = TYPE_RAVEN_PCI_HOST_BRIDGE,
|
2012-08-20 19:08:08 +02:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.instance_size = sizeof(PREPPCIState),
|
2012-05-26 19:14:52 +02:00
|
|
|
.instance_init = raven_pcihost_initfn,
|
2012-01-24 20:12:29 +01:00
|
|
|
.class_init = raven_pcihost_class_init,
|
2012-01-03 02:42:46 +01:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void raven_register_types(void)
|
2012-01-03 01:50:07 +01:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&raven_pcihost_info);
|
|
|
|
type_register_static(&raven_info);
|
2012-01-03 01:50:07 +01:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(raven_register_types)
|