source: rtems/cpukit/score/cpu/nios2/nios2-mpu-reset.c @ d4a95940

4.115
Last change on this file since d4a95940 was d4a95940, checked in by Sebastian Huber <sebastian.huber@…>, on 10/21/11 at 08:44:23

2011-10-21 Sebastian Huber <sebastian.huber@…>

  • nios2-mpu-configuration.c, nios2-mpu-descriptor.c, nios2-mpu-disable-protected.c, nios2-mpu-reset.c: New files.
  • Makefile.am: Reflect changes above.
  • rtems/score/nios2-utility.h, nios2-context-initialize.c: Added support for the memory protection unit (MPU).
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 * Copyright (c) 2011 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.com/license/LICENSE.
13 *
14 * $Id$
15 */
16
17#ifdef HAVE_CONFIG_H
18  #include "config.h"
19#endif
20
21#include <rtems/score/nios2-utility.h>
22
23void _Nios2_MPU_Reset( const Nios2_MPU_Configuration *config )
24{
25  uint32_t data_mpubase = (1U << config->data_region_size_log2)
26    | NIOS2_MPUBASE_D;
27  uint32_t inst_mpubase = 1U << config->instruction_region_size_log2;
28  uint32_t mpuacc = NIOS2_MPUACC_WR;
29  int data_count = config->data_region_count;
30  int inst_count = config->instruction_region_count;
31  int i = 0;
32
33  _Nios2_MPU_Disable();
34
35  for ( i = 0; i < data_count; ++i ) {
36    uint32_t index = ((uint32_t) i) << NIOS2_MPUBASE_INDEX_OFFSET;
37
38    _Nios2_Set_ctlreg_mpubase( data_mpubase | index );
39    _Nios2_Set_ctlreg_mpuacc( mpuacc );
40  }
41
42  for ( i = 0; i < inst_count; ++i ) {
43    uint32_t index = ((uint32_t) i) << NIOS2_MPUBASE_INDEX_OFFSET;
44
45    _Nios2_Set_ctlreg_mpubase( inst_mpubase | index );
46    _Nios2_Set_ctlreg_mpuacc( mpuacc );
47  }
48}
Note: See TracBrowser for help on using the repository browser.