]> git.proxmox.com Git - qemu.git/blame - qemu-common.h
Add the -bt switch for setting up bluetooth stuff.
[qemu.git] / qemu-common.h
CommitLineData
faf07963
PB
1/* Common header file that is included by all of qemu. */
2#ifndef QEMU_COMMON_H
3#define QEMU_COMMON_H
4
5/* we put basic includes here to avoid repeating them in device drivers */
6#include <stdlib.h>
7#include <stdio.h>
8#include <stdarg.h>
9#include <string.h>
10#include <inttypes.h>
11#include <limits.h>
12#include <time.h>
13#include <ctype.h>
14#include <errno.h>
15#include <unistd.h>
16#include <fcntl.h>
17#include <sys/stat.h>
18
19#ifndef O_LARGEFILE
20#define O_LARGEFILE 0
21#endif
22#ifndef O_BINARY
23#define O_BINARY 0
24#endif
25
26#ifndef ENOMEDIUM
27#define ENOMEDIUM ENODEV
28#endif
29
30#ifdef _WIN32
4fddf62a 31#define WIN32_LEAN_AND_MEAN
faf07963
PB
32#include <windows.h>
33#define fsync _commit
34#define lseek _lseeki64
35#define ENOTSUP 4096
36extern int qemu_ftruncate64(int, int64_t);
37#define ftruncate qemu_ftruncate64
38
39
40static inline char *realpath(const char *path, char *resolved_path)
41{
42 _fullpath(resolved_path, path, _MAX_PATH);
43 return resolved_path;
44}
45
46#define PRId64 "I64d"
47#define PRIx64 "I64x"
48#define PRIu64 "I64u"
49#define PRIo64 "I64o"
50#endif
51
52/* FIXME: Remove NEED_CPU_H. */
53#ifndef NEED_CPU_H
54
55#include "config-host.h"
56#include <setjmp.h>
57#include "osdep.h"
58#include "bswap.h"
59
60#else
61
62#include "cpu.h"
63
64#endif /* !defined(NEED_CPU_H) */
65
66/* bottom halves */
67typedef struct QEMUBH QEMUBH;
68
69typedef void QEMUBHFunc(void *opaque);
70
71QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
72void qemu_bh_schedule(QEMUBH *bh);
80d3580b
AL
73/* Bottom halfs that are scheduled from a bottom half handler are instantly
74 * invoked. This can create an infinite loop if a bottom half handler
75 * schedules itself. qemu_bh_schedule_idle() avoids this infinite loop by
76 * ensuring that the bottom half isn't executed until the next main loop
77 * iteration.
78 */
1b435b10 79void qemu_bh_schedule_idle(QEMUBH *bh);
faf07963
PB
80void qemu_bh_cancel(QEMUBH *bh);
81void qemu_bh_delete(QEMUBH *bh);
82int qemu_bh_poll(void);
83
87ecb68b
PB
84uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
85
f6503059
AZ
86void qemu_get_timedate(struct tm *tm, int offset);
87int qemu_timedate_diff(struct tm *tm);
88
faf07963
PB
89/* cutils.c */
90void pstrcpy(char *buf, int buf_size, const char *str);
91char *pstrcat(char *buf, int buf_size, const char *s);
92int strstart(const char *str, const char *val, const char **ptr);
93int stristart(const char *str, const char *val, const char **ptr);
94time_t mktimegm(struct tm *tm);
95
ca10f867 96void *qemu_malloc(size_t size);
2137b4cc 97void *qemu_realloc(void *ptr, size_t size);
ca10f867
AJ
98void *qemu_mallocz(size_t size);
99void qemu_free(void *ptr);
100char *qemu_strdup(const char *str);
101
102void *get_mmap_addr(unsigned long size);
103
104
87ecb68b
PB
105/* Error handling. */
106
107void hw_error(const char *fmt, ...)
108 __attribute__ ((__format__ (__printf__, 1, 2)))
109 __attribute__ ((__noreturn__));
110
111/* IO callbacks. */
112typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
113typedef int IOCanRWHandler(void *opaque);
114typedef void IOHandler(void *opaque);
115
116struct ParallelIOArg {
117 void *buffer;
118 int count;
119};
120
121typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
122
123/* A load of opaque types so that device init declarations don't have to
124 pull in all the real definitions. */
125typedef struct NICInfo NICInfo;
1ae26a18 126typedef struct HCIInfo HCIInfo;
87ecb68b
PB
127typedef struct AudioState AudioState;
128typedef struct BlockDriverState BlockDriverState;
129typedef struct DisplayState DisplayState;
130typedef struct TextConsole TextConsole;
c60e08d9 131typedef TextConsole QEMUConsole;
87ecb68b
PB
132typedef struct CharDriverState CharDriverState;
133typedef struct VLANState VLANState;
134typedef struct QEMUFile QEMUFile;
135typedef struct i2c_bus i2c_bus;
136typedef struct i2c_slave i2c_slave;
137typedef struct SMBusDevice SMBusDevice;
138typedef struct QEMUTimer QEMUTimer;
139typedef struct PCIBus PCIBus;
140typedef struct PCIDevice PCIDevice;
141typedef struct SerialState SerialState;
142typedef struct IRQState *qemu_irq;
143struct pcmcia_card_s;
144
b3c7724c
PB
145/* CPU save/load. */
146void cpu_save(QEMUFile *f, void *opaque);
147int cpu_load(QEMUFile *f, void *opaque, int version_id);
148
9e472e10
AL
149/* Force QEMU to stop what it's doing and service IO */
150void qemu_service_io(void);
151
faf07963 152#endif