Select one of the symbols to view example projects that use it.
 
Outline
#define _ROM_CACHE_H_
#include "esp_attr.h"
#include "dport_access.h"
#define DPORT_STALL_OTHER_CPU_START
#define DPORT_STALL_OTHER_CPU_END
mmu_init(int);
cache_flash_mmu_set(int, int, unsigned int, unsigned int, int, int)
cache_sram_mmu_set(int, int, unsigned int, unsigned int, int, int);
Cache_Read_Init(int)
Cache_Flush(int)
Cache_Read_Disable(int)
Cache_Read_Enable(int)
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_rom/esp32/include/esp32/rom/cache.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #ifndef _ROM_CACHE_H_ #define _ROM_CACHE_H_ #include "esp_attr.h" #if __has_include("dport_access.h") #include "dport_access.h" #else #pragma message("For ESP32 with ECO version < 2, you need to use a DPORT workaround that stalls the other CPU") #define DPORT_STALL_OTHER_CPU_START() #define DPORT_STALL_OTHER_CPU_END()/* ... */ #endif #ifdef __cplusplus extern "C" { #endif /** \defgroup uart_apis, uart configuration and communication related apis * @brief uart apis *//* ... */ /** @addtogroup uart_apis * @{ *//* ... */ /** * @brief Initialise cache mmu, mark all entries as invalid. * Please do not call this function in your SDK application. * * @param int cpu_no : 0 for PRO cpu, 1 for APP cpu. * * @return None *//* ... */ void mmu_init(int cpu_no); /** * @brief Set Flash-Cache mmu mapping. * Please do not call this function in your SDK application. * * @param int cpu_no : CPU number, 0 for PRO cpu, 1 for APP cpu. * * @param int pid : process identifier. Range 0~7. * * @param unsigned int vaddr : virtual address in CPU address space. * Can be IRam0, IRam1, IRom0 and DRom0 memory address. * Should be aligned by psize. * * @param unsigned int paddr : physical address in Flash. * Should be aligned by psize. * * @param int psize : page size of flash, in kilobytes. Should be 64 here. * * @param int num : pages to be set. * * @return unsigned int: error status * 0 : mmu set success * 1 : vaddr or paddr is not aligned * 2 : pid error * 3 : psize error * 4 : mmu table to be written is out of range * 5 : vaddr is out of range *//* ... */ static inline __attribute__((always_inline)) unsigned int IRAM_ATTR cache_flash_mmu_set(int cpu_no, int pid, unsigned int vaddr, unsigned int paddr, int psize, int num) { extern unsigned int cache_flash_mmu_set_rom(int cpu_no, int pid, unsigned int vaddr, unsigned int paddr, int psize, int num); unsigned int ret; DPORT_STALL_OTHER_CPU_START(); ret = cache_flash_mmu_set_rom(cpu_no, pid, vaddr, paddr, psize, num); DPORT_STALL_OTHER_CPU_END(); return ret; }{ ... } /** * @brief Set Ext-SRAM-Cache mmu mapping. * Please do not call this function in your SDK application. * * Note that this code lives in IRAM and has a bugfix in respect to the ROM version * of this function (which erroneously refused a vaddr > 2MiB * * @param int cpu_no : CPU number, 0 for PRO cpu, 1 for APP cpu. * * @param int pid : process identifier. Range 0~7. * * @param unsigned int vaddr : virtual address in CPU address space. * Can be IRam0, IRam1, IRom0 and DRom0 memory address. * Should be aligned by psize. * * @param unsigned int paddr : physical address in Ext-SRAM. * Should be aligned by psize. * * @param int psize : page size of flash, in kilobytes. Should be 32 here. * * @param int num : pages to be set. * * @return unsigned int: error status * 0 : mmu set success * 1 : vaddr or paddr is not aligned * 2 : pid error * 3 : psize error * 4 : mmu table to be written is out of range * 5 : vaddr is out of range *//* ... */ unsigned int IRAM_ATTR cache_sram_mmu_set(int cpu_no, int pid, unsigned int vaddr, unsigned int paddr, int psize, int num); /** * @brief Initialise cache access for the cpu. * Please do not call this function in your SDK application. * * @param int cpu_no : 0 for PRO cpu, 1 for APP cpu. * * @return None *//* ... */ static inline __attribute__((always_inline)) void IRAM_ATTR Cache_Read_Init(int cpu_no) { extern void Cache_Read_Init_rom(int cpu_no); DPORT_STALL_OTHER_CPU_START(); Cache_Read_Init_rom(cpu_no); DPORT_STALL_OTHER_CPU_END(); }{ ... } /** * @brief Flush the cache value for the cpu. * Please do not call this function in your SDK application. * * @param int cpu_no : 0 for PRO cpu, 1 for APP cpu. * * @return None *//* ... */ static inline __attribute__((always_inline)) void IRAM_ATTR Cache_Flush(int cpu_no) { extern void Cache_Flush_rom(int cpu_no); DPORT_STALL_OTHER_CPU_START(); Cache_Flush_rom(cpu_no); DPORT_STALL_OTHER_CPU_END(); }{ ... } /** * @brief Disable Cache access for the cpu. * Please do not call this function in your SDK application. * * @param int cpu_no : 0 for PRO cpu, 1 for APP cpu. * * @return None *//* ... */ static inline __attribute__((always_inline)) void IRAM_ATTR Cache_Read_Disable(int cpu_no) { extern void Cache_Read_Disable_rom(int cpu_no); DPORT_STALL_OTHER_CPU_START(); Cache_Read_Disable_rom(cpu_no); DPORT_STALL_OTHER_CPU_END(); }{ ... } /** * @brief Enable Cache access for the cpu. * Please do not call this function in your SDK application. * * @param int cpu_no : 0 for PRO cpu, 1 for APP cpu. * * @return None *//* ... */ static inline __attribute__((always_inline)) void IRAM_ATTR Cache_Read_Enable(int cpu_no) { extern void Cache_Read_Enable_rom(int cpu_no); DPORT_STALL_OTHER_CPU_START(); Cache_Read_Enable_rom(cpu_no); DPORT_STALL_OTHER_CPU_END(); }{ ... } /** * @} *//* ... */ #ifdef __cplusplus }{...} #endif /* ... */ #endif /* _ROM_CACHE_H_ */
Details