]> git.proxmox.com Git - qemu.git/blame - qemu-common.h
r5531 made x509 certs not loadable (original patch from Henrik Holst).
[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
d247d25f 32#define WINVER 0x0501 /* needed for ipv6 bits */
faf07963
PB
33#include <windows.h>
34#define fsync _commit
35#define lseek _lseeki64
36#define ENOTSUP 4096
37extern int qemu_ftruncate64(int, int64_t);
38#define ftruncate qemu_ftruncate64
39
40
41static inline char *realpath(const char *path, char *resolved_path)
42{
43 _fullpath(resolved_path, path, _MAX_PATH);
44 return resolved_path;
45}
46
47#define PRId64 "I64d"
48#define PRIx64 "I64x"
49#define PRIu64 "I64u"
50#define PRIo64 "I64o"
51#endif
52
53/* FIXME: Remove NEED_CPU_H. */
54#ifndef NEED_CPU_H
55
56#include "config-host.h"
57#include <setjmp.h>
58#include "osdep.h"
59#include "bswap.h"
60
61#else
62
63#include "cpu.h"
64
65#endif /* !defined(NEED_CPU_H) */
66
67/* bottom halves */
68typedef struct QEMUBH QEMUBH;
69
70typedef void QEMUBHFunc(void *opaque);
71
72QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
73void qemu_bh_schedule(QEMUBH *bh);
80d3580b
AL
74/* Bottom halfs that are scheduled from a bottom half handler are instantly
75 * invoked. This can create an infinite loop if a bottom half handler
76 * schedules itself. qemu_bh_schedule_idle() avoids this infinite loop by
77 * ensuring that the bottom half isn't executed until the next main loop
78 * iteration.
79 */
1b435b10 80void qemu_bh_schedule_idle(QEMUBH *bh);
faf07963
PB
81void qemu_bh_cancel(QEMUBH *bh);
82void qemu_bh_delete(QEMUBH *bh);
83int qemu_bh_poll(void);
84
87ecb68b
PB
85uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
86
f6503059
AZ
87void qemu_get_timedate(struct tm *tm, int offset);
88int qemu_timedate_diff(struct tm *tm);
89
faf07963
PB
90/* cutils.c */
91void pstrcpy(char *buf, int buf_size, const char *str);
92char *pstrcat(char *buf, int buf_size, const char *s);
93int strstart(const char *str, const char *val, const char **ptr);
94int stristart(const char *str, const char *val, const char **ptr);
95time_t mktimegm(struct tm *tm);
96
ca10f867 97void *qemu_malloc(size_t size);
2137b4cc 98void *qemu_realloc(void *ptr, size_t size);
ca10f867
AJ
99void *qemu_mallocz(size_t size);
100void qemu_free(void *ptr);
101char *qemu_strdup(const char *str);
ac4b0d0c 102char *qemu_strndup(const char *str, size_t size);
ca10f867
AJ
103
104void *get_mmap_addr(unsigned long size);
105
106
87ecb68b
PB
107/* Error handling. */
108
109void hw_error(const char *fmt, ...)
110 __attribute__ ((__format__ (__printf__, 1, 2)))
111 __attribute__ ((__noreturn__));
112
113/* IO callbacks. */
114typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
115typedef int IOCanRWHandler(void *opaque);
116typedef void IOHandler(void *opaque);
117
118struct ParallelIOArg {
119 void *buffer;
120 int count;
121};
122
123typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
124
125/* A load of opaque types so that device init declarations don't have to
126 pull in all the real definitions. */
127typedef struct NICInfo NICInfo;
1ae26a18 128typedef struct HCIInfo HCIInfo;
87ecb68b
PB
129typedef struct AudioState AudioState;
130typedef struct BlockDriverState BlockDriverState;
131typedef struct DisplayState DisplayState;
132typedef struct TextConsole TextConsole;
c60e08d9 133typedef TextConsole QEMUConsole;
87ecb68b
PB
134typedef struct CharDriverState CharDriverState;
135typedef struct VLANState VLANState;
136typedef struct QEMUFile QEMUFile;
137typedef struct i2c_bus i2c_bus;
138typedef struct i2c_slave i2c_slave;
139typedef struct SMBusDevice SMBusDevice;
140typedef struct QEMUTimer QEMUTimer;
141typedef struct PCIBus PCIBus;
142typedef struct PCIDevice PCIDevice;
143typedef struct SerialState SerialState;
144typedef struct IRQState *qemu_irq;
145struct pcmcia_card_s;
146
b3c7724c
PB
147/* CPU save/load. */
148void cpu_save(QEMUFile *f, void *opaque);
149int cpu_load(QEMUFile *f, void *opaque, int version_id);
150
9e472e10
AL
151/* Force QEMU to stop what it's doing and service IO */
152void qemu_service_io(void);
153
faf07963 154#endif