locks.S 2.1 KB

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