DMA API change
[qemu] / vl.h
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
33 typedef void (IOPortWriteFunc)(struct CPUState *env, uint32_t address, uint32_t data);
34 typedef uint32_t (IOPortReadFunc)(struct CPUState *env, uint32_t address);
35
36 int register_ioport_read(int start, int length, IOPortReadFunc *func, int size);
37 int register_ioport_write(int start, int length, IOPortWriteFunc *func, int size);
38 void pic_set_irq(int irq, int level);
39 int64_t cpu_get_ticks(void);
40
41 void kbd_put_keycode(int keycode);
42
43 #define MOUSE_EVENT_LBUTTON 0x01
44 #define MOUSE_EVENT_RBUTTON 0x02
45 #define MOUSE_EVENT_MBUTTON 0x04
46 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
47
48 /* block.c */
49 typedef struct BlockDriverState BlockDriverState;
50
51 BlockDriverState *bdrv_open(const char *filename, int snapshot);
52 void bdrv_close(BlockDriverState *bs);
53 int bdrv_read(BlockDriverState *bs, int64_t sector_num, 
54               uint8_t *buf, int nb_sectors);
55 int bdrv_write(BlockDriverState *bs, int64_t sector_num, 
56                const uint8_t *buf, int nb_sectors);
57 void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
58 int bdrv_commit(BlockDriverState *bs);
59 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
60
61 /* user mode linux compatible COW file */
62 #define COW_MAGIC 0x4f4f4f4d  /* MOOO */
63 #define COW_VERSION 2
64
65 struct cow_header_v2 {
66     uint32_t magic;
67     uint32_t version;
68     char backing_file[1024];
69     int32_t mtime;
70     uint64_t size;
71     uint32_t sectorsize;
72 };
73
74 /* vga.c */
75
76 #define VGA_RAM_SIZE (4096 * 1024)
77
78 typedef struct DisplayState {
79     uint8_t *data;
80     int linesize;
81     int depth;
82     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
83     void (*dpy_resize)(struct DisplayState *s, int w, int h);
84     void (*dpy_refresh)(struct DisplayState *s);
85 } DisplayState;
86
87 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
88 {
89     s->dpy_update(s, x, y, w, h);
90 }
91
92 static inline void dpy_resize(DisplayState *s, int w, int h)
93 {
94     s->dpy_resize(s, w, h);
95 }
96
97 int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base, 
98                    unsigned long vga_ram_offset, int vga_ram_size);
99 void vga_update_display(void);
100
101 /* sdl.c */
102 void sdl_display_init(DisplayState *ds);
103
104 /* ide.c */
105 #define MAX_DISKS 4
106
107 extern BlockDriverState *bs_table[MAX_DISKS];
108
109 void ide_init(void);
110 void ide_set_geometry(int n, int cyls, int heads, int secs);
111 void ide_set_cdrom(int n, int is_cdrom);
112
113 /* oss.c */
114 typedef enum {
115   AUD_FMT_U8,
116   AUD_FMT_S8,
117   AUD_FMT_U16,
118   AUD_FMT_S16
119 } audfmt_e;
120
121 void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt);
122 void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt);
123 int AUD_write (void *in_buf, int size);
124 void AUD_run (void);
125 void AUD_adjust_estimate (int _leftover);
126 int AUD_get_free (void);
127 int AUD_get_live (void);
128 int AUD_get_buffer_size (void);
129 void AUD_init (void);
130
131 /* dma.c */
132 typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size);
133 int DMA_get_channel_mode (int nchan);
134 void DMA_hold_DREQ (int nchan);
135 void DMA_release_DREQ (int nchan);
136 void DMA_schedule(int nchan);
137 void DMA_run (void);
138 void DMA_init (void);
139 void DMA_register_channel (int nchan,
140                            DMA_transfer_handler transfer_handler, void *opaque);
141
142 /* sb16.c */
143 void SB16_run (void);
144 void SB16_init (void);
145  
146 /* fdc.c */
147 #define MAX_FD 2
148 extern BlockDriverState *fd_table[MAX_FD];
149
150 void cmos_register_fd (uint8_t fd0, uint8_t fd1);
151 void fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, uint32_t base,
152                   char boot_device);
153 int fdctrl_disk_change (int idx, const unsigned char *filename, int ro);
154
155 #endif /* VL_H */