preliminaryDataProcessing.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* bitops.h: bit operations for the Fujitsu FR-V CPUs
  2. *
  3. * For an explanation of how atomic ops work in this arch, see:
  4. * Documentation/frv/atomic-ops.txt
  5. *
  6. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  7. * Written by David Howells (dhowells@redhat.com)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #ifndef _ASM_BITOPS_H
  15. #define _ASM_BITOPS_H
  16. #include <linux/compiler.h>
  17. #include <asm/byteorder.h>
  18. #ifdef __KERNEL__
  19. #ifndef _LINUX_BITOPS_H
  20. #error only <linux/bitops.h> can be included directly
  21. #endif
  22. #include <asm-generic/bitops/ffz.h>
  23. /*
  24. * clear_bit() doesn't provide any barrier for the compiler.
  25. */
  26. #define smp_mb__before_clear_bit() barrier()
  27. #define smp_mb__after_clear_bit() barrier()
  28. #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
  29. static inline
  30. unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v)
  31. {
  32. unsigned long old, tmp;
  33. asm volatile(
  34. "0: \n"
  35. " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */
  36. " ckeq icc3,cc7 \n"
  37. " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */
  38. " orcr cc7,cc7,cc3 \n" /* set CC3 to true */
  39. " and%I3 %1,%3,%2 \n"
  40. " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */
  41. " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */
  42. " beq icc3,#0,0b \n"
  43. : "+U"(*v), "=&r"(old), "=r"(tmp)
  44. : "NPr"(~mask)
  45. : "memory", "cc7", "cc3", "icc3"
  46. );
  47. return old;
  48. }
  49. static inline
  50. unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v)
  51. {
  52. unsigned long old, tmp;
  53. asm volatile(
  54. "0: \n"
  55. " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */