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