File indexing completed on 2025-05-11 08:23:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <bsp/mmu.h>
0024
0025 static uint32_t disable_mmu(void)
0026 {
0027 uint32_t ctrl = 0;
0028
0029 arm_cp15_data_cache_test_and_clean_and_invalidate();
0030
0031 ctrl = arm_cp15_get_control();
0032 arm_cp15_set_control(ctrl & ~ARM_CP15_CTRL_M);
0033
0034 arm_cp15_tlb_invalidate();
0035
0036 return ctrl;
0037 }
0038
0039 static void restore_mmu_control(uint32_t ctrl)
0040 {
0041 arm_cp15_set_control(ctrl);
0042 }
0043
0044 static uint32_t set_translation_table_entries(
0045 const void *begin,
0046 const void *end,
0047 uint32_t section_flags
0048 )
0049 {
0050 uint32_t *ttb = arm_cp15_get_translation_table_base();
0051 uint32_t i = ARM_MMU_SECT_GET_INDEX(begin);
0052 uint32_t iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(end));
0053 uint32_t ctrl = disable_mmu();
0054 uint32_t section_flags_of_first_entry = ttb [i];
0055
0056 while (i < iend) {
0057 ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | section_flags;
0058 ++i;
0059 }
0060
0061 restore_mmu_control(ctrl);
0062
0063 return section_flags_of_first_entry;
0064 }
0065
0066 uint32_t lpc32xx_set_translation_table_entries(
0067 const void *begin,
0068 const void *end,
0069 uint32_t section_flags
0070 )
0071 {
0072 rtems_interrupt_level level;
0073 uint32_t section_flags_of_first_entry = 0;
0074
0075 rtems_interrupt_disable(level);
0076 section_flags_of_first_entry =
0077 set_translation_table_entries(begin, end, section_flags);
0078 rtems_interrupt_enable(level);
0079
0080 return section_flags_of_first_entry;
0081 }