Changes in kernel/arch/arm32/src/cpu/cpu.c [93d8022:c8a5c8c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/cpu/cpu.c
r93d8022 rc8a5c8c 41 41 #include <print.h> 42 42 43 #ifdef CONFIG_FPU44 #include <arch/fpu_context.h>45 #endif46 47 43 static inline unsigned log2(unsigned val) 48 44 { … … 64 60 static const char * implementer(unsigned id) 65 61 { 66 switch (id) { 62 switch (id) 63 { 67 64 case 0x41: return "ARM Limited"; 68 65 case 0x44: return "Digital Equipment Corporation"; … … 130 127 { 131 128 uint32_t control_reg = SCTLR_read(); 132 133 dcache_invalidate(); 134 read_barrier(); 135 129 136 130 /* Turn off tex remap, RAZ/WI prior to armv7 */ 137 131 control_reg &= ~SCTLR_TEX_REMAP_EN_FLAG; … … 163 157 #endif 164 158 #ifdef PROCESSOR_ARCH_armv7_a 165 /* ICache coherency is elaborate don in barrier.h.159 /* ICache coherency is elaborate on in barrier.h. 166 160 * VIPT and PIPT caches need maintenance only on code modify, 167 161 * so it should be safe for general use. … … 172 166 control_reg |= 173 167 SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG; 174 } else {175 control_reg &=176 ~(SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG);177 168 } 178 169 #endif … … 213 204 #ifdef PROCESSOR_ARCH_armv7_a 214 205 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT); 215 const uint32_t ccsidr = CCSIDR_read(); 216 return CCSIDR_LINESIZE_LOG(ccsidr); 206 const unsigned ls_log = 2 + 207 ((CCSIDR_read() >> CCSIDR_LINESIZE_SHIFT) & CCSIDR_LINESIZE_MASK); 208 return ls_log + 2; //return log2(bytes) 217 209 #endif 218 210 return 0; … … 225 217 #ifdef PROCESSOR_ARCH_armv7_a 226 218 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT); 227 const uint32_t ccsidr = CCSIDR_read(); 228 return CCSIDR_WAYS(ccsidr); 219 const unsigned ways = 1 + 220 ((CCSIDR_read() >> CCSIDR_ASSOC_SHIFT) & CCSIDR_ASSOC_MASK); 221 return ways; 229 222 #endif 230 223 return 0; … … 236 229 #ifdef PROCESSOR_ARCH_armv7_a 237 230 CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT); 238 const uint32_t ccsidr = CCSIDR_read(); 239 return CCSIDR_SETS(ccsidr); 231 const unsigned sets = 1 + 232 ((CCSIDR_read() >> CCSIDR_NUMSETS_SHIFT) & CCSIDR_NUMSETS_MASK); 233 return sets; 240 234 #endif 241 235 return 0; … … 247 241 #ifdef PROCESSOR_ARCH_armv7_a 248 242 const uint32_t val = CLIDR_read(); 249 for (unsigned i = 0; i < 8; ++i) {243 for (unsigned i = 1; i <= 7; ++i) { 250 244 const unsigned ctype = CLIDR_CACHE(i, val); 251 245 switch (ctype) { … … 286 280 const unsigned ways = dcache_ways(i); 287 281 const unsigned sets = dcache_sets(i); 288 const unsigned way_shift = 32- log2(ways);282 const unsigned way_shift = 31 - log2(ways); 289 283 const unsigned set_shift = dcache_linesize_log(i); 290 284 dcache_clean_manual(i, false, ways, sets, way_shift, set_shift); … … 299 293 const unsigned ways = dcache_ways(i); 300 294 const unsigned sets = dcache_sets(i); 301 const unsigned way_shift = 32- log2(ways);295 const unsigned way_shift = 31 - log2(ways); 302 296 const unsigned set_shift = dcache_linesize_log(i); 303 297 dcache_clean_manual(i, true, ways, sets, way_shift, set_shift); … … 325 319 void icache_invalidate(void) 326 320 { 327 #if defined(PROCESSOR_ARCH_armv7_a)328 321 ICIALLU_write(0); 329 #else330 ICIALL_write(0);331 #endif332 }333 334 #if !defined(PROCESSOR_ARCH_armv7_a)335 static bool cache_is_unified(void)336 {337 if (MIDR_read() != CTR_read()) {338 /* We have the CTR register */339 return (CTR_read() & CTR_SEP_FLAG) != CTR_SEP_FLAG;340 } else {341 panic("Unknown cache type");342 }343 }344 #endif345 346 void dcache_invalidate(void)347 {348 #if defined(PROCESSOR_ARCH_armv7_a)349 dcache_flush_invalidate();350 #else351 if (cache_is_unified())352 CIALL_write(0);353 else354 DCIALL_write(0);355 #endif356 }357 358 void dcache_clean_mva_pou(uintptr_t mva)359 {360 #if defined(PROCESSOR_ARCH_armv7_a)361 DCCMVAU_write(mva);362 #else363 if (cache_is_unified())364 CCMVA_write(mva);365 else366 DCCMVA_write(mva);367 #endif368 322 } 369 323
Note:
See TracChangeset
for help on using the changeset viewer.