switch_cpu64.S 1.2 KB

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