4 /* Devices attached directly to the main system bus. */
7 #include "exec/memory.h"
9 #define QDEV_MAX_MMIO 32
10 #define QDEV_MAX_PIO 32
12 #define TYPE_SYSTEM_BUS "System"
13 #define SYSTEM_BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_SYSTEM_BUS)
15 typedef struct SysBusDevice SysBusDevice
;
17 #define TYPE_SYS_BUS_DEVICE "sys-bus-device"
18 #define SYS_BUS_DEVICE(obj) \
19 OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE)
20 #define SYS_BUS_DEVICE_CLASS(klass) \
21 OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE)
22 #define SYS_BUS_DEVICE_GET_CLASS(obj) \
23 OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE)
27 * @init: Callback function invoked when the #DeviceState.realized property
28 * is changed to %true. Deprecated, new types inheriting directly from
29 * TYPE_SYS_BUS_DEVICE should use #DeviceClass.realize instead, new leaf
30 * types should consult their respective parent type.
32 * SysBusDeviceClass is not overriding #DeviceClass.realize, so derived
33 * classes overriding it are not required to invoke its implementation.
36 #define SYSBUS_DEVICE_GPIO_IRQ "sysbus-irq"
38 typedef struct SysBusDeviceClass
{
40 DeviceClass parent_class
;
43 int (*init
)(SysBusDevice
*dev
);
48 DeviceState parent_obj
;
55 } mmio
[QDEV_MAX_MMIO
];
57 pio_addr_t pio
[QDEV_MAX_PIO
];
60 typedef int FindSysbusDeviceFunc(SysBusDevice
*sbdev
, void *opaque
);
62 void sysbus_init_mmio(SysBusDevice
*dev
, MemoryRegion
*memory
);
63 MemoryRegion
*sysbus_mmio_get_region(SysBusDevice
*dev
, int n
);
64 void sysbus_init_irq(SysBusDevice
*dev
, qemu_irq
*p
);
65 void sysbus_pass_irq(SysBusDevice
*dev
, SysBusDevice
*target
);
66 void sysbus_init_ioports(SysBusDevice
*dev
, pio_addr_t ioport
, pio_addr_t size
);
69 bool sysbus_has_irq(SysBusDevice
*dev
, int n
);
70 bool sysbus_has_mmio(SysBusDevice
*dev
, unsigned int n
);
71 void sysbus_connect_irq(SysBusDevice
*dev
, int n
, qemu_irq irq
);
72 bool sysbus_is_irq_connected(SysBusDevice
*dev
, int n
);
73 qemu_irq
sysbus_get_connected_irq(SysBusDevice
*dev
, int n
);
74 void sysbus_mmio_map(SysBusDevice
*dev
, int n
, hwaddr addr
);
75 void sysbus_mmio_map_overlap(SysBusDevice
*dev
, int n
, hwaddr addr
,
77 void sysbus_add_io(SysBusDevice
*dev
, hwaddr addr
,
79 MemoryRegion
*sysbus_address_space(SysBusDevice
*dev
);
81 /* Call func for every dynamically created sysbus device in the system */
82 void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc
*func
, void *opaque
);
84 /* Legacy helper function for creating devices. */
85 DeviceState
*sysbus_create_varargs(const char *name
,
87 DeviceState
*sysbus_try_create_varargs(const char *name
,
89 static inline DeviceState
*sysbus_create_simple(const char *name
,
93 return sysbus_create_varargs(name
, addr
, irq
, NULL
);
96 static inline DeviceState
*sysbus_try_create_simple(const char *name
,
100 return sysbus_try_create_varargs(name
, addr
, irq
, NULL
);
103 #endif /* !HW_SYSBUS_H */