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