ldcw.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __PARISC_LDCW_H
  2. #define __PARISC_LDCW_H
  3. #ifndef CONFIG_PA20
  4. /* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
  5. and GCC only guarantees 8-byte alignment for stack locals, we can't
  6. be assured of 16-byte alignment for atomic lock data even if we
  7. specify "__attribute ((aligned(16)))" in the type declaration. So,
  8. we use a struct containing an array of four ints for the atomic lock
  9. type and dynamically select the 16-byte aligned int from the array
  10. for the semaphore. */
  11. #define __PA_LDCW_ALIGNMENT 16
  12. #define __ldcw_align(a) ({ \
  13. unsigned long __ret = (unsigned long) &(a)->lock[0]; \
  14. __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \
  15. & ~(__PA_LDCW_ALIGNMENT - 1); \
  16. (volatile unsigned int *) __ret; \
  17. })
  18. #define __LDCW "ldcw"
  19. #else /*CONFIG_PA20*/
  20. /* From: "Jim Hull" <jim.hull of hp.com>
  21. I've attached a summary of the change, but basically, for PA 2.0, as
  22. long as the ",CO" (coherent operation) completer is specified, then the
  23. 16-byte alignment requirement for ldcw and ldcd is relaxed, and instead
  24. they only require "natural" alignment (4-byte for ldcw, 8-byte for
  25. ldcd). */
  26. #define __PA_LDCW_ALIGNMENT 4
  27. #define __ldcw_align(a) (&(a)->slock)
  28. #define __LDCW "ldcw,co"
  29. #endif /*!CONFIG_PA20*/
  30. /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
  31. #define __ldcw(a) ({ \
  32. unsigned __ret; \
  33. __asm__ __volatile__(__LDCW " 0(%2),%0" \
  34. : "=r" (__ret), "+m" (*(a)) : "r" (a)); \
  35. __ret; \
  36. })
  37. #ifdef CONFIG_SMP
  38. # define __lock_aligned __attribute__((__section__(".data..lock_aligned")))
  39. #endif
  40. #endif /* __PARISC_LDCW_H */