vsx_asm.S 1.5 KB

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