switch_cpu64.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * 64-bit switch cpu code
  3. *
  4. * Copyright IBM Corp. 2009
  5. *
  6. */
  7. #include <asm/asm-offsets.h>
  8. #include <asm/ptrace.h>
  9. # smp_switch_to_cpu switches to destination cpu and executes the passed function
  10. # Parameter: %r2 - function to call
  11. # %r3 - function parameter
  12. # %r4 - stack poiner
  13. # %r5 - current cpu
  14. # %r6 - destination cpu
  15. .section .text
  16. .align 4
  17. .globl smp_switch_to_cpu
  18. smp_switch_to_cpu:
  19. stmg %r6,%r15,__SF_GPRS(%r15)
  20. lgr %r1,%r15
  21. aghi %r15,-STACK_FRAME_OVERHEAD
  22. stg %r1,__SF_BACKCHAIN(%r15)
  23. larl %r1,.gprregs
  24. stmg %r0,%r15,0(%r1)
  25. 1: sigp %r0,%r6,__SIGP_RESTART /* start destination CPU */
  26. brc 2,1b /* busy, try again */
  27. 2: sigp %r0,%r5,__SIGP_STOP /* stop current CPU */
  28. brc 2,2b /* busy, try again */
  29. 3: j 3b
  30. .globl smp_restart_cpu
  31. smp_restart_cpu:
  32. larl %r1,.gprregs
  33. lmg %r0,%r15,0(%r1)
  34. 1: sigp %r0,%r5,__SIGP_SENSE /* Wait for calling CPU */
  35. brc 10,1b /* busy, accepted (status 0), running */
  36. tmll %r0,0x40 /* Test if calling CPU is stopped */
  37. jz 1b
  38. ltgr %r4,%r4 /* New stack ? */
  39. jz 1f
  40. lgr %r15,%r4
  41. 1: lgr %r14,%r2 /* r14: Function to call */
  42. lgr %r2,%r3 /* r2 : Parameter for function*/
  43. basr %r14,%r14 /* Call function */
  44. .section .data,"aw",@progbits
  45. .gprregs:
  46. .rept 16
  47. .quad 0
  48. .endr