2005-04-16 15:20:36 -07:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( C ) 1 9 9 5 , 9 6 , 9 7 , 9 8 , 9 9 , 2 0 0 0 , 0 1 , 0 2 b y R a l f B a e c h l e
* Copyright ( C ) 1 9 9 9 , 2 0 0 0 S i l i c o n G r a p h i c s , I n c .
* Copyright ( C ) 2 0 0 1 M I P S T e c h n o l o g i e s , I n c .
* /
# include < l i n u x / e r r n o . h >
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
2006-07-07 14:07:18 +01:00
# include < a s m / i r q f l a g s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / m i p s r e g s . h >
# include < a s m / r e g d e f . h >
# include < a s m / s t a c k f r a m e . h >
2005-09-09 22:32:31 +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
# include < a s m / s y s m i p s . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / u n i s t d . h >
# include < a s m / w a r . h >
# ifndef C O N F I G _ B I N F M T _ E L F 3 2
/* Neither O32 nor N32, so define handle_sys here */
# define h a n d l e _ s y s64 h a n d l e _ s y s
# endif
2013-01-22 12:59:30 +01:00
.align 5
2005-04-16 15:20:36 -07:00
NESTED( h a n d l e _ s y s64 , P T _ S I Z E , s p )
# if ! d e f i n e d ( C O N F I G _ M I P S 3 2 _ O 3 2 ) & & ! d e f i n e d ( C O N F I G _ M I P S 3 2 _ N 3 2 )
/ *
* When 3 2 - b i t c o m p a t i b i l i t y i s c o n f i g u r e d s c a l l _ o 3 2 . S
* already d i d t h i s .
* /
.set noat
SAVE_ S O M E
2006-09-26 23:43:40 +09:00
TRACE_ I R Q S _ O N _ R E L O A D
2005-04-16 15:20:36 -07:00
STI
.set at
# endif
# if ! d e f i n e d ( C O N F I G _ M I P S 3 2 _ O 3 2 ) & & ! d e f i n e d ( C O N F I G _ M I P S 3 2 _ N 3 2 )
ld t 1 , P T _ E P C ( s p ) # s k i p s y s c a l l o n r e t u r n
daddiu t 1 , 4 # s k i p t o n e x t i n s t r u c t i o n
sd t 1 , P T _ E P C ( s p )
# endif
sd a3 , P T _ R 2 6 ( s p ) # s a v e a 3 f o r s y s c a l l r e s t a r t i n g
2013-05-29 01:02:18 +02:00
li t 1 , _ T I F _ W O R K _ S Y S C A L L _ E N T R Y
2005-04-16 15:20:36 -07:00
LONG_ L t 0 , T I _ F L A G S ( $ 2 8 ) # s y s c a l l t r a c i n g e n a b l e d ?
and t 0 , t 1 , t 0
bnez t 0 , s y s c a l l _ t r a c e _ e n t r y
2015-09-25 08:17:42 +01:00
syscall_common :
dsubu t 2 , v0 , _ _ N R _ 6 4 _ L i n u x
2018-12-13 14:37:36 +05:30
sltiu t 0 , t 2 , _ _ N R _ 6 4 _ L i n u x _ s y s c a l l s
2015-09-25 08:17:42 +01:00
beqz t 0 , i l l e g a l _ s y s c a l l
dsll t 0 , t 2 , 3 # o f f s e t i n t o t a b l e
dla t 2 , s y s _ c a l l _ t a b l e
daddu t 0 , t 2 , t 0
ld t 2 , ( t 0 ) # s y s c a l l r o u t i n e
beqz t 2 , i l l e g a l _ s y s c a l l
2005-04-16 15:20:36 -07:00
jalr t 2 # D o T h e R e a l T h i n g ( T M )
li t 0 , - E M A X E R R N O - 1 # e r r o r ?
sltu t 0 , t 0 , v0
sd t 0 , P T _ R 7 ( s p ) # s e t e r r o r f l a g
beqz t 0 , 1 f
2010-09-28 18:50:37 +01:00
ld t 1 , P T _ R 2 ( s p ) # s y s c a l l n u m b e r
2005-04-16 15:20:36 -07:00
dnegu v0 # e r r o r
2010-09-28 18:50:37 +01:00
sd t 1 , P T _ R 0 ( s p ) # s a v e i t f o r s y s c a l l r e s t a r t i n g
2005-04-16 15:20:36 -07:00
1 : sd v0 , P T _ R 2 ( s p ) # r e s u l t
n64_syscall_exit :
2012-05-05 16:11:35 -04:00
j s y s c a l l _ e x i t _ p a r t i a l
2005-04-16 15:20:36 -07:00
/* ------------------------------------------------------------------------ */
syscall_trace_entry :
SAVE_ S T A T I C
move a0 , s p
2015-08-13 08:47:59 +01:00
move a1 , v0
2011-05-19 09:21:29 +01:00
jal s y s c a l l _ t r a c e _ e n t e r
2005-04-16 15:20:36 -07:00
2015-09-25 08:17:42 +01:00
bltz v0 , 1 f # s e c c o m p f a i l e d ? S k i p s y s c a l l
2014-01-22 14:40:02 +00:00
2005-11-30 16:24:57 +00:00
RESTORE_ S T A T I C
2016-03-29 09:35:31 +01:00
ld v0 , P T _ R 2 ( s p ) # R e s t o r e s y s c a l l ( m a y b e m o d i f i e d )
2005-04-16 15:20:36 -07:00
ld a0 , P T _ R 4 ( s p ) # R e s t o r e a r g u m e n t r e g i s t e r s
ld a1 , P T _ R 5 ( s p )
ld a2 , P T _ R 6 ( s p )
ld a3 , P T _ R 7 ( s p )
ld a4 , P T _ R 8 ( s p )
ld a5 , P T _ R 9 ( s p )
2015-09-25 08:17:42 +01:00
j s y s c a l l _ c o m m o n
2005-04-16 15:20:36 -07:00
2015-09-25 08:17:42 +01:00
1 : j s y s c a l l _ e x i t
2005-04-16 15:20:36 -07:00
illegal_syscall :
/* This also isn't a 64-bit syscall, throw an error. */
2008-10-25 01:17:22 +09:00
li v0 , E N O S Y S # e r r o r
2005-04-16 15:20:36 -07:00
sd v0 , P T _ R 2 ( s p )
li t 0 , 1 # s e t e r r o r f l a g
sd t 0 , P T _ R 7 ( s p )
j n 6 4 _ s y s c a l l _ e x i t
END( h a n d l e _ s y s64 )
2019-01-02 20:26:17 +05:30
# define _ _ S Y S C A L L ( n r , e n t r y ) P T R e n t r y
2005-04-16 15:20:36 -07:00
.align 3
2012-07-12 14:06:46 +02:00
.type sys_ c a l l _ t a b l e , @object
EXPORT( s y s _ c a l l _ t a b l e )
2018-12-13 14:37:39 +05:30
# include < a s m / s y s c a l l _ t a b l e _ 6 4 _ n 6 4 . h >
# undef _ _ S Y S C A L L