Line data Source code
1 0 : /*
2 : * Copyright (c) 2017 Synopsys.
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 : #ifndef ZEPHYR_INCLUDE_ARCH_ARC_V2_MPU_ARC_CORE_MPU_H_
7 : #define ZEPHYR_INCLUDE_ARCH_ARC_V2_MPU_ARC_CORE_MPU_H_
8 :
9 : #ifdef __cplusplus
10 : extern "C" {
11 : #endif
12 :
13 : /*
14 : * The defines below represent the region types. The MPU driver is responsible
15 : * to allocate the region accordingly to the type and set the correct
16 : * attributes.
17 : *
18 : * Each MPU is different and has a different set of attributes, hence instead
19 : * of having the attributes at this level the arc_mpu_core defines the intent
20 : * types.
21 : * An intent type (i.e. THREAD_STACK_GUARD) can correspond to a different set
22 : * of operations and attributes for each MPU and it is responsibility of the
23 : * MPU driver to select the correct ones.
24 : *
25 : * The intent based configuration can't fail hence at this level no error
26 : * is returned by the configuration functions.
27 : * If one of the operations corresponding to an intent fails the error has to
28 : * be managed inside the MPU driver and not escalated.
29 : */
30 : /* Thread Region Intent Type */
31 0 : #define THREAD_STACK_USER_REGION 0x0
32 0 : #define THREAD_STACK_REGION 0x1
33 0 : #define THREAD_APP_DATA_REGION 0x2
34 0 : #define THREAD_STACK_GUARD_REGION 0x3
35 0 : #define THREAD_DOMAIN_PARTITION_REGION 0x4
36 :
37 : #if defined(CONFIG_ARC_CORE_MPU)
38 : /* ARC Core MPU Driver API */
39 :
40 : /*
41 : * This API has to be implemented by all the MPU drivers that have
42 : * ARC_CORE_MPU support.
43 : */
44 :
45 : /**
46 : * @brief enable the MPU
47 : */
48 : void arc_core_mpu_enable(void);
49 :
50 : /**
51 : * @brief disable the MPU
52 : */
53 : void arc_core_mpu_disable(void);
54 :
55 : /**
56 : * @brief configure the thread's mpu regions
57 : *
58 : * @param thread the target thread
59 : */
60 : void arc_core_mpu_configure_thread(struct k_thread *thread);
61 :
62 : /*
63 : * Before configure the MPU regions, MPU should be disabled
64 : */
65 : /**
66 : * @brief configure the default region
67 : *
68 : * @param region_attr region attribute of default region
69 : */
70 : void arc_core_mpu_default(uint32_t region_attr);
71 :
72 : /**
73 : * @brief configure the MPU region
74 : *
75 : * @param index MPU region index
76 : * @param base base address
77 : * @param size size of region
78 : * @param region_attr region attribute
79 : */
80 : int arc_core_mpu_region(uint32_t index, uint32_t base, uint32_t size,
81 : uint32_t region_attr);
82 :
83 : #endif /* CONFIG_ARC_CORE_MPU */
84 :
85 : #if defined(CONFIG_USERSPACE)
86 0 : void arc_core_mpu_configure_mem_domain(struct k_thread *thread);
87 0 : void arc_core_mpu_remove_mem_domain(struct k_mem_domain *mem_domain);
88 0 : void arc_core_mpu_remove_mem_partition(struct k_mem_domain *domain,
89 : uint32_t partition_id);
90 0 : int arc_core_mpu_get_max_domain_partition_regions(void);
91 0 : int arc_core_mpu_buffer_validate(const void *addr, size_t size, int write);
92 :
93 : #endif
94 :
95 0 : void configure_mpu_thread(struct k_thread *thread);
96 :
97 : #ifdef __cplusplus
98 : }
99 : #endif
100 :
101 : #endif /* ZEPHYR_INCLUDE_ARCH_ARC_V2_MPU_ARC_CORE_MPU_H_ */
|