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