xref: /optee_os/core/arch/arm/include/arm.h (revision 8e81e2f5366a971afdd2ac47fb8529d1def5feb0)
1 /*
2  * Copyright (c) 2015, Linaro Limited
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef ARM_H
28 #define ARM_H
29 
30 #include <util.h>
31 
32 #define MPIDR_CPU_MASK		0xff
33 #define MPIDR_CLUSTER_SHIFT	8
34 #define MPIDR_CLUSTER_MASK	(0xff << MPIDR_CLUSTER_SHIFT)
35 
36 
37 /* CLIDR definitions */
38 #define CLIDR_LOUIS_SHIFT	21
39 #define CLIDR_LOC_SHIFT		24
40 #define CLIDR_FIELD_WIDTH	3
41 
42 /* CSSELR definitions */
43 #define CSSELR_LEVEL_SHIFT	1
44 
45 /* CTR definitions */
46 #define CTR_CWG_SHIFT		24
47 #define CTR_CWG_MASK		0xf
48 #define CTR_ERG_SHIFT		20
49 #define CTR_ERG_MASK		0xf
50 #define CTR_DMINLINE_SHIFT	16
51 #define CTR_DMINLINE_WIDTH	4
52 #define CTR_DMINLINE_MASK	((1 << 4) - 1)
53 #define CTR_L1IP_SHIFT		14
54 #define CTR_L1IP_MASK		0x3
55 #define CTR_IMINLINE_SHIFT	0
56 #define CTR_IMINLINE_MASK	0xf
57 
58 #define ARM32_CPSR_MODE_MASK	0x1f
59 #define ARM32_CPSR_MODE_USR	0x10
60 #define ARM32_CPSR_MODE_FIQ	0x11
61 #define ARM32_CPSR_MODE_IRQ	0x12
62 #define ARM32_CPSR_MODE_SVC	0x13
63 #define ARM32_CPSR_MODE_MON	0x16
64 #define ARM32_CPSR_MODE_ABT	0x17
65 #define ARM32_CPSR_MODE_UND	0x1b
66 #define ARM32_CPSR_MODE_SYS	0x1f
67 
68 #define ARM32_CPSR_T		(1 << 5)
69 #define ARM32_CPSR_F_SHIFT	6
70 #define ARM32_CPSR_F		(1 << 6)
71 #define ARM32_CPSR_I		(1 << 7)
72 #define ARM32_CPSR_A		(1 << 8)
73 #define ARM32_CPSR_E		(1 << 9)
74 #define ARM32_CPSR_FIA		(ARM32_CPSR_F | ARM32_CPSR_I | ARM32_CPSR_A)
75 #define ARM32_CPSR_IT_MASK	(ARM32_CPSR_IT_MASK1 | ARM32_CPSR_IT_MASK2)
76 #define ARM32_CPSR_IT_MASK1	0x06000000
77 #define ARM32_CPSR_IT_MASK2	0x0000fc00
78 
79 /* ARM Generic timer definitions */
80 #define CNTKCTL_PL0PCTEN	BIT(0) /* physical counter el0 access enable */
81 #define CNTKCTL_PL0VCTEN	BIT(1) /* virtual counter el0 access enable */
82 
83 #ifdef ARM32
84 #include <arm32.h>
85 #endif
86 
87 #ifdef ARM64
88 #include <arm64.h>
89 #endif
90 
91 #endif /*ARM_H*/
92