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 <asm/ptrace.h>
13 #include <asm/export.h>
15 /* Work around cpp -rob */
17 #define EXECINSTR #execinstr
20 .section .fixup,ALLOC,EXECINSTR; \
24 .section __ex_table,ALLOC; \
30 #define EXT(start,end,handler) \
31 .section __ex_table,ALLOC; \
33 .word start, 0, end, handler; \
37 /* Please don't change these macros, unless you change the logic
38 * in the .fixup section below as well.
39 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
40 #define ZERO_BIG_BLOCK(base, offset, source) \
41 std source, [base + offset + 0x00]; \
42 std source, [base + offset + 0x08]; \
43 std source, [base + offset + 0x10]; \
44 std source, [base + offset + 0x18]; \
45 std source, [base + offset + 0x20]; \
46 std source, [base + offset + 0x28]; \
47 std source, [base + offset + 0x30]; \
48 std source, [base + offset + 0x38];
50 #define ZERO_LAST_BLOCKS(base, offset, source) \
51 std source, [base - offset - 0x38]; \
52 std source, [base - offset - 0x30]; \
53 std source, [base - offset - 0x28]; \
54 std source, [base - offset - 0x20]; \
55 std source, [base - offset - 0x18]; \
56 std source, [base - offset - 0x10]; \
57 std source, [base - offset - 0x08]; \
58 std source, [base - offset - 0x00];
67 .type __bzero,#function
69 EXPORT_SYMBOL(__bzero)
71 .globl __memset_start, __memset_end
86 EX(stb %g3, [%o0], sub %o1, 0)
90 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
92 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
114 EX(st %g3, [%o0], sub %o1, 0)
118 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
122 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
124 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
142 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
143 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
151 EX(st %g3, [%o0], and %o1, 7)
157 EX(sth %g3, [%o0], and %o1, 3)
161 EX(stb %g3, [%o0], and %o1, 1)
174 EX(stb %g3, [%o0 - 1], add %o1, 1)
186 .section .fixup,#alloc,#execinstr
207 /* %o4 is faulting address, %o5 is %pc where fault occurred */