Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / include / hw / intc / arm_gicv3_its_common.h
blob7dc712b38d24f1194bd564bf9c254398bd44bd25
1 /*
2 * ITS support for ARM GICv3
4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
5 * Written by Pavel Fedin
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.
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.
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/>.
21 #ifndef QEMU_ARM_GICV3_ITS_COMMON_H
22 #define QEMU_ARM_GICV3_ITS_COMMON_H
24 #include "hw/sysbus.h"
25 #include "hw/intc/arm_gicv3_common.h"
26 #include "qom/object.h"
28 #define TYPE_ARM_GICV3_ITS "arm-gicv3-its"
30 #define ITS_CONTROL_SIZE 0x10000
31 #define ITS_TRANS_SIZE 0x10000
32 #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE)
34 #define GITS_CTLR 0x0
35 #define GITS_IIDR 0x4
36 #define GITS_TYPER 0x8
37 #define GITS_CBASER 0x80
38 #define GITS_CWRITER 0x88
39 #define GITS_CREADR 0x90
40 #define GITS_BASER 0x100
42 #define GITS_TRANSLATER 0x0040
44 typedef struct {
45 bool indirect;
46 uint16_t entry_sz;
47 uint32_t page_sz;
48 uint32_t num_entries;
49 uint64_t base_addr;
50 } TableDesc;
52 typedef struct {
53 uint32_t num_entries;
54 uint64_t base_addr;
55 } CmdQDesc;
57 struct GICv3ITSState {
58 SysBusDevice parent_obj;
60 MemoryRegion iomem_main;
61 MemoryRegion iomem_its_cntrl;
62 MemoryRegion iomem_its_translation;
64 GICv3State *gicv3;
66 int dev_fd; /* kvm device fd if backed by kvm vgic support */
67 uint64_t gits_translater_gpa;
68 bool translater_gpa_known;
70 /* Registers */
71 uint32_t ctlr;
72 uint32_t iidr;
73 uint64_t typer;
74 uint64_t cbaser;
75 uint64_t cwriter;
76 uint64_t creadr;
77 uint64_t baser[8];
79 TableDesc dt;
80 TableDesc ct;
81 TableDesc vpet;
82 CmdQDesc cq;
84 Error *migration_blocker;
87 typedef struct GICv3ITSState GICv3ITSState;
89 void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
90 const MemoryRegionOps *tops);
93 * The ITS should call this when it is realized to add itself
94 * to its GIC's list of connected ITSes.
96 static inline void gicv3_add_its(GICv3State *s, DeviceState *its)
98 g_ptr_array_add(s->itslist, its);
102 * The ITS can use this for operations that must be performed on
103 * every ITS connected to the same GIC that it is
105 static inline void gicv3_foreach_its(GICv3State *s, GFunc func, void *opaque)
107 g_ptr_array_foreach(s->itslist, func, opaque);
110 #define TYPE_ARM_GICV3_ITS_COMMON "arm-gicv3-its-common"
111 typedef struct GICv3ITSCommonClass GICv3ITSCommonClass;
112 DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSCommonClass,
113 ARM_GICV3_ITS_COMMON, TYPE_ARM_GICV3_ITS_COMMON)
115 struct GICv3ITSCommonClass {
116 /*< private >*/
117 SysBusDeviceClass parent_class;
118 /*< public >*/
120 int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid);
121 void (*pre_save)(GICv3ITSState *s);
122 void (*post_load)(GICv3ITSState *s);
126 * its_class_name:
128 * Return the ITS class name to use depending on whether KVM acceleration
129 * and KVM CAP_SIGNAL_MSI are supported
131 * Returns: class name to use or NULL
133 const char *its_class_name(void);
135 #endif