source: rtems/c/src/lib/libbsp/arm/shared/arm-cp15-set-ttb-entries.c @ 991fdb33

4.115
Last change on this file since 991fdb33 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * Copyright (c) 2010-2013 embedded brains GmbH.  All rights reserved.
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
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <libcpu/arm-cp15.h>
16
17static uint32_t set_translation_table_entries(
18  const void *begin,
19  const void *end,
20  uint32_t section_flags
21)
22{
23  uint32_t cl_size = arm_cp15_get_min_cache_line_size();
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));
27  uint32_t index_mask = (1U << (32 - ARM_MMU_SECT_BASE_SHIFT)) - 1U;
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];
34
35  while (i != iend) {
36    uint32_t addr = i << ARM_MMU_SECT_BASE_SHIFT;
37
38    ttb [i] = addr | section_flags;
39
40    i = (i + 1U) & index_mask;
41  }
42
43  arm_cp15_set_control(ctrl);
44
45  return section_flags_of_first_entry;
46}
47
48uint32_t arm_cp15_set_translation_table_entries(
49  const void *begin,
50  const void *end,
51  uint32_t section_flags
52)
53{
54  rtems_interrupt_level level;
55  uint32_t section_flags_of_first_entry;
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;
63}
Note: See TracBrowser for help on using the repository browser.