Revision ea2384d3 vl.h

b/vl.h
48 48
#define lseek64 _lseeki64
49 49
#endif
50 50

  
51
#ifdef QEMU_TOOL
52

  
53
/* we use QEMU_TOOL in the command line tools which do not depend on
54
   the target CPU type */
55
#include "config-host.h"
56
#include <setjmp.h>
57
#include "osdep.h"
58
#include "bswap.h"
59

  
60
#else
61

  
51 62
#include "cpu.h"
52 63

  
64
#endif /* !defined(QEMU_TOOL) */
65

  
53 66
#ifndef glue
54 67
#define xglue(x, y) x ## y
55 68
#define glue(x, y) xglue(x, y)
......
57 70
#define tostring(s)	#s
58 71
#endif
59 72

  
60
#if defined(WORDS_BIGENDIAN)
61
static inline uint32_t be32_to_cpu(uint32_t v)
62
{
63
    return v;
64
}
65

  
66
static inline uint16_t be16_to_cpu(uint16_t v)
67
{
68
    return v;
69
}
70

  
71
static inline uint32_t cpu_to_be32(uint32_t v)
72
{
73
    return v;
74
}
75

  
76
static inline uint16_t cpu_to_be16(uint16_t v)
77
{
78
    return v;
79
}
80

  
81
static inline uint32_t le32_to_cpu(uint32_t v)
82
{
83
    return bswap32(v);
84
}
85

  
86
static inline uint16_t le16_to_cpu(uint16_t v)
87
{
88
    return bswap16(v);
89
}
90

  
91
static inline uint32_t cpu_to_le32(uint32_t v)
92
{
93
    return bswap32(v);
94
}
95

  
96
static inline uint16_t cpu_to_le16(uint16_t v)
97
{
98
    return bswap16(v);
99
}
100

  
101
#else
102

  
103
static inline uint32_t be32_to_cpu(uint32_t v)
104
{
105
    return bswap32(v);
106
}
107

  
108
static inline uint16_t be16_to_cpu(uint16_t v)
109
{
110
    return bswap16(v);
111
}
112

  
113
static inline uint32_t cpu_to_be32(uint32_t v)
114
{
115
    return bswap32(v);
116
}
117

  
118
static inline uint16_t cpu_to_be16(uint16_t v)
119
{
120
    return bswap16(v);
121
}
122

  
123
static inline uint32_t le32_to_cpu(uint32_t v)
124
{
125
    return v;
126
}
127

  
128
static inline uint16_t le16_to_cpu(uint16_t v)
129
{
130
    return v;
131
}
132

  
133
static inline uint32_t cpu_to_le32(uint32_t v)
134
{
135
    return v;
136
}
137

  
138
static inline uint16_t cpu_to_le16(uint16_t v)
139
{
140
    return v;
141
}
142
#endif
143

  
144
static inline void cpu_to_le16w(uint16_t *p, uint16_t v)
145
{
146
    *p = cpu_to_le16(v);
147
}
148

  
149
static inline void cpu_to_le32w(uint32_t *p, uint32_t v)
150
{
151
    *p = cpu_to_le32(v);
152
}
153

  
154
static inline uint16_t le16_to_cpup(const uint16_t *p)
155
{
156
    return le16_to_cpu(*p);
157
}
158

  
159
static inline uint32_t le32_to_cpup(const uint32_t *p)
160
{
161
    return le32_to_cpu(*p);
162
}
163

  
164
/* unaligned versions (optimized for frequent unaligned accesses)*/
165

  
166
#if defined(__i386__) || defined(__powerpc__)
167

  
168
#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
169
#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
170
#define le16_to_cpupu(p) le16_to_cpup(p)
171
#define le32_to_cpupu(p) le32_to_cpup(p)
172

  
173
#else
174

  
175
static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
176
{
177
    uint8_t *p1 = (uint8_t *)p;
178

  
179
    p1[0] = v;
180
    p1[1] = v >> 8;
181
}
182

  
183
static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
184
{
185
    uint8_t *p1 = (uint8_t *)p;
186

  
187
    p1[0] = v;
188
    p1[1] = v >> 8;
189
    p1[2] = v >> 16;
190
    p1[3] = v >> 24;
191
}
192

  
193
static inline uint16_t le16_to_cpupu(const uint16_t *p)
194
{
195
    const uint8_t *p1 = (const uint8_t *)p;
196
    return p1[0] | (p1[1] << 8);
197
}
198

  
199
static inline uint32_t le32_to_cpupu(const uint32_t *p)
200
{
201
    const uint8_t *p1 = (const uint8_t *)p;
202
    return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
203
}
204

  
205
#endif
206

  
207 73
/* vl.c */
208 74
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
209 75

  
......
233 99
void qemu_system_reset_request(void);
234 100
void qemu_system_shutdown_request(void);
235 101

  
102
void main_loop_wait(int timeout);
103

  
236 104
extern int audio_enabled;
237 105
extern int ram_size;
238 106
extern int bios_size;
......
301 169
/* character device */
302 170

  
303 171
#define CHR_EVENT_BREAK 0 /* serial break char */
172
#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
304 173

  
305 174
typedef void IOEventHandler(void *opaque, int event);
306 175

  
......
310 179
                                 IOCanRWHandler *fd_can_read, 
