vsx_asm.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2015, Cyril Bur, IBM Corp.
  4. */
  5. #include "basic_asm.h"
  6. #include "vsx_asm.h"
  7. #long check_vsx(vector int *r3);
  8. #This function wraps storeing VSX regs to the end of an array and a
  9. #call to a comparison function in C which boils down to a memcmp()
  10. FUNC_START(check_vsx)
  11. PUSH_BASIC_STACK(32)
  12. std r3,STACK_FRAME_PARAM(0)(sp)
  13. addi r3, r3, 16 * 12 #Second half of array
  14. bl store_vsx
  15. ld r3,STACK_FRAME_PARAM(0)(sp)
  16. bl vsx_memcmp
  17. POP_BASIC_STACK(32)
  18. blr
  19. FUNC_END(check_vsx)
  20. # int preempt_vmx(vector int *varray, int *threads_starting,
  21. # int *running);
  22. # On starting will (atomically) decrement threads_starting as a signal
  23. # that the VMX have been loaded with varray. Will proceed to check the
  24. # validity of the VMX registers while running is not zero.
  25. FUNC_START(preempt_vsx)
  26. PUSH_BASIC_STACK(512)
  27. std r3,STACK_FRAME_PARAM(0)(sp) # vector int *varray
  28. std r4,STACK_FRAME_PARAM(1)(sp) # int *threads_starting
  29. std r5,STACK_FRAME_PARAM(2)(sp) # int *running
  30. bl load_vsx
  31. nop
  32. sync
  33. # Atomic DEC
  34. ld r3,STACK_FRAME_PARAM(1)(sp)
  35. 1: lwarx r4,0,r3
  36. addi r4,r4,-1
  37. stwcx. r4,0,r3
  38. bne- 1b
  39. 2: ld r3,STACK_FRAME_PARAM(0)(sp)
  40. bl check_vsx
  41. nop
  42. cmpdi r3,0
  43. bne 3f
  44. ld r4,STACK_FRAME_PARAM(2)(sp)
  45. ld r5,0(r4)
  46. cmpwi r5,0
  47. bne 2b
  48. 3: POP_BASIC_STACK(512)
  49. blr
  50. FUNC_END(preempt_vsx)