cacheflush.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __ASM_AVR32_CACHEFLUSH_H
  7. #define __ASM_AVR32_CACHEFLUSH_H
  8. /*
  9. * Invalidate any cacheline containing virtual address vaddr without
  10. * writing anything back to memory.
  11. *
  12. * Note that this function may corrupt unrelated data structures when
  13. * applied on buffers that are not cacheline aligned in both ends.
  14. */
  15. static inline void dcache_invalidate_line(volatile void *vaddr)
  16. {
  17. asm volatile("cache %0[0], 0x0b" : : "r"(vaddr) : "memory");
  18. }
  19. /*
  20. * Make sure any cacheline containing virtual address vaddr is written
  21. * to memory.
  22. */
  23. static inline void dcache_clean_line(volatile void *vaddr)
  24. {
  25. asm volatile("cache %0[0], 0x0c" : : "r"(vaddr) : "memory");
  26. }
  27. /*
  28. * Make sure any cacheline containing virtual address vaddr is written
  29. * to memory and then invalidate it.
  30. */
  31. static inline void dcache_flush_line(volatile void *vaddr)
  32. {
  33. asm volatile("cache %0[0], 0x0d" : : "r"(vaddr) : "memory");
  34. }
  35. /*
  36. * Invalidate any instruction cacheline containing virtual address
  37. * vaddr.
  38. */
  39. static inline void icache_invalidate_line(volatile void *vaddr)
  40. {
  41. asm volatile("cache %0[0], 0x01" : : "r"(vaddr) : "memory");
  42. }
  43. /*
  44. * Applies the above functions on all lines that are touched by the
  45. * specified virtual address range.
  46. */
  47. void dcache_clean_range(volatile void *start, size_t len);
  48. void icache_invalidate_range(volatile void *start, size_t len);
  49. static inline void dcache_flush_unlocked(void)
  50. {
  51. asm volatile("cache %0[5], 0x08" : : "r"(0) : "memory");
  52. }
  53. /*
  54. * Make sure any pending writes are completed before continuing.
  55. */
  56. #define sync_write_buffer() asm volatile("sync 0" : : : "memory")
  57. #endif /* __ASM_AVR32_CACHEFLUSH_H */