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