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