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>
12 #include <asm/export.h>
14 /* Work around cpp -rob */
16 #define EXECINSTR #execinstr
19 .section .fixup,ALLOC,EXECINSTR; \
23 .section __ex_table,ALLOC; \
29 #define EXT(start,end,handler) \
30 .section __ex_table,ALLOC; \
32 .word start, 0, end, handler; \
36 /* Please don't change these macros, unless you change the logic
37 * in the .fixup section below as well.
38 * Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
39 #define ZERO_BIG_BLOCK(base, offset, source) \
40 std source, [base + offset + 0x00]; \
41 std source, [base + offset + 0x08]; \
42 std source, [base + offset + 0x10]; \
43 std source, [base + offset + 0x18]; \
44 std source, [base + offset + 0x20]; \
45 std source, [base + offset + 0x28]; \
46 std source, [base + offset + 0x30]; \
47 std source, [base + offset + 0x38];
49 #define ZERO_LAST_BLOCKS(base, offset, source) \
50 std source, [base - offset - 0x38]; \
51 std source, [base - offset - 0x30]; \
52 std source, [base - offset - 0x28]; \
53 std source, [base - offset - 0x20]; \
54 std source, [base - offset - 0x18]; \
55 std source, [base - offset - 0x10]; \
56 std source, [base - offset - 0x08]; \
57 std source, [base - offset - 0x00];
66 .type __bzero,#function
68 EXPORT_SYMBOL(__bzero)
70 .globl __memset_start, __memset_end
85 EX(stb %g3, [%o0], sub %o1, 0)
89 EX(stb %g3, [%o0 + 0x01], sub %o1, 1)
91 EX(stb %g3, [%o0 + 0x02], sub %o1, 2)
113 EX(st %g3, [%o0], sub %o1, 0)
117 andcc %o1, 0xffffff80, %o3 ! Now everything is 8 aligned and o1 is len to run
121 ZERO_BIG_BLOCK(%o0, 0x00, %g2)
123 ZERO_BIG_BLOCK(%o0, 0x40, %g2)
141 ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
142 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
150 EX(st %g3, [%o0], and %o1, 7)
156 EX(sth %g3, [%o0], and %o1, 3)
160 EX(stb %g3, [%o0], and %o1, 1)
173 EX(stb %g3, [%o0 - 1], add %o1, 1)
185 .section .fixup,#alloc,#execinstr
206 /* %o4 is faulting address, %o5 is %pc where fault occurred */