root / hw / hw.h @ 5dafc53f
History | View | Annotate | Download (4.3 kB)
1 | 87ecb68b | pbrook | /* Declarations for use by hardware emulation. */
|
---|---|---|---|
2 | 87ecb68b | pbrook | #ifndef QEMU_HW_H
|
3 | 87ecb68b | pbrook | #define QEMU_HW_H
|
4 | 87ecb68b | pbrook | |
5 | 87ecb68b | pbrook | #include "qemu-common.h" |
6 | 87ecb68b | pbrook | #include "irq.h" |
7 | 87ecb68b | pbrook | |
8 | 87ecb68b | pbrook | /* VM Load/Save */
|
9 | 87ecb68b | pbrook | |
10 | 5dafc53f | aliguori | /* This function writes a chunk of data to a file at the given position.
|
11 | 5dafc53f | aliguori | * The pos argument can be ignored if the file is only being used for
|
12 | 5dafc53f | aliguori | * streaming. The handler should try to write all of the data it can.
|
13 | 5dafc53f | aliguori | */
|
14 | 5dafc53f | aliguori | typedef void (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, |
15 | 5dafc53f | aliguori | int64_t pos, int size);
|
16 | 5dafc53f | aliguori | |
17 | 5dafc53f | aliguori | /* Read a chunk of data from a file at the given position. The pos argument
|
18 | 5dafc53f | aliguori | * can be ignored if the file is only be used for streaming. The number of
|
19 | 5dafc53f | aliguori | * bytes actually read should be returned.
|
20 | 5dafc53f | aliguori | */
|
21 | 5dafc53f | aliguori | typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, |
22 | 5dafc53f | aliguori | int64_t pos, int size);
|
23 | 5dafc53f | aliguori | |
24 | 5dafc53f | aliguori | /* Close a file and return an error code */
|
25 | 5dafc53f | aliguori | typedef int (QEMUFileCloseFunc)(void *opaque); |
26 | 5dafc53f | aliguori | |
27 | 5dafc53f | aliguori | /* Called to determine if the file has exceeded it's bandwidth allocation. The
|
28 | 5dafc53f | aliguori | * bandwidth capping is a soft limit, not a hard limit.
|
29 | 5dafc53f | aliguori | */
|
30 | 5dafc53f | aliguori | typedef int (QEMUFileRateLimit)(void *opaque); |
31 | 5dafc53f | aliguori | |
32 | 5dafc53f | aliguori | QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
|
33 | 5dafc53f | aliguori | QEMUFileGetBufferFunc *get_buffer, |
34 | 5dafc53f | aliguori | QEMUFileCloseFunc *close, |
35 | 5dafc53f | aliguori | QEMUFileRateLimit *rate_limit); |
36 | 87ecb68b | pbrook | QEMUFile *qemu_fopen(const char *filename, const char *mode); |
37 | 5dafc53f | aliguori | QEMUFile *qemu_fopen_fd(int fd);
|
38 | 87ecb68b | pbrook | void qemu_fflush(QEMUFile *f);
|
39 | 5dafc53f | aliguori | int qemu_fclose(QEMUFile *f);
|
40 | 2ca83a8d | blueswir1 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
41 | 2ca83a8d | blueswir1 | void qemu_put_byte(QEMUFile *f, int v); |
42 | 2ca83a8d | blueswir1 | void qemu_put_be16(QEMUFile *f, unsigned int v); |
43 | 2ca83a8d | blueswir1 | void qemu_put_be32(QEMUFile *f, unsigned int v); |
44 | 87ecb68b | pbrook | void qemu_put_be64(QEMUFile *f, uint64_t v);
|
45 | 2ca83a8d | blueswir1 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
46 | 2ca83a8d | blueswir1 | int qemu_get_byte(QEMUFile *f);
|
47 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be16(QEMUFile *f); |
48 | 2ca83a8d | blueswir1 | unsigned int qemu_get_be32(QEMUFile *f); |
49 | 87ecb68b | pbrook | uint64_t qemu_get_be64(QEMUFile *f); |
50 | 5dafc53f | aliguori | int qemu_file_rate_limit(QEMUFile *f);
|
51 | 5dafc53f | aliguori | |
52 | 5dafc53f | aliguori | /* Try to send any outstanding data. This function is useful when output is
|
53 | 5dafc53f | aliguori | * halted due to rate limiting or EAGAIN errors occur as it can be used to
|
54 | 5dafc53f | aliguori | * resume output. */
|
55 | 5dafc53f | aliguori | void qemu_file_put_notify(QEMUFile *f);
|
56 | 87ecb68b | pbrook | |
57 | 87ecb68b | pbrook | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
58 | 87ecb68b | pbrook | { |
59 | 87ecb68b | pbrook | qemu_put_be64(f, *pv); |
60 | 87ecb68b | pbrook | } |
61 | 87ecb68b | pbrook | |
62 | 87ecb68b | pbrook | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
63 | 87ecb68b | pbrook | { |
64 | 87ecb68b | pbrook | qemu_put_be32(f, *pv); |
65 | 87ecb68b | pbrook | } |
66 | 87ecb68b | pbrook | |
67 | 87ecb68b | pbrook | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
68 | 87ecb68b | pbrook | { |
69 | 87ecb68b | pbrook | qemu_put_be16(f, *pv); |
70 | 87ecb68b | pbrook | } |
71 | 87ecb68b | pbrook | |
72 | 87ecb68b | pbrook | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
73 | 87ecb68b | pbrook | { |
74 | 87ecb68b | pbrook | qemu_put_byte(f, *pv); |
75 | 87ecb68b | pbrook | } |
76 | 87ecb68b | pbrook | |
77 | 87ecb68b | pbrook | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
78 | 87ecb68b | pbrook | { |
79 | 87ecb68b | pbrook | *pv = qemu_get_be64(f); |
80 | 87ecb68b | pbrook | } |
81 | 87ecb68b | pbrook | |
82 | 87ecb68b | pbrook | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
83 | 87ecb68b | pbrook | { |
84 | 87ecb68b | pbrook | *pv = qemu_get_be32(f); |
85 | 87ecb68b | pbrook | } |
86 | 87ecb68b | pbrook | |
87 | 87ecb68b | pbrook | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
88 | 87ecb68b | pbrook | { |
89 | 87ecb68b | pbrook | *pv = qemu_get_be16(f); |
90 | 87ecb68b | pbrook | } |
91 | 87ecb68b | pbrook | |
92 | 87ecb68b | pbrook | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
93 | 87ecb68b | pbrook | { |
94 | 87ecb68b | pbrook | *pv = qemu_get_byte(f); |
95 | 87ecb68b | pbrook | } |
96 | 87ecb68b | pbrook | |
97 | 87ecb68b | pbrook | #ifdef NEED_CPU_H
|
98 | 87ecb68b | pbrook | #if TARGET_LONG_BITS == 64 |
99 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be64
|
100 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be64
|
101 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be64s
|
102 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be64s
|
103 | 87ecb68b | pbrook | #else
|
104 | 87ecb68b | pbrook | #define qemu_put_betl qemu_put_be32
|
105 | 87ecb68b | pbrook | #define qemu_get_betl qemu_get_be32
|
106 | 87ecb68b | pbrook | #define qemu_put_betls qemu_put_be32s
|
107 | 87ecb68b | pbrook | #define qemu_get_betls qemu_get_be32s
|
108 | 87ecb68b | pbrook | #endif
|
109 | 87ecb68b | pbrook | #endif
|
110 | 87ecb68b | pbrook | |
111 | 87ecb68b | pbrook | int64_t qemu_ftell(QEMUFile *f); |
112 | 87ecb68b | pbrook | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
113 | 87ecb68b | pbrook | |
114 | 87ecb68b | pbrook | typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
115 | 87ecb68b | pbrook | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
116 | 87ecb68b | pbrook | |
117 | 87ecb68b | pbrook | int register_savevm(const char *idstr, |
118 | 87ecb68b | pbrook | int instance_id,
|
119 | 87ecb68b | pbrook | int version_id,
|
120 | 87ecb68b | pbrook | SaveStateHandler *save_state, |
121 | 87ecb68b | pbrook | LoadStateHandler *load_state, |
122 | 87ecb68b | pbrook | void *opaque);
|
123 | 87ecb68b | pbrook | |
124 | 87ecb68b | pbrook | typedef void QEMUResetHandler(void *opaque); |
125 | 87ecb68b | pbrook | |
126 | 87ecb68b | pbrook | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
127 | 87ecb68b | pbrook | |
128 | 0ecdffbb | aurel32 | /* handler to set the boot_device for a specific type of QEMUMachine */
|
129 | 0ecdffbb | aurel32 | /* return 0 if success */
|
130 | 3b4366de | blueswir1 | typedef int QEMUBootSetHandler(void *opaque, const char *boot_device); |
131 | 3b4366de | blueswir1 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); |
132 | 0ecdffbb | aurel32 | |
133 | 87ecb68b | pbrook | /* These should really be in isa.h, but are here to make pc.h happy. */
|
134 | 87ecb68b | pbrook | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); |
135 | 87ecb68b | pbrook | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); |
136 | 87ecb68b | pbrook | |
137 | 87ecb68b | pbrook | #endif |