switch_cpu.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * 31-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. stm %r6,%r15,__SF_GPRS(%r15)
  20. lr %r1,%r15
  21. ahi %r15,-STACK_FRAME_OVERHEAD
  22. st %r1,__SF_BACKCHAIN(%r15)
  23. basr %r13,0
  24. 0: la %r1,.gprregs_addr-0b(%r13)
  25. l %r1,0(%r1)
  26. stm %r0,%r15,0(%r1)
  27. 1: sigp %r0,%r6,__SIGP_RESTART /* start destination CPU */
  28. brc 2,1b /* busy, try again */
  29. 2: sigp %r0,%r5,__SIGP_STOP /* stop current CPU */
  30. brc 2,2b /* busy, try again */
  31. 3: j 3b
  32. .globl smp_restart_cpu
  33. smp_restart_cpu:
  34. basr %r13,0
  35. 0: la %r1,.gprregs_addr-0b(%r13)
  36. l %r1,0(%r1)
  37. lm %r0,%r15,0(%r1)
  38. 1: sigp %r0,%r5,__SIGP_SENSE /* Wait for calling CPU */
  39. brc 10,1b /* busy, accepted (status 0), running */
  40. tmll %r0,0x40 /* Test if calling CPU is stopped */
  41. jz 1b
  42. ltr %r4,%r4 /* New stack ? */
  43. jz 1f
  44. lr %r15,%r4
  45. 1: lr %r14,%r2 /* r14: Function to call */
  46. lr %r2,%r3 /* r2 : Parameter for function*/
  47. basr %r14,%r14 /* Call function */
  48. .gprregs_addr:
  49. .long .gprregs
  50. .section .data,"aw",@progbits
  51. .gprregs:
  52. .rept 16
  53. .long 0
  54. .endr