]>
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; |
d7612013 | 26 | mmio_mapfunc unmap; |
3f7132d1 | 27 | ram_addr_t iofunc; |
ec3bb837 | 28 | MemoryRegion *memory; |
aae9460e | 29 | } mmio[QDEV_MAX_MMIO]; |
c646f74f GN |
30 | int num_pio; |
31 | pio_addr_t pio[QDEV_MAX_PIO]; | |
aae9460e PB |
32 | }; |
33 | ||
81a322d4 | 34 | typedef int (*sysbus_initfn)(SysBusDevice *dev); |
aae9460e PB |
35 | |
36 | /* Macros to compensate for lack of type inheritance in C. */ | |
37 | #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev)) | |
38 | #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev) | |
39 | ||
1431b6a1 PB |
40 | typedef struct { |
41 | DeviceInfo qdev; | |
42 | sysbus_initfn init; | |
43 | } SysBusDeviceInfo; | |
44 | ||
aae9460e | 45 | void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init); |
074f2fff | 46 | void sysbus_register_withprop(SysBusDeviceInfo *info); |
aae9460e | 47 | void *sysbus_new(void); |
3f7132d1 BS |
48 | void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size, |
49 | ram_addr_t iofunc); | |
d7612013 AK |
50 | void sysbus_init_mmio_cb2(SysBusDevice *dev, |
51 | mmio_mapfunc cb, mmio_mapfunc unmap); | |
ec3bb837 | 52 | void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory); |
46c305ef | 53 | MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n); |
aae9460e PB |
54 | void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p); |
55 | void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target); | |
c646f74f | 56 | void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size); |
aae9460e PB |
57 | |
58 | ||
59 | void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); | |
c227f099 | 60 | void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); |
2b985d9c AK |
61 | void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr, |
62 | MemoryRegion *mem); | |
d40b2af8 AK |
63 | void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr, |
64 | MemoryRegion *mem, unsigned priority); | |
2b985d9c AK |
65 | void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem); |
66 | void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr, | |
67 | MemoryRegion *mem); | |
68 | void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem); | |
aae9460e PB |
69 | |
70 | /* Legacy helper function for creating devices. */ | |
71 | DeviceState *sysbus_create_varargs(const char *name, | |
c227f099 | 72 | target_phys_addr_t addr, ...); |
4912371f BS |
73 | DeviceState *sysbus_try_create_varargs(const char *name, |
74 | target_phys_addr_t addr, ...); | |
aae9460e | 75 | static inline DeviceState *sysbus_create_simple(const char *name, |
c227f099 | 76 | target_phys_addr_t addr, |
aae9460e PB |
77 | qemu_irq irq) |
78 | { | |
79 | return sysbus_create_varargs(name, addr, irq, NULL); | |
80 | } | |
81 | ||
4912371f BS |
82 | static inline DeviceState *sysbus_try_create_simple(const char *name, |
83 | target_phys_addr_t addr, | |
84 | qemu_irq irq) | |
85 | { | |
86 | return sysbus_try_create_varargs(name, addr, irq, NULL); | |
87 | } | |
88 | ||
aae9460e | 89 | #endif /* !HW_SYSBUS_H */ |