misc.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #ifdef CONFIG_PPC64
  19. #define IN_SYNC twi 0,r5,0; isync
  20. #define EIEIO_32
  21. #define SYNC_64 sync
  22. #else /* CONFIG_PPC32 */
  23. #define IN_SYNC
  24. #define EIEIO_32 eieio
  25. #define SYNC_64
  26. #endif
  27. /*
  28. * Returns (address we are running at) - (address we were linked at)
  29. * for use before the text and data are mapped to KERNELBASE.
  30. */
  31. _GLOBAL(reloc_offset)
  32. mflr r0
  33. bl 1f
  34. 1: mflr r3
  35. LOAD_REG_IMMEDIATE(r4,1b)
  36. subf r3,r4,r3
  37. mtlr r0
  38. blr
  39. /*
  40. * add_reloc_offset(x) returns x + reloc_offset().
  41. */
  42. _GLOBAL(add_reloc_offset)
  43. mflr r0
  44. bl 1f
  45. 1: mflr r5
  46. LOAD_REG_IMMEDIATE(r4,1b)
  47. subf r5,r4,r5
  48. add r3,r3,r5
  49. mtlr r0
  50. blr
  51. /*
  52. * I/O string operations
  53. *
  54. * insb(port, buf, len)
  55. * outsb(port, buf, len)
  56. * insw(port, buf, len)
  57. * outsw(port, buf, len)
  58. * insl(port, buf, len)
  59. * outsl(port, buf, len)
  60. * insw_ns(port, buf, len)
  61. * outsw_ns(port, buf, len)
  62. * insl_ns(port, buf, len)
  63. * outsl_ns(port, buf, len)
  64. *
  65. * The *_ns versions don't do byte-swapping.
  66. */
  67. _GLOBAL(_insb)
  68. cmpwi 0,r5,0
  69. mtctr r5
  70. subi r4,r4,1
  71. blelr-
  72. 00: lbz r5,0(r3)
  73. eieio
  74. stbu r5,1(r4)
  75. bdnz 00b
  76. IN_SYNC
  77. blr
  78. _GLOBAL(_outsb)
  79. cmpwi 0,r5,0
  80. mtctr r5
  81. subi r4,r4,1
  82. blelr-
  83. 00: lbzu r5,1(r4)
  84. stb r5,0(r3)
  85. EIEIO_32
  86. bdnz 00b
  87. SYNC_64
  88. blr
  89. _GLOBAL(_insw)
  90. cmpwi 0,r5,0
  91. mtctr r5
  92. subi r4,r4,2
  93. blelr-
  94. 00: lhbrx r5,0,r3
  95. eieio
  96. sthu r5,2(r4)
  97. bdnz 00b
  98. IN_SYNC
  99. blr
  100. _GLOBAL(_outsw)
  101. cmpwi 0,r5,0
  102. mtctr r5
  103. subi r4,r4,2
  104. blelr-
  105. 00: lhzu r5,2(r4)
  106. EIEIO_32
  107. sthbrx r5,0,r3
  108. bdnz 00b
  109. SYNC_64
  110. blr
  111. _GLOBAL(_insl)
  112. cmpwi 0,r5,0
  113. mtctr r5
  114. subi r4,r4,4
  115. blelr-
  116. 00: lwbrx r5,0,r3
  117. eieio
  118. stwu r5,4(r4)
  119. bdnz 00b
  120. IN_SYNC
  121. blr
  122. _GLOBAL(_outsl)
  123. cmpwi 0,r5,0
  124. mtctr r5
  125. subi r4,r4,4
  126. blelr-
  127. 00: lwzu r5,4(r4)
  128. stwbrx r5,0,r3
  129. EIEIO_32
  130. bdnz 00b
  131. SYNC_64
  132. blr
  133. #ifdef CONFIG_PPC32
  134. _GLOBAL(__ide_mm_insw)
  135. #endif
  136. _GLOBAL(_insw_ns)
  137. cmpwi 0,r5,0
  138. mtctr r5
  139. subi r4,r4,2
  140. blelr-
  141. 00: lhz r5,0(r3)
  142. eieio
  143. sthu r5,2(r4)
  144. bdnz 00b
  145. IN_SYNC
  146. blr
  147. #ifdef CONFIG_PPC32
  148. _GLOBAL(__ide_mm_outsw)
  149. #endif
  150. _GLOBAL(_outsw_ns)
  151. cmpwi 0,r5,0
  152. mtctr r5
  153. subi r4,r4,2
  154. blelr-
  155. 00: lhzu r5,2(r4)
  156. sth r5,0(r3)
  157. EIEIO_32
  158. bdnz 00b
  159. SYNC_64
  160. blr
  161. #ifdef CONFIG_PPC32
  162. _GLOBAL(__ide_mm_insl)
  163. #endif
  164. _GLOBAL(_insl_ns)
  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. IN_SYNC
  174. blr
  175. #ifdef CONFIG_PPC32
  176. _GLOBAL(__ide_mm_outsl)
  177. #endif
  178. _GLOBAL(_outsl_ns)
  179. cmpwi 0,r5,0
  180. mtctr r5
  181. subi r4,r4,4
  182. blelr-
  183. 00: lwzu r5,4(r4)
  184. stw r5,0(r3)
  185. EIEIO_32
  186. bdnz 00b
  187. SYNC_64
  188. blr