replay: interrupts and exceptions
[qemu/ar7.git] / replay / replay-internal.h
blob5ff1c14287d09c9156052282a8b97e6487687d79
1 #ifndef REPLAY_INTERNAL_H
2 #define REPLAY_INTERNAL_H
4 /*
5 * replay-internal.h
7 * Copyright (c) 2010-2015 Institute for System Programming
8 * of the Russian Academy of Sciences.
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 #include <stdio.h>
17 enum ReplayEvents {
18 /* for instruction event */
19 EVENT_INSTRUCTION,
20 /* for software interrupt */
21 EVENT_INTERRUPT,
22 /* for emulated exceptions */
23 EVENT_EXCEPTION,
24 EVENT_COUNT
27 typedef struct ReplayState {
28 /*! Current step - number of processed instructions and timer events. */
29 uint64_t current_step;
30 /*! Number of instructions to be executed before other events happen. */
31 int instructions_count;
32 } ReplayState;
33 extern ReplayState replay_state;
35 extern unsigned int replay_data_kind;
37 /* File for replay writing */
38 extern FILE *replay_file;
40 void replay_put_byte(uint8_t byte);
41 void replay_put_event(uint8_t event);
42 void replay_put_word(uint16_t word);
43 void replay_put_dword(uint32_t dword);
44 void replay_put_qword(int64_t qword);
45 void replay_put_array(const uint8_t *buf, size_t size);
47 uint8_t replay_get_byte(void);
48 uint16_t replay_get_word(void);
49 uint32_t replay_get_dword(void);
50 int64_t replay_get_qword(void);
51 void replay_get_array(uint8_t *buf, size_t *size);
52 void replay_get_array_alloc(uint8_t **buf, size_t *size);
54 /* Mutex functions for protecting replay log file */
56 void replay_mutex_init(void);
57 void replay_mutex_destroy(void);
58 void replay_mutex_lock(void);
59 void replay_mutex_unlock(void);
61 /*! Checks error status of the file. */
62 void replay_check_error(void);
64 /*! Finishes processing of the replayed event and fetches
65 the next event from the log. */
66 void replay_finish_event(void);
67 /*! Reads data type from the file and stores it in the
68 replay_data_kind variable. */
69 void replay_fetch_data_kind(void);
71 /*! Saves queued events (like instructions and sound). */
72 void replay_save_instructions(void);
74 /*! Skips async events until some sync event will be found.
75 \return true, if event was found */
76 bool replay_next_event_is(int event);
78 #endif