2009-05-14 23:35:06 +02:00
|
|
|
#ifndef HW_SYSBUS_H
|
2016-06-29 15:29:06 +02:00
|
|
|
#define HW_SYSBUS_H
|
2009-05-14 23:35:06 +02:00
|
|
|
|
|
|
|
/* Devices attached directly to the main system bus. */
|
|
|
|
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-core.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/memory.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2009-05-14 23:35:06 +02:00
|
|
|
|
2009-07-12 21:21:36 +02:00
|
|
|
#define QDEV_MAX_MMIO 32
|
2010-12-08 12:35:00 +01:00
|
|
|
#define QDEV_MAX_PIO 32
|
2009-05-14 23:35:06 +02:00
|
|
|
|
2012-05-02 09:00:20 +02:00
|
|
|
#define TYPE_SYSTEM_BUS "System"
|
2020-08-31 23:07:33 +02:00
|
|
|
DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS,
|
|
|
|
TYPE_SYSTEM_BUS)
|
2012-05-02 09:00:20 +02:00
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
#define TYPE_SYS_BUS_DEVICE "sys-bus-device"
|
2020-08-31 23:07:37 +02:00
|
|
|
OBJECT_DECLARE_TYPE(SysBusDevice, SysBusDeviceClass,
|
qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros
One of the goals of having less boilerplate on QOM declarations
is to avoid human error. Requiring an extra argument that is
never used is an opportunity for mistakes.
Remove the unused argument from OBJECT_DECLARE_TYPE and
OBJECT_DECLARE_SIMPLE_TYPE.
Coccinelle patch used to convert all users of the macros:
@@
declarer name OBJECT_DECLARE_TYPE;
identifier InstanceType, ClassType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_TYPE(InstanceType, ClassType,
- lowercase,
UPPERCASE);
@@
declarer name OBJECT_DECLARE_SIMPLE_TYPE;
identifier InstanceType, lowercase, UPPERCASE;
@@
OBJECT_DECLARE_SIMPLE_TYPE(InstanceType,
- lowercase,
UPPERCASE);
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Paul Durrant <paul@xen.org>
Acked-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20200916182519.415636-4-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2020-09-16 20:25:17 +02:00
|
|
|
SYS_BUS_DEVICE)
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2013-07-01 12:18:17 +02:00
|
|
|
/**
|
|
|
|
* SysBusDeviceClass:
|
|
|
|
*
|
|
|
|
* SysBusDeviceClass is not overriding #DeviceClass.realize, so derived
|
|
|
|
* classes overriding it are not required to invoke its implementation.
|
|
|
|
*/
|
2014-09-26 07:24:15 +02:00
|
|
|
|
|
|
|
#define SYSBUS_DEVICE_GPIO_IRQ "sysbus-irq"
|
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct SysBusDeviceClass {
|
2013-07-01 12:18:17 +02:00
|
|
|
/*< private >*/
|
2012-01-24 20:12:29 +01:00
|
|
|
DeviceClass parent_class;
|
2015-06-19 04:40:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Let the sysbus device format its own non-PIO, non-MMIO unit address.
|
|
|
|
*
|
|
|
|
* Sometimes a class of SysBusDevices has neither MMIO nor PIO resources,
|
|
|
|
* yet instances of it would like to distinguish themselves, in
|
|
|
|
* OpenFirmware device paths, from other instances of the same class on the
|
|
|
|
* sysbus. For that end we expose this callback.
|
|
|
|
*
|
|
|
|
* The implementation is not supposed to change *@dev, or incur other
|
|
|
|
* observable change.
|
|
|
|
*
|
|
|
|
* The function returns a dynamically allocated string. On error, NULL
|
|
|
|
* should be returned; the unit address portion of the OFW node will be
|
|
|
|
* omitted then. (This is not considered a fatal error.)
|
|
|
|
*/
|
|
|
|
char *(*explicit_ofw_unit_address)(const SysBusDevice *dev);
|
2015-07-06 20:15:14 +02:00
|
|
|
void (*connect_irq_notifier)(SysBusDevice *dev, qemu_irq irq);
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
struct SysBusDevice {
|
2013-07-27 16:40:42 +02:00
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
int num_mmio;
|
|
|
|
struct {
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr addr;
|
2011-07-26 13:26:21 +02:00
|
|
|
MemoryRegion *memory;
|
2009-05-14 23:35:06 +02:00
|
|
|
} mmio[QDEV_MAX_MMIO];
|
2010-12-08 12:35:00 +01:00
|
|
|
int num_pio;
|
2016-03-16 10:20:34 +01:00
|
|
|
uint32_t pio[QDEV_MAX_PIO];
|
2009-05-14 23:35:06 +02:00
|
|
|
};
|
|
|
|
|
2016-09-21 07:23:53 +02:00
|
|
|
typedef void FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
|
2014-09-24 13:06:57 +02:00
|
|
|
|
2011-11-27 10:38:10 +01:00
|
|
|
void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
|
2011-08-28 18:22:17 +02:00
|
|
|
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
|
2009-05-14 23:35:06 +02:00
|
|
|
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
|
|
|
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
2016-03-16 10:20:34 +01:00
|
|
|
void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size);
|
2009-05-14 23:35:06 +02:00
|
|
|
|
|
|
|
|
2014-09-24 12:32:17 +02:00
|
|
|
bool sysbus_has_irq(SysBusDevice *dev, int n);
|
2014-09-24 12:36:30 +02:00
|
|
|
bool sysbus_has_mmio(SysBusDevice *dev, unsigned int n);
|
2009-05-14 23:35:06 +02:00
|
|
|
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
|
2014-09-24 12:32:17 +02:00
|
|
|
bool sysbus_is_irq_connected(SysBusDevice *dev, int n);
|
|
|
|
qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n);
|
2012-10-23 12:30:10 +02:00
|
|
|
void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr);
|
2013-02-22 04:58:44 +01:00
|
|
|
void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
|
2013-09-16 10:21:14 +02:00
|
|
|
int priority);
|
2019-05-13 10:42:39 +02:00
|
|
|
void sysbus_mmio_unmap(SysBusDevice *dev, int n);
|
2012-10-23 12:30:10 +02:00
|
|
|
void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
|
2011-07-24 16:12:11 +02:00
|
|
|
MemoryRegion *mem);
|
2011-12-08 14:57:34 +01:00
|
|
|
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
|
2009-05-14 23:35:06 +02:00
|
|
|
|
2020-06-10 07:32:33 +02:00
|
|
|
bool sysbus_realize(SysBusDevice *dev, Error **errp);
|
|
|
|
bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);
|
|
|
|
|
2014-09-24 13:06:57 +02:00
|
|
|
/* Call func for every dynamically created sysbus device in the system */
|
|
|
|
void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque);
|
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
/* Legacy helper function for creating devices. */
|
|
|
|
DeviceState *sysbus_create_varargs(const char *name,
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr addr, ...);
|
2019-10-22 19:18:12 +02:00
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
static inline DeviceState *sysbus_create_simple(const char *name,
|
2012-10-23 12:30:10 +02:00
|
|
|
hwaddr addr,
|
2009-05-14 23:35:06 +02:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2016-06-29 15:29:06 +02:00
|
|
|
#endif /* HW_SYSBUS_H */
|