r5531 made x509 certs not loadable (original patch from Henrik Holst).
[qemu/mini2440.git] / qemu-common.h
blobb82741bc025d588e703a9bc531dedcb7cb32c75a
1 /* Common header file that is included by all of qemu. */
2 #ifndef QEMU_COMMON_H
3 #define QEMU_COMMON_H
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>
19 #ifndef O_LARGEFILE
20 #define O_LARGEFILE 0
21 #endif
22 #ifndef O_BINARY
23 #define O_BINARY 0
24 #endif
26 #ifndef ENOMEDIUM
27 #define ENOMEDIUM ENODEV
28 #endif
30 #ifdef _WIN32
31 #define WIN32_LEAN_AND_MEAN
32 #define WINVER 0x0501 /* needed for ipv6 bits */
33 #include <windows.h>
34 #define fsync _commit
35 #define lseek _lseeki64
36 #define ENOTSUP 4096
37 extern int qemu_ftruncate64(int, int64_t);
38 #define ftruncate qemu_ftruncate64
41 static inline char *realpath(const char *path, char *resolved_path)
43 _fullpath(resolved_path, path, _MAX_PATH);
44 return resolved_path;
47 #define PRId64 "I64d"
48 #define PRIx64 "I64x"
49 #define PRIu64 "I64u"
50 #define PRIo64 "I64o"
51 #endif
53 /* FIXME: Remove NEED_CPU_H. */
54 #ifndef NEED_CPU_H
56 #include "config-host.h"
57 #include <setjmp.h>
58 #include "osdep.h"
59 #include "bswap.h"
61 #else
63 #include "cpu.h"
65 #endif /* !defined(NEED_CPU_H) */
67 /* bottom halves */
68 typedef struct QEMUBH QEMUBH;
70 typedef void QEMUBHFunc(void *opaque);
72 QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
73 void qemu_bh_schedule(QEMUBH *bh);
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.
80 void qemu_bh_schedule_idle(QEMUBH *bh);
81 void qemu_bh_cancel(QEMUBH *bh);
82 void qemu_bh_delete(QEMUBH *bh);
83 int qemu_bh_poll(void);
85 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
87 void qemu_get_timedate(struct tm *tm, int offset);
88 int qemu_timedate_diff(struct tm *tm);
90 /* cutils.c */
91 void pstrcpy(char *buf, int buf_size, const char *str);
92 char *pstrcat(char *buf, int buf_size, const char *s);
93 int strstart(const char *str, const char *val, const char **ptr);
94 int stristart(const char *str, const char *val, const char **ptr);
95 time_t mktimegm(struct tm *tm);
97 void *qemu_malloc(size_t size);
98 void *qemu_realloc(void *ptr, size_t size);
99 void *qemu_mallocz(size_t size);
100 void qemu_free(void *ptr);
101 char *qemu_strdup(const char *str);
102 char *qemu_strndup(const char *str, size_t size);
104 void *get_mmap_addr(unsigned long size);
107 /* Error handling. */
109 void hw_error(const char *fmt, ...)
110 __attribute__ ((__format__ (__printf__, 1, 2)))
111 __attribute__ ((__noreturn__));
113 /* IO callbacks. */
114 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
115 typedef int IOCanRWHandler(void *opaque);
116 typedef void IOHandler(void *opaque);
118 struct ParallelIOArg {
119 void *buffer;
120 int count;
123 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
125 /* A load of opaque types so that device init declarations don't have to
126 pull in all the real definitions. */
127 typedef struct NICInfo NICInfo;
128 typedef struct HCIInfo HCIInfo;
129 typedef struct AudioState AudioState;
130 typedef struct BlockDriverState BlockDriverState;
131 typedef struct DisplayState DisplayState;
132 typedef struct TextConsole TextConsole;
133 typedef TextConsole QEMUConsole;
134 typedef struct CharDriverState CharDriverState;
135 typedef struct VLANState VLANState;
136 typedef struct QEMUFile QEMUFile;
137 typedef struct i2c_bus i2c_bus;
138 typedef struct i2c_slave i2c_slave;
139 typedef struct SMBusDevice SMBusDevice;
140 typedef struct QEMUTimer QEMUTimer;
141 typedef struct PCIBus PCIBus;
142 typedef struct PCIDevice PCIDevice;
143 typedef struct SerialState SerialState;
144 typedef struct IRQState *qemu_irq;
145 struct pcmcia_card_s;
147 /* CPU save/load. */
148 void cpu_save(QEMUFile *f, void *opaque);
149 int cpu_load(QEMUFile *f, void *opaque, int version_id);
151 /* Force QEMU to stop what it's doing and service IO */
152 void qemu_service_io(void);
154 #endif