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>
13 #define EXECINSTR #execinstr
16 .section .fixup,ALLOC,EXECINSTR; \
20 .section __ex_table,ALLOC; \
26 #define EXT(start,end,handler) \
27 .section __ex_table,ALLOC; \
29 .word start, 0, end, handler; \
33 /* Please don't change these macros, unless you change the logic
34 * in the .fixup section below as well.
35 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
36 #define ZERO_BIG_BLOCK(base, offset, source) \
37 std source, [base + offset + 0x00]; \
38 std source, [base + offset + 0x08]; \
39 std source, [base + offset + 0x10]; \
40 std source, [base + offset + 0x18]; \
41 std source, [base + offset + 0x20]; \
42 std source, [base + offset + 0x28]; \
43 std source, [base + offset + 0x30]; \
44 std source, [base + offset + 0x38];
46 #define ZERO_LAST_BLOCKS(base, offset, source) \
47 std source, [base - offset - 0x38]; \
48 std source, [base - offset - 0x30]; \
49 std source, [base - offset - 0x28]; \
50 std source, [base - offset - 0x20]; \
51 std source, [base - offset - 0x18]; \
52 std source, [base - offset - 0x10]; \
53 std source, [base - offset - 0x08]; \
54 std source, [base - offset - 0x00];
64 .globl __memset_start, __memset_end
77 EX(stb %g3, [%o0], sub %o1, 0)
81 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
83 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
104 EX(st %g3, [%o0], sub %o1, 0)
108 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
112 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
114 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
132 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
133 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
141 EX(st %g3, [%o0], and %o1, 7)
147 EX(sth %g3, [%o0], and %o1, 3)
151 EX(stb %g3, [%o0], and %o1, 1)
164 EX(stb %g3, [%o0 - 1], add %o1, 1)
170 .section .fixup,#alloc,#execinstr
191 /* %o4 is faulting address, %o5 is %pc where fault occurred */