1 // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <stdlib.h>
16 #include <stdint.h>
17 
18 #include "esp_err.h"
19 
20 #include "hal/mpu_hal.h"
21 #include "hal/mpu_ll.h"
22 #include "hal/mpu_types.h"
23 
24 #include "soc/soc_caps.h"
25 
mpu_hal_set_region_access(int id,mpu_access_t access)26 void mpu_hal_set_region_access(int id, mpu_access_t access)
27 {
28     uint32_t addr = mpu_ll_id_to_addr(id);
29 
30     switch (access)
31     {
32 #if SOC_MPU_REGION_RO_SUPPORTED
33         case MPU_REGION_RO:
34             mpu_ll_set_region_ro(addr);
35             break;
36 #endif
37 #if SOC_MPU_REGION_WO_SUPPORTED
38         case MPU_REGION_WO:
39             mpu_ll_set_region_wo(addr);
40             break;
41 #endif
42         case MPU_REGION_RW:
43             mpu_ll_set_region_rw(addr);
44             break;
45         case MPU_REGION_X:
46             mpu_ll_set_region_x(addr);
47             break;
48         case MPU_REGION_RWX:
49             mpu_ll_set_region_rwx(addr);
50             break;
51         case MPU_REGION_ILLEGAL:
52             mpu_ll_set_region_illegal(addr);
53             break;
54         default:
55             break;
56     }
57 }
58