2005-04-16 15:20:36 -07:00
/ *
* Linux/ P A R I S C P r o j e c t ( h t t p : / / w w w . p a r i s c - l i n u x . o r g / )
*
* HP- U X S y s t e m C a l l W r a p p e r r o u t i n e s a n d S y s t e m C a l l R e t u r n P a t h
*
* Copyright ( C ) 2 0 0 0 H e w l e t t - P a c k a r d ( J o h n M a r v i n )
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d b y
* the F r e e S o f t w a r e F o u n d a t i o n ; either version 2, or (at your option)
* any l a t e r v e r s i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 6 7 5 M a s s A v e , C a m b r i d g e , M A 0 2 1 3 9 , U S A .
* /
2007-01-28 16:43:32 +01:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-16 15:20:36 -07:00
# warning P A 6 4 s u p p o r t n e e d s m o r e w o r k . . . d i d f i r s t c u t
# endif
2005-09-09 20:57:26 +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 / a s s e m b l y . h >
# include < a s m / s i g n a l . h >
2007-01-28 16:43:32 +01:00
# include < l i n u x / l i n k a g e . h >
2005-04-16 15:20:36 -07:00
2007-01-28 16:43:32 +01:00
.level LEVEL
2008-05-22 14:36:31 -04:00
.text
2005-04-16 15:20:36 -07:00
/ * These s h o u l d p r o b a b l y g o i n a h e a d e r f i l e s o m e w h e r e .
* They a r e d u p l i c a t e d i n k e r n e l / w r a p p e r s . S
* Possibly w e s h o u l d c o n s i d e r c o n s o l i d a t i n g t h e s e
* register s a v e / r e s t o r e m a c r o s .
* /
.macro reg_save regs
2007-01-28 16:43:32 +01:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-16 15:20:36 -07:00
# warning N E E D S W O R K f o r 6 4 - b i t
# endif
STREG % r3 , P T _ G R 3 ( \ r e g s )
STREG % r4 , P T _ G R 4 ( \ r e g s )
STREG % r5 , P T _ G R 5 ( \ r e g s )
STREG % r6 , P T _ G R 6 ( \ r e g s )
STREG % r7 , P T _ G R 7 ( \ r e g s )
STREG % r8 , P T _ G R 8 ( \ r e g s )
STREG % r9 , P T _ G R 9 ( \ r e g s )
STREG % r10 ,P T _ G R 1 0 ( \ r e g s )
STREG % r11 ,P T _ G R 1 1 ( \ r e g s )
STREG % r12 ,P T _ G R 1 2 ( \ r e g s )
STREG % r13 ,P T _ G R 1 3 ( \ r e g s )
STREG % r14 ,P T _ G R 1 4 ( \ r e g s )
STREG % r15 ,P T _ G R 1 5 ( \ r e g s )
STREG % r16 ,P T _ G R 1 6 ( \ r e g s )
STREG % r17 ,P T _ G R 1 7 ( \ r e g s )
STREG % r18 ,P T _ G R 1 8 ( \ r e g s )
.endm
.macro reg_restore regs
LDREG P T _ G R 3 ( \ r e g s ) , % r3
LDREG P T _ G R 4 ( \ r e g s ) , % r4
LDREG P T _ G R 5 ( \ r e g s ) , % r5
LDREG P T _ G R 6 ( \ r e g s ) , % r6
LDREG P T _ G R 7 ( \ r e g s ) , % r7
LDREG P T _ G R 8 ( \ r e g s ) , % r8
LDREG P T _ G R 9 ( \ r e g s ) , % r9
LDREG P T _ G R 1 0 ( \ r e g s ) ,% r10
LDREG P T _ G R 1 1 ( \ r e g s ) ,% r11
LDREG P T _ G R 1 2 ( \ r e g s ) ,% r12
LDREG P T _ G R 1 3 ( \ r e g s ) ,% r13
LDREG P T _ G R 1 4 ( \ r e g s ) ,% r14
LDREG P T _ G R 1 5 ( \ r e g s ) ,% r15
LDREG P T _ G R 1 6 ( \ r e g s ) ,% r16
LDREG P T _ G R 1 7 ( \ r e g s ) ,% r17
LDREG P T _ G R 1 8 ( \ r e g s ) ,% r18
.endm
.import sys_fork
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ f o r k _ w r a p p e r )
2005-04-16 15:20:36 -07:00
ldo T A S K _ R E G S - T A S K _ S Z _ A L G N - 6 4 ( % r30 ) ,% r1 ;! get pt regs
;! pointer in task
reg_ s a v e % r1
STREG % r2 ,- 2 0 ( % r30 )
ldo 6 4 ( % r30 ) ,% r30
STREG % r2 ,P T _ G R 1 9 ( % r1 ) ;! save for child
STREG % r30 ,P T _ G R 2 1 ( % r1 ) ;! save for child
LDREG P T _ G R 3 0 ( % r1 ) ,% r25
mtctl % r25 ,% c r29
copy % r1 ,% r24
bl s y s _ c l o n e ,% r2
ldi S I G C H L D ,% r26
LDREG - 8 4 ( % r30 ) ,% r2
fork_return :
ldo - 6 4 ( % r30 ) ,% r30
ldo T A S K _ R E G S - T A S K _ S Z _ A L G N - 6 4 ( % r30 ) ,% r1 ;! get pt regs
reg_ r e s t o r e % r1
/ *
* HP- U X w a n t s p i d ( c h i l d g e t s p a r e n t p i d , p a r e n t g e t s c h i l d p i d )
* in r28 a n d a f l a g i n r29 ( r29 = = 1 f o r c h i l d , 0 f o r p a r e n t ) .
* Linux f o r k r e t u r n s 0 f o r c h i l d , p i d f o r p a r e n t . S i n c e H P - U X
* libc s t u b t h r o w s a w a y p a r e n t p i d a n d r e t u r n s 0 f o r c h i l d ,
* we' l l j u s t r e t u r n 0 f o r p a r e n t p i d n o w . O n l y a p p l i c a t i o n s
* that j u m p d i r e c t l y t o t h e g a t e w a y p a g e ( n o t s u p p o r t e d ) w i l l
* know t h e d i f f e r e n c e . W e c a n f i x t h i s l a t e r i f n e c e s s a r y .
* /
ldo - 1 0 2 4 ( % r0 ) ,% r1
comb,> > = ,n % r28 ,% r1 ,f o r k _ e x i t / * j u s t l e t t h e s y s c a l l e x i t h a n d l e i t * /
or,= % r28 ,% r0 ,% r0
or,t r % r0 ,% r0 ,% r29 / * r28 < > 0 , w e a r e p a r e n t , s e t r29 t o 0 * /
ldo 1 ( % r0 ) ,% r29 / * r28 = = 0 , w e a r e c h i l d , s e t r29 t o 1 * /
fork_exit :
bv % r0 ( % r2 )
nop
2007-01-28 16:43:32 +01:00
ENDPROC( h p u x _ f o r k _ w r a p p e r )
2005-04-16 15:20:36 -07:00
/* Set the return value for the child */
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ c h i l d _ r e t u r n )
2005-04-16 15:20:36 -07:00
# if d e f i n e d ( C O N F I G _ S M P ) | | d e f i n e d ( C O N F I G _ P R E E M P T )
2007-01-28 16:43:32 +01:00
bl,n s c h e d u l e _ t a i l , % r2
2005-04-16 15:20:36 -07:00
# endif
LDREG T A S K _ P T _ G R 1 9 - T A S K _ S Z _ A L G N - 1 2 8 ( % r30 ) ,% r2
b f o r k _ r e t u r n
copy % r0 ,% r28
2007-01-28 16:43:32 +01:00
ENDPROC( h p u x _ c h i l d _ r e t u r n )
2005-04-16 15:20:36 -07:00
.import hpux_execve
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ e x e c v _ w r a p p e r )
2005-04-16 15:20:36 -07:00
copy % r0 ,% r24 / * N U L L e n v i r o n m e n t * /
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ e x e c v e _ w r a p p e r )
2005-04-16 15:20:36 -07:00
ldo T A S K _ R E G S - T A S K _ S Z _ A L G N - 6 4 ( % r30 ) ,% r1 ;! get pt regs
/ *
* Do w e n e e d t o s a v e / r e s t o r e r3 - r18 h e r e ?
* I d o n ' t t h i n k s o . w h y w o u l d n e w t h r e a d n e e d o l d
* threads r e g i s t e r s ?
* /
/* Store arg0, arg1 and arg2 so that hpux_execve will find them */
STREG % r26 ,P T _ G R 2 6 ( % r1 )
STREG % r25 ,P T _ G R 2 5 ( % r1 )
STREG % r24 ,P T _ G R 2 4 ( % r1 )
STREG % r2 ,- 2 0 ( % r30 )
ldo 6 4 ( % r30 ) ,% r30
bl h p u x _ e x e c v e ,% r2
copy % r1 ,% a r g 0
ldo - 6 4 ( % r30 ) ,% r30
LDREG - 2 0 ( % r30 ) ,% r2
/* If exec succeeded we need to load the args */
ldo - 1 0 2 4 ( % r0 ) ,% r1
comb,> > = % r28 ,% r1 ,e x e c _ e r r o r
copy % r2 ,% r19
ldo - T A S K _ S Z _ A L G N - 6 4 ( % r30 ) ,% r1 ;! get task ptr
LDREG T A S K _ P T _ G R 2 6 ( % r1 ) ,% r26
LDREG T A S K _ P T _ G R 2 5 ( % r1 ) ,% r25
LDREG T A S K _ P T _ G R 2 4 ( % r1 ) ,% r24
LDREG T A S K _ P T _ G R 2 3 ( % r1 ) ,% r23
copy % r0 ,% r2 / * F l a g t o s y s c a l l _ e x i t n o t t o c l e a r a r g s * /
exec_error :
bv % r0 ( % r19 )
nop
2007-01-28 16:43:32 +01:00
ENDPROC( h p u x _ e x e c v _ w r a p p e r )
2005-04-16 15:20:36 -07:00
.import hpux_pipe
/* HP-UX expects pipefd's returned in r28 & r29 */
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ p i p e _ w r a p p e r )
2005-04-16 15:20:36 -07:00
STREG % r2 ,- 2 0 ( % r30 )
ldo 6 4 ( % r30 ) ,% r30
bl h p u x _ p i p e ,% r2
ldo - 5 6 ( % r30 ) ,% r26 / * p a s s l o c a l a r r a y t o h p u x _ p i p e * /
ldo - 1 0 2 4 ( % r0 ) ,% r1
comb,> > = % r28 ,% r1 ,p i p e _ e x i t / * l e t s y s c a l l e x i t h a n d l e i t * /
LDREG - 8 4 ( % r30 ) ,% r2
/* if success, load fd's from stack array */
LDREG - 5 6 ( % r30 ) ,% r28
LDREG - 5 2 ( % r30 ) ,% r29
pipe_exit :
bv % r0 ( % r2 )
ldo - 6 4 ( % r30 ) ,% r30
2007-01-28 16:43:32 +01:00
ENDPROC( h p u x _ p i p e _ w r a p p e r )
2005-04-16 15:20:36 -07:00
.import syscall_exit
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ s y s c a l l _ e x i t )
2005-04-16 15:20:36 -07:00
/ *
*
* HP- U X c a l l r e t u r n c o n v e n t i o n s :
*
* if e r r o r :
* r2 2 = 1
* r2 8 = e r r n o v a l u e
* r2 9 = s e c o n d a r y r e t u r n v a l u e
* else
* r2 2 = 0
* r2 8 = r e t u r n v a l u e
* r2 9 = s e c o n d a r y r e t u r n v a l u e
*
* For n o w , w e ' l l j u s t c h e c k t o s e e i f r28 i s < ( u n s i g n e d l o n g ) - 1 0 2 4
* ( to h a n d l e a d d r e s s e s > 2 G b ) a n d i f s o s e t r22 t o z e r o . I f n o t ,
* we' l l c o m p l e m e n t r28 a n d s e t r22 t o 1 . W r a p p e r s w i l l b e
* needed f o r s y s c a l l s t h a t c a r e a b o u t t h e s e c o n d a r y r e t u r n v a l u e .
* The w r a p p e r m a y a l s o n e e d a w a y o f a v o i d i n g t h e f o l l o w i n g c o d e ,
* but w e ' l l d e a l w i t h t h a t w h e n i t b e c o m e s n e c e s s a r y .
* /
ldo - 1 0 2 4 ( % r0 ) ,% r1
comb,< < % r28 ,% r1 ,n o _ e r r o r
copy % r0 ,% r22
subi 0 ,% r28 ,% r28
ldo 1 ( % r0 ) ,% r22
no_error :
2007-01-28 16:43:32 +01:00
b,n s y s c a l l _ e x i t
ENDPROC( h p u x _ s y s c a l l _ e x i t )
2005-04-16 15:20:36 -07:00
.import hpux_unimplemented
2007-01-28 16:43:32 +01:00
ENTRY( h p u x _ u n i m p l e m e n t e d _ w r a p p e r )
2005-04-16 15:20:36 -07:00
b h p u x _ u n i m p l e m e n t e d
STREG % r22 ,- 6 4 ( % r30 ) / * o v e r w r i t e a r g 8 w i t h s y s c a l l n u m b e r * /
2007-01-28 16:43:32 +01:00
ENDPROC( h p u x _ u n i m p l e m e n t e d _ w r a p p e r )