Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
cpu.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Lexmark International, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_A_R_CPU_H_
8#define ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_A_R_CPU_H_
9
10#if defined(CONFIG_ARM_MPU)
12#endif
13
14/*
15 * SCTLR register bit assignments
16 */
17#define SCTLR_MPU_ENABLE (1 << 0)
18
19#define MODE_USR 0x10
20#define MODE_FIQ 0x11
21#define MODE_IRQ 0x12
22#define MODE_SVC 0x13
23#define MODE_ABT 0x17
24#define MODE_HYP 0x1a
25#define MODE_UND 0x1b
26#define MODE_SYS 0x1f
27#define MODE_MASK 0x1f
28
29#define A_BIT (1 << 8)
30#define I_BIT (1 << 7)
31#define F_BIT (1 << 6)
32#define T_BIT (1 << 5)
33
34#define HIVECS (1 << 13)
35
36#define CPACR_NA (0U)
37#define CPACR_FA (3U)
38
39#define CPACR_CP10(r) (r << 20)
40#define CPACR_CP11(r) (r << 22)
41
42#define FPEXC_EN (1 << 30)
43
44#define DFSR_DOMAIN_SHIFT (4)
45#define DFSR_DOMAIN_MASK (0xf)
46#define DFSR_FAULT_4_MASK (1 << 10)
47#define DFSR_WRITE_MASK (1 << 11)
48#define DFSR_AXI_SLAVE_MASK (1 << 12)
49
50/* Armv8-R AArch32 architecture profile */
51#define VBAR_MASK (0xFFFFFFE0U)
52#define SCTLR_M_BIT BIT(0)
53#define SCTLR_A_BIT BIT(1)
54#define SCTLR_C_BIT BIT(2)
55#define SCTLR_I_BIT BIT(12)
56
57/* Hyp System Control Register */
58#define HSCTLR_RES1 (BIT(29) | BIT(28) | BIT(23) | \
59 BIT(22) | BIT(18) | BIT(16) | \
60 BIT(11) | BIT(4) | BIT(3))
61
62/* Hyp Auxiliary Control Register */
63#define HACTLR_CPUACTLR BIT(0)
64#define HACTLR_CDBGDCI BIT(1)
65#define HACTLR_FLASHIFREGIONR BIT(7)
66#define HACTLR_PERIPHPREGIONR BIT(8)
67#define HACTLR_QOSR_BIT BIT(9)
68#define HACTLR_BUSTIMEOUTR_BIT BIT(10)
69#define HACTLR_INTMONR_BIT BIT(12)
70#define HACTLR_ERR_BIT BIT(13)
71
72#define HACTLR_INIT (HACTLR_ERR_BIT | HACTLR_INTMONR_BIT | \
73 HACTLR_BUSTIMEOUTR_BIT | HACTLR_QOSR_BIT | \
74 HACTLR_PERIPHPREGIONR | HACTLR_FLASHIFREGIONR | \
75 HACTLR_CDBGDCI | HACTLR_CPUACTLR)
76/* ARMv8 Timer */
77#define CNTV_CTL_ENABLE_BIT BIT(0)
78#define CNTV_CTL_IMASK_BIT BIT(1)
79
80/* Interrupt Controller System Register Enable Register */
81#define ICC_SRE_ELx_SRE_BIT BIT(0)
82#define ICC_SRE_ELx_DFB_BIT BIT(1)
83#define ICC_SRE_ELx_DIB_BIT BIT(2)
84#define ICC_SRE_EL3_EN_BIT BIT(3)
85
86/* MPIDR */
87#define MPIDR_AFFLVL_MASK (0xff)
88
89#define MPIDR_AFF0_SHIFT (0)
90#define MPIDR_AFF1_SHIFT (8)
91#define MPIDR_AFF2_SHIFT (16)
92
93#define MPIDR_AFFLVL(mpidr, aff_level) \
94 (((mpidr) >> MPIDR_AFF##aff_level##_SHIFT) & MPIDR_AFFLVL_MASK)
95
96#define GET_MPIDR() read_sysreg(mpidr)
97#define MPIDR_TO_CORE(mpidr) MPIDR_AFFLVL(mpidr, 0)
98
99/* ICC SGI macros */
100#define SGIR_TGT_MASK (0xffff)
101#define SGIR_AFF1_SHIFT (16)
102#define SGIR_AFF2_SHIFT (32)
103#define SGIR_AFF3_SHIFT (48)
104#define SGIR_AFF_MASK (0xff)
105#define SGIR_INTID_SHIFT (24)
106#define SGIR_INTID_MASK (0xf)
107#define SGIR_IRM_SHIFT (40)
108#define SGIR_IRM_MASK (0x1)
109#define SGIR_IRM_TO_AFF (0)
110
111#define GICV3_SGIR_VALUE(_aff3, _aff2, _aff1, _intid, _irm, _tgt) \
112 ((((uint64_t) (_aff3) & SGIR_AFF_MASK) << SGIR_AFF3_SHIFT) | \
113 (((uint64_t) (_irm) & SGIR_IRM_MASK) << SGIR_IRM_SHIFT) | \
114 (((uint64_t) (_aff2) & SGIR_AFF_MASK) << SGIR_AFF2_SHIFT) | \
115 (((_intid) & SGIR_INTID_MASK) << SGIR_INTID_SHIFT) | \
116 (((_aff1) & SGIR_AFF_MASK) << SGIR_AFF1_SHIFT) | \
117 ((_tgt) & SGIR_TGT_MASK))
118
119#endif /* ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_A_R_CPU_H_ */