]>
Commit | Line | Data |
---|---|---|
32993977 IY |
1 | /* |
2 | * defines ioport related functions | |
3 | * | |
4 | * Copyright (c) 2003 Fabrice Bellard | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
61f3c91a | 9 | * version 2.1 of the License, or (at your option) any later version. |
32993977 IY |
10 | * |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
8167ee88 | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
32993977 IY |
18 | */ |
19 | ||
20 | /************************************************************************** | |
21 | * IO ports API | |
22 | */ | |
23 | ||
24 | #ifndef IOPORT_H | |
25 | #define IOPORT_H | |
26 | ||
ec150c7e MA |
27 | #include "exec/memory.h" |
28 | ||
32993977 | 29 | #define MAX_IOPORTS (64 * 1024) |
d56dd6cf | 30 | #define IOPORTS_MASK (MAX_IOPORTS - 1) |
32993977 | 31 | |
5767e4e1 JK |
32 | typedef 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; /* private field */ | |
39 | } MemoryRegionPortio; | |
40 | ||
41 | #define PORTIO_END_OF_LIST() { } | |
32993977 | 42 | |
3bb28b72 JK |
43 | #ifndef CONFIG_USER_ONLY |
44 | extern const MemoryRegionOps unassigned_io_ops; | |
45 | #endif | |
46 | ||
89a80e74 PB |
47 | void cpu_outb(uint32_t addr, uint8_t val); |
48 | void cpu_outw(uint32_t addr, uint16_t val); | |
49 | void cpu_outl(uint32_t addr, uint32_t val); | |
50 | uint8_t cpu_inb(uint32_t addr); | |
51 | uint16_t cpu_inw(uint32_t addr); | |
52 | uint32_t cpu_inl(uint32_t addr); | |
32993977 | 53 | |
6bf9fd43 AK |
54 | typedef struct PortioList { |
55 | const struct MemoryRegionPortio *ports; | |
db10ca90 | 56 | Object *owner; |
6bf9fd43 AK |
57 | struct MemoryRegion *address_space; |
58 | unsigned nr; | |
59 | struct MemoryRegion **regions; | |
60 | void *opaque; | |
61 | const char *name; | |
c76bc480 | 62 | bool flush_coalesced_mmio; |
6bf9fd43 AK |
63 | } PortioList; |
64 | ||
db10ca90 | 65 | void portio_list_init(PortioList *piolist, Object *owner, |
6bf9fd43 AK |
66 | const struct MemoryRegionPortio *callbacks, |
67 | void *opaque, const char *name); | |
c76bc480 | 68 | void portio_list_set_flush_coalesced(PortioList *piolist); |
6bf9fd43 AK |
69 | void portio_list_destroy(PortioList *piolist); |
70 | void portio_list_add(PortioList *piolist, | |
71 | struct MemoryRegion *address_space, | |
72 | uint32_t addr); | |
73 | void portio_list_del(PortioList *piolist); | |
74 | ||
32993977 | 75 | #endif /* IOPORT_H */ |