root / hw / hw.h @ dd4239d6
History | View | Annotate | Download (28.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 | f11f6a5f | Juan Quintela | #include <stdbool.h> |
14 | 32993977 | Isaku Yamahata | #include "ioport.h" |
15 | 87ecb68b | pbrook | #include "irq.h" |
16 | 87ecb68b | pbrook | |
17 | 87ecb68b | pbrook | /* VM Load/Save */
|
18 | 87ecb68b | pbrook | |
19 | 5dafc53f | aliguori | /* This function writes a chunk of data to a file at the given position.
|
20 | 5dafc53f | aliguori | * The pos argument can be ignored if the file is only being used for
|
21 | 5dafc53f | aliguori | * streaming. The handler should try to write all of the data it can.
|
22 | 5dafc53f | aliguori | */
|
23 | 871d2f07 | aliguori | typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, |
24 | 871d2f07 | aliguori | int64_t pos, int size);
|
25 | 5dafc53f | aliguori | |
26 | 5dafc53f | aliguori | /* Read a chunk of data from a file at the given position. The pos argument
|
27 | 5dafc53f | aliguori | * can be ignored if the file is only be used for streaming. The number of
|
28 | 5dafc53f | aliguori | * bytes actually read should be returned.
|
29 | 5dafc53f | aliguori | */
|
30 | 5dafc53f | aliguori | typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, |
31 | 5dafc53f | aliguori | int64_t pos, int size);
|
32 | 5dafc53f | aliguori | |
33 | 5dafc53f | aliguori | /* Close a file and return an error code */
|
34 | 5dafc53f | aliguori | typedef int (QEMUFileCloseFunc)(void *opaque); |
35 | 5dafc53f | aliguori | |
36 | 5dafc53f | aliguori | /* Called to determine if the file has exceeded it's bandwidth allocation. The
|
37 | 5dafc53f | aliguori | * bandwidth capping is a soft limit, not a hard limit.
|
38 | 5dafc53f | aliguori | */
|
39 | 5dafc53f | aliguori | typedef int (QEMUFileRateLimit)(void *opaque); |
40 | 5dafc53f | aliguori | |
41 | 19629537 | Glauber Costa | /* Called to change the current bandwidth allocation. This function must return
|
42 | 19629537 | Glauber Costa | * the new actual bandwidth. It should be new_rate if everything goes ok, and
|
43 | 19629537 | Glauber Costa | * the old rate otherwise
|
44 | 19629537 | Glauber Costa | */
|
45 | 19629537 | Glauber Costa | typedef size_t (QEMUFileSetRateLimit)(void *opaque, size_t new_rate); |
46 | c163b5ca | lirans@il.ibm.com | typedef size_t (QEMUFileGetRateLimit)(void *opaque); |
47 | 19629537 | Glauber Costa | |
48 | 5dafc53f | aliguori | QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
|
49 | 5dafc53f | aliguori | QEMUFileGetBufferFunc *get_buffer, |
50 | 5dafc53f | aliguori | QEMUFileCloseFunc *close, |
51 | 19629537 | Glauber Costa | QEMUFileRateLimit *rate_limit, |
52 | c163b5ca | lirans@il.ibm.com | QEMUFileSetRateLimit *set_rate_limit, |
53 | c163b5ca | lirans@il.ibm.com | QEMUFileGetRateLimit *get_rate_limit); |
54 | 87ecb68b | pbrook | QEMUFile *qemu_fopen(const char *filename, const char *mode); |
55 | 5ac1fad3 | Paolo Bonzini | QEMUFile *qemu_fdopen(int fd, const char *mode); |
56 | c1d36665 | aliguori | QEMUFile *qemu_fopen_socket(int fd);
|
57 | 065e2813 | aliguori | QEMUFile *qemu_popen(FILE *popen_file, const char *mode); |
58 | 065e2813 | aliguori | QEMUFile *qemu_popen_cmd(const char *command, const char *mode); |
59 | 7f79dd28 | Paolo Bonzini | int qemu_stdio_fd(QEMUFile *f);
|
60 | 87ecb68b | pbrook | void qemu_fflush(QEMUFile *f);
|
61 | 5dafc53f | aliguori | int qemu_fclose(QEMUFile *f);
|
62 | 2ca83a8d | blueswir1 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
63 | 2ca83a8d | blueswir1 | void qemu_put_byte(QEMUFile *f, int v); |
64 | b6c4f71f | blueswir1 | |
65 | b6c4f71f | blueswir1 | static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) |
66 | b6c4f71f | blueswir1 | { |
67 | b6c4f71f | blueswir1 | qemu_put_byte(f, (int)v);
|
68 | b6c4f71f | blueswir1 | } |
69 | b6c4f71f | blueswir1 | |
70 | b6c4f71f | blueswir1 | #define qemu_put_sbyte qemu_put_byte
|
71 | b6c4f71f | blueswir1 | |
72 | 2ca83a8d | blueswir1 | void qemu_put_be16(QEMUFile *f, unsigned int v); |
73 | 2ca83a8d | blueswir1 | void qemu_put_be32(QEMUFile *f, unsigned int v); |
74 | 87ecb68b | pbrook | void qemu_put_be64(QEMUFile *f, uint64_t v);
|
75 | 2ca83a8d | blueswir1 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
76 | 2ca83a8d | blueswir1 | int qemu_get_byte(QEMUFile *f);
|
77 | b6c4f71f | blueswir1 | |
78 | b6c4f71f | blueswir1 | static inline unsigned int qemu_get_ubyte(QEMUFile *f) |
79 | b6c4f71f | blueswir1 | { |
80 | b6c4f71f | blueswir1 | return (unsigned int)qemu_get_byte(f); |
81 | b6c4f71f | blueswir1 | } |
82 | b6c4f71f | blueswir1 | |
83 | b6c4f71f | blueswir1 | #define qemu_get_sbyte qemu_get_byte
|
84 | b6c4f71f | blueswir1 | |
85 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be16(QEMUFile *f); |
86 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be32(QEMUFile *f); |
87 | 87ecb68b | pbrook | uint64_t qemu_get_be64(QEMUFile *f); |
88 | 5dafc53f | aliguori | int qemu_file_rate_limit(QEMUFile *f);
|
89 | 19629537 | Glauber Costa | size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate); |
90 | c163b5ca | lirans@il.ibm.com | size_t qemu_file_get_rate_limit(QEMUFile *f); |
91 | 871d2f07 | aliguori | int qemu_file_has_error(QEMUFile *f);
|
92 | 4dabe248 | aliguori | void qemu_file_set_error(QEMUFile *f);
|
93 | 5dafc53f | aliguori | |
94 | 5dafc53f | aliguori | /* Try to send any outstanding data. This function is useful when output is
|
95 | 5dafc53f | aliguori | * halted due to rate limiting or EAGAIN errors occur as it can be used to
|
96 | 5dafc53f | aliguori | * resume output. */
|
97 | 5dafc53f | aliguori | void qemu_file_put_notify(QEMUFile *f);
|
98 | 87ecb68b | pbrook | |
99 | 87ecb68b | pbrook | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
100 | 87ecb68b | pbrook | { |
101 | 87ecb68b | pbrook | qemu_put_be64(f, *pv); |
102 | 87ecb68b | pbrook | } |
103 | 87ecb68b | pbrook | |
104 | 87ecb68b | pbrook | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
105 | 87ecb68b | pbrook | { |
106 | 87ecb68b | pbrook | qemu_put_be32(f, *pv); |
107 | 87ecb68b | pbrook | } |
108 | 87ecb68b | pbrook | |
109 | 87ecb68b | pbrook | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
110 | 87ecb68b | pbrook | { |
111 | 87ecb68b | pbrook | qemu_put_be16(f, *pv); |
112 | 87ecb68b | pbrook | } |
113 | 87ecb68b | pbrook | |
114 | 87ecb68b | pbrook | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
115 | 87ecb68b | pbrook | { |
116 | 87ecb68b | pbrook | qemu_put_byte(f, *pv); |
117 | 87ecb68b | pbrook | } |
118 | 87ecb68b | pbrook | |
119 | 87ecb68b | pbrook | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
120 | 87ecb68b | pbrook | { |
121 | 87ecb68b | pbrook | *pv = qemu_get_be64(f); |
122 | 87ecb68b | pbrook | } |
123 | 87ecb68b | pbrook | |
124 | 87ecb68b | pbrook | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
125 | 87ecb68b | pbrook | { |
126 | 87ecb68b | pbrook | *pv = qemu_get_be32(f); |
127 | 87ecb68b | pbrook | } |
128 | 87ecb68b | pbrook | |
129 | 87ecb68b | pbrook | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
130 | 87ecb68b | pbrook | { |
131 | 87ecb68b | pbrook | *pv = qemu_get_be16(f); |
132 | 87ecb68b | pbrook | } |
133 | 87ecb68b | pbrook | |
134 | 87ecb68b | pbrook | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
135 | 87ecb68b | pbrook | { |
136 | 87ecb68b | pbrook | *pv = qemu_get_byte(f); |
137 | 87ecb68b | pbrook | } |
138 | 87ecb68b | pbrook | |
139 | b6c4f71f | blueswir1 | // Signed versions for type safety
|
140 | b6c4f71f | blueswir1 | static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) |
141 | b6c4f71f | blueswir1 | { |
142 | b6c4f71f | blueswir1 | qemu_put_buffer(f, (const uint8_t *)buf, size);
|
143 | b6c4f71f | blueswir1 | } |
144 | b6c4f71f | blueswir1 | |
145 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe16(QEMUFile *f, int v) |
146 | b6c4f71f | blueswir1 | { |
147 | b6c4f71f | blueswir1 | qemu_put_be16(f, (unsigned int)v); |
148 | b6c4f71f | blueswir1 | } |
149 | b6c4f71f | blueswir1 | |
150 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe32(QEMUFile *f, int v) |
151 | b6c4f71f | blueswir1 | { |
152 | b6c4f71f | blueswir1 | qemu_put_be32(f, (unsigned int)v); |
153 | b6c4f71f | blueswir1 | } |
154 | b6c4f71f | blueswir1 | |
155 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) |
156 | b6c4f71f | blueswir1 | { |
157 | b6c4f71f | blueswir1 | qemu_put_be64(f, (uint64_t)v); |
158 | b6c4f71f | blueswir1 | } |
159 | b6c4f71f | blueswir1 | |
160 | b6c4f71f | blueswir1 | static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) |
161 | b6c4f71f | blueswir1 | { |
162 | b6c4f71f | blueswir1 | return qemu_get_buffer(f, (uint8_t *)buf, size);
|
163 | b6c4f71f | blueswir1 | } |
164 | b6c4f71f | blueswir1 | |
165 | b6c4f71f | blueswir1 | static inline int qemu_get_sbe16(QEMUFile *f) |
166 | b6c4f71f | blueswir1 | { |
167 | b6c4f71f | blueswir1 | return (int)qemu_get_be16(f); |
168 | b6c4f71f | blueswir1 | } |
169 | b6c4f71f | blueswir1 | |
170 | b6c4f71f | blueswir1 | static inline int qemu_get_sbe32(QEMUFile *f) |
171 | b6c4f71f | blueswir1 | { |
172 | b6c4f71f | blueswir1 | return (int)qemu_get_be32(f); |
173 | b6c4f71f | blueswir1 | } |
174 | b6c4f71f | blueswir1 | |
175 | b6c4f71f | blueswir1 | static inline int64_t qemu_get_sbe64(QEMUFile *f) |
176 | b6c4f71f | blueswir1 | { |
177 | b6c4f71f | blueswir1 | return (int64_t)qemu_get_be64(f);
|
178 | b6c4f71f | blueswir1 | } |
179 | b6c4f71f | blueswir1 | |
180 | b6c4f71f | blueswir1 | static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) |
181 | b6c4f71f | blueswir1 | { |
182 | b6c4f71f | blueswir1 | qemu_put_8s(f, (const uint8_t *)pv);
|
183 | b6c4f71f | blueswir1 | } |
184 | b6c4f71f | blueswir1 | |
185 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) |
186 | b6c4f71f | blueswir1 | { |
187 | b6c4f71f | blueswir1 | qemu_put_be16s(f, (const uint16_t *)pv);
|
188 | b6c4f71f | blueswir1 | } |
189 | b6c4f71f | blueswir1 | |
190 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) |
191 | b6c4f71f | blueswir1 | { |
192 | b6c4f71f | blueswir1 | qemu_put_be32s(f, (const uint32_t *)pv);
|
193 | b6c4f71f | blueswir1 | } |
194 | b6c4f71f | blueswir1 | |
195 | b6c4f71f | blueswir1 | static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) |
196 | b6c4f71f | blueswir1 | { |
197 | b6c4f71f | blueswir1 | qemu_put_be64s(f, (const uint64_t *)pv);
|
198 | b6c4f71f | blueswir1 | } |
199 | b6c4f71f | blueswir1 | |
200 | b6c4f71f | blueswir1 | static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) |
201 | b6c4f71f | blueswir1 | { |
202 | b6c4f71f | blueswir1 | qemu_get_8s(f, (uint8_t *)pv); |
203 | b6c4f71f | blueswir1 | } |
204 | b6c4f71f | blueswir1 | |
205 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) |
206 | b6c4f71f | blueswir1 | { |
207 | b6c4f71f | blueswir1 | qemu_get_be16s(f, (uint16_t *)pv); |
208 | b6c4f71f | blueswir1 | } |
209 | b6c4f71f | blueswir1 | |
210 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) |
211 | b6c4f71f | blueswir1 | { |
212 | b6c4f71f | blueswir1 | qemu_get_be32s(f, (uint32_t *)pv); |
213 | b6c4f71f | blueswir1 | } |
214 | b6c4f71f | blueswir1 | |
215 | b6c4f71f | blueswir1 | static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) |
216 | b6c4f71f | blueswir1 | { |
217 | b6c4f71f | blueswir1 | qemu_get_be64s(f, (uint64_t *)pv); |
218 | b6c4f71f | blueswir1 | } |
219 | b6c4f71f | blueswir1 | |
220 | 87ecb68b | pbrook | #ifdef NEED_CPU_H
|
221 | 87ecb68b | pbrook | #if TARGET_LONG_BITS == 64 |
222 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be64
|
223 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be64
|
224 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be64s
|
225 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be64s
|
226 | b6c4f71f | blueswir1 | #define qemu_put_sbetl qemu_put_sbe64
|
227 | b6c4f71f | blueswir1 | #define qemu_get_sbetl qemu_get_sbe64
|
228 | b6c4f71f | blueswir1 | #define qemu_put_sbetls qemu_put_sbe64s
|
229 | b6c4f71f | blueswir1 | #define qemu_get_sbetls qemu_get_sbe64s
|
230 | 87ecb68b | pbrook | #else
|
231 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be32
|
232 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be32
|
233 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be32s
|
234 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be32s
|
235 | b6c4f71f | blueswir1 | #define qemu_put_sbetl qemu_put_sbe32
|
236 | b6c4f71f | blueswir1 | #define qemu_get_sbetl qemu_get_sbe32
|
237 | b6c4f71f | blueswir1 | #define qemu_put_sbetls qemu_put_sbe32s
|
238 | b6c4f71f | blueswir1 | #define qemu_get_sbetls qemu_get_sbe32s
|
239 | 87ecb68b | pbrook | #endif
|
240 | 87ecb68b | pbrook | #endif
|
241 | 87ecb68b | pbrook | |
242 | 87ecb68b | pbrook | int64_t qemu_ftell(QEMUFile *f); |
243 | 87ecb68b | pbrook | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
244 | 87ecb68b | pbrook | |
245 | c163b5ca | lirans@il.ibm.com | typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque); |
246 | 87ecb68b | pbrook | typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
247 | 9366f418 | aliguori | typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque); |
248 | 87ecb68b | pbrook | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
249 | 87ecb68b | pbrook | |
250 | 87ecb68b | pbrook | int register_savevm(const char *idstr, |
251 | 87ecb68b | pbrook | int instance_id,
|
252 | 87ecb68b | pbrook | int version_id,
|
253 | 87ecb68b | pbrook | SaveStateHandler *save_state, |
254 | 87ecb68b | pbrook | LoadStateHandler *load_state, |
255 | 87ecb68b | pbrook | void *opaque);
|
256 | 87ecb68b | pbrook | |
257 | 9366f418 | aliguori | int register_savevm_live(const char *idstr, |
258 | 9366f418 | aliguori | int instance_id,
|
259 | 9366f418 | aliguori | int version_id,
|
260 | c163b5ca | lirans@il.ibm.com | SaveSetParamsHandler *set_params, |
261 | c163b5ca | lirans@il.ibm.com | SaveLiveStateHandler *save_live_state, |
262 | 9366f418 | aliguori | SaveStateHandler *save_state, |
263 | 9366f418 | aliguori | LoadStateHandler *load_state, |
264 | 9366f418 | aliguori | void *opaque);
|
265 | 9366f418 | aliguori | |
266 | 41bd13af | aliguori | void unregister_savevm(const char *idstr, void *opaque); |
267 | 41bd13af | aliguori | |
268 | 87ecb68b | pbrook | typedef void QEMUResetHandler(void *opaque); |
269 | 87ecb68b | pbrook | |
270 | a08d4367 | Jan Kiszka | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
271 | dda9b29f | Jan Kiszka | void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); |
272 | 87ecb68b | pbrook | |
273 | 76e30d0f | Jan Kiszka | /* handler to set the boot_device order for a specific type of QEMUMachine */
|
274 | 0ecdffbb | aurel32 | /* return 0 if success */
|
275 | 76e30d0f | Jan Kiszka | typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices); |
276 | 3b4366de | blueswir1 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); |
277 | 76e30d0f | Jan Kiszka | int qemu_boot_set(const char *boot_devices); |
278 | 0ecdffbb | aurel32 | |
279 | 9ed7d6ae | Juan Quintela | typedef struct VMStateInfo VMStateInfo; |
280 | 9ed7d6ae | Juan Quintela | typedef struct VMStateDescription VMStateDescription; |
281 | 9ed7d6ae | Juan Quintela | |
282 | 9ed7d6ae | Juan Quintela | struct VMStateInfo {
|
283 | 9ed7d6ae | Juan Quintela | const char *name; |
284 | 9ed7d6ae | Juan Quintela | int (*get)(QEMUFile *f, void *pv, size_t size); |
285 | 84e2e3eb | Juan Quintela | void (*put)(QEMUFile *f, void *pv, size_t size); |
286 | 9ed7d6ae | Juan Quintela | }; |
287 | 9ed7d6ae | Juan Quintela | |
288 | 9ed7d6ae | Juan Quintela | enum VMStateFlags {
|
289 | 5139931f | Juan Quintela | VMS_SINGLE = 0x001,
|
290 | 5139931f | Juan Quintela | VMS_POINTER = 0x002,
|
291 | 5139931f | Juan Quintela | VMS_ARRAY = 0x004,
|
292 | 5139931f | Juan Quintela | VMS_STRUCT = 0x008,
|
293 | bdb4941d | Juan Quintela | VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ |
294 | 5139931f | Juan Quintela | VMS_BUFFER = 0x020, /* static sized buffer */ |
295 | 19df438b | Juan Quintela | VMS_ARRAY_OF_POINTER = 0x040,
|
296 | bdb4941d | Juan Quintela | VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ |
297 | 9ed7d6ae | Juan Quintela | }; |
298 | 9ed7d6ae | Juan Quintela | |
299 | 9ed7d6ae | Juan Quintela | typedef struct { |
300 | 9ed7d6ae | Juan Quintela | const char *name; |
301 | 9ed7d6ae | Juan Quintela | size_t offset; |
302 | 9ed7d6ae | Juan Quintela | size_t size; |
303 | f752a6aa | Juan Quintela | int num;
|
304 | b00319a9 | Juan Quintela | size_t num_offset; |
305 | 9ed7d6ae | Juan Quintela | const VMStateInfo *info;
|
306 | 9ed7d6ae | Juan Quintela | enum VMStateFlags flags;
|
307 | ec245e21 | Juan Quintela | const VMStateDescription *vmsd;
|
308 | 9ed7d6ae | Juan Quintela | int version_id;
|
309 | f11f6a5f | Juan Quintela | bool (*field_exists)(void *opaque, int version_id); |
310 | 9ed7d6ae | Juan Quintela | } VMStateField; |
311 | 9ed7d6ae | Juan Quintela | |
312 | 9ed7d6ae | Juan Quintela | struct VMStateDescription {
|
313 | 9ed7d6ae | Juan Quintela | const char *name; |
314 | 9ed7d6ae | Juan Quintela | int version_id;
|
315 | 9ed7d6ae | Juan Quintela | int minimum_version_id;
|
316 | 9ed7d6ae | Juan Quintela | int minimum_version_id_old;
|
317 | 9ed7d6ae | Juan Quintela | LoadStateHandler *load_state_old; |
318 | fd4d52de | Juan Quintela | int (*pre_load)(void *opaque); |
319 | e59fb374 | Juan Quintela | int (*post_load)(void *opaque, int version_id); |
320 | d4bfa4d7 | Juan Quintela | void (*pre_save)(void *opaque); |
321 | d4bfa4d7 | Juan Quintela | void (*post_save)(void *opaque); |
322 | 9ed7d6ae | Juan Quintela | VMStateField *fields; |
323 | 9ed7d6ae | Juan Quintela | }; |
324 | 9ed7d6ae | Juan Quintela | |
325 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_int8; |
326 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_int16; |
327 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_int32; |
328 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_int64; |
329 | 9ed7d6ae | Juan Quintela | |
330 | 80cd83e7 | Juan Quintela | extern const VMStateInfo vmstate_info_uint8_equal; |
331 | dc3b83a0 | Juan Quintela | extern const VMStateInfo vmstate_info_uint16_equal; |
332 | 82501660 | Juan Quintela | extern const VMStateInfo vmstate_info_int32_equal; |
333 | 0a031e0a | Juan Quintela | extern const VMStateInfo vmstate_info_int32_le; |
334 | 82501660 | Juan Quintela | |
335 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_uint8; |
336 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_uint16; |
337 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_uint32; |
338 | 9ed7d6ae | Juan Quintela | extern const VMStateInfo vmstate_info_uint64; |
339 | 9ed7d6ae | Juan Quintela | |
340 | dde0463b | Juan Quintela | extern const VMStateInfo vmstate_info_timer; |
341 | 55a6e51f | Blue Swirl | extern const VMStateInfo vmstate_info_ptimer; |
342 | 6f67c50f | Juan Quintela | extern const VMStateInfo vmstate_info_buffer; |
343 | 76507c75 | Juan Quintela | extern const VMStateInfo vmstate_info_unused_buffer; |
344 | dde0463b | Juan Quintela | |
345 | f752a6aa | Juan Quintela | #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) |
346 | b00319a9 | Juan Quintela | #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) |
347 | f752a6aa | Juan Quintela | |
348 | 904ca304 | Juan Quintela | #define vmstate_offset_value(_state, _field, _type) \
|
349 | 904ca304 | Juan Quintela | (offsetof(_state, _field) + \ |
350 | 904ca304 | Juan Quintela | type_check(_type, typeof_field(_state, _field))) |
351 | 904ca304 | Juan Quintela | |
352 | c29d8b1e | Juan Quintela | #define vmstate_offset_pointer(_state, _field, _type) \
|
353 | c29d8b1e | Juan Quintela | (offsetof(_state, _field) + \ |
354 | c29d8b1e | Juan Quintela | type_check_pointer(_type, typeof_field(_state, _field))) |
355 | c29d8b1e | Juan Quintela | |
356 | 646bef19 | Juan Quintela | #define vmstate_offset_array(_state, _field, _type, _num) \
|
357 | 646bef19 | Juan Quintela | (offsetof(_state, _field) + \ |
358 | 646bef19 | Juan Quintela | type_check_array(_type, typeof_field(_state, _field), _num)) |
359 | 646bef19 | Juan Quintela | |
360 | 9ba2f660 | Juan Quintela | #define vmstate_offset_sub_array(_state, _field, _type, _start) \
|
361 | 9ba2f660 | Juan Quintela | (offsetof(_state, _field[_start])) |
362 | 9ba2f660 | Juan Quintela | |
363 | 844b236a | Juan Quintela | #define vmstate_offset_buffer(_state, _field) \
|
364 | 844b236a | Juan Quintela | vmstate_offset_array(_state, _field, uint8_t, \ |
365 | 844b236a | Juan Quintela | sizeof(typeof_field(_state, _field)))
|
366 | 844b236a | Juan Quintela | |
367 | d4829d49 | Juan Quintela | #define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
|
368 | f11f6a5f | Juan Quintela | .name = (stringify(_field)), \ |
369 | d4829d49 | Juan Quintela | .version_id = (_version), \ |
370 | f11f6a5f | Juan Quintela | .field_exists = (_test), \ |
371 | f11f6a5f | Juan Quintela | .size = sizeof(_type), \
|
372 | f11f6a5f | Juan Quintela | .info = &(_info), \ |
373 | f11f6a5f | Juan Quintela | .flags = VMS_SINGLE, \ |
374 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, _type), \ |
375 | f11f6a5f | Juan Quintela | } |
376 | f11f6a5f | Juan Quintela | |
377 | dde0463b | Juan Quintela | #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \
|
378 | dde0463b | Juan Quintela | .name = (stringify(_field)), \ |
379 | dde0463b | Juan Quintela | .version_id = (_version), \ |
380 | dde0463b | Juan Quintela | .info = &(_info), \ |
381 | dde0463b | Juan Quintela | .size = sizeof(_type), \
|
382 | dde0463b | Juan Quintela | .flags = VMS_SINGLE|VMS_POINTER, \ |
383 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, _type), \ |
384 | dde0463b | Juan Quintela | } |
385 | dde0463b | Juan Quintela | |
386 | f752a6aa | Juan Quintela | #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
|
387 | f752a6aa | Juan Quintela | .name = (stringify(_field)), \ |
388 | f752a6aa | Juan Quintela | .version_id = (_version), \ |
389 | f752a6aa | Juan Quintela | .num = (_num), \ |
390 | f752a6aa | Juan Quintela | .info = &(_info), \ |
391 | f752a6aa | Juan Quintela | .size = sizeof(_type), \
|
392 | f752a6aa | Juan Quintela | .flags = VMS_ARRAY, \ |
393 | 646bef19 | Juan Quintela | .offset = vmstate_offset_array(_state, _field, _type, _num), \ |
394 | f752a6aa | Juan Quintela | } |
395 | f752a6aa | Juan Quintela | |
396 | f11f6a5f | Juan Quintela | #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
|
397 | f11f6a5f | Juan Quintela | .name = (stringify(_field)), \ |
398 | f11f6a5f | Juan Quintela | .field_exists = (_test), \ |
399 | f11f6a5f | Juan Quintela | .num = (_num), \ |
400 | f11f6a5f | Juan Quintela | .info = &(_info), \ |
401 | f11f6a5f | Juan Quintela | .size = sizeof(_type), \
|
402 | f11f6a5f | Juan Quintela | .flags = VMS_ARRAY, \ |
403 | 646bef19 | Juan Quintela | .offset = vmstate_offset_array(_state, _field, _type, _num),\ |
404 | f11f6a5f | Juan Quintela | } |
405 | f11f6a5f | Juan Quintela | |
406 | 9ba2f660 | Juan Quintela | #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
|
407 | 9ba2f660 | Juan Quintela | .name = (stringify(_field)), \ |
408 | 9ba2f660 | Juan Quintela | .version_id = (_version), \ |
409 | 9ba2f660 | Juan Quintela | .num = (_num), \ |
410 | 9ba2f660 | Juan Quintela | .info = &(_info), \ |
411 | 9ba2f660 | Juan Quintela | .size = sizeof(_type), \
|
412 | 9ba2f660 | Juan Quintela | .flags = VMS_ARRAY, \ |
413 | 9ba2f660 | Juan Quintela | .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ |
414 | 9ba2f660 | Juan Quintela | } |
415 | 9ba2f660 | Juan Quintela | |
416 | d6698281 | Juan Quintela | #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
|
417 | b00319a9 | Juan Quintela | .name = (stringify(_field)), \ |
418 | b00319a9 | Juan Quintela | .version_id = (_version), \ |
419 | 904ca304 | Juan Quintela | .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ |
420 | b00319a9 | Juan Quintela | .info = &(_info), \ |
421 | b00319a9 | Juan Quintela | .size = sizeof(_type), \
|
422 | d6698281 | Juan Quintela | .flags = VMS_VARRAY_INT32|VMS_POINTER, \ |
423 | c29d8b1e | Juan Quintela | .offset = vmstate_offset_pointer(_state, _field, _type), \ |
424 | b00319a9 | Juan Quintela | } |
425 | b00319a9 | Juan Quintela | |
426 | bdb4941d | Juan Quintela | #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
|
427 | bdb4941d | Juan Quintela | .name = (stringify(_field)), \ |
428 | bdb4941d | Juan Quintela | .version_id = (_version), \ |
429 | bdb4941d | Juan Quintela | .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ |
430 | bdb4941d | Juan Quintela | .info = &(_info), \ |
431 | bdb4941d | Juan Quintela | .size = sizeof(_type), \
|
432 | bdb4941d | Juan Quintela | .flags = VMS_VARRAY_UINT16, \ |
433 | bdb4941d | Juan Quintela | .offset = offsetof(_state, _field), \ |
434 | bdb4941d | Juan Quintela | } |
435 | bdb4941d | Juan Quintela | |
436 | ec245e21 | Juan Quintela | #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) { \
|
437 | ec245e21 | Juan Quintela | .name = (stringify(_field)), \ |
438 | ec245e21 | Juan Quintela | .version_id = (_version), \ |
439 | ec245e21 | Juan Quintela | .vmsd = &(_vmsd), \ |
440 | ec245e21 | Juan Quintela | .size = sizeof(_type), \
|
441 | ec245e21 | Juan Quintela | .flags = VMS_STRUCT, \ |
442 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, _type), \ |
443 | ec245e21 | Juan Quintela | } |
444 | ec245e21 | Juan Quintela | |
445 | 840e9cef | Juan Quintela | #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) { \
|
446 | 840e9cef | Juan Quintela | .name = (stringify(_field)), \ |
447 | 840e9cef | Juan Quintela | .vmsd = &(_vmsd), \ |
448 | 840e9cef | Juan Quintela | .size = sizeof(_type), \
|
449 | 840e9cef | Juan Quintela | .flags = VMS_STRUCT|VMS_POINTER, \ |
450 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, _type), \ |
451 | 840e9cef | Juan Quintela | } |
452 | 840e9cef | Juan Quintela | |
453 | 19df438b | Juan Quintela | #define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
|
454 | 19df438b | Juan Quintela | .name = (stringify(_field)), \ |
455 | 19df438b | Juan Quintela | .version_id = (_version), \ |
456 | 19df438b | Juan Quintela | .num = (_num), \ |
457 | 19df438b | Juan Quintela | .info = &(_info), \ |
458 | 19df438b | Juan Quintela | .size = sizeof(_type), \
|
459 | 19df438b | Juan Quintela | .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ |
460 | 646bef19 | Juan Quintela | .offset = vmstate_offset_array(_state, _field, _type, _num), \ |
461 | 19df438b | Juan Quintela | } |
462 | 19df438b | Juan Quintela | |
463 | 79c451b9 | Juan Quintela | #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \
|
464 | 79c451b9 | Juan Quintela | .name = (stringify(_field)), \ |
465 | 79c451b9 | Juan Quintela | .num = (_num), \ |
466 | 79c451b9 | Juan Quintela | .version_id = (_version), \ |
467 | 79c451b9 | Juan Quintela | .vmsd = &(_vmsd), \ |
468 | 79c451b9 | Juan Quintela | .size = sizeof(_type), \
|
469 | 79c451b9 | Juan Quintela | .flags = VMS_STRUCT|VMS_ARRAY, \ |
470 | 646bef19 | Juan Quintela | .offset = vmstate_offset_array(_state, _field, _type, _num), \ |
471 | 79c451b9 | Juan Quintela | } |
472 | 79c451b9 | Juan Quintela | |
473 | 6680f01c | Juan Quintela | #define VMSTATE_STRUCT_ARRAY_SIZE_UINT8(_field, _state, _field__num, _version, _vmsd, _type) { \
|
474 | 6680f01c | Juan Quintela | .name = (stringify(_field)), \ |
475 | 904ca304 | Juan Quintela | .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ |
476 | 6680f01c | Juan Quintela | .version_id = (_version), \ |
477 | 6680f01c | Juan Quintela | .vmsd = &(_vmsd), \ |
478 | 6680f01c | Juan Quintela | .size = sizeof(_type), \
|
479 | 6680f01c | Juan Quintela | .flags = VMS_STRUCT|VMS_ARRAY, \ |
480 | 646bef19 | Juan Quintela | .offset = vmstate_offset_array(_state, _field, _type, _num), \ |
481 | 6680f01c | Juan Quintela | } |
482 | 6680f01c | Juan Quintela | |
483 | b2e15099 | Juan Quintela | #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
|
484 | 25dc563b | Juan Quintela | .name = (stringify(_field)), \ |
485 | b2e15099 | Juan Quintela | .version_id = (_version), \ |
486 | 25dc563b | Juan Quintela | .field_exists = (_test), \ |
487 | b2e15099 | Juan Quintela | .size = (_size - _start), \ |
488 | 25dc563b | Juan Quintela | .info = &vmstate_info_buffer, \ |
489 | 25dc563b | Juan Quintela | .flags = VMS_BUFFER, \ |
490 | b2e15099 | Juan Quintela | .offset = vmstate_offset_buffer(_state, _field) + _start, \ |
491 | 7e72abc3 | Juan Quintela | } |
492 | 7e72abc3 | Juan Quintela | |
493 | 9cae69bd | Isaku Yamahata | #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
|
494 | 1ae71a77 | Juan Quintela | .name = (stringify(_field)), \ |
495 | 1ae71a77 | Juan Quintela | .version_id = (_version), \ |
496 | 1ae71a77 | Juan Quintela | .size = (_size), \ |
497 | 9cae69bd | Isaku Yamahata | .info = &(_info), \ |
498 | 1ae71a77 | Juan Quintela | .flags = VMS_BUFFER, \ |
499 | 1ae71a77 | Juan Quintela | .offset = offsetof(_state, _field), \ |
500 | 1ae71a77 | Juan Quintela | } |
501 | 1ae71a77 | Juan Quintela | |
502 | 76507c75 | Juan Quintela | #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \
|
503 | 76507c75 | Juan Quintela | .name = "unused", \
|
504 | 76507c75 | Juan Quintela | .field_exists = (_test), \ |
505 | 76507c75 | Juan Quintela | .version_id = (_version), \ |
506 | 76507c75 | Juan Quintela | .size = (_size), \ |
507 | 76507c75 | Juan Quintela | .info = &vmstate_info_unused_buffer, \ |
508 | 76507c75 | Juan Quintela | .flags = VMS_BUFFER, \ |
509 | 76507c75 | Juan Quintela | } |
510 | 73534f2f | Juan Quintela | extern const VMStateDescription vmstate_pci_device; |
511 | 73534f2f | Juan Quintela | |
512 | 73534f2f | Juan Quintela | #define VMSTATE_PCI_DEVICE(_field, _state) { \
|
513 | 73534f2f | Juan Quintela | .name = (stringify(_field)), \ |
514 | 73534f2f | Juan Quintela | .size = sizeof(PCIDevice), \
|
515 | 73534f2f | Juan Quintela | .vmsd = &vmstate_pci_device, \ |
516 | 73534f2f | Juan Quintela | .flags = VMS_STRUCT, \ |
517 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, PCIDevice), \ |
518 | 73534f2f | Juan Quintela | } |
519 | 73534f2f | Juan Quintela | |
520 | a9f49946 | Isaku Yamahata | extern const VMStateDescription vmstate_pcie_device; |
521 | a9f49946 | Isaku Yamahata | |
522 | a9f49946 | Isaku Yamahata | #define VMSTATE_PCIE_DEVICE(_field, _state) { \
|
523 | a9f49946 | Isaku Yamahata | .name = (stringify(_field)), \ |
524 | a9f49946 | Isaku Yamahata | .version_id = 2, \
|
525 | a9f49946 | Isaku Yamahata | .size = sizeof(PCIDevice), \
|
526 | a9f49946 | Isaku Yamahata | .vmsd = &vmstate_pcie_device, \ |
527 | a9f49946 | Isaku Yamahata | .flags = VMS_STRUCT, \ |
528 | a9f49946 | Isaku Yamahata | .offset = vmstate_offset_value(_state, _field, PCIDevice), \ |
529 | a9f49946 | Isaku Yamahata | } |
530 | a9f49946 | Isaku Yamahata | |
531 | 1894839f | Juan Quintela | extern const VMStateDescription vmstate_i2c_slave; |
532 | 1894839f | Juan Quintela | |
533 | 1894839f | Juan Quintela | #define VMSTATE_I2C_SLAVE(_field, _state) { \
|
534 | 1894839f | Juan Quintela | .name = (stringify(_field)), \ |
535 | 1894839f | Juan Quintela | .size = sizeof(i2c_slave), \
|
536 | 1894839f | Juan Quintela | .vmsd = &vmstate_i2c_slave, \ |
537 | 1894839f | Juan Quintela | .flags = VMS_STRUCT, \ |
538 | 904ca304 | Juan Quintela | .offset = vmstate_offset_value(_state, _field, i2c_slave), \ |
539 | 1894839f | Juan Quintela | } |
540 | 1894839f | Juan Quintela | |
541 | 9e77fcd0 | Juan Quintela | #define vmstate_offset_macaddr(_state, _field) \
|
542 | 9e77fcd0 | Juan Quintela | vmstate_offset_array(_state, _field.a, uint8_t, \ |
543 | 9e77fcd0 | Juan Quintela | sizeof(typeof_field(_state, _field)))
|
544 | 9e77fcd0 | Juan Quintela | |
545 | 9e77fcd0 | Juan Quintela | #define VMSTATE_MACADDR(_field, _state) { \
|
546 | 9e77fcd0 | Juan Quintela | .name = (stringify(_field)), \ |
547 | 9e77fcd0 | Juan Quintela | .size = sizeof(MACAddr), \
|
548 | 9e77fcd0 | Juan Quintela | .info = &vmstate_info_uint8, \ |
549 | 9e77fcd0 | Juan Quintela | .flags = VMS_BUFFER, \ |
550 | 9e77fcd0 | Juan Quintela | .offset = vmstate_offset_macaddr(_state, _field), \ |
551 | 9e77fcd0 | Juan Quintela | } |
552 | 9e77fcd0 | Juan Quintela | |
553 | 9ed7d6ae | Juan Quintela | /* _f : field name
|
554 | b00319a9 | Juan Quintela | _f_n : num of elements field_name
|
555 | f752a6aa | Juan Quintela | _n : num of elements
|
556 | 9ed7d6ae | Juan Quintela | _s : struct state name
|
557 | 9ed7d6ae | Juan Quintela | _v : version
|
558 | 9ed7d6ae | Juan Quintela | */
|
559 | 9ed7d6ae | Juan Quintela | |
560 | d4829d49 | Juan Quintela | #define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \
|
561 | d4829d49 | Juan Quintela | VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type)
|
562 | d4829d49 | Juan Quintela | |
563 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT8_V(_f, _s, _v) \
|
564 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) |
565 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT16_V(_f, _s, _v) \
|
566 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) |
567 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT32_V(_f, _s, _v) \
|
568 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) |
569 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT64_V(_f, _s, _v) \
|
570 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) |
571 | 9ed7d6ae | Juan Quintela | |
572 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT8_V(_f, _s, _v) \
|
573 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) |
574 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT16_V(_f, _s, _v) \
|
575 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) |
576 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT32_V(_f, _s, _v) \
|
577 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) |
578 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT64_V(_f, _s, _v) \
|
579 | 9ed7d6ae | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) |
580 | 9ed7d6ae | Juan Quintela | |
581 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT8(_f, _s) \
|
582 | 9ed7d6ae | Juan Quintela | VMSTATE_INT8_V(_f, _s, 0)
|
583 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT16(_f, _s) \
|
584 | 9ed7d6ae | Juan Quintela | VMSTATE_INT16_V(_f, _s, 0)
|
585 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT32(_f, _s) \
|
586 | 9ed7d6ae | Juan Quintela | VMSTATE_INT32_V(_f, _s, 0)
|
587 | 9ed7d6ae | Juan Quintela | #define VMSTATE_INT64(_f, _s) \
|
588 | 9ed7d6ae | Juan Quintela | VMSTATE_INT64_V(_f, _s, 0)
|
589 | 9ed7d6ae | Juan Quintela | |
590 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT8(_f, _s) \
|
591 | 9ed7d6ae | Juan Quintela | VMSTATE_UINT8_V(_f, _s, 0)
|
592 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT16(_f, _s) \
|
593 | 9ed7d6ae | Juan Quintela | VMSTATE_UINT16_V(_f, _s, 0)
|
594 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT32(_f, _s) \
|
595 | 9ed7d6ae | Juan Quintela | VMSTATE_UINT32_V(_f, _s, 0)
|
596 | 9ed7d6ae | Juan Quintela | #define VMSTATE_UINT64(_f, _s) \
|
597 | 9ed7d6ae | Juan Quintela | VMSTATE_UINT64_V(_f, _s, 0)
|
598 | 9ed7d6ae | Juan Quintela | |
599 | 80cd83e7 | Juan Quintela | #define VMSTATE_UINT8_EQUAL(_f, _s) \
|
600 | 80cd83e7 | Juan Quintela | VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
|
601 | 80cd83e7 | Juan Quintela | |
602 | dc3b83a0 | Juan Quintela | #define VMSTATE_UINT16_EQUAL(_f, _s) \
|
603 | dc3b83a0 | Juan Quintela | VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
|
604 | dc3b83a0 | Juan Quintela | |
605 | dc3b83a0 | Juan Quintela | #define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
|
606 | dc3b83a0 | Juan Quintela | VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) |
607 | dc3b83a0 | Juan Quintela | |
608 | 82501660 | Juan Quintela | #define VMSTATE_INT32_EQUAL(_f, _s) \
|
609 | 82501660 | Juan Quintela | VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
|
610 | 82501660 | Juan Quintela | |
611 | 0a031e0a | Juan Quintela | #define VMSTATE_INT32_LE(_f, _s) \
|
612 | 0a031e0a | Juan Quintela | VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
|
613 | 0a031e0a | Juan Quintela | |
614 | f11f6a5f | Juan Quintela | #define VMSTATE_UINT32_TEST(_f, _s, _t) \
|
615 | d4829d49 | Juan Quintela | VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
|
616 | f11f6a5f | Juan Quintela | |
617 | dde0463b | Juan Quintela | #define VMSTATE_TIMER_V(_f, _s, _v) \
|
618 | dde0463b | Juan Quintela | VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) |
619 | dde0463b | Juan Quintela | |
620 | dde0463b | Juan Quintela | #define VMSTATE_TIMER(_f, _s) \
|
621 | dde0463b | Juan Quintela | VMSTATE_TIMER_V(_f, _s, 0)
|
622 | dde0463b | Juan Quintela | |
623 | 19df438b | Juan Quintela | #define VMSTATE_TIMER_ARRAY(_f, _s, _n) \
|
624 | 19df438b | Juan Quintela | VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
|
625 | 19df438b | Juan Quintela | |
626 | 55a6e51f | Blue Swirl | #define VMSTATE_PTIMER_V(_f, _s, _v) \
|
627 | 55a6e51f | Blue Swirl | VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *) |
628 | 55a6e51f | Blue Swirl | |
629 | 55a6e51f | Blue Swirl | #define VMSTATE_PTIMER(_f, _s) \
|
630 | 55a6e51f | Blue Swirl | VMSTATE_PTIMER_V(_f, _s, 0)
|
631 | 55a6e51f | Blue Swirl | |
632 | 632cf073 | Juan Quintela | #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
|
633 | 632cf073 | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) |
634 | 632cf073 | Juan Quintela | |
635 | 632cf073 | Juan Quintela | #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \
|
636 | 632cf073 | Juan Quintela | VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
|
637 | 632cf073 | Juan Quintela | |
638 | b6bd0bdc | Juan Quintela | #define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \
|
639 | b6bd0bdc | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) |
640 | b6bd0bdc | Juan Quintela | |
641 | b6bd0bdc | Juan Quintela | #define VMSTATE_UINT8_ARRAY(_f, _s, _n) \
|
642 | b6bd0bdc | Juan Quintela | VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
|
643 | b6bd0bdc | Juan Quintela | |
644 | f752a6aa | Juan Quintela | #define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \
|
645 | f752a6aa | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) |
646 | f752a6aa | Juan Quintela | |
647 | f752a6aa | Juan Quintela | #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
|
648 | f752a6aa | Juan Quintela | VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
|
649 | f752a6aa | Juan Quintela | |
650 | 80a04bbe | Juan Quintela | #define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \
|
651 | 80a04bbe | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) |
652 | 80a04bbe | Juan Quintela | |
653 | 80a04bbe | Juan Quintela | #define VMSTATE_UINT64_ARRAY(_f, _s, _n) \
|
654 | 80a04bbe | Juan Quintela | VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
|
655 | 80a04bbe | Juan Quintela | |
656 | 289070c7 | Juan Quintela | #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \
|
657 | 289070c7 | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) |
658 | 289070c7 | Juan Quintela | |
659 | 289070c7 | Juan Quintela | #define VMSTATE_INT16_ARRAY(_f, _s, _n) \
|
660 | 289070c7 | Juan Quintela | VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
|
661 | 289070c7 | Juan Quintela | |
662 | f752a6aa | Juan Quintela | #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \
|
663 | f752a6aa | Juan Quintela | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) |
664 | f752a6aa | Juan Quintela | |
665 | f752a6aa | Juan Quintela | #define VMSTATE_INT32_ARRAY(_f, _s, _n) \
|
666 | f752a6aa | Juan Quintela | VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
|
667 | f752a6aa | Juan Quintela | |
668 | 9ba2f660 | Juan Quintela | #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \
|
669 | 9ba2f660 | Juan Quintela | VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
|
670 | 9ba2f660 | Juan Quintela | |
671 | 9ba2f660 | Juan Quintela | #define VMSTATE_UINT32_ARRAY(_f, _s, _n) \
|
672 | 9ba2f660 | Juan Quintela | VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
|
673 | 9ba2f660 | Juan Quintela | |
674 | 6f67c50f | Juan Quintela | #define VMSTATE_BUFFER_V(_f, _s, _v) \
|
675 | b2e15099 | Juan Quintela | VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f))) |
676 | 6f67c50f | Juan Quintela | |
677 | 6f67c50f | Juan Quintela | #define VMSTATE_BUFFER(_f, _s) \
|
678 | b2e15099 | Juan Quintela | VMSTATE_BUFFER_V(_f, _s, 0)
|
679 | b2e15099 | Juan Quintela | |
680 | b2e15099 | Juan Quintela | #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \
|
681 | b2e15099 | Juan Quintela | VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size) |
682 | b2e15099 | Juan Quintela | |
683 | b2e15099 | Juan Quintela | #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
|
684 | b2e15099 | Juan Quintela | VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) |
685 | 6f67c50f | Juan Quintela | |
686 | b2e15099 | Juan Quintela | #define VMSTATE_BUFFER_TEST(_f, _s, _test) \
|
687 | b2e15099 | Juan Quintela | VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) |
688 | 25dc563b | Juan Quintela | |
689 | 9cae69bd | Isaku Yamahata | #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \
|
690 | 9cae69bd | Isaku Yamahata | VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size) |
691 | 9cae69bd | Isaku Yamahata | |
692 | 76507c75 | Juan Quintela | #define VMSTATE_UNUSED_V(_v, _size) \
|
693 | 76507c75 | Juan Quintela | VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
|
694 | 76507c75 | Juan Quintela | |
695 | 76507c75 | Juan Quintela | #define VMSTATE_UNUSED(_size) \
|
696 | 76507c75 | Juan Quintela | VMSTATE_UNUSED_V(0, _size)
|
697 | 76507c75 | Juan Quintela | |
698 | 76507c75 | Juan Quintela | #define VMSTATE_UNUSED_TEST(_test, _size) \
|
699 | 76507c75 | Juan Quintela | VMSTATE_UNUSED_BUFFER(_test, 0, _size)
|
700 | 76507c75 | Juan Quintela | |
701 | f89a8e4e | Juan Quintela | #ifdef NEED_CPU_H
|
702 | f89a8e4e | Juan Quintela | #if TARGET_LONG_BITS == 64 |
703 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL_V(_f, _s, _v) \
|
704 | f89a8e4e | Juan Quintela | VMSTATE_UINT64_V(_f, _s, _v) |
705 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
|
706 | f89a8e4e | Juan Quintela | VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) |
707 | f89a8e4e | Juan Quintela | #else
|
708 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL_V(_f, _s, _v) \
|
709 | f89a8e4e | Juan Quintela | VMSTATE_UINT32_V(_f, _s, _v) |
710 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
|
711 | f89a8e4e | Juan Quintela | VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) |
712 | f89a8e4e | Juan Quintela | #endif
|
713 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL(_f, _s) \
|
714 | f89a8e4e | Juan Quintela | VMSTATE_UINTTL_V(_f, _s, 0)
|
715 | f89a8e4e | Juan Quintela | #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
|
716 | f89a8e4e | Juan Quintela | VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
|
717 | f89a8e4e | Juan Quintela | |
718 | f89a8e4e | Juan Quintela | #endif
|
719 | f89a8e4e | Juan Quintela | |
720 | 9ed7d6ae | Juan Quintela | #define VMSTATE_END_OF_LIST() \
|
721 | 9ed7d6ae | Juan Quintela | {} |
722 | 9ed7d6ae | Juan Quintela | |
723 | 9ed7d6ae | Juan Quintela | extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, |
724 | 9ed7d6ae | Juan Quintela | void *opaque, int version_id); |
725 | 9ed7d6ae | Juan Quintela | extern void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, |
726 | 84e2e3eb | Juan Quintela | void *opaque);
|
727 | 9ed7d6ae | Juan Quintela | extern int vmstate_register(int instance_id, const VMStateDescription *vmsd, |
728 | 9ed7d6ae | Juan Quintela | void *base);
|
729 | 1eb7538b | Juan Quintela | void vmstate_unregister(const VMStateDescription *vmsd, void *opaque); |
730 | 87ecb68b | pbrook | #endif |