xref: /qemu/include/system/accel-ops.h (revision 0f66536a012b2d1b02818bbb2d24485205fc2f64)
1 /*
2  * Accelerator OPS, used for cpus.c module
3  *
4  * Copyright 2021 SUSE LLC
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef ACCEL_OPS_H
11 #define ACCEL_OPS_H
12 
13 #include "exec/vaddr.h"
14 #include "qom/object.h"
15 
16 #define ACCEL_OPS_SUFFIX "-ops"
17 #define TYPE_ACCEL_OPS "accel" ACCEL_OPS_SUFFIX
18 #define ACCEL_OPS_NAME(name) (name "-" TYPE_ACCEL_OPS)
19 
20 DECLARE_CLASS_CHECKERS(AccelOpsClass, ACCEL_OPS, TYPE_ACCEL_OPS)
21 
22 /**
23  * struct AccelOpsClass - accelerator interfaces
24  *
25  * This structure is used to abstract accelerator differences from the
26  * core CPU code. Not all have to be implemented.
27  */
28 struct AccelOpsClass {
29     /*< private >*/
30     ObjectClass parent_class;
31     /*< public >*/
32 
33     /* initialization function called when accel is chosen */
34     void (*ops_init)(AccelOpsClass *ops);
35 
36     bool (*cpus_are_resettable)(void);
37     void (*cpu_reset_hold)(CPUState *cpu);
38 
39     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
40     void (*kick_vcpu_thread)(CPUState *cpu);
41     bool (*cpu_thread_is_idle)(CPUState *cpu);
42 
43     void (*synchronize_post_reset)(CPUState *cpu);
44     void (*synchronize_post_init)(CPUState *cpu);
45     void (*synchronize_state)(CPUState *cpu);
46     void (*synchronize_pre_loadvm)(CPUState *cpu);
47     void (*synchronize_pre_resume)(bool step_pending);
48 
49     void (*handle_interrupt)(CPUState *cpu, int mask);
50 
51     /**
52      * @get_virtual_clock: fetch virtual clock
53      * @set_virtual_clock: set virtual clock
54      *
55      * These allow the timer subsystem to defer to the accelerator to
56      * fetch time. The set function is needed if the accelerator wants
57      * to track the changes to time as the timer is warped through
58      * various timer events.
59      */
60     int64_t (*get_virtual_clock)(void);
61     void (*set_virtual_clock)(int64_t time);
62 
63     int64_t (*get_elapsed_ticks)(void);
64 
65     /* gdbstub hooks */
66     bool (*supports_guest_debug)(void);
67     int (*update_guest_debug)(CPUState *cpu);
68     int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
69     int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
70     void (*remove_all_breakpoints)(CPUState *cpu);
71 };
72 
73 #endif /* ACCEL_OPS_H */
74