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:
hujun5
2025-08-12 11:02:35 +08:00
committed by Xiang Xiao
parent 7d30afa589
commit e9c33195a3
2 changed files with 44 additions and 0 deletions
+28
View File
@@ -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
*
+16
View File
@@ -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
*