1
2
3
4
5
6
7
8
9
10
11#ifndef LIBQTEST_SINGLE_H
12#define LIBQTEST_SINGLE_H
13
14#include "libqtest.h"
15
16#ifndef _WIN32
17QTestState *global_qtest __attribute__((common, weak));
18#else
19__declspec(selectany) QTestState *global_qtest;
20#endif
21
22
23
24
25
26
27
28
29
30
31static inline QTestState *qtest_start(const char *args)
32{
33 global_qtest = qtest_init(args);
34 return global_qtest;
35}
36
37
38
39
40
41
42static inline void qtest_end(void)
43{
44 if (!global_qtest) {
45 return;
46 }
47 qtest_quit(global_qtest);
48 global_qtest = NULL;
49}
50
51
52
53
54
55
56
57
58
59G_GNUC_PRINTF(1, 2)
60static inline QDict *qmp(const char *fmt, ...)
61{
62 va_list ap;
63 QDict *response;
64
65 va_start(ap, fmt);
66 response = qtest_vqmp(global_qtest, fmt, ap);
67 va_end(ap);
68 return response;
69}
70
71
72
73
74
75
76
77static inline void qmp_eventwait(const char *event)
78{
79 return qtest_qmp_eventwait(global_qtest, event);
80}
81
82
83
84
85
86
87
88static inline bool get_irq(int num)
89{
90 return qtest_get_irq(global_qtest, num);
91}
92
93
94
95
96
97
98
99
100static inline void outb(uint16_t addr, uint8_t value)
101{
102 qtest_outb(global_qtest, addr, value);
103}
104
105
106
107
108
109
110
111
112static inline void outw(uint16_t addr, uint16_t value)
113{
114 qtest_outw(global_qtest, addr, value);
115}
116
117
118
119
120
121
122
123
124static inline void outl(uint16_t addr, uint32_t value)
125{
126 qtest_outl(global_qtest, addr, value);
127}
128
129
130
131
132
133
134
135
136
137static inline uint8_t inb(uint16_t addr)
138{
139 return qtest_inb(global_qtest, addr);
140}
141
142
143
144
145
146
147
148
149
150static inline uint16_t inw(uint16_t addr)
151{
152 return qtest_inw(global_qtest, addr);
153}
154
155
156
157
158
159
160
161
162
163static inline uint32_t inl(uint16_t addr)
164{
165 return qtest_inl(global_qtest, addr);
166}
167
168
169
170
171
172
173
174
175static inline void writeb(uint64_t addr, uint8_t value)
176{
177 qtest_writeb(global_qtest, addr, value);
178}
179
180
181
182
183
184
185
186
187static inline void writew(uint64_t addr, uint16_t value)
188{
189 qtest_writew(global_qtest, addr, value);
190}
191
192
193
194
195
196
197
198
199static inline void writel(uint64_t addr, uint32_t value)
200{
201 qtest_writel(global_qtest, addr, value);
202}
203
204
205
206
207
208
209
210
211static inline void writeq(uint64_t addr, uint64_t value)
212{
213 qtest_writeq(global_qtest, addr, value);
214}
215
216
217
218
219
220
221
222
223
224static inline uint8_t readb(uint64_t addr)
225{
226 return qtest_readb(global_qtest, addr);
227}
228
229
230
231
232
233
234
235
236
237static inline uint16_t readw(uint64_t addr)
238{
239 return qtest_readw(global_qtest, addr);
240}
241
242
243
244
245
246
247
248
249
250static inline uint32_t readl(uint64_t addr)
251{
252 return qtest_readl(global_qtest, addr);
253}
254
255
256
257
258
259
260
261
262
263static inline uint64_t readq(uint64_t addr)
264{
265 return qtest_readq(global_qtest, addr);
266}
267
268
269
270
271
272
273
274
275
276static inline void memread(uint64_t addr, void *data, size_t size)
277{
278 qtest_memread(global_qtest, addr, data, size);
279}
280
281
282
283
284
285
286
287
288
289static inline void memwrite(uint64_t addr, const void *data, size_t size)
290{
291 qtest_memwrite(global_qtest, addr, data, size);
292}
293
294
295
296
297
298
299
300
301static inline int64_t clock_step_next(void)
302{
303 return qtest_clock_step_next(global_qtest);
304}
305
306
307
308
309
310
311
312
313
314static inline int64_t clock_step(int64_t step)
315{
316 return qtest_clock_step(global_qtest, step);
317}
318
319#endif
320