cache.h 769 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __ASM_SH_CACHE_H
  2. #define __ASM_SH_CACHE_H
  3. #if defined(CONFIG_SH4) || defined(CONFIG_SH4A)
  4. int cache_control(unsigned int cmd);
  5. #define L1_CACHE_BYTES 32
  6. struct __large_struct { unsigned long buf[100]; };
  7. #define __m(x) (*(struct __large_struct *)(x))
  8. void dcache_wback_range(u32 start, u32 end)
  9. {
  10. u32 v;
  11. start &= ~(L1_CACHE_BYTES - 1);
  12. for (v = start; v < end; v += L1_CACHE_BYTES) {
  13. asm volatile ("ocbwb %0" : /* no output */
  14. : "m" (__m(v)));
  15. }
  16. }
  17. void dcache_invalid_range(u32 start, u32 end)
  18. {
  19. u32 v;
  20. start &= ~(L1_CACHE_BYTES - 1);
  21. for (v = start; v < end; v += L1_CACHE_BYTES) {
  22. asm volatile ("ocbi %0" : /* no output */
  23. : "m" (__m(v)));
  24. }
  25. }
  26. #endif /* CONFIG_SH4 || CONFIG_SH4A */
  27. #endif /* __ASM_SH_CACHE_H */