root / hw / sysbus.h @ 3b1fd90e
History | View | Annotate | Download (1.8 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 | aae9460e | Paul Brook | #define QDEV_MAX_MMIO 5 |
9 | aae9460e | Paul Brook | #define QDEV_MAX_IRQ 32 |
10 | aae9460e | Paul Brook | |
11 | aae9460e | Paul Brook | typedef struct SysBusDevice SysBusDevice; |
12 | aae9460e | Paul Brook | 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 | aae9460e | Paul Brook | target_phys_addr_t addr; |
22 | aae9460e | Paul Brook | 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 | aae9460e | Paul Brook | typedef void (*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 | aae9460e | Paul Brook | void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init); |
35 | aae9460e | Paul Brook | void *sysbus_new(void); |
36 | aae9460e | Paul Brook | void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size, int iofunc); |
37 | aae9460e | Paul Brook | void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
|
38 | aae9460e | Paul Brook | mmio_mapfunc cb); |
39 | aae9460e | Paul Brook | void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
|
40 | aae9460e | Paul Brook | void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
|
41 | aae9460e | Paul Brook | |
42 | aae9460e | Paul Brook | |
43 | aae9460e | Paul Brook | void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); |
44 | aae9460e | Paul Brook | void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); |
45 | aae9460e | Paul Brook | |
46 | aae9460e | Paul Brook | /* Legacy helper function for creating devices. */
|
47 | aae9460e | Paul Brook | DeviceState *sysbus_create_varargs(const char *name, |
48 | aae9460e | Paul Brook | target_phys_addr_t addr, ...); |
49 | aae9460e | Paul Brook | static inline DeviceState *sysbus_create_simple(const char *name, |
50 | aae9460e | Paul Brook | target_phys_addr_t addr, |
51 | aae9460e | Paul Brook | qemu_irq irq) |
52 | aae9460e | Paul Brook | { |
53 | aae9460e | Paul Brook | return sysbus_create_varargs(name, addr, irq, NULL); |
54 | aae9460e | Paul Brook | } |
55 | aae9460e | Paul Brook | |
56 | aae9460e | Paul Brook | #endif /* !HW_SYSBUS_H */ |