1 /* linux/arch/sparc/lib/memset.S: Sparc optimized memset, bzero and clear_user code
2 * Copyright (C) 1991,1996 Free Software Foundation
3 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
6 * Returns 0, if ok, and number of bytes not yet set if exception
7 * occurs and we were called as clear_user.
10 #include <asm/cprefix.h>
11 #include <asm/ptrace.h>
13 /* Work around cpp -rob */
15 #define EXECINSTR #execinstr
18 .section .fixup,ALLOC,EXECINSTR; \
22 .section __ex_table,ALLOC; \
28 #define EXT(start,end,handler) \
29 .section __ex_table,ALLOC; \
31 .word start, 0, end, handler; \
35 /* Please don't change these macros, unless you change the logic
36 * in the .fixup section below as well.
37 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
38 #define ZERO_BIG_BLOCK(base, offset, source) \
39 std source, [base + offset + 0x00]; \
40 std source, [base + offset + 0x08]; \
41 std source, [base + offset + 0x10]; \
42 std source, [base + offset + 0x18]; \
43 std source, [base + offset + 0x20]; \
44 std source, [base + offset + 0x28]; \
45 std source, [base + offset + 0x30]; \
46 std source, [base + offset + 0x38];
48 #define ZERO_LAST_BLOCKS(base, offset, source) \
49 std source, [base - offset - 0x38]; \
50 std source, [base - offset - 0x30]; \
51 std source, [base - offset - 0x28]; \
52 std source, [base - offset - 0x20]; \
53 std source, [base - offset - 0x18]; \
54 std source, [base - offset - 0x10]; \
55 std source, [base - offset - 0x08]; \
56 std source, [base - offset - 0x00];
64 .globl C_LABEL(__bzero), C_LABEL(__memset),
65 .globl C_LABEL(memset)
66 .globl C_LABEL(__memset_start), C_LABEL(__memset_end)
67 C_LABEL(__memset_start):
80 EX(stb %g3, [%o0], sub %o1, 0)
84 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
86 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
107 EX(st %g3, [%o0], sub %o1, 0)
111 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
115 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
117 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
135 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
136 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
144 EX(st %g3, [%o0], and %o1, 7)
150 EX(sth %g3, [%o0], and %o1, 3)
154 EX(stb %g3, [%o0], and %o1, 1)
167 EX(stb %g3, [%o0 - 1], add %o1, 1)
171 C_LABEL(__memset_end):
173 .section .fixup,#alloc,#execinstr
194 /* %o4 is faulting address, %o5 is %pc where fault occurred */
198 call C_LABEL(lookup_fault)