1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/linkage.h>
6 .macro GET_FRONT_BITS rx y
14 .macro GET_AFTER_BITS rx y
22 /* void *memcpy(void *dest, const void *src, size_t n); */
30 jbt .L_dest_not_aligned
34 jbt .L_dest_aligned_but_src_not_aligned
37 jbt .L_aligned_and_len_less_16bytes
40 .L_aligned_and_len_larger_16bytes:
53 jbf .L_aligned_and_len_larger_16bytes
59 .L_aligned_and_len_less_16bytes:
75 .L_copy_by_byte: /* len less than 4 bytes */
88 * If dest is not aligned, just copying some bytes makes the dest align.
89 * Afther that, we judge whether the src is aligned.
103 ldb r1, (r3, 0) /* makes the dest align. */
113 mov r6, r3 /* judge whether the src is aligned. */
118 /* Judge the number of misaligned, 1, 2, 3? */
119 .L_dest_aligned_but_src_not_aligned:
130 bf .L_dest_aligned_but_src_not_aligned_2bytes
132 bf .L_dest_aligned_but_src_not_aligned_3bytes
134 .L_dest_aligned_but_src_not_aligned_1byte:
141 .L10: /* If the len is less than 16 bytes */
168 GET_FRONT_BITS r1 8 /* little or big endian? */
175 GET_AFTER_BITS r11 24
207 .L_dest_aligned_but_src_not_aligned_2bytes:
245 GET_FRONT_BITS r10 16
247 GET_AFTER_BITS r11 16
255 GET_FRONT_BITS r10 16
280 .L_dest_aligned_but_src_not_aligned_3bytes:
315 GET_FRONT_BITS r10 24
325 GET_FRONT_BITS r10 24