misc.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * This file contains miscellaneous low-level functions.
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. *
  5. * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
  6. * and Paul Mackerras.
  7. *
  8. * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
  9. * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. #include <asm/ppc_asm.h>
  17. .text
  18. /*
  19. * Returns (address we are running at) - (address we were linked at)
  20. * for use before the text and data are mapped to KERNELBASE.
  21. */
  22. _GLOBAL(reloc_offset)
  23. mflr r0
  24. bl 1f
  25. 1: mflr r3
  26. LOAD_REG_IMMEDIATE(r4,1b)
  27. subf r3,r4,r3
  28. mtlr r0
  29. blr
  30. /*
  31. * add_reloc_offset(x) returns x + reloc_offset().
  32. */
  33. _GLOBAL(add_reloc_offset)
  34. mflr r0
  35. bl 1f
  36. 1: mflr r5
  37. LOAD_REG_IMMEDIATE(r4,1b)
  38. subf r5,r4,r5
  39. add r3,r3,r5
  40. mtlr r0
  41. blr
  42. /*
  43. * I/O string operations
  44. *
  45. * insb(port, buf, len)
  46. * outsb(port, buf, len)
  47. * insw(port, buf, len)
  48. * outsw(port, buf, len)
  49. * insl(port, buf, len)
  50. * outsl(port, buf, len)
  51. * insw_ns(port, buf, len)
  52. * outsw_ns(port, buf, len)
  53. * insl_ns(port, buf, len)
  54. * outsl_ns(port, buf, len)
  55. *
  56. * The *_ns versions don't do byte-swapping.
  57. */
  58. _GLOBAL(_insb)
  59. sync
  60. cmpwi 0,r5,0
  61. mtctr r5
  62. subi r4,r4,1
  63. blelr-
  64. 00: lbz r5,0(r3)
  65. eieio
  66. stbu r5,1(r4)
  67. bdnz 00b
  68. twi 0,r5,0
  69. isync
  70. blr
  71. _GLOBAL(_outsb)
  72. cmpwi 0,r5,0
  73. mtctr r5
  74. subi r4,r4,1
  75. blelr-
  76. sync
  77. 00: lbzu r5,1(r4)
  78. stb r5,0(r3)
  79. bdnz 00b
  80. sync
  81. blr
  82. _GLOBAL(_insw)
  83. sync
  84. cmpwi 0,r5,0
  85. mtctr r5
  86. subi r4,r4,2
  87. blelr-
  88. 00: lhbrx r5,0,r3
  89. eieio
  90. sthu r5,2(r4)
  91. bdnz 00b
  92. twi 0,r5,0
  93. isync
  94. blr
  95. _GLOBAL(_outsw)
  96. cmpwi 0,r5,0
  97. mtctr r5
  98. subi r4,r4,2
  99. blelr-
  100. sync
  101. 00: lhzu r5,2(r4)
  102. sthbrx r5,0,r3
  103. bdnz 00b
  104. sync
  105. blr
  106. _GLOBAL(_insl)
  107. sync
  108. cmpwi 0,r5,0
  109. mtctr r5
  110. subi r4,r4,4
  111. blelr-
  112. 00: lwbrx r5,0,r3
  113. eieio
  114. stwu r5,4(r4)
  115. bdnz 00b
  116. twi 0,r5,0
  117. isync
  118. blr
  119. _GLOBAL(_outsl)
  120. cmpwi 0,r5,0
  121. mtctr r5
  122. subi r4,r4,4
  123. blelr-
  124. sync
  125. 00: lwzu r5,4(r4)
  126. stwbrx r5,0,r3
  127. bdnz 00b
  128. sync
  129. blr
  130. #ifdef CONFIG_PPC32
  131. _GLOBAL(__ide_mm_insw)
  132. #endif
  133. _GLOBAL(_insw_ns)
  134. sync
  135. cmpwi 0,r5,0
  136. mtctr r5
  137. subi r4,r4,2
  138. blelr-
  139. 00: lhz r5,0(r3)
  140. eieio
  141. sthu r5,2(r4)
  142. bdnz 00b
  143. twi 0,r5,0
  144. isync
  145. blr
  146. #ifdef CONFIG_PPC32
  147. _GLOBAL(__ide_mm_outsw)
  148. #endif
  149. _GLOBAL(_outsw_ns)
  150. cmpwi 0,r5,0
  151. mtctr r5
  152. subi r4,r4,2
  153. blelr-
  154. sync
  155. 00: lhzu r5,2(r4)
  156. sth r5,0(r3)
  157. bdnz 00b
  158. sync
  159. blr
  160. #ifdef CONFIG_PPC32
  161. _GLOBAL(__ide_mm_insl)
  162. #endif
  163. _GLOBAL(_insl_ns)
  164. sync
  165. cmpwi 0,r5,0
  166. mtctr r5
  167. subi r4,r4,4
  168. blelr-
  169. 00: lwz r5,0(r3)
  170. eieio
  171. stwu r5,4(r4)
  172. bdnz 00b
  173. twi 0,r5,0
  174. isync
  175. blr
  176. #ifdef CONFIG_PPC32
  177. _GLOBAL(__ide_mm_outsl)
  178. #endif
  179. _GLOBAL(_outsl_ns)
  180. cmpwi 0,r5,0
  181. mtctr r5
  182. subi r4,r4,4
  183. blelr-
  184. sync
  185. 00: lwzu r5,4(r4)
  186. stw r5,0(r3)
  187. bdnz 00b
  188. sync
  189. blr