root / hw / hw.h @ 6806e595
History | View | Annotate | Download (7.8 kB)
1 | 87ecb68b | pbrook | /* Declarations for use by hardware emulation. */
|
---|---|---|---|
2 | 87ecb68b | pbrook | #ifndef QEMU_HW_H
|
3 | 87ecb68b | pbrook | #define QEMU_HW_H
|
4 | 87ecb68b | pbrook | |
5 | 87ecb68b | pbrook | #include "qemu-common.h" |
6 | 1ad2134f | Paul Brook | |
7 | 1ad2134f | Paul Brook | #if defined(TARGET_PHYS_ADDR_BITS) && !defined(NEED_CPU_H)
|
8 | 1ad2134f | Paul Brook | #include "targphys.h" |
9 | 1ad2134f | Paul Brook | #include "poison.h" |
10 | 1ad2134f | Paul Brook | #include "cpu-common.h" |
11 | 1ad2134f | Paul Brook | #endif
|
12 | 1ad2134f | Paul Brook | |
13 | 87ecb68b | pbrook | #include "irq.h" |
14 | 87ecb68b | pbrook | |
15 | 87ecb68b | pbrook | /* VM Load/Save */
|
16 | 87ecb68b | pbrook | |
17 | 5dafc53f | aliguori | /* This function writes a chunk of data to a file at the given position.
|
18 | 5dafc53f | aliguori | * The pos argument can be ignored if the file is only being used for
|
19 | 5dafc53f | aliguori | * streaming. The handler should try to write all of the data it can.
|
20 | 5dafc53f | aliguori | */
|
21 | 871d2f07 | aliguori | typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, |
22 | 871d2f07 | aliguori | int64_t pos, int size);
|
23 | 5dafc53f | aliguori | |
24 | 5dafc53f | aliguori | /* Read a chunk of data from a file at the given position. The pos argument
|
25 | 5dafc53f | aliguori | * can be ignored if the file is only be used for streaming. The number of
|
26 | 5dafc53f | aliguori | * bytes actually read should be returned.
|
27 | 5dafc53f | aliguori | */
|
28 | 5dafc53f | aliguori | typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, |
29 | 5dafc53f | aliguori | int64_t pos, int size);
|
30 | 5dafc53f | aliguori | |
31 | 5dafc53f | aliguori | /* Close a file and return an error code */
|
32 | 5dafc53f | aliguori | typedef int (QEMUFileCloseFunc)(void *opaque); |
33 | 5dafc53f | aliguori | |
34 | 5dafc53f | aliguori | /* Called to determine if the file has exceeded it's bandwidth allocation. The
|
35 | 5dafc53f | aliguori | * bandwidth capping is a soft limit, not a hard limit.
|
36 | 5dafc53f | aliguori | */
|
37 | 5dafc53f | aliguori | typedef int (QEMUFileRateLimit)(void *opaque); |
38 | 5dafc53f | aliguori | |
39 | 19629537 | Glauber Costa | /* Called to change the current bandwidth allocation. This function must return
|
40 | 19629537 | Glauber Costa | * the new actual bandwidth. It should be new_rate if everything goes ok, and
|
41 | 19629537 | Glauber Costa | * the old rate otherwise
|
42 | 19629537 | Glauber Costa | */
|
43 | 19629537 | Glauber Costa | typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate); |
44 | 19629537 | Glauber Costa | |
45 | 5dafc53f | aliguori | QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
|
46 | 5dafc53f | aliguori | QEMUFileGetBufferFunc *get_buffer, |
47 | 5dafc53f | aliguori | QEMUFileCloseFunc *close, |
48 | 19629537 | Glauber Costa | QEMUFileRateLimit *rate_limit, |
49 | 19629537 | Glauber Costa | QEMUFileSetRateLimit *set_rate_limit); |
50 | 87ecb68b | pbrook | QEMUFile *qemu_fopen(const char *filename, const char *mode); |
51 | c1d36665 | aliguori | QEMUFile *qemu_fopen_socket(int fd);
|
52 | 065e2813 | aliguori | QEMUFile *qemu_popen(FILE *popen_file, const char *mode); |
53 | 065e2813 | aliguori | QEMUFile *qemu_popen_cmd(const char *command, const char *mode); |
54 | 8a43b1ea | Chris Lalancette | int qemu_popen_fd(QEMUFile *f);
|
55 | 87ecb68b | pbrook | void qemu_fflush(QEMUFile *f);
|
56 | 5dafc53f | aliguori | int qemu_fclose(QEMUFile *f);
|
57 | 2ca83a8d | blueswir1 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
58 | 2ca83a8d | blueswir1 | void qemu_put_byte(QEMUFile *f, int v); |
59 | b6c4f71f | blueswir1 | |
60 | b6c4f71f | blueswir1 | static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) |
61 | b6c4f71f | blueswir1 | { |
62 | b6c4f71f | blueswir1 | qemu_put_byte(f, (int)v);
|
63 | b6c4f71f | blueswir1 | } |
64 | b6c4f71f | blueswir1 | |
65 | b6c4f71f | blueswir1 | #define qemu_put_sbyte qemu_put_byte
|
66 | b6c4f71f | blueswir1 | |
67 | 2ca83a8d | blueswir1 | void qemu_put_be16(QEMUFile *f, unsigned int v); |
68 | 2ca83a8d | blueswir1 | void qemu_put_be32(QEMUFile *f, unsigned int v); |
69 | 87ecb68b | pbrook | void qemu_put_be64(QEMUFile *f, uint64_t v);
|
70 | 2ca83a8d | blueswir1 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
71 | 2ca83a8d | blueswir1 | int qemu_get_byte(QEMUFile *f);
|
72 | b6c4f71f | blueswir1 | |
73 | b6c4f71f | blueswir1 | static inline unsigned int qemu_get_ubyte(QEMUFile *f) |
74 | b6c4f71f | blueswir1 | { |
75 | b6c4f71f | blueswir1 | return (unsigned int)qemu_get_byte(f); |
76 | b6c4f71f | blueswir1 | } |
77 | b6c4f71f | blueswir1 | |
78 | b6c4f71f | blueswir1 | #define qemu_get_sbyte qemu_get_byte
|
79 | b6c4f71f | blueswir1 | |
80 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be16(QEMUFile *f); |
81 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be32(QEMUFile *f); |
82 | 87ecb68b | pbrook | uint64_t qemu_get_be64(QEMUFile *f); |
83 | 5dafc53f | aliguori | int qemu_file_rate_limit(QEMUFile *f);
|
84 | 19629537 | Glauber Costa | size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate); |
85 | 871d2f07 | aliguori | int qemu_file_has_error(QEMUFile *f);
|
86 | 4dabe248 | aliguori | void qemu_file_set_error(QEMUFile *f);
|
87 | 5dafc53f | aliguori | |
88 | 5dafc53f | aliguori | /* Try to send any outstanding data. This function is useful when output is
|
89 | 5dafc53f | aliguori | * halted due to rate limiting or EAGAIN errors occur as it can be used to
|
90 | 5dafc53f | aliguori | * resume output. */
|
91 | 5dafc53f | aliguori | void qemu_file_put_notify(QEMUFile *f);
|
92 | 87ecb68b | pbrook | |
93 | 87ecb68b | pbrook | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
94 | 87ecb68b | pbrook | { |
95 | 87ecb68b | pbrook | qemu_put_be64(f, *pv); |
96 | 87ecb68b | pbrook | } |
97 | 87ecb68b | pbrook | |
98 | 87ecb68b | pbrook | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
99 | 87ecb68b | pbrook | { |
100 | 87ecb68b | pbrook | qemu_put_be32(f, *pv); |
101 | 87ecb68b | pbrook | } |
102 | 87ecb68b | pbrook | |
103 | 87ecb68b | pbrook | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
104 | 87ecb68b | pbrook | { |
105 | 87ecb68b | pbrook | qemu_put_be16(f, *pv); |
106 | 87ecb68b | pbrook | } |
107 | 87ecb68b | pbrook | |
108 | 87ecb68b | pbrook | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
109 | 87ecb68b | pbrook | { |
110 | 87ecb68b | pbrook | qemu_put_byte(f, *pv); |
111 | 87ecb68b | pbrook | } |
112 | 87ecb68b | pbrook | |
113 | 87ecb68b | pbrook | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
114 | 87ecb68b | pbrook | { |
115 | 87ecb68b | pbrook | *pv = qemu_get_be64(f); |
116 | 87ecb68b | pbrook | } |
117 | 87ecb68b | pbrook | |
118 | 87ecb68b | pbrook | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
119 | 87ecb68b | pbrook | { |
120 | 87ecb68b | pbrook | *pv = qemu_get_be32(f); |
121 | 87ecb68b | pbrook | } |
122 | 87ecb68b | pbrook | |
123 | 87ecb68b | pbrook | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
124 | 87ecb68b | pbrook | { |
125 | 87ecb68b | pbrook | *pv = qemu_get_be16(f); |
126 | 87ecb68b | pbrook | } |
127 | 87ecb68b | pbrook | |
128 | 87ecb68b | pbrook | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
129 | 87ecb68b | pbrook | { |
130 | 87ecb68b | pbrook | *pv = qemu_get_byte(f); |
131 | 87ecb68b | pbrook | } |
132 | 87ecb68b | pbrook | |
133 | b6c4f71f | blueswir1 | // Signed versions for type safety
|
134 | b6c4f71f | blueswir1 | static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) |
135 | b6c4f71f | blueswir1 | { |
136 | b6c4f71f | blueswir1 | qemu_put_buffer(f, (const uint8_t *)buf, size);
|
137 | b6c4f71f | blueswir1 | } |
138 | b6c4f71f | blueswir1 | |
139 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe16(QEMUFile *f, int v) |
140 | b6c4f71f | blueswir1 | { |
141 | b6c4f71f | blueswir1 | qemu_put_be16(f, (unsigned int)v); |
142 | b6c4f71f | blueswir1 | } |
143 | b6c4f71f | blueswir1 | |
144 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe32(QEMUFile *f, int v) |
145 | b6c4f71f | blueswir1 | { |
146 | b6c4f71f | blueswir1 | qemu_put_be32(f, (unsigned int)v); |
147 | b6c4f71f | blueswir1 | } |
148 | b6c4f71f | blueswir1 | |
149 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) |
150 | b6c4f71f | blueswir1 | { |
151 | b6c4f71f | blueswir1 | qemu_put_be64(f, (uint64_t)v); |
152 | b6c4f71f | blueswir1 | } |
153 | b6c4f71f | blueswir1 | |
154 | b6c4f71f | blueswir1 | static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) |
155 | b6c4f71f | blueswir1 | { |
156 | b6c4f71f | blueswir1 | return qemu_get_buffer(f, (uint8_t *)buf, size);
|
157 | b6c4f71f | blueswir1 | } |
158 | b6c4f71f | blueswir1 | |
159 | b6c4f71f | blueswir1 | static inline int qemu_get_sbe16(QEMUFile *f) |
160 | b6c4f71f | blueswir1 | { |
161 | b6c4f71f | blueswir1 | return (int)qemu_get_be16(f); |
162 | b6c4f71f | blueswir1 | } |
163 | b6c4f71f | blueswir1 | |
164 | b6c4f71f | blueswir1 | static inline int qemu_get_sbe32(QEMUFile *f) |
165 | b6c4f71f | blueswir1 | { |
166 | b6c4f71f | blueswir1 | return (int)qemu_get_be32(f); |
167 | b6c4f71f | blueswir1 | } |
168 | b6c4f71f | blueswir1 | |
169 | b6c4f71f | blueswir1 | static inline int64_t qemu_get_sbe64(QEMUFile *f) |
170 | b6c4f71f | blueswir1 | { |
171 | b6c4f71f | blueswir1 | return (int64_t)qemu_get_be64(f);
|
172 | b6c4f71f | blueswir1 | } |
173 | b6c4f71f | blueswir1 | |
174 | b6c4f71f | blueswir1 | static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) |
175 | b6c4f71f | blueswir1 | { |
176 | b6c4f71f | blueswir1 | qemu_put_8s(f, (const uint8_t *)pv);
|
177 | b6c4f71f | blueswir1 | } |
178 | b6c4f71f | blueswir1 | |
179 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) |
180 | b6c4f71f | blueswir1 | { |
181 | b6c4f71f | blueswir1 | qemu_put_be16s(f, (const uint16_t *)pv);
|
182 | b6c4f71f | blueswir1 | } |
183 | b6c4f71f | blueswir1 | |
184 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) |
185 | b6c4f71f | blueswir1 | { |
186 | b6c4f71f | blueswir1 | qemu_put_be32s(f, (const uint32_t *)pv);
|
187 | b6c4f71f | blueswir1 | } |
188 | b6c4f71f | blueswir1 | |
189 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) |
190 | b6c4f71f | blueswir1 | { |
191 | b6c4f71f | blueswir1 | qemu_put_be64s(f, (const uint64_t *)pv);
|
192 | b6c4f71f | blueswir1 | } |
193 | b6c4f71f | blueswir1 | |
194 | b6c4f71f | blueswir1 | static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) |
195 | b6c4f71f | blueswir1 | { |
196 | b6c4f71f | blueswir1 | qemu_get_8s(f, (uint8_t *)pv); |
197 | b6c4f71f | blueswir1 | } |
198 | b6c4f71f | blueswir1 | |
199 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) |
200 | b6c4f71f | blueswir1 | { |
201 | b6c4f71f | blueswir1 | qemu_get_be16s(f, (uint16_t *)pv); |
202 | b6c4f71f | blueswir1 | } |
203 | b6c4f71f | blueswir1 | |
204 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) |
205 | b6c4f71f | blueswir1 | { |
206 | b6c4f71f | blueswir1 | qemu_get_be32s(f, (uint32_t *)pv); |
207 | b6c4f71f | blueswir1 | } |
208 | b6c4f71f | blueswir1 | |
209 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) |
210 | b6c4f71f | blueswir1 | { |
211 | b6c4f71f | blueswir1 | qemu_get_be64s(f, (uint64_t *)pv); |
212 | b6c4f71f | blueswir1 | } |
213 | b6c4f71f | blueswir1 | |
214 | 87ecb68b | pbrook | #ifdef NEED_CPU_H
|
215 | 87ecb68b | pbrook | #if TARGET_LONG_BITS == 64 |
216 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be64
|
217 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be64
|
218 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be64s
|
219 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be64s
|
220 | b6c4f71f | blueswir1 | #define qemu_put_sbetl qemu_put_sbe64
|
221 | b6c4f71f | blueswir1 | #define qemu_get_sbetl qemu_get_sbe64
|
222 | b6c4f71f | blueswir1 | #define qemu_put_sbetls qemu_put_sbe64s
|
223 | b6c4f71f | blueswir1 | #define qemu_get_sbetls qemu_get_sbe64s
|
224 | 87ecb68b | pbrook | #else
|
225 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be32
|
226 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be32
|
227 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be32s
|
228 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be32s
|
229 | b6c4f71f | blueswir1 | #define qemu_put_sbetl qemu_put_sbe32
|
230 | b6c4f71f | blueswir1 | #define qemu_get_sbetl qemu_get_sbe32
|
231 | b6c4f71f | blueswir1 | #define qemu_put_sbetls qemu_put_sbe32s
|
232 | b6c4f71f | blueswir1 | #define qemu_get_sbetls qemu_get_sbe32s
|
233 | 87ecb68b | pbrook | #endif
|
234 | 87ecb68b | pbrook | #endif
|
235 | 87ecb68b | pbrook | |
236 | 87ecb68b | pbrook | int64_t qemu_ftell(QEMUFile *f); |
237 | 87ecb68b | pbrook | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
238 | 87ecb68b | pbrook | |
239 | 87ecb68b | pbrook | typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
240 | 9366f418 | aliguori | typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque); |
241 | 87ecb68b | pbrook | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
242 | 87ecb68b | pbrook | |
243 | 87ecb68b | pbrook | int register_savevm(const char *idstr, |
244 | 87ecb68b | pbrook | int instance_id,
|
245 | 87ecb68b | pbrook | int version_id,
|
246 | 87ecb68b | pbrook | SaveStateHandler *save_state, |
247 | 87ecb68b | pbrook | LoadStateHandler *load_state, |
248 | 87ecb68b | pbrook | void *opaque);
|
249 | 87ecb68b | pbrook | |
250 | 9366f418 | aliguori | int register_savevm_live(const char *idstr, |
251 | 9366f418 | aliguori | int instance_id,
|
252 | 9366f418 | aliguori | int version_id,
|
253 | 9366f418 | aliguori | SaveLiveStateHandler *save_live_state, |
254 | 9366f418 | aliguori | SaveStateHandler *save_state, |
255 | 9366f418 | aliguori | LoadStateHandler *load_state, |
256 | 9366f418 | aliguori | void *opaque);
|
257 | 9366f418 | aliguori | |
258 | 41bd13af | aliguori | void unregister_savevm(const char *idstr, void *opaque); |
259 | 41bd13af | aliguori | |
260 | 87ecb68b | pbrook | typedef void QEMUResetHandler(void *opaque); |
261 | 87ecb68b | pbrook | |
262 | a08d4367 | Jan Kiszka | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
263 | 87ecb68b | pbrook | |
264 | 0ecdffbb | aurel32 | /* handler to set the boot_device for a specific type of QEMUMachine */
|
265 | 0ecdffbb | aurel32 | /* return 0 if success */
|
266 | 3b4366de | blueswir1 | typedef int QEMUBootSetHandler(void *opaque, const char *boot_device); |
267 | 3b4366de | blueswir1 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); |
268 | 0ecdffbb | aurel32 | |
269 | 87ecb68b | pbrook | /* These should really be in isa.h, but are here to make pc.h happy. */
|
270 | 87ecb68b | pbrook | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); |
271 | 87ecb68b | pbrook | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); |
272 | 87ecb68b | pbrook | |
273 | 87ecb68b | pbrook | #endif |