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 by Ralf Baechle
9 #include <asm/offset.h>
10 #include <asm/regdef.h>
12 #define EX(insn,reg,addr,handler) \
14 .section __ex_table,"a"; \
18 #define F_FILL64(dst, offset, val, fixup) \
19 EX(sw, val, (offset + 0x00)(dst), fixup); \
20 EX(sw, val, (offset + 0x04)(dst), fixup); \
21 EX(sw, val, (offset + 0x08)(dst), fixup); \
22 EX(sw, val, (offset + 0x0c)(dst), fixup); \
23 EX(sw, val, (offset + 0x10)(dst), fixup); \
24 EX(sw, val, (offset + 0x14)(dst), fixup); \
25 EX(sw, val, (offset + 0x18)(dst), fixup); \
26 EX(sw, val, (offset + 0x1c)(dst), fixup); \
27 EX(sw, val, (offset + 0x20)(dst), fixup); \
28 EX(sw, val, (offset + 0x24)(dst), fixup); \
29 EX(sw, val, (offset + 0x28)(dst), fixup); \
30 EX(sw, val, (offset + 0x2c)(dst), fixup); \
31 EX(sw, val, (offset + 0x30)(dst), fixup); \
32 EX(sw, val, (offset + 0x34)(dst), fixup); \
33 EX(sw, val, (offset + 0x38)(dst), fixup); \
34 EX(sw, val, (offset + 0x3c)(dst), fixup)
37 * memset(void *s, int c, size_t n)
39 * a0: start of area to clear
40 * a1: char to fill with
41 * a2: size of area to clear
47 move v0, a0 /* result */
49 andi a1, 0xff /* spread fillword */
57 sltiu t0, a2, 4 /* very small region? */
59 andi t0, a0, 3 /* aligned? */
62 subu t0, 4 /* alignment in bytes */
65 EX(swl, a1, (a0), first_fixup) /* make word aligned */
68 EX(swr, a1, (a0), first_fixup) /* make word aligned */
70 subu a0, t0 /* word align ptr */
71 addu a2, t0 /* correct size */
73 1: ori t1, a2, 0x3f /* # of full blocks */
75 beqz t1, memset_partial /* no block to fill */
78 addu t1, a0 /* end address */
81 F_FILL64(a0, -64, a1, fwd_fixup)
86 PTR_LA t1, 2f /* where to start */
89 addu a0, t0 /* dest ptr */
94 F_FILL64(a0, -64, a1, partial_fixup) /* ... but first do wrds ... */
96 andi a2, 3 /* 0 <= n <= 3 to go */
99 addu a0, a2 /* What's left */
101 EX(swr, a1, -1(a0), last_fixup)
104 EX(swl, a1, -1(a0), last_fixup)
113 1: addiu a0, 1 /* fill bytewise */
126 lw t0, THREAD_BUADDR($28)
133 lw t0, THREAD_BUADDR($28)