barrier.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
  3. * Copyright (C) 2002 Paul Mundt
  4. */
  5. #ifndef __ASM_SH_BARRIER_H
  6. #define __ASM_SH_BARRIER_H
  7. #if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
  8. #include <asm/cache_insns.h>
  9. #endif
  10. /*
  11. * A brief note on ctrl_barrier(), the control register write barrier.
  12. *
  13. * Legacy SH cores typically require a sequence of 8 nops after
  14. * modification of a control register in order for the changes to take
  15. * effect. On newer cores (like the sh4a and sh5) this is accomplished
  16. * with icbi.
  17. *
  18. * Also note that on sh4a in the icbi case we can forego a synco for the
  19. * write barrier, as it's not necessary for control registers.
  20. *
  21. * Historically we have only done this type of barrier for the MMUCR, but
  22. * it's also necessary for the CCR, so we make it generic here instead.
  23. */
  24. #if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
  25. #define mb() __asm__ __volatile__ ("synco": : :"memory")
  26. #define rmb() mb()
  27. #define wmb() mb()
  28. #define ctrl_barrier() __icbi(PAGE_OFFSET)
  29. #else
  30. #if defined(CONFIG_CPU_J2) && defined(CONFIG_SMP)
  31. #define __smp_mb() do { int tmp = 0; __asm__ __volatile__ ("cas.l %0,%0,@%1" : "+r"(tmp) : "z"(&tmp) : "memory", "t"); } while(0)
  32. #define __smp_rmb() __smp_mb()
  33. #define __smp_wmb() __smp_mb()
  34. #endif
  35. #define ctrl_barrier() __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
  36. #endif
  37. #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
  38. #include <asm-generic/barrier.h>
  39. #endif /* __ASM_SH_BARRIER_H */