2
0

accel-ops.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef ACCEL_OPS_H
  10. #define ACCEL_OPS_H
  11. #include "exec/vaddr.h"
  12. #include "qom/object.h"
  13. #define ACCEL_OPS_SUFFIX "-ops"
  14. #define TYPE_ACCEL_OPS "accel" ACCEL_OPS_SUFFIX
  15. #define ACCEL_OPS_NAME(name) (name "-" TYPE_ACCEL_OPS)
  16. DECLARE_CLASS_CHECKERS(AccelOpsClass, ACCEL_OPS, TYPE_ACCEL_OPS)
  17. /**
  18. * struct AccelOpsClass - accelerator interfaces
  19. *
  20. * This structure is used to abstract accelerator differences from the
  21. * core CPU code. Not all have to be implemented.
  22. */
  23. struct AccelOpsClass {
  24. /*< private >*/
  25. ObjectClass parent_class;
  26. /*< public >*/
  27. /* initialization function called when accel is chosen */
  28. void (*ops_init)(AccelOpsClass *ops);
  29. bool (*cpus_are_resettable)(void);
  30. void (*cpu_reset_hold)(CPUState *cpu);
  31. void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
  32. void (*kick_vcpu_thread)(CPUState *cpu);
  33. bool (*cpu_thread_is_idle)(CPUState *cpu);
  34. void (*synchronize_post_reset)(CPUState *cpu);
  35. void (*synchronize_post_init)(CPUState *cpu);
  36. void (*synchronize_state)(CPUState *cpu);
  37. void (*synchronize_pre_loadvm)(CPUState *cpu);
  38. void (*synchronize_pre_resume)(bool step_pending);
  39. void (*handle_interrupt)(CPUState *cpu, int mask);
  40. /**
  41. * @get_virtual_clock: fetch virtual clock
  42. * @set_virtual_clock: set virtual clock
  43. *
  44. * These allow the timer subsystem to defer to the accelerator to
  45. * fetch time. The set function is needed if the accelerator wants
  46. * to track the changes to time as the timer is warped through
  47. * various timer events.
  48. */
  49. int64_t (*get_virtual_clock)(void);
  50. void (*set_virtual_clock)(int64_t time);
  51. int64_t (*get_elapsed_ticks)(void);
  52. /* gdbstub hooks */
  53. bool (*supports_guest_debug)(void);
  54. int (*update_guest_debug)(CPUState *cpu);
  55. int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
  56. int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
  57. void (*remove_all_breakpoints)(CPUState *cpu);
  58. };
  59. #endif /* ACCEL_OPS_H */