2010-02-05 19:48:36 +01:00
|
|
|
/*
|
|
|
|
* QEMU DEC 21154 PCI bridge
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006-2007 Fabrice Bellard
|
|
|
|
* Copyright (c) 2007 Jocelyn Mayer
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-03-18 17:36:02 +01:00
|
|
|
#include "dec.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/pci/pci.h"
|
|
|
|
#include "hw/pci/pci_host.h"
|
|
|
|
#include "hw/pci/pci_bridge.h"
|
|
|
|
#include "hw/pci/pci_bus.h"
|
2010-02-05 19:48:36 +01:00
|
|
|
|
|
|
|
/* debug DEC */
|
|
|
|
//#define DEBUG_DEC
|
|
|
|
|
|
|
|
#ifdef DEBUG_DEC
|
|
|
|
#define DEC_DPRINTF(fmt, ...) \
|
|
|
|
do { printf("DEC: " fmt , ## __VA_ARGS__); } while (0)
|
|
|
|
#else
|
|
|
|
#define DEC_DPRINTF(fmt, ...)
|
|
|
|
#endif
|
|
|
|
|
2012-08-20 19:07:59 +02:00
|
|
|
#define DEC_21154(obj) OBJECT_CHECK(DECState, (obj), TYPE_DEC_21154)
|
|
|
|
|
2010-02-05 19:48:36 +01:00
|
|
|
typedef struct DECState {
|
2012-08-20 19:08:09 +02:00
|
|
|
PCIHostState parent_obj;
|
2010-02-05 19:48:36 +01:00
|
|
|
} DECState;
|
|
|
|
|
2010-02-07 20:28:32 +01:00
|
|
|
static int dec_map_irq(PCIDevice *pci_dev, int irq_num)
|
|
|
|
{
|
|
|
|
return irq_num;
|
|
|
|
}
|
|
|
|
|
2016-01-15 03:23:31 +01:00
|
|
|
static void dec_pci_bridge_realize(PCIDevice *pci_dev, Error **errp)
|
2013-03-14 23:01:11 +01:00
|
|
|
{
|
2016-01-15 03:23:31 +01:00
|
|
|
pci_bridge_initfn(pci_dev, TYPE_PCI_BUS);
|
2013-03-14 23:01:11 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
|
2017-06-13 21:48:49 +02:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2016-01-15 03:23:31 +01:00
|
|
|
k->realize = dec_pci_bridge_realize;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->exit = pci_bridge_exitfn;
|
|
|
|
k->vendor_id = PCI_VENDOR_ID_DEC;
|
|
|
|
k->device_id = PCI_DEVICE_ID_DEC_21154;
|
|
|
|
k->config_write = pci_bridge_write_config;
|
|
|
|
k->is_bridge = 1;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->desc = "DEC 21154 PCI-PCI bridge";
|
|
|
|
dc->reset = pci_bridge_reset;
|
|
|
|
dc->vmsd = &vmstate_pci_device;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo dec_21154_pci_bridge_info = {
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "dec-21154-p2p-bridge",
|
2013-07-11 17:13:43 +02:00
|
|
|
.parent = TYPE_PCI_BRIDGE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.instance_size = sizeof(PCIBridge),
|
|
|
|
.class_init = dec_21154_pci_bridge_class_init,
|
2010-07-13 06:01:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
|
|
|
|
{
|
|
|
|
PCIDevice *dev;
|
|
|
|
PCIBridge *br;
|
2010-02-07 20:28:32 +01:00
|
|
|
|
2010-07-13 06:01:42 +02:00
|
|
|
dev = pci_create_multifunction(parent_bus, devfn, false,
|
|
|
|
"dec-21154-p2p-bridge");
|
2013-07-11 17:13:43 +02:00
|
|
|
br = PCI_BRIDGE(dev);
|
2010-07-13 06:01:42 +02:00
|
|
|
pci_bridge_map_irq(br, "DEC 21154 PCI-PCI bridge", dec_map_irq);
|
|
|
|
qdev_init_nofail(&dev->qdev);
|
|
|
|
return pci_bridge_get_sec_bus(br);
|
2010-02-07 20:28:32 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static int pci_dec_21154_device_init(SysBusDevice *dev)
|
2010-02-05 19:48:36 +01:00
|
|
|
{
|
2012-08-20 19:07:59 +02:00
|
|
|
PCIHostState *phb;
|
2010-02-05 19:48:36 +01:00
|
|
|
|
2012-08-20 19:08:08 +02:00
|
|
|
phb = PCI_HOST_BRIDGE(dev);
|
2010-02-05 19:48:36 +01:00
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&phb->conf_mem, OBJECT(dev), &pci_host_conf_le_ops,
|
2012-08-20 19:07:59 +02:00
|
|
|
dev, "pci-conf-idx", 0x1000);
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&phb->data_mem, OBJECT(dev), &pci_host_data_le_ops,
|
2012-08-20 19:07:59 +02:00
|
|
|
dev, "pci-data-idx", 0x1000);
|
|
|
|
sysbus_init_mmio(dev, &phb->conf_mem);
|
|
|
|
sysbus_init_mmio(dev, &phb->data_mem);
|
2010-02-05 19:48:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-19 15:52:30 +01:00
|
|
|
static void dec_21154_pci_host_realize(PCIDevice *d, Error **errp)
|
2010-02-05 19:48:36 +01:00
|
|
|
{
|
|
|
|
/* PCI2PCI bridge same values as PearPC - check this */
|
|
|
|
}
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void dec_21154_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 17:26:58 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
|
2017-06-13 21:48:49 +02:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2015-01-19 15:52:30 +01:00
|
|
|
k->realize = dec_21154_pci_host_realize;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_DEC;
|
|
|
|
k->device_id = PCI_DEVICE_ID_DEC_21154;
|
|
|
|
k->revision = 0x02;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_PCI;
|
|
|
|
k->is_bridge = 1;
|
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.
|
|
|
|
*/
|
2017-05-03 22:35:44 +02:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo dec_21154_pci_host_info = {
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "dec-21154",
|
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIDevice),
|
|
|
|
.class_init = dec_21154_pci_host_class_init,
|
2010-02-05 19:48:36 +01:00
|
|
|
};
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data)
|
2010-02-05 19:48:36 +01:00
|
|
|
{
|
2012-01-24 20:12:29 +01:00
|
|
|
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
|
|
|
|
|
|
|
|
sdc->init = pci_dec_21154_device_init;
|
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo pci_dec_21154_device_info = {
|
2012-08-20 19:07:59 +02:00
|
|
|
.name = TYPE_DEC_21154,
|
2012-08-20 19:08:08 +02:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.instance_size = sizeof(DECState),
|
|
|
|
.class_init = pci_dec_21154_device_class_init,
|
2012-01-24 20:12:29 +01:00
|
|
|
};
|
2011-12-04 19:22:06 +01:00
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void dec_register_types(void)
|
2012-01-24 20:12:29 +01:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&pci_dec_21154_device_info);
|
|
|
|
type_register_static(&dec_21154_pci_host_info);
|
|
|
|
type_register_static(&dec_21154_pci_bridge_info);
|
2010-02-05 19:48:36 +01:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(dec_register_types)
|