arm_gicv3_its_common.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * ITS support for ARM GICv3
  3. *
  4. * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  5. * Written by Pavel Fedin
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef QEMU_ARM_GICV3_ITS_COMMON_H
  21. #define QEMU_ARM_GICV3_ITS_COMMON_H
  22. #include "hw/sysbus.h"
  23. #include "hw/intc/arm_gicv3_common.h"
  24. #include "qom/object.h"
  25. #define TYPE_ARM_GICV3_ITS "arm-gicv3-its"
  26. #define ITS_CONTROL_SIZE 0x10000
  27. #define ITS_TRANS_SIZE 0x10000
  28. #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE)
  29. #define GITS_CTLR 0x0
  30. #define GITS_IIDR 0x4
  31. #define GITS_TYPER 0x8
  32. #define GITS_CBASER 0x80
  33. #define GITS_CWRITER 0x88
  34. #define GITS_CREADR 0x90
  35. #define GITS_BASER 0x100
  36. #define GITS_TRANSLATER 0x0040
  37. typedef struct {
  38. bool indirect;
  39. uint16_t entry_sz;
  40. uint32_t page_sz;
  41. uint32_t num_entries;
  42. uint64_t base_addr;
  43. } TableDesc;
  44. typedef struct {
  45. uint32_t num_entries;
  46. uint64_t base_addr;
  47. } CmdQDesc;
  48. struct GICv3ITSState {
  49. SysBusDevice parent_obj;
  50. MemoryRegion iomem_main;
  51. MemoryRegion iomem_its_cntrl;
  52. MemoryRegion iomem_its_translation;
  53. GICv3State *gicv3;
  54. int dev_fd; /* kvm device fd if backed by kvm vgic support */
  55. uint64_t gits_translater_gpa;
  56. bool translater_gpa_known;
  57. uint8_t itt_entry_size;
  58. /* Registers */
  59. uint32_t ctlr;
  60. uint32_t iidr;
  61. uint64_t typer;
  62. uint64_t cbaser;
  63. uint64_t cwriter;
  64. uint64_t creadr;
  65. uint64_t baser[8];
  66. TableDesc dt;
  67. TableDesc ct;
  68. TableDesc vpet;
  69. CmdQDesc cq;
  70. Error *migration_blocker;
  71. };
  72. typedef struct GICv3ITSState GICv3ITSState;
  73. void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
  74. const MemoryRegionOps *tops);
  75. /*
  76. * The ITS should call this when it is realized to add itself
  77. * to its GIC's list of connected ITSes.
  78. */
  79. static inline void gicv3_add_its(GICv3State *s, DeviceState *its)
  80. {
  81. g_ptr_array_add(s->itslist, its);
  82. }
  83. /*
  84. * The ITS can use this for operations that must be performed on
  85. * every ITS connected to the same GIC that it is
  86. */
  87. static inline void gicv3_foreach_its(GICv3State *s, GFunc func, void *opaque)
  88. {
  89. g_ptr_array_foreach(s->itslist, func, opaque);
  90. }
  91. #define TYPE_ARM_GICV3_ITS_COMMON "arm-gicv3-its-common"
  92. typedef struct GICv3ITSCommonClass GICv3ITSCommonClass;
  93. DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSCommonClass,
  94. ARM_GICV3_ITS_COMMON, TYPE_ARM_GICV3_ITS_COMMON)
  95. struct GICv3ITSCommonClass {
  96. /*< private >*/
  97. SysBusDeviceClass parent_class;
  98. /*< public >*/
  99. int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid);
  100. void (*pre_save)(GICv3ITSState *s);
  101. void (*post_load)(GICv3ITSState *s);
  102. };
  103. /**
  104. * its_class_name:
  105. *
  106. * Return the ITS class name to use depending on whether KVM acceleration
  107. * and KVM CAP_SIGNAL_MSI are supported
  108. *
  109. * Returns: class name to use or NULL
  110. */
  111. const char *its_class_name(void);
  112. #endif