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