Skip to content

Commit

Permalink
[MIPS] Unify memset.S
Browse files Browse the repository at this point in the history
The 32-bit version and 64-bit version are almost equal.  Unify them.
This makes further improvements (for example, supporting CDEX, etc.)
easier.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed Feb 6, 2007
1 parent c44e8d5 commit a583158
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 152 deletions.
2 changes: 1 addition & 1 deletion arch/mips/lib-32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for MIPS-specific library files..
#

lib-y += memset.o watch.o
lib-y += watch.o

obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/lib-64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for MIPS-specific library files..
#

lib-y += memset.o watch.o
lib-y += watch.o

obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
Expand Down
142 changes: 0 additions & 142 deletions arch/mips/lib-64/memset.S

This file was deleted.

2 changes: 1 addition & 1 deletion arch/mips/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for MIPS-specific library files..
#

lib-y += csum_partial.o memcpy.o promlib.o \
lib-y += csum_partial.o memcpy.o memset.o promlib.o \
strlen_user.o strncpy_user.o strnlen_user.o uncached.o

obj-y += iomap.o
Expand Down
35 changes: 28 additions & 7 deletions arch/mips/lib-32/memset.S → arch/mips/lib/memset.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include <asm/asm-offsets.h>
#include <asm/regdef.h>

#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

#define EX(insn,reg,addr,handler) \
9: insn reg, addr; \
.section __ex_table,"a"; \
Expand All @@ -25,6 +33,7 @@
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)
#if LONGSIZE == 4
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)
Expand All @@ -33,6 +42,7 @@
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)
#endif
.endm

/*
Expand All @@ -49,9 +59,13 @@ LEAF(memset)
move v0, a0 /* result */

andi a1, 0xff /* spread fillword */
sll t1, a1, 8
LONG_SLL t1, a1, 8
or a1, t1
sll t1, a1, 16
LONG_SLL t1, a1, 16
#if LONGSIZE == 8
or a1, t1
LONG_SLL t1, a1, 32
#endif
or a1, t1
1:

Expand All @@ -64,18 +78,18 @@ FEXPORT(__bzero)
PTR_SUBU t0, LONGSIZE /* alignment in bytes */

#ifdef __MIPSEB__
EX(swl, a1, (a0), first_fixup) /* make word aligned */
EX(LONG_S_L, a1, (a0), first_fixup) /* make word/dword aligned */
#endif
#ifdef __MIPSEL__
EX(swr, a1, (a0), first_fixup) /* make word aligned */
EX(LONG_S_R, a1, (a0), first_fixup) /* make word/dword aligned */
#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
beqz t1, memset_partial /* no block to fill */
andi t0, a2, 0x3c
andi t0, a2, 0x40-LONGSIZE

PTR_ADDU t1, a0 /* end address */
.set reorder
Expand All @@ -86,7 +100,14 @@ FEXPORT(__bzero)

memset_partial:
PTR_LA t1, 2f /* where to start */
#if LONGSIZE == 4
PTR_SUBU t1, t0
#else
.set noat
LONG_SRL AT, t0, 1
PTR_SUBU t1, AT
.set noat
#endif
jr t1
PTR_ADDU a0, t0 /* dest ptr */

Expand All @@ -100,10 +121,10 @@ memset_partial:
beqz a2, 1f
PTR_ADDU a0, a2 /* What's left */
#ifdef __MIPSEB__
EX(swr, a1, -1(a0), last_fixup)
EX(LONG_S_R, a1, -1(a0), last_fixup)
#endif
#ifdef __MIPSEL__
EX(swl, a1, -1(a0), last_fixup)
EX(LONG_S_L, a1, -1(a0), last_fixup)
#endif
1: jr ra
move a2, zero
Expand Down

0 comments on commit a583158

Please sign in to comment.