root / vl.h @ 80cabfad
History | View | Annotate | Download (6.2 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 |
#include "cpu.h" |
28 |
|
29 |
/* vl.c */
|
30 |
extern int reset_requested; |
31 |
extern int64_t ticks_per_sec;
|
32 |
extern int pit_min_timer_count; |
33 |
|
34 |
typedef void (IOPortWriteFunc)(struct CPUState *env, uint32_t address, uint32_t data); |
35 |
typedef uint32_t (IOPortReadFunc)(struct CPUState *env, uint32_t address); |
36 |
|
37 |
int register_ioport_read(int start, int length, IOPortReadFunc *func, int size); |
38 |
int register_ioport_write(int start, int length, IOPortWriteFunc *func, int size); |
39 |
int64_t cpu_get_ticks(void);
|
40 |
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
41 |
|
42 |
void net_send_packet(int net_fd, const uint8_t *buf, int size); |
43 |
|
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); |
51 |
|
52 |
/* block.c */
|
53 |
typedef struct BlockDriverState BlockDriverState; |
54 |
|
55 |
BlockDriverState *bdrv_open(const char *filename, int snapshot); |
56 |
void bdrv_close(BlockDriverState *bs);
|
57 |
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
58 |
uint8_t *buf, int nb_sectors);
|
59 |
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
60 |
const uint8_t *buf, int nb_sectors); |
61 |
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
|
62 |
int bdrv_commit(BlockDriverState *bs);
|
63 |
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
64 |
|
65 |
/* vga.c */
|
66 |
|
67 |
#define VGA_RAM_SIZE (4096 * 1024) |
68 |
|
69 |
typedef struct DisplayState { |
70 |
uint8_t *data; |
71 |
int linesize;
|
72 |
int depth;
|
73 |
void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
74 |
void (*dpy_resize)(struct DisplayState *s, int w, int h); |
75 |
void (*dpy_refresh)(struct DisplayState *s); |
76 |
} DisplayState; |
77 |
|
78 |
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) |
79 |
{ |
80 |
s->dpy_update(s, x, y, w, h); |
81 |
} |
82 |
|
83 |
static inline void dpy_resize(DisplayState *s, int w, int h) |
84 |
{ |
85 |
s->dpy_resize(s, w, h); |
86 |
} |
87 |
|
88 |
int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base,
|
89 |
unsigned long vga_ram_offset, int vga_ram_size); |
90 |
void vga_update_display(void); |
91 |
|
92 |
/* sdl.c */
|
93 |
void sdl_display_init(DisplayState *ds);
|
94 |
|
95 |
/* ide.c */
|
96 |
#define MAX_DISKS 4 |
97 |
|
98 |
extern BlockDriverState *bs_table[MAX_DISKS];
|
99 |
|
100 |
void ide_init(void); |
101 |
void ide_set_geometry(int n, int cyls, int heads, int secs); |
102 |
void ide_set_cdrom(int n, int is_cdrom); |
103 |
|
104 |
/* oss.c */
|
105 |
typedef enum { |
106 |
AUD_FMT_U8, |
107 |
AUD_FMT_S8, |
108 |
AUD_FMT_U16, |
109 |
AUD_FMT_S16 |
110 |
} audfmt_e; |
111 |
|
112 |
void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt); |
113 |
void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt); |
114 |
int AUD_write (void *in_buf, int size); |
115 |
void AUD_run (void); |
116 |
void AUD_adjust_estimate (int _leftover); |
117 |
int AUD_get_free (void); |
118 |
int AUD_get_live (void); |
119 |
int AUD_get_buffer_size (void); |
120 |
void AUD_init (void); |
121 |
|
122 |
/* dma.c */
|
123 |
typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size); |
124 |
int DMA_get_channel_mode (int nchan); |
125 |
void DMA_hold_DREQ (int nchan); |
126 |
void DMA_release_DREQ (int nchan); |
127 |
void DMA_schedule(int nchan); |
128 |
void DMA_run (void); |
129 |
void DMA_init (void); |
130 |
void DMA_register_channel (int nchan, |
131 |
DMA_transfer_handler transfer_handler, void *opaque);
|
132 |
|
133 |
/* sb16.c */
|
134 |
void SB16_run (void); |
135 |
void SB16_init (void); |
136 |
|
137 |
/* fdc.c */
|
138 |
#define MAX_FD 2 |
139 |
extern BlockDriverState *fd_table[MAX_FD];
|
140 |
|
141 |
void cmos_register_fd (uint8_t fd0, uint8_t fd1);
|
142 |
void fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, uint32_t base, |
143 |
char boot_device);
|
144 |
int fdctrl_disk_change (int idx, const unsigned char *filename, int ro); |
145 |
|
146 |
/* ne2000.c */
|
147 |
|
148 |
#define MAX_ETH_FRAME_SIZE 1514 |
149 |
|
150 |
void ne2000_init(int base, int irq); |
151 |
int ne2000_can_receive(void); |
152 |
void ne2000_receive(uint8_t *buf, int size); |
153 |
|
154 |
extern int net_fd; |
155 |
|
156 |
/* pckbd.c */
|
157 |
|
158 |
void kbd_put_keycode(int keycode); |
159 |
|
160 |
#define MOUSE_EVENT_LBUTTON 0x01 |
161 |
#define MOUSE_EVENT_RBUTTON 0x02 |
162 |
#define MOUSE_EVENT_MBUTTON 0x04 |
163 |
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
164 |
|
165 |
void kbd_init(void); |
166 |
|
167 |
/* mc146818rtc.c */
|
168 |
|
169 |
typedef struct RTCState { |
170 |
uint8_t cmos_data[128];
|
171 |
uint8_t cmos_index; |
172 |
int irq;
|
173 |
} RTCState; |
174 |
|
175 |
extern RTCState rtc_state;
|
176 |
|
177 |
void rtc_init(int base, int irq); |
178 |
void rtc_timer(void); |
179 |
|
180 |
/* serial.c */
|
181 |
|
182 |
void serial_init(int base, int irq); |
183 |
int serial_can_receive(void); |
184 |
void serial_receive_byte(int ch); |
185 |
void serial_receive_break(void); |
186 |
|
187 |
/* i8259.c */
|
188 |
|
189 |
void pic_set_irq(int irq, int level); |
190 |
void pic_init(void); |
191 |
|
192 |
/* i8254.c */
|
193 |
|
194 |
#define PIT_FREQ 1193182 |
195 |
|
196 |
typedef struct PITChannelState { |
197 |
int count; /* can be 65536 */ |
198 |
uint16_t latched_count; |
199 |
uint8_t rw_state; |
200 |
uint8_t mode; |
201 |
uint8_t bcd; /* not supported */
|
202 |
uint8_t gate; /* timer start */
|
203 |
int64_t count_load_time; |
204 |
int64_t count_last_edge_check_time; |
205 |
} PITChannelState; |
206 |
|
207 |
extern PITChannelState pit_channels[3]; |
208 |
|
209 |
void pit_init(void); |
210 |
void pit_set_gate(PITChannelState *s, int val); |
211 |
int pit_get_out(PITChannelState *s);
|
212 |
int pit_get_out_edges(PITChannelState *s);
|
213 |
|
214 |
/* pc.c */
|
215 |
void pc_init(int ram_size, int vga_ram_size, int boot_device, |
216 |
DisplayState *ds, const char **fd_filename, int snapshot, |
217 |
const char *kernel_filename, const char *kernel_cmdline, |
218 |
const char *initrd_filename); |
219 |
|
220 |
#endif /* VL_H */ |