1 /* GENbzero.S: Generic sparc64 memset/clear_user.
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
13 .section __ex_table; \
23 .type GENmemset, #function
24 GENmemset: /* %o0=buf, %o1=pat, %o2=len */
36 .type GENbzero, #function
39 1: brz,pn %o1, GENbzero_return
42 /* %o5: saved %asi, restored at GENbzero_done
43 * %o4: store %asi to use
49 GENbzero_from_clear_user:
51 bl,pn %icc, GENbzero_tiny
57 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
62 bl,pn %icc, GENbzero_medium
63 andcc %o0, (64 - 1), %g1
64 be,pt %xcc, GENbzero_pre_loop
68 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
74 andn %o1, (64 - 1), %g1
77 EX_ST(stxa %o2, [%o0 + 0x00] %asi)
78 EX_ST(stxa %o2, [%o0 + 0x08] %asi)
79 EX_ST(stxa %o2, [%o0 + 0x10] %asi)
80 EX_ST(stxa %o2, [%o0 + 0x18] %asi)
81 EX_ST(stxa %o2, [%o0 + 0x20] %asi)
82 EX_ST(stxa %o2, [%o0 + 0x28] %asi)
83 EX_ST(stxa %o2, [%o0 + 0x30] %asi)
84 EX_ST(stxa %o2, [%o0 + 0x38] %asi)
86 bne,pt %xcc, GENbzero_loop
91 brz,pn %o1, GENbzero_done
96 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
100 2: brz,pt %o1, GENbzero_done
104 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
117 .size GENbzero, .-GENbzero
118 .size GENmemset, .-GENmemset
121 .type GENclear_user, #function
122 GENclear_user: /* %o0=buf, %o1=len */
124 brz,pn %o1, GENbzero_done
127 bne,pn %icc, GENbzero
129 ba,pt %xcc, GENbzero_from_clear_user
131 .size GENclear_user, .-GENclear_user
133 #define BRANCH_ALWAYS 0x10680000
134 #define NOP 0x01000000
135 #define GEN_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 generic_patch_bzero
153 .type generic_patch_bzero,#function
155 GEN_DO_PATCH(memset, GENmemset)
156 GEN_DO_PATCH(__bzero, GENbzero)
157 GEN_DO_PATCH(__clear_user, GENclear_user)
160 .size generic_patch_bzero,.-generic_patch_bzero