crypto: add compat cast5_set_key with nettle < 3.0.0
[qemu/ar7.git] / include / sysemu / replay.h
blobe7989199fcfcdc886faf3e502c0a098b4b033408
1 #ifndef REPLAY_H
2 #define REPLAY_H
4 /*
5 * replay.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 "qapi-types.h"
16 #include "qemu/typedefs.h"
18 /* replay clock kinds */
19 enum ReplayClockKind {
20 /* host_clock */
21 REPLAY_CLOCK_HOST,
22 /* virtual_rt_clock */
23 REPLAY_CLOCK_VIRTUAL_RT,
24 REPLAY_CLOCK_COUNT
26 typedef enum ReplayClockKind ReplayClockKind;
28 /* IDs of the checkpoints */
29 enum ReplayCheckpoint {
30 CHECKPOINT_CLOCK_WARP_START,
31 CHECKPOINT_CLOCK_WARP_ACCOUNT,
32 CHECKPOINT_RESET_REQUESTED,
33 CHECKPOINT_SUSPEND_REQUESTED,
34 CHECKPOINT_CLOCK_VIRTUAL,
35 CHECKPOINT_CLOCK_HOST,
36 CHECKPOINT_CLOCK_VIRTUAL_RT,
37 CHECKPOINT_INIT,
38 CHECKPOINT_RESET,
39 CHECKPOINT_COUNT
41 typedef enum ReplayCheckpoint ReplayCheckpoint;
43 extern ReplayMode replay_mode;
45 /* Replay process control functions */
47 /*! Enables recording or saving event log with specified parameters */
48 void replay_configure(struct QemuOpts *opts);
49 /*! Initializes timers used for snapshotting and enables events recording */
50 void replay_start(void);
51 /*! Closes replay log file and frees other resources. */
52 void replay_finish(void);
53 /*! Adds replay blocker with the specified error description */
54 void replay_add_blocker(Error *reason);
56 /* Processing the instructions */
58 /*! Returns number of executed instructions. */
59 uint64_t replay_get_current_step(void);
60 /*! Returns number of instructions to execute in replay mode. */
61 int replay_get_instructions(void);
62 /*! Updates instructions counter in replay mode. */
63 void replay_account_executed_instructions(void);
65 /* Interrupts and exceptions */
67 /*! Called by exception handler to write or read
68 exception processing events. */
69 bool replay_exception(void);
70 /*! Used to determine that exception is pending.
71 Does not proceed to the next event in the log. */
72 bool replay_has_exception(void);
73 /*! Called by interrupt handlers to write or read
74 interrupt processing events.
75 \return true if interrupt should be processed */
76 bool replay_interrupt(void);
77 /*! Tries to read interrupt event from the file.
78 Returns true, when interrupt request is pending */
79 bool replay_has_interrupt(void);
81 /* Processing clocks and other time sources */
83 /*! Save the specified clock */
84 int64_t replay_save_clock(ReplayClockKind kind, int64_t clock);
85 /*! Read the specified clock from the log or return cached data */
86 int64_t replay_read_clock(ReplayClockKind kind);
87 /*! Saves or reads the clock depending on the current replay mode. */
88 #define REPLAY_CLOCK(clock, value) \
89 (replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock)) \
90 : replay_mode == REPLAY_MODE_RECORD \
91 ? replay_save_clock((clock), (value)) \
92 : (value))
94 /* Events */
96 /*! Called when qemu shutdown is requested. */
97 void replay_shutdown_request(void);
98 /*! Should be called at check points in the execution.
99 These check points are skipped, if they were not met.
100 Saves checkpoint in the SAVE mode and validates in the PLAY mode.
101 Returns 0 in PLAY mode if checkpoint was not found.
102 Returns 1 in all other cases. */
103 bool replay_checkpoint(ReplayCheckpoint checkpoint);
105 /* Asynchronous events queue */
107 /*! Disables storing events in the queue */
108 void replay_disable_events(void);
109 /*! Returns true when saving events is enabled */
110 bool replay_events_enabled(void);
111 /*! Adds bottom half event to the queue */
112 void replay_bh_schedule_event(QEMUBH *bh);
113 /*! Adds input event to the queue */
114 void replay_input_event(QemuConsole *src, InputEvent *evt);
115 /*! Adds input sync event to the queue */
116 void replay_input_sync_event(void);
118 /* Character device */
120 /*! Registers char driver to save it's events */
121 void replay_register_char_driver(struct CharDriverState *chr);
122 /*! Saves write to char device event to the log */
123 void replay_chr_be_write(struct CharDriverState *s, uint8_t *buf, int len);
124 /*! Writes char write return value to the replay log. */
125 void replay_char_write_event_save(int res, int offset);
126 /*! Reads char write return value from the replay log. */
127 void replay_char_write_event_load(int *res, int *offset);
128 /*! Reads information about read_all character event. */
129 int replay_char_read_all_load(uint8_t *buf);
130 /*! Writes character read_all error code into the replay log. */
131 void replay_char_read_all_save_error(int res);
132 /*! Writes character read_all execution result into the replay log. */
133 void replay_char_read_all_save_buf(uint8_t *buf, int offset);
135 #endif