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 #ifndef PATH_MAX
31 #define PATH_MAX 1024
32 #endif
33 
34 #ifdef _WIN32
35 #define WIN32_LEAN_AND_MEAN
36 #include <windows.h>
37 #define fsync _commit
38 #define lseek _lseeki64
39 #define ENOTSUP 4096
40 extern int qemu_ftruncate64(int, int64_t);
41 #define ftruncate qemu_ftruncate64
42 
43 
realpath(const char * path,char * resolved_path)44 static inline char *realpath(const char *path, char *resolved_path)
45 {
46     _fullpath(resolved_path, path, _MAX_PATH);
47     return resolved_path;
48 }
49 
50 #define PRId64 "I64d"
51 #define PRIx64 "I64x"
52 #define PRIu64 "I64u"
53 #define PRIo64 "I64o"
54 #endif
55 
56 /* FIXME: Remove NEED_CPU_H.  */
57 #ifndef NEED_CPU_H
58 
59 #include "config-host.h"
60 #include <setjmp.h>
61 #include "osdep.h"
62 #include "bswap.h"
63 
64 #else
65 
66 #include "cpu.h"
67 
68 #endif /* !defined(NEED_CPU_H) */
69 
70 /* bottom halves */
71 typedef struct QEMUBH QEMUBH;
72 
73 typedef void QEMUBHFunc(void *opaque);
74 
75 QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
76 void qemu_bh_schedule(QEMUBH *bh);
77 void qemu_bh_cancel(QEMUBH *bh);
78 void qemu_bh_delete(QEMUBH *bh);
79 int qemu_bh_poll(void);
80 
81 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
82 
83 /* cutils.c */
84 void pstrcpy(char *buf, int buf_size, const char *str);
85 char *pstrcat(char *buf, int buf_size, const char *s);
86 int strstart(const char *str, const char *val, const char **ptr);
87 int stristart(const char *str, const char *val, const char **ptr);
88 time_t mktimegm(struct tm *tm);
89 
90 /* Error handling.  */
91 
92 void hw_error(const char *fmt, ...)
93     __attribute__ ((__format__ (__printf__, 1, 2)))
94     __attribute__ ((__noreturn__));
95 
96 /* IO callbacks.  */
97 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
98 typedef int IOCanRWHandler(void *opaque);
99 typedef void IOHandler(void *opaque);
100 
101 struct ParallelIOArg {
102     void *buffer;
103     int count;
104 };
105 
106 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
107 
108 /* A load of opaque types so that device init declarations don't have to
109    pull in all the real definitions.  */
110 typedef struct NICInfo NICInfo;
111 typedef struct AudioState AudioState;
112 typedef struct BlockDriverState BlockDriverState;
113 typedef struct DisplayState DisplayState;
114 typedef struct TextConsole TextConsole;
115 typedef struct CharDriverState CharDriverState;
116 typedef struct VLANState VLANState;
117 typedef struct QEMUFile QEMUFile;
118 typedef struct i2c_bus i2c_bus;
119 typedef struct i2c_slave i2c_slave;
120 typedef struct SMBusDevice SMBusDevice;
121 typedef struct QEMUTimer QEMUTimer;
122 typedef struct PCIBus PCIBus;
123 typedef struct PCIDevice PCIDevice;
124 typedef struct SerialState SerialState;
125 typedef struct IRQState *qemu_irq;
126 struct pcmcia_card_s;
127 
128 #endif
129