]> git.proxmox.com Git - mirror_qemu.git/blame - hw/sysbus.h
console: vga_hw_screen_dump_ptr: take Error argument
[mirror_qemu.git] / 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
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
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
26typedef struct SysBusDeviceClass {
27 DeviceClass parent_class;
28
29 int (*init)(SysBusDevice *dev);
30} SysBusDeviceClass;
31
aae9460e
PB
32struct SysBusDevice {
33 DeviceState qdev;
34 int num_irq;
35 qemu_irq irqs[QDEV_MAX_IRQ];
36 qemu_irq *irqp[QDEV_MAX_IRQ];
37 int num_mmio;
38 struct {
c227f099 39 target_phys_addr_t addr;
ec3bb837 40 MemoryRegion *memory;
aae9460e 41 } mmio[QDEV_MAX_MMIO];
c646f74f
GN
42 int num_pio;
43 pio_addr_t pio[QDEV_MAX_PIO];
aae9460e
PB
44};
45
aae9460e
PB
46/* Macros to compensate for lack of type inheritance in C. */
47#define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
48#define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
49
aae9460e 50void *sysbus_new(void);
750ecd44 51void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
46c305ef 52MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
aae9460e
PB
53void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
54void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
c646f74f 55void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
aae9460e
PB
56
57
58void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
c227f099 59void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
2b985d9c
AK
60void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
61 MemoryRegion *mem);
d40b2af8
AK
62void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
63 MemoryRegion *mem, unsigned priority);
2b985d9c
AK
64void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
65void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
66 MemoryRegion *mem);
67void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
62ec4832 68MemoryRegion *sysbus_address_space(SysBusDevice *dev);
aae9460e
PB
69
70/* Legacy helper function for creating devices. */
71DeviceState *sysbus_create_varargs(const char *name,
c227f099 72 target_phys_addr_t addr, ...);
4912371f
BS
73DeviceState *sysbus_try_create_varargs(const char *name,
74 target_phys_addr_t addr, ...);
aae9460e 75static 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
82static 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 */