bcopy.m4 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. define(_rcsid,``$OpenBSD: bcopy.m4,v 1.12 2013/06/14 12:45:18 kettenis Exp $'')dnl
  2. dnl
  3. dnl
  4. dnl This is the source file for bcopy.S, spcopy.S
  5. dnl
  6. dnl
  7. define(`versionmacro',substr(_rcsid,1,eval(len(_rcsid)-2)))dnl
  8. dnl
  9. /* This is a generated file. DO NOT EDIT. */
  10. /*
  11. * Generated from:
  12. *
  13. * versionmacro
  14. */
  15. /*
  16. * Copyright (c) 1999,2004 Michael Shalayeff
  17. * All rights reserved.
  18. *
  19. * Permission to use, copy, modify, and distribute this software for any
  20. * purpose with or without fee is hereby granted, provided that the above
  21. * copyright notice and this permission notice appear in all copies.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  24. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  25. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  26. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
  28. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  29. * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. */
  31. dnl
  32. dnl macro: L(`%arg1',`%arg2')
  33. dnl synopsis: creates an assembly label based on args resulting in $%arg1.%arg2
  34. dnl
  35. define(`L', `$$1.$2')dnl
  36. dnl
  37. dnl
  38. dnl
  39. define(`STWS',`ifelse($5, `u',dnl
  40. `ifelse($1, `22', `shrpw $4, %r`$1', %sar, %r31
  41. stby,B,m %r31, F`'4($2, $3)',
  42. `0', `0', `shrpw %r`'incr($1), %r`$1', %sar, %r31
  43. stw,M %r31, F`'4($2, $3)')',dnl
  44. `0', `0',
  45. `ifelse($1, `22',
  46. `stby,B`'ifelse(B, `b', `,m ', `0', `0', ` ')`'%r`$1', F`'4($2, $3)',
  47. `0', `0', `stw,M %r`$1', F`'4($2, $3)')')')dnl
  48. define(`STWSS', `ifelse(`$3', `22', `dnl',
  49. `0', `0', `STWSS($1, $2, eval($3 + 1), $4, $5)')
  50. STWS($3, $1, $2, $4, $5)dnl
  51. ')dnl
  52. define(`LDWSS', `ifelse(`$3', `22', `dnl',
  53. `0', `0', `LDWSS($1, $2, eval($3 + 1))')
  54. ldw,M F`'4($1, $2), %r`'$3`'dnl
  55. ')dnl
  56. dnl
  57. dnl copy data in 4-words blocks
  58. dnl
  59. define(`hppa_blcopy',`
  60. addi -16, $6, $6
  61. L($1, `loop16'`$7')
  62. ldw F 32($2, $3), %r0
  63. ifelse(F, `-', `dnl
  64. addi F`'4, $5, $5', `0', `0', `dnl')
  65. LDWSS($2, $3, 19)
  66. STWSS($4, $5, 20, `%ret1', $7)
  67. ifelse($7, `u', `dnl
  68. STWS(19, $4, $5, `%ret1', $7)', $7, `a', `dnl')
  69. addib,*>= -16, $6, L($1, `loop16'`$7')
  70. ifelse($7, `a', `dnl
  71. STWS(19, $4, $5, `%ret1', $7)dnl
  72. ', $7, `u', `dnl
  73. copy %r19, %ret1')')dnl
  74. dnl
  75. dnl copy in words
  76. dnl
  77. define(`STWL', `addib,*<,n 12, $6, L($1, cleanup)
  78. ifelse($7, `u', ` copy %ret1, %r22', $7, `a', `dnl')
  79. L($1, word)
  80. ldw,M F`'4($2, $3), %r22
  81. addib,*>= -4, $6, L($1, word)
  82. stw,M %r22, F`'4($4, $5)
  83. L($1, cleanup)
  84. addib,*=,n 4, $6, L($1, done)
  85. ldw 0($2, $3), %r22
  86. add $5, $6, $5
  87. b L($1, done)
  88. stby,E %r22, 0($4, $5)
  89. ')
  90. dnl
  91. dnl
  92. dnl parameters:
  93. dnl $1 name
  94. dnl $2 source space
  95. dnl $3 source address
  96. dnl $4 destination space
  97. dnl $5 destination address
  98. dnl $6 length
  99. dnl $7 direction
  100. dnl
  101. define(hppa_copy,
  102. `dnl
  103. dnl
  104. dnl if direction is `-' (backwards copy), adjust src, dst
  105. dnl
  106. ifelse($7,`-', `add $3, $6, $3
  107. add $5, $6, $5
  108. define(`F', `-')dnl
  109. define(`R', `')dnl
  110. define(`M', `mb')dnl
  111. define(`B', `e')dnl
  112. define(`E', `b')dnl
  113. ',dnl ifelse
  114. `0',`0',
  115. `define(`F', `')dnl
  116. define(`R', `-')dnl
  117. define(`M', `ma')dnl
  118. define(`B', `b')dnl
  119. define(`E', `e')dnl
  120. ')dnl ifelse
  121. ifelse($7,`-', `', `0',`0',
  122. ` cmpib,*>=,n 15, $6, L($1, byte)
  123. extrd,u $3, 63, 2, %r20
  124. extrd,u $5, 63, 2, %r19
  125. add $6, %r19, $6
  126. cmpb,*<> %r20, %r19, L($1, unaligned)
  127. depd %r0, 63, 2, $3
  128. hppa_blcopy($1, $2, $3, $4, $5, $6, `a')
  129. STWL($1, $2, $3, $4, $5, $6, `a')dnl
  130. L($1, unaligned)
  131. sub,*>= %r19, %r20, %r21
  132. ldw,ma F`'4($2, $3), %ret1
  133. depd,z %r21, 60, 61, %r22
  134. mtsar %r22
  135. hppa_blcopy($1, $2, $3, $4, $5, $6, `u')
  136. dnl STWL($1, $2, $3, $4, $5, $6, `u')
  137. addib,*<,n 12, $6, L($1, cleanup_un)
  138. L($1, word_un)
  139. ldw,M F`'4($2, $3), %r22
  140. shrpw %ret1, %r22, %sar, %r21
  141. addib,*< -4, $6, L($1, cleanup1_un)
  142. stw,M %r21, F`'4($4, $5)
  143. ldw,M F`'4($2, $3), %ret1
  144. shrpw %r22, %ret1, %sar, %r21
  145. addib,*>= -4, $6, L($1, word_un)
  146. stw,M %r21, F`'4($4, $5)
  147. L($1, cleanup_un)
  148. addib,*<=,n 4, $6, L($1, done)
  149. mfctl %sar, %r19
  150. add $5, $6, $5
  151. extrd,u %r19, 60, 2, %r19
  152. sub,*<= $6, %r19, %r0
  153. ldw,M F`'4($2, $3), %r22
  154. shrpw %ret1, %r22, %sar, %r21
  155. b L($1, done)
  156. stby,E %r21, 0($4, $5)
  157. L($1, cleanup1_un)
  158. b L($1, cleanup_un)
  159. copy %r22, %ret1
  160. ')dnl ifelse
  161. L($1, byte)
  162. cmpb,*>=,n %r0, $6, L($1, done)
  163. L($1, byte_loop)
  164. ldbs,M F`'1($2, $3), %r22
  165. addib,*<> -1, $6, L($1, byte_loop)
  166. stbs,M %r22, F`'1($4, $5)
  167. L($1, done)
  168. ')dnl
  169. `
  170. #undef _LOCORE
  171. #define _LOCORE
  172. #include <machine/asm.h>
  173. #include <machine/frame.h>
  174. '
  175. ifelse(NAME, `bcopy',
  176. `
  177. LEAF_ENTRY(bcopy)
  178. copy %arg0, %ret0
  179. copy %arg1, %arg0
  180. copy %ret0, %arg1
  181. ALTENTRY(memmove)
  182. cmpb,*>,n %arg0, %arg1, L(bcopy, reverse)
  183. ALTENTRY(memcpy)
  184. copy %arg0, %ret0
  185. hppa_copy(bcopy_f, %sr0, %arg1, %sr0, %arg0, %arg2, `+')
  186. bv %r0(%rp)
  187. nop
  188. L(bcopy, reverse)
  189. copy %arg0, %ret0
  190. hppa_copy(bcopy_r, %sr0, %arg1, %sr0, %arg0, %arg2, `-')
  191. bv %r0(%rp)
  192. nop
  193. EXIT(bcopy)
  194. ')dnl
  195. dnl
  196. ifelse(NAME, `spcopy',
  197. `
  198. #ifdef _KERNEL
  199. #include <assym.h>
  200. /*
  201. * int spcopy (pa_space_t ssp, const void *src, pa_space_t dsp, void *dst,
  202. * size_t size)
  203. * do a space to space bcopy.
  204. *
  205. * assumes that spaces do not clash, otherwise we lose
  206. */
  207. .import copy_on_fault, code
  208. LEAF_ENTRY(spcopy)
  209. sub,*<> %r0, arg4, %r0
  210. bv %r0(%rp)
  211. nop
  212. `
  213. std %rp, HPPA_FRAME_RP(%sp)
  214. ldo HPPA_FRAME_SIZE(%sp), %sp
  215. /* setup fault handler */
  216. mfctl %cr24, %r1
  217. ldd CI_CURPROC(%r1), %r1
  218. ldil L%copy_on_fault, %r21
  219. ldd P_ADDR(%r1), %r2
  220. ldo R%copy_on_fault(%r21), %r21
  221. ldd PCB_ONFAULT+U_PCB(%r2), %r1
  222. std %r21, PCB_ONFAULT+U_PCB(%r2)
  223. '
  224. mtsp %arg0, %sr1
  225. mtsp %arg2, %sr2
  226. copy arg4, %ret0
  227. hppa_copy(spcopy, %sr1, %arg1, %sr2, %arg3, %ret0, `+')
  228. mtsp %r0, %sr1
  229. mtsp %r0, %sr2
  230. /* reset fault handler */
  231. std %r1, PCB_ONFAULT+U_PCB(%r2)
  232. ldo -HPPA_FRAME_SIZE(%sp), %sp
  233. ldd HPPA_FRAME_RP(%sp), %rp
  234. bv %r0(%rp)
  235. copy %r0, %ret0
  236. EXIT(spcopy)
  237. #endif
  238. ')dnl
  239. .end