]> git.proxmox.com Git - mirror_qemu.git/blame - vl.h
device independent VGA screen dump
[mirror_qemu.git] / vl.h
CommitLineData
fc01f7e7
FB
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
16f62432
FB
27#include "cpu.h"
28
33e3963e 29/* vl.c */
313aa567 30extern int reset_requested;
27503323 31extern int64_t ticks_per_sec;
80cabfad 32extern int pit_min_timer_count;
313aa567 33
c4b1fcc0
FB
34typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
35typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
313aa567 36
c4b1fcc0
FB
37int register_ioport_read(int start, int length, int size,
38 IOPortReadFunc *func, void *opaque);
39int register_ioport_write(int start, int length, int size,
40 IOPortWriteFunc *func, void *opaque);
27503323 41int64_t cpu_get_ticks(void);
80cabfad 42uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
313aa567 43
80cabfad
FB
44void hw_error(const char *fmt, ...);
45
46int load_image(const char *filename, uint8_t *addr);
47extern const char *bios_dir;
48
49void pstrcpy(char *buf, int buf_size, const char *str);
50char *pstrcat(char *buf, int buf_size, const char *s);
33e3963e 51
c4b1fcc0
FB
52int serial_open_device(void);
53
54/* network redirectors support */
55
56#define MAX_NICS 8
57
58typedef struct NetDriverState {
59 int fd;
60 uint8_t macaddr[6];
61 char ifname[16];
62} NetDriverState;
63
64extern int nb_nics;
65extern NetDriverState nd_table[MAX_NICS];
66
67void net_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
68
69/* async I/O support */
70
71typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
72typedef int IOCanRWHandler(void *opaque);
73
74int add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read,
75 IOReadHandler *fd_read, void *opaque);
76
fc01f7e7
FB
77/* block.c */
78typedef struct BlockDriverState BlockDriverState;
79
c4b1fcc0
FB
80BlockDriverState *bdrv_new(const char *device_name);
81void bdrv_delete(BlockDriverState *bs);
82int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
fc01f7e7
FB
83void bdrv_close(BlockDriverState *bs);
84int bdrv_read(BlockDriverState *bs, int64_t sector_num,
85 uint8_t *buf, int nb_sectors);
86int bdrv_write(BlockDriverState *bs, int64_t sector_num,
87 const uint8_t *buf, int nb_sectors);
88void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
33e3963e 89int bdrv_commit(BlockDriverState *bs);
77fef8c1 90void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
33e3963e 91
c4b1fcc0
FB
92#define BDRV_TYPE_HD 0
93#define BDRV_TYPE_CDROM 1
94#define BDRV_TYPE_FLOPPY 2
95
96void bdrv_set_geometry_hint(BlockDriverState *bs,
97 int cyls, int heads, int secs);
98void bdrv_set_type_hint(BlockDriverState *bs, int type);
99void bdrv_get_geometry_hint(BlockDriverState *bs,
100 int *pcyls, int *pheads, int *psecs);
101int bdrv_get_type_hint(BlockDriverState *bs);
102int bdrv_is_removable(BlockDriverState *bs);
103int bdrv_is_read_only(BlockDriverState *bs);
104int bdrv_is_inserted(BlockDriverState *bs);
105int bdrv_is_locked(BlockDriverState *bs);
106void bdrv_set_locked(BlockDriverState *bs, int locked);
107void bdrv_set_change_cb(BlockDriverState *bs,
108 void (*change_cb)(void *opaque), void *opaque);
109
110void bdrv_info(void);
111BlockDriverState *bdrv_find(const char *name);
112
313aa567
FB
113/* vga.c */
114
4fa0f5d2 115#define VGA_RAM_SIZE (4096 * 1024)
313aa567
FB
116
117typedef struct DisplayState {
118 uint8_t *data;
119 int linesize;
120 int depth;
121 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
122 void (*dpy_resize)(struct DisplayState *s, int w, int h);
123 void (*dpy_refresh)(struct DisplayState *s);
124} DisplayState;
125
126static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
127{
128 s->dpy_update(s, x, y, w, h);
129}
130
131static inline void dpy_resize(DisplayState *s, int w, int h)
132{
133 s->dpy_resize(s, w, h);
134}
135
7138fcfb
FB
136int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base,
137 unsigned long vga_ram_offset, int vga_ram_size);
313aa567 138void vga_update_display(void);
59a983b9 139void vga_screen_dump(const char *filename);
313aa567
FB
140
141/* sdl.c */
142void sdl_display_init(DisplayState *ds);
143
5391d806
FB
144/* ide.c */
145#define MAX_DISKS 4
146
147extern BlockDriverState *bs_table[MAX_DISKS];
148
c4b1fcc0
FB
149void ide_init(int iobase, int iobase2, int irq,
150 BlockDriverState *hd0, BlockDriverState *hd1);
5391d806 151
27503323
FB
152/* oss.c */
153typedef enum {
154 AUD_FMT_U8,
155 AUD_FMT_S8,
156 AUD_FMT_U16,
157 AUD_FMT_S16
158} audfmt_e;
159
160void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt);
161void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt);
162int AUD_write (void *in_buf, int size);
163void AUD_run (void);
164void AUD_adjust_estimate (int _leftover);
165int AUD_get_free (void);
166int AUD_get_live (void);
167int AUD_get_buffer_size (void);
168void AUD_init (void);
169
170/* dma.c */
16f62432 171typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size);
27503323
FB
172int DMA_get_channel_mode (int nchan);
173void DMA_hold_DREQ (int nchan);
174void DMA_release_DREQ (int nchan);
16f62432 175void DMA_schedule(int nchan);
27503323
FB
176void DMA_run (void);
177void DMA_init (void);
178void DMA_register_channel (int nchan,
16f62432 179 DMA_transfer_handler transfer_handler, void *opaque);
27503323
FB
180
181/* sb16.c */
182void SB16_run (void);
183void SB16_init (void);
184
7138fcfb
FB
185/* fdc.c */
186#define MAX_FD 2
187extern BlockDriverState *fd_table[MAX_FD];
188
7138fcfb 189void fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, uint32_t base,
c4b1fcc0
FB
190 BlockDriverState **fds);
191int fdctrl_get_drive_type(int drive_num);
7138fcfb 192
80cabfad
FB
193/* ne2000.c */
194
c4b1fcc0 195void ne2000_init(int base, int irq, NetDriverState *nd);
80cabfad
FB
196
197/* pckbd.c */
198
199void kbd_put_keycode(int keycode);
200
201#define MOUSE_EVENT_LBUTTON 0x01
202#define MOUSE_EVENT_RBUTTON 0x02
203#define MOUSE_EVENT_MBUTTON 0x04
204void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
205
206void kbd_init(void);
207
208/* mc146818rtc.c */
209
210typedef struct RTCState {
211 uint8_t cmos_data[128];
212 uint8_t cmos_index;
213 int irq;
214} RTCState;
215
216extern RTCState rtc_state;
217
218void rtc_init(int base, int irq);
219void rtc_timer(void);
220
221/* serial.c */
222
c4b1fcc0
FB
223typedef struct SerialState SerialState;
224
225extern SerialState *serial_console;
226
227SerialState *serial_init(int base, int irq, int fd);
228int serial_can_receive(SerialState *s);
229void serial_receive_byte(SerialState *s, int ch);
230void serial_receive_break(SerialState *s);
80cabfad
FB
231
232/* i8259.c */
233
234void pic_set_irq(int irq, int level);
235void pic_init(void);
236
237/* i8254.c */
238
239#define PIT_FREQ 1193182
240
241typedef struct PITChannelState {
242 int count; /* can be 65536 */
243 uint16_t latched_count;
244 uint8_t rw_state;
245 uint8_t mode;
246 uint8_t bcd; /* not supported */
247 uint8_t gate; /* timer start */
248 int64_t count_load_time;
249 int64_t count_last_edge_check_time;
250} PITChannelState;
251
252extern PITChannelState pit_channels[3];
253
c4b1fcc0 254void pit_init(int base);
80cabfad
FB
255void pit_set_gate(PITChannelState *s, int val);
256int pit_get_out(PITChannelState *s);
257int pit_get_out_edges(PITChannelState *s);
258
259/* pc.c */
260void pc_init(int ram_size, int vga_ram_size, int boot_device,
261 DisplayState *ds, const char **fd_filename, int snapshot,
262 const char *kernel_filename, const char *kernel_cmdline,
263 const char *initrd_filename);
264
c4b1fcc0
FB
265/* monitor.c */
266void monitor_init(void);
267void term_printf(const char *fmt, ...);
268void term_flush(void);
269void term_print_help(void);
270
fc01f7e7 271#endif /* VL_H */