xref: /qemu/hw/arm/smmuv3.c (revision 10a83cb9887eddb1b504ecf3b189159db949178e)
1*10a83cb9SPrem Mallappa /*
2*10a83cb9SPrem Mallappa  * Copyright (C) 2014-2016 Broadcom Corporation
3*10a83cb9SPrem Mallappa  * Copyright (c) 2017 Red Hat, Inc.
4*10a83cb9SPrem Mallappa  * Written by Prem Mallappa, Eric Auger
5*10a83cb9SPrem Mallappa  *
6*10a83cb9SPrem Mallappa  * This program is free software; you can redistribute it and/or modify
7*10a83cb9SPrem Mallappa  * it under the terms of the GNU General Public License version 2 as
8*10a83cb9SPrem Mallappa  * published by the Free Software Foundation.
9*10a83cb9SPrem Mallappa  *
10*10a83cb9SPrem Mallappa  * This program is distributed in the hope that it will be useful,
11*10a83cb9SPrem Mallappa  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*10a83cb9SPrem Mallappa  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*10a83cb9SPrem Mallappa  * GNU General Public License for more details.
14*10a83cb9SPrem Mallappa  *
15*10a83cb9SPrem Mallappa  * You should have received a copy of the GNU General Public License along
16*10a83cb9SPrem Mallappa  * with this program; if not, see <http://www.gnu.org/licenses/>.
17*10a83cb9SPrem Mallappa  */
18*10a83cb9SPrem Mallappa 
19*10a83cb9SPrem Mallappa #include "qemu/osdep.h"
20*10a83cb9SPrem Mallappa #include "hw/boards.h"
21*10a83cb9SPrem Mallappa #include "sysemu/sysemu.h"
22*10a83cb9SPrem Mallappa #include "hw/sysbus.h"
23*10a83cb9SPrem Mallappa #include "hw/qdev-core.h"
24*10a83cb9SPrem Mallappa #include "hw/pci/pci.h"
25*10a83cb9SPrem Mallappa #include "exec/address-spaces.h"
26*10a83cb9SPrem Mallappa #include "trace.h"
27*10a83cb9SPrem Mallappa #include "qemu/log.h"
28*10a83cb9SPrem Mallappa #include "qemu/error-report.h"
29*10a83cb9SPrem Mallappa #include "qapi/error.h"
30*10a83cb9SPrem Mallappa 
31*10a83cb9SPrem Mallappa #include "hw/arm/smmuv3.h"
32*10a83cb9SPrem Mallappa #include "smmuv3-internal.h"
33*10a83cb9SPrem Mallappa 
34*10a83cb9SPrem Mallappa static void smmuv3_init_regs(SMMUv3State *s)
35*10a83cb9SPrem Mallappa {
36*10a83cb9SPrem Mallappa     /**
37*10a83cb9SPrem Mallappa      * IDR0: stage1 only, AArch64 only, coherent access, 16b ASID,
38*10a83cb9SPrem Mallappa      *       multi-level stream table
39*10a83cb9SPrem Mallappa      */
40*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); /* stage 1 supported */
41*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */
42*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */
43*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */
44*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */
45*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */
46*10a83cb9SPrem Mallappa     /* terminated transaction will always be aborted/error returned */
47*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TERM_MODEL, 1);
48*10a83cb9SPrem Mallappa     /* 2-level stream table supported */
49*10a83cb9SPrem Mallappa     s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STLEVEL, 1);
50*10a83cb9SPrem Mallappa 
51*10a83cb9SPrem Mallappa     s->idr[1] = FIELD_DP32(s->idr[1], IDR1, SIDSIZE, SMMU_IDR1_SIDSIZE);
52*10a83cb9SPrem Mallappa     s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS);
53*10a83cb9SPrem Mallappa     s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS,   SMMU_CMDQS);
54*10a83cb9SPrem Mallappa 
55*10a83cb9SPrem Mallappa    /* 4K and 64K granule support */
56*10a83cb9SPrem Mallappa     s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1);
57*10a83cb9SPrem Mallappa     s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1);
58*10a83cb9SPrem Mallappa     s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
59*10a83cb9SPrem Mallappa 
60*10a83cb9SPrem Mallappa     s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS);
61*10a83cb9SPrem Mallappa     s->cmdq.prod = 0;
62*10a83cb9SPrem Mallappa     s->cmdq.cons = 0;
63*10a83cb9SPrem Mallappa     s->cmdq.entry_size = sizeof(struct Cmd);
64*10a83cb9SPrem Mallappa     s->eventq.base = deposit64(s->eventq.base, 0, 5, SMMU_EVENTQS);
65*10a83cb9SPrem Mallappa     s->eventq.prod = 0;
66*10a83cb9SPrem Mallappa     s->eventq.cons = 0;
67*10a83cb9SPrem Mallappa     s->eventq.entry_size = sizeof(struct Evt);
68*10a83cb9SPrem Mallappa 
69*10a83cb9SPrem Mallappa     s->features = 0;
70*10a83cb9SPrem Mallappa     s->sid_split = 0;
71*10a83cb9SPrem Mallappa }
72*10a83cb9SPrem Mallappa 
73*10a83cb9SPrem Mallappa static MemTxResult smmu_write_mmio(void *opaque, hwaddr offset, uint64_t data,
74*10a83cb9SPrem Mallappa                                    unsigned size, MemTxAttrs attrs)
75*10a83cb9SPrem Mallappa {
76*10a83cb9SPrem Mallappa     /* not yet implemented */
77*10a83cb9SPrem Mallappa     return MEMTX_ERROR;
78*10a83cb9SPrem Mallappa }
79*10a83cb9SPrem Mallappa 
80*10a83cb9SPrem Mallappa static MemTxResult smmu_readll(SMMUv3State *s, hwaddr offset,
81*10a83cb9SPrem Mallappa                                uint64_t *data, MemTxAttrs attrs)
82*10a83cb9SPrem Mallappa {
83*10a83cb9SPrem Mallappa     switch (offset) {
84*10a83cb9SPrem Mallappa     case A_GERROR_IRQ_CFG0:
85*10a83cb9SPrem Mallappa         *data = s->gerror_irq_cfg0;
86*10a83cb9SPrem Mallappa         return MEMTX_OK;
87*10a83cb9SPrem Mallappa     case A_STRTAB_BASE:
88*10a83cb9SPrem Mallappa         *data = s->strtab_base;
89*10a83cb9SPrem Mallappa         return MEMTX_OK;
90*10a83cb9SPrem Mallappa     case A_CMDQ_BASE:
91*10a83cb9SPrem Mallappa         *data = s->cmdq.base;
92*10a83cb9SPrem Mallappa         return MEMTX_OK;
93*10a83cb9SPrem Mallappa     case A_EVENTQ_BASE:
94*10a83cb9SPrem Mallappa         *data = s->eventq.base;
95*10a83cb9SPrem Mallappa         return MEMTX_OK;
96*10a83cb9SPrem Mallappa     default:
97*10a83cb9SPrem Mallappa         *data = 0;
98*10a83cb9SPrem Mallappa         qemu_log_mask(LOG_UNIMP,
99*10a83cb9SPrem Mallappa                       "%s Unexpected 64-bit access to 0x%"PRIx64" (RAZ)\n",
100*10a83cb9SPrem Mallappa                       __func__, offset);
101*10a83cb9SPrem Mallappa         return MEMTX_OK;
102*10a83cb9SPrem Mallappa     }
103*10a83cb9SPrem Mallappa }
104*10a83cb9SPrem Mallappa 
105*10a83cb9SPrem Mallappa static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset,
106*10a83cb9SPrem Mallappa                               uint64_t *data, MemTxAttrs attrs)
107*10a83cb9SPrem Mallappa {
108*10a83cb9SPrem Mallappa     switch (offset) {
109*10a83cb9SPrem Mallappa     case A_IDREGS ... A_IDREGS + 0x1f:
110*10a83cb9SPrem Mallappa         *data = smmuv3_idreg(offset - A_IDREGS);
111*10a83cb9SPrem Mallappa         return MEMTX_OK;
112*10a83cb9SPrem Mallappa     case A_IDR0 ... A_IDR5:
113*10a83cb9SPrem Mallappa         *data = s->idr[(offset - A_IDR0) / 4];
114*10a83cb9SPrem Mallappa         return MEMTX_OK;
115*10a83cb9SPrem Mallappa     case A_IIDR:
116*10a83cb9SPrem Mallappa         *data = s->iidr;
117*10a83cb9SPrem Mallappa         return MEMTX_OK;
118*10a83cb9SPrem Mallappa     case A_CR0:
119*10a83cb9SPrem Mallappa         *data = s->cr[0];
120*10a83cb9SPrem Mallappa         return MEMTX_OK;
121*10a83cb9SPrem Mallappa     case A_CR0ACK:
122*10a83cb9SPrem Mallappa         *data = s->cr0ack;
123*10a83cb9SPrem Mallappa         return MEMTX_OK;
124*10a83cb9SPrem Mallappa     case A_CR1:
125*10a83cb9SPrem Mallappa         *data = s->cr[1];
126*10a83cb9SPrem Mallappa         return MEMTX_OK;
127*10a83cb9SPrem Mallappa     case A_CR2:
128*10a83cb9SPrem Mallappa         *data = s->cr[2];
129*10a83cb9SPrem Mallappa         return MEMTX_OK;
130*10a83cb9SPrem Mallappa     case A_STATUSR:
131*10a83cb9SPrem Mallappa         *data = s->statusr;
132*10a83cb9SPrem Mallappa         return MEMTX_OK;
133*10a83cb9SPrem Mallappa     case A_IRQ_CTRL:
134*10a83cb9SPrem Mallappa     case A_IRQ_CTRL_ACK:
135*10a83cb9SPrem Mallappa         *data = s->irq_ctrl;
136*10a83cb9SPrem Mallappa         return MEMTX_OK;
137*10a83cb9SPrem Mallappa     case A_GERROR:
138*10a83cb9SPrem Mallappa         *data = s->gerror;
139*10a83cb9SPrem Mallappa         return MEMTX_OK;
140*10a83cb9SPrem Mallappa     case A_GERRORN:
141*10a83cb9SPrem Mallappa         *data = s->gerrorn;
142*10a83cb9SPrem Mallappa         return MEMTX_OK;
143*10a83cb9SPrem Mallappa     case A_GERROR_IRQ_CFG0: /* 64b */
144*10a83cb9SPrem Mallappa         *data = extract64(s->gerror_irq_cfg0, 0, 32);
145*10a83cb9SPrem Mallappa         return MEMTX_OK;
146*10a83cb9SPrem Mallappa     case A_GERROR_IRQ_CFG0 + 4:
147*10a83cb9SPrem Mallappa         *data = extract64(s->gerror_irq_cfg0, 32, 32);
148*10a83cb9SPrem Mallappa         return MEMTX_OK;
149*10a83cb9SPrem Mallappa     case A_GERROR_IRQ_CFG1:
150*10a83cb9SPrem Mallappa         *data = s->gerror_irq_cfg1;
151*10a83cb9SPrem Mallappa         return MEMTX_OK;
152*10a83cb9SPrem Mallappa     case A_GERROR_IRQ_CFG2:
153*10a83cb9SPrem Mallappa         *data = s->gerror_irq_cfg2;
154*10a83cb9SPrem Mallappa         return MEMTX_OK;
155*10a83cb9SPrem Mallappa     case A_STRTAB_BASE: /* 64b */
156*10a83cb9SPrem Mallappa         *data = extract64(s->strtab_base, 0, 32);
157*10a83cb9SPrem Mallappa         return MEMTX_OK;
158*10a83cb9SPrem Mallappa     case A_STRTAB_BASE + 4: /* 64b */
159*10a83cb9SPrem Mallappa         *data = extract64(s->strtab_base, 32, 32);
160*10a83cb9SPrem Mallappa         return MEMTX_OK;
161*10a83cb9SPrem Mallappa     case A_STRTAB_BASE_CFG:
162*10a83cb9SPrem Mallappa         *data = s->strtab_base_cfg;
163*10a83cb9SPrem Mallappa         return MEMTX_OK;
164*10a83cb9SPrem Mallappa     case A_CMDQ_BASE: /* 64b */
165*10a83cb9SPrem Mallappa         *data = extract64(s->cmdq.base, 0, 32);
166*10a83cb9SPrem Mallappa         return MEMTX_OK;
167*10a83cb9SPrem Mallappa     case A_CMDQ_BASE + 4:
168*10a83cb9SPrem Mallappa         *data = extract64(s->cmdq.base, 32, 32);
169*10a83cb9SPrem Mallappa         return MEMTX_OK;
170*10a83cb9SPrem Mallappa     case A_CMDQ_PROD:
171*10a83cb9SPrem Mallappa         *data = s->cmdq.prod;
172*10a83cb9SPrem Mallappa         return MEMTX_OK;
173*10a83cb9SPrem Mallappa     case A_CMDQ_CONS:
174*10a83cb9SPrem Mallappa         *data = s->cmdq.cons;
175*10a83cb9SPrem Mallappa         return MEMTX_OK;
176*10a83cb9SPrem Mallappa     case A_EVENTQ_BASE: /* 64b */
177*10a83cb9SPrem Mallappa         *data = extract64(s->eventq.base, 0, 32);
178*10a83cb9SPrem Mallappa         return MEMTX_OK;
179*10a83cb9SPrem Mallappa     case A_EVENTQ_BASE + 4: /* 64b */
180*10a83cb9SPrem Mallappa         *data = extract64(s->eventq.base, 32, 32);
181*10a83cb9SPrem Mallappa         return MEMTX_OK;
182*10a83cb9SPrem Mallappa     case A_EVENTQ_PROD:
183*10a83cb9SPrem Mallappa         *data = s->eventq.prod;
184*10a83cb9SPrem Mallappa         return MEMTX_OK;
185*10a83cb9SPrem Mallappa     case A_EVENTQ_CONS:
186*10a83cb9SPrem Mallappa         *data = s->eventq.cons;
187*10a83cb9SPrem Mallappa         return MEMTX_OK;
188*10a83cb9SPrem Mallappa     default:
189*10a83cb9SPrem Mallappa         *data = 0;
190*10a83cb9SPrem Mallappa         qemu_log_mask(LOG_UNIMP,
191*10a83cb9SPrem Mallappa                       "%s unhandled 32-bit access at 0x%"PRIx64" (RAZ)\n",
192*10a83cb9SPrem Mallappa                       __func__, offset);
193*10a83cb9SPrem Mallappa         return MEMTX_OK;
194*10a83cb9SPrem Mallappa     }
195*10a83cb9SPrem Mallappa }
196*10a83cb9SPrem Mallappa 
197*10a83cb9SPrem Mallappa static MemTxResult smmu_read_mmio(void *opaque, hwaddr offset, uint64_t *data,
198*10a83cb9SPrem Mallappa                                   unsigned size, MemTxAttrs attrs)
199*10a83cb9SPrem Mallappa {
200*10a83cb9SPrem Mallappa     SMMUState *sys = opaque;
201*10a83cb9SPrem Mallappa     SMMUv3State *s = ARM_SMMUV3(sys);
202*10a83cb9SPrem Mallappa     MemTxResult r;
203*10a83cb9SPrem Mallappa 
204*10a83cb9SPrem Mallappa     /* CONSTRAINED UNPREDICTABLE choice to have page0/1 be exact aliases */
205*10a83cb9SPrem Mallappa     offset &= ~0x10000;
206*10a83cb9SPrem Mallappa 
207*10a83cb9SPrem Mallappa     switch (size) {
208*10a83cb9SPrem Mallappa     case 8:
209*10a83cb9SPrem Mallappa         r = smmu_readll(s, offset, data, attrs);
210*10a83cb9SPrem Mallappa         break;
211*10a83cb9SPrem Mallappa     case 4:
212*10a83cb9SPrem Mallappa         r = smmu_readl(s, offset, data, attrs);
213*10a83cb9SPrem Mallappa         break;
214*10a83cb9SPrem Mallappa     default:
215*10a83cb9SPrem Mallappa         r = MEMTX_ERROR;
216*10a83cb9SPrem Mallappa         break;
217*10a83cb9SPrem Mallappa     }
218*10a83cb9SPrem Mallappa 
219*10a83cb9SPrem Mallappa     trace_smmuv3_read_mmio(offset, *data, size, r);
220*10a83cb9SPrem Mallappa     return r;
221*10a83cb9SPrem Mallappa }
222*10a83cb9SPrem Mallappa 
223*10a83cb9SPrem Mallappa static const MemoryRegionOps smmu_mem_ops = {
224*10a83cb9SPrem Mallappa     .read_with_attrs = smmu_read_mmio,
225*10a83cb9SPrem Mallappa     .write_with_attrs = smmu_write_mmio,
226*10a83cb9SPrem Mallappa     .endianness = DEVICE_LITTLE_ENDIAN,
227*10a83cb9SPrem Mallappa     .valid = {
228*10a83cb9SPrem Mallappa         .min_access_size = 4,
229*10a83cb9SPrem Mallappa         .max_access_size = 8,
230*10a83cb9SPrem Mallappa     },
231*10a83cb9SPrem Mallappa     .impl = {
232*10a83cb9SPrem Mallappa         .min_access_size = 4,
233*10a83cb9SPrem Mallappa         .max_access_size = 8,
234*10a83cb9SPrem Mallappa     },
235*10a83cb9SPrem Mallappa };
236*10a83cb9SPrem Mallappa 
237*10a83cb9SPrem Mallappa static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
238*10a83cb9SPrem Mallappa {
239*10a83cb9SPrem Mallappa     int i;
240*10a83cb9SPrem Mallappa 
241*10a83cb9SPrem Mallappa     for (i = 0; i < ARRAY_SIZE(s->irq); i++) {
242*10a83cb9SPrem Mallappa         sysbus_init_irq(dev, &s->irq[i]);
243*10a83cb9SPrem Mallappa     }
244*10a83cb9SPrem Mallappa }
245*10a83cb9SPrem Mallappa 
246*10a83cb9SPrem Mallappa static void smmu_reset(DeviceState *dev)
247*10a83cb9SPrem Mallappa {
248*10a83cb9SPrem Mallappa     SMMUv3State *s = ARM_SMMUV3(dev);
249*10a83cb9SPrem Mallappa     SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
250*10a83cb9SPrem Mallappa 
251*10a83cb9SPrem Mallappa     c->parent_reset(dev);
252*10a83cb9SPrem Mallappa 
253*10a83cb9SPrem Mallappa     smmuv3_init_regs(s);
254*10a83cb9SPrem Mallappa }
255*10a83cb9SPrem Mallappa 
256*10a83cb9SPrem Mallappa static void smmu_realize(DeviceState *d, Error **errp)
257*10a83cb9SPrem Mallappa {
258*10a83cb9SPrem Mallappa     SMMUState *sys = ARM_SMMU(d);
259*10a83cb9SPrem Mallappa     SMMUv3State *s = ARM_SMMUV3(sys);
260*10a83cb9SPrem Mallappa     SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
261*10a83cb9SPrem Mallappa     SysBusDevice *dev = SYS_BUS_DEVICE(d);
262*10a83cb9SPrem Mallappa     Error *local_err = NULL;
263*10a83cb9SPrem Mallappa 
264*10a83cb9SPrem Mallappa     c->parent_realize(d, &local_err);
265*10a83cb9SPrem Mallappa     if (local_err) {
266*10a83cb9SPrem Mallappa         error_propagate(errp, local_err);
267*10a83cb9SPrem Mallappa         return;
268*10a83cb9SPrem Mallappa     }
269*10a83cb9SPrem Mallappa 
270*10a83cb9SPrem Mallappa     memory_region_init_io(&sys->iomem, OBJECT(s),
271*10a83cb9SPrem Mallappa                           &smmu_mem_ops, sys, TYPE_ARM_SMMUV3, 0x20000);
272*10a83cb9SPrem Mallappa 
273*10a83cb9SPrem Mallappa     sys->mrtypename = TYPE_SMMUV3_IOMMU_MEMORY_REGION;
274*10a83cb9SPrem Mallappa 
275*10a83cb9SPrem Mallappa     sysbus_init_mmio(dev, &sys->iomem);
276*10a83cb9SPrem Mallappa 
277*10a83cb9SPrem Mallappa     smmu_init_irq(s, dev);
278*10a83cb9SPrem Mallappa }
279*10a83cb9SPrem Mallappa 
280*10a83cb9SPrem Mallappa static const VMStateDescription vmstate_smmuv3_queue = {
281*10a83cb9SPrem Mallappa     .name = "smmuv3_queue",
282*10a83cb9SPrem Mallappa     .version_id = 1,
283*10a83cb9SPrem Mallappa     .minimum_version_id = 1,
284*10a83cb9SPrem Mallappa     .fields = (VMStateField[]) {
285*10a83cb9SPrem Mallappa         VMSTATE_UINT64(base, SMMUQueue),
286*10a83cb9SPrem Mallappa         VMSTATE_UINT32(prod, SMMUQueue),
287*10a83cb9SPrem Mallappa         VMSTATE_UINT32(cons, SMMUQueue),
288*10a83cb9SPrem Mallappa         VMSTATE_UINT8(log2size, SMMUQueue),
289*10a83cb9SPrem Mallappa     },
290*10a83cb9SPrem Mallappa };
291*10a83cb9SPrem Mallappa 
292*10a83cb9SPrem Mallappa static const VMStateDescription vmstate_smmuv3 = {
293*10a83cb9SPrem Mallappa     .name = "smmuv3",
294*10a83cb9SPrem Mallappa     .version_id = 1,
295*10a83cb9SPrem Mallappa     .minimum_version_id = 1,
296*10a83cb9SPrem Mallappa     .fields = (VMStateField[]) {
297*10a83cb9SPrem Mallappa         VMSTATE_UINT32(features, SMMUv3State),
298*10a83cb9SPrem Mallappa         VMSTATE_UINT8(sid_size, SMMUv3State),
299*10a83cb9SPrem Mallappa         VMSTATE_UINT8(sid_split, SMMUv3State),
300*10a83cb9SPrem Mallappa 
301*10a83cb9SPrem Mallappa         VMSTATE_UINT32_ARRAY(cr, SMMUv3State, 3),
302*10a83cb9SPrem Mallappa         VMSTATE_UINT32(cr0ack, SMMUv3State),
303*10a83cb9SPrem Mallappa         VMSTATE_UINT32(statusr, SMMUv3State),
304*10a83cb9SPrem Mallappa         VMSTATE_UINT32(irq_ctrl, SMMUv3State),
305*10a83cb9SPrem Mallappa         VMSTATE_UINT32(gerror, SMMUv3State),
306*10a83cb9SPrem Mallappa         VMSTATE_UINT32(gerrorn, SMMUv3State),
307*10a83cb9SPrem Mallappa         VMSTATE_UINT64(gerror_irq_cfg0, SMMUv3State),
308*10a83cb9SPrem Mallappa         VMSTATE_UINT32(gerror_irq_cfg1, SMMUv3State),
309*10a83cb9SPrem Mallappa         VMSTATE_UINT32(gerror_irq_cfg2, SMMUv3State),
310*10a83cb9SPrem Mallappa         VMSTATE_UINT64(strtab_base, SMMUv3State),
311*10a83cb9SPrem Mallappa         VMSTATE_UINT32(strtab_base_cfg, SMMUv3State),
312*10a83cb9SPrem Mallappa         VMSTATE_UINT64(eventq_irq_cfg0, SMMUv3State),
313*10a83cb9SPrem Mallappa         VMSTATE_UINT32(eventq_irq_cfg1, SMMUv3State),
314*10a83cb9SPrem Mallappa         VMSTATE_UINT32(eventq_irq_cfg2, SMMUv3State),
315*10a83cb9SPrem Mallappa 
316*10a83cb9SPrem Mallappa         VMSTATE_STRUCT(cmdq, SMMUv3State, 0, vmstate_smmuv3_queue, SMMUQueue),
317*10a83cb9SPrem Mallappa         VMSTATE_STRUCT(eventq, SMMUv3State, 0, vmstate_smmuv3_queue, SMMUQueue),
318*10a83cb9SPrem Mallappa 
319*10a83cb9SPrem Mallappa         VMSTATE_END_OF_LIST(),
320*10a83cb9SPrem Mallappa     },
321*10a83cb9SPrem Mallappa };
322*10a83cb9SPrem Mallappa 
323*10a83cb9SPrem Mallappa static void smmuv3_instance_init(Object *obj)
324*10a83cb9SPrem Mallappa {
325*10a83cb9SPrem Mallappa     /* Nothing much to do here as of now */
326*10a83cb9SPrem Mallappa }
327*10a83cb9SPrem Mallappa 
328*10a83cb9SPrem Mallappa static void smmuv3_class_init(ObjectClass *klass, void *data)
329*10a83cb9SPrem Mallappa {
330*10a83cb9SPrem Mallappa     DeviceClass *dc = DEVICE_CLASS(klass);
331*10a83cb9SPrem Mallappa     SMMUv3Class *c = ARM_SMMUV3_CLASS(klass);
332*10a83cb9SPrem Mallappa 
333*10a83cb9SPrem Mallappa     dc->vmsd = &vmstate_smmuv3;
334*10a83cb9SPrem Mallappa     device_class_set_parent_reset(dc, smmu_reset, &c->parent_reset);
335*10a83cb9SPrem Mallappa     c->parent_realize = dc->realize;
336*10a83cb9SPrem Mallappa     dc->realize = smmu_realize;
337*10a83cb9SPrem Mallappa }
338*10a83cb9SPrem Mallappa 
339*10a83cb9SPrem Mallappa static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass,
340*10a83cb9SPrem Mallappa                                                   void *data)
341*10a83cb9SPrem Mallappa {
342*10a83cb9SPrem Mallappa }
343*10a83cb9SPrem Mallappa 
344*10a83cb9SPrem Mallappa static const TypeInfo smmuv3_type_info = {
345*10a83cb9SPrem Mallappa     .name          = TYPE_ARM_SMMUV3,
346*10a83cb9SPrem Mallappa     .parent        = TYPE_ARM_SMMU,
347*10a83cb9SPrem Mallappa     .instance_size = sizeof(SMMUv3State),
348*10a83cb9SPrem Mallappa     .instance_init = smmuv3_instance_init,
349*10a83cb9SPrem Mallappa     .class_size    = sizeof(SMMUv3Class),
350*10a83cb9SPrem Mallappa     .class_init    = smmuv3_class_init,
351*10a83cb9SPrem Mallappa };
352*10a83cb9SPrem Mallappa 
353*10a83cb9SPrem Mallappa static const TypeInfo smmuv3_iommu_memory_region_info = {
354*10a83cb9SPrem Mallappa     .parent = TYPE_IOMMU_MEMORY_REGION,
355*10a83cb9SPrem Mallappa     .name = TYPE_SMMUV3_IOMMU_MEMORY_REGION,
356*10a83cb9SPrem Mallappa     .class_init = smmuv3_iommu_memory_region_class_init,
357*10a83cb9SPrem Mallappa };
358*10a83cb9SPrem Mallappa 
359*10a83cb9SPrem Mallappa static void smmuv3_register_types(void)
360*10a83cb9SPrem Mallappa {
361*10a83cb9SPrem Mallappa     type_register(&smmuv3_type_info);
362*10a83cb9SPrem Mallappa     type_register(&smmuv3_iommu_memory_region_info);
363*10a83cb9SPrem Mallappa }
364*10a83cb9SPrem Mallappa 
365*10a83cb9SPrem Mallappa type_init(smmuv3_register_types)
366*10a83cb9SPrem Mallappa 
367