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