include/exec: Split out icount.h

Split icount stuff from system/cpu-timers.h.
There are 17 files which only require icount.h, 7 that only
require cpu-timers.h, and 7 that require both.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2025-03-14 12:57:31 -07:00
parent 31030cf0ff
commit 161f5bc8e9
26 changed files with 92 additions and 75 deletions

View file

@ -15,64 +15,6 @@
/* init the whole cpu timers API, including icount, ticks, and cpu_throttle */
void cpu_timers_init(void);
/* icount - Instruction Counter API */
/**
* ICountMode: icount enablement state:
*
* @ICOUNT_DISABLED: Disabled - Do not count executed instructions.
* @ICOUNT_PRECISE: Enabled - Fixed conversion of insn to ns via "shift" option
* @ICOUNT_ADAPTATIVE: Enabled - Runtime adaptive algorithm to compute shift
*/
typedef enum {
ICOUNT_DISABLED = 0,
ICOUNT_PRECISE,
ICOUNT_ADAPTATIVE,
} ICountMode;
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
extern ICountMode use_icount;
#define icount_enabled() (use_icount)
#else
#define icount_enabled() ICOUNT_DISABLED
#endif
/*
* Update the icount with the executed instructions. Called by
* cpus-tcg vCPU thread so the main-loop can see time has moved forward.
*/
void icount_update(CPUState *cpu);
/* get raw icount value */
int64_t icount_get_raw(void);
/* return the virtual CPU time in ns, based on the instruction counter. */
int64_t icount_get(void);
/*
* convert an instruction counter value to ns, based on the icount shift.
* This shift is set as a fixed value with the icount "shift" option
* (precise mode), or it is constantly approximated and corrected at
* runtime in adaptive mode.
*/
int64_t icount_to_ns(int64_t icount);
/**
* icount_configure: configure the icount options, including "shift"
* @opts: Options to parse
* @errp: pointer to a NULL-initialized error object
*
* Return: true on success, else false setting @errp with error
*/
bool icount_configure(QemuOpts *opts, Error **errp);
/* used by tcg vcpu thread to calc icount budget */
int64_t icount_round(int64_t count);
/* if the CPUs are idle, start accounting real time to virtual clock. */
void icount_start_warp_timer(void);
void icount_account_warp_timer(void);
void icount_notify_exit(void);
/*
* CPU Ticks and Clock
*/