blob: c8940303c6c4b8e5302b3166cbd3723bea1fc04b [file] [log] [blame]
Soby Mathewc6820d12016-05-09 17:49:55 +01001/*
Antonio Nino Diazac998032017-02-27 17:23:54 +00002 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
Soby Mathewc6820d12016-05-09 17:49:55 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathewc6820d12016-05-09 17:49:55 +01005 */
6
7#ifndef __ARCH_H__
8#define __ARCH_H__
9
Isla Mitchell02c63072017-07-21 14:44:36 +010010#include <utils_def.h>
11
Soby Mathewc6820d12016-05-09 17:49:55 +010012/*******************************************************************************
13 * MIDR bit definitions
14 ******************************************************************************/
15#define MIDR_IMPL_MASK 0xff
16#define MIDR_IMPL_SHIFT 24
17#define MIDR_VAR_SHIFT 20
18#define MIDR_VAR_BITS 4
19#define MIDR_REV_SHIFT 0
20#define MIDR_REV_BITS 4
21#define MIDR_PN_MASK 0xfff
22#define MIDR_PN_SHIFT 4
23
24/*******************************************************************************
25 * MPIDR macros
26 ******************************************************************************/
Summer Qin93c812f2017-02-28 16:46:17 +000027#define MPIDR_MT_MASK (1 << 24)
Soby Mathewc6820d12016-05-09 17:49:55 +010028#define MPIDR_CPU_MASK MPIDR_AFFLVL_MASK
29#define MPIDR_CLUSTER_MASK (MPIDR_AFFLVL_MASK << MPIDR_AFFINITY_BITS)
30#define MPIDR_AFFINITY_BITS 8
31#define MPIDR_AFFLVL_MASK 0xff
32#define MPIDR_AFFLVL_SHIFT 3
33#define MPIDR_AFF0_SHIFT 0
34#define MPIDR_AFF1_SHIFT 8
35#define MPIDR_AFF2_SHIFT 16
36#define MPIDR_AFFINITY_MASK 0x00ffffff
37#define MPIDR_AFFLVL0 0
38#define MPIDR_AFFLVL1 1
39#define MPIDR_AFFLVL2 2
40
41#define MPIDR_AFFLVL0_VAL(mpidr) \
42 (((mpidr) >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK)
43#define MPIDR_AFFLVL1_VAL(mpidr) \
44 (((mpidr) >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK)
45#define MPIDR_AFFLVL2_VAL(mpidr) \
46 (((mpidr) >> MPIDR_AFF2_SHIFT) & MPIDR_AFFLVL_MASK)
Jeenu Viswambharanab14e9b2017-09-22 08:32:09 +010047#define MPIDR_AFFLVL3_VAL(mpidr) 0
Soby Mathewc6820d12016-05-09 17:49:55 +010048
49/*
50 * The MPIDR_MAX_AFFLVL count starts from 0. Take care to
51 * add one while using this macro to define array sizes.
52 */
53#define MPIDR_MAX_AFFLVL 2
54
55/* Data Cache set/way op type defines */
56#define DC_OP_ISW 0x0
57#define DC_OP_CISW 0x1
58#define DC_OP_CSW 0x2
59
60/*******************************************************************************
61 * Generic timer memory mapped registers & offsets
62 ******************************************************************************/
63#define CNTCR_OFF 0x000
64#define CNTFID_OFF 0x020
65
66#define CNTCR_EN (1 << 0)
67#define CNTCR_HDBG (1 << 1)
68#define CNTCR_FCREQ(x) ((x) << 8)
69
70/*******************************************************************************
71 * System register bit definitions
72 ******************************************************************************/
73/* CLIDR definitions */
74#define LOUIS_SHIFT 21
75#define LOC_SHIFT 24
76#define CLIDR_FIELD_WIDTH 3
77
78/* CSSELR definitions */
79#define LEVEL_SHIFT 1
80
81/* ID_PFR1 definitions */
82#define ID_PFR1_VIRTEXT_SHIFT 12
83#define ID_PFR1_VIRTEXT_MASK 0xf
84#define GET_VIRT_EXT(id) (((id) >> ID_PFR1_VIRTEXT_SHIFT) \
85 & ID_PFR1_VIRTEXT_MASK)
86#define ID_PFR1_GIC_SHIFT 28
87#define ID_PFR1_GIC_MASK 0xf
88
89/* SCTLR definitions */
Etienne Carriere70a004b2017-11-05 22:56:03 +010090#define SCTLR_RES1_DEF ((1 << 23) | (1 << 22) | (1 << 4) | (1 << 3))
91#if ARM_ARCH_MAJOR == 7
92#define SCTLR_RES1 SCTLR_RES1_DEF
93#else
94#define SCTLR_RES1 (SCTLR_RES1_DEF | (1 << 11))
95#endif
Soby Mathewc6820d12016-05-09 17:49:55 +010096#define SCTLR_M_BIT (1 << 0)
97#define SCTLR_A_BIT (1 << 1)
98#define SCTLR_C_BIT (1 << 2)
99#define SCTLR_CP15BEN_BIT (1 << 5)
100#define SCTLR_ITD_BIT (1 << 7)
Etienne Carriere70a004b2017-11-05 22:56:03 +0100101#define SCTLR_Z_BIT (1 << 11)
Soby Mathewc6820d12016-05-09 17:49:55 +0100102#define SCTLR_I_BIT (1 << 12)
103#define SCTLR_V_BIT (1 << 13)
Etienne Carriere70a004b2017-11-05 22:56:03 +0100104#define SCTLR_RR_BIT (1 << 14)
Soby Mathewc6820d12016-05-09 17:49:55 +0100105#define SCTLR_NTWI_BIT (1 << 16)
106#define SCTLR_NTWE_BIT (1 << 18)
107#define SCTLR_WXN_BIT (1 << 19)
108#define SCTLR_UWXN_BIT (1 << 20)
109#define SCTLR_EE_BIT (1 << 25)
110#define SCTLR_TRE_BIT (1 << 28)
111#define SCTLR_AFE_BIT (1 << 29)
112#define SCTLR_TE_BIT (1 << 30)
David Cunadofee86532017-04-13 22:38:29 +0100113#define SCTLR_RESET_VAL (SCTLR_RES1 | SCTLR_NTWE_BIT | \
114 SCTLR_NTWI_BIT | SCTLR_CP15BEN_BIT)
Soby Mathewc6820d12016-05-09 17:49:55 +0100115
dp-arm595d0d52017-02-08 11:51:50 +0000116/* SDCR definitions */
117#define SDCR_SPD(x) ((x) << 14)
118#define SDCR_SPD_LEGACY 0x0
119#define SDCR_SPD_DISABLE 0x2
120#define SDCR_SPD_ENABLE 0x3
David Cunadofee86532017-04-13 22:38:29 +0100121#define SDCR_RESET_VAL 0x0
dp-arm595d0d52017-02-08 11:51:50 +0000122
David Cunadofee86532017-04-13 22:38:29 +0100123#if !ERROR_DEPRECATED
dp-arm595d0d52017-02-08 11:51:50 +0000124#define SDCR_DEF_VAL SDCR_SPD(SDCR_SPD_DISABLE)
David Cunadofee86532017-04-13 22:38:29 +0100125#endif
dp-arm595d0d52017-02-08 11:51:50 +0000126
Soby Mathewc6820d12016-05-09 17:49:55 +0100127/* HSCTLR definitions */
128#define HSCTLR_RES1 ((1 << 29) | (1 << 28) | (1 << 23) | (1 << 22) \
129 | (1 << 18) | (1 << 16) | (1 << 11) | (1 << 4) \
Soby Mathewa993c422016-09-29 14:15:57 +0100130 | (1 << 3))
Soby Mathewc6820d12016-05-09 17:49:55 +0100131#define HSCTLR_M_BIT (1 << 0)
132#define HSCTLR_A_BIT (1 << 1)
133#define HSCTLR_C_BIT (1 << 2)
134#define HSCTLR_CP15BEN_BIT (1 << 5)
135#define HSCTLR_ITD_BIT (1 << 7)
136#define HSCTLR_SED_BIT (1 << 8)
137#define HSCTLR_I_BIT (1 << 12)
138#define HSCTLR_WXN_BIT (1 << 19)
139#define HSCTLR_EE_BIT (1 << 25)
140#define HSCTLR_TE_BIT (1 << 30)
141
142/* CPACR definitions */
143#define CPACR_FPEN(x) ((x) << 20)
144#define CPACR_FP_TRAP_PL0 0x1
145#define CPACR_FP_TRAP_ALL 0x2
146#define CPACR_FP_TRAP_NONE 0x3
147
148/* SCR definitions */
149#define SCR_TWE_BIT (1 << 13)
150#define SCR_TWI_BIT (1 << 12)
151#define SCR_SIF_BIT (1 << 9)
152#define SCR_HCE_BIT (1 << 8)
153#define SCR_SCD_BIT (1 << 7)
154#define SCR_NET_BIT (1 << 6)
155#define SCR_AW_BIT (1 << 5)
156#define SCR_FW_BIT (1 << 4)
157#define SCR_EA_BIT (1 << 3)
158#define SCR_FIQ_BIT (1 << 2)
159#define SCR_IRQ_BIT (1 << 1)
160#define SCR_NS_BIT (1 << 0)
161#define SCR_VALID_BIT_MASK 0x33ff
David Cunadofee86532017-04-13 22:38:29 +0100162#define SCR_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100163
164#define GET_NS_BIT(scr) ((scr) & SCR_NS_BIT)
165
166/* HCR definitions */
167#define HCR_AMO_BIT (1 << 5)
168#define HCR_IMO_BIT (1 << 4)
169#define HCR_FMO_BIT (1 << 3)
David Cunadofee86532017-04-13 22:38:29 +0100170#define HCR_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100171
172/* CNTHCTL definitions */
David Cunadofee86532017-04-13 22:38:29 +0100173#define CNTHCTL_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100174#define PL1PCEN_BIT (1 << 1)
175#define PL1PCTEN_BIT (1 << 0)
176
177/* CNTKCTL definitions */
178#define PL0PTEN_BIT (1 << 9)
179#define PL0VTEN_BIT (1 << 8)
180#define PL0PCTEN_BIT (1 << 0)
181#define PL0VCTEN_BIT (1 << 1)
182#define EVNTEN_BIT (1 << 2)
183#define EVNTDIR_BIT (1 << 3)
184#define EVNTI_SHIFT 4
185#define EVNTI_MASK 0xf
186
187/* HCPTR definitions */
David Cunadofee86532017-04-13 22:38:29 +0100188#define HCPTR_RES1 ((1 << 13) | (1<<12) | 0x3ff)
Soby Mathewc6820d12016-05-09 17:49:55 +0100189#define TCPAC_BIT (1 << 31)
190#define TTA_BIT (1 << 20)
191#define TCP11_BIT (1 << 10)
192#define TCP10_BIT (1 << 10)
David Cunadofee86532017-04-13 22:38:29 +0100193#define HCPTR_RESET_VAL HCPTR_RES1
194
195/* VTTBR defintions */
196#define VTTBR_RESET_VAL ULL(0x0)
197#define VTTBR_VMID_MASK ULL(0xff)
198#define VTTBR_VMID_SHIFT 48
199#define VTTBR_BADDR_MASK 0xffffffffffff
200#define VTTBR_BADDR_SHIFT 0
201
202/* HDCR definitions */
203#define HDCR_RESET_VAL 0x0
204
205/* HSTR definitions */
206#define HSTR_RESET_VAL 0x0
207
208/* CNTHP_CTL definitions */
209#define CNTHP_CTL_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100210
211/* NASCR definitions */
212#define NSASEDIS_BIT (1 << 15)
Yatharth Kocharf528faf2016-06-28 16:58:26 +0100213#define NSTRCDIS_BIT (1 << 20)
David Cunadofee86532017-04-13 22:38:29 +0100214/* NOTE: correct typo in the definitions */
215#if !ERROR_DEPRECATED
Soby Mathewc6820d12016-05-09 17:49:55 +0100216#define NASCR_CP11_BIT (1 << 11)
217#define NASCR_CP10_BIT (1 << 10)
David Cunadofee86532017-04-13 22:38:29 +0100218#endif
219#define NSACR_CP11_BIT (1 << 11)
220#define NSACR_CP10_BIT (1 << 10)
221#define NSACR_IMP_DEF_MASK (0x7 << 16)
222#define NSACR_ENABLE_FP_ACCESS (NSACR_CP11_BIT | NSACR_CP10_BIT)
223#define NSACR_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100224
225/* CPACR definitions */
226#define ASEDIS_BIT (1 << 31)
227#define TRCDIS_BIT (1 << 28)
228#define CPACR_CP11_SHIFT 22
229#define CPACR_CP10_SHIFT 20
230#define CPACR_ENABLE_FP_ACCESS (0x3 << CPACR_CP11_SHIFT |\
231 0x3 << CPACR_CP10_SHIFT)
David Cunadofee86532017-04-13 22:38:29 +0100232#define CPACR_RESET_VAL 0x0
Soby Mathewc6820d12016-05-09 17:49:55 +0100233
234/* FPEXC definitions */
David Cunadofee86532017-04-13 22:38:29 +0100235#define FPEXC_RES1 ((1 << 10) | (1 << 9) | (1 << 8))
Soby Mathewc6820d12016-05-09 17:49:55 +0100236#define FPEXC_EN_BIT (1 << 30)
David Cunadofee86532017-04-13 22:38:29 +0100237#define FPEXC_RESET_VAL FPEXC_RES1
Soby Mathewc6820d12016-05-09 17:49:55 +0100238
239/* SPSR/CPSR definitions */
240#define SPSR_FIQ_BIT (1 << 0)
241#define SPSR_IRQ_BIT (1 << 1)
242#define SPSR_ABT_BIT (1 << 2)
243#define SPSR_AIF_SHIFT 6
244#define SPSR_AIF_MASK 0x7
245
246#define SPSR_E_SHIFT 9
247#define SPSR_E_MASK 0x1
248#define SPSR_E_LITTLE 0
249#define SPSR_E_BIG 1
250
251#define SPSR_T_SHIFT 5
252#define SPSR_T_MASK 0x1
253#define SPSR_T_ARM 0
254#define SPSR_T_THUMB 1
255
256#define SPSR_MODE_SHIFT 0
257#define SPSR_MODE_MASK 0x7
258
259
260#define DISABLE_ALL_EXCEPTIONS \
261 (SPSR_FIQ_BIT | SPSR_IRQ_BIT | SPSR_ABT_BIT)
262
263/*
264 * TTBCR definitions
265 */
266/* The ARM Trusted Firmware uses the long descriptor format */
267#define TTBCR_EAE_BIT (1 << 31)
268
269#define TTBCR_SH1_NON_SHAREABLE (0x0 << 28)
270#define TTBCR_SH1_OUTER_SHAREABLE (0x2 << 28)
271#define TTBCR_SH1_INNER_SHAREABLE (0x3 << 28)
272
273#define TTBCR_RGN1_OUTER_NC (0x0 << 26)
274#define TTBCR_RGN1_OUTER_WBA (0x1 << 26)
275#define TTBCR_RGN1_OUTER_WT (0x2 << 26)
276#define TTBCR_RGN1_OUTER_WBNA (0x3 << 26)
277
278#define TTBCR_RGN1_INNER_NC (0x0 << 24)
279#define TTBCR_RGN1_INNER_WBA (0x1 << 24)
280#define TTBCR_RGN1_INNER_WT (0x2 << 24)
281#define TTBCR_RGN1_INNER_WBNA (0x3 << 24)
282
283#define TTBCR_EPD1_BIT (1 << 23)
284#define TTBCR_A1_BIT (1 << 22)
285
286#define TTBCR_T1SZ_SHIFT 16
287#define TTBCR_T1SZ_MASK (0x7)
Antonio Nino Diazd48ae612016-08-02 09:21:41 +0100288#define TTBCR_TxSZ_MIN 0
289#define TTBCR_TxSZ_MAX 7
Soby Mathewc6820d12016-05-09 17:49:55 +0100290
291#define TTBCR_SH0_NON_SHAREABLE (0x0 << 12)
292#define TTBCR_SH0_OUTER_SHAREABLE (0x2 << 12)
293#define TTBCR_SH0_INNER_SHAREABLE (0x3 << 12)
294
295#define TTBCR_RGN0_OUTER_NC (0x0 << 10)
296#define TTBCR_RGN0_OUTER_WBA (0x1 << 10)
297#define TTBCR_RGN0_OUTER_WT (0x2 << 10)
298#define TTBCR_RGN0_OUTER_WBNA (0x3 << 10)
299
300#define TTBCR_RGN0_INNER_NC (0x0 << 8)
301#define TTBCR_RGN0_INNER_WBA (0x1 << 8)
302#define TTBCR_RGN0_INNER_WT (0x2 << 8)
303#define TTBCR_RGN0_INNER_WBNA (0x3 << 8)
304
305#define TTBCR_EPD0_BIT (1 << 7)
306#define TTBCR_T0SZ_SHIFT 0
307#define TTBCR_T0SZ_MASK (0x7)
308
309#define MODE_RW_SHIFT 0x4
310#define MODE_RW_MASK 0x1
311#define MODE_RW_32 0x1
312
313#define MODE32_SHIFT 0
314#define MODE32_MASK 0x1f
315#define MODE32_usr 0x10
316#define MODE32_fiq 0x11
317#define MODE32_irq 0x12
318#define MODE32_svc 0x13
319#define MODE32_mon 0x16
320#define MODE32_abt 0x17
321#define MODE32_hyp 0x1a
322#define MODE32_und 0x1b
323#define MODE32_sys 0x1f
324
325#define GET_M32(mode) (((mode) >> MODE32_SHIFT) & MODE32_MASK)
326
327#define SPSR_MODE32(mode, isa, endian, aif) \
328 (MODE_RW_32 << MODE_RW_SHIFT | \
329 ((mode) & MODE32_MASK) << MODE32_SHIFT | \
330 ((isa) & SPSR_T_MASK) << SPSR_T_SHIFT | \
331 ((endian) & SPSR_E_MASK) << SPSR_E_SHIFT | \
332 ((aif) & SPSR_AIF_MASK) << SPSR_AIF_SHIFT)
333
334/*
Isla Mitchellc4a1a072017-08-07 11:20:13 +0100335 * TTBR definitions
336 */
337#define TTBR_CNP_BIT 0x1
338
339/*
Soby Mathewc6820d12016-05-09 17:49:55 +0100340 * CTR definitions
341 */
342#define CTR_CWG_SHIFT 24
343#define CTR_CWG_MASK 0xf
344#define CTR_ERG_SHIFT 20
345#define CTR_ERG_MASK 0xf
346#define CTR_DMINLINE_SHIFT 16
347#define CTR_DMINLINE_WIDTH 4
348#define CTR_DMINLINE_MASK ((1 << 4) - 1)
349#define CTR_L1IP_SHIFT 14
350#define CTR_L1IP_MASK 0x3
351#define CTR_IMINLINE_SHIFT 0
352#define CTR_IMINLINE_MASK 0xf
353
354#define MAX_CACHE_LINE_SIZE 0x800 /* 2KB */
355
David Cunado5f55e282016-10-31 17:37:34 +0000356/* PMCR definitions */
357#define PMCR_N_SHIFT 11
358#define PMCR_N_MASK 0x1f
359#define PMCR_N_BITS (PMCR_N_MASK << PMCR_N_SHIFT)
David Cunado4168f2f2017-10-02 17:41:39 +0100360#define PMCR_LC_BIT (1 << 6)
361#define PMCR_DP_BIT (1 << 5)
David Cunado5f55e282016-10-31 17:37:34 +0000362
Soby Mathewc6820d12016-05-09 17:49:55 +0100363/*******************************************************************************
Antonio Nino Diazac998032017-02-27 17:23:54 +0000364 * Definitions of register offsets, fields and macros for CPU system
365 * instructions.
366 ******************************************************************************/
367
368#define TLBI_ADDR_SHIFT 0
369#define TLBI_ADDR_MASK 0xFFFFF000
370#define TLBI_ADDR(x) (((x) >> TLBI_ADDR_SHIFT) & TLBI_ADDR_MASK)
371
372/*******************************************************************************
Soby Mathewc6820d12016-05-09 17:49:55 +0100373 * Definitions of register offsets and fields in the CNTCTLBase Frame of the
374 * system level implementation of the Generic Timer.
375 ******************************************************************************/
376#define CNTNSAR 0x4
377#define CNTNSAR_NS_SHIFT(x) (x)
378
379#define CNTACR_BASE(x) (0x40 + ((x) << 2))
380#define CNTACR_RPCT_SHIFT 0x0
381#define CNTACR_RVCT_SHIFT 0x1
382#define CNTACR_RFRQ_SHIFT 0x2
383#define CNTACR_RVOFF_SHIFT 0x3
384#define CNTACR_RWVT_SHIFT 0x4
385#define CNTACR_RWPT_SHIFT 0x5
386
387/* MAIR macros */
388#define MAIR0_ATTR_SET(attr, index) ((attr) << ((index) << 3))
389#define MAIR1_ATTR_SET(attr, index) ((attr) << (((index) - 3) << 3))
390
391/* System register defines The format is: coproc, opt1, CRn, CRm, opt2 */
392#define SCR p15, 0, c1, c1, 0
393#define SCTLR p15, 0, c1, c0, 0
Etienne Carriere70a004b2017-11-05 22:56:03 +0100394#define ACTLR p15, 0, c1, c0, 1
dp-arm595d0d52017-02-08 11:51:50 +0000395#define SDCR p15, 0, c1, c3, 1
Soby Mathewc6820d12016-05-09 17:49:55 +0100396#define MPIDR p15, 0, c0, c0, 5
397#define MIDR p15, 0, c0, c0, 0
398#define VBAR p15, 0, c12, c0, 0
399#define MVBAR p15, 0, c12, c0, 1
400#define NSACR p15, 0, c1, c1, 2
401#define CPACR p15, 0, c1, c0, 2
402#define DCCIMVAC p15, 0, c7, c14, 1
403#define DCCMVAC p15, 0, c7, c10, 1
404#define DCIMVAC p15, 0, c7, c6, 1
405#define DCCISW p15, 0, c7, c14, 2
406#define DCCSW p15, 0, c7, c10, 2
407#define DCISW p15, 0, c7, c6, 2
408#define CTR p15, 0, c0, c0, 1
409#define CNTFRQ p15, 0, c14, c0, 0
410#define ID_PFR1 p15, 0, c0, c1, 1
411#define MAIR0 p15, 0, c10, c2, 0
412#define MAIR1 p15, 0, c10, c2, 1
413#define TTBCR p15, 0, c2, c0, 2
414#define TTBR0 p15, 0, c2, c0, 0
415#define TTBR1 p15, 0, c2, c0, 1
416#define TLBIALL p15, 0, c8, c7, 0
417#define TLBIALLIS p15, 0, c8, c3, 0
418#define TLBIMVA p15, 0, c8, c7, 1
419#define TLBIMVAA p15, 0, c8, c7, 3
Antonio Nino Diazac998032017-02-27 17:23:54 +0000420#define TLBIMVAAIS p15, 0, c8, c3, 3
421#define BPIALLIS p15, 0, c7, c1, 6
Soby Mathewc6820d12016-05-09 17:49:55 +0100422#define HSCTLR p15, 4, c1, c0, 0
423#define HCR p15, 4, c1, c1, 0
424#define HCPTR p15, 4, c1, c1, 2
David Cunadofee86532017-04-13 22:38:29 +0100425#define HSTR p15, 4, c1, c1, 3
Soby Mathewc6820d12016-05-09 17:49:55 +0100426#define CNTHCTL p15, 4, c14, c1, 0
Yatharth Kochar2694cba2016-11-14 12:00:41 +0000427#define CNTKCTL p15, 0, c14, c1, 0
Soby Mathewc6820d12016-05-09 17:49:55 +0100428#define VPIDR p15, 4, c0, c0, 0
429#define VMPIDR p15, 4, c0, c0, 5
430#define ISR p15, 0, c12, c1, 0
431#define CLIDR p15, 1, c0, c0, 1
432#define CSSELR p15, 2, c0, c0, 0
433#define CCSIDR p15, 1, c0, c0, 0
Yatharth Kochara9f776c2016-11-10 16:17:51 +0000434#define DBGOSDLR p14, 0, c1, c3, 4
Soby Mathewc6820d12016-05-09 17:49:55 +0100435
David Cunado5f55e282016-10-31 17:37:34 +0000436/* Debug register defines. The format is: coproc, opt1, CRn, CRm, opt2 */
437#define HDCR p15, 4, c1, c1, 1
David Cunado5f55e282016-10-31 17:37:34 +0000438#define PMCR p15, 0, c9, c12, 0
David Cunadoc14b08e2016-11-25 00:21:59 +0000439#define CNTHP_CTL p15, 4, c14, c2, 1
David Cunado5f55e282016-10-31 17:37:34 +0000440
Etienne Carriere70a004b2017-11-05 22:56:03 +0100441/* AArch32 coproc registers for 32bit MMU descriptor support */
442#define PRRR p15, 0, c10, c2, 0
443#define NMRR p15, 0, c10, c2, 1
444#define DACR p15, 0, c3, c0, 0
445
Soby Mathewc6820d12016-05-09 17:49:55 +0100446/* GICv3 CPU Interface system register defines. The format is: coproc, opt1, CRn, CRm, opt2 */
447#define ICC_IAR1 p15, 0, c12, c12, 0
448#define ICC_IAR0 p15, 0, c12, c8, 0
449#define ICC_EOIR1 p15, 0, c12, c12, 1
450#define ICC_EOIR0 p15, 0, c12, c8, 1
451#define ICC_HPPIR1 p15, 0, c12, c12, 2
452#define ICC_HPPIR0 p15, 0, c12, c8, 2
453#define ICC_BPR1 p15, 0, c12, c12, 3
454#define ICC_BPR0 p15, 0, c12, c8, 3
455#define ICC_DIR p15, 0, c12, c11, 1
456#define ICC_PMR p15, 0, c4, c6, 0
457#define ICC_RPR p15, 0, c12, c11, 3
458#define ICC_CTLR p15, 0, c12, c12, 4
459#define ICC_MCTLR p15, 6, c12, c12, 4
460#define ICC_SRE p15, 0, c12, c12, 5
461#define ICC_HSRE p15, 4, c12, c9, 5
462#define ICC_MSRE p15, 6, c12, c12, 5
463#define ICC_IGRPEN0 p15, 0, c12, c12, 6
464#define ICC_IGRPEN1 p15, 0, c12, c12, 7
465#define ICC_MGRPEN1 p15, 6, c12, c12, 7
466
467/* 64 bit system register defines The format is: coproc, opt1, CRm */
468#define TTBR0_64 p15, 0, c2
469#define TTBR1_64 p15, 1, c2
470#define CNTVOFF_64 p15, 4, c14
471#define VTTBR_64 p15, 6, c2
472#define CNTPCT_64 p15, 0, c14
473
474/* 64 bit GICv3 CPU Interface system register defines. The format is: coproc, opt1, CRm */
475#define ICC_SGI1R_EL1_64 p15, 0, c12
476#define ICC_ASGI1R_EL1_64 p15, 1, c12
477#define ICC_SGI0R_EL1_64 p15, 2, c12
478
Isla Mitchell02c63072017-07-21 14:44:36 +0100479/*******************************************************************************
480 * Definitions of MAIR encodings for device and normal memory
481 ******************************************************************************/
482/*
483 * MAIR encodings for device memory attributes.
484 */
485#define MAIR_DEV_nGnRnE U(0x0)
486#define MAIR_DEV_nGnRE U(0x4)
487#define MAIR_DEV_nGRE U(0x8)
488#define MAIR_DEV_GRE U(0xc)
489
490/*
491 * MAIR encodings for normal memory attributes.
492 *
493 * Cache Policy
494 * WT: Write Through
495 * WB: Write Back
496 * NC: Non-Cacheable
497 *
498 * Transient Hint
499 * NTR: Non-Transient
500 * TR: Transient
501 *
502 * Allocation Policy
503 * RA: Read Allocate
504 * WA: Write Allocate
505 * RWA: Read and Write Allocate
506 * NA: No Allocation
507 */
508#define MAIR_NORM_WT_TR_WA U(0x1)
509#define MAIR_NORM_WT_TR_RA U(0x2)
510#define MAIR_NORM_WT_TR_RWA U(0x3)
511#define MAIR_NORM_NC U(0x4)
512#define MAIR_NORM_WB_TR_WA U(0x5)
513#define MAIR_NORM_WB_TR_RA U(0x6)
514#define MAIR_NORM_WB_TR_RWA U(0x7)
515#define MAIR_NORM_WT_NTR_NA U(0x8)
516#define MAIR_NORM_WT_NTR_WA U(0x9)
517#define MAIR_NORM_WT_NTR_RA U(0xa)
518#define MAIR_NORM_WT_NTR_RWA U(0xb)
519#define MAIR_NORM_WB_NTR_NA U(0xc)
520#define MAIR_NORM_WB_NTR_WA U(0xd)
521#define MAIR_NORM_WB_NTR_RA U(0xe)
522#define MAIR_NORM_WB_NTR_RWA U(0xf)
523
524#define MAIR_NORM_OUTER_SHIFT 4
525
526#define MAKE_MAIR_NORMAL_MEMORY(inner, outer) ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT))
527
Soby Mathewc6820d12016-05-09 17:49:55 +0100528#endif /* __ARCH_H__ */