25 #ifndef LIBBSP_ARM_SHARED_ARM_CP15_START_H 26 #define LIBBSP_ARM_SHARED_ARM_CP15_START_H 29 #include <bsp/start.h> 30 #include <bsp/linker-symbols.h> 43 #define ARMV7_CP15_START_DEFAULT_SECTIONS \ 45 .begin = (uint32_t) bsp_section_fast_text_begin, \ 46 .end = (uint32_t) bsp_section_fast_text_end, \ 47 .flags = ARMV7_MMU_CODE_CACHED \ 49 .begin = (uint32_t) bsp_section_fast_data_begin, \ 50 .end = (uint32_t) bsp_section_fast_data_end, \ 51 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 53 .begin = (uint32_t) bsp_section_start_begin, \ 54 .end = (uint32_t) bsp_section_start_end, \ 55 .flags = ARMV7_MMU_CODE_CACHED \ 57 .begin = (uint32_t) bsp_section_vector_begin, \ 58 .end = (uint32_t) bsp_section_vector_end, \ 59 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 61 .begin = (uint32_t) bsp_section_text_begin, \ 62 .end = (uint32_t) bsp_section_text_end, \ 63 .flags = ARMV7_MMU_CODE_CACHED \ 65 .begin = (uint32_t) bsp_section_rodata_begin, \ 66 .end = (uint32_t) bsp_section_rodata_end, \ 67 .flags = ARMV7_MMU_DATA_READ_ONLY_CACHED \ 69 .begin = (uint32_t) bsp_section_data_begin, \ 70 .end = (uint32_t) bsp_section_data_end, \ 71 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 73 .begin = (uint32_t) bsp_section_bss_begin, \ 74 .end = (uint32_t) bsp_section_bss_end, \ 75 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 77 .begin = (uint32_t) bsp_section_work_begin, \ 78 .end = (uint32_t) bsp_section_work_end, \ 79 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 81 .begin = (uint32_t) bsp_section_stack_begin, \ 82 .end = (uint32_t) bsp_section_stack_end, \ 83 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 85 .begin = (uint32_t) bsp_section_nocache_begin, \ 86 .end = (uint32_t) bsp_section_nocache_end, \ 87 .flags = ARMV7_MMU_DEVICE \ 89 .begin = (uint32_t) bsp_section_nocachenoload_begin, \ 90 .end = (uint32_t) bsp_section_nocachenoload_end, \ 91 .flags = ARMV7_MMU_DEVICE \ 93 .begin = (uint32_t) bsp_translation_table_base, \ 94 .end = (uint32_t) bsp_translation_table_end, \ 95 .flags = ARMV7_MMU_DATA_READ_WRITE_CACHED \ 98 #define ARMV7_CP15_START_WORKSPACE_ENTRY_INDEX 8 101 arm_cp15_start_mmu_config_table[];
103 BSP_START_DATA_SECTION
extern const size_t 104 arm_cp15_start_mmu_config_table_size;
106 BSP_START_TEXT_SECTION
static inline void 107 arm_cp15_start_set_translation_table_entries(
117 #ifdef ARM_MMU_USE_SMALL_PAGES 120 pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
121 i = ARM_MMU_SMALL_PAGE_GET_INDEX(
config->begin);
122 iend = ARM_MMU_SMALL_PAGE_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(
config->end));
123 index_mask = (1U << (32 - ARM_MMU_SMALL_PAGE_BASE_SHIFT)) - 1U;
124 flags = ARM_MMU_SECT_FLAGS_TO_SMALL_PAGE(
config->flags);
127 pt[i] = (i << ARM_MMU_SMALL_PAGE_BASE_SHIFT) | flags;
128 i = (i + 1U) & index_mask;
131 i = ARM_MMU_SECT_GET_INDEX(
config->begin);
132 iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(
config->end));
133 index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
137 ttb[i] = (i << ARM_MMU_SECT_BASE_SHIFT) | flags;
138 i = (i + 1U) & index_mask;
144 BSP_START_TEXT_SECTION
static inline void 145 arm_cp15_start_setup_translation_table(
147 uint32_t client_domain,
152 #ifdef ARM_MMU_USE_SMALL_PAGES 158 dac = ARM_CP15_DAC_DOMAIN(client_domain, ARM_CP15_DAC_CLIENT);
159 arm_cp15_set_domain_access_control(dac);
160 arm_cp15_set_translation_table_base(ttb);
163 #ifdef ARM_MMU_USE_SMALL_PAGES 164 pt = &ttb[ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT];
165 for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
168 for (j = 0; j < ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT; ++j) {
172 ttb[i] = (uint32_t) pt | (client_domain << ARM_MMU_SECT_DOMAIN_SHIFT)
173 | ARM_MMU_PAGE_TABLE_DEFAULT;
174 pt += ARM_MMU_SMALL_PAGE_TABLE_ENTRY_COUNT;
177 for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
182 for (i = 0; i < config_count; ++i) {
183 arm_cp15_start_set_translation_table_entries(ttb, &config_table [i]);
187 BSP_START_TEXT_SECTION
static inline void 188 arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
191 uint32_t client_domain,
196 arm_cp15_start_setup_translation_table(
204 ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
206 arm_cp15_set_control(ctrl);
209 BSP_START_TEXT_SECTION
static inline uint32_t
210 arm_cp15_start_setup_mmu_and_cache(uint32_t ctrl_clear, uint32_t ctrl_set)
212 uint32_t ctrl = arm_cp15_get_control();
217 arm_cp15_set_control(ctrl);
219 arm_cp15_tlb_invalidate();
ARM co-processor 15 (CP15) API.
Definition: deflate.c:115
Definition: arm-cp15-start.h:37