source: rtems/c/src/lib/libbsp/arm/lpc32xx/misc/mmu.c @ f437107

4.115
Last change on this file since f437107 was f437107, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 28, 2011 at 9:00:01 AM

2011-03-29 Sebastian Huber <sebastian.huber@…>

  • configure.ac, include/bspopts.h.in: New BSP option LPC32XX_SCRATCH_AREA_SIZE. Disable BSP option LPC32XX_DISABLE_READ_ONLY_PROTECTION for all BSPs.
  • include/boot.h: Removed application specific defines.
  • include/nand-mlc.h, misc/nand-mlc.c: Changed configuration layout.
  • include/mmu.h, misc/mmu.c: Documentation. Bugfix.
  • include/bsp.h, startup/bspstarthooks.c, misc/restart.c, startup/linkcmds.lpc32xx_mzx, startup/linkcmds.lpc32xx_mzx_stage_1, startup/linkcmds.lpc32xx_mzx_stage_2, startup/linkcmds.lpc32xx_phycore: Support for scratch area. Moved code into macros for reusability.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc32xx_mmu
5 *
6 * @brief MMU support implementation.
7 */
8
9/*
10 * Copyright (c) 2010-2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <bsp/mmu.h>
24
25static uint32_t disable_mmu(void)
26{
27  uint32_t ctrl = 0;
28
29  arm_cp15_data_cache_test_and_clean_and_invalidate();
30
31  ctrl = arm_cp15_get_control();
32  arm_cp15_set_control(ctrl & ~ARM_CP15_CTRL_M);
33
34  arm_cp15_tlb_invalidate();
35
36  return ctrl;
37}
38
39static void restore_mmu_control(uint32_t ctrl)
40{
41  arm_cp15_set_control(ctrl);
42}
43
44uint32_t set_translation_table_entries(
45  const void *begin,
46  const void *end,
47  uint32_t section_flags
48)
49{
50  uint32_t *ttb = arm_cp15_get_translation_table_base();
51  uint32_t i = ARM_MMU_SECT_GET_INDEX(begin);
52  uint32_t iend = ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(end));
53  uint32_t ctrl = disable_mmu();
54  uint32_t section_flags_of_first_entry = ttb [i];
55
56  while (i < iend) {
57    ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | section_flags;
58    ++i;
59  }
60
61  restore_mmu_control(ctrl);
62
63  return section_flags_of_first_entry;
64}
65
66uint32_t lpc32xx_set_translation_table_entries(
67  const void *begin,
68  const void *end,
69  uint32_t section_flags
70)
71{
72  rtems_interrupt_level level;
73  uint32_t section_flags_of_first_entry = 0;
74
75  rtems_interrupt_disable(level);
76  section_flags_of_first_entry =
77    set_translation_table_entries(begin, end, section_flags);
78  rtems_interrupt_enable(level);
79
80  return section_flags_of_first_entry;
81}
Note: See TracBrowser for help on using the repository browser.