2009-05-14 21:35:06 +00:00
|
|
|
#ifndef HW_SYSBUS_H
|
|
|
|
#define HW_SYSBUS_H 1
|
|
|
|
|
|
|
|
/* Devices attached directly to the main system bus. */
|
|
|
|
|
|
|
|
#include "qdev.h"
|
2011-07-26 11:26:21 +00:00
|
|
|
#include "memory.h"
|
2009-05-14 21:35:06 +00:00
|
|
|
|
2009-07-12 19:21:36 +00:00
|
|
|
#define QDEV_MAX_MMIO 32
|
2010-12-08 11:35:00 +00:00
|
|
|
#define QDEV_MAX_PIO 32
|
2012-01-17 01:08:19 +00:00
|
|
|
#define QDEV_MAX_IRQ 512
|
2009-05-14 21:35:06 +00:00
|
|
|
|
2012-05-02 07:00:20 +00:00
|
|
|
#define TYPE_SYSTEM_BUS "System"
|
|
|
|
#define SYSTEM_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS)
|
|
|
|
|
2009-05-14 21:35:06 +00:00
|
|
|
typedef struct SysBusDevice SysBusDevice;
|
|
|
|
|
2012-01-24 19:12:29 +00: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)
|
|
|
|
|
|
|
|
typedef struct SysBusDeviceClass {
|
|
|
|
DeviceClass parent_class;
|
|
|
|
|
|
|
|
int (*init)(SysBusDevice *dev);
|
|
|
|
} SysBusDeviceClass;
|
|
|
|
|
2009-05-14 21:35:06 +00:00
|
|
|
struct SysBusDevice {
|
|
|
|
DeviceState qdev;
|
|
|
|
int num_irq;
|
|
|
|
qemu_irq irqs[QDEV_MAX_IRQ];
|
|
|
|
qemu_irq *irqp[QDEV_MAX_IRQ];
|
|
|
|
int num_mmio;
|
|
|
|
struct {
|
2009-10-01 21:12:16 +00:00
|
|
|
target_phys_addr_t addr;
|
2011-07-26 11:26:21 +00:00
|
|
|
MemoryRegion *memory;
|
2009-05-14 21:35:06 +00:00
|
|
|
} mmio[QDEV_MAX_MMIO];
|
2010-12-08 11:35:00 +00:00
|
|
|
int num_pio;
|
|
|
|
pio_addr_t pio[QDEV_MAX_PIO];
|
2009-05-14 21:35:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Macros to compensate for lack of type inheritance in C. */
|
|
|
|
#define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
|
|
|
|
#define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
|
|
|
|
|
|
|
|
void *sysbus_new(void);
|
2011-11-27 09:38:10 +00:00
|
|
|
void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
|
2011-08-28 16:22:17 +00:00
|
|
|
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
|
2009-05-14 21:35:06 +00:00
|
|
|
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
|
|
|
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
2010-12-08 11:35:00 +00:00
|
|
|
void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
|
2009-05-14 21:35:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
|
2009-10-01 21:12:16 +00:00
|
|
|
void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
|
2011-07-24 14:12:11 +00:00
|
|
|
void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
|
|
|
|
MemoryRegion *mem);
|
2011-07-25 12:02:17 +00:00
|
|
|
void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
|
|
|
|
MemoryRegion *mem, unsigned priority);
|
2011-07-24 14:12:11 +00:00
|
|
|
void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
|
|
|
|
void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
|
|
|
|
MemoryRegion *mem);
|
|
|
|
void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
|
2011-12-08 13:57:34 +00:00
|
|
|
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
|
2009-05-14 21:35:06 +00:00
|
|
|
|
|
|
|
/* Legacy helper function for creating devices. */
|
|
|
|
DeviceState *sysbus_create_varargs(const char *name,
|
2009-10-01 21:12:16 +00:00
|
|
|
target_phys_addr_t addr, ...);
|
2011-02-05 14:34:56 +00:00
|
|
|
DeviceState *sysbus_try_create_varargs(const char *name,
|
|
|
|
target_phys_addr_t addr, ...);
|
2009-05-14 21:35:06 +00:00
|
|
|
static inline DeviceState *sysbus_create_simple(const char *name,
|
2009-10-01 21:12:16 +00:00
|
|
|
target_phys_addr_t addr,
|
2009-05-14 21:35:06 +00:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-05 14:34:56 +00:00
|
|
|
static inline DeviceState *sysbus_try_create_simple(const char *name,
|
|
|
|
target_phys_addr_t addr,
|
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_try_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2009-05-14 21:35:06 +00:00
|
|
|
#endif /* !HW_SYSBUS_H */
|