[f140fdc] | 1 | /* |
---|
[037e8ae5] | 2 | * Copyright (c) 2010-2013 embedded brains GmbH. All rights reserved. |
---|
[f140fdc] | 3 | * |
---|
| 4 | * embedded brains GmbH |
---|
| 5 | * Obere Lagerstr. 30 |
---|
| 6 | * 82178 Puchheim |
---|
| 7 | * Germany |
---|
| 8 | * <rtems@embedded-brains.de> |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 12 | * http://www.rtems.org/license/LICENSE. |
---|
[f140fdc] | 13 | */ |
---|
| 14 | |
---|
[037e8ae5] | 15 | #include <libcpu/arm-cp15.h> |
---|
[f437107] | 16 | |
---|
[037e8ae5] | 17 | static uint32_t set_translation_table_entries( |
---|
[cfe13cb] | 18 | const void *begin, |
---|
| 19 | const void *end, |
---|
[f140fdc] | 20 | uint32_t section_flags |
---|
| 21 | ) |
---|
| 22 | { |
---|
[037e8ae5] | 23 | uint32_t cl_size = arm_cp15_get_min_cache_line_size(); |
---|
[f140fdc] | 24 | uint32_t *ttb = arm_cp15_get_translation_table_base(); |
---|
| 25 | uint32_t i = ARM_MMU_SECT_GET_INDEX(begin); |
---|
| 26 | uint32_t iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(end)); |
---|
[39234725] | 27 | uint32_t index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U; |
---|
[037e8ae5] | 28 | uint32_t ctrl; |
---|
| 29 | uint32_t section_flags_of_first_entry; |
---|
| 30 | |
---|
| 31 | ctrl = arm_cp15_mmu_disable(cl_size); |
---|
| 32 | arm_cp15_tlb_invalidate(); |
---|
| 33 | section_flags_of_first_entry = ttb [i]; |
---|
[f140fdc] | 34 | |
---|
[39234725] | 35 | while (i != iend) { |
---|
[037e8ae5] | 36 | uint32_t addr = i << ARM_MMU_SECT_BASE_SHIFT; |
---|
| 37 | |
---|
| 38 | ttb [i] = addr | section_flags; |
---|
| 39 | |
---|
[39234725] | 40 | i = (i + 1U) & index_mask; |
---|
[f140fdc] | 41 | } |
---|
[f437107] | 42 | |
---|
[037e8ae5] | 43 | arm_cp15_set_control(ctrl); |
---|
[f437107] | 44 | |
---|
| 45 | return section_flags_of_first_entry; |
---|
| 46 | } |
---|
| 47 | |
---|
[037e8ae5] | 48 | uint32_t arm_cp15_set_translation_table_entries( |
---|
[f437107] | 49 | const void *begin, |
---|
| 50 | const void *end, |
---|
| 51 | uint32_t section_flags |
---|
| 52 | ) |
---|
| 53 | { |
---|
| 54 | rtems_interrupt_level level; |
---|
[037e8ae5] | 55 | uint32_t section_flags_of_first_entry; |
---|
[f437107] | 56 | |
---|
| 57 | rtems_interrupt_disable(level); |
---|
| 58 | section_flags_of_first_entry = |
---|
| 59 | set_translation_table_entries(begin, end, section_flags); |
---|
| 60 | rtems_interrupt_enable(level); |
---|
| 61 | |
---|
| 62 | return section_flags_of_first_entry; |
---|
[f140fdc] | 63 | } |
---|