misc.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * This file contains miscellaneous low-level functions.
  4. * Copyright (C) 1995-1996 Gary Thomas ([email protected])
  5. *
  6. * Largely rewritten by Cort Dougan ([email protected])
  7. * and Paul Mackerras.
  8. *
  9. * PPC64 updates by Dave Engebretsen ([email protected])
  10. *
  11. * setjmp/longjmp code by Paul Mackerras.
  12. */
  13. #include <asm/ppc_asm.h>
  14. #include <asm/unistd.h>
  15. #include <asm/asm-compat.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/export.h>
  18. .text
  19. /*
  20. * Returns (address we are running at) - (address we were linked at)
  21. * for use before the text and data are mapped to KERNELBASE.
  22. * add_reloc_offset(x) returns x + reloc_offset().
  23. */
  24. _GLOBAL(reloc_offset)
  25. li r3, 0
  26. _GLOBAL(add_reloc_offset)
  27. mflr r0
  28. bcl 20,31,$+4
  29. 1: mflr r5
  30. PPC_LL r4,(2f-1b)(r5)
  31. subf r5,r4,r5
  32. add r3,r3,r5
  33. mtlr r0
  34. blr
  35. _ASM_NOKPROBE_SYMBOL(reloc_offset)
  36. _ASM_NOKPROBE_SYMBOL(add_reloc_offset)
  37. .align 3
  38. 2: PPC_LONG 1b
  39. _GLOBAL(setjmp)
  40. mflr r0
  41. PPC_STL r0,0(r3)
  42. PPC_STL r1,SZL(r3)
  43. PPC_STL r2,2*SZL(r3)
  44. #ifdef CONFIG_PPC32
  45. mfcr r12
  46. stmw r12, 3*SZL(r3)
  47. #else
  48. mfcr r0
  49. PPC_STL r0,3*SZL(r3)
  50. PPC_STL r13,4*SZL(r3)
  51. PPC_STL r14,5*SZL(r3)
  52. PPC_STL r15,6*SZL(r3)
  53. PPC_STL r16,7*SZL(r3)
  54. PPC_STL r17,8*SZL(r3)
  55. PPC_STL r18,9*SZL(r3)
  56. PPC_STL r19,10*SZL(r3)
  57. PPC_STL r20,11*SZL(r3)
  58. PPC_STL r21,12*SZL(r3)
  59. PPC_STL r22,13*SZL(r3)
  60. PPC_STL r23,14*SZL(r3)
  61. PPC_STL r24,15*SZL(r3)
  62. PPC_STL r25,16*SZL(r3)
  63. PPC_STL r26,17*SZL(r3)
  64. PPC_STL r27,18*SZL(r3)
  65. PPC_STL r28,19*SZL(r3)
  66. PPC_STL r29,20*SZL(r3)
  67. PPC_STL r30,21*SZL(r3)
  68. PPC_STL r31,22*SZL(r3)
  69. #endif
  70. li r3,0
  71. blr
  72. _GLOBAL(longjmp)
  73. #ifdef CONFIG_PPC32
  74. lmw r12, 3*SZL(r3)
  75. mtcrf 0x38, r12
  76. #else
  77. PPC_LL r13,4*SZL(r3)
  78. PPC_LL r14,5*SZL(r3)
  79. PPC_LL r15,6*SZL(r3)
  80. PPC_LL r16,7*SZL(r3)
  81. PPC_LL r17,8*SZL(r3)
  82. PPC_LL r18,9*SZL(r3)
  83. PPC_LL r19,10*SZL(r3)
  84. PPC_LL r20,11*SZL(r3)
  85. PPC_LL r21,12*SZL(r3)
  86. PPC_LL r22,13*SZL(r3)
  87. PPC_LL r23,14*SZL(r3)
  88. PPC_LL r24,15*SZL(r3)
  89. PPC_LL r25,16*SZL(r3)
  90. PPC_LL r26,17*SZL(r3)
  91. PPC_LL r27,18*SZL(r3)
  92. PPC_LL r28,19*SZL(r3)
  93. PPC_LL r29,20*SZL(r3)
  94. PPC_LL r30,21*SZL(r3)
  95. PPC_LL r31,22*SZL(r3)
  96. PPC_LL r0,3*SZL(r3)
  97. mtcrf 0x38,r0
  98. #endif
  99. PPC_LL r0,0(r3)
  100. PPC_LL r1,SZL(r3)
  101. PPC_LL r2,2*SZL(r3)
  102. mtlr r0
  103. mr. r3, r4
  104. bnelr
  105. li r3, 1
  106. blr
  107. _GLOBAL(current_stack_frame)
  108. PPC_LL r3,0(r1)
  109. blr
  110. EXPORT_SYMBOL(current_stack_frame)