1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef IOPORT_H
25#define IOPORT_H
26
27#include "qemu-common.h"
28#include "qom/object.h"
29#include "exec/memory.h"
30
31typedef uint32_t pio_addr_t;
32#define FMT_pioaddr PRIx32
33
34#define MAX_IOPORTS (64 * 1024)
35#define IOPORTS_MASK (MAX_IOPORTS - 1)
36
37typedef struct MemoryRegionPortio {
38 uint32_t offset;
39 uint32_t len;
40 unsigned size;
41 uint32_t (*read)(void *opaque, uint32_t address);
42 void (*write)(void *opaque, uint32_t address, uint32_t data);
43 uint32_t base;
44} MemoryRegionPortio;
45
46#define PORTIO_END_OF_LIST() { }
47
48#ifndef CONFIG_USER_ONLY
49extern const MemoryRegionOps unassigned_io_ops;
50#endif
51
52void cpu_outb(pio_addr_t addr, uint8_t val);
53void cpu_outw(pio_addr_t addr, uint16_t val);
54void cpu_outl(pio_addr_t addr, uint32_t val);
55uint8_t cpu_inb(pio_addr_t addr);
56uint16_t cpu_inw(pio_addr_t addr);
57uint32_t cpu_inl(pio_addr_t addr);
58
59typedef struct PortioList {
60 const struct MemoryRegionPortio *ports;
61 Object *owner;
62 struct MemoryRegion *address_space;
63 unsigned nr;
64 struct MemoryRegion **regions;
65 void *opaque;
66 const char *name;
67 bool flush_coalesced_mmio;
68} PortioList;
69
70void portio_list_init(PortioList *piolist, Object *owner,
71 const struct MemoryRegionPortio *callbacks,
72 void *opaque, const char *name);
73void portio_list_set_flush_coalesced(PortioList *piolist);
74void portio_list_destroy(PortioList *piolist);
75void portio_list_add(PortioList *piolist,
76 struct MemoryRegion *address_space,
77 uint32_t addr);
78void portio_list_del(PortioList *piolist);
79
80#endif
81