locks.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * locks.S: SMP low-level lock primitives on Sparc.
  3. *
  4. * Copyright (C) 1996 David S. Miller ([email protected])
  5. * Copyright (C) 1998 Anton Blanchard ([email protected])
  6. * Copyright (C) 1998 Jakub Jelinek ([email protected])
  7. */
  8. #include <asm/ptrace.h>
  9. #include <asm/psr.h>
  10. #include <asm/smp.h>
  11. #include <asm/spinlock.h>
  12. #include <asm/export.h>
  13. .text
  14. .align 4
  15. /* Read/writer locks, as usual this is overly clever to make it
  16. * as fast as possible.
  17. */
  18. /* caches... */
  19. ___rw_read_enter_spin_on_wlock:
  20. orcc %g2, 0x0, %g0
  21. be,a ___rw_read_enter
  22. ldstub [%g1 + 3], %g2
  23. b ___rw_read_enter_spin_on_wlock
  24. ldub [%g1 + 3], %g2
  25. ___rw_read_try_spin_on_wlock:
  26. andcc %g2, 0xff, %g0
  27. be,a ___rw_read_try
  28. ldstub [%g1 + 3], %g2
  29. xnorcc %g2, 0x0, %o0 /* if g2 is ~0, set o0 to 0 and bugger off */
  30. bne,a ___rw_read_enter_spin_on_wlock
  31. ld [%g1], %g2
  32. retl
  33. mov %g4, %o7
  34. ___rw_read_exit_spin_on_wlock:
  35. orcc %g2, 0x0, %g0
  36. be,a ___rw_read_exit
  37. ldstub [%g1 + 3], %g2
  38. b ___rw_read_exit_spin_on_wlock
  39. ldub [%g1 + 3], %g2
  40. ___rw_write_enter_spin_on_wlock:
  41. orcc %g2, 0x0, %g0
  42. be,a ___rw_write_enter
  43. ldstub [%g1 + 3], %g2
  44. b ___rw_write_enter_spin_on_wlock
  45. ld [%g1], %g2
  46. .globl ___rw_read_enter
  47. EXPORT_SYMBOL(___rw_read_enter)
  48. ___rw_read_enter:
  49. orcc %g2, 0x0, %g0
  50. bne,a ___rw_read_enter_spin_on_wlock
  51. ldub [%g1 + 3], %g2
  52. ld [%g1], %g2
  53. add %g2, 1, %g2
  54. st %g2, [%g1]
  55. retl
  56. mov %g4, %o7
  57. .globl ___rw_read_exit
  58. EXPORT_SYMBOL(___rw_read_exit)
  59. ___rw_read_exit:
  60. orcc %g2, 0x0, %g0
  61. bne,a ___rw_read_exit_spin_on_wlock
  62. ldub [%g1 + 3], %g2
  63. ld [%g1], %g2
  64. sub %g2, 0x1ff, %g2
  65. st %g2, [%g1]
  66. retl
  67. mov %g4, %o7
  68. .globl ___rw_read_try
  69. EXPORT_SYMBOL(___rw_read_try)
  70. ___rw_read_try:
  71. orcc %g2, 0x0, %g0
  72. bne ___rw_read_try_spin_on_wlock
  73. ld [%g1], %g2
  74. add %g2, 1, %g2
  75. st %g2, [%g1]
  76. set 1, %o1
  77. retl
  78. mov %g4, %o7
  79. .globl ___rw_write_enter
  80. EXPORT_SYMBOL(___rw_write_enter)
  81. ___rw_write_enter:
  82. orcc %g2, 0x0, %g0
  83. bne ___rw_write_enter_spin_on_wlock
  84. ld [%g1], %g2
  85. andncc %g2, 0xff, %g0
  86. bne,a ___rw_write_enter_spin_on_wlock
  87. stb %g0, [%g1 + 3]
  88. retl
  89. mov %g4, %o7