2008-04-28 11:47:20 +04:00
/ * SunOS' s e x e c v ( ) c a l l o n l y s p e c i f i e s t h e a r g v a r g u m e n t , t h e
* environment s e t t i n g s a r e t h e s a m e a s t h e c a l l i n g p r o c e s s e s .
* /
2012-09-27 03:44:26 +04:00
sys64_execve :
set s y s _ e x e c v e , % g 1
jmpl % g 1 , % g 0
flushw
2008-04-28 11:47:20 +04:00
# ifdef C O N F I G _ C O M P A T
sunos_execv :
2012-09-27 03:44:26 +04:00
mov % g 0 , % o 2
2008-04-28 11:47:20 +04:00
sys32_execve :
2012-09-27 03:44:26 +04:00
set c o m p a t _ s y s _ e x e c v e , % g 1
2008-04-28 11:47:20 +04:00
jmpl % g 1 , % g 0
2012-09-27 03:44:26 +04:00
flushw
# endif
2008-04-28 11:47:20 +04:00
.align 32
2009-01-14 16:13:56 +03:00
sys_sparc_pipe :
2009-01-20 08:11:27 +03:00
ba,p t % x c c , s y s _ s p a r c _ p i p e _ r e a l
2008-04-28 11:47:20 +04:00
add % s p , P T R E G S _ O F F , % o 0
sys_nis_syscall :
ba,p t % x c c , c _ s y s _ n i s _ s y s c a l l
add % s p , P T R E G S _ O F F , % o 0
sys_memory_ordering :
ba,p t % x c c , s p a r c _ m e m o r y _ o r d e r i n g
add % s p , P T R E G S _ O F F , % o 1
# ifdef C O N F I G _ C O M P A T
sys32_sigstack :
ba,p t % x c c , d o _ s y s32 _ s i g s t a c k
mov % i 6 , % o 2
# endif
.align 32
# ifdef C O N F I G _ C O M P A T
sys32_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ s i g r e t u r n 3 2
add % o 7 , 1 f - . - 4 , % o 7
nop
# endif
sys_rt_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ r t _ s i g r e t u r n
add % o 7 , 1 f - . - 4 , % o 7
nop
# ifdef C O N F I G _ C O M P A T
sys32_rt_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ r t _ s i g r e t u r n 3 2
add % o 7 , 1 f - . - 4 , % o 7
nop
# endif
.align 32
1 : ldx [ % g 6 + T I _ F L A G S ] , % l 5
2013-09-14 16:02:11 +04:00
andcc % l 5 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S Y S C A L L _ T R A C E P O I N T | _ T I F _ N O H Z ) , % g 0
2008-04-28 11:47:20 +04:00
be,p t % i c c , r t r a p
nop
2008-08-25 07:10:23 +04:00
call s y s c a l l _ t r a c e _ l e a v e
add % s p , P T R E G S _ O F F , % o 0
2008-04-28 11:47:20 +04:00
ba,p t % x c c , r t r a p
nop
/ * This i s h o w f o r k ( ) w a s m e a n t t o b e d o n e , 8 i n s t r u c t i o n e n t r y .
*
* I q u e s t i o n e d t h e f o l l o w i n g c o d e b r i e f l y , l e t m e c l e a r t h i n g s
* up s o y o u m u s t n o t r e a s o n o n i t l i k e I d i d .
*
* Know t h e f o r k _ k p s r e t c . w e u s e i n t h e s p a r c32 p o r t ? W e d o n ' t
* need i t h e r e b e c a u s e t h e o n l y p i e c e o f w i n d o w s t a t e w e c o p y t o
* the c h i l d i s t h e C W P r e g i s t e r . E v e n i f t h e p a r e n t s l e e p s ,
* we a r e s a f e b e c a u s e w e s t u c k i t i n t o p t _ r e g s o f t h e p a r e n t
* so i t w i l l n o t c h a n g e .
*
* XXX T h i s r a i s e s t h e q u e s t i o n , w h e t h e r w e c a n d o t h e s a m e o n
* XXX s p a r c32 t o g e t r i d o f f o r k _ k p s r _ a n d _ f o r k _ k w i m . T h e
* XXX a n s w e r i s y e s . W e s t i c k f o r k _ k p s r i n U R E G _ G 0 a n d
* XXX f o r k _ k w i m i n U R E G _ G 1 ( g l o b a l r e g i s t e r s a r e c o n s i d e r e d
* XXX v o l a t i l e a c r o s s a s y s t e m c a l l i n t h e s p a r c A B I I t h i n k
* XXX i f i t i s n ' t w e c a n u s e r e g s - > y i n s t e a d , a n y o n e w h o d e p e n d s
* XXX u p o n t h e Y r e g i s t e r b e i n g p r e s e r v e d a c r o s s a f o r k d e s e r v e s
* XXX t o l o s e ) .
*
* In f a c t w e s h o u l d t a k e a d v a n t a g e o f t h a t f a c t f o r o t h e r t h i n g s
* during s y s t e m c a l l s . . .
* /
.align 32
sys_vfork : /* Under Linux, vfork and fork are just special cases of clone. */
sethi % h i ( 0 x40 0 0 | 0 x01 0 0 | S I G C H L D ) , % o 0
or % o 0 , % l o ( 0 x40 0 0 | 0 x01 0 0 | S I G C H L D ) , % o 0
ba,p t % x c c , s y s _ c l o n e
sys_fork :
clr % o 1
mov S I G C H L D , % o 0
sys_clone :
flushw
movrz % o 1 , % f p , % o 1
mov 0 , % o 3
ba,p t % x c c , s p a r c _ d o _ f o r k
add % s p , P T R E G S _ O F F , % o 2
2013-07-26 16:42:39 +04:00
.globl ret_from_fork
ret_from_fork :
2010-03-03 19:08:49 +03:00
/* Clear current_thread_info()->new_child. */
2008-04-28 11:47:20 +04:00
stb % g 0 , [ % g 6 + T I _ N E W _ C H I L D ]
call s c h e d u l e _ t a i l
mov % g 7 , % o 0
2012-10-06 06:37:01 +04:00
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ] , % o 0
2012-09-27 03:28:00 +04:00
brnz,p t % o 0 , r e t _ s y s _ c a l l
2012-10-06 06:37:01 +04:00
ldx [ % g 6 + T I _ F L A G S ] , % l 0
2012-09-27 03:28:00 +04:00
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 1 ] , % l 1
call % l 1
2012-10-06 06:37:01 +04:00
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 2 ] , % o 0
2010-03-03 19:08:49 +03:00
ba,p t % x c c , r e t _ s y s _ c a l l
2012-09-27 03:28:00 +04:00
mov 0 , % o 0
2008-04-28 11:47:20 +04:00
2012-12-03 23:17:57 +04:00
.globl sparc_exit_group
.type sparc_ e x i t _ g r o u p ,#f u n c t i o n
sparc_exit_group :
sethi % h i ( s y s _ e x i t _ g r o u p ) , % g 7
ba,p t % x c c , 1 f
or % g 7 , % l o ( s y s _ e x i t _ g r o u p ) , % g 7
.size sparc_ e x i t _ g r o u p ,. - s p a r c _ e x i t _ g r o u p
2008-04-28 11:47:20 +04:00
.globl sparc_exit
.type sparc_ e x i t ,#f u n c t i o n
sparc_exit :
2012-12-03 23:17:57 +04:00
sethi % h i ( s y s _ e x i t ) , % g 7
or % g 7 , % l o ( s y s _ e x i t ) , % g 7
1 : rdpr % p s t a t e , % g 2
2008-04-28 11:47:20 +04:00
wrpr % g 2 , P S T A T E _ I E , % p s t a t e
rdpr % o t h e r w i n , % g 1
rdpr % c a n s a v e , % g 3
add % g 3 , % g 1 , % g 3
wrpr % g 3 , 0 x0 , % c a n s a v e
wrpr % g 0 , 0 x0 , % o t h e r w i n
wrpr % g 2 , 0 x0 , % p s t a t e
2012-12-03 23:17:57 +04:00
jmpl % g 7 , % g 0
2008-04-28 11:47:20 +04:00
stb % g 0 , [ % g 6 + T I _ W S A V E D ]
.size sparc_ e x i t ,. - s p a r c _ e x i t
linux_sparc_ni_syscall :
sethi % h i ( s y s _ n i _ s y s c a l l ) , % l 7
ba,p t % x c c , 4 f
or % l 7 , % l o ( s y s _ n i _ s y s c a l l ) , % l 7
linux_syscall_trace32 :
2008-08-25 07:10:23 +04:00
call s y s c a l l _ t r a c e _ e n t e r
add % s p , P T R E G S _ O F F , % o 0
2008-07-27 11:30:50 +04:00
brnz,p n % o 0 , 3 f
mov - E N O S Y S , % o 0
2008-04-28 11:47:20 +04:00
srl % i 0 , 0 , % o 0
srl % i 4 , 0 , % o 4
srl % i 1 , 0 , % o 1
srl % i 2 , 0 , % o 2
2013-07-26 17:21:12 +04:00
ba,p t % x c c , 5 f
2008-04-28 11:47:20 +04:00
srl % i 3 , 0 , % o 3
linux_syscall_trace :
2008-08-25 07:10:23 +04:00
call s y s c a l l _ t r a c e _ e n t e r
add % s p , P T R E G S _ O F F , % o 0
2008-07-27 11:30:50 +04:00
brnz,p n % o 0 , 3 f
mov - E N O S Y S , % o 0
2008-04-28 11:47:20 +04:00
mov % i 0 , % o 0
mov % i 1 , % o 1
mov % i 2 , % o 2
mov % i 3 , % o 3
b,p t % x c c , 2 f
mov % i 4 , % o 4
/* Linux 32-bit system calls enter here... */
.align 32
.globl linux_sparc_syscall32
linux_sparc_syscall32 :
/* Direct access to user regs, much faster. */
2009-12-11 11:44:47 +03:00
cmp % g 1 , N R _ s y s c a l l s ! I E U 1 G r o u p
2008-04-28 11:47:20 +04:00
bgeu,p n % x c c , l i n u x _ s p a r c _ n i _ s y s c a l l ! C T I
srl % i 0 , 0 , % o 0 ! I E U 0
sll % g 1 , 2 , % l 4 ! I E U 0 G r o u p
srl % i 4 , 0 , % o 4 ! I E U 1
lduw [ % l 7 + % l 4 ] , % l 7 ! L o a d
srl % i 1 , 0 , % o 1 ! I E U 0 G r o u p
ldx [ % g 6 + T I _ F L A G S ] , % l 0 ! L o a d
2013-07-26 17:21:12 +04:00
srl % i 3 , 0 , % o 3 ! I E U 0
2008-04-28 11:47:20 +04:00
srl % i 2 , 0 , % o 2 ! I E U 0 G r o u p
2013-09-14 16:02:11 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S Y S C A L L _ T R A C E P O I N T | _ T I F _ N O H Z ) , % g 0
2008-04-28 11:47:20 +04:00
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e 3 2 ! C T I
mov % i 0 , % l 5 ! I E U 1
2013-07-26 17:21:12 +04:00
5 : call % l 7 ! C T I G r o u p b r k f o r c e d
srl % i 5 , 0 , % o 5 ! I E U 1
2014-03-14 19:42:01 +04:00
ba,p t % x c c , 3 f
sra % o 0 , 0 , % o 0
2008-04-28 11:47:20 +04:00
/* Linux native system calls enter here... */
.align 32
.globl linux_sparc_syscall
linux_sparc_syscall :
/* Direct access to user regs, much faster. */
2009-12-11 11:44:47 +03:00
cmp % g 1 , N R _ s y s c a l l s ! I E U 1 G r o u p
2008-04-28 11:47:20 +04:00
bgeu,p n % x c c , l i n u x _ s p a r c _ n i _ s y s c a l l ! C T I
mov % i 0 , % o 0 ! I E U 0
sll % g 1 , 2 , % l 4 ! I E U 0 G r o u p
mov % i 1 , % o 1 ! I E U 1
lduw [ % l 7 + % l 4 ] , % l 7 ! L o a d
4 : mov % i 2 , % o 2 ! I E U 0 G r o u p
ldx [ % g 6 + T I _ F L A G S ] , % l 0 ! L o a d
mov % i 3 , % o 3 ! I E U 1
mov % i 4 , % o 4 ! I E U 0 G r o u p
2013-09-14 16:02:11 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S Y S C A L L _ T R A C E P O I N T | _ T I F _ N O H Z ) , % g 0
2008-04-28 11:47:20 +04:00
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e ! C T I G r o u p
mov % i 0 , % l 5 ! I E U 0
2 : call % l 7 ! C T I G r o u p b r k f o r c e d
mov % i 5 , % o 5 ! I E U 0
nop
3 : stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
ret_sys_call :
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ T S T A T E ] , % g 3
mov % u l o ( T S T A T E _ X C A R R Y | T S T A T E _ I C A R R Y ) , % g 2
sllx % g 2 , 3 2 , % g 2
cmp % o 0 , - E R E S T A R T _ R E S T A R T B L O C K
bgeu,p n % x c c , 1 f
2013-09-14 16:02:11 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S Y S C A L L _ T R A C E P O I N T | _ T I F _ N O H Z ) , % g 0
2012-10-11 04:25:00 +04:00
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ] , % l 1 ! p c = n p c
2 :
2008-04-28 11:47:20 +04:00
/* System call success, clear Carry condition code. */
andn % g 3 , % g 2 , % g 3
2012-10-11 04:25:00 +04:00
3 :
2008-04-28 11:47:20 +04:00
stx % g 3 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T S T A T E ]
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e 2
add % l 1 , 0 x4 , % l 2 ! n p c = n p c + 4
stx % l 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T P C ]
ba,p t % x c c , r t r a p
stx % l 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ]
1 :
2012-10-11 04:25:00 +04:00
/ * Check i f f o r c e _ s u c c e s s f u l _ s y s c a l l _ r e t u r n ( )
* was i n v o k e d .
* /
ldub [ % g 6 + T I _ S Y S _ N O E R R O R ] , % l 2
brnz,p n % l 2 , 2 b
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ] , % l 1 ! p c = n p c
2008-04-28 11:47:20 +04:00
/ * System c a l l f a i l u r e , s e t C a r r y c o n d i t i o n c o d e .
* Also, g e t a b s ( e r r n o ) t o r e t u r n t o t h e p r o c e s s .
* /
sub % g 0 , % o 0 , % o 0
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
2012-10-11 04:25:00 +04:00
ba,p t % x c c , 3 b
or % g 3 , % g 2 , % g 3
2008-04-28 11:47:20 +04:00
linux_syscall_trace2 :
2008-08-25 07:10:23 +04:00
call s y s c a l l _ t r a c e _ l e a v e
add % s p , P T R E G S _ O F F , % o 0
2008-04-28 11:47:20 +04:00
stx % l 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T P C ]
ba,p t % x c c , r t r a p
stx % l 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ]