2019-05-27 09:55:01 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2005-10-10 15:52:43 +04:00
/ *
* String h a n d l i n g f u n c t i o n s f o r P o w e r P C .
*
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
* /
# include < a s m / p r o c e s s o r . h >
# include < a s m / e r r n o . h >
# include < a s m / p p c _ a s m . h >
2016-01-14 07:33:46 +03:00
# include < a s m / e x p o r t . h >
2019-04-26 19:23:26 +03:00
# include < a s m / k a s a n . h >
2005-10-10 15:52:43 +04:00
2019-04-26 19:23:26 +03:00
# ifndef C O N F I G _ K A S A N
2017-03-27 22:37:40 +03:00
_ GLOBAL( _ _ m e m s e t 1 6 )
rlwimi r4 ,r4 ,1 6 ,0 ,1 5
/* fall through */
_ GLOBAL( _ _ m e m s e t 3 2 )
rldimi r4 ,r4 ,3 2 ,0
/* fall through */
_ GLOBAL( _ _ m e m s e t 6 4 )
neg r0 ,r3
andi. r0 ,r0 ,7
cmplw c r1 ,r5 ,r0
b . L m s
EXPORT_ S Y M B O L ( _ _ m e m s e t 1 6 )
EXPORT_ S Y M B O L ( _ _ m e m s e t 3 2 )
EXPORT_ S Y M B O L ( _ _ m e m s e t 6 4 )
2019-04-26 19:23:26 +03:00
# endif
2017-03-27 22:37:40 +03:00
2019-04-26 19:23:26 +03:00
_ GLOBAL_ K A S A N ( m e m s e t )
2005-10-10 15:52:43 +04:00
neg r0 ,r3
rlwimi r4 ,r4 ,8 ,1 6 ,2 3
andi. r0 ,r0 ,7 / * # b y t e s t o b e 8 - b y t e a l i g n e d * /
rlwimi r4 ,r4 ,1 6 ,0 ,1 5
cmplw c r1 ,r5 ,r0 / * d o w e g e t t h a t f a r ? * /
rldimi r4 ,r4 ,3 2 ,0
2017-03-27 22:37:40 +03:00
.Lms : PPC_ M T O C R F ( 1 ,r0 )
2005-10-10 15:52:43 +04:00
mr r6 ,r3
blt c r1 ,8 f
2018-08-21 04:04:12 +03:00
beq 3 f / * i f a l r e a d y 8 - b y t e a l i g n e d * /
2005-10-10 15:52:43 +04:00
subf r5 ,r0 ,r5
bf 3 1 ,1 f
stb r4 ,0 ( r6 )
addi r6 ,r6 ,1
1 : bf 3 0 ,2 f
sth r4 ,0 ( r6 )
addi r6 ,r6 ,2
2 : bf 2 9 ,3 f
stw r4 ,0 ( r6 )
addi r6 ,r6 ,4
3 : srdi. r0 ,r5 ,6
clrldi r5 ,r5 ,5 8
mtctr r0
beq 5 f
2016-08-04 09:53:22 +03:00
.balign 16
2005-10-10 15:52:43 +04:00
4 : std r4 ,0 ( r6 )
std r4 ,8 ( r6 )
std r4 ,1 6 ( r6 )
std r4 ,2 4 ( r6 )
std r4 ,3 2 ( r6 )
std r4 ,4 0 ( r6 )
std r4 ,4 8 ( r6 )
std r4 ,5 6 ( r6 )
addi r6 ,r6 ,6 4
bdnz 4 b
5 : srwi. r0 ,r5 ,3
clrlwi r5 ,r5 ,2 9
2012-04-18 06:21:52 +04:00
PPC_ M T O C R F ( 1 ,r0 )
2005-10-10 15:52:43 +04:00
beq 8 f
bf 2 9 ,6 f
std r4 ,0 ( r6 )
std r4 ,8 ( r6 )
std r4 ,1 6 ( r6 )
std r4 ,2 4 ( r6 )
addi r6 ,r6 ,3 2
6 : bf 3 0 ,7 f
std r4 ,0 ( r6 )
std r4 ,8 ( r6 )
addi r6 ,r6 ,1 6
7 : bf 3 1 ,8 f
std r4 ,0 ( r6 )
addi r6 ,r6 ,8
8 : cmpwi r5 ,0
2012-04-18 06:21:52 +04:00
PPC_ M T O C R F ( 1 ,r5 )
2018-08-21 04:04:12 +03:00
beqlr
2005-10-10 15:52:43 +04:00
bf 2 9 ,9 f
stw r4 ,0 ( r6 )
addi r6 ,r6 ,4
9 : bf 3 0 ,1 0 f
sth r4 ,0 ( r6 )
addi r6 ,r6 ,2
10 : bflr 3 1
stb r4 ,0 ( r6 )
blr
2016-01-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( m e m s e t )
2019-04-26 19:23:26 +03:00
EXPORT_ S Y M B O L _ K A S A N ( m e m s e t )
2005-10-10 15:52:43 +04:00
2019-04-26 19:23:26 +03:00
_ GLOBAL_ T O C _ K A S A N ( m e m m o v e )
2005-10-10 15:52:43 +04:00
cmplw 0 ,r3 ,r4
2014-02-04 09:04:35 +04:00
bgt b a c k w a r d s _ m e m c p y
b m e m c p y
2005-10-10 15:52:43 +04:00
_ GLOBAL( b a c k w a r d s _ m e m c p y )
rlwinm. r7 ,r5 ,3 2 - 3 ,3 ,3 1 / * r0 = r5 > > 3 * /
add r6 ,r3 ,r5
add r4 ,r4 ,r5
beq 2 f
andi. r0 ,r6 ,3
mtctr r7
bne 5 f
2016-08-04 09:53:22 +03:00
.balign 16
2005-10-10 15:52:43 +04:00
1 : lwz r7 ,- 4 ( r4 )
lwzu r8 ,- 8 ( r4 )
stw r7 ,- 4 ( r6 )
stwu r8 ,- 8 ( r6 )
bdnz 1 b
andi. r5 ,r5 ,7
2 : cmplwi 0 ,r5 ,4
blt 3 f
lwzu r0 ,- 4 ( r4 )
subi r5 ,r5 ,4
stwu r0 ,- 4 ( r6 )
3 : cmpwi 0 ,r5 ,0
beqlr
mtctr r5
4 : lbzu r0 ,- 1 ( r4 )
stbu r0 ,- 1 ( r6 )
bdnz 4 b
blr
5 : mtctr r0
6 : lbzu r7 ,- 1 ( r4 )
stbu r7 ,- 1 ( r6 )
bdnz 6 b
subf r5 ,r0 ,r5
rlwinm. r7 ,r5 ,3 2 - 3 ,3 ,3 1
beq 2 b
mtctr r7
b 1 b
2016-01-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( m e m m o v e )
2019-04-26 19:23:26 +03:00
EXPORT_ S Y M B O L _ K A S A N ( m e m m o v e )