2009-05-14 23:35:06 +02:00
|
|
|
#ifndef HW_SYSBUS_H
|
|
|
|
#define HW_SYSBUS_H 1
|
|
|
|
|
|
|
|
/* Devices attached directly to the main system bus. */
|
|
|
|
|
|
|
|
#include "qdev.h"
|
|
|
|
|
2009-07-12 21:21:36 +02:00
|
|
|
#define QDEV_MAX_MMIO 32
|
2009-07-16 16:15:34 +02:00
|
|
|
#define QDEV_MAX_IRQ 256
|
2009-05-14 23:35:06 +02:00
|
|
|
|
|
|
|
typedef struct SysBusDevice SysBusDevice;
|
2009-10-01 23:12:16 +02:00
|
|
|
typedef void (*mmio_mapfunc)(SysBusDevice *dev, target_phys_addr_t addr);
|
2009-05-14 23:35:06 +02: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 23:12:16 +02:00
|
|
|
target_phys_addr_t addr;
|
|
|
|
target_phys_addr_t size;
|
2009-05-14 23:35:06 +02:00
|
|
|
mmio_mapfunc cb;
|
|
|
|
int iofunc;
|
|
|
|
} mmio[QDEV_MAX_MMIO];
|
|
|
|
};
|
|
|
|
|
2009-08-14 10:36:05 +02:00
|
|
|
typedef int (*sysbus_initfn)(SysBusDevice *dev);
|
2009-05-14 23:35:06 +02: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 16:52:04 +02:00
|
|
|
typedef struct {
|
|
|
|
DeviceInfo qdev;
|
|
|
|
sysbus_initfn init;
|
|
|
|
} SysBusDeviceInfo;
|
|
|
|
|
2009-05-14 23:35:06 +02:00
|
|
|
void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init);
|
2009-06-10 09:41:42 +02:00
|
|
|
void sysbus_register_withprop(SysBusDeviceInfo *info);
|
2009-05-14 23:35:06 +02:00
|
|
|
void *sysbus_new(void);
|
2009-10-01 23:12:16 +02:00
|
|
|
void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size, int iofunc);
|
|
|
|
void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
|
2009-05-14 23:35:06 +02:00
|
|
|
mmio_mapfunc cb);
|
|
|
|
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
|
|
|
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
|
|
|
|
|
|
|
|
|
|
|
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
|
2009-10-01 23:12:16 +02:00
|
|
|
void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
|
2009-05-14 23:35:06 +02:00
|
|
|
|
|
|
|
/* Legacy helper function for creating devices. */
|
|
|
|
DeviceState *sysbus_create_varargs(const char *name,
|
2009-10-01 23:12:16 +02:00
|
|
|
target_phys_addr_t addr, ...);
|
2009-05-14 23:35:06 +02:00
|
|
|
static inline DeviceState *sysbus_create_simple(const char *name,
|
2009-10-01 23:12:16 +02:00
|
|
|
target_phys_addr_t addr,
|
2009-05-14 23:35:06 +02:00
|
|
|
qemu_irq irq)
|
|
|
|
{
|
|
|
|
return sysbus_create_varargs(name, addr, irq, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !HW_SYSBUS_H */
|