xref: /qemu/include/sysemu/cpus.h (revision 922d42bb)
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 /* Create a dummy vcpu for CpusAccel->create_vcpu_thread */
29 void dummy_start_vcpu_thread(CPUState *);
30 
31 /* interface available for cpus accelerator threads */
32 
33 /* For temporary buffers for forming a name */
34 #define VCPU_THREAD_NAME_SIZE 16
35 
36 void cpus_kick_thread(CPUState *cpu);
37 bool cpu_work_list_empty(CPUState *cpu);
38 bool cpu_thread_is_idle(CPUState *cpu);
39 bool all_cpu_threads_idle(void);
40 bool cpu_can_run(CPUState *cpu);
41 void qemu_wait_io_event_common(CPUState *cpu);
42 void qemu_wait_io_event(CPUState *cpu);
43 void cpu_thread_signal_created(CPUState *cpu);
44 void cpu_thread_signal_destroyed(CPUState *cpu);
45 void cpu_handle_guest_debug(CPUState *cpu);
46 
47 /* end interface for cpus accelerator threads */
48 
49 bool qemu_in_vcpu_thread(void);
50 void qemu_init_cpu_loop(void);
51 void resume_all_vcpus(void);
52 void pause_all_vcpus(void);
53 void cpu_stop_current(void);
54 
55 extern int icount_align_option;
56 
57 /* Unblock cpu */
58 void qemu_cpu_kick_self(void);
59 
60 void cpu_synchronize_all_states(void);
61 void cpu_synchronize_all_post_reset(void);
62 void cpu_synchronize_all_post_init(void);
63 void cpu_synchronize_all_pre_loadvm(void);
64 
65 #ifndef CONFIG_USER_ONLY
66 /* vl.c */
67 /* *-user doesn't have configurable SMP topology */
68 extern int smp_cores;
69 extern int smp_threads;
70 #endif
71 
72 void list_cpus(const char *optarg);
73 
74 #endif
75