]> Git Repo - qemu.git/blob - hw/sysbus.h
Merge remote-tracking branch 'stefanha/block' into staging
[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 "exec/memory.h"
8
9 #define QDEV_MAX_MMIO 32
10 #define QDEV_MAX_PIO 32
11 #define QDEV_MAX_IRQ 512
12
13 #define TYPE_SYSTEM_BUS "System"
14 #define SYSTEM_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS)
15
16 typedef struct SysBusDevice SysBusDevice;
17
18 #define TYPE_SYS_BUS_DEVICE "sys-bus-device"
19 #define SYS_BUS_DEVICE(obj) \
20      OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE)
21 #define SYS_BUS_DEVICE_CLASS(klass) \
22      OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE)
23 #define SYS_BUS_DEVICE_GET_CLASS(obj) \
24      OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE)
25
26 typedef struct SysBusDeviceClass {
27     DeviceClass parent_class;
28
29     int (*init)(SysBusDevice *dev);
30 } SysBusDeviceClass;
31
32 struct SysBusDevice {
33     DeviceState qdev;
34     int num_irq;
35     qemu_irq irqs[QDEV_MAX_IRQ];
36     qemu_irq *irqp[QDEV_MAX_IRQ];
37     int num_mmio;
38     struct {
39         hwaddr addr;
40         MemoryRegion *memory;
41     } mmio[QDEV_MAX_MMIO];
42     int num_pio;
43     pio_addr_t pio[QDEV_MAX_PIO];
44 };
45
46 /* Macros to compensate for lack of type inheritance in C.  */
47 #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
48
49 void *sysbus_new(void);
50 void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
51 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
52 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
53 void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
54 void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
55
56
57 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
58 void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr);
59 void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
60                              unsigned priority);
61 void sysbus_add_memory(SysBusDevice *dev, hwaddr addr,
62                        MemoryRegion *mem);
63 void sysbus_add_memory_overlap(SysBusDevice *dev, hwaddr addr,
64                                MemoryRegion *mem, unsigned priority);
65 void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
66 void sysbus_add_io(SysBusDevice *dev, hwaddr 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                                  hwaddr addr, ...);
74 DeviceState *sysbus_try_create_varargs(const char *name,
75                                        hwaddr addr, ...);
76 static inline DeviceState *sysbus_create_simple(const char *name,
77                                               hwaddr 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                                                     hwaddr addr,
85                                                     qemu_irq irq)
86 {
87     return sysbus_try_create_varargs(name, addr, irq, NULL);
88 }
89
90 #endif /* !HW_SYSBUS_H */
This page took 0.03923 seconds and 4 git commands to generate.