PPC: e500: msync is 440 only, e500 has real sync
[qemu.git] / hw / sysbus.h
1 #ifndef HW_SYSBUS_H
2 #define HW_SYSBUS_H 1
3
4 /* Devices attached directly to the main system bus. */
5
6 #include "qdev.h"
7 #include "memory.h"
8
9 #define QDEV_MAX_MMIO 32
10 #define QDEV_MAX_PIO 32
11 #define QDEV_MAX_IRQ 512
12
13 typedef struct SysBusDevice SysBusDevice;
14
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)
22
23 typedef struct SysBusDeviceClass {
24 DeviceClass parent_class;
25
26 int (*init)(SysBusDevice *dev);
27 } SysBusDeviceClass;
28
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];
41 };
42
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)
46
47 #define sysbus_register_withprop(info) sysbus_qdev_register(info)
48 void sysbus_qdev_register(DeviceInfo *info);
49 void sysbus_qdev_register_subclass(DeviceInfo *info, const char *parent);
50
51 void *sysbus_new(void);
52 void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
53 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
54 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
55 void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
56 void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
57
58
59 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
60 void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
61 void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
62 MemoryRegion *mem);
63 void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
64 MemoryRegion *mem, unsigned priority);
65 void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
66 void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
67 MemoryRegion *mem);
68 void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
69 MemoryRegion *sysbus_address_space(SysBusDevice *dev);
70
71 /* Legacy helper function for creating devices. */
72 DeviceState *sysbus_create_varargs(const char *name,
73 target_phys_addr_t addr, ...);
74 DeviceState *sysbus_try_create_varargs(const char *name,
75 target_phys_addr_t addr, ...);
76 static inline DeviceState *sysbus_create_simple(const char *name,
77 target_phys_addr_t addr,
78 qemu_irq irq)
79 {
80 return sysbus_create_varargs(name, addr, irq, NULL);
81 }
82
83 static inline DeviceState *sysbus_try_create_simple(const char *name,
84 target_phys_addr_t addr,
85 qemu_irq irq)
86 {
87 return sysbus_try_create_varargs(name, addr, irq, NULL);
88 }
89
90 #endif /* !HW_SYSBUS_H */