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