root / hw / sysbus.h @ f76e1d81
History | View | Annotate | Download (3 kB)
1 | aae9460e | Paul Brook | #ifndef HW_SYSBUS_H
|
---|---|---|---|
2 | aae9460e | Paul Brook | #define HW_SYSBUS_H 1 |
3 | aae9460e | Paul Brook | |
4 | aae9460e | Paul Brook | /* Devices attached directly to the main system bus. */
|
5 | aae9460e | Paul Brook | |
6 | aae9460e | Paul Brook | #include "qdev.h" |
7 | ec3bb837 | Avi Kivity | #include "memory.h" |
8 | aae9460e | Paul Brook | |
9 | f40070c3 | Blue Swirl | #define QDEV_MAX_MMIO 32 |
10 | c646f74f | Gleb Natapov | #define QDEV_MAX_PIO 32 |
11 | ea0e6841 | Evgeny Voevodin | #define QDEV_MAX_IRQ 512 |
12 | aae9460e | Paul Brook | |
13 | aae9460e | Paul Brook | typedef struct SysBusDevice SysBusDevice; |
14 | aae9460e | Paul Brook | |
15 | 999e12bb | Anthony Liguori | #define TYPE_SYS_BUS_DEVICE "sys-bus-device" |
16 | 999e12bb | Anthony Liguori | #define SYS_BUS_DEVICE(obj) \
|
17 | 999e12bb | Anthony Liguori | OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE) |
18 | 999e12bb | Anthony Liguori | #define SYS_BUS_DEVICE_CLASS(klass) \
|
19 | 999e12bb | Anthony Liguori | OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE) |
20 | 999e12bb | Anthony Liguori | #define SYS_BUS_DEVICE_GET_CLASS(obj) \
|
21 | 999e12bb | Anthony Liguori | OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE) |
22 | 999e12bb | Anthony Liguori | |
23 | 999e12bb | Anthony Liguori | typedef struct SysBusDeviceClass { |
24 | 999e12bb | Anthony Liguori | DeviceClass parent_class; |
25 | 999e12bb | Anthony Liguori | |
26 | 999e12bb | Anthony Liguori | int (*init)(SysBusDevice *dev);
|
27 | 999e12bb | Anthony Liguori | } SysBusDeviceClass; |
28 | 999e12bb | Anthony Liguori | |
29 | aae9460e | Paul Brook | struct SysBusDevice {
|
30 | aae9460e | Paul Brook | DeviceState qdev; |
31 | aae9460e | Paul Brook | int num_irq;
|
32 | aae9460e | Paul Brook | qemu_irq irqs[QDEV_MAX_IRQ]; |
33 | aae9460e | Paul Brook | qemu_irq *irqp[QDEV_MAX_IRQ]; |
34 | aae9460e | Paul Brook | int num_mmio;
|
35 | aae9460e | Paul Brook | struct {
|
36 | c227f099 | Anthony Liguori | target_phys_addr_t addr; |
37 | ec3bb837 | Avi Kivity | MemoryRegion *memory; |
38 | aae9460e | Paul Brook | } mmio[QDEV_MAX_MMIO]; |
39 | c646f74f | Gleb Natapov | int num_pio;
|
40 | c646f74f | Gleb Natapov | pio_addr_t pio[QDEV_MAX_PIO]; |
41 | aae9460e | Paul Brook | }; |
42 | aae9460e | Paul Brook | |
43 | aae9460e | Paul Brook | /* Macros to compensate for lack of type inheritance in C. */
|
44 | aae9460e | Paul Brook | #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
|
45 | aae9460e | Paul Brook | #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
|
46 | aae9460e | Paul Brook | |
47 | aae9460e | Paul Brook | void *sysbus_new(void); |
48 | 750ecd44 | Avi Kivity | void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
|
49 | 46c305ef | Peter Maydell | MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
|
50 | aae9460e | Paul Brook | void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
51 | aae9460e | Paul Brook | void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
52 | c646f74f | Gleb Natapov | void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
|
53 | aae9460e | Paul Brook | |
54 | aae9460e | Paul Brook | |
55 | aae9460e | Paul Brook | void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); |
56 | c227f099 | Anthony Liguori | void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); |
57 | 2b985d9c | Avi Kivity | void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
|
58 | 2b985d9c | Avi Kivity | MemoryRegion *mem); |
59 | d40b2af8 | Avi Kivity | void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
|
60 | d40b2af8 | Avi Kivity | MemoryRegion *mem, unsigned priority);
|
61 | 2b985d9c | Avi Kivity | void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
|
62 | 2b985d9c | Avi Kivity | void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
|
63 | 2b985d9c | Avi Kivity | MemoryRegion *mem); |
64 | 2b985d9c | Avi Kivity | void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
|
65 | 62ec4832 | Avi Kivity | MemoryRegion *sysbus_address_space(SysBusDevice *dev); |
66 | aae9460e | Paul Brook | |
67 | aae9460e | Paul Brook | /* Legacy helper function for creating devices. */
|
68 | aae9460e | Paul Brook | DeviceState *sysbus_create_varargs(const char *name, |
69 | c227f099 | Anthony Liguori | target_phys_addr_t addr, ...); |
70 | 4912371f | Blue Swirl | DeviceState *sysbus_try_create_varargs(const char *name, |
71 | 4912371f | Blue Swirl | target_phys_addr_t addr, ...); |
72 | aae9460e | Paul Brook | static inline DeviceState *sysbus_create_simple(const char *name, |
73 | c227f099 | Anthony Liguori | target_phys_addr_t addr, |
74 | aae9460e | Paul Brook | qemu_irq irq) |
75 | aae9460e | Paul Brook | { |
76 | aae9460e | Paul Brook | return sysbus_create_varargs(name, addr, irq, NULL); |
77 | aae9460e | Paul Brook | } |
78 | aae9460e | Paul Brook | |
79 | 4912371f | Blue Swirl | static inline DeviceState *sysbus_try_create_simple(const char *name, |
80 | 4912371f | Blue Swirl | target_phys_addr_t addr, |
81 | 4912371f | Blue Swirl | qemu_irq irq) |
82 | 4912371f | Blue Swirl | { |
83 | 4912371f | Blue Swirl | return sysbus_try_create_varargs(name, addr, irq, NULL); |
84 | 4912371f | Blue Swirl | } |
85 | 4912371f | Blue Swirl | |
86 | aae9460e | Paul Brook | #endif /* !HW_SYSBUS_H */ |