gic.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * ARM Generic Interrupt Controller (GIC) specific defines
  4. */
  5. #ifndef SELFTEST_KVM_GIC_H
  6. #define SELFTEST_KVM_GIC_H
  7. #include <asm/kvm.h>
  8. enum gic_type {
  9. GIC_V3,
  10. GIC_TYPE_MAX,
  11. };
  12. /*
  13. * Note that the redistributor frames are at the end, as the range scales
  14. * with the number of vCPUs in the VM.
  15. */
  16. #define GITS_BASE_GPA 0x8000000ULL
  17. #define GICD_BASE_GPA (GITS_BASE_GPA + KVM_VGIC_V3_ITS_SIZE)
  18. #define GICR_BASE_GPA (GICD_BASE_GPA + KVM_VGIC_V3_DIST_SIZE)
  19. /* The GIC is identity-mapped into the guest at the time of setup. */
  20. #define GITS_BASE_GVA ((volatile void *)GITS_BASE_GPA)
  21. #define GICD_BASE_GVA ((volatile void *)GICD_BASE_GPA)
  22. #define GICR_BASE_GVA ((volatile void *)GICR_BASE_GPA)
  23. #define MIN_SGI 0
  24. #define MIN_PPI 16
  25. #define MIN_SPI 32
  26. #define MAX_SPI 1019
  27. #define IAR_SPURIOUS 1023
  28. #define INTID_IS_SGI(intid) (0 <= (intid) && (intid) < MIN_PPI)
  29. #define INTID_IS_PPI(intid) (MIN_PPI <= (intid) && (intid) < MIN_SPI)
  30. #define INTID_IS_SPI(intid) (MIN_SPI <= (intid) && (intid) <= MAX_SPI)
  31. void gic_init(enum gic_type type, unsigned int nr_cpus);
  32. void gic_irq_enable(unsigned int intid);
  33. void gic_irq_disable(unsigned int intid);
  34. unsigned int gic_get_and_ack_irq(void);
  35. void gic_set_eoi(unsigned int intid);
  36. void gic_set_dir(unsigned int intid);
  37. /*
  38. * Sets the EOI mode. When split is false, EOI just drops the priority. When
  39. * split is true, EOI drops the priority and deactivates the interrupt.
  40. */
  41. void gic_set_eoi_split(bool split);
  42. void gic_set_priority_mask(uint64_t mask);
  43. void gic_set_priority(uint32_t intid, uint32_t prio);
  44. void gic_irq_set_active(unsigned int intid);
  45. void gic_irq_clear_active(unsigned int intid);
  46. bool gic_irq_get_active(unsigned int intid);
  47. void gic_irq_set_pending(unsigned int intid);
  48. void gic_irq_clear_pending(unsigned int intid);
  49. bool gic_irq_get_pending(unsigned int intid);
  50. void gic_irq_set_config(unsigned int intid, bool is_edge);
  51. void gic_rdist_enable_lpis(vm_paddr_t cfg_table, size_t cfg_table_size,
  52. vm_paddr_t pend_table);
  53. #endif /* SELFTEST_KVM_GIC_H */