atomic64-ops.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* kernel atomic64 operations
  2. *
  3. * For an explanation of how atomic ops work in this arch, see:
  4. * Documentation/frv/atomic-ops.txt
  5. *
  6. * Copyright (C) 2009 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. #include <asm/spr-regs.h>
  15. .text
  16. .balign 4
  17. ###############################################################################
  18. #
  19. # uint64_t __xchg_64(uint64_t i, uint64_t *v)
  20. #
  21. ###############################################################################
  22. .globl __xchg_64
  23. .type __xchg_64,@function
  24. __xchg_64:
  25. or.p gr8,gr8,gr4
  26. or gr9,gr9,gr5
  27. 0:
  28. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  29. ckeq icc3,cc7
  30. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  31. orcr cc7,cc7,cc3 /* set CC3 to true */
  32. cstd.p gr4,@(gr10,gr0) ,cc3,#1
  33. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  34. beq icc3,#0,0b
  35. bralr
  36. .size __xchg_64, .-__xchg_64
  37. ###############################################################################
  38. #
  39. # uint64_t __cmpxchg_64(uint64_t test, uint64_t new, uint64_t *v)
  40. #
  41. ###############################################################################
  42. .globl __cmpxchg_64
  43. .type __cmpxchg_64,@function
  44. __cmpxchg_64:
  45. or.p gr8,gr8,gr4
  46. or gr9,gr9,gr5
  47. 0:
  48. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  49. ckeq icc3,cc7
  50. ldd.p @(gr12,gr0),gr8 /* LDD.P/ORCR must be atomic */
  51. orcr cc7,cc7,cc3
  52. subcc gr8,gr4,gr0,icc0
  53. subcc.p gr9,gr5,gr0,icc1
  54. bnelr icc0,#0
  55. bnelr icc1,#0
  56. cstd.p gr10,@(gr12,gr0) ,cc3,#1
  57. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  58. beq icc3,#0,0b
  59. bralr
  60. .size __cmpxchg_64, .-__cmpxchg_64