atomic-ops.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* atomic-ops.S: kernel atomic 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) 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. #include <asm/spr-regs.h>
  15. .text
  16. .balign 4
  17. ###############################################################################
  18. #
  19. # uint32_t __xchg_32(uint32_t i, uint32_t *v)
  20. #
  21. ###############################################################################
  22. .globl __xchg_32
  23. .type __xchg_32,@function
  24. __xchg_32:
  25. or.p gr8,gr8,gr10
  26. 0:
  27. orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
  28. ckeq icc3,cc7
  29. ld.p @(gr9,gr0),gr8 /* LD.P/ORCR must be atomic */
  30. orcr cc7,cc7,cc3 /* set CC3 to true */
  31. cst.p gr10,@(gr9,gr0) ,cc3,#1
  32. corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
  33. beq icc3,#0,0b
  34. bralr
  35. .size __xchg_32, .-__xchg_32
  36. ###############################################################################
  37. #
  38. # uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new)
  39. #
  40. ###############################################################################
  41. .globl __cmpxchg_32
  42. .type __cmpxchg_32,@function
  43. __cmpxchg_32:
  44. or.p gr8,gr8,gr11
  45. 0:
  46. orcc gr0,gr0,gr0,icc3
  47. ckeq icc3,cc7
  48. ld.p @(gr11,gr0),gr8
  49. orcr cc7,cc7,cc3
  50. subcc gr8,gr9,gr7,icc0
  51. bnelr icc0,#0
  52. cst.p gr10,@(gr11,gr0) ,cc3,#1
  53. corcc gr29,gr29,gr0 ,cc3,#1
  54. beq icc3,#0,0b
  55. bralr
  56. .size __cmpxchg_32, .-__cmpxchg_32