1#ifndef REPLAY_INTERNAL_H
2#define REPLAY_INTERNAL_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16enum ReplayEvents {
17
18 EVENT_INSTRUCTION,
19
20 EVENT_INTERRUPT,
21
22 EVENT_EXCEPTION,
23
24 EVENT_ASYNC,
25
26 EVENT_SHUTDOWN,
27 EVENT_SHUTDOWN_LAST = EVENT_SHUTDOWN + SHUTDOWN_CAUSE__MAX,
28
29 EVENT_CHAR_WRITE,
30
31 EVENT_CHAR_READ_ALL,
32 EVENT_CHAR_READ_ALL_ERROR,
33
34 EVENT_AUDIO_OUT,
35
36 EVENT_AUDIO_IN,
37
38 EVENT_RANDOM,
39
40
41 EVENT_CLOCK,
42 EVENT_CLOCK_LAST = EVENT_CLOCK + REPLAY_CLOCK_COUNT - 1,
43
44
45 EVENT_CHECKPOINT,
46 EVENT_CHECKPOINT_LAST = EVENT_CHECKPOINT + CHECKPOINT_COUNT - 1,
47
48 EVENT_END,
49 EVENT_COUNT
50};
51
52
53
54enum ReplayAsyncEventKind {
55 REPLAY_ASYNC_EVENT_BH,
56 REPLAY_ASYNC_EVENT_BH_ONESHOT,
57 REPLAY_ASYNC_EVENT_INPUT,
58 REPLAY_ASYNC_EVENT_INPUT_SYNC,
59 REPLAY_ASYNC_EVENT_CHAR_READ,
60 REPLAY_ASYNC_EVENT_BLOCK,
61 REPLAY_ASYNC_EVENT_NET,
62 REPLAY_ASYNC_COUNT
63};
64
65typedef enum ReplayAsyncEventKind ReplayAsyncEventKind;
66
67typedef struct ReplayState {
68
69 int64_t cached_clock[REPLAY_CLOCK_COUNT];
70
71 uint64_t current_icount;
72
73 int instruction_count;
74
75 unsigned int data_kind;
76
77 unsigned int has_unread_data;
78
79 uint64_t file_offset;
80
81
82
83 uint64_t block_request_id;
84
85 uint64_t host_clock_last;
86
87 int32_t read_event_kind;
88
89 uint64_t read_event_id;
90
91 int32_t read_event_checkpoint;
92} ReplayState;
93extern ReplayState replay_state;
94
95
96extern FILE *replay_file;
97
98extern uint64_t replay_break_icount;
99
100extern QEMUTimer *replay_break_timer;
101
102void replay_put_byte(uint8_t byte);
103void replay_put_event(uint8_t event);
104void replay_put_word(uint16_t word);
105void replay_put_dword(uint32_t dword);
106void replay_put_qword(int64_t qword);
107void replay_put_array(const uint8_t *buf, size_t size);
108
109uint8_t replay_get_byte(void);
110uint16_t replay_get_word(void);
111uint32_t replay_get_dword(void);
112int64_t replay_get_qword(void);
113void replay_get_array(uint8_t *buf, size_t *size);
114void replay_get_array_alloc(uint8_t **buf, size_t *size);
115
116
117
118
119void replay_mutex_init(void);
120bool replay_mutex_locked(void);
121
122
123void replay_check_error(void);
124
125
126
127void replay_finish_event(void);
128
129
130void replay_fetch_data_kind(void);
131
132
133void replay_advance_current_icount(uint64_t current_icount);
134
135void replay_save_instructions(void);
136
137
138
139bool replay_next_event_is(int event);
140
141
142
143
144void replay_read_next_clock(unsigned int kind);
145
146
147
148
149void replay_init_events(void);
150
151void replay_finish_events(void);
152
153bool replay_has_events(void);
154
155void replay_save_events(int checkpoint);
156
157void replay_read_events(int checkpoint);
158
159void replay_add_event(ReplayAsyncEventKind event_kind, void *opaque,
160 void *opaque2, uint64_t id);
161
162
163
164
165void replay_save_input_event(InputEvent *evt);
166
167InputEvent *replay_read_input_event(void);
168
169void replay_add_input_event(struct InputEvent *event);
170
171void replay_add_input_sync_event(void);
172
173
174
175
176void replay_event_char_read_run(void *opaque);
177
178void replay_event_char_read_save(void *opaque);
179
180void *replay_event_char_read_load(void);
181
182
183
184
185void replay_event_net_run(void *opaque);
186
187void replay_event_net_save(void *opaque);
188
189void *replay_event_net_load(void);
190
191
192
193
194
195
196void replay_vmstate_register(void);
197
198#endif
199