[rtems commit] nios2: New functions

Sebastian Huber sebh at rtems.org
Wed Apr 11 09:23:14 UTC 2012


Module:    rtems
Branch:    master
Commit:    8eb559d316ee9a1839268b9b6ffe9e4ac40d250b
Changeset: http://git.rtems.org/rtems/commit/?id=8eb559d316ee9a1839268b9b6ffe9e4ac40d250b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Apr 11 10:34:01 2012 +0200

nios2: New functions

Add
  o _Nios2_MPU_Get_region_descriptor(), and
  o _Nios2_MPU_Set_region_registers().

---

 cpukit/score/cpu/nios2/nios2-mpu-descriptor.c      |   32 ++++++++++++++++++++
 cpukit/score/cpu/nios2/rtems/score/nios2-utility.h |   17 ++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/cpukit/score/cpu/nios2/nios2-mpu-descriptor.c b/cpukit/score/cpu/nios2/nios2-mpu-descriptor.c
index 2c52313..be680ff 100644
--- a/cpukit/score/cpu/nios2/nios2-mpu-descriptor.c
+++ b/cpukit/score/cpu/nios2/nios2-mpu-descriptor.c
@@ -106,3 +106,35 @@ bool _Nios2_MPU_Setup_region_registers(
 
   return ok;
 }
+
+bool _Nios2_MPU_Get_region_descriptor(
+  const Nios2_MPU_Configuration *config,
+  int index,
+  bool data,
+  Nios2_MPU_Region_descriptor *desc
+)
+{
+  bool ok = _Nios2_MPU_Is_valid_index( config, index, data );
+
+  if ( ok ) {
+    uint32_t mpubase;
+    uint32_t mpuacc;
+
+    _Nios2_MPU_Get_region_registers( index, data, &mpubase, &mpuacc );
+
+    desc->index = index;
+    desc->base = (void *) (mpubase & NIOS2_MPUBASE_BASE_MASK);
+    if ( config->region_uses_limit ) {
+      desc->end = (void *) (mpuacc & NIOS2_MPUACC_LIMIT_MASK);
+    } else {
+      desc->end = (void *) ((mpuacc & NIOS2_MPUACC_MASK_MASK) + 1);
+    }
+    desc->perm = (mpuacc & NIOS2_MPUACC_PERM_MASK) >> NIOS2_MPUACC_PERM_OFFSET;
+    desc->data = data;
+    desc->cacheable = (mpuacc & NIOS2_MPUACC_C) != 0;
+    desc->read = (mpuacc & NIOS2_MPUACC_RD) != 0;
+    desc->write = (mpuacc & NIOS2_MPUACC_WR) != 0;
+  }
+
+  return ok;
+}
diff --git a/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h b/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h
index 9702feb..bab411b 100644
--- a/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h
+++ b/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h
@@ -401,6 +401,13 @@ bool _Nios2_MPU_Setup_region_registers(
   uint32_t *mpuacc
 );
 
+bool _Nios2_MPU_Get_region_descriptor(
+  const Nios2_MPU_Configuration *config,
+  int index,
+  bool data,
+  Nios2_MPU_Region_descriptor *desc
+);
+
 /**
  * @brief Seaches the region table part for a disabled region.
  *
@@ -451,6 +458,16 @@ static inline void _Nios2_MPU_Get_region_registers(
   *mpuacc = _Nios2_Get_ctlreg_mpuacc();
 }
 
+static inline void _Nios2_MPU_Set_region_registers(
+  uint32_t mpubase,
+  uint32_t mpuacc
+)
+{
+  _Nios2_Set_ctlreg_mpubase( mpubase );
+  _Nios2_Set_ctlreg_mpuacc( mpuacc );
+  _Nios2_Flush_pipeline();
+}
+
 static inline void _Nios2_MPU_Enable( void )
 {
   uint32_t config = _Nios2_Get_ctlreg_config();




More information about the vc mailing list