]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/sysbus.h
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
[mirror_qemu.git] / include / hw / sysbus.h
CommitLineData
aae9460e
PB
1#ifndef HW_SYSBUS_H
2#define HW_SYSBUS_H 1
3
4/* Devices attached directly to the main system bus. */
5
83c9f4ca 6#include "hw/qdev.h"
022c62cb 7#include "exec/memory.h"
aae9460e 8
f40070c3 9#define QDEV_MAX_MMIO 32
c646f74f 10#define QDEV_MAX_PIO 32
ea0e6841 11#define QDEV_MAX_IRQ 512
aae9460e 12
0d936928
AL
13#define TYPE_SYSTEM_BUS "System"
14#define SYSTEM_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS)
15
aae9460e 16typedef struct SysBusDevice SysBusDevice;
aae9460e 17
999e12bb
AL
18#define TYPE_SYS_BUS_DEVICE "sys-bus-device"
19#define SYS_BUS_DEVICE(obj) \
20 OBJECT_CHECK(SysBusDevice, (obj), TYPE_SYS_BUS_DEVICE)
21#define SYS_BUS_DEVICE_CLASS(klass) \
22 OBJECT_CLASS_CHECK(SysBusDeviceClass, (klass), TYPE_SYS_BUS_DEVICE)
23#define SYS_BUS_DEVICE_GET_CLASS(obj) \
24 OBJECT_GET_CLASS(SysBusDeviceClass, (obj), TYPE_SYS_BUS_DEVICE)
25
ce724398
HT
26/**
27 * SysBusDeviceClass:
28 * @init: Callback function invoked when the #DeviceState.realized property
29 * is changed to %true. Deprecated, new types inheriting directly from
30 * TYPE_SYS_BUS_DEVICE should use #DeviceClass.realize instead, new leaf
31 * types should consult their respective parent type.
32 *
33 * SysBusDeviceClass is not overriding #DeviceClass.realize, so derived
34 * classes overriding it are not required to invoke its implementation.
35 */
999e12bb 36typedef struct SysBusDeviceClass {
ce724398 37 /*< private >*/
999e12bb 38 DeviceClass parent_class;
ce724398 39 /*< public >*/
999e12bb
AL
40
41 int (*init)(SysBusDevice *dev);
42} SysBusDeviceClass;
43
aae9460e 44struct SysBusDevice {
b67964d7
AF
45 /*< private >*/
46 DeviceState parent_obj;
47 /*< public >*/
48
aae9460e
PB
49 int num_irq;
50 qemu_irq irqs[QDEV_MAX_IRQ];
51 qemu_irq *irqp[QDEV_MAX_IRQ];
52 int num_mmio;
53 struct {
a8170e5e 54 hwaddr addr;
ec3bb837 55 MemoryRegion *memory;
aae9460e 56 } mmio[QDEV_MAX_MMIO];
c646f74f
GN
57 int num_pio;
58 pio_addr_t pio[QDEV_MAX_PIO];
aae9460e
PB
59};
60
750ecd44 61void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
46c305ef 62MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
aae9460e
PB
63void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
64void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
c646f74f 65void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
aae9460e
PB
66
67
68void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
a8170e5e 69void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr);
7feb640c 70void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
a1ff8ae0 71 int priority);
a8170e5e 72void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
2b985d9c
AK
73 MemoryRegion *mem);
74void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
62ec4832 75MemoryRegion *sysbus_address_space(SysBusDevice *dev);
aae9460e
PB
76
77/* Legacy helper function for creating devices. */
78DeviceState *sysbus_create_varargs(const char *name,
a8170e5e 79 hwaddr addr, ...);
4912371f 80DeviceState *sysbus_try_create_varargs(const char *name,
a8170e5e 81 hwaddr addr, ...);
aae9460e 82static inline DeviceState *sysbus_create_simple(const char *name,
a8170e5e 83 hwaddr addr,
aae9460e
PB
84 qemu_irq irq)
85{
86 return sysbus_create_varargs(name, addr, irq, NULL);
87}
88
4912371f 89static inline DeviceState *sysbus_try_create_simple(const char *name,
a8170e5e 90 hwaddr addr,
4912371f
BS
91 qemu_irq irq)
92{
93 return sysbus_try_create_varargs(name, addr, irq, NULL);
94}
95
aae9460e 96#endif /* !HW_SYSBUS_H */