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