7
7
#include <device.h>
8
8
#include <init.h>
9
9
#include <kernel.h>
10
- #include <kernel_structs.h>
11
10
#include <soc.h>
12
11
#include <arch/arc/v2/mpu/arc_core_mpu.h>
13
12
14
- #define LOG_LEVEL CONFIG_MPU_LOG_LEVEL
15
- #include <logging/log.h>
16
- LOG_MODULE_REGISTER (mpu );
17
-
18
13
/*
19
14
* @brief Configure MPU for the thread
20
15
*
@@ -25,84 +20,11 @@ LOG_MODULE_REGISTER(mpu);
25
20
void configure_mpu_thread (struct k_thread * thread )
26
21
{
27
22
arc_core_mpu_disable ();
28
- #if defined(CONFIG_MPU_STACK_GUARD )
29
- configure_mpu_stack_guard (thread );
30
- #endif
31
-
32
- #if defined(CONFIG_USERSPACE )
33
- configure_mpu_user_context (thread );
34
- configure_mpu_mem_domain (thread );
35
- #endif
23
+ arc_core_mpu_configure_thread (thread );
36
24
arc_core_mpu_enable ();
37
25
}
38
26
39
- #if defined(CONFIG_MPU_STACK_GUARD )
40
- /*
41
- * @brief Configure MPU stack guard
42
- *
43
- * This function configures per thread stack guards reprogramming the MPU.
44
- * The functionality is meant to be used during context switch.
45
- *
46
- * @param thread thread info data structure.
47
- */
48
- void configure_mpu_stack_guard (struct k_thread * thread )
49
- {
50
- #if defined(CONFIG_USERSPACE )
51
- if ((thread -> thread_base .user_options & K_USER ) != 0 ) {
52
- /* the areas before and after the user stack of thread is
53
- * kernel only. These area can be used as stack guard.
54
- * -----------------------
55
- * | kernel only area |
56
- * |---------------------|
57
- * | user stack |
58
- * |---------------------|
59
- * |privilege stack guard|
60
- * |---------------------|
61
- * | privilege stack |
62
- * -----------------------
63
- */
64
- arc_core_mpu_configure (THREAD_STACK_GUARD_REGION ,
65
- thread -> arch .priv_stack_start - STACK_GUARD_SIZE ,
66
- STACK_GUARD_SIZE );
67
- return ;
68
- }
69
- #endif
70
- arc_core_mpu_configure (THREAD_STACK_GUARD_REGION ,
71
- thread -> stack_info .start - STACK_GUARD_SIZE ,
72
- STACK_GUARD_SIZE );
73
-
74
- }
75
- #endif
76
-
77
27
#if defined(CONFIG_USERSPACE )
78
- /*
79
- * @brief Configure MPU user context
80
- *
81
- * This function configures the thread's user context.
82
- * The functionality is meant to be used during context switch.
83
- *
84
- * @param thread thread info data structure.
85
- */
86
- void configure_mpu_user_context (struct k_thread * thread )
87
- {
88
- LOG_DBG ("configure user thread %p's context" , thread );
89
- arc_core_mpu_configure_user_context (thread );
90
- }
91
-
92
-
93
- /*
94
- * @brief Configure MPU memory domain
95
- *
96
- * This function configures per thread memory domain reprogramming the MPU.
97
- * The functionality is meant to be used during context switch.
98
- *
99
- * @param thread thread info data structure.
100
- */
101
- void configure_mpu_mem_domain (struct k_thread * thread )
102
- {
103
- LOG_DBG ("configure thread %p's domain" , thread );
104
- arc_core_mpu_configure_mem_domain (thread );
105
- }
106
28
107
29
int z_arch_mem_domain_max_partitions_get (void )
108
30
{
@@ -115,31 +37,28 @@ int z_arch_mem_domain_max_partitions_get(void)
115
37
void z_arch_mem_domain_partition_remove (struct k_mem_domain * domain ,
116
38
u32_t partition_id )
117
39
{
118
- ARG_UNUSED (domain );
119
-
120
40
arc_core_mpu_disable ();
121
- arc_core_mpu_mem_partition_remove ( partition_id );
41
+ arc_core_mpu_remove_mem_partition ( domain , partition_id );
122
42
arc_core_mpu_enable ();
123
-
124
43
}
125
44
126
45
/*
127
46
* Configure MPU memory domain
128
47
*/
129
48
void z_arch_mem_domain_configure (struct k_thread * thread )
130
49
{
131
- configure_mpu_mem_domain (thread );
50
+ arc_core_mpu_disable ();
51
+ arc_core_mpu_configure_mem_domain (thread );
52
+ arc_core_mpu_enable ();
132
53
}
133
54
134
55
/*
135
56
* Destroy MPU regions for the mem domain
136
57
*/
137
58
void z_arch_mem_domain_destroy (struct k_mem_domain * domain )
138
59
{
139
- ARG_UNUSED (domain );
140
-
141
60
arc_core_mpu_disable ();
142
- arc_core_mpu_configure_mem_domain ( NULL );
61
+ arc_core_mpu_remove_mem_domain ( domain );
143
62
arc_core_mpu_enable ();
144
63
}
145
64
0 commit comments