Use the new concat_tl_i64 op for std and stda
[qemu/mini2440.git] / hw / hw.h
blob069c99266f134f1a02b8ed08729feca07869a6b3
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 QEMUFile *qemu_fopen(const char *filename, const char *mode);
11 void qemu_fflush(QEMUFile *f);
12 void qemu_fclose(QEMUFile *f);
13 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
14 void qemu_put_byte(QEMUFile *f, int8_t v);
16 static inline void qemu_put_ubyte(QEMUFile *f, uint8_t v)
18 qemu_put_byte(f, (int8_t)v);
21 #define qemu_put_sbyte qemu_put_byte
23 void qemu_put_be16(QEMUFile *f, uint16_t v);
24 void qemu_put_be32(QEMUFile *f, uint32_t v);
25 void qemu_put_be64(QEMUFile *f, uint64_t v);
26 size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
27 int8_t qemu_get_byte(QEMUFile *f);
29 static inline uint8_t qemu_get_ubyte(QEMUFile *f)
31 return (uint8_t)qemu_get_byte(f);
34 #define qemu_get_sbyte qemu_get_byte
36 uint16_t qemu_get_be16(QEMUFile *f);
37 uint32_t qemu_get_be32(QEMUFile *f);
38 uint64_t qemu_get_be64(QEMUFile *f);
40 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
42 qemu_put_be64(f, *pv);
45 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
47 qemu_put_be32(f, *pv);
50 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
52 qemu_put_be16(f, *pv);
55 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
57 qemu_put_byte(f, *pv);
60 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
62 *pv = qemu_get_be64(f);
65 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
67 *pv = qemu_get_be32(f);
70 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
72 *pv = qemu_get_be16(f);
75 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
77 *pv = qemu_get_byte(f);
80 // Signed versions for type safety
81 static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, size_t size)
83 qemu_put_buffer(f, (const uint8_t *)buf, size);
86 static inline void qemu_put_sbe16(QEMUFile *f, int16_t v)
88 qemu_put_be16(f, (uint16_t)v);
91 static inline void qemu_put_sbe32(QEMUFile *f, int32_t v)
93 qemu_put_be32(f, (uint32_t)v);
96 static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
98 qemu_put_be64(f, (uint64_t)v);
101 static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, size_t size)
103 return qemu_get_buffer(f, (uint8_t *)buf, size);
106 static inline int16_t qemu_get_sbe16(QEMUFile *f)
108 return (int16_t)qemu_get_be16(f);
111 static inline int32_t qemu_get_sbe32(QEMUFile *f)
113 return (int32_t)qemu_get_be32(f);
116 static inline int64_t qemu_get_sbe64(QEMUFile *f)
118 return (int64_t)qemu_get_be64(f);
121 static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
123 qemu_put_8s(f, (const uint8_t *)pv);
126 static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
128 qemu_put_be16s(f, (const uint16_t *)pv);
131 static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
133 qemu_put_be32s(f, (const uint32_t *)pv);
136 static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
138 qemu_put_be64s(f, (const uint64_t *)pv);
141 static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
143 qemu_get_8s(f, (uint8_t *)pv);
146 static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
148 qemu_get_be16s(f, (uint16_t *)pv);
151 static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
153 qemu_get_be32s(f, (uint32_t *)pv);
156 static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
158 qemu_get_be64s(f, (uint64_t *)pv);
161 #ifdef NEED_CPU_H
162 #if TARGET_LONG_BITS == 64
163 #define qemu_put_betl qemu_put_be64
164 #define qemu_get_betl qemu_get_be64
165 #define qemu_put_betls qemu_put_be64s
166 #define qemu_get_betls qemu_get_be64s
167 #define qemu_put_sbetl qemu_put_sbe64
168 #define qemu_get_sbetl qemu_get_sbe64
169 #define qemu_put_sbetls qemu_put_sbe64s
170 #define qemu_get_sbetls qemu_get_sbe64s
171 #else
172 #define qemu_put_betl qemu_put_be32
173 #define qemu_get_betl qemu_get_be32
174 #define qemu_put_betls qemu_put_be32s
175 #define qemu_get_betls qemu_get_be32s
176 #define qemu_put_sbetl qemu_put_sbe32
177 #define qemu_get_sbetl qemu_get_sbe32
178 #define qemu_put_sbetls qemu_put_sbe32s
179 #define qemu_get_sbetls qemu_get_sbe32s
180 #endif
181 #endif
183 int64_t qemu_ftell(QEMUFile *f);
184 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
186 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
187 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
189 int register_savevm(const char *idstr,
190 int instance_id,
191 int version_id,
192 SaveStateHandler *save_state,
193 LoadStateHandler *load_state,
194 void *opaque);
196 typedef void QEMUResetHandler(void *opaque);
198 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
200 /* handler to set the boot_device for a specific type of QEMUMachine */
201 /* return 0 if success */
202 typedef int QEMUBootSetHandler(void *opaque, const char *boot_device);
203 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
205 /* These should really be in isa.h, but are here to make pc.h happy. */
206 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
207 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
209 #endif