Commit 83bedcc9 authored by Adithya Baglody's avatar Adithya Baglody Committed by Andrew Boie
Browse files

ARM: MPU: Arch specific memory domain APIs



Added architecture specific support for memory domain destroy
and remove partition for arm and nxp. An optimized version of
remove partition was also added.

Signed-off-by: default avatarAdithya Baglody <adithya.nagaraj.baglody@intel.com>
parent 57832073
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -52,4 +52,31 @@ int _arch_mem_domain_max_partitions_get(void)
{
	return arm_core_mpu_get_max_domain_partition_regions();
}

/*
 * Reset MPU region for a single memory partition
 */
void _arch_mem_domain_partition_remove(struct k_mem_domain *domain,
				       u32_t  partition_id)
{
	ARG_UNUSED(domain);

	arm_core_mpu_disable();
	arm_core_mpu_mem_partition_remove(partition_id);
	arm_core_mpu_enable();

}

/*
 * Destroy MPU regions for the mem domain
 */
void _arch_mem_domain_destroy(struct k_mem_domain *domain)
{
	ARG_UNUSED(domain);

	arm_core_mpu_disable();
	arm_core_mpu_configure_mem_domain(NULL);
	arm_core_mpu_enable();
}

#endif
+17 −0
Original line number Diff line number Diff line
@@ -262,6 +262,23 @@ void arm_core_mpu_configure_mem_partition(u32_t part_index,
	}
}

/**
 * @brief Reset MPU region for a single memory partition
 *
 * @param   part_index  memory partition index
 */
void arm_core_mpu_mem_partition_remove(u32_t part_index)
{
	u32_t region_index =
		_get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION);

	SYS_LOG_DBG("disable region 0x%x", region_index + part_index);
	/* Disable region */
	ARM_MPU_DEV->rnr = region_index + part_index;
	ARM_MPU_DEV->rbar = 0;
	ARM_MPU_DEV->rasr = 0;
}

/**
 * @brief get the maximum number of free regions for memory domain partitions
 */
+18 −0
Original line number Diff line number Diff line
@@ -289,6 +289,24 @@ void arm_core_mpu_configure_mem_partition(u32_t part_index,
	}
}

/**
 * @brief Reset MPU region for a single memory partition
 *
 * @param   part_index  memory partition index
 */
void arm_core_mpu_mem_partition_remove(u32_t part_index)
{
	u32_t region_index =
		_get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION);

	SYS_LOG_DBG("disable region 0x%x", region_index);
	/* Disable region */
	SYSMPU->WORD[region_index + part_index][0] = 0;
	SYSMPU->WORD[region_index + part_index][1] = 0;
	SYSMPU->WORD[region_index + part_index][2] = 0;
	SYSMPU->WORD[region_index + part_index][3] = 0;
}

/**
 * @brief get the maximum number of free regions for memory domain partitions
 */
+5 −0
Original line number Diff line number Diff line
@@ -299,6 +299,11 @@ extern "C" {
#endif  /* CONFIG_NXP_MPU */
#endif /* CONFIG_USERSPACE */

#ifndef _ASMLANGUAGE
/* Typedef for the k_mem_partition attribute*/
typedef u32_t k_mem_partition_attr_t;
#endif /* _ASMLANGUAGE */

#ifdef CONFIG_ARM_USERSPACE
#ifndef _ASMLANGUAGE
/* Syscall invocation macros. arm-specific machine constraints used to ensure
+7 −0
Original line number Diff line number Diff line
@@ -80,6 +80,13 @@ void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain);
void arm_core_mpu_configure_mem_partition(u32_t part_index,
					  struct k_mem_partition *part);

/**
 * @brief Reset MPU region for a single memory partition
 *
 * @param   part_index  memory partition index
 */
void arm_core_mpu_mem_partition_remove(u32_t part_index);

/**
 * @brief get the maximum number of free regions for memory domain partitions
 */
Loading