19#ifndef LIBBSP_ARM_SHARED_ARM_CP15_START_H
20#define LIBBSP_ARM_SHARED_ARM_CP15_START_H
24#include <bsp/linker-symbols.h>
37#define ARMV7_CP15_START_DEFAULT_SECTIONS \
39 .begin = (uint32_t) bsp_section_fast_text_begin, \
40 .end = (uint32_t) bsp_section_fast_text_end, \
41 .flags = ARMV7_MMU_CODE_CACHED \
43 .begin = (uint32_t) bsp_section_fast_data_begin, \
44 .end = (uint32_t) bsp_section_fast_data_end, \
45 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
47 .begin = (uint32_t) bsp_section_start_begin, \
48 .end = (uint32_t) bsp_section_start_end, \
49 .flags = ARMV7_MMU_CODE_CACHED \
51 .begin = (uint32_t) bsp_section_vector_begin, \
52 .end = (uint32_t) bsp_section_vector_end, \
53 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
55 .begin = (uint32_t) bsp_section_text_begin, \
56 .end = (uint32_t) bsp_section_text_end, \
57 .flags = ARMV7_MMU_CODE_CACHED \
59 .begin = (uint32_t) bsp_section_rodata_begin, \
60 .end = (uint32_t) bsp_section_rodata_end, \
61 .flags = ARMV7_MMU_DATA_READ_ONLY_CACHED \
63 .begin = (uint32_t) bsp_section_data_begin, \
64 .end = (uint32_t) bsp_section_data_end, \
65 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
67 .begin = (uint32_t) bsp_section_bss_begin, \
68 .end = (uint32_t) bsp_section_bss_end, \
69 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
71 .begin = (uint32_t) bsp_section_rtemsstack_begin, \
72 .end = (uint32_t) bsp_section_rtemsstack_end, \
73 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
75 .begin = (uint32_t) bsp_section_noinit_begin, \
76 .end = (uint32_t) bsp_section_noinit_end, \
77 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
79 .begin = (uint32_t) bsp_section_work_begin, \
80 .end = (uint32_t) bsp_section_work_end, \
81 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
83 .begin = (uint32_t) bsp_section_stack_begin, \
84 .end = (uint32_t) bsp_section_stack_end, \
85 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
87 .begin = (uint32_t) bsp_section_nocache_begin, \
88 .end = (uint32_t) bsp_section_nocache_end, \
89 .flags = ARMV7_MMU_DEVICE \
91 .begin = (uint32_t) bsp_section_nocachenoload_begin, \
92 .end = (uint32_t) bsp_section_nocachenoload_end, \
93 .flags = ARMV7_MMU_DEVICE \
95 .begin = (uint32_t) bsp_translation_table_base, \
96 .end = (uint32_t) bsp_translation_table_end, \
97 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \
100#define ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX 10
103 arm_cp15_start_mmu_config_table[];
105BSP_START_DATA_SECTION
extern const size_t
106 arm_cp15_start_mmu_config_table_size;
108BSP_START_TEXT_SECTION
static inline void
109arm_cp15_start_set_translation_table_entries(
119#ifdef ARM_MMU_USE_SMALL_PAGES
122 pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
123 i = ARM_MMU_SMALL_PAGE_GET_INDEX(
config->begin);
124 iend = ARM_MMU_SMALL_PAGE_GET_INDEX(ARM_MMU_SMALL_PAGE_MVA_ALIGN_UP(
config->end));
125 index_mask = (1U << (32 - ARM_MMU_SMALL_PAGE_BASE_SHIFT)) - 1U;
126 flags = ARM_MMU_SECT_FLAGS_TO_SMALL_PAGE(
config->flags);
129 pt[i] = (i << ARM_MMU_SMALL_PAGE_BASE_SHIFT) | flags;
130 i = (i + 1U) & index_mask;
133 i = ARM_MMU_SECT_GET_INDEX(
config->begin);
134 iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(
config->end));
135 index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
139 ttb[i] = (i << ARM_MMU_SECT_BASE_SHIFT) | flags;
140 i = (i + 1U) & index_mask;
146BSP_START_TEXT_SECTION
static inline void
147arm_cp15_start_setup_translation_table(
149 uint32_t client_domain,
154#ifdef ARM_MMU_USE_SMALL_PAGES
160 dac = ARM_CP15_DAC_DOMAIN(client_domain, ARM_CP15_DAC_CLIENT);
161 arm_cp15_set_domain_access_control(dac);
162 arm_cp15_set_translation_table_base(ttb);
165#ifdef ARM_MMU_USE_SMALL_PAGES
166 pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
167 for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
170 for (j = 0; j < ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT; ++j) {
174 ttb[i] = (uint32_t) pt | (client_domain << ARM_MMU_SECT_DOMAIN_SHIFT)
175 | ARM_MMU_PAGE_TABLE_DEFAULT;
176 pt += ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT;
179 for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
184 for (i = 0; i < config_count; ++i) {
185 arm_cp15_start_set_translation_table_entries(ttb, &config_table [i]);
189BSP_START_TEXT_SECTION
static inline void
190arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
193 uint32_t client_domain,
198 arm_cp15_start_setup_translation_table(
206 ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
208 arm_cp15_set_control(ctrl);
211BSP_START_TEXT_SECTION
static inline uint32_t
212arm_cp15_start_setup_mmu_and_cache(uint32_t ctrl_clear, uint32_t ctrl_set)
214 uint32_t ctrl = arm_cp15_get_control();
219 arm_cp15_set_control(ctrl);
221 arm_cp15_tlb_invalidate();
ARM co-processor 15 (CP15) API.
Definition: arm-cp15-start.h:31
Definition: deflate.c:114