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