Skip to content

Commit 9ccdcb9

Browse files
Andy Grossandrewboie
Andy Gross
authored andcommitted
arm: mpu: Add user context API placeholder
This patch adds a configure_mpu_user_context API and implements the required function placeholders in the NXP and ARM MPU files. Signed-off-by: Andy Gross <[email protected]>
1 parent 29af3e0 commit 9ccdcb9

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

arch/arm/core/cortex_m/mpu/arm_core_mpu.c

+16
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ void configure_mpu_stack_guard(struct k_thread *thread)
3232
#endif
3333

3434
#if defined(CONFIG_USERSPACE)
35+
/*
36+
* @brief Configure MPU user context
37+
*
38+
* This function configures the thread's user context.
39+
* The functionality is meant to be used during context switch.
40+
*
41+
* @param thread thread info data structure.
42+
*/
43+
void configure_mpu_user_context(struct k_thread *thread)
44+
{
45+
SYS_LOG_DBG("configure user thread %p's context", thread);
46+
arm_core_mpu_disable();
47+
arm_core_mpu_configure_user_context(thread);
48+
arm_core_mpu_enable();
49+
}
50+
3551
/*
3652
* @brief Configure MPU memory domain
3753
*

arch/arm/core/cortex_m/mpu/arm_mpu.c

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size)
240240
}
241241

242242
#if defined(CONFIG_USERSPACE)
243+
void arm_core_mpu_configure_user_context(struct k_thread *thread)
244+
{
245+
return 0;
246+
}
247+
243248
/**
244249
* @brief configure MPU regions for the memory partitions of the memory domain
245250
*

arch/arm/core/cortex_m/mpu/nxp_mpu.c

+5
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size)
249249
}
250250

251251
#if defined(CONFIG_USERSPACE)
252+
void arm_core_mpu_configure_user_context(struct k_thread *thread)
253+
{
254+
return 0;
255+
}
256+
252257
/**
253258
* @brief configure MPU regions for the memory partitions of the memory domain
254259
*

include/arch/arm/cortex_m/mpu/arm_core_mpu.h

+11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ void configure_mpu_stack_guard(struct k_thread *thread);
4242
* @param thread thread info data structure.
4343
*/
4444
void configure_mpu_mem_domain(struct k_thread *thread);
45+
46+
/*
47+
* @brief Configure MPU user context
48+
*
49+
* This function configures the stack and application data regions
50+
* for user mode threads
51+
*
52+
* @param thread thread info data structure.
53+
*/
54+
void configure_mpu_user_context(struct k_thread *thread);
55+
4556
#endif
4657

4758
#ifdef __cplusplus

include/arch/arm/cortex_m/mpu/arm_core_mpu_dev.h

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern "C" {
3737
#if defined(CONFIG_ARM_CORE_MPU)
3838
struct k_mem_domain;
3939
struct k_mem_partition;
40+
struct k_thread;
4041

4142
/* ARM Core MPU Driver API */
4243

@@ -71,6 +72,13 @@ void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size);
7172
*/
7273
void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain);
7374

75+
/**
76+
* @brief configure MPU regions for a user thread's context
77+
*
78+
* @param thread thread to configure
79+
*/
80+
void arm_core_mpu_configure_user_context(struct k_thread *thread);
81+
7482
/**
7583
* @brief configure MPU region for a single memory partition
7684
*

0 commit comments

Comments
 (0)