1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* NGbzero.S: Niagara optimized memset/clear_user.
4 * Copyright (C) 2006 David S. Miller (davem@davemloft.net)
10 .section __ex_table,"a";\
12 .word 98b, __retl_o1_asi;\
19 .type NGmemset, #function
20 NGmemset: /* %o0=buf, %o1=pat, %o2=len */
32 .type NGbzero, #function
35 1: brz,pn %o1, NGbzero_return
38 /* %o5: saved %asi, restored at NGbzero_done
39 * %g7: store-init %asi to use
40 * %o4: non-store-init %asi to use
43 mov ASI_BLK_INIT_QUAD_LDD_P, %g7
47 NGbzero_from_clear_user:
49 bl,pn %icc, NGbzero_tiny
55 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
60 bl,pn %icc, NGbzero_medium
61 andcc %o0, (64 - 1), %g1
62 be,pt %xcc, NGbzero_pre_loop
66 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
73 andn %o1, (64 - 1), %g1
76 EX_ST(stxa %o2, [%o0 + 0x00] %asi)
77 EX_ST(stxa %o2, [%o0 + 0x08] %asi)
78 EX_ST(stxa %o2, [%o0 + 0x10] %asi)
79 EX_ST(stxa %o2, [%o0 + 0x18] %asi)
80 EX_ST(stxa %o2, [%o0 + 0x20] %asi)
81 EX_ST(stxa %o2, [%o0 + 0x28] %asi)
82 EX_ST(stxa %o2, [%o0 + 0x30] %asi)
83 EX_ST(stxa %o2, [%o0 + 0x38] %asi)
85 bne,pt %xcc, NGbzero_loop
90 brz,pn %o1, NGbzero_done
95 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
99 2: brz,pt %o1, NGbzero_done
103 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
116 .size NGbzero, .-NGbzero
117 .size NGmemset, .-NGmemset
120 .type NGclear_user, #function
121 NGclear_user: /* %o0=buf, %o1=len */
123 brz,pn %o1, NGbzero_done
128 mov ASI_BLK_INIT_QUAD_LDD_AIUS, %g7
129 ba,pt %xcc, NGbzero_from_clear_user
131 .size NGclear_user, .-NGclear_user
133 #define BRANCH_ALWAYS 0x10680000
134 #define NOP 0x01000000
135 #define NG_DO_PATCH(OLD, NEW) \
136 sethi %hi(NEW), %g1; \
137 or %g1, %lo(NEW), %g1; \
138 sethi %hi(OLD), %g2; \
139 or %g2, %lo(OLD), %g2; \
141 sethi %hi(BRANCH_ALWAYS), %g3; \
143 srl %g1, 11 + 2, %g1; \
144 or %g3, %lo(BRANCH_ALWAYS), %g3; \
147 sethi %hi(NOP), %g3; \
148 or %g3, %lo(NOP), %g3; \
149 stw %g3, [%g2 + 0x4]; \
152 .globl niagara_patch_bzero
153 .type niagara_patch_bzero,#function
155 NG_DO_PATCH(memset, NGmemset)
156 NG_DO_PATCH(__bzero, NGbzero)
157 NG_DO_PATCH(__clear_user, NGclear_user)
158 NG_DO_PATCH(tsb_init, NGtsb_init)
161 .size niagara_patch_bzero,.-niagara_patch_bzero