bitops.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* $Id: bitops.S,v 1.3 2001/11/18 00:12:56 davem Exp $
  2.  * bitops.S: Sparc64 atomic bit operations.
  3.  *
  4.  * Copyright (C) 2000 David S. Miller (davem@redhat.com)
  5.  */
  6. #include <asm/asi.h>
  7. .text
  8. .align 64
  9. .globl __bitops_begin
  10. __bitops_begin:
  11. .globl ___test_and_set_bit
  12. ___test_and_set_bit: /* %o0=nr, %o1=addr */
  13. srlx %o0, 6, %g1
  14. mov 1, %g5
  15. sllx %g1, 3, %g3
  16. and %o0, 63, %g2
  17. sllx %g5, %g2, %g5
  18. add %o1, %g3, %o1
  19. ldx [%o1], %g7
  20. 1: andcc %g7, %g5, %o0
  21. bne,pn %xcc, 2f
  22.  xor %g7, %g5, %g1
  23. casx [%o1], %g7, %g1
  24. cmp %g7, %g1
  25. bne,a,pn %xcc, 1b
  26.  ldx [%o1], %g7
  27. 2: retl
  28.  membar #StoreLoad | #StoreStore
  29. .globl ___test_and_clear_bit
  30. ___test_and_clear_bit: /* %o0=nr, %o1=addr */
  31. srlx %o0, 6, %g1
  32. mov 1, %g5
  33. sllx %g1, 3, %g3
  34. and %o0, 63, %g2
  35. sllx %g5, %g2, %g5
  36. add %o1, %g3, %o1
  37. ldx [%o1], %g7
  38. 1: andcc %g7, %g5, %o0
  39. be,pn %xcc, 2f
  40.  xor %g7, %g5, %g1
  41. casx [%o1], %g7, %g1
  42. cmp %g7, %g1
  43. bne,a,pn %xcc, 1b
  44.  ldx [%o1], %g7
  45. 2: retl
  46.  membar #StoreLoad | #StoreStore
  47. .globl ___test_and_change_bit
  48. ___test_and_change_bit: /* %o0=nr, %o1=addr */
  49. srlx %o0, 6, %g1
  50. mov 1, %g5
  51. sllx %g1, 3, %g3
  52. and %o0, 63, %g2
  53. sllx %g5, %g2, %g5
  54. add %o1, %g3, %o1
  55. ldx [%o1], %g7
  56. 1: and %g7, %g5, %o0
  57. xor %g7, %g5, %g1
  58. casx [%o1], %g7, %g1
  59. cmp %g7, %g1
  60. bne,a,pn %xcc, 1b
  61.  ldx [%o1], %g7
  62. 2: retl
  63.  membar #StoreLoad | #StoreStore
  64. nop
  65. .globl ___test_and_set_le_bit
  66. ___test_and_set_le_bit: /* %o0=nr, %o1=addr */
  67. srlx %o0, 5, %g1
  68. mov 1, %g5
  69. sllx %g1, 2, %g3
  70. and %o0, 31, %g2
  71. sllx %g5, %g2, %g5
  72. add %o1, %g3, %o1
  73. lduwa [%o1] ASI_PL, %g7
  74. 1: andcc %g7, %g5, %o0
  75. bne,pn %icc, 2f
  76.  xor %g7, %g5, %g1
  77. casa [%o1] ASI_PL, %g7, %g1
  78. cmp %g7, %g1
  79. bne,a,pn %icc, 1b
  80.  lduwa [%o1] ASI_PL, %g7
  81. 2: retl
  82.  membar #StoreLoad | #StoreStore
  83. .globl ___test_and_clear_le_bit
  84. ___test_and_clear_le_bit: /* %o0=nr, %o1=addr */
  85. srlx %o0, 5, %g1
  86. mov 1, %g5
  87. sllx %g1, 2, %g3
  88. and %o0, 31, %g2
  89. sllx %g5, %g2, %g5
  90. add %o1, %g3, %o1
  91. lduwa [%o1] ASI_PL, %g7
  92. 1: andcc %g7, %g5, %o0
  93. be,pn %icc, 2f
  94.  xor %g7, %g5, %g1
  95. casa [%o1] ASI_PL, %g7, %g1
  96. cmp %g7, %g1
  97. bne,a,pn %icc, 1b
  98.  lduwa [%o1] ASI_PL, %g7
  99. 2: retl
  100.  membar #StoreLoad | #StoreStore
  101. .globl __bitops_end
  102. __bitops_end: