xref: /qemu/include/sysemu/cpus.h (revision 55567891)
1 #ifndef QEMU_CPUS_H
2 #define QEMU_CPUS_H
3 
4 #include "qemu/timer.h"
5 
6 /* cpus.c */
7 
8 /* CPU execution threads */
9 
10 typedef struct CpusAccel {
11     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY */
12     void (*kick_vcpu_thread)(CPUState *cpu);
13 
14     void (*synchronize_post_reset)(CPUState *cpu);
15     void (*synchronize_post_init)(CPUState *cpu);
16     void (*synchronize_state)(CPUState *cpu);
17     void (*synchronize_pre_loadvm)(CPUState *cpu);
18 
19     void (*handle_interrupt)(CPUState *cpu, int mask);
20 
21     int64_t (*get_virtual_clock)(void);
22     int64_t (*get_elapsed_ticks)(void);
23 } CpusAccel;
24 
25 /* register accel-specific cpus interface implementation */
26 void cpus_register_accel(const CpusAccel *i);
27 
28 /* interface available for cpus accelerator threads */
29 
30 /* For temporary buffers for forming a name */
31 #define VCPU_THREAD_NAME_SIZE 16
32 
33 void cpus_kick_thread(CPUState *cpu);
34 bool cpu_work_list_empty(CPUState *cpu);
35 bool cpu_thread_is_idle(CPUState *cpu);
36 bool all_cpu_threads_idle(void);
37 bool cpu_can_run(CPUState *cpu);
38 void qemu_wait_io_event_common(CPUState *cpu);
39 void qemu_wait_io_event(CPUState *cpu);
40 void cpu_thread_signal_created(CPUState *cpu);
41 void cpu_thread_signal_destroyed(CPUState *cpu);
42 void cpu_handle_guest_debug(CPUState *cpu);
43 
44 /* end interface for cpus accelerator threads */
45 
46 bool qemu_in_vcpu_thread(void);
47 void qemu_init_cpu_loop(void);
48 void resume_all_vcpus(void);
49 void pause_all_vcpus(void);
50 void cpu_stop_current(void);
51 
52 extern int icount_align_option;
53 
54 /* Unblock cpu */
55 void qemu_cpu_kick_self(void);
56 
57 void cpu_synchronize_all_states(void);
58 void cpu_synchronize_all_post_reset(void);
59 void cpu_synchronize_all_post_init(void);
60 void cpu_synchronize_all_pre_loadvm(void);
61 
62 #ifndef CONFIG_USER_ONLY
63 /* vl.c */
64 /* *-user doesn't have configurable SMP topology */
65 extern int smp_cores;
66 extern int smp_threads;
67 #endif
68 
69 void list_cpus(const char *optarg);
70 
71 #endif
72