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 */
116 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 1: ori t1, a2, 0x3f /* # of full blocks */
126 beqz t1, .Lmemset_partial\@ /* no block to fill */
127 andi t0, a2, 0x40-STORSIZE
129 PTR_ADDU t1, a0 /* end address */
133 f_fill64 a0, -64, FILL64RG, .Lfwd_fixup\@, \mode
139 PTR_LA t1, 2f /* where to start */
140 #ifdef CONFIG_CPU_MICROMIPS
144 PTR_SUBU t1, FILLPTRG
147 LONG_SRL AT, FILLPTRG, 1
152 PTR_ADDU a0, t0 /* dest ptr */
157 /* ... but first do longs ... */
158 f_fill64 a0, -64, FILL64RG, .Lpartial_fixup\@, \mode
160 andi a2, STORMASK /* At most one long to go */
163 PTR_ADDU a0, a2 /* What's left */
166 EX(LONG_S_R, a1, -1(a0), .Llast_fixup\@)
169 EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@)
178 1: PTR_ADDIU a0, 1 /* fill bytewise */
196 PTR_L t0, TI_TASK($28)
198 LONG_L t0, THREAD_BUADDR(t0)
204 PTR_L t0, TI_TASK($28)
206 LONG_L t0, THREAD_BUADDR(t0)
213 andi v1, a2, STORMASK
218 * memset(void *s, int c, size_t n)
220 * a0: start of area to clear
221 * a1: char to fill with
222 * a2: size of area to clear
227 move v0, a0 /* result */
229 andi a1, 0xff /* spread fillword */
242 __BUILD_BZERO LEGACY_MODE
246 __BUILD_BZERO EVA_MODE