1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
/*-
* Copyright (c) 2015 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Semihalf under
* the sponsorship of the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _GIC_V3_REG_H_
#define _GIC_V3_REG_H_
/*
* Maximum number of interrupts
* supported by GIC (including SGIs, PPIs and SPIs)
*/
#define GIC_I_NUM_MAX (1020)
/*
* Priority MAX/MIN values
*/
#define GIC_PRIORITY_MAX (0x00UL)
/* Upper value is determined by LPI max priority */
#define GIC_PRIORITY_MIN (0xFCUL)
/* Numbers for shared peripheral interrupts */
#define GIC_LAST_SPI (1019)
/* Numbers for local peripheral interrupts */
#define GIC_FIRST_LPI (8192)
/*
* Registers (v2/v3)
*/
/* GICD_CTLR */
#define GICD_CTLR_G1 (1 << 0)
#define GICD_CTLR_G1A (1 << 1)
#define GICD_CTLR_ARE_NS (1 << 4)
#define GICD_CTLR_RWP (1 << 31)
/* GICD_TYPER */
#define GICD_TYPER_IDBITS(n) ((((n) >> 19) & 0x1F) + 1)
/*
* Registers (v3)
*/
#define GICD_IROUTER(n) (0x6000 + ((n) * 8))
#define GICD_PIDR4 0xFFD0
#define GICD_PIDR5 0xFFD4
#define GICD_PIDR6 0xFFD8
#define GICD_PIDR7 0xFFDC
#define GICD_PIDR0 0xFFE0
#define GICD_PIDR1 0xFFE4
#define GICD_PIDR2 0xFFE8
#define GICR_PIDR2_ARCH_SHIFT 4
#define GICR_PIDR2_ARCH_MASK 0xF0
#define GICR_PIDR2_ARCH(x) \
(((x) & GICR_PIDR2_ARCH_MASK) >> GICR_PIDR2_ARCH_SHIFT)
#define GICR_PIDR2_ARCH_GICv3 0x3
#define GICR_PIDR2_ARCH_GICv4 0x4
#define GICD_PIDR3 0xFFEC
/* Redistributor registers */
#define GICR_CTLR GICD_CTLR
#define GICR_CTLR_LPI_ENABLE (1 << 0)
#define GICR_PIDR2 GICD_PIDR2
#define GICR_TYPER (0x0008)
#define GICR_TYPER_PLPIS (1 << 0)
#define GICR_TYPER_VLPIS (1 << 1)
#define GICR_TYPER_LAST (1 << 4)
#define GICR_TYPER_CPUNUM_SHIFT (8)
#define GICR_TYPER_CPUNUM_MASK (0xFFFUL << GICR_TYPER_CPUNUM_SHIFT)
#define GICR_TYPER_CPUNUM(x) \
(((x) & GICR_TYPER_CPUNUM_MASK) >> GICR_TYPER_CPUNUM_SHIFT)
#define GICR_TYPER_AFF_SHIFT (32)
#define GICR_WAKER (0x0014)
#define GICR_WAKER_PS (1 << 1) /* Processor sleep */
#define GICR_WAKER_CA (1 << 2) /* Children asleep */
#define GICR_PROPBASER (0x0070)
#define GICR_PROPBASER_IDBITS_MASK 0x1FUL
/*
* Cacheability
* 0x0 - Device-nGnRnE
* 0x1 - Normal Inner Non-cacheable
* 0x2 - Normal Inner Read-allocate, Write-through
* 0x3 - Normal Inner Read-allocate, Write-back
* 0x4 - Normal Inner Write-allocate, Write-through
* 0x5 - Normal Inner Write-allocate, Write-back
* 0x6 - Normal Inner Read-allocate, Write-allocate, Write-through
* 0x7 - Normal Inner Read-allocate, Write-allocate, Write-back
*/
#define GICR_PROPBASER_CACHE_SHIFT 7
#define GICR_PROPBASER_CACHE_DnGnRnE 0x0UL
#define GICR_PROPBASER_CACHE_NIN 0x1UL
#define GICR_PROPBASER_CACHE_NIRAWT 0x2UL
#define GICR_PROPBASER_CACHE_NIRAWB 0x3UL
#define GICR_PROPBASER_CACHE_NIWAWT 0x4UL
#define GICR_PROPBASER_CACHE_NIWAWB 0x5UL
#define GICR_PROPBASER_CACHE_NIRAWAWT 0x6UL
#define GICR_PROPBASER_CACHE_NIRAWAWB 0x7UL
#define GICR_PROPBASER_CACHE_MASK \
(0x7UL << GICR_PROPBASER_CACHE_SHIFT)
/*
* Shareability
* 0x0 - Non-shareable
* 0x1 - Inner-shareable
* 0x2 - Outer-shareable
* 0x3 - Reserved. Threated as 0x0
*/
#define GICR_PROPBASER_SHARE_SHIFT 10
#define GICR_PROPBASER_SHARE_NS 0x0UL
#define GICR_PROPBASER_SHARE_IS 0x1UL
#define GICR_PROPBASER_SHARE_OS 0x2UL
#define GICR_PROPBASER_SHARE_RES 0x3UL
#define GICR_PROPBASER_SHARE_MASK \
(0x3UL << GICR_PROPBASER_SHARE_SHIFT)
#define GICR_PENDBASER (0x0078)
/*
* Cacheability
* 0x0 - Device-nGnRnE
* 0x1 - Normal Inner Non-cacheable
* 0x2 - Normal Inner Read-allocate, Write-through
* 0x3 - Normal Inner Read-allocate, Write-back
* 0x4 - Normal Inner Write-allocate, Write-through
* 0x5 - Normal Inner Write-allocate, Write-back
* 0x6 - Normal Inner Read-allocate, Write-allocate, Write-through
* 0x7 - Normal Inner Read-allocate, Write-allocate, Write-back
*/
#define GICR_PENDBASER_CACHE_SHIFT 7
#define GICR_PENDBASER_CACHE_DnGnRnE 0x0UL
#define GICR_PENDBASER_CACHE_NIN 0x1UL
#define GICR_PENDBASER_CACHE_NIRAWT 0x2UL
#define GICR_PENDBASER_CACHE_NIRAWB 0x3UL
#define GICR_PENDBASER_CACHE_NIWAWT 0x4UL
#define GICR_PENDBASER_CACHE_NIWAWB 0x5UL
#define GICR_PENDBASER_CACHE_NIRAWAWT 0x6UL
#define GICR_PENDBASER_CACHE_NIRAWAWB 0x7UL
#define GICR_PENDBASER_CACHE_MASK \
(0x7UL << GICR_PENDBASER_CACHE_SHIFT)
/*
* Shareability
* 0x0 - Non-shareable
* 0x1 - Inner-shareable
* 0x2 - Outer-shareable
* 0x3 - Reserved. Threated as 0x0
*/
#define GICR_PENDBASER_SHARE_SHIFT 10
#define GICR_PENDBASER_SHARE_NS 0x0UL
#define GICR_PENDBASER_SHARE_IS 0x1UL
#define GICR_PENDBASER_SHARE_OS 0x2UL
#define GICR_PENDBASER_SHARE_RES 0x3UL
#define GICR_PENDBASER_SHARE_MASK \
(0x3UL << GICR_PENDBASER_SHARE_SHIFT)
/* Re-distributor registers for SGIs and PPIs */
#define GICR_RD_BASE_SIZE PAGE_SIZE_64K
#define GICR_SGI_BASE_SIZE PAGE_SIZE_64K
#define GICR_VLPI_BASE_SIZE PAGE_SIZE_64K
#define GICR_RESERVED_SIZE PAGE_SIZE_64K
#define GICR_IGROUPR0 (0x0080)
#define GICR_ISENABLER0 (0x0100)
#define GICR_ICENABLER0 (0x0180)
#define GICR_I_ENABLER_SGI_MASK (0x0000FFFF)
#define GICR_I_ENABLER_PPI_MASK (0xFFFF0000)
#define GICR_I_PER_IPRIORITYn (GICD_I_PER_IPRIORITYn)
/* ITS registers */
#define GITS_PIDR2 GICR_PIDR2
#define GITS_PIDR2_ARCH_MASK GICR_PIDR2_ARCH_MASK
#define GITS_PIDR2_ARCH_GICv3 GICR_PIDR2_ARCH_GICv3
#define GITS_PIDR2_ARCH_GICv4 GICR_PIDR2_ARCH_GICv4
#define GITS_CTLR (0x0000)
#define GITS_CTLR_EN (1 << 0)
#define GITS_IIDR (0x0004)
#define GITS_IIDR_PRODUCT_SHIFT 24
#define GITS_IIDR_PRODUCT_MASK (0xff << GITS_IIDR_PRODUCT_SHIFT)
#define GITS_IIDR_VARIANT_SHIFT 16
#define GITS_IIDR_VARIANT_MASK (0xf << GITS_IIDR_VARIANT_SHIFT)
#define GITS_IIDR_REVISION_SHIFT 12
#define GITS_IIDR_REVISION_MASK (0xf << GITS_IIDR_REVISION_SHIFT)
#define GITS_IIDR_IMPLEMENTOR_SHIFT 0
#define GITS_IIDR_IMPLEMENTOR_MASK (0xfff << GITS_IIDR_IMPLEMENTOR_SHIFT)
#define GITS_IIDR_RAW(impl, prod, var, rev) \
((prod) << GITS_IIDR_PRODUCT_SHIFT | \
(var) << GITS_IIDR_VARIANT_SHIFT | \
(rev) << GITS_IIDR_REVISION_SHIFT | \
(impl) << GITS_IIDR_IMPLEMENTOR_SHIFT)
#define GITS_IIDR_IMPL_ARM (0x43B)
#define GITS_IIDR_PROD_GIC500 (0x0)
#define GITS_IIDR_IMPL_CAVIUM (0x34c)
#define GITS_IIDR_PROD_THUNDER (0xa1)
#define GITS_IIDR_VAR_THUNDER_1 (0x0)
#define GITS_CBASER (0x0080)
#define GITS_CBASER_VALID (1UL << 63)
/*
* Cacheability
* 0x0 - Device-nGnRnE
* 0x1 - Normal Inner Non-cacheable
* 0x2 - Normal Inner Read-allocate, Write-through
* 0x3 - Normal Inner Read-allocate, Write-back
* 0x4 - Normal Inner Write-allocate, Write-through
* 0x5 - Normal Inner Write-allocate, Write-back
* 0x6 - Normal Inner Read-allocate, Write-allocate, Write-through
* 0x7 - Normal Inner Read-allocate, Write-allocate, Write-back
*/
#define GITS_CBASER_CACHE_SHIFT 59
#define GITS_CBASER_CACHE_DnGnRnE 0x0UL
#define GITS_CBASER_CACHE_NIN 0x1UL
#define GITS_CBASER_CACHE_NIRAWT 0x2UL
#define GITS_CBASER_CACHE_NIRAWB 0x3UL
#define GITS_CBASER_CACHE_NIWAWT 0x4UL
#define GITS_CBASER_CACHE_NIWAWB 0x5UL
#define GITS_CBASER_CACHE_NIRAWAWT 0x6UL
#define GITS_CBASER_CACHE_NIRAWAWB 0x7UL
#define GITS_CBASER_CACHE_MASK (0x7UL << GITS_CBASER_CACHE_SHIFT)
/*
* Shareability
* 0x0 - Non-shareable
* 0x1 - Inner-shareable
* 0x2 - Outer-shareable
* 0x3 - Reserved. Threated as 0x0
*/
#define GITS_CBASER_SHARE_SHIFT 10
#define GITS_CBASER_SHARE_NS 0x0UL
#define GITS_CBASER_SHARE_IS 0x1UL
#define GITS_CBASER_SHARE_OS 0x2UL
#define GITS_CBASER_SHARE_RES 0x3UL
#define GITS_CBASER_SHARE_MASK \
(0x3UL << GITS_CBASER_SHARE_SHIFT)
#define GITS_CBASER_PA_SHIFT 12
#define GITS_CBASER_PA_MASK (0xFFFFFFFFFUL << GITS_CBASER_PA_SHIFT)
#define GITS_CWRITER (0x0088)
#define GITS_CREADR (0x0090)
#define GITS_BASER_BASE (0x0100)
#define GITS_BASER(x) (GITS_BASER_BASE + (x) * 8)
#define GITS_BASER_VALID (1UL << 63)
#define GITS_BASER_TYPE_SHIFT 56
#define GITS_BASER_TYPE(x) \
(((x) & GITS_BASER_TYPE_MASK) >> GITS_BASER_TYPE_SHIFT)
#define GITS_BASER_TYPE_UNIMPL 0x0UL /* Unimplemented */
#define GITS_BASER_TYPE_DEV 0x1UL /* Devices */
#define GITS_BASER_TYPE_VP 0x2UL /* Virtual Processors */
#define GITS_BASER_TYPE_PP 0x3UL /* Physical Processors */
#define GITS_BASER_TYPE_IC 0x4UL /* Interrupt Collections */
#define GITS_BASER_TYPE_RES5 0x5UL /* Reserved */
#define GITS_BASER_TYPE_RES6 0x6UL /* Reserved */
#define GITS_BASER_TYPE_RES7 0x7UL /* Reserved */
#define GITS_BASER_TYPE_MASK (0x7UL << GITS_BASER_TYPE_SHIFT)
/*
* Cacheability
* 0x0 - Non-cacheable, non-bufferable
* 0x1 - Non-cacheable
* 0x2 - Read-allocate, Write-through
* 0x3 - Read-allocate, Write-back
* 0x4 - Write-allocate, Write-through
* 0x5 - Write-allocate, Write-back
* 0x6 - Read-allocate, Write-allocate, Write-through
* 0x7 - Read-allocate, Write-allocate, Write-back
*/
#define GITS_BASER_CACHE_SHIFT 59
#define GITS_BASER_CACHE_NCNB 0x0UL
#define GITS_BASER_CACHE_NC 0x1UL
#define GITS_BASER_CACHE_RAWT 0x2UL
#define GITS_BASER_CACHE_RAWB 0x3UL
#define GITS_BASER_CACHE_WAWT 0x4UL
#define GITS_BASER_CACHE_WAWB 0x5UL
#define GITS_BASER_CACHE_RAWAWT 0x6UL
#define GITS_BASER_CACHE_RAWAWB 0x7UL
#define GITS_BASER_CACHE_MASK (0x7UL << GITS_BASER_CACHE_SHIFT)
#define GITS_BASER_ESIZE_SHIFT 48
#define GITS_BASER_ESIZE_MASK (0x1FUL << GITS_BASER_ESIZE_SHIFT)
#define GITS_BASER_ESIZE(x) \
((((x) & GITS_BASER_ESIZE_MASK) >> GITS_BASER_ESIZE_SHIFT) + 1)
#define GITS_BASER_PA_SHIFT 12
#define GITS_BASER_PA_MASK (0xFFFFFFFFFUL << GITS_BASER_PA_SHIFT)
/*
* Shareability
* 0x0 - Non-shareable
* 0x1 - Inner-shareable
* 0x2 - Outer-shareable
* 0x3 - Reserved. Threated as 0x0
*/
#define GITS_BASER_SHARE_SHIFT 10
#define GITS_BASER_SHARE_NS 0x0UL
#define GITS_BASER_SHARE_IS 0x1UL
#define GITS_BASER_SHARE_OS 0x2UL
#define GITS_BASER_SHARE_RES 0x3UL
#define GITS_BASER_SHARE_MASK (0x3UL << GITS_BASER_SHARE_SHIFT)
#define GITS_BASER_PSZ_SHIFT 8
#define GITS_BASER_PSZ_4K 0x0UL
#define GITS_BASER_PSZ_16K 0x1UL
#define GITS_BASER_PSZ_64K 0x2UL
#define GITS_BASER_PSZ_MASK (0x3UL << GITS_BASER_PSZ_SHIFT)
#define GITS_BASER_SIZE_MASK 0xFFUL
#define GITS_BASER_NUM 8
#define GITS_TYPER (0x0008)
#define GITS_TYPER_PTA (1UL << 19)
#define GITS_TYPER_DEVB_SHIFT 13
#define GITS_TYPER_DEVB_MASK (0x1FUL << GITS_TYPER_DEVB_SHIFT)
/* Number of device identifiers implemented */
#define GITS_TYPER_DEVB(x) \
((((x) & GITS_TYPER_DEVB_MASK) >> GITS_TYPER_DEVB_SHIFT) + 1)
#define GITS_TYPER_ITTES_SHIFT 4
#define GITS_TYPER_ITTES_MASK (0xFUL << GITS_TYPER_ITTES_SHIFT)
/* Number of bytes per ITT Entry */
#define GITS_TYPER_ITTES(x) \
((((x) & GITS_TYPER_ITTES_MASK) >> GITS_TYPER_ITTES_SHIFT) + 1)
#define GITS_TRANSLATER (0x10040)
/*
* LPI related
*/
#define LPI_CONF_PRIO_MASK (0xFC)
#define LPI_CONF_GROUP1 (1 << 1)
#define LPI_CONF_ENABLE (1 << 0)
/*
* GIC 500 ITS tracking facility
*/
#define GITS_TRKCTLR 0xC000
#define GITS_TRKR 0xC004
#define GITS_TRKDIDR 0xC008
#define GITS_TRKPIDR 0xC00C
#define GITS_TRKVIDR 0xC010
#define GITS_TRKTGTR 0xC014
#define GITS_TRKICR 0xC018
#define GITS_TRKLCR 0xC018
/*
* CPU interface
*/
/*
* Registers list (ICC_xyz_EL1):
*
* PMR - Priority Mask Register
* * interrupts of priority higher than specified
* in this mask will be signalled to the CPU.
* (0xff - lowest possible prio., 0x00 - highest prio.)
*
* CTLR - Control Register
* * controls behavior of the CPU interface and displays
* implemented features.
*
* IGRPEN1 - Interrupt Group 1 Enable Register
*
* IAR1 - Interrupt Acknowledge Register Group 1
* * contains number of the highest priority pending
* interrupt from the Group 1.
*
* EOIR1 - End of Interrupt Register Group 1
* * Writes inform CPU interface about completed Group 1
* interrupts processing.
*/
#define gic_icc_write(reg, val) \
do { \
WRITE_SPECIALREG(icc_ ##reg ##_el1, val); \
isb(); \
} while (0)
#define gic_icc_read(reg) \
({ \
uint64_t val; \
\
val = READ_SPECIALREG(icc_ ##reg ##_el1); \
(val); \
})
#define gic_icc_set(reg, mask) \
do { \
uint64_t val; \
val = gic_icc_read(reg); \
val |= (mask); \
gic_icc_write(reg, val); \
} while (0)
#define gic_icc_clear(reg, mask) \
do { \
uint64_t val; \
val = gic_icc_read(reg); \
val &= ~(mask); \
gic_icc_write(reg, val); \
} while (0)
#endif /* _GIC_V3_REG_H_ */
|