nios2: New functions

Add
  o _Nios2_MPU_Get_region_descriptor(), and
  o _Nios2_MPU_Set_region_registers().
This commit is contained in:
Sebastian Huber
2012-04-11 10:34:01 +02:00
parent 2d0ca00003
commit 8eb559d316
2 changed files with 49 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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();