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