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