18 #define CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS 20 #define CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS 22 #define CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING 24 #define CPU_INSTRUCTION_CACHE_ALIGNMENT 64 26 #define CPU_DATA_CACHE_ALIGNMENT 64 28 static inline volatile struct l2c_regs *get_l2c_regs(
void)
30 volatile struct l2c_regs *l2c = NULL;
33 adev = (
void *) ambapp_for_each(
35 OPTIONS_ALL | OPTIONS_AHB_SLVS,
42 l2c = (
volatile struct l2c_regs *) DEV_TO_AHB(adev)->start[1];
48 static inline size_t get_l2_size(
void)
51 volatile struct l2c_regs *l2c = get_l2c_regs();
54 unsigned status = l2c->status;
55 unsigned ways = (status & 0x3) + 1;
56 unsigned set_size = ((status & 0x7ff) >> 2) * 1024;
58 size = ways * set_size;
64 static inline size_t get_l1_size(uint32_t l1_cfg)
66 uint32_t ways = ((l1_cfg >> 24) & 0x7) + 1;
67 uint32_t wsize = UINT32_C(1) << (((l1_cfg >> 20) & 0xf) + 10);
72 static inline size_t get_max_size(
size_t a,
size_t b)
77 static inline size_t get_cache_size(uint32_t level, uint32_t l1_cfg)
83 size = get_max_size(get_l1_size(l1_cfg), get_l2_size());
86 size = get_l1_size(l1_cfg);
99 static inline size_t _CPU_cache_get_data_cache_size(uint32_t level)
101 return get_cache_size(level, leon3_get_data_cache_config_register());
104 static inline void _CPU_cache_flush_data_range(
112 static inline void _CPU_cache_invalidate_data_range(
120 static inline void _CPU_cache_freeze_data(
void)
125 static inline void _CPU_cache_unfreeze_data(
void)
130 static inline void _CPU_cache_invalidate_entire_instruction(
void)
132 uint32_t cache_reg = leon3_get_cache_control_register();
134 cache_reg |= LEON3_REG_CACHE_CTRL_FI;
135 leon3_set_cache_control_register(cache_reg);
138 static inline void _CPU_cache_invalidate_instruction_range(
143 _CPU_cache_invalidate_entire_instruction();
146 static inline void _CPU_cache_freeze_instruction(
void)
151 static inline void _CPU_cache_unfreeze_instruction(
void)
156 static inline void _CPU_cache_flush_entire_data(
void)
161 static inline void _CPU_cache_invalidate_entire_data(
void)
166 static inline void _CPU_cache_enable_data(
void)
171 static inline void _CPU_cache_disable_data(
void)
176 static inline size_t _CPU_cache_get_instruction_cache_size( uint32_t level )
178 return get_cache_size(level, leon3_get_inst_cache_config_register());
181 static inline void _CPU_cache_enable_instruction(
void)
186 static inline void _CPU_cache_disable_instruction(
void)
191 #include "../../../shared/cache/cacheimpl.h"
LEON3 BSP data types and macros.