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 "exec/memory.h"
28
29#define MAX_IOPORTS (64 * 1024)
30#define IOPORTS_MASK (MAX_IOPORTS - 1)
31
32typedef struct MemoryRegionPortio {
33 uint32_t offset;
34 uint32_t len;
35 unsigned size;
36 uint32_t (*read)(void *opaque, uint32_t address);
37 void (*write)(void *opaque, uint32_t address, uint32_t data);
38 uint32_t base;
39} MemoryRegionPortio;
40
41#define PORTIO_END_OF_LIST() { }
42
43#ifndef CONFIG_USER_ONLY
44extern const MemoryRegionOps unassigned_io_ops;
45#endif
46
47void cpu_outb(uint32_t addr, uint8_t val);
48void cpu_outw(uint32_t addr, uint16_t val);
49void cpu_outl(uint32_t addr, uint32_t val);
50uint8_t cpu_inb(uint32_t addr);
51uint16_t cpu_inw(uint32_t addr);
52uint32_t cpu_inl(uint32_t addr);
53
54typedef struct PortioList {
55 const struct MemoryRegionPortio *ports;
56 Object *owner;
57 struct MemoryRegion *address_space;
58 unsigned nr;
59 struct MemoryRegion **regions;
60 void *opaque;
61 const char *name;
62 bool flush_coalesced_mmio;
63} PortioList;
64
65void portio_list_init(PortioList *piolist, Object *owner,
66 const struct MemoryRegionPortio *callbacks,
67 void *opaque, const char *name);
68void portio_list_set_flush_coalesced(PortioList *piolist);
69void portio_list_destroy(PortioList *piolist);
70void portio_list_add(PortioList *piolist,
71 struct MemoryRegion *address_space,
72 uint32_t addr);
73void portio_list_del(PortioList *piolist);
74
75#endif
76