root / hw / sysbus.h @ a6f4e09d
History | View | Annotate | Download (2.6 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 | a1961a4b | Blue Swirl | #define QDEV_MAX_IRQ 256 |
12 | aae9460e | Paul Brook | |
13 | aae9460e | Paul Brook | typedef struct SysBusDevice SysBusDevice; |
14 | c227f099 | Anthony Liguori | typedef void (*mmio_mapfunc)(SysBusDevice *dev, target_phys_addr_t addr); |
15 | aae9460e | Paul Brook | |
16 | aae9460e | Paul Brook | struct SysBusDevice {
|
17 | aae9460e | Paul Brook | DeviceState qdev; |
18 | aae9460e | Paul Brook | int num_irq;
|
19 | aae9460e | Paul Brook | qemu_irq irqs[QDEV_MAX_IRQ]; |
20 | aae9460e | Paul Brook | qemu_irq *irqp[QDEV_MAX_IRQ]; |
21 | aae9460e | Paul Brook | int num_mmio;
|
22 | aae9460e | Paul Brook | struct {
|
23 | c227f099 | Anthony Liguori | target_phys_addr_t addr; |
24 | c227f099 | Anthony Liguori | target_phys_addr_t size; |
25 | aae9460e | Paul Brook | mmio_mapfunc cb; |
26 | 3f7132d1 | Blue Swirl | ram_addr_t iofunc; |
27 | ec3bb837 | Avi Kivity | MemoryRegion *memory; |
28 | aae9460e | Paul Brook | } mmio[QDEV_MAX_MMIO]; |
29 | c646f74f | Gleb Natapov | int num_pio;
|
30 | c646f74f | Gleb Natapov | pio_addr_t pio[QDEV_MAX_PIO]; |
31 | aae9460e | Paul Brook | }; |
32 | aae9460e | Paul Brook | |
33 | 81a322d4 | Gerd Hoffmann | typedef int (*sysbus_initfn)(SysBusDevice *dev); |
34 | aae9460e | Paul Brook | |
35 | aae9460e | Paul Brook | /* Macros to compensate for lack of type inheritance in C. */
|
36 | aae9460e | Paul Brook | #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
|
37 | aae9460e | Paul Brook | #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
|
38 | aae9460e | Paul Brook | |
39 | 1431b6a1 | Paul Brook | typedef struct { |
40 | 1431b6a1 | Paul Brook | DeviceInfo qdev; |
41 | 1431b6a1 | Paul Brook | sysbus_initfn init; |
42 | 1431b6a1 | Paul Brook | } SysBusDeviceInfo; |
43 | 1431b6a1 | Paul Brook | |
44 | aae9460e | Paul Brook | void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init); |
45 | 074f2fff | Gerd Hoffmann | void sysbus_register_withprop(SysBusDeviceInfo *info);
|
46 | aae9460e | Paul Brook | void *sysbus_new(void); |
47 | 3f7132d1 | Blue Swirl | void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size,
|
48 | 3f7132d1 | Blue Swirl | ram_addr_t iofunc); |
49 | c227f099 | Anthony Liguori | void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
|
50 | aae9460e | Paul Brook | mmio_mapfunc cb); |
51 | ec3bb837 | Avi Kivity | void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory);
|
52 | aae9460e | Paul Brook | void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
53 | aae9460e | Paul Brook | void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
54 | c646f74f | Gleb Natapov | void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
|
55 | aae9460e | Paul Brook | |
56 | aae9460e | Paul Brook | |
57 | aae9460e | Paul Brook | void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); |
58 | c227f099 | Anthony Liguori | void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); |
59 | aae9460e | Paul Brook | |
60 | aae9460e | Paul Brook | /* Legacy helper function for creating devices. */
|
61 | aae9460e | Paul Brook | DeviceState *sysbus_create_varargs(const char *name, |
62 | c227f099 | Anthony Liguori | target_phys_addr_t addr, ...); |
63 | 4912371f | Blue Swirl | DeviceState *sysbus_try_create_varargs(const char *name, |
64 | 4912371f | Blue Swirl | target_phys_addr_t addr, ...); |
65 | aae9460e | Paul Brook | static inline DeviceState *sysbus_create_simple(const char *name, |
66 | c227f099 | Anthony Liguori | target_phys_addr_t addr, |
67 | aae9460e | Paul Brook | qemu_irq irq) |
68 | aae9460e | Paul Brook | { |
69 | aae9460e | Paul Brook | return sysbus_create_varargs(name, addr, irq, NULL); |
70 | aae9460e | Paul Brook | } |
71 | aae9460e | Paul Brook | |
72 | 4912371f | Blue Swirl | static inline DeviceState *sysbus_try_create_simple(const char *name, |
73 | 4912371f | Blue Swirl | target_phys_addr_t addr, |
74 | 4912371f | Blue Swirl | qemu_irq irq) |
75 | 4912371f | Blue Swirl | { |
76 | 4912371f | Blue Swirl | return sysbus_try_create_varargs(name, addr, irq, NULL); |
77 | 4912371f | Blue Swirl | } |
78 | 4912371f | Blue Swirl | |
79 | aae9460e | Paul Brook | #endif /* !HW_SYSBUS_H */ |