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