1 | /*
|
---|
2 | * QEMU System Emulator header
|
---|
3 | *
|
---|
4 | * Copyright (c) 2003 Fabrice Bellard
|
---|
5 | *
|
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
7 | * of this software and associated documentation files (the "Software"), to deal
|
---|
8 | * in the Software without restriction, including without limitation the rights
|
---|
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
10 | * copies of the Software, and to permit persons to whom the Software is
|
---|
11 | * furnished to do so, subject to the following conditions:
|
---|
12 | *
|
---|
13 | * The above copyright notice and this permission notice shall be included in
|
---|
14 | * all copies or substantial portions of the Software.
|
---|
15 | *
|
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
---|
22 | * THE SOFTWARE.
|
---|
23 | */
|
---|
24 | #ifndef VL_H
|
---|
25 | #define VL_H
|
---|
26 |
|
---|
27 | /* we put basic includes here to avoid repeating them in device drivers */
|
---|
28 | #include <stdlib.h>
|
---|
29 | #include <stdio.h>
|
---|
30 | #include <stdarg.h>
|
---|
31 | #include <string.h>
|
---|
32 | #include <inttypes.h>
|
---|
33 | #include <limits.h>
|
---|
34 | #include <time.h>
|
---|
35 | #include <ctype.h>
|
---|
36 | #include <errno.h>
|
---|
37 | #include <unistd.h>
|
---|
38 | #include <fcntl.h>
|
---|
39 | #include <sys/stat.h>
|
---|
40 | #ifndef VBOX
|
---|
41 | #include "audio/audio.h"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifndef O_LARGEFILE
|
---|
45 | #define O_LARGEFILE 0
|
---|
46 | #endif
|
---|
47 | #ifndef O_BINARY
|
---|
48 | #define O_BINARY 0
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #ifdef _WIN32
|
---|
52 | #define lseek _lseeki64
|
---|
53 | #define ENOTSUP 4096
|
---|
54 | /* XXX: find 64 bit version */
|
---|
55 | #define ftruncate chsize
|
---|
56 |
|
---|
57 | static inline char *realpath(const char *path, char *resolved_path)
|
---|
58 | {
|
---|
59 | _fullpath(resolved_path, path, _MAX_PATH);
|
---|
60 | return resolved_path;
|
---|
61 | }
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #ifdef QEMU_TOOL
|
---|
65 |
|
---|
66 | /* we use QEMU_TOOL in the command line tools which do not depend on
|
---|
67 | the target CPU type */
|
---|
68 | #include "config-host.h"
|
---|
69 | #include <setjmp.h>
|
---|
70 | #include "osdep.h"
|
---|
71 | #include "bswap.h"
|
---|
72 |
|
---|
73 | #else
|
---|
74 |
|
---|
75 | #include "cpu.h"
|
---|
76 |
|
---|
77 | #endif /* !defined(QEMU_TOOL) */
|
---|
78 |
|
---|
79 | #ifdef VBOX
|
---|
80 | # include <VBox/types.h>
|
---|
81 | # include "REMInternal.h"
|
---|
82 | # undef MIN
|
---|
83 | # undef MAX
|
---|
84 | #endif /* VBOX */
|
---|
85 |
|
---|
86 | #ifndef glue
|
---|
87 | #define xglue(x, y) x ## y
|
---|
88 | #define glue(x, y) xglue(x, y)
|
---|
89 | #define stringify(s) tostring(s)
|
---|
90 | #define tostring(s) #s
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | /* vl.c */
|
---|
94 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
|
---|
95 |
|
---|
96 | void hw_error(const char *fmt, ...);
|
---|
97 |
|
---|
98 | int get_image_size(const char *filename);
|
---|
99 | int load_image(const char *filename, uint8_t *addr);
|
---|
100 | extern const char *bios_dir;
|
---|
101 |
|
---|
102 | void pstrcpy(char *buf, int buf_size, const char *str);
|
---|
103 | char *pstrcat(char *buf, int buf_size, const char *s);
|
---|
104 | int strstart(const char *str, const char *val, const char **ptr);
|
---|
105 |
|
---|
106 | extern int vm_running;
|
---|
107 |
|
---|
108 | typedef void VMStopHandler(void *opaque, int reason);
|
---|
109 |
|
---|
110 | int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
|
---|
111 | void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
|
---|
112 |
|
---|
113 | void vm_start(void);
|
---|
114 | void vm_stop(int reason);
|
---|
115 |
|
---|
116 | typedef void QEMUResetHandler(void *opaque);
|
---|
117 |
|
---|
118 | void qemu_register_reset(QEMUResetHandler *func, void *opaque);
|
---|
119 | void qemu_system_reset_request(void);
|
---|
120 | void qemu_system_shutdown_request(void);
|
---|
121 |
|
---|
122 | void main_loop_wait(int timeout);
|
---|
123 |
|
---|
124 | extern int audio_enabled;
|
---|
125 | extern int sb16_enabled;
|
---|
126 | extern int adlib_enabled;
|
---|
127 | extern int gus_enabled;
|
---|
128 | extern int ram_size;
|
---|
129 | extern int bios_size;
|
---|
130 | extern int rtc_utc;
|
---|
131 | #ifndef VBOX
|
---|
132 | extern int cirrus_vga_enabled;
|
---|
133 | #endif
|
---|
134 | extern int graphic_width;
|
---|
135 | extern int graphic_height;
|
---|
136 | extern int graphic_depth;
|
---|
137 | extern const char *keyboard_layout;
|
---|
138 |
|
---|
139 | /* XXX: make it dynamic */
|
---|
140 | #if defined (TARGET_PPC)
|
---|
141 | #define BIOS_SIZE (512 * 1024)
|
---|
142 | #else
|
---|
143 | #define BIOS_SIZE ((256 + 64) * 1024)
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | /* keyboard/mouse support */
|
---|
147 |
|
---|
148 | #define MOUSE_EVENT_LBUTTON 0x01
|
---|
149 | #define MOUSE_EVENT_RBUTTON 0x02
|
---|
150 | #define MOUSE_EVENT_MBUTTON 0x04
|
---|
151 |
|
---|
152 | typedef void QEMUPutKBDEvent(void *opaque, int keycode);
|
---|
153 | typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
|
---|
154 |
|
---|
155 | void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
|
---|
156 | void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
|
---|
157 |
|
---|
158 | void kbd_put_keycode(int keycode);
|
---|
159 | void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
|
---|
160 |
|
---|
161 | /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
|
---|
162 | constants) */
|
---|
163 | #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
|
---|
164 | #define QEMU_KEY_BACKSPACE 0x007f
|
---|
165 | #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
|
---|
166 | #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
|
---|
167 | #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
|
---|
168 | #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
|
---|
169 | #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
|
---|
170 | #define QEMU_KEY_END QEMU_KEY_ESC1(4)
|
---|
171 | #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
|
---|
172 | #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
|
---|
173 | #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
|
---|
174 |
|
---|
175 | #define QEMU_KEY_CTRL_UP 0xe400
|
---|
176 | #define QEMU_KEY_CTRL_DOWN 0xe401
|
---|
177 | #define QEMU_KEY_CTRL_LEFT 0xe402
|
---|
178 | #define QEMU_KEY_CTRL_RIGHT 0xe403
|
---|
179 | #define QEMU_KEY_CTRL_HOME 0xe404
|
---|
180 | #define QEMU_KEY_CTRL_END 0xe405
|
---|
181 | #define QEMU_KEY_CTRL_PAGEUP 0xe406
|
---|
182 | #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
|
---|
183 |
|
---|
184 | void kbd_put_keysym(int keysym);
|
---|
185 |
|
---|
186 | /* async I/O support */
|
---|
187 |
|
---|
188 | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
|
---|
189 | typedef int IOCanRWHandler(void *opaque);
|
---|
190 |
|
---|
191 | int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read,
|
---|
192 | IOReadHandler *fd_read, void *opaque);
|
---|
193 | void qemu_del_fd_read_handler(int fd);
|
---|
194 |
|
---|
195 | /* character device */
|
---|
196 |
|
---|
197 | #define CHR_EVENT_BREAK 0 /* serial break char */
|
---|
198 | #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
|
---|
199 |
|
---|
200 | typedef void IOEventHandler(void *opaque, int event);
|
---|
201 |
|
---|
202 | typedef struct CharDriverState {
|
---|
203 | int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
|
---|
204 | void (*chr_add_read_handler)(struct CharDriverState *s,
|
---|
205 | IOCanRWHandler *fd_can_read,
|
---|
206 | IOReadHandler *fd_read, void *opaque);
|
---|
207 | IOEventHandler *chr_event;
|
---|
208 | void (*chr_send_event)(struct CharDriverState *chr, int event);
|
---|
209 | void *opaque;
|
---|
210 | } CharDriverState;
|
---|
211 |
|
---|
212 | void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
|
---|
213 | int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
|
---|
214 | void qemu_chr_send_event(CharDriverState *s, int event);
|
---|
215 | void qemu_chr_add_read_handler(CharDriverState *s,
|
---|
216 | IOCanRWHandler *fd_can_read,
|
---|
217 | IOReadHandler *fd_read, void *opaque);
|
---|
218 | void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
|
---|
219 |
|
---|
220 | /* consoles */
|
---|
221 |
|
---|
222 | typedef struct DisplayState DisplayState;
|
---|
223 | typedef struct TextConsole TextConsole;
|
---|
224 |
|
---|
225 | extern TextConsole *vga_console;
|
---|
226 |
|
---|
227 | TextConsole *graphic_console_init(DisplayState *ds);
|
---|
228 | int is_active_console(TextConsole *s);
|
---|
229 | CharDriverState *text_console_init(DisplayState *ds);
|
---|
230 | void console_select(unsigned int index);
|
---|
231 |
|
---|
232 | #ifdef VBOX
|
---|
233 | void console_init(void);
|
---|
234 | #endif
|
---|
235 |
|
---|
236 | /* serial ports */
|
---|
237 |
|
---|
238 | #define MAX_SERIAL_PORTS 4
|
---|
239 |
|
---|
240 | extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
|
---|
241 |
|
---|
242 | /* parallel ports */
|
---|
243 |
|
---|
244 | #define MAX_PARALLEL_PORTS 3
|
---|
245 |
|
---|
246 | extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
|
---|
247 |
|
---|
248 | /* network redirectors support */
|
---|
249 |
|
---|
250 | #define MAX_NICS 8
|
---|
251 |
|
---|
252 | typedef struct NetDriverState {
|
---|
253 | int index; /* index number in QEMU */
|
---|
254 | uint8_t macaddr[6];
|
---|
255 | char ifname[16];
|
---|
256 | void (*send_packet)(struct NetDriverState *nd,
|
---|
257 | const uint8_t *buf, int size);
|
---|
258 | void (*add_read_packet)(struct NetDriverState *nd,
|
---|
259 | IOCanRWHandler *fd_can_read,
|
---|
260 | IOReadHandler *fd_read, void *opaque);
|
---|
261 | /* tun specific data */
|
---|
262 | int fd;
|
---|
263 | /* slirp specific data */
|
---|
264 | } NetDriverState;
|
---|
265 |
|
---|
266 | extern int nb_nics;
|
---|
267 | extern NetDriverState nd_table[MAX_NICS];
|
---|
268 |
|
---|
269 | void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
|
---|
270 | void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read,
|
---|
271 | IOReadHandler *fd_read, void *opaque);
|
---|
272 |
|
---|
273 | /* timers */
|
---|
274 |
|
---|
275 | #if defined(VBOX)
|
---|
276 |
|
---|
277 | #include <VBox/tm.h>
|
---|
278 |
|
---|
279 | /* VBox wrappers */
|
---|
280 | #define QEMUTimerCB FNTMTIMERQEMU
|
---|
281 | typedef struct TMTIMER QEMUTimer;
|
---|
282 | #define rt_clock THIS_SHALL_NOT_BE_USED//TMCLOCK_REAL
|
---|
283 | #define vm_clock THIS_SHALL_NOT_BE_USED//TMCLOCK_VIRTUAL
|
---|
284 | #define ticks_per_sec THIS_SHALL_NOT_BE_USED//TMCpuTicksPerSecond((PVM)cpu_single_env->pVM)
|
---|
285 | #define qemu_get_clock(enmClock) THIS_SHALL_NOT_BE_USED//TMR3Clock((PVM)cpu_single_env->pVM, enmClock)
|
---|
286 | #define qemu_new_timer(clock, callback, user) THIS_SHALL_NOT_BE_USED//(QEMUTimer *)TMR3TimerCreateExternal((PVM)cpu_single_env->pVM, clock, callback, user, __FUNCTION__ )
|
---|
287 | #define qemu_free_timer(timer) THIS_SHALL_NOT_BE_USED//TMTimerDestroy(timer)
|
---|
288 | #define qemu_del_timer(timer) THIS_SHALL_NOT_BE_USED//TMTimerStop(timer)
|
---|
289 | #define qemu_mod_timer(timer, expire) THIS_SHALL_NOT_BE_USED//TMTimerSet(timer, (uint64_t)expire)
|
---|
290 | #define qemu_timer_pending(timer) THIS_SHALL_NOT_BE_USED//TMTimerIsActive(timer)
|
---|
291 | #define cpu_disable_ticks() THIS_SHALL_NOT_BE_USED//TMCpuTickPause((PVM)cpu_single_env->pVM)
|
---|
292 | #define cpu_enable_ticks() THIS_SHALL_NOT_BE_USED//TMCpuTickResume((PVM)cpu_single_env->pVM)
|
---|
293 | #define cpu_calibrate_ticks() THIS_SHALL_NOT_BE_USED//do {} while (0)
|
---|
294 | #define init_timers() THIS_SHALL_NOT_BE_USED//do {} while (0)
|
---|
295 | #define quit_timers() THIS_SHALL_NOT_BE_USED//do {} while (0)
|
---|
296 |
|
---|
297 | #else /* !VBOX */
|
---|
298 |
|
---|
299 | typedef struct QEMUClock QEMUClock;
|
---|
300 | typedef struct QEMUTimer QEMUTimer;
|
---|
301 | typedef void QEMUTimerCB(void *opaque);
|
---|
302 |
|
---|
303 | /* The real time clock should be used only for stuff which does not
|
---|
304 | change the virtual machine state, as it is run even if the virtual
|
---|
305 | machine is stopped. The real time clock has a frequency of 1000
|
---|
306 | Hz. */
|
---|
307 | extern QEMUClock *rt_clock;
|
---|
308 |
|
---|
309 | /* The virtual clock is only run during the emulation. It is stopped
|
---|
310 | when the virtual machine is stopped. Virtual timers use a high
|
---|
311 | precision clock, usually cpu cycles (use ticks_per_sec). */
|
---|
312 | extern QEMUClock *vm_clock;
|
---|
313 |
|
---|
314 | int64_t qemu_get_clock(QEMUClock *clock);
|
---|
315 |
|
---|
316 | QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
|
---|
317 | void qemu_free_timer(QEMUTimer *ts);
|
---|
318 | void qemu_del_timer(QEMUTimer *ts);
|
---|
319 | void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
|
---|
320 | int qemu_timer_pending(QEMUTimer *ts);
|
---|
321 |
|
---|
322 | extern int64_t ticks_per_sec;
|
---|
323 | extern int pit_min_timer_count;
|
---|
324 |
|
---|
325 | void cpu_enable_ticks(void);
|
---|
326 | void cpu_disable_ticks(void);
|
---|
327 | #endif /* !VBOX */
|
---|
328 |
|
---|
329 | /* VM Load/Save */
|
---|
330 |
|
---|
331 | #if defined(VBOX)
|
---|
332 |
|
---|
333 | #include <VBox/ssm.h>
|
---|
334 | #include <VBox/err.h>
|
---|
335 |
|
---|
336 | typedef struct SSMHANDLE QEMUFile;
|
---|
337 |
|
---|
338 | #define qemu_put_buffer(f, pv, cb) THIS_SHALL_NOT_BE_USED//SSMR3PutMem((f), (pv), (cb))
|
---|
339 | #define qemu_put_byte(f, u8) THIS_SHALL_NOT_BE_USED//SSMR3PutU8((f), (uint8_t)(u8))
|
---|
340 | #define qemu_put_8s(f, pu8) THIS_SHALL_NOT_BE_USED//SSMR3PutU8((f), *(pu8))
|
---|
341 | #define qemu_put_be16s(f, pu16) THIS_SHALL_NOT_BE_USED//SSMR3PutU32((f), *(pu16))
|
---|
342 | #define qemu_put_be32s(f, pu32) THIS_SHALL_NOT_BE_USED//SSMR3PutU32((f), *(pu32))
|
---|
343 | #define qemu_put_be64s(f, pu64) THIS_SHALL_NOT_BE_USED//SSMR3PutU64((f), *(pu64))
|
---|
344 | #define qemu_put_be16(f, u16) THIS_SHALL_NOT_BE_USED//SSMR3PutU16((f), (uint16_t)(u16))
|
---|
345 | #define qemu_put_be32(f, u32) THIS_SHALL_NOT_BE_USED//SSMR3PutU32((f), (uint32_t)(u32))
|
---|
346 | #define qemu_put_be64(f, u64) THIS_SHALL_NOT_BE_USED//SSMR3PutU64((f), (uint64_t)(u64))
|
---|
347 |
|
---|
348 | #define qemu_get_8s(f, pu8) THIS_SHALL_NOT_BE_USED//SSMR3GetU8((f), (pu8))
|
---|
349 | #define qemu_get_be16s(f, pu16) THIS_SHALL_NOT_BE_USED//SSMR3GetU16((f), (pu16))
|
---|
350 | #define qemu_get_be32s(f, pu32) THIS_SHALL_NOT_BE_USED//SSMR3GetU32((f), (pu32))
|
---|
351 | #define qemu_get_be64s(f, pu64) THIS_SHALL_NOT_BE_USED//SSMR3GetU64((f), (pu64))
|
---|
352 |
|
---|
353 | #if 0
|
---|
354 | static inline int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size)
|
---|
355 | {
|
---|
356 | int rc = SSMR3GetMem(f, buf, size);
|
---|
357 | return VBOX_SUCCESS(rc) ? size : 0;
|
---|
358 | }
|
---|
359 |
|
---|
360 | static inline int qemu_get_byte(QEMUFile *f)
|
---|
361 | {
|
---|
362 | uint8_t u8;
|
---|
363 | int rc = SSMR3GetU8(f, &u8);
|
---|
364 | return VBOX_SUCCESS(rc) ? (int)u8 : -1;
|
---|
365 | }
|
---|
366 |
|
---|
367 | static inline unsigned int qemu_get_be16(QEMUFile *f)
|
---|
368 | {
|
---|
369 | uint16_t u16;
|
---|
370 | int rc = SSMR3GetU16(f, &u16);
|
---|
371 | return VBOX_SUCCESS(rc) ? u16 : ~0;
|
---|
372 | }
|
---|
373 |
|
---|
374 | static inline unsigned int qemu_get_be32(QEMUFile *f)
|
---|
375 | {
|
---|
376 | uint32_t u32;
|
---|
377 | int rc = SSMR3GetU32(f, &u32);
|
---|
378 | return VBOX_SUCCESS(rc) ? u32 : ~0;
|
---|
379 | }
|
---|
380 |
|
---|
381 | static inline uint64_t qemu_get_be64(QEMUFile *f)
|
---|
382 | {
|
---|
383 | uint64_t u64;
|
---|
384 | int rc = SSMR3GetU64(f, &u64);
|
---|
385 | return VBOX_SUCCESS(rc) ? u64 : ~0;
|
---|
386 | }
|
---|
387 |
|
---|
388 | #define qemu_put_timer(f, ts) TMR3TimerSave((ts), (f))
|
---|
389 | #define qemu_get_timer(f, ts) TMR3TimerLoad((ts), (f))
|
---|
390 |
|
---|
391 | typedef void SaveStateHandler(QEMUFile *f, void *opaque);
|
---|
392 | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
|
---|
393 |
|
---|
394 | int register_savevm(const char *idstr,
|
---|
395 | int instance_id,
|
---|
396 | int version_id,
|
---|
397 | SaveStateHandler *save_state,
|
---|
398 | LoadStateHandler *load_state,
|
---|
399 | void *opaque);
|
---|
400 | #endif /* not used */
|
---|
401 |
|
---|
402 | #else /* !VBOX */
|
---|
403 |
|
---|
404 | typedef FILE QEMUFile;
|
---|
405 |
|
---|
406 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
|
---|
407 | void qemu_put_byte(QEMUFile *f, int v);
|
---|
408 | void qemu_put_be16(QEMUFile *f, unsigned int v);
|
---|
409 | void qemu_put_be32(QEMUFile *f, unsigned int v);
|
---|
410 | void qemu_put_be64(QEMUFile *f, uint64_t v);
|
---|
411 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
|
---|
412 | int qemu_get_byte(QEMUFile *f);
|
---|
413 | unsigned int qemu_get_be16(QEMUFile *f);
|
---|
414 | unsigned int qemu_get_be32(QEMUFile *f);
|
---|
415 | uint64_t qemu_get_be64(QEMUFile *f);
|
---|
416 |
|
---|
417 | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
|
---|
418 | {
|
---|
419 | qemu_put_be64(f, *pv);
|
---|
420 | }
|
---|
421 |
|
---|
422 | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
|
---|
423 | {
|
---|
424 | qemu_put_be32(f, *pv);
|
---|
425 | }
|
---|
426 |
|
---|
427 | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
|
---|
428 | {
|
---|
429 | qemu_put_be16(f, *pv);
|
---|
430 | }
|
---|
431 |
|
---|
432 | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
|
---|
433 | {
|
---|
434 | qemu_put_byte(f, *pv);
|
---|
435 | }
|
---|
436 |
|
---|
437 | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
|
---|
438 | {
|
---|
439 | *pv = qemu_get_be64(f);
|
---|
440 | }
|
---|
441 |
|
---|
442 | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
|
---|
443 | {
|
---|
444 | *pv = qemu_get_be32(f);
|
---|
445 | }
|
---|
446 |
|
---|
447 | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
|
---|
448 | {
|
---|
449 | *pv = qemu_get_be16(f);
|
---|
450 | }
|
---|
451 |
|
---|
452 | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
|
---|
453 | {
|
---|
454 | *pv = qemu_get_byte(f);
|
---|
455 | }
|
---|
456 |
|
---|
457 | #if TARGET_LONG_BITS == 64
|
---|
458 | #define qemu_put_betl qemu_put_be64
|
---|
459 | #define qemu_get_betl qemu_get_be64
|
---|
460 | #define qemu_put_betls qemu_put_be64s
|
---|
461 | #define qemu_get_betls qemu_get_be64s
|
---|
462 | #else
|
---|
463 | #define qemu_put_betl qemu_put_be32
|
---|
464 | #define qemu_get_betl qemu_get_be32
|
---|
465 | #define qemu_put_betls qemu_put_be32s
|
---|
466 | #define qemu_get_betls qemu_get_be32s
|
---|
467 | #endif
|
---|
468 |
|
---|
469 | int64_t qemu_ftell(QEMUFile *f);
|
---|
470 | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
---|
471 |
|
---|
472 | typedef void SaveStateHandler(QEMUFile *f, void *opaque);
|
---|
473 | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
|
---|
474 |
|
---|
475 | int qemu_loadvm(const char *filename);
|
---|
476 | int qemu_savevm(const char *filename);
|
---|
477 | int register_savevm(const char *idstr,
|
---|
478 | int instance_id,
|
---|
479 | int version_id,
|
---|
480 | SaveStateHandler *save_state,
|
---|
481 | LoadStateHandler *load_state,
|
---|
482 | void *opaque);
|
---|
483 | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
|
---|
484 | void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
|
---|
485 | #endif /* !VBOX */
|
---|
486 |
|
---|
487 | /* block.c */
|
---|
488 | typedef struct BlockDriverState BlockDriverState;
|
---|
489 | typedef struct BlockDriver BlockDriver;
|
---|
490 |
|
---|
491 | #ifdef VBOX
|
---|
492 | extern BlockDriver bdrv_vbox;
|
---|
493 | /* @@@AH remove later */
|
---|
494 | extern BlockDriver bdrv_qcow;
|
---|
495 | extern BlockDriver bdrv_raw;
|
---|
496 | #else /* !VBOX */
|
---|
497 | extern BlockDriver bdrv_raw;
|
---|
498 | extern BlockDriver bdrv_cow;
|
---|
499 | extern BlockDriver bdrv_qcow;
|
---|
500 | extern BlockDriver bdrv_vmdk;
|
---|
501 | extern BlockDriver bdrv_cloop;
|
---|
502 | extern BlockDriver bdrv_dmg;
|
---|
503 | #endif /* !VBOX */
|
---|
504 |
|
---|
505 | void bdrv_init(void);
|
---|
506 | BlockDriver *bdrv_find_format(const char *format_name);
|
---|
507 | int bdrv_create(BlockDriver *drv,
|
---|
508 | const char *filename, int64_t size_in_sectors,
|
---|
509 | const char *backing_file, int flags);
|
---|
510 | BlockDriverState *bdrv_new(const char *device_name);
|
---|
511 | void bdrv_delete(BlockDriverState *bs);
|
---|
512 | int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
|
---|
513 | int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
|
---|
514 | BlockDriver *drv);
|
---|
515 | void bdrv_close(BlockDriverState *bs);
|
---|
516 | int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
---|
517 | uint8_t *buf, int nb_sectors);
|
---|
518 | int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
---|
519 | const uint8_t *buf, int nb_sectors);
|
---|
520 | void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
|
---|
521 | int bdrv_commit(BlockDriverState *bs);
|
---|
522 | void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
|
---|
523 |
|
---|
524 | #define BDRV_TYPE_HD 0
|
---|
525 | #define BDRV_TYPE_CDROM 1
|
---|
526 | #define BDRV_TYPE_FLOPPY 2
|
---|
527 | #define BIOS_ATA_TRANSLATION_AUTO 0
|
---|
528 | #define BIOS_ATA_TRANSLATION_NONE 1
|
---|
529 | #define BIOS_ATA_TRANSLATION_LBA 2
|
---|
530 |
|
---|
531 | void bdrv_set_geometry_hint(BlockDriverState *bs,
|
---|
532 | int cyls, int heads, int secs);
|
---|
533 | void bdrv_set_type_hint(BlockDriverState *bs, int type);
|
---|
534 | void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
|
---|
535 | void bdrv_get_geometry_hint(BlockDriverState *bs,
|
---|
536 | int *pcyls, int *pheads, int *psecs);
|
---|
537 | int bdrv_get_type_hint(BlockDriverState *bs);
|
---|
538 | int bdrv_get_translation_hint(BlockDriverState *bs);
|
---|
539 | int bdrv_is_removable(BlockDriverState *bs);
|
---|
540 | int bdrv_is_read_only(BlockDriverState *bs);
|
---|
541 | int bdrv_is_inserted(BlockDriverState *bs);
|
---|
542 | int bdrv_is_locked(BlockDriverState *bs);
|
---|
543 | void bdrv_set_locked(BlockDriverState *bs, int locked);
|
---|
544 | void bdrv_set_change_cb(BlockDriverState *bs,
|
---|
545 | void (*change_cb)(void *opaque), void *opaque);
|
---|
546 | void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
|
---|
547 | void bdrv_info(void);
|
---|
548 | BlockDriverState *bdrv_find(const char *name);
|
---|
549 | void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
|
---|
550 | int bdrv_is_encrypted(BlockDriverState *bs);
|
---|
551 | int bdrv_set_key(BlockDriverState *bs, const char *key);
|
---|
552 | void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
|
---|
553 | void *opaque);
|
---|
554 | const char *bdrv_get_device_name(BlockDriverState *bs);
|
---|
555 |
|
---|
556 | int qcow_get_cluster_size(BlockDriverState *bs);
|
---|
557 | int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
|
---|
558 | const uint8_t *buf);
|
---|
559 |
|
---|
560 | #ifndef QEMU_TOOL
|
---|
561 | /* ISA bus */
|
---|
562 |
|
---|
563 | #if defined(VBOX)
|
---|
564 | #define isa_mem_base THIS_SHALL_NOT_BE_USED//0
|
---|
565 | #else /* !VBOX */
|
---|
566 |
|
---|
567 | extern target_phys_addr_t isa_mem_base;
|
---|
568 |
|
---|
569 | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
|
---|
570 | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
|
---|
571 |
|
---|
572 | int register_ioport_read(int start, int length, int size,
|
---|
573 | IOPortReadFunc *func, void *opaque);
|
---|
574 | int register_ioport_write(int start, int length, int size,
|
---|
575 | IOPortWriteFunc *func, void *opaque);
|
---|
576 | void isa_unassign_ioport(int start, int length);
|
---|
577 | #endif /* !VBOX */
|
---|
578 |
|
---|
579 | /* PCI bus */
|
---|
580 |
|
---|
581 | #if defined(VBOX)
|
---|
582 | typedef struct PCIBus PCIBus;
|
---|
583 | typedef struct PCIDevice PCIDevice;
|
---|
584 | typedef struct openpic_t openpic_t;
|
---|
585 | #else /* !VBOX */
|
---|
586 | extern int pci_enabled;
|
---|
587 |
|
---|
588 | extern target_phys_addr_t pci_mem_base;
|
---|
589 |
|
---|
590 | typedef struct PCIBus PCIBus;
|
---|
591 | typedef struct PCIDevice PCIDevice;
|
---|
592 |
|
---|
593 | typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
|
---|
594 | uint32_t address, uint32_t data, int len);
|
---|
595 | typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
|
---|
596 | uint32_t address, int len);
|
---|
597 | typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
|
---|
598 | uint32_t addr, uint32_t size, int type);
|
---|
599 |
|
---|
600 | #define PCI_ADDRESS_SPACE_MEM 0x00
|
---|
601 | #define PCI_ADDRESS_SPACE_IO 0x01
|
---|
602 | #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
|
---|
603 |
|
---|
604 | typedef struct PCIIORegion {
|
---|
605 | uint32_t addr; /* current PCI mapping address. -1 means not mapped */
|
---|
606 | uint32_t size;
|
---|
607 | uint8_t type;
|
---|
608 | PCIMapIORegionFunc *map_func;
|
---|
609 | } PCIIORegion;
|
---|
610 |
|
---|
611 | #define PCI_ROM_SLOT 6
|
---|
612 | #define PCI_NUM_REGIONS 7
|
---|
613 | struct PCIDevice {
|
---|
614 | /* PCI config space */
|
---|
615 | uint8_t config[256];
|
---|
616 |
|
---|
617 | /* the following fields are read only */
|
---|
618 | PCIBus *bus;
|
---|
619 | int devfn;
|
---|
620 | char name[64];
|
---|
621 | PCIIORegion io_regions[PCI_NUM_REGIONS];
|
---|
622 |
|
---|
623 | /* do not access the following fields */
|
---|
624 | PCIConfigReadFunc *config_read;
|
---|
625 | PCIConfigWriteFunc *config_write;
|
---|
626 | int irq_index;
|
---|
627 | };
|
---|
628 |
|
---|
629 | PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
---|
630 | int instance_size, int devfn,
|
---|
631 | PCIConfigReadFunc *config_read,
|
---|
632 | PCIConfigWriteFunc *config_write);
|
---|
633 |
|
---|
634 | void pci_register_io_region(PCIDevice *pci_dev, int region_num,
|
---|
635 | uint32_t size, int type,
|
---|
636 | PCIMapIORegionFunc *map_func);
|
---|
637 |
|
---|
638 | void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
|
---|
639 |
|
---|
640 | uint32_t pci_default_read_config(PCIDevice *d,
|
---|
641 | uint32_t address, int len);
|
---|
642 | void pci_default_write_config(PCIDevice *d,
|
---|
643 | uint32_t address, uint32_t val, int len);
|
---|
644 | void generic_pci_save(QEMUFile* f, void *opaque);
|
---|
645 | int generic_pci_load(QEMUFile* f, void *opaque, int version_id);
|
---|
646 |
|
---|
647 | extern struct PIIX3State *piix3_state;
|
---|
648 |
|
---|
649 | PCIBus *i440fx_init(void);
|
---|
650 | void piix3_init(PCIBus *bus);
|
---|
651 | void pci_bios_init(void);
|
---|
652 | void pci_info(void);
|
---|
653 |
|
---|
654 | /* temporary: will be moved in platform specific file */
|
---|
655 | PCIBus *pci_prep_init(void);
|
---|
656 | struct openpic_t;
|
---|
657 | void pci_pmac_set_openpic(PCIBus *bus, struct openpic_t *openpic);
|
---|
658 | PCIBus *pci_pmac_init(void);
|
---|
659 |
|
---|
660 | /* openpic.c */
|
---|
661 | typedef struct openpic_t openpic_t;
|
---|
662 | void openpic_set_irq (openpic_t *opp, int n_IRQ, int level);
|
---|
663 | openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus);
|
---|
664 | #endif /* !VBOX */
|
---|
665 |
|
---|
666 | /* vga.c */
|
---|
667 |
|
---|
668 | #define VGA_RAM_SIZE (4096 * 1024)
|
---|
669 |
|
---|
670 | struct DisplayState {
|
---|
671 | uint8_t *data;
|
---|
672 | int linesize;
|
---|
673 | int depth;
|
---|
674 | int width;
|
---|
675 | int height;
|
---|
676 | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
|
---|
677 | void (*dpy_resize)(struct DisplayState *s, int w, int h);
|
---|
678 | void (*dpy_refresh)(struct DisplayState *s);
|
---|
679 | };
|
---|
680 |
|
---|
681 | static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
|
---|
682 | {
|
---|
683 | s->dpy_update(s, x, y, w, h);
|
---|
684 | }
|
---|
685 |
|
---|
686 | static inline void dpy_resize(DisplayState *s, int w, int h)
|
---|
687 | {
|
---|
688 | s->dpy_resize(s, w, h);
|
---|
689 | }
|
---|
690 |
|
---|
691 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
---|
692 | unsigned long vga_ram_offset, int vga_ram_size);
|
---|
693 | void vga_update_display(void);
|
---|
694 | void vga_invalidate_display(void);
|
---|
695 | void vga_screen_dump(const char *filename);
|
---|
696 |
|
---|
697 | /* cirrus_vga.c */
|
---|
698 | void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
---|
699 | unsigned long vga_ram_offset, int vga_ram_size);
|
---|
700 | void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
|
---|
701 | unsigned long vga_ram_offset, int vga_ram_size);
|
---|
702 |
|
---|
703 | /* sdl.c */
|
---|
704 | void sdl_display_init(DisplayState *ds, int full_screen);
|
---|
705 |
|
---|
706 | /* ide.c */
|
---|
707 | #define MAX_DISKS 4
|
---|
708 |
|
---|
709 | extern BlockDriverState *bs_table[MAX_DISKS];
|
---|
710 |
|
---|
711 | void isa_ide_init(int iobase, int iobase2, int irq,
|
---|
712 | BlockDriverState *hd0, BlockDriverState *hd1);
|
---|
713 | void pci_ide_init(PCIBus *bus, BlockDriverState **hd_table);
|
---|
714 | void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table);
|
---|
715 | int pmac_ide_init (BlockDriverState **hd_table,
|
---|
716 | openpic_t *openpic, int irq);
|
---|
717 |
|
---|
718 | /* sb16.c */
|
---|
719 | void SB16_init (void);
|
---|
720 |
|
---|
721 | /* adlib.c */
|
---|
722 | void Adlib_init (void);
|
---|
723 |
|
---|
724 | /* gus.c */
|
---|
725 | void GUS_init (void);
|
---|
726 |
|
---|
727 | /* dma.c */
|
---|
728 | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
|
---|
729 | int DMA_get_channel_mode (int nchan);
|
---|
730 | int DMA_read_memory (int nchan, void *buf, int pos, int size);
|
---|
731 | int DMA_write_memory (int nchan, void *buf, int pos, int size);
|
---|
732 | void DMA_hold_DREQ (int nchan);
|
---|
733 | void DMA_release_DREQ (int nchan);
|
---|
734 | void DMA_schedule(int nchan);
|
---|
735 | void DMA_run (void);
|
---|
736 | void DMA_init (int high_page_enable);
|
---|
737 | void DMA_register_channel (int nchan,
|
---|
738 | DMA_transfer_handler transfer_handler,
|
---|
739 | void *opaque);
|
---|
740 | /* fdc.c */
|
---|
741 | #define MAX_FD 2
|
---|
742 | extern BlockDriverState *fd_table[MAX_FD];
|
---|
743 |
|
---|
744 | typedef struct fdctrl_t fdctrl_t;
|
---|
745 |
|
---|
746 | fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
|
---|
747 | uint32_t io_base,
|
---|
748 | BlockDriverState **fds);
|
---|
749 | int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
|
---|
750 |
|
---|
751 | /* ne2000.c */
|
---|
752 |
|
---|
753 | void isa_ne2000_init(int base, int irq, NetDriverState *nd);
|
---|
754 | void pci_ne2000_init(PCIBus *bus, NetDriverState *nd);
|
---|
755 |
|
---|
756 | /* pckbd.c */
|
---|
757 |
|
---|
758 | void kbd_init(void);
|
---|
759 |
|
---|
760 | /* mc146818rtc.c */
|
---|
761 |
|
---|
762 | typedef struct RTCState RTCState;
|
---|
763 |
|
---|
764 | RTCState *rtc_init(int base, int irq);
|
---|
765 | void rtc_set_memory(RTCState *s, int addr, int val);
|
---|
766 | void rtc_set_date(RTCState *s, const struct tm *tm);
|
---|
767 |
|
---|
768 | /* serial.c */
|
---|
769 |
|
---|
770 | typedef struct SerialState SerialState;
|
---|
771 | SerialState *serial_init(int base, int irq, CharDriverState *chr);
|
---|
772 |
|
---|
773 | /* parallel.c */
|
---|
774 |
|
---|
775 | typedef struct ParallelState ParallelState;
|
---|
776 | ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
|
---|
777 |
|
---|
778 | /* i8259.c */
|
---|
779 |
|
---|
780 | void pic_set_irq(int irq, int level);
|
---|
781 | void pic_init(void);
|
---|
782 | uint32_t pic_intack_read(CPUState *env);
|
---|
783 | void pic_info(void);
|
---|
784 | void irq_info(void);
|
---|
785 |
|
---|
786 | /* APIC */
|
---|
787 | int apic_init(CPUState *env);
|
---|
788 | int apic_get_interrupt(CPUState *env);
|
---|
789 |
|
---|
790 | /* i8254.c */
|
---|
791 |
|
---|
792 | #define PIT_FREQ 1193182
|
---|
793 |
|
---|
794 | typedef struct PITState PITState;
|
---|
795 |
|
---|
796 | PITState *pit_init(int base, int irq);
|
---|
797 | void pit_set_gate(PITState *pit, int channel, int val);
|
---|
798 | int pit_get_gate(PITState *pit, int channel);
|
---|
799 | int pit_get_out(PITState *pit, int channel, int64_t current_time);
|
---|
800 |
|
---|
801 | /* pc.c */
|
---|
802 | void pc_init(int ram_size, int vga_ram_size, int boot_device,
|
---|
803 | DisplayState *ds, const char **fd_filename, int snapshot,
|
---|
804 | const char *kernel_filename, const char *kernel_cmdline,
|
---|
805 | const char *initrd_filename);
|
---|
806 |
|
---|
807 | /* ppc.c */
|
---|
808 | void ppc_init (int ram_size, int vga_ram_size, int boot_device,
|
---|
809 | DisplayState *ds, const char **fd_filename, int snapshot,
|
---|
810 | const char *kernel_filename, const char *kernel_cmdline,
|
---|
811 | const char *initrd_filename);
|
---|
812 | void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
|
---|
813 | DisplayState *ds, const char **fd_filename, int snapshot,
|
---|
814 | const char *kernel_filename, const char *kernel_cmdline,
|
---|
815 | const char *initrd_filename);
|
---|
816 | void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
|
---|
817 | DisplayState *ds, const char **fd_filename, int snapshot,
|
---|
818 | const char *kernel_filename, const char *kernel_cmdline,
|
---|
819 | const char *initrd_filename);
|
---|
820 | #ifdef TARGET_PPC
|
---|
821 | ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
|
---|
822 | #endif
|
---|
823 | void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
|
---|
824 |
|
---|
825 | extern CPUWriteMemoryFunc *PPC_io_write[];
|
---|
826 | extern CPUReadMemoryFunc *PPC_io_read[];
|
---|
827 | extern int prep_enabled;
|
---|
828 |
|
---|
829 | #ifndef VBOX
|
---|
830 | /* sun4m.c */
|
---|
831 | void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
|
---|
832 | DisplayState *ds, const char **fd_filename, int snapshot,
|
---|
833 | const char *kernel_filename, const char *kernel_cmdline,
|
---|
834 | const char *initrd_filename);
|
---|
835 | uint32_t iommu_translate(uint32_t addr);
|
---|
836 |
|
---|
837 | /* iommu.c */
|
---|
838 | void *iommu_init(uint32_t addr);
|
---|
839 | uint32_t iommu_translate_local(void *opaque, uint32_t addr);
|
---|
840 |
|
---|
841 | /* lance.c */
|
---|
842 | void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
|
---|
843 |
|
---|
844 | /* tcx.c */
|
---|
845 | void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
|
---|
846 | unsigned long vram_offset, int vram_size);
|
---|
847 | void tcx_update_display(void *opaque);
|
---|
848 | void tcx_invalidate_display(void *opaque);
|
---|
849 | void tcx_screen_dump(void *opaque, const char *filename);
|
---|
850 |
|
---|
851 | /* slavio_intctl.c */
|
---|
852 | void *slavio_intctl_init();
|
---|
853 | void slavio_pic_info(void *opaque);
|
---|
854 | void slavio_irq_info(void *opaque);
|
---|
855 | void slavio_pic_set_irq(void *opaque, int irq, int level);
|
---|
856 |
|
---|
857 | /* magic-load.c */
|
---|
858 | int load_elf(const char *filename, uint8_t *addr);
|
---|
859 | int load_aout(const char *filename, uint8_t *addr);
|
---|
860 |
|
---|
861 | /* slavio_timer.c */
|
---|
862 | void slavio_timer_init(uint32_t addr1, int irq1, uint32_t addr2, int irq2);
|
---|
863 |
|
---|
864 | /* slavio_serial.c */
|
---|
865 | SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2);
|
---|
866 | void slavio_serial_ms_kbd_init(int base, int irq);
|
---|
867 |
|
---|
868 | /* NVRAM helpers */
|
---|
869 | #include "hw/m48t59.h"
|
---|
870 |
|
---|
871 | void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
|
---|
872 | uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
|
---|
873 | void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
|
---|
874 | uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
|
---|
875 | void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
|
---|
876 | uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
|
---|
877 | void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
|
---|
878 | const unsigned char *str, uint32_t max);
|
---|
879 | int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
|
---|
880 | void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
|
---|
881 | uint32_t start, uint32_t count);
|
---|
882 | int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
|
---|
883 | const unsigned char *arch,
|
---|
884 | uint32_t RAM_size, int boot_device,
|
---|
885 | uint32_t kernel_image, uint32_t kernel_size,
|
---|
886 | const char *cmdline,
|
---|
887 | uint32_t initrd_image, uint32_t initrd_size,
|
---|
888 | uint32_t NVRAM_image,
|
---|
889 | int width, int height, int depth);
|
---|
890 | #endif
|
---|
891 |
|
---|
892 | /* adb.c */
|
---|
893 |
|
---|
894 | #define MAX_ADB_DEVICES 16
|
---|
895 |
|
---|
896 | #define ADB_MAX_OUT_LEN 16
|
---|
897 |
|
---|
898 | typedef struct ADBDevice ADBDevice;
|
---|
899 |
|
---|
900 | /* buf = NULL means polling */
|
---|
901 | typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
|
---|
902 | const uint8_t *buf, int len);
|
---|
903 | typedef int ADBDeviceReset(ADBDevice *d);
|
---|
904 |
|
---|
905 | struct ADBDevice {
|
---|
906 | struct ADBBusState *bus;
|
---|
907 | int devaddr;
|
---|
908 | int handler;
|
---|
909 | ADBDeviceRequest *devreq;
|
---|
910 | ADBDeviceReset *devreset;
|
---|
911 | void *opaque;
|
---|
912 | };
|
---|
913 |
|
---|
914 | typedef struct ADBBusState {
|
---|
915 | ADBDevice devices[MAX_ADB_DEVICES];
|
---|
916 | int nb_devices;
|
---|
917 | int poll_index;
|
---|
918 | } ADBBusState;
|
---|
919 |
|
---|
920 | int adb_request(ADBBusState *s, uint8_t *buf_out,
|
---|
921 | const uint8_t *buf, int len);
|
---|
922 | int adb_poll(ADBBusState *s, uint8_t *buf_out);
|
---|
923 |
|
---|
924 | ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
|
---|
925 | ADBDeviceRequest *devreq,
|
---|
926 | ADBDeviceReset *devreset,
|
---|
927 | void *opaque);
|
---|
928 | void adb_kbd_init(ADBBusState *bus);
|
---|
929 | void adb_mouse_init(ADBBusState *bus);
|
---|
930 |
|
---|
931 | /* cuda.c */
|
---|
932 |
|
---|
933 | extern ADBBusState adb_bus;
|
---|
934 | int cuda_init(openpic_t *openpic, int irq);
|
---|
935 |
|
---|
936 | #endif /* defined(QEMU_TOOL) */
|
---|
937 |
|
---|
938 | #ifndef VBOX
|
---|
939 | /* monitor.c */
|
---|
940 | void monitor_init(CharDriverState *hd, int show_banner);
|
---|
941 | void term_puts(const char *str);
|
---|
942 | void term_vprintf(const char *fmt, va_list ap);
|
---|
943 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
---|
944 | void term_flush(void);
|
---|
945 | void term_print_help(void);
|
---|
946 | void monitor_readline(const char *prompt, int is_password,
|
---|
947 | char *buf, int buf_size);
|
---|
948 |
|
---|
949 | /* readline.c */
|
---|
950 | typedef void ReadLineFunc(void *opaque, const char *str);
|
---|
951 |
|
---|
952 | extern int completion_index;
|
---|
953 | void add_completion(const char *str);
|
---|
954 | void readline_handle_byte(int ch);
|
---|
955 | void readline_find_completion(const char *cmdline);
|
---|
956 | const char *readline_get_history(unsigned int index);
|
---|
957 | void readline_start(const char *prompt, int is_password,
|
---|
958 | ReadLineFunc *readline_func, void *opaque);
|
---|
959 |
|
---|
960 | #endif /* !VBOX */
|
---|
961 |
|
---|
962 | /* gdbstub.c */
|
---|
963 |
|
---|
964 | #define DEFAULT_GDBSTUB_PORT 1234
|
---|
965 |
|
---|
966 | int gdbserver_start(int port);
|
---|
967 |
|
---|
968 | #endif /* VL_H */
|
---|