2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1998, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2007 by Maciej W. Rozycki
9 * Copyright (C) 2011, 2012 MIPS Technologies, Inc.
12 #include <asm/asm-offsets.h>
13 #include <asm/regdef.h>
23 #ifdef CONFIG_CPU_MICROMIPS
24 #define STORSIZE (LONGSIZE * 2)
25 #define STORMASK (STORSIZE - 1)
29 #define LONG_S LONG_SP
31 #define STORSIZE LONGSIZE
32 #define STORMASK LONGMASK
41 * No need to protect it with EVA #ifdefery. The generated block of code
42 * will never be assembled if EVA is not enabled.
44 #define __EVAFY(insn, reg, addr) __BUILD_EVA_INSN(insn##e, reg, addr)
45 #define ___BUILD_EVA_INSN(insn, reg, addr) __EVAFY(insn, reg, addr)
47 #define EX(insn,reg,addr,handler) \
48 .if \mode == LEGACY_MODE; \
51 9: ___BUILD_EVA_INSN(insn, reg, addr); \
53 .section __ex_table,"a"; \
57 .macro f_fill64 dst, offset, val, fixup, mode
58 EX(LONG_S, \val, (\offset + 0 * STORSIZE)(\dst), \fixup)
59 EX(LONG_S, \val, (\offset + 1 * STORSIZE)(\dst), \fixup)
60 EX(LONG_S, \val, (\offset + 2 * STORSIZE)(\dst), \fixup)
61 EX(LONG_S, \val, (\offset + 3 * STORSIZE)(\dst), \fixup)
62 #if ((defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4)) || !defined(CONFIG_CPU_MICROMIPS))
63 EX(LONG_S, \val, (\offset + 4 * STORSIZE)(\dst), \fixup)
64 EX(LONG_S, \val, (\offset + 5 * STORSIZE)(\dst), \fixup)
65 EX(LONG_S, \val, (\offset + 6 * STORSIZE)(\dst), \fixup)
66 EX(LONG_S, \val, (\offset + 7 * STORSIZE)(\dst), \fixup)
68 #if (!defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4))
69 EX(LONG_S, \val, (\offset + 8 * STORSIZE)(\dst), \fixup)
70 EX(LONG_S, \val, (\offset + 9 * STORSIZE)(\dst), \fixup)
71 EX(LONG_S, \val, (\offset + 10 * STORSIZE)(\dst), \fixup)
72 EX(LONG_S, \val, (\offset + 11 * STORSIZE)(\dst), \fixup)
73 EX(LONG_S, \val, (\offset + 12 * STORSIZE)(\dst), \fixup)
74 EX(LONG_S, \val, (\offset + 13 * STORSIZE)(\dst), \fixup)
75 EX(LONG_S, \val, (\offset + 14 * STORSIZE)(\dst), \fixup)
76 EX(LONG_S, \val, (\offset + 15 * STORSIZE)(\dst), \fixup)
84 * Macro to generate the __bzero{,_user} symbol
86 * mode: LEGACY_MODE or EVA_MODE
88 .macro __BUILD_BZERO mode
89 /* Initialize __memset if this is the first time we call this macro */
92 .hidden __memset /* Make sure it does not leak */
95 sltiu t0, a2, STORSIZE /* very small region? */
96 bnez t0, .Lsmall_memset\@
97 andi t0, a0, STORMASK /* aligned? */
99 #ifdef CONFIG_CPU_MICROMIPS
100 move t8, a1 /* used by 'swp' instruction */
103 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
105 PTR_SUBU t0, STORSIZE /* alignment in bytes */
110 PTR_SUBU t0, AT /* alignment in bytes */
114 #ifndef CONFIG_CPU_MIPSR6
117 EX(LONG_S_L, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */
119 EX(LONG_S_R, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */
121 PTR_SUBU a0, t0 /* long align ptr */
122 PTR_ADDU a2, t0 /* correct size */
124 #else /* CONFIG_CPU_MIPSR6 */
125 #define STORE_BYTE(N) \
126 EX(sb, a1, N(a0), .Lbyte_fixup\@); \
130 PTR_ADDU a2, t0 /* correct size */
135 EX(sb, a1, 2(a0), .Lbyte_fixup\@)
141 EX(sb, a1, 6(a0), .Lbyte_fixup\@)
146 PTR_ADDIU a0, STORSIZE
147 #endif /* CONFIG_CPU_MIPSR6 */
148 1: ori t1, a2, 0x3f /* # of full blocks */
150 beqz t1, .Lmemset_partial\@ /* no block to fill */
151 andi t0, a2, 0x40-STORSIZE
153 PTR_ADDU t1, a0 /* end address */
157 f_fill64 a0, -64, FILL64RG, .Lfwd_fixup\@, \mode
163 PTR_LA t1, 2f /* where to start */
164 #ifdef CONFIG_CPU_MICROMIPS
168 PTR_SUBU t1, FILLPTRG
171 LONG_SRL AT, FILLPTRG, 1
176 PTR_ADDU a0, t0 /* dest ptr */
181 /* ... but first do longs ... */
182 f_fill64 a0, -64, FILL64RG, .Lpartial_fixup\@, \mode
184 andi a2, STORMASK /* At most one long to go */
187 #ifndef CONFIG_CPU_MIPSR6
188 PTR_ADDU a0, a2 /* What's left */
191 EX(LONG_S_R, a1, -1(a0), .Llast_fixup\@)
193 EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@)
201 EX(sb, a1, 2(a0), .Lbyte_fixup\@)
207 EX(sb, a1, 6(a0), .Lbyte_fixup\@)
218 1: PTR_ADDIU a0, 1 /* fill bytewise */
241 PTR_L t0, TI_TASK($28)
243 LONG_L t0, THREAD_BUADDR(t0)
249 PTR_L t0, TI_TASK($28)
251 LONG_L t0, THREAD_BUADDR(t0)
258 andi v1, a2, STORMASK
263 * memset(void *s, int c, size_t n)
265 * a0: start of area to clear
266 * a1: char to fill with
267 * a2: size of area to clear
272 move v0, a0 /* result */
274 andi a1, 0xff /* spread fillword */
287 FEXPORT(__bzero_kernel)
289 __BUILD_BZERO LEGACY_MODE
293 __BUILD_BZERO EVA_MODE