@@ -103,6 +103,11 @@ typedef enum {
103
103
CACHE_AUTOLOAD_NEGATIVE = 1 , /*!< cache autoload step is negative */
104
104
} cache_autoload_order_t ;
105
105
106
+ typedef enum {
107
+ CACHE_AUTOLOAD_REGION0 = 0 , /*!< cache autoload region0 */
108
+ CACHE_AUTOLOAD_REGION1 = 1 , /*!< cache autoload region1 */
109
+ } cache_autoload_region_t ;
110
+
106
111
#define CACHE_AUTOLOAD_STEP (i ) ((i) - 1)
107
112
108
113
typedef enum {
@@ -144,14 +149,17 @@ struct dcache_tag_item {
144
149
};
145
150
146
151
struct autoload_config {
152
+ uint8_t ena ; /*!< autoload enable */
147
153
uint8_t order ; /*!< autoload step is positive or negative */
148
154
uint8_t trigger ; /*!< autoload trigger */
149
- uint8_t ena0 ; /*!< autoload region0 enable */
150
- uint8_t ena1 ; /*!< autoload region1 enable */
151
- uint32_t addr0 ; /*!< autoload region0 start address */
152
- uint32_t size0 ; /*!< autoload region0 size */
153
- uint32_t addr1 ; /*!< autoload region1 start address */
154
- uint32_t size1 ; /*!< autoload region1 size */
155
+ uint8_t size ; /*!< autoload size */
156
+ };
157
+
158
+ struct autoload_region_config {
159
+ uint8_t region ; /*!< autoload region*/
160
+ uint8_t ena ; /*!< autoload region enable */
161
+ uint32_t addr ; /*!< autoload region start address */
162
+ uint32_t size ; /*!< autoload region size */
155
163
};
156
164
157
165
struct tag_group_info {
@@ -160,6 +168,7 @@ struct tag_group_info {
160
168
uint32_t vaddr_offset ; /*!< virtual address offset of the cache ways */
161
169
uint32_t tag_addr [MAX_CACHE_WAYS ]; /*!< tag memory address, only [0~mode.ways-1] is valid to use */
162
170
uint32_t cache_memory_offset [MAX_CACHE_WAYS ]; /*!< cache memory address, only [0~mode.ways-1] is valid to use */
171
+ uint8_t use_legacy ; /*!< 1 for using legacy tag api, 0 for using 2rd tag api */
163
172
};
164
173
165
174
struct lock_config {
@@ -168,6 +177,39 @@ struct lock_config {
168
177
uint16_t group ; /*!< manual lock group, 0 or 1*/
169
178
};
170
179
180
+ struct cache_internal_stub_table {
181
+ uint32_t (* icache_line_size )(void );
182
+ uint32_t (* dcache_line_size )(void );
183
+ uint32_t (* icache_addr )(uint32_t addr );
184
+ uint32_t (* dcache_addr )(uint32_t addr );
185
+ void (* invalidate_icache_items )(uint32_t addr , uint32_t items );
186
+ void (* invalidate_dcache_items )(uint32_t addr , uint32_t items );
187
+ void (* clean_items )(uint32_t addr , uint32_t items );
188
+ void (* writeback_items )(uint32_t addr , uint32_t items );
189
+ void (* lock_icache_items )(uint32_t addr , uint32_t items );
190
+ void (* lock_dcache_items )(uint32_t addr , uint32_t items );
191
+ void (* unlock_icache_items )(uint32_t addr , uint32_t items );
192
+ void (* unlock_dcache_items )(uint32_t addr , uint32_t items );
193
+ void (* occupy_items )(uint32_t addr , uint32_t items );
194
+ uint32_t (* suspend_icache_autoload )(void );
195
+ void (* resume_icache_autoload )(uint32_t autoload );
196
+ uint32_t (* suspend_dcache_autoload )(void );
197
+ void (* resume_dcache_autoload )(uint32_t autoload );
198
+ void (* freeze_icache_enable )(cache_freeze_mode_t mode );
199
+ void (* freeze_icache_disable )(void );
200
+ void (* freeze_dcache_enable )(cache_freeze_mode_t mode );
201
+ void (* freeze_dcache_disable )(void );
202
+ int (* op_addr )(uint32_t op_icache , uint32_t start_addr , uint32_t size , uint32_t cache_line_size , uint32_t max_sync_num , void (* cache_Iop )(uint32_t , uint32_t ), void (* cache_Dop )(uint32_t , uint32_t ));
203
+ };
204
+
205
+ typedef void (* cache_op_start )(void );
206
+ typedef void (* cache_op_end )(void );
207
+
208
+ typedef struct {
209
+ cache_op_start start ;
210
+ cache_op_end end ;
211
+ } cache_op_cb_t ;
212
+
171
213
#define ESP_ROM_ERR_INVALID_ARG 1
172
214
#define MMU_SET_ADDR_ALIGNED_ERROR 2
173
215
#define MMU_SET_PASE_SIZE_ERROR 3
@@ -190,7 +232,7 @@ void Cache_MMU_Init(void);
190
232
* @brief Set ICache mmu mapping.
191
233
* Please do not call this function in your SDK application.
192
234
*
193
- * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid.
235
+ * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid.
194
236
*
195
237
* @param uint32_t vaddr : virtual address in CPU address space.
196
238
* Can be Iram0,Iram1,Irom0,Drom0 and AHB buses address.
@@ -217,7 +259,7 @@ int Cache_Ibus_MMU_Set(uint32_t ext_ram, uint32_t vaddr, uint32_t paddr, uint32
217
259
* @brief Set DCache mmu mapping.
218
260
* Please do not call this function in your SDK application.
219
261
*
220
- * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid.
262
+ * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid.
221
263
*
222
264
* @param uint32_t vaddr : virtual address in CPU address space.
223
265
* Can be DRam0, DRam1, DRom0, DPort and AHB buses address.
@@ -272,9 +314,9 @@ uint32_t Cache_Flash_To_SPIRAM_Copy(uint32_t bus, uint32_t bus_start_addr, uint3
272
314
* @brief allocate memory to used by ICache.
273
315
* Please do not call this function in your SDK application.
274
316
*
275
- * @param cache_array_t icache_low : the data array bank used by icache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1
317
+ * @param cache_array_t icache_low : the data array bank used by icache low part. Due to timing constraint , can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0
276
318
*
277
- * @param cache_array_t icache_high : the data array bank used by icache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 only if icache_low and icache_high is not CACHE_MEMORY_INVALID
319
+ * @param cache_array_t icache_high : the data array bank used by icache high part. Due to timing constraint , can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_IBANK1 only if icache_low and icache_high is CACHE_MEMORY_IBANK0
278
320
*
279
321
* return none
280
322
*/
@@ -284,9 +326,9 @@ void Cache_Occupy_ICache_MEMORY(cache_array_t icache_low, cache_array_t icache_h
284
326
* @brief allocate memory to used by DCache.
285
327
* Please do not call this function in your SDK application.
286
328
*
287
- * @param cache_array_t dcache_low : the data array bank used by dcache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0 , CACHE_MEMORY_DBANK1
329
+ * @param cache_array_t dcache_low : the data array bank used by dcache low part. Due to timing constraint , can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK1
288
330
*
289
- * @param cache_array_t dcache1_high : the data array bank used by dcache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 only if dcache_low0 and dcache_low1 is not CACHE_MEMORY_INVALID
331
+ * @param cache_array_t dcache1_high : the data array bank used by dcache high part. Due to timing constraint , can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_DBANK0 only if dcache_low0 and dcache_low1 is CACHE_MEMORY_DBANK1
290
332
*
291
333
* return none
292
334
*/
@@ -310,7 +352,7 @@ void Cache_Get_Mode(struct cache_mode *mode);
310
352
*
311
353
* @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC
312
354
*
313
- * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B
355
+ * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B and CACHE_LINE_SIZE_32B
314
356
*
315
357
* return none
316
358
*/
@@ -320,9 +362,9 @@ void Cache_Set_ICache_Mode(cache_size_t cache_size, cache_ways_t ways, cache_lin
320
362
* @brief set DCache modes: cache size, associate ways and cache line size.
321
363
* Please do not call this function in your SDK application.
322
364
*
323
- * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_8KB and CACHE_SIZE_16KB
365
+ * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_HALF and CACHE_SIZE_FULL
324
366
*
325
- * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC
367
+ * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC, only CACHE_4WAYS_ASSOC works
326
368
*
327
369
* @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B
328
370
*
@@ -351,7 +393,7 @@ uint32_t Cache_Address_Through_ICache(uint32_t addr);
351
393
uint32_t Cache_Address_Through_DCache (uint32_t addr );
352
394
353
395
/**
354
- * @brief Init mmu owner register to make i/d cache use half mmu entries .
396
+ * @brief Init Cache for ROM boot, including resetting the Dcache, initializing Owner, MMU, setting DCache mode, Enabling DCache, unmasking bus .
355
397
*
356
398
* @param None
357
399
*
@@ -636,6 +678,16 @@ void Cache_End_DCache_Preload(uint32_t autoload);
636
678
*/
637
679
void Cache_Config_ICache_Autoload (const struct autoload_config * config );
638
680
681
+ /**
682
+ * @brief Config region autoload parameters of ICache.
683
+ * Please do not call this function in your SDK application.
684
+ *
685
+ * @param struct autoload_region_config * config : region autoload parameters.
686
+ *
687
+ * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success
688
+ */
689
+ int Cache_Config_ICache_Region_Autoload (const struct autoload_region_config * config );
690
+
639
691
/**
640
692
* @brief Enable auto preload for ICache.
641
693
* Please do not call this function in your SDK application.
@@ -666,6 +718,16 @@ void Cache_Disable_ICache_Autoload(void);
666
718
*/
667
719
void Cache_Config_DCache_Autoload (const struct autoload_config * config );
668
720
721
+ /**
722
+ * @brief Config region autoload parameters of DCache.
723
+ * Please do not call this function in your SDK application.
724
+ *
725
+ * @param struct autoload_region_config * config : region autoload parameters.
726
+ *
727
+ * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success
728
+ */
729
+ int Cache_Config_DCache_Region_Autoload (const struct autoload_region_config * config );
730
+
669
731
/**
670
732
* @brief Enable auto preload for DCache.
671
733
* Please do not call this function in your SDK application.
@@ -1008,7 +1070,24 @@ void Cache_Freeze_DCache_Disable(void);
1008
1070
*
1009
1071
* @return None
1010
1072
*/
1011
- void Cache_Travel_Tag_Memory (struct cache_mode * mode , uint32_t filter_addr , void (* process )(struct tag_group_info * ));
1073
+ void Cache_Travel_Tag_Memory (struct cache_mode * mode , uint32_t filter_addr , void (* process )(struct tag_group_info * ));
1074
+
1075
+ /**
1076
+ * @brief Travel tag memory to run a call back function, using 2nd tag registers.
1077
+ * ICache and DCache are suspend when doing this.
1078
+ * The callback will get the parameter tag_group_info, which will include a group of tag memory addresses and cache memory addresses.
1079
+ * Please do not call this function in your SDK application.
1080
+ *
1081
+ * @param struct cache_mode * mode : the cache to check and the cache mode.
1082
+ *
1083
+ * @param uint32_t filter_addr : only the cache lines which may include the filter_address will be returned to the call back function.
1084
+ * 0 for do not filter, all cache lines will be returned.
1085
+ *
1086
+ * @param void (* process)(struct tag_group_info *) : call back function, which may be called many times, a group(the addresses in the group are in the same position in the cache ways) a time.
1087
+ *
1088
+ * @return None
1089
+ */
1090
+ void Cache_Travel_Tag_Memory2 (struct cache_mode * mode , uint32_t filter_addr , void (* process )(struct tag_group_info * ));
1012
1091
1013
1092
/**
1014
1093
* @brief Get the virtual address from cache mode, cache tag and the virtual address offset of cache ways.
@@ -1092,6 +1171,8 @@ int flash2spiram_rodata_offset(void);
1092
1171
uint32_t flash_instr_rodata_start_page (uint32_t bus );
1093
1172
uint32_t flash_instr_rodata_end_page (uint32_t bus );
1094
1173
1174
+ extern struct cache_internal_stub_table * rom_cache_internal_table_ptr ;
1175
+ extern cache_op_cb_t rom_cache_op_cb ;
1095
1176
#ifdef __cplusplus
1096
1177
}
1097
1178
#endif
0 commit comments