Statistics
| Branch: | Revision:

root / hw / sysbus.h @ 113f89df

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