37#ifndef LIBCPU_SHARED_ARM_CP15_H
38#define LIBCPU_SHARED_ARM_CP15_H
50#ifndef ARM_CP15_TEXT_SECTION
51 #define ARM_CP15_TEXT_SECTION
54#define ARM_CP15_CACHE_PREPARE_MVA(mva) \
55 ((const void *) (((uint32_t) (mva)) & ~0x1fU))
57#define ARM_CP15_TLB_PREPARE_MVA(mva) \
58 ((const void *) (((uint32_t) (mva)) & ~0x3fU))
80#define ARM_MMU_SECT_BASE_SHIFT 20
81#define ARM_MMU_SECT_BASE_MASK (0xfffU << ARM_MMU_SECT_BASE_SHIFT)
82#define ARM_MMU_SECT_NS (1U << 19)
83#define ARM_MMU_SECT_NG (1U << 17)
84#define ARM_MMU_SECT_S (1U << 16)
85#define ARM_MMU_SECT_AP_2 (1U << 15)
86#define ARM_MMU_SECT_TEX_2 (1U << 14)
87#define ARM_MMU_SECT_TEX_1 (1U << 13)
88#define ARM_MMU_SECT_TEX_0 (1U << 12)
89#define ARM_MMU_SECT_TEX_SHIFT 12
90#define ARM_MMU_SECT_TEX_MASK (0x3U << ARM_MMU_SECT_TEX_SHIFT)
91#define ARM_MMU_SECT_AP_1 (1U << 11)
92#define ARM_MMU_SECT_AP_0 (1U << 10)
93#define ARM_MMU_SECT_AP_SHIFT 10
94#define ARM_MMU_SECT_AP_MASK (0x23U << ARM_MMU_SECT_AP_SHIFT)
95#define ARM_MMU_SECT_DOMAIN_SHIFT 5
96#define ARM_MMU_SECT_DOMAIN_MASK (0xfU << ARM_MMU_SECT_DOMAIN_SHIFT)
97#define ARM_MMU_SECT_XN (1U << 4)
98#define ARM_MMU_SECT_C (1U << 3)
99#define ARM_MMU_SECT_B (1U << 2)
100#define ARM_MMU_SECT_PXN (1U << 0)
101#define ARM_MMU_SECT_DEFAULT 0x2U
102#define ARM_MMU_SECT_GET_INDEX(mva) \
103 (((uint32_t) (mva)) >> ARM_MMU_SECT_BASE_SHIFT)
104#define ARM_MMU_SECT_MVA_ALIGN_UP(mva) \
105 ((1U << ARM_MMU_SECT_BASE_SHIFT) \
106 + ((((uint32_t) (mva) - 1U)) & ~((1U << ARM_MMU_SECT_BASE_SHIFT) - 1U)))
108#define ARM_MMU_PAGE_TABLE_BASE_SHIFT 10
109#define ARM_MMU_PAGE_TABLE_BASE_MASK (0x3fffffU << ARM_MMU_PAGE_TABLE_BASE_SHIFT)
110#define ARM_MMU_PAGE_TABLE_DOMAIN_SHIFT 5
111#define ARM_MMU_PAGE_TABLE_DOMAIN_MASK (0xfU << ARM_MMU_PAGE_TABLE_DOMAIN_SHIFT)
112#define ARM_MMU_PAGE_TABLE_NS (1U << 3)
113#define ARM_MMU_PAGE_TABLE_PXN (1U << 2)
114#define ARM_MMU_PAGE_TABLE_DEFAULT 0x1U
116#define ARM_MMU_SMALL_PAGE_BASE_SHIFT 12
117#define ARM_MMU_SMALL_PAGE_BASE_MASK (0xfffffU << ARM_MMU_SMALL_PAGE_BASE_SHIFT)
118#define ARM_MMU_SMALL_PAGE_NG (1U << 11)
119#define ARM_MMU_SMALL_PAGE_S (1U << 10)
120#define ARM_MMU_SMALL_PAGE_AP_2 (1U << 9)
121#define ARM_MMU_SMALL_PAGE_TEX_2 (1U << 8)
122#define ARM_MMU_SMALL_PAGE_TEX_1 (1U << 7)
123#define ARM_MMU_SMALL_PAGE_TEX_0 (1U << 6)
124#define ARM_MMU_SMALL_PAGE_TEX_SHIFT 6
125#define ARM_MMU_SMALL_PAGE_TEX_MASK (0x3U << ARM_MMU_SMALL_PAGE_TEX_SHIFT)
126#define ARM_MMU_SMALL_PAGE_AP_1 (1U << 5)
127#define ARM_MMU_SMALL_PAGE_AP_0 (1U << 4)
128#define ARM_MMU_SMALL_PAGE_AP_SHIFT 4
129#define ARM_MMU_SMALL_PAGE_AP_MASK (0x23U << ARM_MMU_SMALL_PAGE_AP_SHIFT)
130#define ARM_MMU_SMALL_PAGE_C (1U << 3)
131#define ARM_MMU_SMALL_PAGE_B (1U << 2)
132#define ARM_MMU_SMALL_PAGE_XN (1U << 0)
133#define ARM_MMU_SMALL_PAGE_DEFAULT 0x2U
134#define ARM_MMU_SMALL_PAGE_GET_INDEX(mva) \
135 (((uint32_t) (mva)) >> ARM_MMU_SMALL_PAGE_BASE_SHIFT)
136#define ARM_MMU_SMALL_PAGE_MVA_ALIGN_UP(mva) \
137 ((1U << ARM_MMU_SMALL_PAGE_BASE_SHIFT) \
138 + ((((uint32_t) (mva) - 1U)) & ~((1U << ARM_MMU_SMALL_PAGE_BASE_SHIFT) - 1U)))
140#define ARM_MMU_SECT_FLAGS_TO_PAGE_TABLE(flags) \
141 (ARM_MMU_PAGE_TABLE_DEFAULT \
142 | ((flags) & ARM_MMU_SECT_DOMAIN_MASK) \
143 | (((flags) & ARM_MMU_SECT_NS) >> 16) \
144 | (((flags) & ARM_MMU_SECT_PXN) << 2))
146#define ARM_MMU_PAGE_TABLE_FLAGS_TO_SECT(flags) \
147 (ARM_MMU_SECT_DEFAULT \
148 | ((flags) & ARM_MMU_PAGE_TABLE_DOMAIN_MASK) \
149 | (((flags) & ARM_MMU_PAGE_TABLE_NS) << 16) \
150 | (((flags) & ARM_MMU_PAGE_TABLE_PXN) >> 2))
152#define ARM_MMU_SECT_FLAGS_TO_SMALL_PAGE(flags) \
153 ((((flags) & 0x3fc00) >> 6) \
154 | ((flags) & (ARM_MMU_SECT_C | ARM_MMU_SECT_B | 0x2)) \
155 | (((flags) & ARM_MMU_SECT_XN) >> 4))
157#define ARM_MMU_SMALL_PAGE_FLAGS_TO_SECT(flags) \
158 ((((flags) & 0xff0) << 6) \
159 | ((flags) & (ARM_MMU_SMALL_PAGE_C | ARM_MMU_SMALL_PAGE_B | 0x2)) \
160 | (((flags) & ARM_MMU_SMALL_PAGE_XN) << 4))
162#define ARM_MMU_TRANSLATION_TABLE_ENTRY_SIZE 4U
163#define ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT 4096U
165#define ARM_MMU_SMALL_PAGE_TABLE_ENTRY_SIZE 4U
166#define ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT 256U
168#define ARM_MMU_DEFAULT_CLIENT_DOMAIN 15U
170#define ARMV7_MMU_READ_ONLY \
171 ((ARM_MMU_DEFAULT_CLIENT_DOMAIN << ARM_MMU_SECT_DOMAIN_SHIFT) \
172 | ARM_MMU_SECT_AP_0 \
173 | ARM_MMU_SECT_AP_2 \
174 | ARM_MMU_SECT_DEFAULT)
176#define ARMV7_MMU_READ_ONLY_CACHED \
177 (ARMV7_MMU_READ_ONLY | ARM_MMU_SECT_TEX_0 | ARM_MMU_SECT_C | ARM_MMU_SECT_B)
179#define ARMV7_MMU_READ_WRITE \
180 ((ARM_MMU_DEFAULT_CLIENT_DOMAIN << ARM_MMU_SECT_DOMAIN_SHIFT) \
181 | ARM_MMU_SECT_AP_0 \
182 | ARM_MMU_SECT_DEFAULT)
185 #define ARMV7_MMU_READ_WRITE_CACHED \
186 (ARMV7_MMU_READ_WRITE \
187 | ARM_MMU_SECT_TEX_0 | ARM_MMU_SECT_C | ARM_MMU_SECT_B | ARM_MMU_SECT_S)
189 #define ARMV7_MMU_READ_WRITE_CACHED \
190 (ARMV7_MMU_READ_WRITE \
191 | ARM_MMU_SECT_TEX_0 | ARM_MMU_SECT_C | ARM_MMU_SECT_B)
194#define ARMV7_MMU_DATA_READ_ONLY \
195 (ARMV7_MMU_READ_ONLY | ARM_MMU_SECT_TEX_0)
197#define ARMV7_MMU_DATA_READ_ONLY_CACHED \
198 ARMV7_MMU_READ_ONLY_CACHED
200#define ARMV7_MMU_DATA_READ_WRITE \
201 (ARMV7_MMU_READ_WRITE | ARM_MMU_SECT_TEX_0)
203#define ARMV7_MMU_DATA_READ_WRITE_CACHED \
204 ARMV7_MMU_READ_WRITE_CACHED
206#define ARMV7_MMU_CODE \
207 (ARMV7_MMU_READ_ONLY | ARM_MMU_SECT_TEX_0)
209#define ARMV7_MMU_CODE_CACHED \
210 ARMV7_MMU_READ_ONLY_CACHED
212#define ARMV7_MMU_DEVICE \
213 (ARMV7_MMU_READ_WRITE | ARM_MMU_SECT_B)
223#define ARM_CP15_CTRL_TE (1U << 30)
224#define ARM_CP15_CTRL_AFE (1U << 29)
225#define ARM_CP15_CTRL_TRE (1U << 28)
226#define ARM_CP15_CTRL_NMFI (1U << 27)
227#define ARM_CP15_CTRL_EE (1U << 25)
228#define ARM_CP15_CTRL_VE (1U << 24)
229#define ARM_CP15_CTRL_XP (1U << 23)
230#define ARM_CP15_CTRL_U (1U << 22)
231#define ARM_CP15_CTRL_FI (1U << 21)
232#define ARM_CP15_CTRL_UWXN (1U << 20)
233#define ARM_CP15_CTRL_WXN (1U << 19)
234#define ARM_CP15_CTRL_HA (1U << 17)
235#define ARM_CP15_CTRL_L4 (1U << 15)
236#define ARM_CP15_CTRL_RR (1U << 14)
237#define ARM_CP15_CTRL_V (1U << 13)
238#define ARM_CP15_CTRL_I (1U << 12)
239#define ARM_CP15_CTRL_Z (1U << 11)
240#define ARM_CP15_CTRL_SW (1U << 10)
241#define ARM_CP15_CTRL_R (1U << 9)
242#define ARM_CP15_CTRL_S (1U << 8)
243#define ARM_CP15_CTRL_B (1U << 7)
244#define ARM_CP15_CTRL_CP15BEN (1U << 5)
245#define ARM_CP15_CTRL_C (1U << 2)
246#define ARM_CP15_CTRL_A (1U << 1)
247#define ARM_CP15_CTRL_M (1U << 0)
257#define ARM_CP15_DAC_NO_ACCESS 0x0U
258#define ARM_CP15_DAC_CLIENT 0x1U
259#define ARM_CP15_DAC_MANAGER 0x3U
260#define ARM_CP15_DAC_DOMAIN(index, val) ((val) << (2 * index))
270#define ARM_CP15_FAULT_STATUS_MASK 0x040F
272#define ARM_CP15_FSR_ALIGNMENT_FAULT 0x00000001
273#define ARM_CP15_FSR_BACKGROUND_FAULT 0x0000
274#define ARM_CP15_FSR_ACCESS_PERMISSION_FAULT 0x000D
275#define ARM_CP15_FSR_PRECISE_EXTERNAL_ABORT_FAULT 0x0008
276#define ARM_CP15_FSR_IMPRECISE_EXTERNAL_ABORT_FAULT 0x0406
277#define ARM_CP15_FSR_PRECISE_PARITY_ERROR_EXCEPTION 0x0006
278#define ARM_CP15_FSR_IMPRECISE_PARITY_ERROR_EXCEPTION 0x0408
279#define ARM_CP15_FSR_DEBUG_EVENT 0x0002
292#define ARM_CP15_CACHE_TYPE_FORMAT_ARMV6 0
293#define ARM_CP15_CACHE_TYPE_FORMAT_ARMV7 4
303#define ARM_CP15_CACHE_CSS_ID_DATA 0
304#define ARM_CP15_CACHE_CSS_ID_INSTRUCTION 1
305#define ARM_CP15_CACHE_CSS_LEVEL(level) ((level) << 1)
309ARM_CP15_TEXT_SECTION
static inline uint32_t
310arm_cp15_get_id_code(
void)
312 ARM_SWITCH_REGISTERS;
317 "mrc p15, 0, %[val], c0, c0, 0\n"
319 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
325ARM_CP15_TEXT_SECTION
static inline uint32_t
326arm_cp15_get_tcm_status(
void)
328 ARM_SWITCH_REGISTERS;
333 "mrc p15, 0, %[val], c0, c0, 2\n"
335 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
341ARM_CP15_TEXT_SECTION
static inline uint32_t
342arm_cp15_get_control(
void)
344 ARM_SWITCH_REGISTERS;
349 "mrc p15, 0, %[val], c1, c0, 0\n"
351 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
357ARM_CP15_TEXT_SECTION
static inline void
358arm_cp15_set_control(uint32_t val)
360 ARM_SWITCH_REGISTERS;
364 "mcr p15, 0, %[val], c1, c0, 0\n"
390ARM_CP15_TEXT_SECTION
static inline uint32_t
391arm_cp15_mmu_disable(uint32_t cls)
393 ARM_SWITCH_REGISTERS;
400 "mrc p15, 0, %[ctrl], c1, c0, 0\n"
401 "bic %[tmp_0], %[ctrl], #1\n"
402 "mcr p15, 0, %[tmp_0], c1, c0, 0\n"
406 "rsb %[tmp_0], %[cls], #0\n"
407 "and %[tmp_0], %[tmp_0], %[tmp_1]\n"
408 "sub %[tmp_0], %[tmp_0], %[cls], asl #3\n"
409 "add %[tmp_1], %[tmp_0], %[cls], asl #4\n"
411 "mcr p15, 0, %[tmp_0], c7, c14, 1\n"
412 "add %[tmp_0], %[tmp_0], %[cls]\n"
413 "cmp %[tmp_1], %[tmp_0]\n"
416 : [ctrl]
"=&r" (ctrl),
417 [tmp_0]
"=&r" (tmp_0),
418 [tmp_1]
"=&r" (tmp_1)
419 ARM_SWITCH_ADDITIONAL_OUTPUT
427ARM_CP15_TEXT_SECTION
static inline uint32_t
428*arm_cp15_get_translation_table_base(
void)
430 ARM_SWITCH_REGISTERS;
435 "mrc p15, 0, %[base], c2, c0, 0\n"
437 : [base]
"=&r" (base) ARM_SWITCH_ADDITIONAL_OUTPUT
443ARM_CP15_TEXT_SECTION
static inline void
444arm_cp15_set_translation_table_base(uint32_t *base)
446 ARM_SWITCH_REGISTERS;
450 "mcr p15, 0, %[base], c2, c0, 0\n"
458ARM_CP15_TEXT_SECTION
static inline uint32_t
459arm_cp15_get_translation_table_base_control_register(
void)
461 ARM_SWITCH_REGISTERS;
466 "mrc p15, 0, %[ttb_cr], c2, c0, 2\n"
468 : [ttb_cr]
"=&r" (ttb_cr) ARM_SWITCH_ADDITIONAL_OUTPUT
474ARM_CP15_TEXT_SECTION
static inline void
475arm_cp15_set_translation_table_base_control_register(uint32_t ttb_cr)
477 ARM_SWITCH_REGISTERS;
481 "mcr p15, 0, %[ttb_cr], c2, c0, 2\n"
484 : [ttb_cr]
"r" (ttb_cr)
488ARM_CP15_TEXT_SECTION
static inline uint32_t
489arm_cp15_get_domain_access_control(
void)
491 ARM_SWITCH_REGISTERS;
496 "mrc p15, 0, %[val], c3, c0, 0\n"
498 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
504ARM_CP15_TEXT_SECTION
static inline void
505arm_cp15_set_domain_access_control(uint32_t val)
507 ARM_SWITCH_REGISTERS;
511 "mcr p15, 0, %[val], c3, c0, 0\n"
518ARM_CP15_TEXT_SECTION
static inline uint32_t
519arm_cp15_get_data_fault_status(
void)
521 ARM_SWITCH_REGISTERS;
526 "mrc p15, 0, %[val], c5, c0, 0\n"
528 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
534ARM_CP15_TEXT_SECTION
static inline void
535arm_cp15_set_data_fault_status(uint32_t val)
537 ARM_SWITCH_REGISTERS;
541 "mcr p15, 0, %[val], c5, c0, 0\n"
548ARM_CP15_TEXT_SECTION
static inline uint32_t
549arm_cp15_get_instruction_fault_status(
void)
551 ARM_SWITCH_REGISTERS;
556 "mrc p15, 0, %[val], c5, c0, 1\n"
558 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
564ARM_CP15_TEXT_SECTION
static inline void
565arm_cp15_set_instruction_fault_status(uint32_t val)
567 ARM_SWITCH_REGISTERS;
571 "mcr p15, 0, %[val], c5, c0, 1\n"
578ARM_CP15_TEXT_SECTION
static inline void
579*arm_cp15_get_fault_address(
void)
581 ARM_SWITCH_REGISTERS;
586 "mrc p15, 0, %[mva], c6, c0, 0\n"
588 : [mva]
"=&r" (mva) ARM_SWITCH_ADDITIONAL_OUTPUT
594ARM_CP15_TEXT_SECTION
static inline void
595arm_cp15_set_fault_address(
const void *mva)
597 ARM_SWITCH_REGISTERS;
601 "mcr p15, 0, %[mva], c6, c0, 0\n"
608ARM_CP15_TEXT_SECTION
static inline void
609arm_cp15_tlb_invalidate(
void)
611 ARM_SWITCH_REGISTERS;
616 "mcr p15, 0, %[sbz], c8, c7, 0\n"
626 _ARM_Data_synchronization_barrier();
627 _ARM_Instruction_synchronization_barrier();
630ARM_CP15_TEXT_SECTION
static inline void
631arm_cp15_tlb_invalidate_entry(
const void *mva)
633 ARM_SWITCH_REGISTERS;
635 mva = ARM_CP15_TLB_PREPARE_MVA(mva);
639 "mcr p15, 0, %[mva], c8, c7, 1\n"
646ARM_CP15_TEXT_SECTION
static inline void
647arm_cp15_tlb_invalidate_entry_all_asids(
const void *mva)
649 ARM_SWITCH_REGISTERS;
651 mva = ARM_CP15_TLB_PREPARE_MVA(mva);
655 "mcr p15, 0, %[mva], c8, c7, 3\n"
662ARM_CP15_TEXT_SECTION
static inline void
663arm_cp15_tlb_invalidate_entry_all_asids_inner_shareable(
const void *mva)
665 ARM_SWITCH_REGISTERS;
667 mva = ARM_CP15_TLB_PREPARE_MVA(mva);
671 "mcr p15, 0, %[mva], c8, c3, 3\n"
678ARM_CP15_TEXT_SECTION
static inline void
679arm_cp15_tlb_instruction_invalidate(
void)
681 ARM_SWITCH_REGISTERS;
686 "mcr p15, 0, %[sbz], c8, c5, 0\n"
693ARM_CP15_TEXT_SECTION
static inline void
694arm_cp15_tlb_instruction_invalidate_entry(
const void *mva)
696 ARM_SWITCH_REGISTERS;
698 mva = ARM_CP15_TLB_PREPARE_MVA(mva);
702 "mcr p15, 0, %[mva], c8, c5, 1\n"
709ARM_CP15_TEXT_SECTION
static inline void
710arm_cp15_tlb_data_invalidate(
void)
712 ARM_SWITCH_REGISTERS;
717 "mcr p15, 0, %[sbz], c8, c6, 0\n"
724ARM_CP15_TEXT_SECTION
static inline void
725arm_cp15_tlb_data_invalidate_entry(
const void *mva)
727 ARM_SWITCH_REGISTERS;
729 mva = ARM_CP15_TLB_PREPARE_MVA(mva);
733 "mcr p15, 0, %[mva], c8, c6, 1\n"
740ARM_CP15_TEXT_SECTION
static inline void
741arm_cp15_tlb_lockdown_entry(
const void *mva)
743 uint32_t arm_switch_reg;
747 "add %[arm_switch_reg], pc, #16\n"
748 "mcr p15, 0, %[arm_switch_reg], c7, c13, 1\n"
749 "mcr p15, 0, %[mva], c8, c7, 1\n"
750 "mrc p15, 0, %[arm_switch_reg], c10, c0, 0\n"
751 "orr %[arm_switch_reg], #0x1\n"
752 "mcr p15, 0, %[arm_switch_reg], c10, c0, 0\n"
753 "ldr %[mva], [%[mva]]\n"
754 "mrc p15, 0, %[arm_switch_reg], c10, c0, 0\n"
755 "bic %[arm_switch_reg], #0x1\n"
756 "mcr p15, 0, %[arm_switch_reg], c10, c0, 0\n"
758 : [mva]
"=r" (mva), [arm_switch_reg]
"=&r" (arm_switch_reg)
772ARM_CP15_TEXT_SECTION
static inline uint32_t
773arm_cp15_get_cache_type(
void)
775 ARM_SWITCH_REGISTERS;
780 "mrc p15, 0, %[val], c0, c0, 1\n"
782 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
789ARM_CP15_TEXT_SECTION
static inline int
790arm_cp15_cache_type_get_format(uint32_t
ct)
792 return (
ct >> 29) & 0x7U;
796ARM_CP15_TEXT_SECTION
static inline uint32_t
797arm_cp15_get_min_cache_line_size(
void)
800 uint32_t
ct = arm_cp15_get_cache_type();
801 uint32_t
format = arm_cp15_cache_type_get_format(
ct);
803 if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV7) {
805 mcls = (1U << (
ct & 0xf)) * 4;
806 }
else if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV6) {
808 uint32_t mask = (1U << 12) - 1;
809 uint32_t dcls = (
ct >> 12) & mask;
810 uint32_t icls =
ct & mask;
812 mcls = dcls <= icls ? dcls : icls;
819ARM_CP15_TEXT_SECTION
static inline uint32_t
820arm_cp15_get_data_cache_line_size(
void)
823 uint32_t
ct = arm_cp15_get_cache_type();
824 uint32_t
format = arm_cp15_cache_type_get_format(
ct);
826 if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV7) {
828 mcls = (1U << ((
ct & 0xf0000) >> 16)) * 4;
829 }
else if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV6) {
831 uint32_t mask = (1U << 12) - 1;
832 mcls = (
ct >> 12) & mask;
839ARM_CP15_TEXT_SECTION
static inline uint32_t
840arm_cp15_get_instruction_cache_line_size(
void)
843 uint32_t
ct = arm_cp15_get_cache_type();
844 uint32_t
format = arm_cp15_cache_type_get_format(
ct);
846 if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV7) {
848 mcls = (1U << (
ct & 0x0000f)) * 4;
849 }
else if (
format == ARM_CP15_CACHE_TYPE_FORMAT_ARMV6) {
851 uint32_t mask = (1U << 12) - 1;
860ARM_CP15_TEXT_SECTION
static inline uint32_t
861arm_cp15_get_cache_size_id(
void)
863 ARM_SWITCH_REGISTERS;
868 "mrc p15, 1, %[val], c0, c0, 0\n"
870 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
876ARM_CP15_TEXT_SECTION
static inline uint32_t
877arm_ccsidr_get_line_power(uint32_t ccsidr)
879 return (ccsidr & 0x7) + 4;
882ARM_CP15_TEXT_SECTION
static inline uint32_t
883arm_ccsidr_get_associativity(uint32_t ccsidr)
885 return ((ccsidr >> 3) & 0x3ff) + 1;
888ARM_CP15_TEXT_SECTION
static inline uint32_t
889arm_ccsidr_get_num_sets(uint32_t ccsidr)
891 return ((ccsidr >> 13) & 0x7fff) + 1;
896ARM_CP15_TEXT_SECTION
static inline uint32_t
897arm_cp15_get_cache_level_id(
void)
899 ARM_SWITCH_REGISTERS;
904 "mrc p15, 1, %[val], c0, c0, 1\n"
906 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
912ARM_CP15_TEXT_SECTION
static inline uint32_t
913arm_clidr_get_level_of_coherency(uint32_t clidr)
915 return (clidr >> 24) & 0x7;
918ARM_CP15_TEXT_SECTION
static inline uint32_t
919arm_clidr_get_cache_type(uint32_t clidr, uint32_t level)
921 return (clidr >> (3 * level)) & 0x7;
926ARM_CP15_TEXT_SECTION
static inline uint32_t
927arm_cp15_get_cache_size_selection(
void)
929 ARM_SWITCH_REGISTERS;
934 "mrc p15, 2, %[val], c0, c0, 0\n"
936 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
942ARM_CP15_TEXT_SECTION
static inline void
943arm_cp15_set_cache_size_selection(uint32_t val)
945 ARM_SWITCH_REGISTERS;
949 "mcr p15, 2, %[val], c0, c0, 0\n"
957ARM_CP15_TEXT_SECTION
static inline uint32_t
958arm_cp15_get_cache_size_id_for_level(uint32_t level_and_inst_dat)
964 arm_cp15_set_cache_size_selection(level_and_inst_dat);
965 _ARM_Instruction_synchronization_barrier();
966 ccsidr = arm_cp15_get_cache_size_id();
972ARM_CP15_TEXT_SECTION
static inline void
973arm_cp15_cache_invalidate(
void)
975 ARM_SWITCH_REGISTERS;
980 "mcr p15, 0, %[sbz], c7, c7, 0\n"
990ARM_CP15_TEXT_SECTION
static inline void
991arm_cp15_instruction_cache_inner_shareable_invalidate_all(
void)
993 ARM_SWITCH_REGISTERS;
998 "mcr p15, 0, %[sbz], c7, c1, 0\n"
1008ARM_CP15_TEXT_SECTION
static inline void
1009arm_cp15_branch_predictor_inner_shareable_invalidate_all(
void)
1011 ARM_SWITCH_REGISTERS;
1016 "mcr p15, 0, %[sbz], c7, c1, 6\n"
1026ARM_CP15_TEXT_SECTION
static inline void
1027arm_cp15_branch_predictor_invalidate_all(
void)
1029 ARM_SWITCH_REGISTERS;
1034 "mcr p15, 0, %[sbz], c7, c5, 6\n"
1043ARM_CP15_TEXT_SECTION
static inline void
1044arm_cp15_flush_prefetch_buffer(
void)
1046 ARM_SWITCH_REGISTERS;
1051 "mcr p15, 0, %[sbz], c7, c5, 4\n"
1059ARM_CP15_TEXT_SECTION
static inline void
1060arm_cp15_instruction_cache_invalidate(
void)
1062 ARM_SWITCH_REGISTERS;
1067 "mcr p15, 0, %[sbz], c7, c5, 0\n"
1075ARM_CP15_TEXT_SECTION
static inline void
1076arm_cp15_instruction_cache_invalidate_line(
const void *mva)
1078 ARM_SWITCH_REGISTERS;
1080 mva = ARM_CP15_CACHE_PREPARE_MVA(mva);
1084 "mcr p15, 0, %[mva], c7, c5, 1\n"
1092ARM_CP15_TEXT_SECTION
static inline void
1093arm_cp15_instruction_cache_invalidate_line_by_set_and_way(uint32_t set_and_way)
1095 ARM_SWITCH_REGISTERS;
1099 "mcr p15, 0, %[set_and_way], c7, c5, 2\n"
1102 : [set_and_way]
"r" (set_and_way)
1107ARM_CP15_TEXT_SECTION
static inline void
1108arm_cp15_instruction_cache_prefetch_line(
const void *mva)
1110 ARM_SWITCH_REGISTERS;
1112 mva = ARM_CP15_CACHE_PREPARE_MVA(mva);
1116 "mcr p15, 0, %[mva], c7, c13, 1\n"
1123ARM_CP15_TEXT_SECTION
static inline void
1124arm_cp15_data_cache_invalidate(
void)
1126 ARM_SWITCH_REGISTERS;
1131 "mcr p15, 0, %[sbz], c7, c6, 0\n"
1139ARM_CP15_TEXT_SECTION
static inline void
1140arm_cp15_data_cache_invalidate_line(
const void *mva)
1142 ARM_SWITCH_REGISTERS;
1144 mva = ARM_CP15_CACHE_PREPARE_MVA(mva);
1148 "mcr p15, 0, %[mva], c7, c6, 1\n"
1156ARM_CP15_TEXT_SECTION
static inline void
1157arm_cp15_data_cache_invalidate_line_by_set_and_way(uint32_t set_and_way)
1159 ARM_SWITCH_REGISTERS;
1163 "mcr p15, 0, %[set_and_way], c7, c6, 2\n"
1166 : [set_and_way]
"r" (set_and_way)
1171ARM_CP15_TEXT_SECTION
static inline void
1172arm_cp15_cache_invalidate_level(uint32_t level, uint32_t inst_data_fl)
1175 uint32_t line_power;
1176 uint32_t associativity;
1180 ccsidr = arm_cp15_get_cache_size_id_for_level((level << 1) | inst_data_fl);
1182 line_power = arm_ccsidr_get_line_power(ccsidr);
1183 associativity = arm_ccsidr_get_associativity(ccsidr);
1184 way_shift = __builtin_clz(associativity - 1);
1186 for (way = 0; way < associativity; ++way) {
1187 uint32_t num_sets = arm_ccsidr_get_num_sets(ccsidr);
1190 for (set = 0; set < num_sets; ++set) {
1191 uint32_t set_way = (way << way_shift)
1192 | (set << line_power)
1195 arm_cp15_data_cache_invalidate_line_by_set_and_way(set_way);
1200ARM_CP15_TEXT_SECTION
static inline void
1201arm_cp15_data_cache_invalidate_all_levels(
void)
1203 uint32_t clidr = arm_cp15_get_cache_level_id();
1204 uint32_t loc = arm_clidr_get_level_of_coherency(clidr);
1207 for (level = 0; level < loc; ++level) {
1208 uint32_t ctype = arm_clidr_get_cache_type(clidr, level);
1211 if (((ctype & (0x6)) == 2) || (ctype == 4)) {
1212 arm_cp15_cache_invalidate_level(level, 0);
1217ARM_CP15_TEXT_SECTION
static inline void
1218arm_cp15_data_cache_clean_line(
const void *mva)
1220 ARM_SWITCH_REGISTERS;
1222 mva = ARM_CP15_CACHE_PREPARE_MVA(mva);
1226 "mcr p15, 0, %[mva], c7, c10, 1\n"
1234ARM_CP15_TEXT_SECTION
static inline void
1235arm_cp15_data_cache_clean_line_by_set_and_way(uint32_t set_and_way)
1237 ARM_SWITCH_REGISTERS;
1241 "mcr p15, 0, %[set_and_way], c7, c10, 2\n"
1244 : [set_and_way]
"r" (set_and_way)
1249ARM_CP15_TEXT_SECTION
static inline void
1250arm_cp15_data_cache_clean_level(uint32_t level)
1253 uint32_t line_power;
1254 uint32_t associativity;
1258 ccsidr = arm_cp15_get_cache_size_id_for_level(level << 1);
1260 line_power = arm_ccsidr_get_line_power(ccsidr);
1261 associativity = arm_ccsidr_get_associativity(ccsidr);
1262 way_shift = __builtin_clz(associativity - 1);
1264 for (way = 0; way < associativity; ++way) {
1265 uint32_t num_sets = arm_ccsidr_get_num_sets(ccsidr);
1268 for (set = 0; set < num_sets; ++set) {
1269 uint32_t set_way = (way << way_shift)
1270 | (set << line_power)
1273 arm_cp15_data_cache_clean_line_by_set_and_way(set_way);
1278ARM_CP15_TEXT_SECTION
static inline void
1279arm_cp15_data_cache_clean_all_levels(
void)
1281 uint32_t clidr = arm_cp15_get_cache_level_id();
1282 uint32_t loc = arm_clidr_get_level_of_coherency(clidr);
1285 for (level = 0; level < loc; ++level) {
1286 uint32_t ctype = arm_clidr_get_cache_type(clidr, level);
1289 if (((ctype & (0x6)) == 2) || (ctype == 4)) {
1290 arm_cp15_data_cache_clean_level(level);
1295ARM_CP15_TEXT_SECTION
static inline void
1296arm_cp15_data_cache_test_and_clean(
void)
1298 ARM_SWITCH_REGISTERS;
1303 "mrc p15, 0, r15, c7, c10, 3\n"
1312ARM_CP15_TEXT_SECTION
static inline void
1313arm_cp15_data_cache_clean_and_invalidate(
void)
1315 ARM_SWITCH_REGISTERS;
1327 "mcr p15, 0, %[sbz], c7, c14, 0\n"
1341 "mrc p15, 0, r15, c7, c14, 3\n"
1351ARM_CP15_TEXT_SECTION
static inline void
1352arm_cp15_data_cache_clean_and_invalidate_line(
const void *mva)
1354 ARM_SWITCH_REGISTERS;
1356 mva = ARM_CP15_CACHE_PREPARE_MVA(mva);
1360 "mcr p15, 0, %[mva], c7, c14, 1\n"
1368ARM_CP15_TEXT_SECTION
static inline void
1369arm_cp15_data_cache_clean_and_invalidate_line_by_set_and_way(uint32_t set_and_way)
1371 ARM_SWITCH_REGISTERS;
1375 "mcr p15, 0, %[set_and_way], c7, c14, 2\n"
1378 : [set_and_way]
"r" (set_and_way)
1383ARM_CP15_TEXT_SECTION
static inline void
1384arm_cp15_data_cache_test_and_clean_and_invalidate(
void)
1386 ARM_SWITCH_REGISTERS;
1391 "mrc p15, 0, r15, c7, c14, 3\n"
1402ARM_CP15_TEXT_SECTION
static inline void
1403arm_cp15_drain_write_buffer(
void)
1405 ARM_SWITCH_REGISTERS;
1410 "mcr p15, 0, %[sbz], c7, c10, 4\n"
1418ARM_CP15_TEXT_SECTION
static inline void
1419arm_cp15_wait_for_interrupt(
void)
1421 ARM_SWITCH_REGISTERS;
1426 "mcr p15, 0, %[sbz], c7, c0, 4\n"
1434ARM_CP15_TEXT_SECTION
static inline uint32_t
1435arm_cp15_get_multiprocessor_affinity(
void)
1437 ARM_SWITCH_REGISTERS;
1442 "mrc p15, 0, %[mpidr], c0, c0, 5\n"
1444 : [mpidr]
"=&r" (mpidr) ARM_SWITCH_ADDITIONAL_OUTPUT
1447 return mpidr & 0xff;
1450ARM_CP15_TEXT_SECTION
static inline uint32_t
1451arm_cortex_a9_get_multiprocessor_cpu_id(
void)
1453 return arm_cp15_get_multiprocessor_affinity() & 0xff;
1456#define ARM_CORTEX_A9_ACTL_FW (1U << 0)
1457#define ARM_CORTEX_A9_ACTL_L2_PREFETCH_HINT_ENABLE (1U << 1)
1458#define ARM_CORTEX_A9_ACTL_L1_PREFETCH_ENABLE (1U << 2)
1459#define ARM_CORTEX_A9_ACTL_WRITE_FULL_LINE_OF_ZEROS_MODE (1U << 3)
1460#define ARM_CORTEX_A9_ACTL_SMP (1U << 6)
1461#define ARM_CORTEX_A9_ACTL_EXCL (1U << 7)
1462#define ARM_CORTEX_A9_ACTL_ALLOC_IN_ONE_WAY (1U << 8)
1463#define ARM_CORTEX_A9_ACTL_PARITY_ON (1U << 9)
1465ARM_CP15_TEXT_SECTION
static inline uint32_t
1466arm_cp15_get_auxiliary_control(
void)
1468 ARM_SWITCH_REGISTERS;
1473 "mrc p15, 0, %[val], c1, c0, 1\n"
1475 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1481ARM_CP15_TEXT_SECTION
static inline void
1482arm_cp15_set_auxiliary_control(uint32_t val)
1484 ARM_SWITCH_REGISTERS;
1488 "mcr p15, 0, %[val], c1, c0, 1\n"
1497ARM_CP15_TEXT_SECTION
static inline uint32_t
1498arm_cp15_get_processor_feature_1(
void)
1500 ARM_SWITCH_REGISTERS;
1505 "mrc p15, 0, %[val], c0, c1, 1\n"
1507 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1515ARM_CP15_TEXT_SECTION
static inline void
1516*arm_cp15_get_vector_base_address(
void)
1518 ARM_SWITCH_REGISTERS;
1523 "mrc p15, 0, %[base], c12, c0, 0\n"
1525 : [base]
"=&r" (base) ARM_SWITCH_ADDITIONAL_OUTPUT
1531ARM_CP15_TEXT_SECTION
static inline void
1532arm_cp15_set_vector_base_address(
void *base)
1534 ARM_SWITCH_REGISTERS;
1538 "mcr p15, 0, %[base], c12, c0, 0\n"
1545ARM_CP15_TEXT_SECTION
static inline void
1546*arm_cp15_get_hyp_vector_base_address(
void)
1548 ARM_SWITCH_REGISTERS;
1553 "mrc p15, 4, %[base], c12, c0, 0\n"
1555 : [base]
"=&r" (base) ARM_SWITCH_ADDITIONAL_OUTPUT
1561ARM_CP15_TEXT_SECTION
static inline void
1562arm_cp15_set_hyp_vector_base_address(
void *base)
1564 ARM_SWITCH_REGISTERS;
1568 "mcr p15, 4, %[base], c12, c0, 0\n"
1576ARM_CP15_TEXT_SECTION
static inline uint32_t
1577arm_cp15_get_performance_monitors_cycle_count(
void)
1579 ARM_SWITCH_REGISTERS;
1584 "mrc p15, 0, %[val], c9, c13, 0\n"
1586 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1593ARM_CP15_TEXT_SECTION
static inline void
1594arm_cp15_set_performance_monitors_cycle_count(uint32_t val)
1596 ARM_SWITCH_REGISTERS;
1600 "mcr p15, 0, %[val], c9, c13, 0\n"
1608ARM_CP15_TEXT_SECTION
static inline uint32_t
1609arm_cp15_get_performance_monitors_common_event_id_0(
void)
1611 ARM_SWITCH_REGISTERS;
1616 "mrc p15, 0, %[val], c9, c12, 6\n"
1618 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1625ARM_CP15_TEXT_SECTION
static inline uint32_t
1626arm_cp15_get_performance_monitors_common_event_id_1(
void)
1628 ARM_SWITCH_REGISTERS;
1633 "mrc p15, 0, %[val], c9, c12, 7\n"
1635 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1641#define ARM_CP15_PMCLRSET_CYCLE_COUNTER 0x80000000
1644ARM_CP15_TEXT_SECTION
static inline uint32_t
1645arm_cp15_get_performance_monitors_count_enable_clear(
void)
1647 ARM_SWITCH_REGISTERS;
1652 "mrc p15, 0, %[val], c9, c12, 2\n"
1654 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1661ARM_CP15_TEXT_SECTION
static inline void
1662arm_cp15_set_performance_monitors_count_enable_clear(uint32_t val)
1664 ARM_SWITCH_REGISTERS;
1668 "mcr p15, 0, %[val], c9, c12, 2\n"
1676ARM_CP15_TEXT_SECTION
static inline uint32_t
1677arm_cp15_get_performance_monitors_count_enable_set(
void)
1679 ARM_SWITCH_REGISTERS;
1684 "mrc p15, 0, %[val], c9, c12, 1\n"
1686 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1693ARM_CP15_TEXT_SECTION
static inline void
1694arm_cp15_set_performance_monitors_count_enable_set(uint32_t val)
1696 ARM_SWITCH_REGISTERS;
1700 "mcr p15, 0, %[val], c9, c12, 1\n"
1707#define ARM_CP15_PMCR_IMP(x) ((x) << 24)
1708#define ARM_CP15_PMCR_IDCODE(x) ((x) << 16)
1709#define ARM_CP15_PMCR_N(x) ((x) << 11)
1710#define ARM_CP15_PMCR_DP (1U << 5)
1711#define ARM_CP15_PMCR_X (1U << 4)
1712#define ARM_CP15_PMCR_D (1U << 3)
1713#define ARM_CP15_PMCR_C (1U << 2)
1714#define ARM_CP15_PMCR_P (1U << 1)
1715#define ARM_CP15_PMCR_E (1U << 0)
1718ARM_CP15_TEXT_SECTION
static inline uint32_t
1719arm_cp15_get_performance_monitors_control(
void)
1721 ARM_SWITCH_REGISTERS;
1726 "mrc p15, 0, %[val], c9, c12, 0\n"
1728 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1735ARM_CP15_TEXT_SECTION
static inline void
1736arm_cp15_set_performance_monitors_control(uint32_t val)
1738 ARM_SWITCH_REGISTERS;
1742 "mcr p15, 0, %[val], c9, c12, 0\n"
1750ARM_CP15_TEXT_SECTION
static inline uint32_t
1751arm_cp15_get_performance_monitors_interrupt_enable_clear(
void)
1753 ARM_SWITCH_REGISTERS;
1758 "mrc p15, 0, %[val], c9, c14, 2\n"
1760 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1767ARM_CP15_TEXT_SECTION
static inline void
1768arm_cp15_set_performance_monitors_interrupt_enable_clear(uint32_t val)
1770 ARM_SWITCH_REGISTERS;
1774 "mcr p15, 0, %[val], c9, c14, 2\n"
1782ARM_CP15_TEXT_SECTION
static inline uint32_t
1783arm_cp15_get_performance_monitors_interrupt_enable_set(
void)
1785 ARM_SWITCH_REGISTERS;
1790 "mrc p15, 0, %[val], c9, c14, 1\n"
1792 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1799ARM_CP15_TEXT_SECTION
static inline void
1800arm_cp15_set_performance_monitors_interrupt_enable_set(uint32_t val)
1802 ARM_SWITCH_REGISTERS;
1806 "mcr p15, 0, %[val], c9, c14, 1\n"
1814ARM_CP15_TEXT_SECTION
static inline uint32_t
1815arm_cp15_get_performance_monitors_overflow_flag_status(
void)
1817 ARM_SWITCH_REGISTERS;
1822 "mrc p15, 0, %[val], c9, c12, 3\n"
1824 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1831ARM_CP15_TEXT_SECTION
static inline void
1832arm_cp15_set_performance_monitors_overflow_flag_status(uint32_t val)
1834 ARM_SWITCH_REGISTERS;
1838 "mcr p15, 0, %[val], c9, c12, 3\n"
1846ARM_CP15_TEXT_SECTION
static inline uint32_t
1847arm_cp15_get_performance_monitors_overflow_flag_status_set(
void)
1849 ARM_SWITCH_REGISTERS;
1854 "mrc p15, 0, %[val], c9, c14, 3\n"
1856 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1863ARM_CP15_TEXT_SECTION
static inline void
1864arm_cp15_set_performance_monitors_overflow_flag_status_set(uint32_t val)
1866 ARM_SWITCH_REGISTERS;
1870 "mcr p15, 0, %[val], c9, c14, 3\n"
1878ARM_CP15_TEXT_SECTION
static inline uint32_t
1879arm_cp15_get_performance_monitors_event_counter_selection(
void)
1881 ARM_SWITCH_REGISTERS;
1886 "mrc p15, 0, %[val], c9, c12, 5\n"
1888 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1895ARM_CP15_TEXT_SECTION
static inline void
1896arm_cp15_set_performance_monitors_event_counter_selection(uint32_t val)
1898 ARM_SWITCH_REGISTERS;
1902 "mcr p15, 0, %[val], c9, c12, 5\n"
1910ARM_CP15_TEXT_SECTION
static inline void
1911arm_cp15_set_performance_monitors_software_increment(uint32_t val)
1913 ARM_SWITCH_REGISTERS;
1917 "mcr p15, 0, %[val], c9, c12, 4\n"
1925ARM_CP15_TEXT_SECTION
static inline uint32_t
1926arm_cp15_get_performance_monitors_user_enable(
void)
1928 ARM_SWITCH_REGISTERS;
1933 "mrc p15, 0, %[val], c9, c14, 0\n"
1935 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1942ARM_CP15_TEXT_SECTION
static inline void
1943arm_cp15_set_performance_monitors_user_enable(uint32_t val)
1945 ARM_SWITCH_REGISTERS;
1949 "mcr p15, 0, %[val], c9, c14, 0\n"
1957ARM_CP15_TEXT_SECTION
static inline uint32_t
1958arm_cp15_get_performance_monitors_event_count(
void)
1960 ARM_SWITCH_REGISTERS;
1965 "mrc p15, 0, %[val], c9, c13, 2\n"
1967 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
1974ARM_CP15_TEXT_SECTION
static inline void
1975arm_cp15_set_performance_monitors_event_count(uint32_t val)
1977 ARM_SWITCH_REGISTERS;
1981 "mcr p15, 0, %[val], c9, c13, 2\n"
1989ARM_CP15_TEXT_SECTION
static inline uint32_t
1990arm_cp15_get_performance_monitors_event_type_select(
void)
1992 ARM_SWITCH_REGISTERS;
1997 "mrc p15, 0, %[val], c9, c13, 1\n"
1999 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2006ARM_CP15_TEXT_SECTION
static inline void
2007arm_cp15_set_performance_monitors_event_type_select(uint32_t val)
2009 ARM_SWITCH_REGISTERS;
2013 "mcr p15, 0, %[val], c9, c13, 1\n"
2021ARM_CP15_TEXT_SECTION
static inline uint32_t
2022arm_cp15_get_counter_frequency(
void)
2024 ARM_SWITCH_REGISTERS;
2029 "mrc p15, 0, %[val], c14, c0, 0\n"
2031 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2038ARM_CP15_TEXT_SECTION
static inline void
2039arm_cp15_set_counter_frequency(uint32_t val)
2041 ARM_SWITCH_REGISTERS;
2045 "mcr p15, 0, %[val], c14, c0, 0\n"
2053ARM_CP15_TEXT_SECTION
static inline uint64_t
2054arm_cp15_get_counter_physical_count(
void)
2056 ARM_SWITCH_REGISTERS;
2061 "mrrc p15, 0, %Q[val], %R[val], c14\n"
2063 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2070ARM_CP15_TEXT_SECTION
static inline uint32_t
2071arm_cp15_get_counter_non_secure_pl1_control(
void)
2073 ARM_SWITCH_REGISTERS;
2078 "mrc p15, 0, %[val], c14, c1, 0\n"
2080 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2087ARM_CP15_TEXT_SECTION
static inline void
2088arm_cp15_set_counter_non_secure_pl1_control(uint32_t val)
2090 ARM_SWITCH_REGISTERS;
2094 "mcr p15, 0, %[val], c14, c1, 0\n"
2102ARM_CP15_TEXT_SECTION
static inline uint32_t
2103arm_cp15_get_counter_pl1_physical_timer_value(
void)
2105 ARM_SWITCH_REGISTERS;
2110 "mrc p15, 0, %[val], c14, c2, 0\n"
2112 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2119ARM_CP15_TEXT_SECTION
static inline void
2120arm_cp15_set_counter_pl1_physical_timer_value(uint32_t val)
2122 ARM_SWITCH_REGISTERS;
2126 "mcr p15, 0, %[val], c14, c2, 0\n"
2134ARM_CP15_TEXT_SECTION
static inline uint32_t
2135arm_cp15_get_counter_pl1_physical_timer_control(
void)
2137 ARM_SWITCH_REGISTERS;
2142 "mrc p15, 0, %[val], c14, c2, 1\n"
2144 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2151ARM_CP15_TEXT_SECTION
static inline void
2152arm_cp15_set_counter_pl1_physical_timer_control(uint32_t val)
2154 ARM_SWITCH_REGISTERS;
2158 "mcr p15, 0, %[val], c14, c2, 1\n"
2166ARM_CP15_TEXT_SECTION
static inline uint32_t
2167arm_cp15_get_counter_pl1_virtual_timer_value(
void)
2169 ARM_SWITCH_REGISTERS;
2174 "mrc p15, 0, %[val], c14, c3, 0\n"
2176 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2183ARM_CP15_TEXT_SECTION
static inline void
2184arm_cp15_set_counter_pl1_virtual_timer_value(uint32_t val)
2186 ARM_SWITCH_REGISTERS;
2190 "mcr p15, 0, %[val], c14, c3, 0\n"
2198ARM_CP15_TEXT_SECTION
static inline uint32_t
2199arm_cp15_get_counter_pl1_virtual_timer_control(
void)
2201 ARM_SWITCH_REGISTERS;
2206 "mrc p15, 0, %[val], c14, c3, 1\n"
2208 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2215ARM_CP15_TEXT_SECTION
static inline void
2216arm_cp15_set_counter_pl1_virtual_timer_control(uint32_t val)
2218 ARM_SWITCH_REGISTERS;
2222 "mcr p15, 0, %[val], c14, c3, 1\n"
2230ARM_CP15_TEXT_SECTION
static inline uint64_t
2231arm_cp15_get_counter_virtual_count(
void)
2233 ARM_SWITCH_REGISTERS;
2238 "mrrc p15, 1, %Q[val], %R[val], c14\n"
2240 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2247ARM_CP15_TEXT_SECTION
static inline uint64_t
2248arm_cp15_get_counter_pl1_physical_compare_value(
void)
2250 ARM_SWITCH_REGISTERS;
2255 "mrrc p15, 2, %Q[val], %R[val], c14\n"
2257 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2264ARM_CP15_TEXT_SECTION
static inline void
2265arm_cp15_set_counter_pl1_physical_compare_value(uint64_t val)
2267 ARM_SWITCH_REGISTERS;
2271 "mcrr p15, 2, %Q[val], %R[val], c14\n"
2279ARM_CP15_TEXT_SECTION
static inline uint64_t
2280arm_cp15_get_counter_pl1_virtual_compare_value(
void)
2282 ARM_SWITCH_REGISTERS;
2287 "mrrc p15, 3, %Q[val], %R[val], c14\n"
2289 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2296ARM_CP15_TEXT_SECTION
static inline void
2297arm_cp15_set_counter_pl1_virtual_compare_value(uint64_t val)
2299 ARM_SWITCH_REGISTERS;
2303 "mcrr p15, 3, %Q[val], %R[val], c14\n"
2311ARM_CP15_TEXT_SECTION
static inline uint64_t
2312arm_cp15_get_counter_virtual_offset(
void)
2314 ARM_SWITCH_REGISTERS;
2319 "mrrc p15, 4, %Q[val], %R[val], c14\n"
2321 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2328ARM_CP15_TEXT_SECTION
static inline void
2329arm_cp15_set_counter_virtual_offset(uint64_t val)
2331 ARM_SWITCH_REGISTERS;
2335 "mcrr p15, 4, %Q[val], %R[val], c14\n"
2343ARM_CP15_TEXT_SECTION
static inline uint32_t
2344arm_cp15_get_diagnostic_control(
void)
2346 ARM_SWITCH_REGISTERS;
2351 "mrc p15, 0, %[val], c15, c0, 1\n"
2353 : [val]
"=&r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
2360ARM_CP15_TEXT_SECTION
static inline void
2361arm_cp15_set_diagnostic_control(uint32_t val)
2363 ARM_SWITCH_REGISTERS;
2367 "mcr p15, 0, %[val], c15, c0, 1\n"
2375ARM_CP15_TEXT_SECTION
static inline void
2376arm_cp15_data_cache_all_invalidate(
void)
2378 ARM_SWITCH_REGISTERS;
2383 "mcr p15, 0, %[sbz], c15, c5, 0\n"
2399 uint32_t section_flags
2408 Arm_symbolic_exception_name exception,
2409 void (*handler)(
void)
#define rtems_interrupt_local_disable(_isr_cookie)
Disables the maskable interrupts on the current processor.
Definition: intr.h:427
ISR_Level rtems_interrupt_level
This integer type represents interrupt levels.
Definition: intr.h:111
#define rtems_interrupt_local_enable(_isr_cookie)
Restores the previous interrupt level on the current processor.
Definition: intr.h:468
void * arm_cp15_set_exception_handler(Arm_symbolic_exception_name exception, void(*handler)(void))
Sets the exception handler in the vector table.
Definition: arm-cp15-set-exception-handler.c:41
uint32_t arm_cp15_set_translation_table_entries(const void *begin, const void *end, uint32_t section_flags)
Sets the section_flags for the address range [begin, end).
Definition: arm-cp15-set-ttb-entries.c:148
This header file defines the RTEMS Classic API.
unsigned ct
Definition: tlb.h:14