]> git.proxmox.com Git - mirror_qemu.git/blame - replay/replay-internal.h
replay: ptimer
[mirror_qemu.git] / replay / replay-internal.h
CommitLineData
c92079f4
PD
1#ifndef REPLAY_INTERNAL_H
2#define REPLAY_INTERNAL_H
3
4/*
5 * replay-internal.h
6 *
7 * Copyright (c) 2010-2015 Institute for System Programming
8 * of the Russian Academy of Sciences.
9 *
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.
12 *
13 */
14
15#include <stdio.h>
16
26bc60ac
PD
17enum ReplayEvents {
18 /* for instruction event */
19 EVENT_INSTRUCTION,
6f060969
PD
20 /* for software interrupt */
21 EVENT_INTERRUPT,
22 /* for emulated exceptions */
23 EVENT_EXCEPTION,
c0c071d0
PD
24 /* for async events */
25 EVENT_ASYNC,
b60c48a7
PD
26 /* for shutdown request */
27 EVENT_SHUTDOWN,
8eda206e
PD
28 /* for clock read/writes */
29 /* some of greater codes are reserved for clocks */
30 EVENT_CLOCK,
31 EVENT_CLOCK_LAST = EVENT_CLOCK + REPLAY_CLOCK_COUNT - 1,
8bd7f71d
PD
32 /* for checkpoint event */
33 /* some of greater codes are reserved for checkpoints */
34 EVENT_CHECKPOINT,
35 EVENT_CHECKPOINT_LAST = EVENT_CHECKPOINT + CHECKPOINT_COUNT - 1,
26bc60ac
PD
36 EVENT_COUNT
37};
38
c0c071d0
PD
39/* Asynchronous events IDs */
40
41enum ReplayAsyncEventKind {
8a354bd9 42 REPLAY_ASYNC_EVENT_BH,
c0c071d0
PD
43 REPLAY_ASYNC_COUNT
44};
45
46typedef enum ReplayAsyncEventKind ReplayAsyncEventKind;
47
26bc60ac 48typedef struct ReplayState {
8eda206e
PD
49 /*! Cached clock values. */
50 int64_t cached_clock[REPLAY_CLOCK_COUNT];
26bc60ac
PD
51 /*! Current step - number of processed instructions and timer events. */
52 uint64_t current_step;
53 /*! Number of instructions to be executed before other events happen. */
54 int instructions_count;
55} ReplayState;
56extern ReplayState replay_state;
57
c92079f4
PD
58extern unsigned int replay_data_kind;
59
60/* File for replay writing */
61extern FILE *replay_file;
62
63void replay_put_byte(uint8_t byte);
64void replay_put_event(uint8_t event);
65void replay_put_word(uint16_t word);
66void replay_put_dword(uint32_t dword);
67void replay_put_qword(int64_t qword);
68void replay_put_array(const uint8_t *buf, size_t size);
69
70uint8_t replay_get_byte(void);
71uint16_t replay_get_word(void);
72uint32_t replay_get_dword(void);
73int64_t replay_get_qword(void);
74void replay_get_array(uint8_t *buf, size_t *size);
75void replay_get_array_alloc(uint8_t **buf, size_t *size);
76
c16861ef
PD
77/* Mutex functions for protecting replay log file */
78
79void replay_mutex_init(void);
80void replay_mutex_destroy(void);
81void replay_mutex_lock(void);
82void replay_mutex_unlock(void);
83
c92079f4
PD
84/*! Checks error status of the file. */
85void replay_check_error(void);
86
87/*! Finishes processing of the replayed event and fetches
88 the next event from the log. */
89void replay_finish_event(void);
90/*! Reads data type from the file and stores it in the
91 replay_data_kind variable. */
92void replay_fetch_data_kind(void);
93
26bc60ac
PD
94/*! Saves queued events (like instructions and sound). */
95void replay_save_instructions(void);
96
97/*! Skips async events until some sync event will be found.
98 \return true, if event was found */
99bool replay_next_event_is(int event);
100
8eda206e
PD
101/*! Reads next clock value from the file.
102 If clock kind read from the file is different from the parameter,
103 the value is not used. */
104void replay_read_next_clock(unsigned int kind);
105
c0c071d0
PD
106/* Asynchronous events queue */
107
108/*! Initializes events' processing internals */
109void replay_init_events(void);
110/*! Clears internal data structures for events handling */
111void replay_finish_events(void);
112/*! Enables storing events in the queue */
113void replay_enable_events(void);
114/*! Flushes events queue */
115void replay_flush_events(void);
116/*! Clears events list before loading new VM state */
117void replay_clear_events(void);
118/*! Returns true if there are any unsaved events in the queue */
119bool replay_has_events(void);
120/*! Saves events from queue into the file */
121void replay_save_events(int checkpoint);
122/*! Read events from the file into the input queue */
123void replay_read_events(int checkpoint);
124
c92079f4 125#endif