2009-05-15 05:35:06 +08:00
|
|
|
#ifndef HW_SYSBUS_H
|
|
|
|
#define HW_SYSBUS_H 1
|
|
|
|
|
|
|
|
/* Devices attached directly to the main system bus. */
|
|
|
|
|
2013-02-04 22:40:22 +08:00
|
|
|
#include "hw/qdev.h"
|
2012-12-18 01:19:49 +08:00
|
|
|
#include "exec/memory.h"
|
2009-05-15 05:35:06 +08:00
|
|
|
|
2009-07-13 03:21:36 +08:00
|
|
|
#define QDEV_MAX_MMIO 32
|
2010-12-08 19:35:00 +08:00
|
|
|
#define QDEV_MAX_PIO 32
|
2012-01-17 09:08:19 +08:00
|
|
|
#define QDEV_MAX_IRQ 512
|
2009-05-15 05:35:06 +08:00
|
|
|
|
2012-05-02 15:00:20 +08:00
|
|
|
#define TYPE_SYSTEM_BUS "System"
|
|
|
|
#define SYSTEM_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS)
|
|
|
|
|
2009-05-15 05:35:06 +08:00
|
|
|
typedef struct SysBusDevice SysBusDevice;
|
|
|
|
|
2012-01-25 03:12:29 +08:00
|
|
|
#define TYPE_SYS_BUS_DEVICE "sys-bus-device"
|
|
|
|
#define SYS_BUS_DEVICE(obj) \
|
|
|
|
OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE)
|
|
|
|
#define SYS_BUS_DEVICE_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE)
|
|
|
|
#define SYS_BUS_DEVICE_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE)
|
|
|
|
|
2013-07-01 18:18:17 +08:00
|
|
|
/**
|
|
|
|
* SysBusDeviceClass:
|
|
|
|
* @init: Callback function invoked when the #DeviceState.realized property
|
|
|
|
* is changed to %true. Deprecated, new types inheriting directly from
|
|
|
|
* TYPE_SYS_BUS_DEVICE should use #DeviceClass.realize instead, new leaf
|
|
|
|
* types should consult their respective parent type.
|
|
|
|
*
|
|
|
|
* SysBusDeviceClass is not overriding #DeviceClass.realize, so derived
|
|
|
|
* classes overriding it are not required to invoke its implementation.
|
|
|
|
*/
|
2012-01-25 03:12:29 +08:00
|
|
|
typedef struct SysBusDeviceClass {
|
2013-07-01 18:18:17 +08:00
|
|
|
/*< private >*/
|
2012-01-25 03:12:29 +08:00
|
|
|
DeviceClass parent_class;
|
2013-07-01 18:18:17 +08:00
|
|
|
/*< public >*/
|
2012-01-25 03:12:29 +08:00
|
|
|
|
|
|
|
int (*init)(SysBusDevice *dev);
|
|
|
|
} SysBusDeviceClass;
|
|
|
|
|
2009-05-15 05:35:06 +08:00
|
|
|
struct SysBusDevice {
|
2013-07-27 22:40:42 +08:00
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
2009-05-15 05:35:06 +08:00
|
|
|
int num_irq;
|
|
|
|
qemu_irq irqs[QDEV_MAX_IRQ];
|
|
|
|
qemu_irq *irqp[QDEV_MAX_IRQ];
|
|
|
|
int num_mmio;
|
|
|
|
struct {
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr addr;
|
2011-07-26 19:26:21 +08:00
|
|
|
MemoryRegion *memory;
|
2009-05-15 05:35:06 +08:00
|
|
|
} mmio[QDEV_MAX_MMIO];
|
2010-12-08 19:35:00 +08:00
|
|
|
int num_pio;
|
|
|
|
pio_addr_t pio[QDEV_MAX_PIO];
|
2009-05-15 05:35:06 +08:00
|
|
|
};
|
|
|
|
|
2011-11-27 17:38:10 +08:00
|
|
|
void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
|
2011-08-29 00:22:17 +08:00
|
|
|
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
|
2009-05-15 05:35:06 +08:00
|
|
|
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
|
|
|
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
2010-12-08 19:35:00 +08:00
|
|
|
void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
|
2009-05-15 05:35:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
|
2012-10-23 18:30:10 +08:00
|
|
|
void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr);
|
2013-02-22 11:58:44 +08:00
|
|
|
void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
|
2013-09-16 16:21:14 +08:00
|
|
|
int priority);
|
2012-10-23 18:30:10 +08:00
|
|
|
void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
|
2011-07-24 22:12:11 +08:00
|
|
|
MemoryRegion *mem);
|
|
|
|
void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
|
2011-12-08 21:57:34 +08:00
|
|
|
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
|
2009-05-15 05:35:06 +08:00
|
|
|
|
|
|
|
/* Legacy helper function for creating devices. */
|
|
|
|
DeviceState *sysbus_create_varargs(const char *name,
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr addr, ...);
|
2011-02-05 22:34:56 +08:00
|
|
|
DeviceState *sysbus_try_create_varargs(const char *name,
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr addr, ...);
|
2009-05-15 05:35:06 +08:00
|
|
|
static inline DeviceState *sysbus_create_simple(const char *name,
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr addr,
|
2009-05-15 05:35:06 +08:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-05 22:34:56 +08:00
|
|
|
static inline DeviceState *sysbus_try_create_simple(const char *name,
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr addr,
|
2011-02-05 22:34:56 +08:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_try_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2009-05-15 05:35:06 +08:00
|
|
|
#endif /* !HW_SYSBUS_H */
|