1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* linux/arch/sparc/lib/memset.S: Sparc optimized memset, bzero and clear_user code
3 * Copyright (C) 1991,1996 Free Software Foundation
4 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
7 * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
8 * number of bytes not yet set if exception occurs and we were called as
12 #include <linux/export.h>
13 #include <asm/ptrace.h>
15 /* Work around cpp -rob */
17 #define EXECINSTR #execinstr
20 .section .fixup,ALLOC,EXECINSTR; \
24 .section __ex_table,ALLOC; \
30 #define STORE(source, base, offset, n) \
31 98: std source, [base + offset + n]; \
32 .section .fixup,ALLOC,EXECINSTR; \
35 sub %o3, n - offset, %o3; \
36 .section __ex_table,ALLOC; \
42 #define STORE_LAST(source, base, offset, n) \
43 EX(std source, [base - offset - n], \
46 /* Please don't change these macros, unless you change the logic
47 * in the .fixup section below as well.
48 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
49 #define ZERO_BIG_BLOCK(base, offset, source) \
50 STORE(source, base, offset, 0x00); \
51 STORE(source, base, offset, 0x08); \
52 STORE(source, base, offset, 0x10); \
53 STORE(source, base, offset, 0x18); \
54 STORE(source, base, offset, 0x20); \
55 STORE(source, base, offset, 0x28); \
56 STORE(source, base, offset, 0x30); \
57 STORE(source, base, offset, 0x38);
59 #define ZERO_LAST_BLOCKS(base, offset, source) \
60 STORE_LAST(source, base, offset, 0x38); \
61 STORE_LAST(source, base, offset, 0x30); \
62 STORE_LAST(source, base, offset, 0x28); \
63 STORE_LAST(source, base, offset, 0x20); \
64 STORE_LAST(source, base, offset, 0x18); \
65 STORE_LAST(source, base, offset, 0x10); \
66 STORE_LAST(source, base, offset, 0x08); \
67 STORE_LAST(source, base, offset, 0x00);
76 .type __bzero,#function
78 EXPORT_SYMBOL(__bzero)
93 EX(stb %g3, [%o0], sub %o1, 0)
97 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
99 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
121 EX(st %g3, [%o0], sub %o1, 0)
125 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
129 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
131 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
146 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
147 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
155 EX(st %g3, [%o0], and %o1, 7)
161 EX(sth %g3, [%o0], and %o1, 3)
165 EX(stb %g3, [%o0], and %o1, 1)
178 EX(stb %g3, [%o0 - 1], add %o1, 1)
189 .section .fixup,#alloc,#execinstr