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