xref: /openbmc/qemu/include/sysemu/accel-ops.h (revision 7d87775f)
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/cpu-common.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 typedef struct AccelOpsClass AccelOpsClass;
21 DECLARE_CLASS_CHECKERS(AccelOpsClass, ACCEL_OPS, TYPE_ACCEL_OPS)
22 
23 /**
24  * struct AccelOpsClass - accelerator interfaces
25  *
26  * This structure is used to abstract accelerator differences from the
27  * core CPU code. Not all have to be implemented.
28  */
29 struct AccelOpsClass {
30     /*< private >*/
31     ObjectClass parent_class;
32     /*< public >*/
33 
34     /* initialization function called when accel is chosen */
35     void (*ops_init)(AccelOpsClass *ops);
36 
37     bool (*cpus_are_resettable)(void);
38     void (*cpu_reset_hold)(CPUState *cpu);
39 
40     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
41     void (*kick_vcpu_thread)(CPUState *cpu);
42     bool (*cpu_thread_is_idle)(CPUState *cpu);
43 
44     void (*synchronize_post_reset)(CPUState *cpu);
45     void (*synchronize_post_init)(CPUState *cpu);
46     void (*synchronize_state)(CPUState *cpu);
47     void (*synchronize_pre_loadvm)(CPUState *cpu);
48     void (*synchronize_pre_resume)(bool step_pending);
49 
50     void (*handle_interrupt)(CPUState *cpu, int mask);
51 
52     /**
53      * @get_virtual_clock: fetch virtual clock
54      * @set_virtual_clock: set virtual clock
55      *
56      * These allow the timer subsystem to defer to the accelerator to
57      * fetch time. The set function is needed if the accelerator wants
58      * to track the changes to time as the timer is warped through
59      * various timer events.
60      */
61     int64_t (*get_virtual_clock)(void);
62     void (*set_virtual_clock)(int64_t time);
63 
64     int64_t (*get_elapsed_ticks)(void);
65 
66     /* gdbstub hooks */
67     bool (*supports_guest_debug)(void);
68     int (*update_guest_debug)(CPUState *cpu);
69     int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
70     int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
71     void (*remove_all_breakpoints)(CPUState *cpu);
72 };
73 
74 #endif /* ACCEL_OPS_H */
75