311 180
                                 IOReadHandler *fd_read, void *opaque);
312 181
    IOEventHandler *chr_event;
182
    IOEventHandler *chr_send_event;
313 183
    void *opaque;
314 184
} CharDriverState;
315 185

  
316 186
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
317 187
int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
188
void qemu_chr_send_event(CharDriverState *s, int event);
318 189
void qemu_chr_add_read_handler(CharDriverState *s, 
319 190
                               IOCanRWHandler *fd_can_read, 
320 191
                               IOReadHandler *fd_read, void *opaque);
......
464 335

  
465 336
/* block.c */
466 337
typedef struct BlockDriverState BlockDriverState;
467

  
338
typedef struct BlockDriver BlockDriver;
339

  
340
extern BlockDriver bdrv_raw;
341
extern BlockDriver bdrv_cow;
342
extern BlockDriver bdrv_qcow;
343
extern BlockDriver bdrv_vmdk;
344

  
345
void bdrv_init(void);
346
BlockDriver *bdrv_find_format(const char *format_name);
347
int bdrv_create(BlockDriver *drv, 
348
                const char *filename, int64_t size_in_sectors,
349
                const char *backing_file, int flags);
468 350
BlockDriverState *bdrv_new(const char *device_name);
469 351
void bdrv_delete(BlockDriverState *bs);
470 352
int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
353
int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
354
               BlockDriver *drv);
471 355
void bdrv_close(BlockDriverState *bs);
472 356
int bdrv_read(BlockDriverState *bs, int64_t sector_num, 
473 357
              uint8_t *buf, int nb_sectors);
......
494 378
void bdrv_set_locked(BlockDriverState *bs, int locked);
495 379
void bdrv_set_change_cb(BlockDriverState *bs, 
496 380
                        void (*change_cb)(void *opaque), void *opaque);
497

  
381
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
498 382
void bdrv_info(void);
499 383
BlockDriverState *bdrv_find(const char *name);
500 384
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
385
int bdrv_is_encrypted(BlockDriverState *bs);
386
int bdrv_set_key(BlockDriverState *bs, const char *key);
387
void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 
388
                         void *opaque);
389
const char *bdrv_get_device_name(BlockDriverState *bs);
501 390

  
391
int qcow_get_cluster_size(BlockDriverState *bs);
392
int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
393
                          const uint8_t *buf);
394

  
395
#ifndef QEMU_TOOL
502 396
/* ISA bus */
503 397

  
504 398
extern target_phys_addr_t isa_mem_base;
......
823 717
extern ADBBusState adb_bus;
824 718
int cuda_init(openpic_t *openpic, int irq);
825 719

  
720
#endif /* defined(QEMU_TOOL) */
721

  
826 722
/* monitor.c */
827 723
void monitor_init(CharDriverState *hd, int show_banner);
724
void term_puts(const char *str);
725
void term_vprintf(const char *fmt, va_list ap);
828 726
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
829 727
void term_flush(void);
830 728
void term_print_help(void);
729
void monitor_readline(const char *prompt, int is_password,
730
                      char *buf, int buf_size);
731

  
732
/* readline.c */
733
typedef void ReadLineFunc(void *opaque, const char *str);
734

  
735
extern int completion_index;
736
void add_completion(const char *str);
737
void readline_handle_byte(int ch);
738
void readline_find_completion(const char *cmdline);
739
const char *readline_get_history(unsigned int index);
740
void readline_start(const char *prompt, int is_password,
741
                    ReadLineFunc *readline_func, void *opaque);
831 742

  
832 743
/* gdbstub.c */
833 744

  

Also available in: Unified diff