1 /* GENbzero.S: Generic sparc64 memset/clear_user.
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
9 .section __ex_table,"a";\
11 .word 98b, __retl_o1_asi;\
19 .type GENmemset, #function
20 GENmemset: /* %o0=buf, %o1=pat, %o2=len */
32 .type GENbzero, #function
35 1: brz,pn %o1, GENbzero_return
38 /* %o5: saved %asi, restored at GENbzero_done
39 * %o4: store %asi to use
45 GENbzero_from_clear_user:
47 bl,pn %icc, GENbzero_tiny
53 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
58 bl,pn %icc, GENbzero_medium
59 andcc %o0, (64 - 1), %g1
60 be,pt %xcc, GENbzero_pre_loop
64 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
70 andn %o1, (64 - 1), %g1
73 EX_ST(stxa %o2, [%o0 + 0x00] %asi)
74 EX_ST(stxa %o2, [%o0 + 0x08] %asi)
75 EX_ST(stxa %o2, [%o0 + 0x10] %asi)
76 EX_ST(stxa %o2, [%o0 + 0x18] %asi)
77 EX_ST(stxa %o2, [%o0 + 0x20] %asi)
78 EX_ST(stxa %o2, [%o0 + 0x28] %asi)
79 EX_ST(stxa %o2, [%o0 + 0x30] %asi)
80 EX_ST(stxa %o2, [%o0 + 0x38] %asi)
82 bne,pt %xcc, GENbzero_loop
87 brz,pn %o1, GENbzero_done
92 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
96 2: brz,pt %o1, GENbzero_done
100 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
113 .size GENbzero, .-GENbzero
114 .size GENmemset, .-GENmemset
117 .type GENclear_user, #function
118 GENclear_user: /* %o0=buf, %o1=len */
120 brz,pn %o1, GENbzero_done
123 bne,pn %icc, GENbzero
125 ba,pt %xcc, GENbzero_from_clear_user
127 .size GENclear_user, .-GENclear_user
129 #define BRANCH_ALWAYS 0x10680000
130 #define NOP 0x01000000
131 #define GEN_DO_PATCH(OLD, NEW) \
132 sethi %hi(NEW), %g1; \
133 or %g1, %lo(NEW), %g1; \
134 sethi %hi(OLD), %g2; \
135 or %g2, %lo(OLD), %g2; \
137 sethi %hi(BRANCH_ALWAYS), %g3; \
139 srl %g1, 11 + 2, %g1; \
140 or %g3, %lo(BRANCH_ALWAYS), %g3; \
143 sethi %hi(NOP), %g3; \
144 or %g3, %lo(NOP), %g3; \
145 stw %g3, [%g2 + 0x4]; \
148 .globl generic_patch_bzero
149 .type generic_patch_bzero,#function
151 GEN_DO_PATCH(memset, GENmemset)
152 GEN_DO_PATCH(__bzero, GENbzero)
153 GEN_DO_PATCH(__clear_user, GENclear_user)
156 .size generic_patch_bzero,.-generic_patch_bzero