• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdint.h>
16 
17 #include "soc/soc_caps.h"
18 
19 #include "xt_instr_macros.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
mpu_ll_id_to_addr(int id)25 static inline uint32_t mpu_ll_id_to_addr(int id)
26 {
27     // vpn - id
28     // 0x00000000 = 0
29     // 0x20000000 = 1
30     // 0x40000000 = 2
31     // 0x60000000 = 3
32     // 0x80000000 = 4
33     // 0xa0000000 = 5
34     // 0xc0000000 = 6
35     // 0xe0000000 = 7
36     return id * SOC_MPU_MIN_REGION_SIZE;
37 }
38 
mpu_ll_set_region_rw(uint32_t addr)39 static inline void mpu_ll_set_region_rw(uint32_t addr)
40 {
41     WDTLB(0x0, addr); // cached, no allocate
42 }
43 
mpu_ll_set_region_rwx(uint32_t addr)44 static inline void mpu_ll_set_region_rwx(uint32_t addr)
45 {
46     WDTLB(0x2, addr); // bypass cache
47 }
48 
mpu_ll_set_region_x(uint32_t addr)49 static inline void mpu_ll_set_region_x(uint32_t addr)
50 {
51     WITLB(0x3, addr); // cached
52 }
53 
mpu_ll_set_region_illegal(uint32_t addr)54 static inline void mpu_ll_set_region_illegal(uint32_t addr)
55 {
56     WITLB(0xF, addr);
57     WDTLB(0xF, addr);
58 }
59 
60 #ifdef __cplusplus
61 }
62 #endif
63