root / hw / sysbus.h @ 3ced9f7a
History | View | Annotate | Download (1.9 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 | aae9460e | Paul Brook | |
8 | f40070c3 | Blue Swirl | #define QDEV_MAX_MMIO 32 |
9 | a1961a4b | Blue Swirl | #define QDEV_MAX_IRQ 256 |
10 | aae9460e | Paul Brook | |
11 | aae9460e | Paul Brook | typedef struct SysBusDevice SysBusDevice; |
12 | c227f099 | Anthony Liguori | typedef void (*mmio_mapfunc)(SysBusDevice *dev, target_phys_addr_t addr); |
13 | aae9460e | Paul Brook | |
14 | aae9460e | Paul Brook | struct SysBusDevice {
|
15 | aae9460e | Paul Brook | DeviceState qdev; |
16 | aae9460e | Paul Brook | int num_irq;
|
17 | aae9460e | Paul Brook | qemu_irq irqs[QDEV_MAX_IRQ]; |
18 | aae9460e | Paul Brook | qemu_irq *irqp[QDEV_MAX_IRQ]; |
19 | aae9460e | Paul Brook | int num_mmio;
|
20 | aae9460e | Paul Brook | struct {
|
21 | c227f099 | Anthony Liguori | target_phys_addr_t addr; |
22 | c227f099 | Anthony Liguori | target_phys_addr_t size; |
23 | aae9460e | Paul Brook | mmio_mapfunc cb; |
24 | aae9460e | Paul Brook | int iofunc;
|
25 | aae9460e | Paul Brook | } mmio[QDEV_MAX_MMIO]; |
26 | aae9460e | Paul Brook | }; |
27 | aae9460e | Paul Brook | |
28 | 81a322d4 | Gerd Hoffmann | typedef int (*sysbus_initfn)(SysBusDevice *dev); |
29 | aae9460e | Paul Brook | |
30 | aae9460e | Paul Brook | /* Macros to compensate for lack of type inheritance in C. */
|
31 | aae9460e | Paul Brook | #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
|
32 | aae9460e | Paul Brook | #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
|
33 | aae9460e | Paul Brook | |
34 | 1431b6a1 | Paul Brook | typedef struct { |
35 | 1431b6a1 | Paul Brook | DeviceInfo qdev; |
36 | 1431b6a1 | Paul Brook | sysbus_initfn init; |
37 | 1431b6a1 | Paul Brook | } SysBusDeviceInfo; |
38 | 1431b6a1 | Paul Brook | |
39 | aae9460e | Paul Brook | void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init); |
40 | 074f2fff | Gerd Hoffmann | void sysbus_register_withprop(SysBusDeviceInfo *info);
|
41 | aae9460e | Paul Brook | void *sysbus_new(void); |
42 | c227f099 | Anthony Liguori | void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size, int iofunc); |
43 | c227f099 | Anthony Liguori | void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
|
44 | aae9460e | Paul Brook | mmio_mapfunc cb); |
45 | aae9460e | Paul Brook | void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
46 | aae9460e | Paul Brook | void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
47 | aae9460e | Paul Brook | |
48 | aae9460e | Paul Brook | |
49 | aae9460e | Paul Brook | void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); |
50 | c227f099 | Anthony Liguori | void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); |
51 | aae9460e | Paul Brook | |
52 | aae9460e | Paul Brook | /* Legacy helper function for creating devices. */
|
53 | aae9460e | Paul Brook | DeviceState *sysbus_create_varargs(const char *name, |
54 | c227f099 | Anthony Liguori | target_phys_addr_t addr, ...); |
55 | aae9460e | Paul Brook | static inline DeviceState *sysbus_create_simple(const char *name, |
56 | c227f099 | Anthony Liguori | target_phys_addr_t addr, |
57 | aae9460e | Paul Brook | qemu_irq irq) |
58 | aae9460e | Paul Brook | { |
59 | aae9460e | Paul Brook | return sysbus_create_varargs(name, addr, irq, NULL); |
60 | aae9460e | Paul Brook | } |
61 | aae9460e | Paul Brook | |
62 | aae9460e | Paul Brook | #endif /* !HW_SYSBUS_H */ |