1 /*
2 * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "sdkconfig.h"
8 #include "soc/periph_defs.h"
9 #include "esp_intr_alloc.h"
10 #include "esp_fault.h"
11 #include "esp_attr.h"
12 #include "esp_memprot_err.h"
13 #include "hal/memprot_types.h"
14 #include "esp_private/esp_memprot_internal.h"
15 #include "esp_memprot.h"
16
esp_mprot_set_split_addr(const esp_mprot_mem_t mem_type,const esp_mprot_split_addr_t line_type,const void * line_addr)17 esp_err_t esp_mprot_set_split_addr(const esp_mprot_mem_t mem_type, const esp_mprot_split_addr_t line_type, const void *line_addr)
18 {
19 return ESP_OK;
20 }
21
esp_mprot_get_split_addr(const esp_mprot_mem_t mem_type,const esp_mprot_split_addr_t line_type,void ** line_addr)22 esp_err_t esp_mprot_get_split_addr(const esp_mprot_mem_t mem_type, const esp_mprot_split_addr_t line_type, void **line_addr)
23 {
24 if (line_addr == NULL) {
25 return ESP_ERR_INVALID_ARG;
26 }
27
28 *line_addr = NULL;
29
30 return ESP_OK;
31 }
32
esp_mprot_get_default_main_split_addr(const esp_mprot_mem_t mem_type,void ** def_split_addr)33 esp_err_t esp_mprot_get_default_main_split_addr(const esp_mprot_mem_t mem_type, void **def_split_addr)
34 {
35 if (def_split_addr == NULL) {
36 return ESP_ERR_INVALID_ARG;
37 }
38
39 *def_split_addr = NULL;
40
41 return ESP_OK;
42 }
43
esp_mprot_set_split_addr_lock(const esp_mprot_mem_t mem_type)44 esp_err_t esp_mprot_set_split_addr_lock(const esp_mprot_mem_t mem_type)
45 {
46 return ESP_OK;
47 }
48
esp_mprot_get_split_addr_lock(const esp_mprot_mem_t mem_type,bool * locked)49 esp_err_t esp_mprot_get_split_addr_lock(const esp_mprot_mem_t mem_type, bool *locked)
50 {
51 if (locked == NULL) {
52 return ESP_ERR_INVALID_ARG;
53 }
54
55 *locked = false;
56
57 return ESP_OK;
58 }
59
esp_mprot_set_pms_lock(const esp_mprot_mem_t mem_type)60 esp_err_t esp_mprot_set_pms_lock(const esp_mprot_mem_t mem_type)
61 {
62 return ESP_OK;
63 }
64
esp_mprot_get_pms_lock(const esp_mprot_mem_t mem_type,bool * locked)65 esp_err_t esp_mprot_get_pms_lock(const esp_mprot_mem_t mem_type, bool *locked)
66 {
67 if (locked == NULL) {
68 return ESP_ERR_INVALID_ARG;
69 }
70
71 *locked = false;
72
73 return ESP_OK;
74 }
75
esp_mprot_set_pms_area(const esp_mprot_pms_area_t area_type,const uint32_t flags)76 esp_err_t esp_mprot_set_pms_area(const esp_mprot_pms_area_t area_type, const uint32_t flags)
77 {
78 return ESP_OK;
79 }
80
esp_mprot_get_pms_area(const esp_mprot_pms_area_t area_type,uint32_t * flags)81 esp_err_t esp_mprot_get_pms_area(const esp_mprot_pms_area_t area_type, uint32_t *flags)
82 {
83 if (flags == NULL) {
84 return ESP_ERR_INVALID_ARG;
85 }
86
87 *flags = MEMPROT_OP_NONE;
88
89 return ESP_OK;
90 }
91
esp_mprot_set_monitor_lock(const esp_mprot_mem_t mem_type)92 esp_err_t esp_mprot_set_monitor_lock(const esp_mprot_mem_t mem_type)
93 {
94 return ESP_OK;
95 }
96
esp_mprot_get_monitor_lock(const esp_mprot_mem_t mem_type,bool * locked)97 esp_err_t esp_mprot_get_monitor_lock(const esp_mprot_mem_t mem_type, bool *locked)
98 {
99 if (locked == NULL) {
100 return ESP_ERR_INVALID_ARG;
101 }
102
103 *locked = false;
104
105 return ESP_OK;
106 }
107
esp_mprot_set_monitor_en(const esp_mprot_mem_t mem_type,const bool enable)108 esp_err_t esp_mprot_set_monitor_en(const esp_mprot_mem_t mem_type, const bool enable)
109 {
110 return ESP_OK;
111 }
112
esp_mprot_get_monitor_en(const esp_mprot_mem_t mem_type,bool * enabled)113 esp_err_t esp_mprot_get_monitor_en(const esp_mprot_mem_t mem_type, bool *enabled)
114 {
115 if (enabled == NULL) {
116 return ESP_ERR_INVALID_ARG;
117 }
118
119 *enabled = false;
120
121 return ESP_OK;
122 }
123
esp_mprot_monitor_clear_intr(const esp_mprot_mem_t mem_type,int const * const core)124 esp_err_t IRAM_ATTR esp_mprot_monitor_clear_intr(const esp_mprot_mem_t mem_type, int const *const core __attribute__((unused)))
125 {
126 return ESP_OK;
127 }
128
esp_mprot_get_active_intr(esp_memp_intr_source_t * active_memp_intr)129 esp_err_t IRAM_ATTR esp_mprot_get_active_intr(esp_memp_intr_source_t *active_memp_intr)
130 {
131 if (active_memp_intr == NULL) {
132 return ESP_ERR_INVALID_ARG;
133 }
134
135 active_memp_intr->mem_type = MEMPROT_TYPE_NONE;
136 active_memp_intr->core = -1;
137
138 return ESP_OK;
139 }
140
esp_mprot_is_conf_locked_any(bool * locked)141 esp_err_t IRAM_ATTR esp_mprot_is_conf_locked_any(bool *locked)
142 {
143 if (locked == NULL) {
144 return ESP_ERR_INVALID_ARG;
145 }
146
147 *locked = false;
148
149 return ESP_OK;
150 }
151
esp_mprot_is_intr_ena_any(bool * enabled)152 esp_err_t IRAM_ATTR esp_mprot_is_intr_ena_any(bool *enabled)
153 {
154 if (enabled == NULL) {
155 return ESP_ERR_INVALID_ARG;
156 }
157
158 *enabled = false;
159
160 return ESP_OK;
161 }
162
esp_mprot_get_violate_addr(const esp_mprot_mem_t mem_type,void ** fault_addr,int const * const core)163 esp_err_t IRAM_ATTR esp_mprot_get_violate_addr(const esp_mprot_mem_t mem_type, void **fault_addr, int const *const core __attribute__((unused)))
164 {
165 if (fault_addr == NULL) {
166 return ESP_ERR_INVALID_ARG;
167 }
168
169 *fault_addr = NULL;
170
171 return ESP_OK;
172 }
173
esp_mprot_get_violate_world(const esp_mprot_mem_t mem_type,esp_mprot_pms_world_t * world,int const * const core)174 esp_err_t IRAM_ATTR esp_mprot_get_violate_world(const esp_mprot_mem_t mem_type, esp_mprot_pms_world_t *world, int const *const core __attribute__((unused)))
175 {
176 if (world == NULL) {
177 return ESP_ERR_INVALID_ARG;
178 }
179
180 *world = MEMPROT_PMS_WORLD_NONE;
181
182 return ESP_OK;
183 }
184
esp_mprot_get_violate_operation(const esp_mprot_mem_t mem_type,uint32_t * oper,int const * const core)185 esp_err_t IRAM_ATTR esp_mprot_get_violate_operation(const esp_mprot_mem_t mem_type, uint32_t *oper, int const *const core __attribute__((unused)))
186 {
187 if (oper == NULL) {
188 return ESP_ERR_INVALID_ARG;
189 }
190
191 *oper = MEMPROT_OP_NONE;
192
193 return ESP_OK;
194 }
195
esp_mprot_has_byte_enables(const esp_mprot_mem_t mem_type)196 bool IRAM_ATTR esp_mprot_has_byte_enables(const esp_mprot_mem_t mem_type)
197 {
198 return false;
199 }
200
esp_mprot_get_violate_byte_enables(const esp_mprot_mem_t mem_type,uint32_t * byte_en,int const * const core)201 esp_err_t IRAM_ATTR esp_mprot_get_violate_byte_enables(const esp_mprot_mem_t mem_type, uint32_t *byte_en, int const *const core __attribute__((unused)))
202 {
203 if (byte_en == NULL) {
204 return ESP_ERR_INVALID_ARG;
205 }
206
207 *byte_en = 0;
208
209 return ESP_OK;
210 }
211
esp_mprot_set_prot(const esp_memp_config_t * memp_config)212 esp_err_t esp_mprot_set_prot(const esp_memp_config_t *memp_config)
213 {
214 return ESP_OK;
215 }
216