2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2005-04-16 15:20:36 -07:00
/ *
* linux/ a r c h / a r m / l i b / c s u m p a r t i a l c o p y u s e r . S
*
* Copyright ( C ) 1 9 9 5 - 1 9 9 8 R u s s e l l K i n g
*
* 2 7 / 0 3 / 0 3 Ian M o l t o n C l e a n u p C O N F I G _ C P U
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
# include < a s m / e r r n o . h >
2005-09-09 21:08:59 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
.text
2015-08-19 20:40:41 +01:00
# ifdef C O N F I G _ C P U _ S W _ D O M A I N _ P A N
.macro save_regs
mrc p15 , 0 , i p , c3 , c0 , 0
stmfd s p ! , { r1 , r2 , r4 - r8 , i p , l r }
uaccess_ e n a b l e i p
.endm
.macro load_regs
ldmfd s p ! , { r1 , r2 , r4 - r8 , i p , l r }
mcr p15 , 0 , i p , c3 , c0 , 0
ret l r
.endm
# else
2005-04-16 15:20:36 -07:00
.macro save_regs
2008-08-29 18:31:27 +01:00
stmfd s p ! , { r1 , r2 , r4 - r8 , l r }
2005-04-16 15:20:36 -07:00
.endm
2006-01-12 16:53:51 +00:00
.macro load_regs
2008-08-29 18:31:27 +01:00
ldmfd s p ! , { r1 , r2 , r4 - r8 , p c }
2005-04-16 15:20:36 -07:00
.endm
2015-08-19 20:40:41 +01:00
# endif
2005-04-16 15:20:36 -07:00
.macro load1 b , r e g 1
2009-07-24 12:32:57 +01:00
ldrusr \ r e g 1 , r0 , 1
2005-04-16 15:20:36 -07:00
.endm
.macro load2 b , r e g 1 , r e g 2
2009-07-24 12:32:57 +01:00
ldrusr \ r e g 1 , r0 , 1
ldrusr \ r e g 2 , r0 , 1
2005-04-16 15:20:36 -07:00
.endm
.macro load1 l , r e g 1
2009-07-24 12:32:57 +01:00
ldrusr \ r e g 1 , r0 , 4
2005-04-16 15:20:36 -07:00
.endm
.macro load2 l , r e g 1 , r e g 2
2009-07-24 12:32:57 +01:00
ldrusr \ r e g 1 , r0 , 4
ldrusr \ r e g 2 , r0 , 4
2005-04-16 15:20:36 -07:00
.endm
.macro load4 l , r e g 1 , r e g 2 , r e g 3 , r e g 4
2009-07-24 12:32:57 +01:00
ldrusr \ r e g 1 , r0 , 4
ldrusr \ r e g 2 , r0 , 4
ldrusr \ r e g 3 , r0 , 4
ldrusr \ r e g 4 , r0 , 4
2005-04-16 15:20:36 -07:00
.endm
/ *
* unsigned i n t
* csum_ p a r t i a l _ c o p y _ f r o m _ u s e r ( c o n s t c h a r * s r c , c h a r * d s t , i n t l e n , i n t s u m , i n t * e r r _ p t r )
* r0 = s r c , r1 = d s t , r2 = l e n , r3 = s u m , [ s p ] = * e r r _ p t r
* Returns : r0 = c h e c k s u m , [ [ s p , #0 ] , #0 ] = 0 o r - E F A U L T
* /
# define F N _ E N T R Y E N T R Y ( c s u m _ p a r t i a l _ c o p y _ f r o m _ u s e r )
2008-08-28 11:22:32 +01:00
# define F N _ E X I T E N D P R O C ( c s u m _ p a r t i a l _ c o p y _ f r o m _ u s e r )
2005-04-16 15:20:36 -07:00
# include " c s u m p a r t i a l c o p y g e n e r i c . S "
/ *
* FIXME : minor b u g l e t h e r e
* We d o n ' t r e t u r n t h e c h e c k s u m f o r t h e d a t a p r e s e n t i n t h e b u f f e r . T o d o
* so p r o p e r l y , w e w o u l d h a v e t o a d d i n w h a t e v e r r e g i s t e r s w e r e l o a d e d b e f o r e
* the f a u l t , w h i c h , w i t h t h e c u r r e n t a s m a b o v e i s n o t p r e d i c t a b l e .
* /
2015-03-24 10:41:09 +01:00
.pushsection .text .fixup , " ax"
2005-04-16 15:20:36 -07:00
.align 4
2009-07-24 12:32:57 +01:00
9001 : mov r4 , #- E F A U L T
2017-12-01 03:51:04 +01:00
# ifdef C O N F I G _ C P U _ S W _ D O M A I N _ P A N
ldr r5 , [ s p , #9 * 4 ] @ *err_ptr
# else
2010-07-26 12:18:16 +01:00
ldr r5 , [ s p , #8 * 4 ] @ *err_ptr
2017-12-01 03:51:04 +01:00
# endif
2005-04-16 15:20:36 -07:00
str r4 , [ r5 ]
ldmia s p , { r1 , r2 } @ retrieve dst, len
add r2 , r2 , r1
mov r0 , #0 @ zero the buffer
2009-07-24 12:32:57 +01:00
9002 : teq r2 , r1
2019-02-18 00:57:38 +01:00
strbne r0 , [ r1 ] , #1
2009-07-24 12:32:57 +01:00
bne 9 0 0 2 b
2006-01-12 16:53:51 +00:00
load_ r e g s
2010-04-19 10:15:03 +01:00
.popsection