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 * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
7 * number of bytes not yet set if exception occurs and we were called as
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];
66 .globl __memset_start, __memset_end
81 EX(stb %g3, [%o0], sub %o1, 0)
85 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
87 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
109 EX(st %g3, [%o0], sub %o1, 0)
113 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
117 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
119 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
137 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
138 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
146 EX(st %g3, [%o0], and %o1, 7)
152 EX(sth %g3, [%o0], and %o1, 3)
156 EX(stb %g3, [%o0], and %o1, 1)
169 EX(stb %g3, [%o0 - 1], add %o1, 1)
181 .section .fixup,#alloc,#execinstr
202 /* %o4 is faulting address, %o5 is %pc where fault occurred */