2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998, 1999, 2000 by Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
2007-10-23 05:43:25 -06:00
|
|
|
* Copyright (C) 2007 Maciej W. Rozycki
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
#include <asm/asm.h>
|
2005-09-09 14:32:31 -06:00
|
|
|
#include <asm/asm-offsets.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/regdef.h>
|
|
|
|
|
2006-12-17 08:07:40 -07:00
|
|
|
#if LONGSIZE == 4
|
|
|
|
#define LONG_S_L swl
|
|
|
|
#define LONG_S_R swr
|
|
|
|
#else
|
|
|
|
#define LONG_S_L sdl
|
|
|
|
#define LONG_S_R sdr
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#define EX(insn,reg,addr,handler) \
|
|
|
|
9: insn reg, addr; \
|
|
|
|
.section __ex_table,"a"; \
|
|
|
|
PTR 9b, handler; \
|
|
|
|
.previous
|
|
|
|
|
|
|
|
.macro f_fill64 dst, offset, val, fixup
|
|
|
|
EX(LONG_S, \val, (\offset + 0 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 1 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 2 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 3 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 4 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 5 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 6 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 7 * LONGSIZE)(\dst), \fixup)
|
2006-12-17 08:07:40 -07:00
|
|
|
#if LONGSIZE == 4
|
2005-04-16 16:20:36 -06:00
|
|
|
EX(LONG_S, \val, (\offset + 8 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 9 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 10 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 11 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 12 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 13 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 14 * LONGSIZE)(\dst), \fixup)
|
|
|
|
EX(LONG_S, \val, (\offset + 15 * LONGSIZE)(\dst), \fixup)
|
2006-12-17 08:07:40 -07:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
.endm
|
|
|
|
|
|
|
|
/*
|
|
|
|
* memset(void *s, int c, size_t n)
|
|
|
|
*
|
|
|
|
* a0: start of area to clear
|
|
|
|
* a1: char to fill with
|
|
|
|
* a2: size of area to clear
|
|
|
|
*/
|
|
|
|
.set noreorder
|
|
|
|
.align 5
|
|
|
|
LEAF(memset)
|
|
|
|
beqz a1, 1f
|
|
|
|
move v0, a0 /* result */
|
|
|
|
|
|
|
|
andi a1, 0xff /* spread fillword */
|
2006-12-17 08:07:40 -07:00
|
|
|
LONG_SLL t1, a1, 8
|
2005-04-16 16:20:36 -06:00
|
|
|
or a1, t1
|
2006-12-17 08:07:40 -07:00
|
|
|
LONG_SLL t1, a1, 16
|
|
|
|
#if LONGSIZE == 8
|
|
|
|
or a1, t1
|
|
|
|
LONG_SLL t1, a1, 32
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
or a1, t1
|
|
|
|
1:
|
|
|
|
|
|
|
|
FEXPORT(__bzero)
|
|
|
|
sltiu t0, a2, LONGSIZE /* very small region? */
|
2008-01-29 03:14:59 -07:00
|
|
|
bnez t0, .Lsmall_memset
|
2005-04-16 16:20:36 -06:00
|
|
|
andi t0, a0, LONGMASK /* aligned? */
|
|
|
|
|
2007-10-23 05:43:25 -06:00
|
|
|
#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
|
2005-04-16 16:20:36 -06:00
|
|
|
beqz t0, 1f
|
|
|
|
PTR_SUBU t0, LONGSIZE /* alignment in bytes */
|
2007-10-23 05:43:25 -06:00
|
|
|
#else
|
|
|
|
.set noat
|
|
|
|
li AT, LONGSIZE
|
|
|
|
beqz t0, 1f
|
|
|
|
PTR_SUBU t0, AT /* alignment in bytes */
|
|
|
|
.set at
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-11-25 03:47:56 -07:00
|
|
|
R10KCBARRIER(0(ra))
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef __MIPSEB__
|
2008-01-29 03:14:59 -07:00
|
|
|
EX(LONG_S_L, a1, (a0), .Lfirst_fixup) /* make word/dword aligned */
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
|
|
|
#ifdef __MIPSEL__
|
2008-01-29 03:14:59 -07:00
|
|
|
EX(LONG_S_R, a1, (a0), .Lfirst_fixup) /* make word/dword aligned */
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
|
|
|
PTR_SUBU a0, t0 /* long align ptr */
|
|
|
|
PTR_ADDU a2, t0 /* correct size */
|
|
|
|
|
|
|
|
1: ori t1, a2, 0x3f /* # of full blocks */
|
|
|
|
xori t1, 0x3f
|
2008-01-29 03:14:59 -07:00
|
|
|
beqz t1, .Lmemset_partial /* no block to fill */
|
2006-12-17 08:07:40 -07:00
|
|
|
andi t0, a2, 0x40-LONGSIZE
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
PTR_ADDU t1, a0 /* end address */
|
|
|
|
.set reorder
|
|
|
|
1: PTR_ADDIU a0, 64
|
2007-11-25 03:47:56 -07:00
|
|
|
R10KCBARRIER(0(ra))
|
2008-01-29 03:14:59 -07:00
|
|
|
f_fill64 a0, -64, a1, .Lfwd_fixup
|
2005-04-16 16:20:36 -06:00
|
|
|
bne t1, a0, 1b
|
|
|
|
.set noreorder
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Lmemset_partial:
|
2007-11-25 03:47:56 -07:00
|
|
|
R10KCBARRIER(0(ra))
|
2005-04-16 16:20:36 -06:00
|
|
|
PTR_LA t1, 2f /* where to start */
|
2006-12-17 08:07:40 -07:00
|
|
|
#if LONGSIZE == 4
|
2005-04-16 16:20:36 -06:00
|
|
|
PTR_SUBU t1, t0
|
2006-12-17 08:07:40 -07:00
|
|
|
#else
|
|
|
|
.set noat
|
|
|
|
LONG_SRL AT, t0, 1
|
|
|
|
PTR_SUBU t1, AT
|
2007-10-23 05:43:25 -06:00
|
|
|
.set at
|
2006-12-17 08:07:40 -07:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
jr t1
|
|
|
|
PTR_ADDU a0, t0 /* dest ptr */
|
|
|
|
|
|
|
|
.set push
|
|
|
|
.set noreorder
|
|
|
|
.set nomacro
|
2008-01-29 03:14:59 -07:00
|
|
|
f_fill64 a0, -64, a1, .Lpartial_fixup /* ... but first do longs ... */
|
2005-04-16 16:20:36 -06:00
|
|
|
2: .set pop
|
|
|
|
andi a2, LONGMASK /* At most one long to go */
|
|
|
|
|
|
|
|
beqz a2, 1f
|
|
|
|
PTR_ADDU a0, a2 /* What's left */
|
2007-11-25 03:47:56 -07:00
|
|
|
R10KCBARRIER(0(ra))
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef __MIPSEB__
|
2008-01-29 03:14:59 -07:00
|
|
|
EX(LONG_S_R, a1, -1(a0), .Llast_fixup)
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
|
|
|
#ifdef __MIPSEL__
|
2008-01-29 03:14:59 -07:00
|
|
|
EX(LONG_S_L, a1, -1(a0), .Llast_fixup)
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
|
|
|
1: jr ra
|
|
|
|
move a2, zero
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Lsmall_memset:
|
2005-04-16 16:20:36 -06:00
|
|
|
beqz a2, 2f
|
|
|
|
PTR_ADDU t1, a0, a2
|
|
|
|
|
|
|
|
1: PTR_ADDIU a0, 1 /* fill bytewise */
|
2007-11-25 03:47:56 -07:00
|
|
|
R10KCBARRIER(0(ra))
|
2005-04-16 16:20:36 -06:00
|
|
|
bne t1, a0, 1b
|
|
|
|
sb a1, -1(a0)
|
|
|
|
|
|
|
|
2: jr ra /* done */
|
|
|
|
move a2, zero
|
|
|
|
END(memset)
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Lfirst_fixup:
|
2005-04-16 16:20:36 -06:00
|
|
|
jr ra
|
|
|
|
nop
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Lfwd_fixup:
|
2005-04-16 16:20:36 -06:00
|
|
|
PTR_L t0, TI_TASK($28)
|
|
|
|
LONG_L t0, THREAD_BUADDR(t0)
|
|
|
|
andi a2, 0x3f
|
|
|
|
LONG_ADDU a2, t1
|
|
|
|
jr ra
|
|
|
|
LONG_SUBU a2, t0
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Lpartial_fixup:
|
2005-04-16 16:20:36 -06:00
|
|
|
PTR_L t0, TI_TASK($28)
|
|
|
|
LONG_L t0, THREAD_BUADDR(t0)
|
|
|
|
andi a2, LONGMASK
|
|
|
|
LONG_ADDU a2, t1
|
|
|
|
jr ra
|
|
|
|
LONG_SUBU a2, t0
|
|
|
|
|
2008-01-29 03:14:59 -07:00
|
|
|
.Llast_fixup:
|
2005-04-16 16:20:36 -06:00
|
|
|
jr ra
|
|
|
|
andi v1, a2, LONGMASK
|