1 /* NGbzero.S: Niagara optimized memset/clear_user.
3 * Copyright (C) 2006 David S. Miller (davem@davemloft.net)
9 .section __ex_table,"a";\
11 .word 98b, __retl_o1; \
18 .type NGmemset, #function
19 NGmemset: /* %o0=buf, %o1=pat, %o2=len */
31 .type NGbzero, #function
34 1: brz,pn %o1, NGbzero_return
37 /* %o5: saved %asi, restored at NGbzero_done
38 * %g7: store-init %asi to use
39 * %o4: non-store-init %asi to use
42 mov ASI_BLK_INIT_QUAD_LDD_P, %g7
46 NGbzero_from_clear_user:
48 bl,pn %icc, NGbzero_tiny
54 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
59 bl,pn %icc, NGbzero_medium
60 andcc %o0, (64 - 1), %g1
61 be,pt %xcc, NGbzero_pre_loop
65 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
72 andn %o1, (64 - 1), %g1
75 EX_ST(stxa %o2, [%o0 + 0x00] %asi)
76 EX_ST(stxa %o2, [%o0 + 0x08] %asi)
77 EX_ST(stxa %o2, [%o0 + 0x10] %asi)
78 EX_ST(stxa %o2, [%o0 + 0x18] %asi)
79 EX_ST(stxa %o2, [%o0 + 0x20] %asi)
80 EX_ST(stxa %o2, [%o0 + 0x28] %asi)
81 EX_ST(stxa %o2, [%o0 + 0x30] %asi)
82 EX_ST(stxa %o2, [%o0 + 0x38] %asi)
84 bne,pt %xcc, NGbzero_loop
89 brz,pn %o1, NGbzero_done
94 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
98 2: brz,pt %o1, NGbzero_done
102 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
115 .size NGbzero, .-NGbzero
116 .size NGmemset, .-NGmemset
119 .type NGclear_user, #function
120 NGclear_user: /* %o0=buf, %o1=len */
122 brz,pn %o1, NGbzero_done
127 mov ASI_BLK_INIT_QUAD_LDD_AIUS, %g7
128 ba,pt %xcc, NGbzero_from_clear_user
130 .size NGclear_user, .-NGclear_user
132 #define BRANCH_ALWAYS 0x10680000
133 #define NOP 0x01000000
134 #define NG_DO_PATCH(OLD, NEW) \
135 sethi %hi(NEW), %g1; \
136 or %g1, %lo(NEW), %g1; \
137 sethi %hi(OLD), %g2; \
138 or %g2, %lo(OLD), %g2; \
140 sethi %hi(BRANCH_ALWAYS), %g3; \
142 srl %g1, 11 + 2, %g1; \
143 or %g3, %lo(BRANCH_ALWAYS), %g3; \
146 sethi %hi(NOP), %g3; \
147 or %g3, %lo(NOP), %g3; \
148 stw %g3, [%g2 + 0x4]; \
151 .globl niagara_patch_bzero
152 .type niagara_patch_bzero,#function
154 NG_DO_PATCH(memset, NGmemset)
155 NG_DO_PATCH(__bzero, NGbzero)
156 NG_DO_PATCH(__clear_user, NGclear_user)
157 NG_DO_PATCH(tsb_init, NGtsb_init)
160 .size niagara_patch_bzero,.-niagara_patch_bzero