2009-05-15 01:35:06 +04:00
|
|
|
#ifndef HW_SYSBUS_H
|
|
|
|
#define HW_SYSBUS_H 1
|
|
|
|
|
|
|
|
/* Devices attached directly to the main system bus. */
|
|
|
|
|
|
|
|
#include "qdev.h"
|
2011-07-26 15:26:21 +04:00
|
|
|
#include "memory.h"
|
2009-05-15 01:35:06 +04:00
|
|
|
|
2009-07-12 23:21:36 +04:00
|
|
|
#define QDEV_MAX_MMIO 32
|
2010-12-08 14:35:00 +03:00
|
|
|
#define QDEV_MAX_PIO 32
|
2009-07-16 18:15:34 +04:00
|
|
|
#define QDEV_MAX_IRQ 256
|
2009-05-15 01:35:06 +04:00
|
|
|
|
|
|
|
typedef struct SysBusDevice SysBusDevice;
|
2009-10-02 01:12:16 +04:00
|
|
|
typedef void (*mmio_mapfunc)(SysBusDevice *dev, target_phys_addr_t addr);
|
2009-05-15 01:35:06 +04: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-02 01:12:16 +04:00
|
|
|
target_phys_addr_t addr;
|
|
|
|
target_phys_addr_t size;
|
2009-05-15 01:35:06 +04:00
|
|
|
mmio_mapfunc cb;
|
2011-08-15 18:17:29 +04:00
|
|
|
mmio_mapfunc unmap;
|
2010-10-02 18:27:41 +04:00
|
|
|
ram_addr_t iofunc;
|
2011-07-26 15:26:21 +04:00
|
|
|
MemoryRegion *memory;
|
2009-05-15 01:35:06 +04:00
|
|
|
} mmio[QDEV_MAX_MMIO];
|
2010-12-08 14:35:00 +03:00
|
|
|
int num_pio;
|
|
|
|
pio_addr_t pio[QDEV_MAX_PIO];
|
2009-05-15 01:35:06 +04:00
|
|
|
};
|
|
|
|
|
2009-08-14 12:36:05 +04:00
|
|
|
typedef int (*sysbus_initfn)(SysBusDevice *dev);
|
2009-05-15 01:35:06 +04: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)
|
|
|
|
|
2009-06-05 18:52:04 +04:00
|
|
|
typedef struct {
|
|
|
|
DeviceInfo qdev;
|
|
|
|
sysbus_initfn init;
|
|
|
|
} SysBusDeviceInfo;
|
|
|
|
|
2009-05-15 01:35:06 +04:00
|
|
|
void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init);
|
2009-06-10 11:41:42 +04:00
|
|
|
void sysbus_register_withprop(SysBusDeviceInfo *info);
|
2009-05-15 01:35:06 +04:00
|
|
|
void *sysbus_new(void);
|
2010-10-02 18:27:41 +04:00
|
|
|
void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size,
|
|
|
|
ram_addr_t iofunc);
|
2011-08-15 18:17:29 +04:00
|
|
|
void sysbus_init_mmio_cb2(SysBusDevice *dev,
|
|
|
|
mmio_mapfunc cb, mmio_mapfunc unmap);
|
2011-07-26 15:26:21 +04:00
|
|
|
void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory);
|
2011-08-28 20:22:17 +04:00
|
|
|
MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
|
2009-05-15 01:35:06 +04:00
|
|
|
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
|
|
|
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
2010-12-08 14:35:00 +03:00
|
|
|
void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
|
2009-05-15 01:35:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
|
2009-10-02 01:12:16 +04:00
|
|
|
void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
|
2011-07-24 18:12:11 +04:00
|
|
|
void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
|
|
|
|
MemoryRegion *mem);
|
2011-07-25 16:02:17 +04:00
|
|
|
void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
|
|
|
|
MemoryRegion *mem, unsigned priority);
|
2011-07-24 18:12:11 +04: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);
|
2009-05-15 01:35:06 +04:00
|
|
|
|
|
|
|
/* Legacy helper function for creating devices. */
|
|
|
|
DeviceState *sysbus_create_varargs(const char *name,
|
2009-10-02 01:12:16 +04:00
|
|
|
target_phys_addr_t addr, ...);
|
2011-02-05 17:34:56 +03:00
|
|
|
DeviceState *sysbus_try_create_varargs(const char *name,
|
|
|
|
target_phys_addr_t addr, ...);
|
2009-05-15 01:35:06 +04:00
|
|
|
static inline DeviceState *sysbus_create_simple(const char *name,
|
2009-10-02 01:12:16 +04:00
|
|
|
target_phys_addr_t addr,
|
2009-05-15 01:35:06 +04:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
2011-02-05 17:34:56 +03: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-15 01:35:06 +04:00
|
|
|
#endif /* !HW_SYSBUS_H */
|