helpers.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .align 32
  2. .globl __flushw_user
  3. .type __flushw_user,#function
  4. __flushw_user:
  5. rdpr %otherwin, %g1
  6. brz,pn %g1, 2f
  7. clr %g2
  8. 1: save %sp, -128, %sp
  9. rdpr %otherwin, %g1
  10. brnz,pt %g1, 1b
  11. add %g2, 1, %g2
  12. 1: sub %g2, 1, %g2
  13. brnz,pt %g2, 1b
  14. restore %g0, %g0, %g0
  15. 2: retl
  16. nop
  17. .size __flushw_user,.-__flushw_user
  18. /* Flush %fp and %i7 to the stack for all register
  19. * windows active inside of the cpu. This allows
  20. * show_stack_trace() to avoid using an expensive
  21. * 'flushw'.
  22. */
  23. .globl stack_trace_flush
  24. .type stack_trace_flush,#function
  25. stack_trace_flush:
  26. rdpr %pstate, %o0
  27. wrpr %o0, PSTATE_IE, %pstate
  28. rdpr %cwp, %g1
  29. rdpr %canrestore, %g2
  30. sub %g1, 1, %g3
  31. 1: brz,pn %g2, 2f
  32. sub %g2, 1, %g2
  33. wrpr %g3, %cwp
  34. stx %fp, [%sp + STACK_BIAS + RW_V9_I6]
  35. stx %i7, [%sp + STACK_BIAS + RW_V9_I7]
  36. ba,pt %xcc, 1b
  37. sub %g3, 1, %g3
  38. 2: wrpr %g1, %cwp
  39. wrpr %o0, %pstate
  40. retl
  41. nop
  42. .size stack_trace_flush,.-stack_trace_flush
  43. #ifdef CONFIG_PERF_EVENTS
  44. .globl perf_arch_fetch_caller_regs
  45. .type perf_arch_fetch_caller_regs,#function
  46. perf_arch_fetch_caller_regs:
  47. /* We always read the %pstate into %o5 since we will use
  48. * that to construct a fake %tstate to store into the regs.
  49. */
  50. rdpr %pstate, %o5
  51. brz,pn %o2, 50f
  52. mov %o2, %g7
  53. /* Turn off interrupts while we walk around the register
  54. * window by hand.
  55. */
  56. wrpr %o5, PSTATE_IE, %pstate
  57. /* The %canrestore tells us how many register windows are
  58. * still live in the chip above us, past that we have to
  59. * walk the frame as saved on the stack. We stash away
  60. * the %cwp in %g1 so we can return back to the original
  61. * register window.
  62. */
  63. rdpr %cwp, %g1
  64. rdpr %canrestore, %g2
  65. sub %g1, 1, %g3
  66. /* We have the skip count in %g7, if it hits zero then
  67. * %fp/%i7 are the registers we need. Otherwise if our
  68. * %canrestore count maintained in %g2 hits zero we have
  69. * to start traversing the stack.
  70. */
  71. 10: brz,pn %g2, 4f
  72. sub %g2, 1, %g2
  73. wrpr %g3, %cwp
  74. subcc %g7, 1, %g7
  75. bne,pt %xcc, 10b
  76. sub %g3, 1, %g3
  77. /* We found the values we need in the cpu's register
  78. * windows.
  79. */
  80. mov %fp, %g3
  81. ba,pt %xcc, 3f
  82. mov %i7, %g2
  83. 50: mov %fp, %g3
  84. ba,pt %xcc, 2f
  85. mov %i7, %g2
  86. /* We hit the end of the valid register windows in the
  87. * cpu, start traversing the stack frame.
  88. */
  89. 4: mov %fp, %g3
  90. 20: ldx [%g3 + STACK_BIAS + RW_V9_I7], %g2
  91. subcc %g7, 1, %g7
  92. bne,pn %xcc, 20b
  93. ldx [%g3 + STACK_BIAS + RW_V9_I6], %g3
  94. /* Restore the current register window position and
  95. * re-enable interrupts.
  96. */
  97. 3: wrpr %g1, %cwp
  98. wrpr %o5, %pstate
  99. 2: stx %g3, [%o0 + PT_V9_FP]
  100. sllx %o5, 8, %o5
  101. stx %o5, [%o0 + PT_V9_TSTATE]
  102. stx %g2, [%o0 + PT_V9_TPC]
  103. add %g2, 4, %g2
  104. retl
  105. stx %g2, [%o0 + PT_V9_TNPC]
  106. .size perf_arch_fetch_caller_regs,.-perf_arch_fetch_caller_regs
  107. #endif /* CONFIG_PERF_EVENTS */
  108. #ifdef CONFIG_SMP
  109. .globl hard_smp_processor_id
  110. .type hard_smp_processor_id,#function
  111. hard_smp_processor_id:
  112. #endif
  113. .globl real_hard_smp_processor_id
  114. .type real_hard_smp_processor_id,#function
  115. real_hard_smp_processor_id:
  116. __GET_CPUID(%o0)
  117. retl
  118. nop
  119. #ifdef CONFIG_SMP
  120. .size hard_smp_processor_id,.-hard_smp_processor_id
  121. #endif
  122. .size real_hard_smp_processor_id,.-real_hard_smp_processor_id