hw/9pfs: Documentation changes related to proxy fs
[qemu/ar7.git] / hw / sysbus.h
blob899756bf7fdcaeeab5a477e0bbef5932c6718a91
1 #ifndef HW_SYSBUS_H
2 #define HW_SYSBUS_H 1
4 /* Devices attached directly to the main system bus. */
6 #include "qdev.h"
7 #include "memory.h"
9 #define QDEV_MAX_MMIO 32
10 #define QDEV_MAX_PIO 32
11 #define QDEV_MAX_IRQ 256
13 typedef struct SysBusDevice SysBusDevice;
15 struct 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 {
22 target_phys_addr_t addr;
23 MemoryRegion *memory;
24 } mmio[QDEV_MAX_MMIO];
25 int num_pio;
26 pio_addr_t pio[QDEV_MAX_PIO];
29 typedef int (*sysbus_initfn)(SysBusDevice *dev);
31 /* Macros to compensate for lack of type inheritance in C. */
32 #define sysbus_from_qdev(dev) ((SysBusDevice *)(dev))
33 #define FROM_SYSBUS(type, dev) DO_UPCAST(type, busdev, dev)
35 typedef struct {
36 DeviceInfo qdev;
37 sysbus_initfn init;
38 } SysBusDeviceInfo;
40 void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init);
41 void sysbus_register_withprop(SysBusDeviceInfo *info);
42 void *sysbus_new(void);
43 void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory);
44 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n);
45 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
46 void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
47 void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
50 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
51 void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr);
52 void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr,
53 MemoryRegion *mem);
54 void sysbus_add_memory_overlap(SysBusDevice *dev, target_phys_addr_t addr,
55 MemoryRegion *mem, unsigned priority);
56 void sysbus_del_memory(SysBusDevice *dev, MemoryRegion *mem);
57 void sysbus_add_io(SysBusDevice *dev, target_phys_addr_t addr,
58 MemoryRegion *mem);
59 void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
60 MemoryRegion *sysbus_address_space(SysBusDevice *dev);
62 /* Legacy helper function for creating devices. */
63 DeviceState *sysbus_create_varargs(const char *name,
64 target_phys_addr_t addr, ...);
65 DeviceState *sysbus_try_create_varargs(const char *name,
66 target_phys_addr_t addr, ...);
67 static inline DeviceState *sysbus_create_simple(const char *name,
68 target_phys_addr_t addr,
69 qemu_irq irq)
71 return sysbus_create_varargs(name, addr, irq, NULL);
74 static inline DeviceState *sysbus_try_create_simple(const char *name,
75 target_phys_addr_t addr,
76 qemu_irq irq)
78 return sysbus_try_create_varargs(name, addr, irq, NULL);
81 #endif /* !HW_SYSBUS_H */