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
37 #define EX(insn,reg,addr,handler) \
39 .section __ex_table,"a"; \
43 .macro f_fill64 dst, offset, val, fixup
44 EX(LONG_S, \val, (\offset + 0 * STORSIZE)(\dst), \fixup)
45 EX(LONG_S, \val, (\offset + 1 * STORSIZE)(\dst), \fixup)
46 EX(LONG_S, \val, (\offset + 2 * STORSIZE)(\dst), \fixup)
47 EX(LONG_S, \val, (\offset + 3 * STORSIZE)(\dst), \fixup)
48 #if ((defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4)) || !defined(CONFIG_CPU_MICROMIPS))
49 EX(LONG_S, \val, (\offset + 4 * STORSIZE)(\dst), \fixup)
50 EX(LONG_S, \val, (\offset + 5 * STORSIZE)(\dst), \fixup)
51 EX(LONG_S, \val, (\offset + 6 * STORSIZE)(\dst), \fixup)
52 EX(LONG_S, \val, (\offset + 7 * STORSIZE)(\dst), \fixup)
54 #if (!defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4))
55 EX(LONG_S, \val, (\offset + 8 * STORSIZE)(\dst), \fixup)
56 EX(LONG_S, \val, (\offset + 9 * STORSIZE)(\dst), \fixup)
57 EX(LONG_S, \val, (\offset + 10 * STORSIZE)(\dst), \fixup)
58 EX(LONG_S, \val, (\offset + 11 * STORSIZE)(\dst), \fixup)
59 EX(LONG_S, \val, (\offset + 12 * STORSIZE)(\dst), \fixup)
60 EX(LONG_S, \val, (\offset + 13 * STORSIZE)(\dst), \fixup)
61 EX(LONG_S, \val, (\offset + 14 * STORSIZE)(\dst), \fixup)
62 EX(LONG_S, \val, (\offset + 15 * STORSIZE)(\dst), \fixup)
67 * memset(void *s, int c, size_t n)
69 * a0: start of area to clear
70 * a1: char to fill with
71 * a2: size of area to clear
77 move v0, a0 /* result */
79 andi a1, 0xff /* spread fillword */
91 sltiu t0, a2, STORSIZE /* very small region? */
92 bnez t0, .Lsmall_memset
93 andi t0, a0, STORMASK /* aligned? */
95 #ifdef CONFIG_CPU_MICROMIPS
96 move t8, a1 /* used by 'swp' instruction */
99 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
101 PTR_SUBU t0, STORSIZE /* alignment in bytes */
106 PTR_SUBU t0, AT /* alignment in bytes */
112 EX(LONG_S_L, a1, (a0), .Lfirst_fixup) /* make word/dword aligned */
115 EX(LONG_S_R, a1, (a0), .Lfirst_fixup) /* make word/dword aligned */
117 PTR_SUBU a0, t0 /* long align ptr */
118 PTR_ADDU a2, t0 /* correct size */
120 1: ori t1, a2, 0x3f /* # of full blocks */
122 beqz t1, .Lmemset_partial /* no block to fill */
123 andi t0, a2, 0x40-STORSIZE
125 PTR_ADDU t1, a0 /* end address */
129 f_fill64 a0, -64, FILL64RG, .Lfwd_fixup
135 PTR_LA t1, 2f /* where to start */
136 #ifdef CONFIG_CPU_MICROMIPS
140 PTR_SUBU t1, FILLPTRG
143 LONG_SRL AT, FILLPTRG, 1
148 PTR_ADDU a0, t0 /* dest ptr */
153 f_fill64 a0, -64, FILL64RG, .Lpartial_fixup /* ... but first do longs ... */
155 andi a2, STORMASK /* At most one long to go */
158 PTR_ADDU a0, a2 /* What's left */
161 EX(LONG_S_R, a1, -1(a0), .Llast_fixup)
164 EX(LONG_S_L, a1, -1(a0), .Llast_fixup)
173 1: PTR_ADDIU a0, 1 /* fill bytewise */
187 PTR_L t0, TI_TASK($28)
189 LONG_L t0, THREAD_BUADDR(t0)
195 PTR_L t0, TI_TASK($28)
197 LONG_L t0, THREAD_BUADDR(t0)
204 andi v1, a2, STORMASK