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" |
bellard | 1fddef4 | 2005-04-17 19:16:13 +0000 | [diff] [blame] | 74 | #include "gdbstub.h" |
bellard | 16f6243 | 2004-02-25 23:25:55 +0000 | [diff] [blame] | 75 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 76 | #endif /* !defined(QEMU_TOOL) */ |
| 77 | |
bellard | 67b915a | 2004-03-31 23:37:16 +0000 | [diff] [blame] | 78 | #ifndef glue |
| 79 | #define xglue(x, y) x ## y |
| 80 | #define glue(x, y) xglue(x, y) |
| 81 | #define stringify(s) tostring(s) |
| 82 | #define tostring(s) #s |
| 83 | #endif |
| 84 | |
bellard | 2423686 | 2006-04-30 21:28:36 +0000 | [diff] [blame] | 85 | #ifndef MIN |
| 86 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| 87 | #endif |
| 88 | #ifndef MAX |
| 89 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| 90 | #endif |
| 91 | |
bellard | 33e3963 | 2003-07-06 17:15:21 +0000 | [diff] [blame] | 92 | /* vl.c */ |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 93 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 94 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 95 | void hw_error(const char *fmt, ...); |
| 96 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 97 | extern const char *bios_dir; |
| 98 | |
| 99 | void pstrcpy(char *buf, int buf_size, const char *str); |
| 100 | char *pstrcat(char *buf, int buf_size, const char *s); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 101 | int strstart(const char *str, const char *val, const char **ptr); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 102 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 103 | extern int vm_running; |
| 104 | |
bellard | 0bd4885 | 2005-11-11 00:00:47 +0000 | [diff] [blame] | 105 | typedef struct vm_change_state_entry VMChangeStateEntry; |
| 106 | typedef void VMChangeStateHandler(void *opaque, int running); |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 107 | typedef void VMStopHandler(void *opaque, int reason); |
| 108 | |
bellard | 0bd4885 | 2005-11-11 00:00:47 +0000 | [diff] [blame] | 109 | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
| 110 | void *opaque); |
| 111 | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); |
| 112 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 113 | int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); |
| 114 | void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); |
| 115 | |
| 116 | void vm_start(void); |
| 117 | void vm_stop(int reason); |
| 118 | |
bellard | bb0c672 | 2004-06-20 12:37:32 +0000 | [diff] [blame] | 119 | typedef void QEMUResetHandler(void *opaque); |
| 120 | |
| 121 | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
| 122 | void qemu_system_reset_request(void); |
| 123 | void qemu_system_shutdown_request(void); |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 124 | void qemu_system_powerdown_request(void); |
| 125 | #if !defined(TARGET_SPARC) |
| 126 | // Please implement a power failure function to signal the OS |
| 127 | #define qemu_system_powerdown() do{}while(0) |
| 128 | #else |
| 129 | void qemu_system_powerdown(void); |
| 130 | #endif |
bellard | bb0c672 | 2004-06-20 12:37:32 +0000 | [diff] [blame] | 131 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 132 | void main_loop_wait(int timeout); |
| 133 | |
bellard | 0ced658 | 2004-05-23 21:06:12 +0000 | [diff] [blame] | 134 | extern int ram_size; |
| 135 | extern int bios_size; |
bellard | ee22c2f | 2004-06-03 12:49:50 +0000 | [diff] [blame] | 136 | extern int rtc_utc; |
bellard | 1f04275 | 2004-06-05 13:46:47 +0000 | [diff] [blame] | 137 | extern int cirrus_vga_enabled; |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 138 | extern int graphic_width; |
| 139 | extern int graphic_height; |
| 140 | extern int graphic_depth; |
bellard | 3d11d0e | 2004-12-12 16:56:30 +0000 | [diff] [blame] | 141 | extern const char *keyboard_layout; |
bellard | d993e02 | 2005-02-10 22:00:06 +0000 | [diff] [blame] | 142 | extern int kqemu_allowed; |
bellard | a09db21 | 2005-04-30 16:10:35 +0000 | [diff] [blame] | 143 | extern int win2k_install_hack; |
bellard | bb36d47 | 2005-11-05 14:22:28 +0000 | [diff] [blame] | 144 | extern int usb_enabled; |
bellard | 6a00d60 | 2005-11-21 23:25:50 +0000 | [diff] [blame] | 145 | extern int smp_cpus; |
bellard | 0ced658 | 2004-05-23 21:06:12 +0000 | [diff] [blame] | 146 | |
| 147 | /* XXX: make it dynamic */ |
| 148 | #if defined (TARGET_PPC) |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 149 | #define BIOS_SIZE ((512 + 32) * 1024) |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 150 | #elif defined(TARGET_MIPS) |
| 151 | #define BIOS_SIZE (128 * 1024) |
bellard | 0ced658 | 2004-05-23 21:06:12 +0000 | [diff] [blame] | 152 | #else |
bellard | 7587cf4 | 2004-06-20 13:43:27 +0000 | [diff] [blame] | 153 | #define BIOS_SIZE ((256 + 64) * 1024) |
bellard | 0ced658 | 2004-05-23 21:06:12 +0000 | [diff] [blame] | 154 | #endif |
bellard | aaaa7df | 2004-04-26 20:56:53 +0000 | [diff] [blame] | 155 | |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 156 | /* keyboard/mouse support */ |
| 157 | |
| 158 | #define MOUSE_EVENT_LBUTTON 0x01 |
| 159 | #define MOUSE_EVENT_RBUTTON 0x02 |
| 160 | #define MOUSE_EVENT_MBUTTON 0x04 |
| 161 | |
| 162 | typedef void QEMUPutKBDEvent(void *opaque, int keycode); |
| 163 | typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); |
| 164 | |
| 165 | void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); |
bellard | 09b26c5 | 2006-04-12 21:09:08 +0000 | [diff] [blame] | 166 | void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute); |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 167 | |
| 168 | void kbd_put_keycode(int keycode); |
| 169 | void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
bellard | 09b26c5 | 2006-04-12 21:09:08 +0000 | [diff] [blame] | 170 | int kbd_mouse_is_absolute(void); |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 171 | |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 172 | /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx |
| 173 | constants) */ |
| 174 | #define QEMU_KEY_ESC1(c) ((c) | 0xe100) |
| 175 | #define QEMU_KEY_BACKSPACE 0x007f |
| 176 | #define QEMU_KEY_UP QEMU_KEY_ESC1('A') |
| 177 | #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') |
| 178 | #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C') |
| 179 | #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D') |
| 180 | #define QEMU_KEY_HOME QEMU_KEY_ESC1(1) |
| 181 | #define QEMU_KEY_END QEMU_KEY_ESC1(4) |
| 182 | #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5) |
| 183 | #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6) |
| 184 | #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3) |
| 185 | |
| 186 | #define QEMU_KEY_CTRL_UP 0xe400 |
| 187 | #define QEMU_KEY_CTRL_DOWN 0xe401 |
| 188 | #define QEMU_KEY_CTRL_LEFT 0xe402 |
| 189 | #define QEMU_KEY_CTRL_RIGHT 0xe403 |
| 190 | #define QEMU_KEY_CTRL_HOME 0xe404 |
| 191 | #define QEMU_KEY_CTRL_END 0xe405 |
| 192 | #define QEMU_KEY_CTRL_PAGEUP 0xe406 |
| 193 | #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 |
| 194 | |
| 195 | void kbd_put_keysym(int keysym); |
| 196 | |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 197 | /* async I/O support */ |
| 198 | |
| 199 | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); |
| 200 | typedef int IOCanRWHandler(void *opaque); |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 201 | typedef void IOHandler(void *opaque); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 202 | |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 203 | int qemu_set_fd_handler2(int fd, |
| 204 | IOCanRWHandler *fd_read_poll, |
| 205 | IOHandler *fd_read, |
| 206 | IOHandler *fd_write, |
| 207 | void *opaque); |
| 208 | int qemu_set_fd_handler(int fd, |
| 209 | IOHandler *fd_read, |
| 210 | IOHandler *fd_write, |
| 211 | void *opaque); |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 212 | |
bellard | f331110 | 2006-04-12 20:21:17 +0000 | [diff] [blame] | 213 | /* Polling handling */ |
| 214 | |
| 215 | /* return TRUE if no sleep should be done afterwards */ |
| 216 | typedef int PollingFunc(void *opaque); |
| 217 | |
| 218 | int qemu_add_polling_cb(PollingFunc *func, void *opaque); |
| 219 | void qemu_del_polling_cb(PollingFunc *func, void *opaque); |
| 220 | |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 221 | /* character device */ |
| 222 | |
| 223 | #define CHR_EVENT_BREAK 0 /* serial break char */ |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 224 | #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 225 | |
bellard | 2122c51 | 2005-11-10 23:58:33 +0000 | [diff] [blame] | 226 | |
| 227 | |
| 228 | #define CHR_IOCTL_SERIAL_SET_PARAMS 1 |
| 229 | typedef struct { |
| 230 | int speed; |
| 231 | int parity; |
| 232 | int data_bits; |
| 233 | int stop_bits; |
| 234 | } QEMUSerialSetParams; |
| 235 | |
| 236 | #define CHR_IOCTL_SERIAL_SET_BREAK 2 |
| 237 | |
| 238 | #define CHR_IOCTL_PP_READ_DATA 3 |
| 239 | #define CHR_IOCTL_PP_WRITE_DATA 4 |
| 240 | #define CHR_IOCTL_PP_READ_CONTROL 5 |
| 241 | #define CHR_IOCTL_PP_WRITE_CONTROL 6 |
| 242 | #define CHR_IOCTL_PP_READ_STATUS 7 |
| 243 | |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 244 | typedef void IOEventHandler(void *opaque, int event); |
| 245 | |
| 246 | typedef struct CharDriverState { |
| 247 | int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); |
| 248 | void (*chr_add_read_handler)(struct CharDriverState *s, |
| 249 | IOCanRWHandler *fd_can_read, |
| 250 | IOReadHandler *fd_read, void *opaque); |
bellard | 2122c51 | 2005-11-10 23:58:33 +0000 | [diff] [blame] | 251 | int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 252 | IOEventHandler *chr_event; |
bellard | eb45f5f | 2004-09-18 19:33:09 +0000 | [diff] [blame] | 253 | void (*chr_send_event)(struct CharDriverState *chr, int event); |
bellard | f331110 | 2006-04-12 20:21:17 +0000 | [diff] [blame] | 254 | void (*chr_close)(struct CharDriverState *chr); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 255 | void *opaque; |
| 256 | } CharDriverState; |
| 257 | |
| 258 | void qemu_chr_printf(CharDriverState *s, const char *fmt, ...); |
| 259 | int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 260 | void qemu_chr_send_event(CharDriverState *s, int event); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 261 | void qemu_chr_add_read_handler(CharDriverState *s, |
| 262 | IOCanRWHandler *fd_can_read, |
| 263 | IOReadHandler *fd_read, void *opaque); |
| 264 | void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event); |
bellard | 2122c51 | 2005-11-10 23:58:33 +0000 | [diff] [blame] | 265 | int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); |
bellard | f8d179e | 2005-11-08 22:30:36 +0000 | [diff] [blame] | 266 | |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 267 | /* consoles */ |
| 268 | |
| 269 | typedef struct DisplayState DisplayState; |
| 270 | typedef struct TextConsole TextConsole; |
| 271 | |
pbrook | 9521989 | 2006-04-09 01:06:34 +0000 | [diff] [blame] | 272 | typedef void (*vga_hw_update_ptr)(void *); |
| 273 | typedef void (*vga_hw_invalidate_ptr)(void *); |
| 274 | typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 275 | |
pbrook | 9521989 | 2006-04-09 01:06:34 +0000 | [diff] [blame] | 276 | TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, |
| 277 | vga_hw_invalidate_ptr invalidate, |
| 278 | vga_hw_screen_dump_ptr screen_dump, |
| 279 | void *opaque); |
| 280 | void vga_hw_update(void); |
| 281 | void vga_hw_invalidate(void); |
| 282 | void vga_hw_screen_dump(const char *filename); |
| 283 | |
| 284 | int is_graphic_console(void); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 285 | CharDriverState *text_console_init(DisplayState *ds); |
| 286 | void console_select(unsigned int index); |
| 287 | |
bellard | 8d11df9 | 2004-08-24 21:13:40 +0000 | [diff] [blame] | 288 | /* serial ports */ |
| 289 | |
| 290 | #define MAX_SERIAL_PORTS 4 |
| 291 | |
| 292 | extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; |
| 293 | |
bellard | 6508fe5 | 2005-01-15 12:02:56 +0000 | [diff] [blame] | 294 | /* parallel ports */ |
| 295 | |
| 296 | #define MAX_PARALLEL_PORTS 3 |
| 297 | |
| 298 | extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; |
| 299 | |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 300 | /* VLANs support */ |
| 301 | |
| 302 | typedef struct VLANClientState VLANClientState; |
| 303 | |
| 304 | struct VLANClientState { |
| 305 | IOReadHandler *fd_read; |
pbrook | d861b05 | 2006-02-04 22:15:28 +0000 | [diff] [blame] | 306 | /* Packets may still be sent if this returns zero. It's used to |
| 307 | rate-limit the slirp code. */ |
| 308 | IOCanRWHandler *fd_can_read; |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 309 | void *opaque; |
| 310 | struct VLANClientState *next; |
| 311 | struct VLANState *vlan; |
| 312 | char info_str[256]; |
| 313 | }; |
| 314 | |
| 315 | typedef struct VLANState { |
| 316 | int id; |
| 317 | VLANClientState *first_client; |
| 318 | struct VLANState *next; |
| 319 | } VLANState; |
| 320 | |
| 321 | VLANState *qemu_find_vlan(int id); |
| 322 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
pbrook | d861b05 | 2006-02-04 22:15:28 +0000 | [diff] [blame] | 323 | IOReadHandler *fd_read, |
| 324 | IOCanRWHandler *fd_can_read, |
| 325 | void *opaque); |
| 326 | int qemu_can_send_packet(VLANClientState *vc); |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 327 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
pbrook | d861b05 | 2006-02-04 22:15:28 +0000 | [diff] [blame] | 328 | void qemu_handler_true(void *opaque); |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 329 | |
| 330 | void do_info_network(void); |
| 331 | |
bellard | 7fb843f | 2006-02-01 23:06:55 +0000 | [diff] [blame] | 332 | /* TAP win32 */ |
| 333 | int tap_win32_init(VLANState *vlan, const char *ifname); |
| 334 | void tap_win32_poll(void); |
| 335 | |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 336 | /* NIC info */ |
bellard | c20709a | 2004-04-21 23:27:19 +0000 | [diff] [blame] | 337 | |
| 338 | #define MAX_NICS 8 |
| 339 | |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 340 | typedef struct NICInfo { |
bellard | c20709a | 2004-04-21 23:27:19 +0000 | [diff] [blame] | 341 | uint8_t macaddr[6]; |
pbrook | a41b2ff | 2006-02-05 04:14:41 +0000 | [diff] [blame] | 342 | const char *model; |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 343 | VLANState *vlan; |
| 344 | } NICInfo; |
bellard | c20709a | 2004-04-21 23:27:19 +0000 | [diff] [blame] | 345 | |
| 346 | extern int nb_nics; |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 347 | extern NICInfo nd_table[MAX_NICS]; |
bellard | c20709a | 2004-04-21 23:27:19 +0000 | [diff] [blame] | 348 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 349 | /* timers */ |
| 350 | |
| 351 | typedef struct QEMUClock QEMUClock; |
| 352 | typedef struct QEMUTimer QEMUTimer; |
| 353 | typedef void QEMUTimerCB(void *opaque); |
| 354 | |
| 355 | /* The real time clock should be used only for stuff which does not |
| 356 | change the virtual machine state, as it is run even if the virtual |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 357 | machine is stopped. The real time clock has a frequency of 1000 |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 358 | Hz. */ |
| 359 | extern QEMUClock *rt_clock; |
| 360 | |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 361 | /* The virtual clock is only run during the emulation. It is stopped |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 362 | when the virtual machine is stopped. Virtual timers use a high |
| 363 | precision clock, usually cpu cycles (use ticks_per_sec). */ |
| 364 | extern QEMUClock *vm_clock; |
| 365 | |
| 366 | int64_t qemu_get_clock(QEMUClock *clock); |
| 367 | |
| 368 | QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque); |
| 369 | void qemu_free_timer(QEMUTimer *ts); |
| 370 | void qemu_del_timer(QEMUTimer *ts); |
| 371 | void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); |
| 372 | int qemu_timer_pending(QEMUTimer *ts); |
| 373 | |
| 374 | extern int64_t ticks_per_sec; |
| 375 | extern int pit_min_timer_count; |
| 376 | |
| 377 | void cpu_enable_ticks(void); |
| 378 | void cpu_disable_ticks(void); |
| 379 | |
| 380 | /* VM Load/Save */ |
| 381 | |
| 382 | typedef FILE QEMUFile; |
| 383 | |
| 384 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
| 385 | void qemu_put_byte(QEMUFile *f, int v); |
| 386 | void qemu_put_be16(QEMUFile *f, unsigned int v); |
| 387 | void qemu_put_be32(QEMUFile *f, unsigned int v); |
| 388 | void qemu_put_be64(QEMUFile *f, uint64_t v); |
| 389 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
| 390 | int qemu_get_byte(QEMUFile *f); |
| 391 | unsigned int qemu_get_be16(QEMUFile *f); |
| 392 | unsigned int qemu_get_be32(QEMUFile *f); |
| 393 | uint64_t qemu_get_be64(QEMUFile *f); |
| 394 | |
| 395 | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
| 396 | { |
| 397 | qemu_put_be64(f, *pv); |
| 398 | } |
| 399 | |
| 400 | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
| 401 | { |
| 402 | qemu_put_be32(f, *pv); |
| 403 | } |
| 404 | |
| 405 | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
| 406 | { |
| 407 | qemu_put_be16(f, *pv); |
| 408 | } |
| 409 | |
| 410 | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
| 411 | { |
| 412 | qemu_put_byte(f, *pv); |
| 413 | } |
| 414 | |
| 415 | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
| 416 | { |
| 417 | *pv = qemu_get_be64(f); |
| 418 | } |
| 419 | |
| 420 | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
| 421 | { |
| 422 | *pv = qemu_get_be32(f); |
| 423 | } |
| 424 | |
| 425 | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
| 426 | { |
| 427 | *pv = qemu_get_be16(f); |
| 428 | } |
| 429 | |
| 430 | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
| 431 | { |
| 432 | *pv = qemu_get_byte(f); |
| 433 | } |
| 434 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 435 | #if TARGET_LONG_BITS == 64 |
| 436 | #define qemu_put_betl qemu_put_be64 |
| 437 | #define qemu_get_betl qemu_get_be64 |
| 438 | #define qemu_put_betls qemu_put_be64s |
| 439 | #define qemu_get_betls qemu_get_be64s |
| 440 | #else |
| 441 | #define qemu_put_betl qemu_put_be32 |
| 442 | #define qemu_get_betl qemu_get_be32 |
| 443 | #define qemu_put_betls qemu_put_be32s |
| 444 | #define qemu_get_betls qemu_get_be32s |
| 445 | #endif |
| 446 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 447 | int64_t qemu_ftell(QEMUFile *f); |
| 448 | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence); |
| 449 | |
| 450 | typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
| 451 | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
| 452 | |
| 453 | int qemu_loadvm(const char *filename); |
| 454 | int qemu_savevm(const char *filename); |
| 455 | int register_savevm(const char *idstr, |
| 456 | int instance_id, |
| 457 | int version_id, |
| 458 | SaveStateHandler *save_state, |
| 459 | LoadStateHandler *load_state, |
| 460 | void *opaque); |
| 461 | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); |
| 462 | void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 463 | |
bellard | 6a00d60 | 2005-11-21 23:25:50 +0000 | [diff] [blame] | 464 | void cpu_save(QEMUFile *f, void *opaque); |
| 465 | int cpu_load(QEMUFile *f, void *opaque, int version_id); |
| 466 | |
bellard | fc01f7e | 2003-06-30 10:03:06 +0000 | [diff] [blame] | 467 | /* block.c */ |
| 468 | typedef struct BlockDriverState BlockDriverState; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 469 | typedef struct BlockDriver BlockDriver; |
bellard | fc01f7e | 2003-06-30 10:03:06 +0000 | [diff] [blame] | 470 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 471 | extern BlockDriver bdrv_raw; |
| 472 | extern BlockDriver bdrv_cow; |
| 473 | extern BlockDriver bdrv_qcow; |
| 474 | extern BlockDriver bdrv_vmdk; |
bellard | 3c56521 | 2004-09-29 21:29:14 +0000 | [diff] [blame] | 475 | extern BlockDriver bdrv_cloop; |
bellard | 585d0ed | 2004-12-12 11:24:44 +0000 | [diff] [blame] | 476 | extern BlockDriver bdrv_dmg; |
bellard | a8753c3 | 2005-04-26 21:34:00 +0000 | [diff] [blame] | 477 | extern BlockDriver bdrv_bochs; |
bellard | 6a0f9e8 | 2005-04-27 20:17:58 +0000 | [diff] [blame] | 478 | extern BlockDriver bdrv_vpc; |
bellard | de167e4 | 2005-04-28 21:15:08 +0000 | [diff] [blame] | 479 | extern BlockDriver bdrv_vvfat; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 480 | |
| 481 | void bdrv_init(void); |
| 482 | BlockDriver *bdrv_find_format(const char *format_name); |
| 483 | int bdrv_create(BlockDriver *drv, |
| 484 | const char *filename, int64_t size_in_sectors, |
| 485 | const char *backing_file, int flags); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 486 | BlockDriverState *bdrv_new(const char *device_name); |
| 487 | void bdrv_delete(BlockDriverState *bs); |
| 488 | int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 489 | int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot, |
| 490 | BlockDriver *drv); |
bellard | fc01f7e | 2003-06-30 10:03:06 +0000 | [diff] [blame] | 491 | void bdrv_close(BlockDriverState *bs); |
| 492 | int bdrv_read(BlockDriverState *bs, int64_t sector_num, |
| 493 | uint8_t *buf, int nb_sectors); |
| 494 | int bdrv_write(BlockDriverState *bs, int64_t sector_num, |
| 495 | const uint8_t *buf, int nb_sectors); |
| 496 | void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr); |
bellard | 33e3963 | 2003-07-06 17:15:21 +0000 | [diff] [blame] | 497 | int bdrv_commit(BlockDriverState *bs); |
bellard | 77fef8c | 2004-02-16 22:05:46 +0000 | [diff] [blame] | 498 | void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
bellard | fc01f7e | 2003-06-30 10:03:06 +0000 | [diff] [blame] | 499 | |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 500 | #define BDRV_TYPE_HD 0 |
| 501 | #define BDRV_TYPE_CDROM 1 |
| 502 | #define BDRV_TYPE_FLOPPY 2 |
bellard | 46d4767 | 2004-11-16 01:45:27 +0000 | [diff] [blame] | 503 | #define BIOS_ATA_TRANSLATION_AUTO 0 |
| 504 | #define BIOS_ATA_TRANSLATION_NONE 1 |
| 505 | #define BIOS_ATA_TRANSLATION_LBA 2 |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 506 | |
| 507 | void bdrv_set_geometry_hint(BlockDriverState *bs, |
| 508 | int cyls, int heads, int secs); |
| 509 | void bdrv_set_type_hint(BlockDriverState *bs, int type); |
bellard | 46d4767 | 2004-11-16 01:45:27 +0000 | [diff] [blame] | 510 | void bdrv_set_translation_hint(BlockDriverState *bs, int translation); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 511 | void bdrv_get_geometry_hint(BlockDriverState *bs, |
| 512 | int *pcyls, int *pheads, int *psecs); |
| 513 | int bdrv_get_type_hint(BlockDriverState *bs); |
bellard | 46d4767 | 2004-11-16 01:45:27 +0000 | [diff] [blame] | 514 | int bdrv_get_translation_hint(BlockDriverState *bs); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 515 | int bdrv_is_removable(BlockDriverState *bs); |
| 516 | int bdrv_is_read_only(BlockDriverState *bs); |
| 517 | int bdrv_is_inserted(BlockDriverState *bs); |
| 518 | int bdrv_is_locked(BlockDriverState *bs); |
| 519 | void bdrv_set_locked(BlockDriverState *bs, int locked); |
| 520 | void bdrv_set_change_cb(BlockDriverState *bs, |
| 521 | void (*change_cb)(void *opaque), void *opaque); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 522 | void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 523 | void bdrv_info(void); |
| 524 | BlockDriverState *bdrv_find(const char *name); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 525 | void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 526 | int bdrv_is_encrypted(BlockDriverState *bs); |
| 527 | int bdrv_set_key(BlockDriverState *bs, const char *key); |
| 528 | void bdrv_iterate_format(void (*it)(void *opaque, const char *name), |
| 529 | void *opaque); |
| 530 | const char *bdrv_get_device_name(BlockDriverState *bs); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 531 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 532 | int qcow_get_cluster_size(BlockDriverState *bs); |
| 533 | int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num, |
| 534 | const uint8_t *buf); |
| 535 | |
| 536 | #ifndef QEMU_TOOL |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 537 | |
| 538 | typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, |
| 539 | int boot_device, |
| 540 | DisplayState *ds, const char **fd_filename, int snapshot, |
| 541 | const char *kernel_filename, const char *kernel_cmdline, |
| 542 | const char *initrd_filename); |
| 543 | |
| 544 | typedef struct QEMUMachine { |
| 545 | const char *name; |
| 546 | const char *desc; |
| 547 | QEMUMachineInitFunc *init; |
| 548 | struct QEMUMachine *next; |
| 549 | } QEMUMachine; |
| 550 | |
| 551 | int qemu_register_machine(QEMUMachine *m); |
| 552 | |
| 553 | typedef void SetIRQFunc(void *opaque, int irq_num, int level); |
bellard | 3de388f | 2005-07-02 18:11:44 +0000 | [diff] [blame] | 554 | typedef void IRQRequestFunc(void *opaque, int level); |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 555 | |
bellard | 26aa7d7 | 2004-04-28 22:26:05 +0000 | [diff] [blame] | 556 | /* ISA bus */ |
| 557 | |
| 558 | extern target_phys_addr_t isa_mem_base; |
| 559 | |
| 560 | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); |
| 561 | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); |
| 562 | |
| 563 | int register_ioport_read(int start, int length, int size, |
| 564 | IOPortReadFunc *func, void *opaque); |
| 565 | int register_ioport_write(int start, int length, int size, |
| 566 | IOPortWriteFunc *func, void *opaque); |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 567 | void isa_unassign_ioport(int start, int length); |
| 568 | |
| 569 | /* PCI bus */ |
| 570 | |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 571 | extern target_phys_addr_t pci_mem_base; |
| 572 | |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 573 | typedef struct PCIBus PCIBus; |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 574 | typedef struct PCIDevice PCIDevice; |
| 575 | |
| 576 | typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, |
| 577 | uint32_t address, uint32_t data, int len); |
| 578 | typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev, |
| 579 | uint32_t address, int len); |
| 580 | typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, |
| 581 | uint32_t addr, uint32_t size, int type); |
| 582 | |
| 583 | #define PCI_ADDRESS_SPACE_MEM 0x00 |
| 584 | #define PCI_ADDRESS_SPACE_IO 0x01 |
| 585 | #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08 |
| 586 | |
| 587 | typedef struct PCIIORegion { |
bellard | 5768f5a | 2004-05-20 12:47:45 +0000 | [diff] [blame] | 588 | uint32_t addr; /* current PCI mapping address. -1 means not mapped */ |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 589 | uint32_t size; |
| 590 | uint8_t type; |
| 591 | PCIMapIORegionFunc *map_func; |
| 592 | } PCIIORegion; |
| 593 | |
bellard | 8a8696a | 2004-06-03 14:06:32 +0000 | [diff] [blame] | 594 | #define PCI_ROM_SLOT 6 |
| 595 | #define PCI_NUM_REGIONS 7 |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 596 | struct PCIDevice { |
| 597 | /* PCI config space */ |
| 598 | uint8_t config[256]; |
| 599 | |
| 600 | /* the following fields are read only */ |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 601 | PCIBus *bus; |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 602 | int devfn; |
| 603 | char name[64]; |
bellard | 8a8696a | 2004-06-03 14:06:32 +0000 | [diff] [blame] | 604 | PCIIORegion io_regions[PCI_NUM_REGIONS]; |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 605 | |
| 606 | /* do not access the following fields */ |
| 607 | PCIConfigReadFunc *config_read; |
| 608 | PCIConfigWriteFunc *config_write; |
bellard | 5768f5a | 2004-05-20 12:47:45 +0000 | [diff] [blame] | 609 | int irq_index; |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 610 | }; |
| 611 | |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 612 | PCIDevice *pci_register_device(PCIBus *bus, const char *name, |
| 613 | int instance_size, int devfn, |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 614 | PCIConfigReadFunc *config_read, |
| 615 | PCIConfigWriteFunc *config_write); |
| 616 | |
| 617 | void pci_register_io_region(PCIDevice *pci_dev, int region_num, |
| 618 | uint32_t size, int type, |
| 619 | PCIMapIORegionFunc *map_func); |
| 620 | |
bellard | 5768f5a | 2004-05-20 12:47:45 +0000 | [diff] [blame] | 621 | void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level); |
| 622 | |
| 623 | uint32_t pci_default_read_config(PCIDevice *d, |
| 624 | uint32_t address, int len); |
| 625 | void pci_default_write_config(PCIDevice *d, |
| 626 | uint32_t address, uint32_t val, int len); |
bellard | 30ca2aa | 2004-10-03 13:56:00 +0000 | [diff] [blame] | 627 | void generic_pci_save(QEMUFile* f, void *opaque); |
| 628 | int generic_pci_load(QEMUFile* f, void *opaque, int version_id); |
bellard | 5768f5a | 2004-05-20 12:47:45 +0000 | [diff] [blame] | 629 | |
bellard | 9995c51 | 2004-05-23 19:09:22 +0000 | [diff] [blame] | 630 | extern struct PIIX3State *piix3_state; |
| 631 | |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 632 | PCIBus *i440fx_init(void); |
| 633 | void piix3_init(PCIBus *bus); |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 634 | void pci_bios_init(void); |
bellard | 5768f5a | 2004-05-20 12:47:45 +0000 | [diff] [blame] | 635 | void pci_info(void); |
bellard | 26aa7d7 | 2004-04-28 22:26:05 +0000 | [diff] [blame] | 636 | |
bellard | 77d4bc3 | 2004-05-26 22:13:53 +0000 | [diff] [blame] | 637 | /* temporary: will be moved in platform specific file */ |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 638 | void pci_set_pic(PCIBus *bus, SetIRQFunc *set_irq, void *irq_opaque); |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 639 | PCIBus *pci_prep_init(void); |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 640 | PCIBus *pci_grackle_init(uint32_t base); |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 641 | PCIBus *pci_pmac_init(void); |
bellard | 8346901 | 2005-07-23 14:27:54 +0000 | [diff] [blame] | 642 | PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base); |
bellard | 77d4bc3 | 2004-05-26 22:13:53 +0000 | [diff] [blame] | 643 | |
pbrook | a41b2ff | 2006-02-05 04:14:41 +0000 | [diff] [blame] | 644 | void pci_nic_init(PCIBus *bus, NICInfo *nd); |
| 645 | |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 646 | /* openpic.c */ |
| 647 | typedef struct openpic_t openpic_t; |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 648 | void openpic_set_irq(void *opaque, int n_IRQ, int level); |
bellard | 7668a27 | 2005-11-23 21:13:45 +0000 | [diff] [blame] | 649 | openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, |
| 650 | CPUState **envp); |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 651 | |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 652 | /* heathrow_pic.c */ |
| 653 | typedef struct HeathrowPICS HeathrowPICS; |
| 654 | void heathrow_pic_set_irq(void *opaque, int num, int level); |
| 655 | HeathrowPICS *heathrow_pic_init(int *pmem_index); |
| 656 | |
bellard | 6a36d84 | 2005-12-18 20:34:32 +0000 | [diff] [blame] | 657 | #ifdef HAS_AUDIO |
| 658 | struct soundhw { |
| 659 | const char *name; |
| 660 | const char *descr; |
| 661 | int enabled; |
| 662 | int isa; |
| 663 | union { |
| 664 | int (*init_isa) (AudioState *s); |
| 665 | int (*init_pci) (PCIBus *bus, AudioState *s); |
| 666 | } init; |
| 667 | }; |
| 668 | |
| 669 | extern struct soundhw soundhw[]; |
| 670 | #endif |
| 671 | |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 672 | /* vga.c */ |
| 673 | |
bellard | 4fa0f5d | 2004-02-06 19:47:52 +0000 | [diff] [blame] | 674 | #define VGA_RAM_SIZE (4096 * 1024) |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 675 | |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 676 | struct DisplayState { |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 677 | uint8_t *data; |
| 678 | int linesize; |
| 679 | int depth; |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 680 | int width; |
| 681 | int height; |
bellard | 2423686 | 2006-04-30 21:28:36 +0000 | [diff] [blame] | 682 | void *opaque; |
| 683 | |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 684 | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
| 685 | void (*dpy_resize)(struct DisplayState *s, int w, int h); |
| 686 | void (*dpy_refresh)(struct DisplayState *s); |
bellard | 2423686 | 2006-04-30 21:28:36 +0000 | [diff] [blame] | 687 | void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 688 | }; |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 689 | |
| 690 | static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) |
| 691 | { |
| 692 | s->dpy_update(s, x, y, w, h); |
| 693 | } |
| 694 | |
| 695 | static inline void dpy_resize(DisplayState *s, int w, int h) |
| 696 | { |
| 697 | s->dpy_resize(s, w, h); |
| 698 | } |
| 699 | |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 700 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 701 | unsigned long vga_ram_offset, int vga_ram_size, |
| 702 | unsigned long vga_bios_offset, int vga_bios_size); |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 703 | |
bellard | d6bfa22 | 2004-06-05 10:32:30 +0000 | [diff] [blame] | 704 | /* cirrus_vga.c */ |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 705 | 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] | 706 | unsigned long vga_ram_offset, int vga_ram_size); |
bellard | d6bfa22 | 2004-06-05 10:32:30 +0000 | [diff] [blame] | 707 | void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, |
| 708 | unsigned long vga_ram_offset, int vga_ram_size); |
| 709 | |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 710 | /* sdl.c */ |
bellard | d63d307 | 2004-10-03 13:29:03 +0000 | [diff] [blame] | 711 | void sdl_display_init(DisplayState *ds, int full_screen); |
bellard | 313aa56 | 2003-08-10 21:52:11 +0000 | [diff] [blame] | 712 | |
bellard | da4dbf7 | 2005-03-02 22:22:43 +0000 | [diff] [blame] | 713 | /* cocoa.m */ |
| 714 | void cocoa_display_init(DisplayState *ds, int full_screen); |
| 715 | |
bellard | 2423686 | 2006-04-30 21:28:36 +0000 | [diff] [blame] | 716 | /* vnc.c */ |
| 717 | void vnc_display_init(DisplayState *ds, int display); |
| 718 | |
bellard | 5391d80 | 2003-11-11 13:48:59 +0000 | [diff] [blame] | 719 | /* ide.c */ |
| 720 | #define MAX_DISKS 4 |
| 721 | |
| 722 | extern BlockDriverState *bs_table[MAX_DISKS]; |
| 723 | |
bellard | 69b9103 | 2004-05-18 23:05:28 +0000 | [diff] [blame] | 724 | void isa_ide_init(int iobase, int iobase2, int irq, |
| 725 | BlockDriverState *hd0, BlockDriverState *hd1); |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 726 | void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table, |
| 727 | int secondary_ide_enabled); |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 728 | void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table); |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 729 | int pmac_ide_init (BlockDriverState **hd_table, |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 730 | SetIRQFunc *set_irq, void *irq_opaque, int irq); |
bellard | 5391d80 | 2003-11-11 13:48:59 +0000 | [diff] [blame] | 731 | |
bellard | 1d14ffa | 2005-10-30 18:58:22 +0000 | [diff] [blame] | 732 | /* es1370.c */ |
bellard | c0fe382 | 2005-11-05 18:55:28 +0000 | [diff] [blame] | 733 | int es1370_init (PCIBus *bus, AudioState *s); |
bellard | 1d14ffa | 2005-10-30 18:58:22 +0000 | [diff] [blame] | 734 | |
bellard | fb06518 | 2004-11-09 23:09:44 +0000 | [diff] [blame] | 735 | /* sb16.c */ |
bellard | c0fe382 | 2005-11-05 18:55:28 +0000 | [diff] [blame] | 736 | int SB16_init (AudioState *s); |
bellard | fb06518 | 2004-11-09 23:09:44 +0000 | [diff] [blame] | 737 | |
| 738 | /* adlib.c */ |
bellard | c0fe382 | 2005-11-05 18:55:28 +0000 | [diff] [blame] | 739 | int Adlib_init (AudioState *s); |
bellard | fb06518 | 2004-11-09 23:09:44 +0000 | [diff] [blame] | 740 | |
| 741 | /* gus.c */ |
bellard | c0fe382 | 2005-11-05 18:55:28 +0000 | [diff] [blame] | 742 | int GUS_init (AudioState *s); |
bellard | 2750332 | 2003-11-13 01:46:15 +0000 | [diff] [blame] | 743 | |
| 744 | /* dma.c */ |
bellard | 85571bc | 2004-11-07 18:04:02 +0000 | [diff] [blame] | 745 | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); |
bellard | 2750332 | 2003-11-13 01:46:15 +0000 | [diff] [blame] | 746 | int DMA_get_channel_mode (int nchan); |
bellard | 85571bc | 2004-11-07 18:04:02 +0000 | [diff] [blame] | 747 | int DMA_read_memory (int nchan, void *buf, int pos, int size); |
| 748 | int DMA_write_memory (int nchan, void *buf, int pos, int size); |
bellard | 2750332 | 2003-11-13 01:46:15 +0000 | [diff] [blame] | 749 | void DMA_hold_DREQ (int nchan); |
| 750 | void DMA_release_DREQ (int nchan); |
bellard | 16f6243 | 2004-02-25 23:25:55 +0000 | [diff] [blame] | 751 | void DMA_schedule(int nchan); |
bellard | 2750332 | 2003-11-13 01:46:15 +0000 | [diff] [blame] | 752 | void DMA_run (void); |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 753 | void DMA_init (int high_page_enable); |
bellard | 2750332 | 2003-11-13 01:46:15 +0000 | [diff] [blame] | 754 | void DMA_register_channel (int nchan, |
bellard | 85571bc | 2004-11-07 18:04:02 +0000 | [diff] [blame] | 755 | DMA_transfer_handler transfer_handler, |
| 756 | void *opaque); |
bellard | 7138fcf | 2004-01-05 00:02:28 +0000 | [diff] [blame] | 757 | /* fdc.c */ |
| 758 | #define MAX_FD 2 |
| 759 | extern BlockDriverState *fd_table[MAX_FD]; |
| 760 | |
bellard | baca51f | 2004-03-19 23:05:34 +0000 | [diff] [blame] | 761 | typedef struct fdctrl_t fdctrl_t; |
| 762 | |
| 763 | fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, |
| 764 | uint32_t io_base, |
| 765 | BlockDriverState **fds); |
| 766 | int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num); |
bellard | 7138fcf | 2004-01-05 00:02:28 +0000 | [diff] [blame] | 767 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 768 | /* ne2000.c */ |
| 769 | |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 770 | void isa_ne2000_init(int base, int irq, NICInfo *nd); |
| 771 | void pci_ne2000_init(PCIBus *bus, NICInfo *nd); |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 772 | |
pbrook | a41b2ff | 2006-02-05 04:14:41 +0000 | [diff] [blame] | 773 | /* rtl8139.c */ |
| 774 | |
| 775 | void pci_rtl8139_init(PCIBus *bus, NICInfo *nd); |
| 776 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 777 | /* pckbd.c */ |
| 778 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 779 | void kbd_init(void); |
| 780 | |
| 781 | /* mc146818rtc.c */ |
| 782 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 783 | typedef struct RTCState RTCState; |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 784 | |
bellard | 8a7ddc3 | 2004-03-31 19:00:16 +0000 | [diff] [blame] | 785 | RTCState *rtc_init(int base, int irq); |
| 786 | void rtc_set_memory(RTCState *s, int addr, int val); |
| 787 | void rtc_set_date(RTCState *s, const struct tm *tm); |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 788 | |
| 789 | /* serial.c */ |
| 790 | |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 791 | typedef struct SerialState SerialState; |
bellard | e5d13e2 | 2005-11-23 21:11:49 +0000 | [diff] [blame] | 792 | SerialState *serial_init(SetIRQFunc *set_irq, void *opaque, |
| 793 | int base, int irq, CharDriverState *chr); |
| 794 | SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque, |
| 795 | target_ulong base, int it_shift, |
| 796 | int irq, CharDriverState *chr); |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 797 | |
bellard | 6508fe5 | 2005-01-15 12:02:56 +0000 | [diff] [blame] | 798 | /* parallel.c */ |
| 799 | |
| 800 | typedef struct ParallelState ParallelState; |
| 801 | ParallelState *parallel_init(int base, int irq, CharDriverState *chr); |
| 802 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 803 | /* i8259.c */ |
| 804 | |
bellard | 3de388f | 2005-07-02 18:11:44 +0000 | [diff] [blame] | 805 | typedef struct PicState2 PicState2; |
| 806 | extern PicState2 *isa_pic; |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 807 | void pic_set_irq(int irq, int level); |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 808 | void pic_set_irq_new(void *opaque, int irq, int level); |
bellard | 3de388f | 2005-07-02 18:11:44 +0000 | [diff] [blame] | 809 | PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque); |
bellard | d592d30 | 2005-07-23 19:05:37 +0000 | [diff] [blame] | 810 | void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func, |
| 811 | void *alt_irq_opaque); |
bellard | 3de388f | 2005-07-02 18:11:44 +0000 | [diff] [blame] | 812 | int pic_read_irq(PicState2 *s); |
| 813 | void pic_update_irq(PicState2 *s); |
| 814 | uint32_t pic_intack_read(PicState2 *s); |
bellard | c20709a | 2004-04-21 23:27:19 +0000 | [diff] [blame] | 815 | void pic_info(void); |
bellard | 4a0fb71e | 2004-05-21 11:39:07 +0000 | [diff] [blame] | 816 | void irq_info(void); |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 817 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 818 | /* APIC */ |
bellard | d592d30 | 2005-07-23 19:05:37 +0000 | [diff] [blame] | 819 | typedef struct IOAPICState IOAPICState; |
| 820 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 821 | int apic_init(CPUState *env); |
| 822 | int apic_get_interrupt(CPUState *env); |
bellard | d592d30 | 2005-07-23 19:05:37 +0000 | [diff] [blame] | 823 | IOAPICState *ioapic_init(void); |
| 824 | void ioapic_set_irq(void *opaque, int vector, int level); |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 825 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 826 | /* i8254.c */ |
| 827 | |
| 828 | #define PIT_FREQ 1193182 |
| 829 | |
bellard | ec844b9 | 2004-05-03 23:18:25 +0000 | [diff] [blame] | 830 | typedef struct PITState PITState; |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 831 | |
bellard | ec844b9 | 2004-05-03 23:18:25 +0000 | [diff] [blame] | 832 | PITState *pit_init(int base, int irq); |
| 833 | void pit_set_gate(PITState *pit, int channel, int val); |
| 834 | int pit_get_gate(PITState *pit, int channel); |
bellard | fd06c37 | 2006-04-24 21:58:30 +0000 | [diff] [blame] | 835 | int pit_get_initial_count(PITState *pit, int channel); |
| 836 | int pit_get_mode(PITState *pit, int channel); |
bellard | ec844b9 | 2004-05-03 23:18:25 +0000 | [diff] [blame] | 837 | int pit_get_out(PITState *pit, int channel, int64_t current_time); |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 838 | |
bellard | fd06c37 | 2006-04-24 21:58:30 +0000 | [diff] [blame] | 839 | /* pcspk.c */ |
| 840 | void pcspk_init(PITState *); |
| 841 | int pcspk_audio_init(AudioState *); |
| 842 | |
bellard | 6515b20 | 2006-05-03 22:02:44 +0000 | [diff] [blame] | 843 | /* acpi.c */ |
| 844 | extern int acpi_enabled; |
| 845 | void piix4_pm_init(PCIBus *bus); |
| 846 | void acpi_bios_init(void); |
| 847 | |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 848 | /* pc.c */ |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 849 | extern QEMUMachine pc_machine; |
bellard | 3dbbdc2 | 2005-11-06 18:20:37 +0000 | [diff] [blame] | 850 | extern QEMUMachine isapc_machine; |
bellard | 80cabfa | 2004-03-14 12:20:30 +0000 | [diff] [blame] | 851 | |
bellard | 6a00d60 | 2005-11-21 23:25:50 +0000 | [diff] [blame] | 852 | void ioport_set_a20(int enable); |
| 853 | int ioport_get_a20(void); |
| 854 | |
bellard | 26aa7d7 | 2004-04-28 22:26:05 +0000 | [diff] [blame] | 855 | /* ppc.c */ |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 856 | extern QEMUMachine prep_machine; |
| 857 | extern QEMUMachine core99_machine; |
| 858 | extern QEMUMachine heathrow_machine; |
| 859 | |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 860 | /* mips_r4k.c */ |
| 861 | extern QEMUMachine mips_machine; |
| 862 | |
bellard | 27c7ca7 | 2006-04-27 21:32:09 +0000 | [diff] [blame] | 863 | /* shix.c */ |
| 864 | extern QEMUMachine shix_machine; |
| 865 | |
bellard | 8cc43fe | 2004-05-26 23:29:15 +0000 | [diff] [blame] | 866 | #ifdef TARGET_PPC |
| 867 | ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq); |
| 868 | #endif |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 869 | void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val); |
bellard | 77d4bc3 | 2004-05-26 22:13:53 +0000 | [diff] [blame] | 870 | |
| 871 | extern CPUWriteMemoryFunc *PPC_io_write[]; |
| 872 | extern CPUReadMemoryFunc *PPC_io_read[]; |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 873 | void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val); |
bellard | 26aa7d7 | 2004-04-28 22:26:05 +0000 | [diff] [blame] | 874 | |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 875 | /* sun4m.c */ |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 876 | extern QEMUMachine sun4m_machine; |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 877 | uint32_t iommu_translate(uint32_t addr); |
bellard | ba3c64f | 2005-12-05 20:31:52 +0000 | [diff] [blame] | 878 | void pic_set_irq_cpu(int irq, int level, unsigned int cpu); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 879 | |
| 880 | /* iommu.c */ |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 881 | void *iommu_init(uint32_t addr); |
| 882 | uint32_t iommu_translate_local(void *opaque, uint32_t addr); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 883 | |
| 884 | /* lance.c */ |
bellard | 7c9d8e0 | 2005-11-15 22:16:05 +0000 | [diff] [blame] | 885 | void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 886 | |
| 887 | /* tcx.c */ |
pbrook | 9521989 | 2006-04-09 01:06:34 +0000 | [diff] [blame] | 888 | void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base, |
bellard | 6f7e9ae | 2005-03-13 09:43:36 +0000 | [diff] [blame] | 889 | unsigned long vram_offset, int vram_size, int width, int height); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 890 | |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 891 | /* slavio_intctl.c */ |
| 892 | void *slavio_intctl_init(); |
bellard | ba3c64f | 2005-12-05 20:31:52 +0000 | [diff] [blame] | 893 | void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env); |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 894 | void slavio_pic_info(void *opaque); |
| 895 | void slavio_irq_info(void *opaque); |
| 896 | void slavio_pic_set_irq(void *opaque, int irq, int level); |
bellard | ba3c64f | 2005-12-05 20:31:52 +0000 | [diff] [blame] | 897 | void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 898 | |
bellard | 5fe141f | 2006-04-23 17:12:42 +0000 | [diff] [blame] | 899 | /* loader.c */ |
| 900 | int get_image_size(const char *filename); |
| 901 | int load_image(const char *filename, uint8_t *addr); |
bellard | 9ee3c02 | 2006-04-26 22:05:26 +0000 | [diff] [blame] | 902 | int load_elf(const char *filename, int64_t virt_to_phys_addend, uint64_t *pentry); |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 903 | int load_aout(const char *filename, uint8_t *addr); |
bellard | 8d5f07f | 2004-10-04 21:23:09 +0000 | [diff] [blame] | 904 | |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 905 | /* slavio_timer.c */ |
bellard | ba3c64f | 2005-12-05 20:31:52 +0000 | [diff] [blame] | 906 | void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu); |
bellard | e80cfcf | 2004-12-19 23:18:01 +0000 | [diff] [blame] | 907 | |
| 908 | /* slavio_serial.c */ |
| 909 | SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2); |
| 910 | void slavio_serial_ms_kbd_init(int base, int irq); |
bellard | e95c8d5 | 2004-09-30 22:22:08 +0000 | [diff] [blame] | 911 | |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 912 | /* slavio_misc.c */ |
| 913 | void *slavio_misc_init(uint32_t base, int irq); |
| 914 | void slavio_set_power_fail(void *opaque, int power_failing); |
| 915 | |
bellard | 6f7e9ae | 2005-03-13 09:43:36 +0000 | [diff] [blame] | 916 | /* esp.c */ |
| 917 | void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr); |
| 918 | |
bellard | 3475187 | 2005-07-02 14:31:34 +0000 | [diff] [blame] | 919 | /* sun4u.c */ |
| 920 | extern QEMUMachine sun4u_machine; |
| 921 | |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 922 | /* NVRAM helpers */ |
| 923 | #include "hw/m48t59.h" |
| 924 | |
| 925 | void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value); |
| 926 | uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr); |
| 927 | void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value); |
| 928 | uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr); |
| 929 | void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value); |
| 930 | uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr); |
| 931 | void NVRAM_set_string (m48t59_t *nvram, uint32_t addr, |
| 932 | const unsigned char *str, uint32_t max); |
| 933 | int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max); |
| 934 | void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr, |
| 935 | uint32_t start, uint32_t count); |
| 936 | int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, |
| 937 | const unsigned char *arch, |
| 938 | uint32_t RAM_size, int boot_device, |
| 939 | uint32_t kernel_image, uint32_t kernel_size, |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 940 | const char *cmdline, |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 941 | uint32_t initrd_image, uint32_t initrd_size, |
bellard | 28b9b5a | 2004-06-21 16:46:35 +0000 | [diff] [blame] | 942 | uint32_t NVRAM_image, |
| 943 | int width, int height, int depth); |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 944 | |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 945 | /* adb.c */ |
| 946 | |
| 947 | #define MAX_ADB_DEVICES 16 |
| 948 | |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 949 | #define ADB_MAX_OUT_LEN 16 |
| 950 | |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 951 | typedef struct ADBDevice ADBDevice; |
| 952 | |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 953 | /* buf = NULL means polling */ |
| 954 | typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out, |
| 955 | const uint8_t *buf, int len); |
bellard | 12c28fed | 2004-07-12 20:26:20 +0000 | [diff] [blame] | 956 | typedef int ADBDeviceReset(ADBDevice *d); |
| 957 | |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 958 | struct ADBDevice { |
| 959 | struct ADBBusState *bus; |
| 960 | int devaddr; |
| 961 | int handler; |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 962 | ADBDeviceRequest *devreq; |
bellard | 12c28fed | 2004-07-12 20:26:20 +0000 | [diff] [blame] | 963 | ADBDeviceReset *devreset; |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 964 | void *opaque; |
| 965 | }; |
| 966 | |
| 967 | typedef struct ADBBusState { |
| 968 | ADBDevice devices[MAX_ADB_DEVICES]; |
| 969 | int nb_devices; |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 970 | int poll_index; |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 971 | } ADBBusState; |
| 972 | |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 973 | int adb_request(ADBBusState *s, uint8_t *buf_out, |
| 974 | const uint8_t *buf, int len); |
| 975 | int adb_poll(ADBBusState *s, uint8_t *buf_out); |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 976 | |
| 977 | ADBDevice *adb_register_device(ADBBusState *s, int devaddr, |
bellard | e2733d2 | 2004-06-21 22:46:10 +0000 | [diff] [blame] | 978 | ADBDeviceRequest *devreq, |
bellard | 12c28fed | 2004-07-12 20:26:20 +0000 | [diff] [blame] | 979 | ADBDeviceReset *devreset, |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 980 | void *opaque); |
| 981 | void adb_kbd_init(ADBBusState *bus); |
| 982 | void adb_mouse_init(ADBBusState *bus); |
| 983 | |
| 984 | /* cuda.c */ |
| 985 | |
| 986 | extern ADBBusState adb_bus; |
bellard | 54fa5af | 2005-06-05 14:50:39 +0000 | [diff] [blame] | 987 | int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq); |
bellard | 63066f4 | 2004-06-03 18:45:02 +0000 | [diff] [blame] | 988 | |
bellard | bb36d47 | 2005-11-05 14:22:28 +0000 | [diff] [blame] | 989 | #include "hw/usb.h" |
| 990 | |
bellard | a594cfb | 2005-11-06 16:13:29 +0000 | [diff] [blame] | 991 | /* usb ports of the VM */ |
| 992 | |
| 993 | #define MAX_VM_USB_PORTS 8 |
| 994 | |
| 995 | extern USBPort *vm_usb_ports[MAX_VM_USB_PORTS]; |
| 996 | extern USBDevice *vm_usb_hub; |
| 997 | |
| 998 | void do_usb_add(const char *devname); |
| 999 | void do_usb_del(const char *devname); |
| 1000 | void usb_info(void); |
| 1001 | |
bellard | b5ff1b3 | 2005-11-26 10:38:39 +0000 | [diff] [blame] | 1002 | /* integratorcp.c */ |
pbrook | 40f137e | 2006-02-20 00:33:36 +0000 | [diff] [blame] | 1003 | extern QEMUMachine integratorcp926_machine; |
| 1004 | extern QEMUMachine integratorcp1026_machine; |
bellard | b5ff1b3 | 2005-11-26 10:38:39 +0000 | [diff] [blame] | 1005 | |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 1006 | /* versatilepb.c */ |
| 1007 | extern QEMUMachine versatilepb_machine; |
pbrook | 1640695 | 2006-04-27 23:15:07 +0000 | [diff] [blame] | 1008 | extern QEMUMachine versatileab_machine; |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 1009 | |
bellard | daa5796 | 2005-11-26 10:14:03 +0000 | [diff] [blame] | 1010 | /* ps2.c */ |
| 1011 | void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); |
| 1012 | void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); |
| 1013 | void ps2_write_mouse(void *, int val); |
| 1014 | void ps2_write_keyboard(void *, int val); |
| 1015 | uint32_t ps2_read_data(void *); |
| 1016 | void ps2_queue(void *, int b); |
pbrook | f94f5d7 | 2006-02-08 04:42:17 +0000 | [diff] [blame] | 1017 | void ps2_keyboard_set_translation(void *opaque, int mode); |
bellard | daa5796 | 2005-11-26 10:14:03 +0000 | [diff] [blame] | 1018 | |
bellard | 80337b6 | 2005-12-04 18:54:21 +0000 | [diff] [blame] | 1019 | /* smc91c111.c */ |
| 1020 | void smc91c111_init(NICInfo *, uint32_t, void *, int); |
| 1021 | |
pbrook | bdd5003 | 2006-02-06 04:11:15 +0000 | [diff] [blame] | 1022 | /* pl110.c */ |
pbrook | 9521989 | 2006-04-09 01:06:34 +0000 | [diff] [blame] | 1023 | void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int); |
pbrook | bdd5003 | 2006-02-06 04:11:15 +0000 | [diff] [blame] | 1024 | |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 1025 | /* pl011.c */ |
| 1026 | void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr); |
| 1027 | |
| 1028 | /* pl050.c */ |
| 1029 | void pl050_init(uint32_t base, void *pic, int irq, int is_mouse); |
| 1030 | |
| 1031 | /* pl080.c */ |
| 1032 | void *pl080_init(uint32_t base, void *pic, int irq); |
| 1033 | |
| 1034 | /* pl190.c */ |
| 1035 | void *pl190_init(uint32_t base, void *parent, int irq, int fiq); |
| 1036 | |
| 1037 | /* arm-timer.c */ |
| 1038 | void sp804_init(uint32_t base, void *pic, int irq); |
| 1039 | void icp_pit_init(uint32_t base, void *pic, int irq); |
| 1040 | |
pbrook | 1640695 | 2006-04-27 23:15:07 +0000 | [diff] [blame] | 1041 | /* arm_boot.c */ |
| 1042 | |
| 1043 | void arm_load_kernel(int ram_size, const char *kernel_filename, |
| 1044 | const char *kernel_cmdline, const char *initrd_filename, |
| 1045 | int board_id); |
| 1046 | |
bellard | 27c7ca7 | 2006-04-27 21:32:09 +0000 | [diff] [blame] | 1047 | /* sh7750.c */ |
| 1048 | struct SH7750State; |
| 1049 | |
pbrook | 008a881 | 2006-04-27 22:32:36 +0000 | [diff] [blame] | 1050 | struct SH7750State *sh7750_init(CPUState * cpu); |
bellard | 27c7ca7 | 2006-04-27 21:32:09 +0000 | [diff] [blame] | 1051 | |
| 1052 | typedef struct { |
| 1053 | /* The callback will be triggered if any of the designated lines change */ |
| 1054 | uint16_t portamask_trigger; |
| 1055 | uint16_t portbmask_trigger; |
| 1056 | /* Return 0 if no action was taken */ |
| 1057 | int (*port_change_cb) (uint16_t porta, uint16_t portb, |
| 1058 | uint16_t * periph_pdtra, |
| 1059 | uint16_t * periph_portdira, |
| 1060 | uint16_t * periph_pdtrb, |
| 1061 | uint16_t * periph_portdirb); |
| 1062 | } sh7750_io_device; |
| 1063 | |
| 1064 | int sh7750_register_io_device(struct SH7750State *s, |
| 1065 | sh7750_io_device * device); |
| 1066 | /* tc58128.c */ |
| 1067 | int tc58128_init(struct SH7750State *s, char *zone1, char *zone2); |
| 1068 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 1069 | #endif /* defined(QEMU_TOOL) */ |
| 1070 | |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 1071 | /* monitor.c */ |
bellard | 82c643f | 2004-07-14 17:28:13 +0000 | [diff] [blame] | 1072 | void monitor_init(CharDriverState *hd, int show_banner); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 1073 | void term_puts(const char *str); |
| 1074 | void term_vprintf(const char *fmt, va_list ap); |
bellard | 40c3bac | 2004-04-04 12:56:28 +0000 | [diff] [blame] | 1075 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 1076 | void term_flush(void); |
| 1077 | void term_print_help(void); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 1078 | void monitor_readline(const char *prompt, int is_password, |
| 1079 | char *buf, int buf_size); |
| 1080 | |
| 1081 | /* readline.c */ |
| 1082 | typedef void ReadLineFunc(void *opaque, const char *str); |
| 1083 | |
| 1084 | extern int completion_index; |
| 1085 | void add_completion(const char *str); |
| 1086 | void readline_handle_byte(int ch); |
| 1087 | void readline_find_completion(const char *cmdline); |
| 1088 | const char *readline_get_history(unsigned int index); |
| 1089 | void readline_start(const char *prompt, int is_password, |
| 1090 | ReadLineFunc *readline_func, void *opaque); |
bellard | c4b1fcc | 2004-03-14 21:44:30 +0000 | [diff] [blame] | 1091 | |
bellard | 5e6ad6f | 2005-08-21 09:30:40 +0000 | [diff] [blame] | 1092 | void kqemu_record_dump(void); |
| 1093 | |
bellard | fc01f7e | 2003-06-30 10:03:06 +0000 | [diff] [blame] | 1094 | #endif /* VL_H */ |