1 /* NGbzero.S: Niagara optimized memset/clear_user.
3 * Copyright (C) 2006 David S. Miller (davem@davemloft.net)
13 .section __ex_table,"a";\
22 .type NGmemset, #function
23 NGmemset: /* %o0=buf, %o1=pat, %o2=len */
35 .type NGbzero, #function
38 1: brz,pn %o1, NGbzero_return
41 /* %o5: saved %asi, restored at NGbzero_done
42 * %g7: store-init %asi to use
43 * %o4: non-store-init %asi to use
46 mov ASI_BLK_INIT_QUAD_LDD_P, %g7
50 NGbzero_from_clear_user:
52 bl,pn %icc, NGbzero_tiny
58 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
63 bl,pn %icc, NGbzero_medium
64 andcc %o0, (64 - 1), %g1
65 be,pt %xcc, NGbzero_pre_loop
69 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
76 andn %o1, (64 - 1), %g1
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)
88 bne,pt %xcc, NGbzero_loop
93 brz,pn %o1, NGbzero_done
98 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
102 2: brz,pt %o1, NGbzero_done
106 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
119 .size NGbzero, .-NGbzero
120 .size NGmemset, .-NGmemset
123 .type NGclear_user, #function
124 NGclear_user: /* %o0=buf, %o1=len */
126 brz,pn %o1, NGbzero_done
131 mov ASI_BLK_INIT_QUAD_LDD_AIUS, %g7
132 ba,pt %xcc, NGbzero_from_clear_user
134 .size NGclear_user, .-NGclear_user
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; \
144 sethi %hi(BRANCH_ALWAYS), %g3; \
146 srl %g1, 11 + 2, %g1; \
147 or %g3, %lo(BRANCH_ALWAYS), %g3; \
150 sethi %hi(NOP), %g3; \
151 or %g3, %lo(NOP), %g3; \
152 stw %g3, [%g2 + 0x4]; \
155 .globl niagara_patch_bzero
156 .type niagara_patch_bzero,#function
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)
164 .size niagara_patch_bzero,.-niagara_patch_bzero