Convert mulscc
[qemu/hppa.git] / hw / hw.h
blobd0cf598204500e3437f66dbe652fa400974f1195
1 /* Declarations for use by hardware emulation. */
2 #ifndef QEMU_HW_H
3 #define QEMU_HW_H
5 #include "qemu-common.h"
6 #include "irq.h"
8 /* VM Load/Save */
10 /* This function writes a chunk of data to a file at the given position.
11 * The pos argument can be ignored if the file is only being used for
12 * streaming. The handler should try to write all of the data it can.
14 typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf,
15 int64_t pos, int size);
17 /* Read a chunk of data from a file at the given position. The pos argument
18 * can be ignored if the file is only be used for streaming. The number of
19 * bytes actually read should be returned.
21 typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf,
22 int64_t pos, int size);
24 /* Close a file and return an error code */
25 typedef int (QEMUFileCloseFunc)(void *opaque);
27 /* Called to determine if the file has exceeded it's bandwidth allocation. The
28 * bandwidth capping is a soft limit, not a hard limit.
30 typedef int (QEMUFileRateLimit)(void *opaque);
32 QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
33 QEMUFileGetBufferFunc *get_buffer,
34 QEMUFileCloseFunc *close,
35 QEMUFileRateLimit *rate_limit);
36 QEMUFile *qemu_fopen(const char *filename, const char *mode);
37 QEMUFile *qemu_fopen_socket(int fd);
38 QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
39 QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
40 void qemu_fflush(QEMUFile *f);
41 int qemu_fclose(QEMUFile *f);
42 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
43 void qemu_put_byte(QEMUFile *f, int v);
45 static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
47 qemu_put_byte(f, (int)v);
50 #define qemu_put_sbyte qemu_put_byte
52 void qemu_put_be16(QEMUFile *f, unsigned int v);
53 void qemu_put_be32(QEMUFile *f, unsigned int v);
54 void qemu_put_be64(QEMUFile *f, uint64_t v);
55 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
56 int qemu_get_byte(QEMUFile *f);
58 static inline unsigned int qemu_get_ubyte(QEMUFile *f)
60 return (unsigned int)qemu_get_byte(f);
63 #define qemu_get_sbyte qemu_get_byte
65 unsigned int qemu_get_be16(QEMUFile *f);
66 unsigned int qemu_get_be32(QEMUFile *f);
67 uint64_t qemu_get_be64(QEMUFile *f);
68 int qemu_file_rate_limit(QEMUFile *f);
69 int qemu_file_has_error(QEMUFile *f);
70 void qemu_file_set_error(QEMUFile *f);
72 /* Try to send any outstanding data. This function is useful when output is
73 * halted due to rate limiting or EAGAIN errors occur as it can be used to
74 * resume output. */
75 void qemu_file_put_notify(QEMUFile *f);
77 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
79 qemu_put_be64(f, *pv);
82 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
84 qemu_put_be32(f, *pv);
87 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
89 qemu_put_be16(f, *pv);
92 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
94 qemu_put_byte(f, *pv);
97 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
99 *pv = qemu_get_be64(f);
102 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
104 *pv = qemu_get_be32(f);
107 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
109 *pv = qemu_get_be16(f);
112 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
114 *pv = qemu_get_byte(f);
117 // Signed versions for type safety
118 static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size)
120 qemu_put_buffer(f, (const uint8_t *)buf, size);
123 static inline void qemu_put_sbe16(QEMUFile *f, int v)
125 qemu_put_be16(f, (unsigned int)v);
128 static inline void qemu_put_sbe32(QEMUFile *f, int v)
130 qemu_put_be32(f, (unsigned int)v);
133 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
135 qemu_put_be64(f, (uint64_t)v);
138 static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size)
140 return qemu_get_buffer(f, (uint8_t *)buf, size);
143 static inline int qemu_get_sbe16(QEMUFile *f)
145 return (int)qemu_get_be16(f);
148 static inline int qemu_get_sbe32(QEMUFile *f)
150 return (int)qemu_get_be32(f);
153 static inline int64_t qemu_get_sbe64(QEMUFile *f)
155 return (int64_t)qemu_get_be64(f);
158 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
160 qemu_put_8s(f, (const uint8_t *)pv);
163 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
165 qemu_put_be16s(f, (const uint16_t *)pv);
168 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
170 qemu_put_be32s(f, (const uint32_t *)pv);
173 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
175 qemu_put_be64s(f, (const uint64_t *)pv);
178 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
180 qemu_get_8s(f, (uint8_t *)pv);
183 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
185 qemu_get_be16s(f, (uint16_t *)pv);
188 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
190 qemu_get_be32s(f, (uint32_t *)pv);
193 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
195 qemu_get_be64s(f, (uint64_t *)pv);
198 #ifdef NEED_CPU_H
199 #if TARGET_LONG_BITS == 64
200 #define qemu_put_betl qemu_put_be64
201 #define qemu_get_betl qemu_get_be64
202 #define qemu_put_betls qemu_put_be64s
203 #define qemu_get_betls qemu_get_be64s
204 #define qemu_put_sbetl qemu_put_sbe64
205 #define qemu_get_sbetl qemu_get_sbe64
206 #define qemu_put_sbetls qemu_put_sbe64s
207 #define qemu_get_sbetls qemu_get_sbe64s
208 #else
209 #define qemu_put_betl qemu_put_be32
210 #define qemu_get_betl qemu_get_be32
211 #define qemu_put_betls qemu_put_be32s
212 #define qemu_get_betls qemu_get_be32s
213 #define qemu_put_sbetl qemu_put_sbe32
214 #define qemu_get_sbetl qemu_get_sbe32
215 #define qemu_put_sbetls qemu_put_sbe32s
216 #define qemu_get_sbetls qemu_get_sbe32s
217 #endif
218 #endif
220 int64_t qemu_ftell(QEMUFile *f);
221 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
223 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
224 typedef int SaveLiveStateHandler(QEMUFile *f, int stage, void *opaque);
225 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
227 int register_savevm(const char *idstr,
228 int instance_id,
229 int version_id,
230 SaveStateHandler *save_state,
231 LoadStateHandler *load_state,
232 void *opaque);
234 int register_savevm_live(const char *idstr,
235 int instance_id,
236 int version_id,
237 SaveLiveStateHandler *save_live_state,
238 SaveStateHandler *save_state,
239 LoadStateHandler *load_state,
240 void *opaque);
242 void unregister_savevm(const char *idstr, void *opaque);
244 typedef void QEMUResetHandler(void *opaque);
246 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
248 /* handler to set the boot_device for a specific type of QEMUMachine */
249 /* return 0 if success */
250 typedef int QEMUBootSetHandler(void *opaque, const char *boot_device);
251 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
253 /* These should really be in isa.h, but are here to make pc.h happy. */
254 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
255 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
257 #endif