b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) ;;; SPDX-License-Identifier: GPL-2.0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 2) ;;; memcpy.S
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 3)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 4) #include <asm/linkage.h>
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 5)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 6) #if defined(CONFIG_CPU_H8300H)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 7) .h8300h
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 8) #endif
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 9) #if defined(CONFIG_CPU_H8S)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 10) .h8300s
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 11) #endif
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 12) .text
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 13) .global memcpy
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 14)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 15) ;;; void *memcpy(void *to, void *from, size_t n)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 16) memcpy:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 17) mov.l er2,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 18) bne 1f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 19) rts
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 20) 1:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 21) ;; address check
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 22) bld #0,r0l
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 23) bxor #0,r1l
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 24) bcs 4f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 25) mov.l er4,@-sp
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 26) mov.l er0,@-sp
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 27) btst #0,r0l
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 28) beq 1f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 29) ;; (aligned even) odd address
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 30) mov.b @er1,r3l
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 31) mov.b r3l,@er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 32) adds #1,er1
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 33) adds #1,er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 34) dec.l #1,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 35) beq 3f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 36) 1:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 37) ;; n < sizeof(unsigned long) check
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 38) sub.l er4,er4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 39) adds #4,er4 ; loop count check value
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 40) cmp.l er4,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 41) blo 2f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 42) ;; unsigned long copy
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 43) 1:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 44) mov.l @er1,er3
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 45) mov.l er3,@er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 46) adds #4,er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 47) adds #4,er1
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 48) subs #4,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 49) cmp.l er4,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 50) bcc 1b
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 51) ;; rest
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 52) 2:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 53) mov.l er2,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 54) beq 3f
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 55) 1:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 56) mov.b @er1,r3l
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 57) mov.b r3l,@er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 58) adds #1,er1
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 59) adds #1,er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 60) dec.l #1,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 61) bne 1b
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 62) 3:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 63) mov.l @sp+,er0
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 64) mov.l @sp+,er4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 65) rts
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 66)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 67) ;; odd <- even / even <- odd
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 68) 4:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 69) mov.l er4,er3
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 70) mov.l er2,er4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 71) mov.l er5,er2
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 72) mov.l er1,er5
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 73) mov.l er6,er1
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 74) mov.l er0,er6
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 75) 1:
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 76) eepmov.w
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 77) mov.w r4,r4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 78) bne 1b
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 79) dec.w #1,e4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 80) bpl 1b
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 81) mov.l er1,er6
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 82) mov.l er2,er5
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 83) mov.l er3,er4
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 84) rts
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 85)
a71a29de4c2f9 (Yoshinori Sato 2015-01-28 02:48:15 +0900 86) .end