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/ptrace.h>
12 /* Work around cpp -rob */
14 #define EXECINSTR #execinstr
17 .section .fixup,ALLOC,EXECINSTR; \
21 .section __ex_table,ALLOC; \
27 #define EXT(start,end,handler) \
28 .section __ex_table,ALLOC; \
30 .word start, 0, end, handler; \
34 /* Please don't change these macros, unless you change the logic
35 * in the .fixup section below as well.
36 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
37 #define ZERO_BIG_BLOCK(base, offset, source) \
38 std source, [base + offset + 0x00]; \
39 std source, [base + offset + 0x08]; \
40 std source, [base + offset + 0x10]; \
41 std source, [base + offset + 0x18]; \
42 std source, [base + offset + 0x20]; \
43 std source, [base + offset + 0x28]; \
44 std source, [base + offset + 0x30]; \
45 std source, [base + offset + 0x38];
47 #define ZERO_LAST_BLOCKS(base, offset, source) \
48 std source, [base - offset - 0x38]; \
49 std source, [base - offset - 0x30]; \
50 std source, [base - offset - 0x28]; \
51 std source, [base - offset - 0x20]; \
52 std source, [base - offset - 0x18]; \
53 std source, [base - offset - 0x10]; \
54 std source, [base - offset - 0x08]; \
55 std source, [base - offset - 0x00];
65 .globl __memset_start, __memset_end
78 EX(stb %g3, [%o0], sub %o1, 0)
82 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
84 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
105 EX(st %g3, [%o0], sub %o1, 0)
109 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
113 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
115 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
133 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
134 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
142 EX(st %g3, [%o0], and %o1, 7)
148 EX(sth %g3, [%o0], and %o1, 3)
152 EX(stb %g3, [%o0], and %o1, 1)
165 EX(stb %g3, [%o0 - 1], add %o1, 1)
171 .section .fixup,#alloc,#execinstr
192 /* %o4 is faulting address, %o5 is %pc where fault occurred */