010-Add-PowerPC-soft-float-support.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. From: Felix Fietkau <nbd@openwrt.org>
  2. Date: Wed, 8 Jul 2015 13:56:37 +0200
  3. Subject: [PATCH] Add PowerPC soft-float support
  4. Some PowerPC CPUs (e.g. Freescale MPC85xx) have a completely different
  5. instruction set for floating point operations (SPE).
  6. Executing regular PowerPC floating point instructions results in
  7. "Illegal instruction" errors.
  8. Make it possible to run these devices in soft-float mode.
  9. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  10. ---
  11. create mode 100644 src/fenv/powerpc-sf/fenv.sub
  12. create mode 100644 src/setjmp/powerpc-sf/longjmp.s
  13. create mode 100644 src/setjmp/powerpc-sf/longjmp.sub
  14. create mode 100644 src/setjmp/powerpc-sf/setjmp.s
  15. create mode 100644 src/setjmp/powerpc-sf/setjmp.sub
  16. --- a/arch/powerpc/reloc.h
  17. +++ b/arch/powerpc/reloc.h
  18. @@ -1,4 +1,10 @@
  19. -#define LDSO_ARCH "powerpc"
  20. +#ifdef _SOFT_FLOAT
  21. +#define FP_SUFFIX "-sf"
  22. +#else
  23. +#define FP_SUFFIX ""
  24. +#endif
  25. +
  26. +#define LDSO_ARCH "powerpc" FP_SUFFIX
  27. #define TPOFF_K (-0x7000)
  28. --- a/configure
  29. +++ b/configure
  30. @@ -522,6 +522,10 @@ trycppif "_MIPSEL || __MIPSEL || __MIPSE
  31. trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf
  32. fi
  33. +if test "$ARCH" = "powerpc" ; then
  34. +trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf
  35. +fi
  36. +
  37. test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \
  38. && SUBARCH=${SUBARCH}el
  39. --- /dev/null
  40. +++ b/src/fenv/powerpc-sf/fenv.sub
  41. @@ -0,0 +1 @@
  42. +../fenv.c
  43. --- /dev/null
  44. +++ b/src/setjmp/powerpc-sf/longjmp.s
  45. @@ -0,0 +1,47 @@
  46. + .global _longjmp
  47. + .global longjmp
  48. + .type _longjmp,@function
  49. + .type longjmp,@function
  50. +_longjmp:
  51. +longjmp:
  52. +# void longjmp(jmp_buf env, int val);
  53. +# put val into return register and restore the env saved in setjmp
  54. +# if val(r4) is 0, put 1 there.
  55. + # 0) move old return address into r0
  56. + lwz 0, 0(3)
  57. + # 1) put it into link reg
  58. + mtlr 0
  59. + #2 ) restore stack ptr
  60. + lwz 1, 4(3)
  61. + #3) restore control reg
  62. + lwz 0, 8(3)
  63. + mtcr 0
  64. + #4) restore r14-r31
  65. + lwz 14, 12(3)
  66. + lwz 15, 16(3)
  67. + lwz 16, 20(3)
  68. + lwz 17, 24(3)
  69. + lwz 18, 28(3)
  70. + lwz 19, 32(3)
  71. + lwz 20, 36(3)
  72. + lwz 21, 40(3)
  73. + lwz 22, 44(3)
  74. + lwz 23, 48(3)
  75. + lwz 24, 52(3)
  76. + lwz 25, 56(3)
  77. + lwz 26, 60(3)
  78. + lwz 27, 64(3)
  79. + lwz 28, 68(3)
  80. + lwz 29, 72(3)
  81. + lwz 30, 76(3)
  82. + lwz 31, 80(3)
  83. + #5) put val into return reg r3
  84. + mr 3, 4
  85. +
  86. + #6) check if return value is 0, make it 1 in that case
  87. + cmpwi cr7, 4, 0
  88. + bne cr7, 1f
  89. + li 3, 1
  90. +1:
  91. + blr
  92. +
  93. --- /dev/null
  94. +++ b/src/setjmp/powerpc-sf/longjmp.sub
  95. @@ -0,0 +1 @@
  96. +longjmp.s
  97. --- /dev/null
  98. +++ b/src/setjmp/powerpc-sf/setjmp.s
  99. @@ -0,0 +1,43 @@
  100. + .global ___setjmp
  101. + .hidden ___setjmp
  102. + .global __setjmp
  103. + .global _setjmp
  104. + .global setjmp
  105. + .type __setjmp,@function
  106. + .type _setjmp,@function
  107. + .type setjmp,@function
  108. +___setjmp:
  109. +__setjmp:
  110. +_setjmp:
  111. +setjmp:
  112. + # 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg)
  113. + mflr 0
  114. + stw 0, 0(3)
  115. + # 1) store reg1 (SP)
  116. + stw 1, 4(3)
  117. + # 2) store cr
  118. + mfcr 0
  119. + stw 0, 8(3)
  120. + # 3) store r14-31
  121. + stw 14, 12(3)
  122. + stw 15, 16(3)
  123. + stw 16, 20(3)
  124. + stw 17, 24(3)
  125. + stw 18, 28(3)
  126. + stw 19, 32(3)
  127. + stw 20, 36(3)
  128. + stw 21, 40(3)
  129. + stw 22, 44(3)
  130. + stw 23, 48(3)
  131. + stw 24, 52(3)
  132. + stw 25, 56(3)
  133. + stw 26, 60(3)
  134. + stw 27, 64(3)
  135. + stw 28, 68(3)
  136. + stw 29, 72(3)
  137. + stw 30, 76(3)
  138. + stw 31, 80(3)
  139. + # 4) set return value to 0
  140. + li 3, 0
  141. + # 5) return
  142. + blr
  143. --- /dev/null
  144. +++ b/src/setjmp/powerpc-sf/setjmp.sub
  145. @@ -0,0 +1 @@
  146. +setjmp.s