2006-05-13 20:11:23 +04:00
|
|
|
/*
|
|
|
|
* QEMU Uninorth PCI host (for all Mac99 and newer machines)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Fabrice Bellard
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2006-05-13 20:11:23 +04: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.
|
|
|
|
*/
|
2019-05-23 17:35:07 +03:00
|
|
|
|
2016-01-26 21:16:58 +03:00
|
|
|
#include "qemu/osdep.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/ppc/mac.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/pci/pci.h"
|
|
|
|
#include "hw/pci/pci_host.h"
|
2018-03-06 23:30:49 +03:00
|
|
|
#include "hw/pci-host/uninorth.h"
|
2018-01-26 12:20:28 +03:00
|
|
|
#include "trace.h"
|
2009-02-05 23:22:07 +03:00
|
|
|
|
2010-02-09 19:37:04 +03:00
|
|
|
static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
|
|
|
|
|
2006-09-24 04:16:34 +04:00
|
|
|
static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
|
2006-05-13 20:11:23 +04:00
|
|
|
{
|
2016-11-20 17:12:31 +03:00
|
|
|
return (irq_num + (pci_dev->devfn >> 3)) & 3;
|
2006-09-24 04:16:34 +04:00
|
|
|
}
|
|
|
|
|
2009-08-28 17:28:17 +04:00
|
|
|
static void pci_unin_set_irq(void *opaque, int irq_num, int level)
|
2006-09-24 04:16:34 +04:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = opaque;
|
2009-08-28 17:28:17 +04:00
|
|
|
|
2018-01-26 12:20:28 +03:00
|
|
|
trace_unin_set_irq(unin_irq_line[irq_num], level);
|
2018-03-06 23:30:58 +03:00
|
|
|
qemu_set_irq(s->irqs[irq_num], level);
|
2006-05-13 20:11:23 +04:00
|
|
|
}
|
|
|
|
|
2010-02-09 19:37:01 +03:00
|
|
|
static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
|
|
|
|
{
|
|
|
|
uint32_t retval;
|
|
|
|
|
|
|
|
if (reg & (1u << 31)) {
|
|
|
|
/* XXX OpenBIOS compatibility hack */
|
|
|
|
retval = reg | (addr & 3);
|
|
|
|
} else if (reg & 1) {
|
|
|
|
/* CFA1 style */
|
|
|
|
retval = (reg & ~7u) | (addr & 7);
|
|
|
|
} else {
|
|
|
|
uint32_t slot, func;
|
|
|
|
|
|
|
|
/* Grab CFA0 style values */
|
2015-03-23 18:29:25 +03:00
|
|
|
slot = ctz32(reg & 0xfffff800);
|
|
|
|
if (slot == 32) {
|
|
|
|
slot = -1; /* XXX: should this be 0? */
|
|
|
|
}
|
2010-02-09 19:37:01 +03:00
|
|
|
func = (reg >> 8) & 7;
|
|
|
|
|
|
|
|
/* ... and then convert them to x86 format */
|
|
|
|
/* config pointer */
|
|
|
|
retval = (reg & (0xff - 7)) | (addr & 7);
|
|
|
|
/* slot */
|
|
|
|
retval |= slot << 11;
|
|
|
|
/* fn */
|
|
|
|
retval |= func << 8;
|
|
|
|
}
|
|
|
|
|
2018-01-26 12:20:28 +03:00
|
|
|
trace_unin_get_config_reg(reg, addr, retval);
|
2010-02-09 19:37:01 +03:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void unin_data_write(void *opaque, hwaddr addr,
|
2011-07-24 18:47:18 +04:00
|
|
|
uint64_t val, unsigned len)
|
2010-02-09 19:37:01 +03:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = opaque;
|
2012-08-20 21:08:09 +04:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s);
|
2018-01-26 12:20:28 +03:00
|
|
|
trace_unin_data_write(addr, len, val);
|
2012-08-20 21:08:09 +04:00
|
|
|
pci_data_write(phb->bus,
|
|
|
|
unin_get_config_reg(phb->config_reg, addr),
|
2010-02-09 19:37:01 +03:00
|
|
|
val, len);
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint64_t unin_data_read(void *opaque, hwaddr addr,
|
2011-07-24 18:47:18 +04:00
|
|
|
unsigned len)
|
2010-02-09 19:37:01 +03:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = opaque;
|
2012-08-20 21:08:09 +04:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s);
|
2010-02-09 19:37:01 +03:00
|
|
|
uint32_t val;
|
|
|
|
|
2012-08-20 21:08:09 +04:00
|
|
|
val = pci_data_read(phb->bus,
|
|
|
|
unin_get_config_reg(phb->config_reg, addr),
|
2010-02-09 19:37:01 +03:00
|
|
|
len);
|
2018-01-26 12:20:28 +03:00
|
|
|
trace_unin_data_read(addr, len, val);
|
2010-02-09 19:37:01 +03:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-07-24 18:47:18 +04:00
|
|
|
static const MemoryRegionOps unin_data_ops = {
|
|
|
|
.read = unin_data_read,
|
|
|
|
.write = unin_data_write,
|
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
|
};
|
|
|
|
|
2018-03-06 23:31:00 +03:00
|
|
|
static void pci_unin_init_irqs(UNINHostState *s)
|
2018-03-06 23:30:58 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(s->irqs); i++) {
|
|
|
|
s->irqs[i] = qdev_get_gpio_in(DEVICE(s->pic), unin_irq_line[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-29 19:59:10 +03:00
|
|
|
static char *pci_unin_main_ofw_unit_address(const SysBusDevice *dev)
|
|
|
|
{
|
|
|
|
UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
|
|
|
|
|
|
|
|
return g_strdup_printf("%x", s->ofw_addr);
|
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
static void pci_unin_main_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
|
2018-03-06 23:30:53 +03:00
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(dev);
|
|
|
|
|
|
|
|
h->bus = pci_register_root_bus(dev, NULL,
|
|
|
|
pci_unin_set_irq, pci_unin_map_irq,
|
2018-03-06 23:30:58 +03:00
|
|
|
s,
|
2018-03-06 23:30:53 +03:00
|
|
|
&s->pci_mmio,
|
2018-03-06 23:30:59 +03:00
|
|
|
&s->pci_io,
|
2018-03-06 23:30:53 +03:00
|
|
|
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
|
|
|
|
|
2018-03-06 23:30:54 +03:00
|
|
|
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-pci");
|
2018-03-06 23:30:58 +03:00
|
|
|
pci_unin_init_irqs(s);
|
2018-03-06 23:30:53 +03:00
|
|
|
|
|
|
|
/* DEC 21154 bridge */
|
|
|
|
#if 0
|
|
|
|
/* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
|
|
|
|
pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
static void pci_unin_main_init(Object *obj)
|
2006-05-13 20:11:23 +04:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(obj);
|
2018-03-06 23:30:47 +03:00
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(obj);
|
2006-05-13 20:11:23 +04:00
|
|
|
|
|
|
|
/* Use values found on a real PowerMac */
|
|
|
|
/* Uninorth main bus */
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-pci-conf-idx", 0x1000);
|
2018-03-06 23:30:47 +03:00
|
|
|
memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj,
|
2018-03-06 23:30:51 +03:00
|
|
|
"unin-pci-conf-data", 0x1000);
|
|
|
|
|
|
|
|
memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio",
|
|
|
|
0x100000000ULL);
|
2018-03-06 23:30:59 +03:00
|
|
|
memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj,
|
|
|
|
"unin-pci-isa-mmio", 0x00800000);
|
2018-03-06 23:30:51 +03:00
|
|
|
|
2018-03-06 23:30:56 +03:00
|
|
|
memory_region_init_alias(&s->pci_hole, OBJECT(s),
|
|
|
|
"unin-pci-hole", &s->pci_mmio,
|
|
|
|
0x80000000ULL, 0x10000000ULL);
|
|
|
|
|
2018-03-06 23:30:58 +03:00
|
|
|
object_property_add_link(obj, "pic", TYPE_OPENPIC,
|
|
|
|
(Object **) &s->pic,
|
|
|
|
qdev_prop_allow_set_link_before_realize,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
0);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
sysbus_init_mmio(sbd, &h->conf_mem);
|
|
|
|
sysbus_init_mmio(sbd, &h->data_mem);
|
2018-03-06 23:30:56 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->pci_hole);
|
2018-03-06 23:30:59 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->pci_io);
|
2009-08-01 00:23:28 +04:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
static void pci_u3_agp_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = U3_AGP_HOST_BRIDGE(dev);
|
2018-03-06 23:30:53 +03:00
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(dev);
|
|
|
|
|
|
|
|
h->bus = pci_register_root_bus(dev, NULL,
|
|
|
|
pci_unin_set_irq, pci_unin_map_irq,
|
2018-03-06 23:30:58 +03:00
|
|
|
s,
|
2018-03-06 23:30:53 +03:00
|
|
|
&s->pci_mmio,
|
2018-03-06 23:30:59 +03:00
|
|
|
&s->pci_io,
|
2018-03-06 23:30:53 +03:00
|
|
|
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
|
|
|
|
|
|
|
|
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "u3-agp");
|
2018-03-06 23:30:58 +03:00
|
|
|
pci_unin_init_irqs(s);
|
2018-03-06 23:30:53 +03:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
static void pci_u3_agp_init(Object *obj)
|
2010-02-09 19:37:02 +03:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = U3_AGP_HOST_BRIDGE(obj);
|
2018-03-06 23:30:47 +03:00
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(obj);
|
2010-02-09 19:37:02 +03:00
|
|
|
|
|
|
|
/* Uninorth U3 AGP bus */
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-pci-conf-idx", 0x1000);
|
2018-03-06 23:30:47 +03:00
|
|
|
memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj,
|
2018-03-06 23:30:51 +03:00
|
|
|
"unin-pci-conf-data", 0x1000);
|
|
|
|
|
|
|
|
memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio",
|
|
|
|
0x100000000ULL);
|
2018-03-06 23:30:59 +03:00
|
|
|
memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj,
|
|
|
|
"unin-pci-isa-mmio", 0x00800000);
|
2018-03-06 23:30:51 +03:00
|
|
|
|
2018-03-06 23:30:57 +03:00
|
|
|
memory_region_init_alias(&s->pci_hole, OBJECT(s),
|
|
|
|
"unin-pci-hole", &s->pci_mmio,
|
|
|
|
0x80000000ULL, 0x70000000ULL);
|
|
|
|
|
2018-03-06 23:30:58 +03:00
|
|
|
object_property_add_link(obj, "pic", TYPE_OPENPIC,
|
|
|
|
(Object **) &s->pic,
|
|
|
|
qdev_prop_allow_set_link_before_realize,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
0);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
sysbus_init_mmio(sbd, &h->conf_mem);
|
|
|
|
sysbus_init_mmio(sbd, &h->data_mem);
|
2018-03-06 23:30:57 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->pci_hole);
|
2018-03-06 23:30:59 +03:00
|
|
|
sysbus_init_mmio(sbd, &s->pci_io);
|
2010-02-09 19:37:02 +03:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
static void pci_unin_agp_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(dev);
|
2018-03-06 23:30:53 +03:00
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(dev);
|
|
|
|
|
|
|
|
h->bus = pci_register_root_bus(dev, NULL,
|
|
|
|
pci_unin_set_irq, pci_unin_map_irq,
|
2018-03-06 23:30:58 +03:00
|
|
|
s,
|
2018-03-06 23:30:53 +03:00
|
|
|
&s->pci_mmio,
|
2018-03-06 23:30:59 +03:00
|
|
|
&s->pci_io,
|
2018-03-06 23:30:53 +03:00
|
|
|
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
|
2018-03-06 23:30:54 +03:00
|
|
|
|
|
|
|
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp");
|
2018-03-06 23:30:58 +03:00
|
|
|
pci_unin_init_irqs(s);
|
2018-03-06 23:30:53 +03:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
static void pci_unin_agp_init(Object *obj)
|
2009-08-01 00:23:28 +04:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(obj);
|
2018-03-06 23:30:47 +03:00
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(obj);
|
2009-08-01 00:23:28 +04:00
|
|
|
|
|
|
|
/* Uninorth AGP bus */
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-agp-conf-idx", 0x1000);
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-agp-conf-data", 0x1000);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
|
|
|
object_property_add_link(obj, "pic", TYPE_OPENPIC,
|
|
|
|
(Object **) &s->pic,
|
|
|
|
qdev_prop_allow_set_link_before_realize,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
0);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
sysbus_init_mmio(sbd, &h->conf_mem);
|
|
|
|
sysbus_init_mmio(sbd, &h->data_mem);
|
2009-08-01 00:23:28 +04:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:55 +03:00
|
|
|
static void pci_unin_internal_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(dev);
|
2018-03-06 23:30:55 +03:00
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(dev);
|
|
|
|
|
|
|
|
h->bus = pci_register_root_bus(dev, NULL,
|
|
|
|
pci_unin_set_irq, pci_unin_map_irq,
|
2018-03-06 23:30:58 +03:00
|
|
|
s,
|
2018-03-06 23:30:55 +03:00
|
|
|
&s->pci_mmio,
|
2018-03-06 23:30:59 +03:00
|
|
|
&s->pci_io,
|
2018-03-06 23:30:55 +03:00
|
|
|
PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS);
|
|
|
|
|
|
|
|
pci_create_simple(h->bus, PCI_DEVFN(14, 0), "uni-north-internal-pci");
|
2018-03-06 23:30:58 +03:00
|
|
|
pci_unin_init_irqs(s);
|
2018-03-06 23:30:55 +03:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
static void pci_unin_internal_init(Object *obj)
|
2009-08-01 00:23:28 +04:00
|
|
|
{
|
2018-03-06 23:31:00 +03:00
|
|
|
UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj);
|
2018-03-06 23:30:47 +03:00
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PCIHostState *h = PCI_HOST_BRIDGE(obj);
|
2009-08-01 00:23:28 +04:00
|
|
|
|
|
|
|
/* Uninorth internal bus */
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-pci-conf-idx", 0x1000);
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
|
2018-03-06 23:30:51 +03:00
|
|
|
obj, "unin-pci-conf-data", 0x1000);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
|
|
|
object_property_add_link(obj, "pic", TYPE_OPENPIC,
|
|
|
|
(Object **) &s->pic,
|
|
|
|
qdev_prop_allow_set_link_before_realize,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
0);
|
2018-03-06 23:30:58 +03:00
|
|
|
|
2018-03-06 23:30:47 +03:00
|
|
|
sysbus_init_mmio(sbd, &h->conf_mem);
|
|
|
|
sysbus_init_mmio(sbd, &h->data_mem);
|
2009-08-01 00:23:28 +04:00
|
|
|
}
|
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
static void unin_main_pci_host_realize(PCIDevice *d, Error **errp)
|
2009-08-01 00:23:28 +04:00
|
|
|
{
|
2018-03-06 23:30:45 +03:00
|
|
|
/* cache_line_size */
|
|
|
|
d->config[0x0C] = 0x08;
|
|
|
|
/* latency_timer */
|
|
|
|
d->config[0x0D] = 0x10;
|
|
|
|
/* capabilities_pointer */
|
|
|
|
d->config[0x34] = 0x00;
|
|
|
|
|
2016-01-22 19:09:23 +03:00
|
|
|
/*
|
|
|
|
* Set kMacRISCPCIAddressSelect (0x48) register to indicate PCI
|
|
|
|
* memory space with base 0x80000000, size 0x10000000 for Apple's
|
|
|
|
* AppleMacRiscPCI driver
|
|
|
|
*/
|
|
|
|
d->config[0x48] = 0x0;
|
|
|
|
d->config[0x49] = 0x0;
|
|
|
|
d->config[0x4a] = 0x0;
|
|
|
|
d->config[0x4b] = 0x1;
|
2009-08-01 00:23:28 +04:00
|
|
|
}
|
2006-05-13 20:11:23 +04:00
|
|
|
|
2018-03-06 23:30:54 +03:00
|
|
|
static void unin_agp_pci_host_realize(PCIDevice *d, Error **errp)
|
|
|
|
{
|
|
|
|
/* cache_line_size */
|
|
|
|
d->config[0x0C] = 0x08;
|
|
|
|
/* latency_timer */
|
|
|
|
d->config[0x0D] = 0x10;
|
|
|
|
/* capabilities_pointer
|
|
|
|
d->config[0x34] = 0x80; */
|
|
|
|
}
|
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
static void u3_agp_pci_host_realize(PCIDevice *d, Error **errp)
|
2010-02-09 19:37:02 +03:00
|
|
|
{
|
|
|
|
/* cache line size */
|
|
|
|
d->config[0x0C] = 0x08;
|
|
|
|
/* latency timer */
|
|
|
|
d->config[0x0D] = 0x10;
|
|
|
|
}
|
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
static void unin_internal_pci_host_realize(PCIDevice *d, Error **errp)
|
2009-08-01 00:23:28 +04:00
|
|
|
{
|
2018-03-06 23:30:45 +03:00
|
|
|
/* cache_line_size */
|
|
|
|
d->config[0x0C] = 0x08;
|
|
|
|
/* latency_timer */
|
|
|
|
d->config[0x0D] = 0x10;
|
|
|
|
/* capabilities_pointer */
|
|
|
|
d->config[0x34] = 0x00;
|
2009-08-01 00:23:28 +04:00
|
|
|
}
|
|
|
|
|
2011-12-04 22:22:06 +04:00
|
|
|
static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
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 20:26:58 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 22:22:06 +04:00
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
k->realize = unin_main_pci_host_realize;
|
2011-12-04 22:22:06 +04:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_APPLE;
|
|
|
|
k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI;
|
|
|
|
k->revision = 0x00;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
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 20:26:58 +04:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
2017-05-03 23:35:44 +03:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 22:22:06 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo unin_main_pci_host_info = {
|
2011-12-04 22:22:06 +04:00
|
|
|
.name = "uni-north-pci",
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIDevice),
|
2011-12-04 22:22:06 +04:00
|
|
|
.class_init = unin_main_pci_host_class_init,
|
2017-09-27 22:56:34 +03:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2009-08-01 00:23:28 +04:00
|
|
|
};
|
|
|
|
|
2011-12-04 22:22:06 +04:00
|
|
|
static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
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 20:26:58 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 22:22:06 +04:00
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
k->realize = u3_agp_pci_host_realize;
|
2011-12-04 22:22:06 +04:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_APPLE;
|
|
|
|
k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP;
|
|
|
|
k->revision = 0x00;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
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 20:26:58 +04:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
2017-05-03 23:35:44 +03:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 22:22:06 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo u3_agp_pci_host_info = {
|
2011-12-04 22:22:06 +04:00
|
|
|
.name = "u3-agp",
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIDevice),
|
2011-12-04 22:22:06 +04:00
|
|
|
.class_init = u3_agp_pci_host_class_init,
|
2017-09-27 22:56:34 +03:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2010-02-09 19:37:02 +03:00
|
|
|
};
|
|
|
|
|
2011-12-04 22:22:06 +04:00
|
|
|
static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
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 20:26:58 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 22:22:06 +04:00
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
k->realize = unin_agp_pci_host_realize;
|
2011-12-04 22:22:06 +04:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_APPLE;
|
|
|
|
k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP;
|
|
|
|
k->revision = 0x00;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
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 20:26:58 +04:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
2017-05-03 23:35:44 +03:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 22:22:06 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo unin_agp_pci_host_info = {
|
2011-12-04 22:22:06 +04:00
|
|
|
.name = "uni-north-agp",
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIDevice),
|
2011-12-04 22:22:06 +04:00
|
|
|
.class_init = unin_agp_pci_host_class_init,
|
2017-09-27 22:56:34 +03:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2009-08-01 00:23:28 +04:00
|
|
|
};
|
|
|
|
|
2011-12-04 22:22:06 +04:00
|
|
|
static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
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 20:26:58 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 22:22:06 +04:00
|
|
|
|
2015-01-19 17:52:30 +03:00
|
|
|
k->realize = unin_internal_pci_host_realize;
|
2011-12-04 22:22:06 +04:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_APPLE;
|
|
|
|
k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI;
|
|
|
|
k->revision = 0x00;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
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 20:26:58 +04:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
2017-05-03 23:35:44 +03:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 22:22:06 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo unin_internal_pci_host_info = {
|
2011-12-04 22:22:06 +04:00
|
|
|
.name = "uni-north-internal-pci",
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIDevice),
|
2011-12-04 22:22:06 +04:00
|
|
|
.class_init = unin_internal_pci_host_class_init,
|
2017-09-27 22:56:34 +03:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2009-08-01 00:23:28 +04:00
|
|
|
};
|
|
|
|
|
2018-08-29 19:59:10 +03:00
|
|
|
static Property pci_unin_main_pci_host_props[] = {
|
|
|
|
DEFINE_PROP_UINT32("ofw-addr", UNINHostState, ofw_addr, -1),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static void pci_unin_main_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2015-09-26 19:22:09 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2018-08-29 19:59:10 +03:00
|
|
|
SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
dc->realize = pci_unin_main_realize;
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, pci_unin_main_pci_host_props);
|
2015-09-26 19:22:09 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2018-08-29 19:59:10 +03:00
|
|
|
dc->fw_name = "pci";
|
|
|
|
sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo pci_unin_main_info = {
|
2012-08-20 21:08:06 +04:00
|
|
|
.name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE,
|
2012-08-20 21:08:08 +04:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2018-03-06 23:31:00 +03:00
|
|
|
.instance_size = sizeof(UNINHostState),
|
2018-03-06 23:30:47 +03:00
|
|
|
.instance_init = pci_unin_main_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = pci_unin_main_class_init,
|
2012-01-19 11:40:16 +04:00
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static void pci_u3_agp_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2015-09-26 19:22:09 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
dc->realize = pci_u3_agp_realize;
|
2015-09-26 19:22:09 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo pci_u3_agp_info = {
|
2012-08-20 21:08:06 +04:00
|
|
|
.name = TYPE_U3_AGP_HOST_BRIDGE,
|
2012-08-20 21:08:08 +04:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2018-03-06 23:31:00 +03:00
|
|
|
.instance_size = sizeof(UNINHostState),
|
2018-03-06 23:30:47 +03:00
|
|
|
.instance_init = pci_u3_agp_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = pci_u3_agp_class_init,
|
2012-01-19 11:40:16 +04:00
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static void pci_unin_agp_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2015-09-26 19:22:09 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2018-03-06 23:30:53 +03:00
|
|
|
dc->realize = pci_unin_agp_realize;
|
2015-09-26 19:22:09 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo pci_unin_agp_info = {
|
2012-08-20 21:08:06 +04:00
|
|
|
.name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE,
|
2012-08-20 21:08:08 +04:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2018-03-06 23:31:00 +03:00
|
|
|
.instance_size = sizeof(UNINHostState),
|
2018-03-06 23:30:47 +03:00
|
|
|
.instance_init = pci_unin_agp_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = pci_unin_agp_class_init,
|
2012-01-19 11:40:16 +04:00
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static void pci_unin_internal_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2015-09-26 19:22:09 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2018-03-06 23:30:55 +03:00
|
|
|
dc->realize = pci_unin_internal_realize;
|
2015-09-26 19:22:09 +03:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 21:07:56 +04:00
|
|
|
static const TypeInfo pci_unin_internal_info = {
|
2012-08-20 21:08:06 +04:00
|
|
|
.name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE,
|
2012-08-20 21:08:08 +04:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2018-03-06 23:31:00 +03:00
|
|
|
.instance_size = sizeof(UNINHostState),
|
2018-03-06 23:30:47 +03:00
|
|
|
.instance_init = pci_unin_internal_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = pci_unin_internal_class_init,
|
2012-01-19 11:40:16 +04:00
|
|
|
};
|
|
|
|
|
2018-05-03 23:24:39 +03:00
|
|
|
/* UniN device */
|
|
|
|
static void unin_write(void *opaque, hwaddr addr, uint64_t value,
|
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
trace_unin_write(addr, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t unin_read(void *opaque, hwaddr addr, unsigned size)
|
|
|
|
{
|
|
|
|
uint32_t value;
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case 0:
|
2018-05-06 17:20:05 +03:00
|
|
|
value = UNINORTH_VERSION_10A;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
value = 0;
|
2018-05-03 23:24:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
trace_unin_read(addr, value);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps unin_ops = {
|
|
|
|
.read = unin_read,
|
|
|
|
.write = unin_write,
|
|
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void unin_init(Object *obj)
|
|
|
|
{
|
|
|
|
UNINState *s = UNI_NORTH(obj);
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
|
2018-05-06 17:20:05 +03:00
|
|
|
memory_region_init_io(&s->mem, obj, &unin_ops, s, "unin", 0x1000);
|
2018-05-03 23:24:39 +03:00
|
|
|
|
|
|
|
sysbus_init_mmio(sbd, &s->mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unin_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo unin_info = {
|
|
|
|
.name = TYPE_UNI_NORTH,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(UNINState),
|
|
|
|
.instance_init = unin_init,
|
|
|
|
.class_init = unin_class_init,
|
|
|
|
};
|
|
|
|
|
2012-02-09 18:20:55 +04:00
|
|
|
static void unin_register_types(void)
|
2009-08-01 00:23:28 +04:00
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
type_register_static(&unin_main_pci_host_info);
|
|
|
|
type_register_static(&u3_agp_pci_host_info);
|
|
|
|
type_register_static(&unin_agp_pci_host_info);
|
|
|
|
type_register_static(&unin_internal_pci_host_info);
|
|
|
|
|
|
|
|
type_register_static(&pci_unin_main_info);
|
|
|
|
type_register_static(&pci_u3_agp_info);
|
|
|
|
type_register_static(&pci_unin_agp_info);
|
|
|
|
type_register_static(&pci_unin_internal_info);
|
2018-05-03 23:24:39 +03:00
|
|
|
|
|
|
|
type_register_static(&unin_info);
|
2006-05-13 20:11:23 +04:00
|
|
|
}
|
2009-08-01 00:23:28 +04:00
|
|
|
|
2012-02-09 18:20:55 +04:00
|
|
|
type_init(unin_register_types)
|