atomic64-ops.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. # long long atomic64_inc_return(atomic64_t *v)
  20. #
  21. ###############################################################################
  22. .globl atomic64_inc_return
  23. .type atomic64_inc_return,@function
  24. atomic64_inc_return:
  25. or.p gr8,gr8,gr10
  26. 0:
  27. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  28. ckeq icc3,cc7
  29. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  30. orcr cc7,cc7,cc3 /* set CC3 to true */
  31. addicc gr9,#1,gr9,icc0
  32. addxi gr8,#0,gr8,icc0
  33. cstd.p gr8,@(gr10,gr0) ,cc3,#1
  34. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  35. beq icc3,#0,0b
  36. bralr
  37. .size atomic64_inc_return, .-atomic64_inc_return
  38. ###############################################################################
  39. #
  40. # long long atomic64_dec_return(atomic64_t *v)
  41. #
  42. ###############################################################################
  43. .globl atomic64_dec_return
  44. .type atomic64_dec_return,@function
  45. atomic64_dec_return:
  46. or.p gr8,gr8,gr10
  47. 0:
  48. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  49. ckeq icc3,cc7
  50. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  51. orcr cc7,cc7,cc3 /* set CC3 to true */
  52. subicc gr9,#1,gr9,icc0
  53. subxi gr8,#0,gr8,icc0
  54. cstd.p gr8,@(gr10,gr0) ,cc3,#1
  55. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  56. beq icc3,#0,0b
  57. bralr
  58. .size atomic64_dec_return, .-atomic64_dec_return
  59. ###############################################################################
  60. #
  61. # long long atomic64_add_return(long long i, atomic64_t *v)
  62. #
  63. ###############################################################################
  64. .globl atomic64_add_return
  65. .type atomic64_add_return,@function
  66. atomic64_add_return:
  67. or.p gr8,gr8,gr4
  68. or gr9,gr9,gr5
  69. 0:
  70. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  71. ckeq icc3,cc7
  72. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  73. orcr cc7,cc7,cc3 /* set CC3 to true */
  74. addcc gr9,gr5,gr9,icc0
  75. addx gr8,gr4,gr8,icc0
  76. cstd.p gr8,@(gr10,gr0) ,cc3,#1
  77. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  78. beq icc3,#0,0b
  79. bralr
  80. .size atomic64_add_return, .-atomic64_add_return
  81. ###############################################################################
  82. #
  83. # long long atomic64_sub_return(long long i, atomic64_t *v)
  84. #
  85. ###############################################################################
  86. .globl atomic64_sub_return
  87. .type atomic64_sub_return,@function
  88. atomic64_sub_return:
  89. or.p gr8,gr8,gr4
  90. or gr9,gr9,gr5
  91. 0:
  92. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  93. ckeq icc3,cc7
  94. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  95. orcr cc7,cc7,cc3 /* set CC3 to true */
  96. subcc gr9,gr5,gr9,icc0
  97. subx gr8,gr4,gr8,icc0
  98. cstd.p gr8,@(gr10,gr0) ,cc3,#1
  99. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  100. beq icc3,#0,0b
  101. bralr
  102. .size atomic64_sub_return, .-atomic64_sub_return
  103. ###############################################################################
  104. #
  105. # uint64_t __xchg_64(uint64_t i, uint64_t *v)
  106. #
  107. ###############################################################################
  108. .globl __xchg_64
  109. .type __xchg_64,@function
  110. __xchg_64:
  111. or.p gr8,gr8,gr4
  112. or gr9,gr9,gr5
  113. 0:
  114. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  115. ckeq icc3,cc7
  116. ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
  117. orcr cc7,cc7,cc3 /* set CC3 to true */
  118. cstd.p gr4,@(gr10,gr0) ,cc3,#1
  119. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  120. beq icc3,#0,0b
  121. bralr
  122. .size __xchg_64, .-__xchg_64
  123. ###############################################################################
  124. #
  125. # uint64_t __cmpxchg_64(uint64_t test, uint64_t new, uint64_t *v)
  126. #
  127. ###############################################################################
  128. .globl __cmpxchg_64
  129. .type __cmpxchg_64,@function
  130. __cmpxchg_64:
  131. or.p gr8,gr8,gr4
  132. or gr9,gr9,gr5
  133. 0:
  134. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  135. ckeq icc3,cc7
  136. ldd.p @(gr12,gr0),gr8 /* LDD.P/ORCR must be atomic */
  137. orcr cc7,cc7,cc3
  138. subcc gr8,gr4,gr0,icc0
  139. subcc.p gr9,gr5,gr0,icc1
  140. bnelr icc0,#0
  141. bnelr icc1,#0
  142. cstd.p gr10,@(gr12,gr0) ,cc3,#1
  143. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  144. beq icc3,#0,0b
  145. bralr
  146. .size __cmpxchg_64, .-__cmpxchg_64