mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 13:52:22 +08:00
arm64: add mpu_usedregion interface
Add mpu_usedregion() function to query the number of MPU regions currently in use. This interface complements existing mpu_allocregion() and mpu_freeregion() functions, allowing callers to determine the occupancy of the MPU region pool. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -162,6 +162,34 @@ unsigned int mpu_allocregion(void)
|
||||
return i;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mpu_allocregion
|
||||
*
|
||||
* Description:
|
||||
* Get the number of MPU region used
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* The the number of MPU region used
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int mpu_usedregion(void)
|
||||
{
|
||||
unsigned int n = g_mpu_region[this_cpu()];
|
||||
unsigned int count = 0;
|
||||
|
||||
while (n)
|
||||
{
|
||||
count += n & 1;
|
||||
n >>= 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mpu_freeregion
|
||||
*
|
||||
|
||||
@@ -383,6 +383,22 @@ unsigned int mpu_allocregion(void);
|
||||
|
||||
void mpu_freeregion(unsigned int region);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mpu_allocregion
|
||||
*
|
||||
* Description:
|
||||
* Get the number of MPU region used
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* The the number of MPU region used
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int mpu_usedregion(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arm64_mpu_enable
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user