virtio-serial-bus: Unset guest_connected at reset and driver reset
[qemu/ar7.git] / hw / sysbus.h
blob22555cd443bbfb9dc7db1f0df36fe3719015d649
1 #ifndef HW_SYSBUS_H
2 #define HW_SYSBUS_H 1
4 /* Devices attached directly to the main system bus. */
6 #include "qdev.h"
7 #include "memory.h"
9 #define QDEV_MAX_MMIO 32
10 #define QDEV_MAX_PIO 32
11 #define QDEV_MAX_IRQ 512
13 typedef struct SysBusDevice SysBusDevice;
15 #define TYPE_SYS_BUS_DEVICE "sys-bus-device"
16 #define SYS_BUS_DEVICE(obj) \
17 OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE)
18 #define SYS_BUS_DEVICE_CLASS(klass) \
19 OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE)
20 #define SYS_BUS_DEVICE_GET_CLASS(obj) \
21 OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE)
23 typedef struct SysBusDeviceClass {
24 DeviceClass parent_class;
26 int (*init)(SysBusDevice *dev);
27 } SysBusDeviceClass;
29 struct SysBusDevice {
30 DeviceState qdev;
31 int num_irq;
32 qemu_irq irqs[QDEV_MAX_IRQ];
33 qemu_irq *irqp[QDEV_MAX_IRQ];
34 int num_mmio;
35 struct {
36 target_phys_addr_t addr;
37 MemoryRegion *memory;
38 } mmio[QDEV_MAX_MMIO];
39 int num_pio;
40 pio_addr_t pio[QDEV_MAX_PIO];
43 /* Macros to compensate for lack of type inheritance in C. */
44 #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
45 #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
47 void *sysbus_new(void);
48 void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
49 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
50 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
51 void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
52 void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
55 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
56 void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
57 void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
58 MemoryRegion *mem);
59 void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
60 MemoryRegion *mem, unsigned priority);
61 void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
62 void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
63 MemoryRegion *mem);
64 void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
65 MemoryRegion *sysbus_address_space(SysBusDevice *dev);
67 /* Legacy helper function for creating devices. */
68 DeviceState *sysbus_create_varargs(const char *name,
69 target_phys_addr_t addr, ...);
70 DeviceState *sysbus_try_create_varargs(const char *name,
71 target_phys_addr_t addr, ...);
72 static inline DeviceState *sysbus_create_simple(const char *name,
73 target_phys_addr_t addr,
74 qemu_irq irq)
76 return sysbus_create_varargs(name, addr, irq, NULL);
79 static inline DeviceState *sysbus_try_create_simple(const char *name,
80 target_phys_addr_t addr,
81 qemu_irq irq)
83 return sysbus_try_create_varargs(name, addr, irq, NULL);
86 #endif /* !HW_SYSBUS_H */