2017-10-25 05:37:49 +03:00
/ / SPDX- L i c e n s e - I d e n t i f i e r : G P L - 2 . 0
/ / Copyright ( C ) 2 0 0 5 - 2 0 1 7 A n d e s T e c h n o l o g y C o r p o r a t i o n
# include < l i n u x / l i n k a g e . h >
# include < a s m / u n i s t d . h >
# include < a s m / a s s e m b l e r . h >
# include < a s m / n d s32 . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / c u r r e n t . h >
/ *
* $ r0 = p r e v i o u s t a s k _ s t r u c t ,
* $ r1 = n e x t t a s k _ s t r u c t ,
* previous a n d n e x t a r e g u a r a n t e e d n o t t o b e t h e s a m e .
* /
ENTRY( _ _ s w i t c h _ t o )
la $ p0 , _ _ e n t r y _ t a s k
sw $ r1 , [ $ p0 ]
2018-11-22 06:14:34 +03:00
addi $ p1 , $ r0 , #T H R E A D _ C P U _ C O N T E X T
2017-10-25 05:37:49 +03:00
smw. b i $ r6 , [ $ p1 ] , $ r14 , #0xb ! p u s h r6 ~ r14 , f p , l p , s p
move $ r25 , $ r1
2018-11-22 06:14:34 +03:00
# if d e f i n e d ( C O N F I G _ F P U )
call _ s w i t c h _ f p u
# endif
addi $ r1 , $ r25 , #T H R E A D _ C P U _ C O N T E X T
2017-10-25 05:37:49 +03:00
lmw. b i $ r6 , [ $ r1 ] , $ r14 , #0xb ! p o p r6 ~ r14 , f p , l p , s p
ret
# define t b l $ r8
/ *
* $ r7 w i l l b e w r i t e n a s s y s c a l l n r
* /
.macro get_scno
lwi $ r7 , [ $ s p + R 1 5 _ O F F S E T ]
swi $ r7 , [ $ s p + S Y S C A L L N O _ O F F S E T ]
.endm
.macro updateipc
addi $ r17 , $ r13 , #4 ! $ r13 i s $ I P C
swi $ r17 , [ $ s p + I P C _ O F F S E T ]
.endm
ENTRY( e h _ s y s c a l l )
updateipc
get_ s c n o
gie_ e n a b l e
lwi $ p0 , [ t s k + #T S K _ T I _ F L A G S ] ! c h e c k f o r s y s c a l l t r a c i n g
andi $ p1 , $ p0 , #_ T I F _ W O R K _ S Y S C A L L _ E N T R Y ! a r e w e t r a c i n g s y s c a l l s ?
bnez $ p1 , _ _ s y s _ t r a c e
la $ l p , r e t _ f a s t _ s y s c a l l ! r e t u r n a d d r e s s
jmp_systbl :
addi $ p1 , $ r7 , #- _ _ N R _ s y s c a l l s ! s y s c a l l n u m b e r o f s y s c a l l i n s t r u c t i o n i s g u a r d e d b y a d d e m b l e r
bgez $ p1 , _ S C N O _ E X C E E D ! c a l l s y s _ * r o u t i n e
la t b l , s y s _ c a l l _ t a b l e ! l o a d s y s c a l l t a b l e p o i n t e r
slli $ p1 , $ r7 , #2
add $ p1 , t b l , $ p1
lwi $ p1 , [ $ p1 ]
jr $ p1 ! n o r e t u r n
_SCNO_EXCEED :
ori $ r0 , $ r7 , #0
ori $ r1 , $ s p , #0
b b a d _ s y s c a l l
/ *
* This i s t h e r e a l l y s l o w p a t h . W e ' r e g o i n g t o b e d o i n g
* context s w i t c h e s , a n d w a i t i n g f o r o u r p a r e n t t o r e s p o n d .
* /
__sys_trace :
move $ r0 , $ s p
bal s y s c a l l _ t r a c e _ e n t e r
move $ r7 , $ r0
la $ l p , _ _ s y s _ t r a c e _ r e t u r n ! r e t u r n a d d r e s s
addi $ p1 , $ r7 , #1
beqz $ p1 , r e t _ s l o w _ s y s c a l l ! f a t a l s i g n a l i s p e n d i n g
addi $ p1 , $ s p , #R 0 _ O F F S E T ! p o i n t e r t o r e g s
lmw. b i $ r0 , [ $ p1 ] , $ r5 ! h a v e t o r e l o a d $ r0 - $ r5
b j m p _ s y s t b l
__sys_trace_return :
swi $ r0 , [ $ s p + #R 0 _ O F F S E T ] ! T : s a v e r e t u r n e d $ r0
move $ r0 , $ s p ! s e t p t _ r e g s f o r s y s c a l l _ t r a c e _ l e a v e
bal s y s c a l l _ t r a c e _ l e a v e
b r e t _ s l o w _ s y s c a l l
ENTRY( s y s _ r t _ s i g r e t u r n _ w r a p p e r )
addi $ r0 , $ s p , #0
b s y s _ r t _ s i g r e t u r n
ENDPROC( s y s _ r t _ s i g r e t u r n _ w r a p p e r )