aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/lib/NGbzero.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/lib/NGbzero.S')
-rw-r--r--arch/sparc/lib/NGbzero.S164
1 files changed, 164 insertions, 0 deletions
diff --git a/arch/sparc/lib/NGbzero.S b/arch/sparc/lib/NGbzero.S
new file mode 100644
index 000000000000..814d5f7a45e1
--- /dev/null
+++ b/arch/sparc/lib/NGbzero.S
@@ -0,0 +1,164 @@
1/* NGbzero.S: Niagara optimized memset/clear_user.
2 *
3 * Copyright (C) 2006 David S. Miller (davem@davemloft.net)
4 */
5#include <asm/asi.h>
6
7#define EX_ST(x,y) \
898: x,y; \
9 .section .fixup; \
10 .align 4; \
1199: retl; \
12 mov %o1, %o0; \
13 .section __ex_table,"a";\
14 .align 4; \
15 .word 98b, 99b; \
16 .text; \
17 .align 4;
18
19 .text
20
21 .globl NGmemset
22 .type NGmemset, #function
23NGmemset: /* %o0=buf, %o1=pat, %o2=len */
24 and %o1, 0xff, %o3
25 mov %o2, %o1
26 sllx %o3, 8, %g1
27 or %g1, %o3, %o2
28 sllx %o2, 16, %g1
29 or %g1, %o2, %o2
30 sllx %o2, 32, %g1
31 ba,pt %xcc, 1f
32 or %g1, %o2, %o2
33
34 .globl NGbzero
35 .type NGbzero, #function
36NGbzero:
37 clr %o2
381: brz,pn %o1, NGbzero_return
39 mov %o0, %o3
40
41 /* %o5: saved %asi, restored at NGbzero_done
42 * %g7: store-init %asi to use
43 * %o4: non-store-init %asi to use
44 */
45 rd %asi, %o5
46 mov ASI_BLK_INIT_QUAD_LDD_P, %g7
47 mov ASI_P, %o4
48 wr %o4, 0x0, %asi
49
50NGbzero_from_clear_user:
51 cmp %o1, 15
52 bl,pn %icc, NGbzero_tiny
53 andcc %o0, 0x7, %g1
54 be,pt %xcc, 2f
55 mov 8, %g2
56 sub %g2, %g1, %g1
57 sub %o1, %g1, %o1
581: EX_ST(stba %o2, [%o0 + 0x00] %asi)
59 subcc %g1, 1, %g1
60 bne,pt %xcc, 1b
61 add %o0, 1, %o0
622: cmp %o1, 128
63 bl,pn %icc, NGbzero_medium
64 andcc %o0, (64 - 1), %g1
65 be,pt %xcc, NGbzero_pre_loop
66 mov 64, %g2
67 sub %g2, %g1, %g1
68 sub %o1, %g1, %o1
691: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
70 subcc %g1, 8, %g1
71 bne,pt %xcc, 1b
72 add %o0, 8, %o0
73
74NGbzero_pre_loop:
75 wr %g7, 0x0, %asi
76 andn %o1, (64 - 1), %g1
77 sub %o1, %g1, %o1
78NGbzero_loop:
79 EX_ST(stxa %o2, [%o0 + 0x00] %asi)
80 EX_ST(stxa %o2, [%o0 + 0x08] %asi)
81 EX_ST(stxa %o2, [%o0 + 0x10] %asi)
82 EX_ST(stxa %o2, [%o0 + 0x18] %asi)
83 EX_ST(stxa %o2, [%o0 + 0x20] %asi)
84 EX_ST(stxa %o2, [%o0 + 0x28] %asi)
85 EX_ST(stxa %o2, [%o0 + 0x30] %asi)
86 EX_ST(stxa %o2, [%o0 + 0x38] %asi)
87 subcc %g1, 64, %g1
88 bne,pt %xcc, NGbzero_loop
89 add %o0, 64, %o0
90
91 membar #Sync
92 wr %o4, 0x0, %asi
93 brz,pn %o1, NGbzero_done
94NGbzero_medium:
95 andncc %o1, 0x7, %g1
96 be,pn %xcc, 2f
97 sub %o1, %g1, %o1
981: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
99 subcc %g1, 8, %g1
100 bne,pt %xcc, 1b
101 add %o0, 8, %o0
1022: brz,pt %o1, NGbzero_done
103 nop
104
105NGbzero_tiny:
1061: EX_ST(stba %o2, [%o0 + 0x00] %asi)
107 subcc %o1, 1, %o1
108 bne,pt %icc, 1b
109 add %o0, 1, %o0
110
111 /* fallthrough */
112
113NGbzero_done:
114 wr %o5, 0x0, %asi
115
116NGbzero_return:
117 retl
118 mov %o3, %o0
119 .size NGbzero, .-NGbzero
120 .size NGmemset, .-NGmemset
121
122 .globl NGclear_user
123 .type NGclear_user, #function
124NGclear_user: /* %o0=buf, %o1=len */
125 rd %asi, %o5
126 brz,pn %o1, NGbzero_done
127 clr %o3
128 cmp %o5, ASI_AIUS
129 bne,pn %icc, NGbzero
130 clr %o2
131 mov ASI_BLK_INIT_QUAD_LDD_AIUS, %g7
132 ba,pt %xcc, NGbzero_from_clear_user
133 mov ASI_AIUS, %o4
134 .size NGclear_user, .-NGclear_user
135
136#define BRANCH_ALWAYS 0x10680000
137#define NOP 0x01000000
138#define NG_DO_PATCH(OLD, NEW) \
139 sethi %hi(NEW), %g1; \
140 or %g1, %lo(NEW), %g1; \
141 sethi %hi(OLD), %g2; \
142 or %g2, %lo(OLD), %g2; \
143 sub %g1, %g2, %g1; \
144 sethi %hi(BRANCH_ALWAYS), %g3; \
145 sll %g1, 11, %g1; \
146 srl %g1, 11 + 2, %g1; \
147 or %g3, %lo(BRANCH_ALWAYS), %g3; \
148 or %g3, %g1, %g3; \
149 stw %g3, [%g2]; \
150 sethi %hi(NOP), %g3; \
151 or %g3, %lo(NOP), %g3; \
152 stw %g3, [%g2 + 0x4]; \
153 flush %g2;
154
155 .globl niagara_patch_bzero
156 .type niagara_patch_bzero,#function
157niagara_patch_bzero:
158 NG_DO_PATCH(memset, NGmemset)
159 NG_DO_PATCH(__bzero, NGbzero)
160 NG_DO_PATCH(__clear_user, NGclear_user)
161 NG_DO_PATCH(tsb_init, NGtsb_init)
162 retl
163 nop
164 .size niagara_patch_bzero,.-niagara_patch_bzero