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

5
Last change on this file since 5c6edee was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

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

  • 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.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/nios2-utility.h>
20
21void _Nios2_MPU_Reset( const Nios2_MPU_Configuration *config )
22{
23  uint32_t data_mpubase = (1U << config->data_region_size_log2)
24    | NIOS2_MPUBASE_D;
25  uint32_t inst_mpubase = 1U << config->instruction_region_size_log2;
26  uint32_t mpuacc = NIOS2_MPUACC_WR;
27  int data_count = config->data_region_count;
28  int inst_count = config->instruction_region_count;
29  int i = 0;
30
31  _Nios2_MPU_Disable();
32
33  for ( i = 0; i < data_count; ++i ) {
34    uint32_t index = ((uint32_t) i) << NIOS2_MPUBASE_INDEX_OFFSET;
35
36    _Nios2_Set_ctlreg_mpubase( data_mpubase | index );
37    _Nios2_Set_ctlreg_mpuacc( mpuacc );
38  }
39
40  for ( i = 0; i < inst_count; ++i ) {
41    uint32_t index = ((uint32_t) i) << NIOS2_MPUBASE_INDEX_OFFSET;
42
43    _Nios2_Set_ctlreg_mpubase( inst_mpubase | index );
44    _Nios2_Set_ctlreg_mpuacc( mpuacc );
45  }
46}
Note: See TracBrowser for help on using the repository browser.