2005-04-17 02:20:36 +04:00
/ *
* arch/ s39 0 / k e r n e l / e n t r y . S
* S3 9 0 l o w - l e v e l e n t r y p o i n t s .
*
* S3 9 0 v e r s i o n
* Copyright ( C ) 1 9 9 9 ,2 0 0 0 I B M D e u t s c h l a n d E n t w i c k l u n g G m b H , I B M C o r p o r a t i o n
* Author( s ) : M a r t i n S c h w i d e f s k y ( s c h w i d e f s k y @de.ibm.com),
* Hartmut P e n n e r ( h p @de.ibm.com),
* Denis J o s e p h B a r r o w ( d j b a r r o w @de.ibm.com,barrow_dj@yahoo.com),
2005-06-26 01:55:30 +04:00
* Heiko C a r s t e n s < h e i k o . c a r s t e n s @de.ibm.com>
2005-04-17 02:20:36 +04:00
* /
# include < l i n u x / s y s . h >
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / c o n f i g . h >
# include < a s m / c a c h e . h >
# include < a s m / l o w c o r e . h >
# include < a s m / e r r n o . h >
# include < a s m / p t r a c e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / o f f s e t s . h >
# include < a s m / u n i s t d . h >
# include < a s m / p a g e . h >
/ *
* Stack l a y o u t f o r t h e s y s t e m _ c a l l s t a c k e n t r y .
* The f i r s t f e w e n t r i e s a r e i d e n t i c a l t o t h e u s e r _ r e g s _ s t r u c t .
* /
SP_ P T R E G S = S T A C K _ F R A M E _ O V E R H E A D
SP_ A R G S = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ A R G S
SP_ P S W = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ P S W
SP_ R 0 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S
SP_ R 1 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 8
SP_ R 2 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 1 6
SP_ R 3 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 2 4
SP_ R 4 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 3 2
SP_ R 5 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 4 0
SP_ R 6 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 4 8
SP_ R 7 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 5 6
SP_ R 8 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 6 4
SP_ R 9 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 7 2
SP_ R 1 0 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 8 0
SP_ R 1 1 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 8 8
SP_ R 1 2 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 9 6
SP_ R 1 3 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 1 0 4
SP_ R 1 4 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 1 1 2
SP_ R 1 5 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ G P R S + 1 2 0
SP_ O R I G _ R 2 = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ O R I G _ G P R 2
SP_ I L C = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ I L C
SP_ T R A P = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ T R A P
SP_ S I Z E = S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E
STACK_ S H I F T = P A G E _ S H I F T + T H R E A D _ O R D E R
STACK_ S I Z E = 1 < < S T A C K _ S H I F T
2005-06-26 01:55:30 +04:00
_ TIF_ W O R K _ S V C = ( _ T I F _ S I G P E N D I N G | _ T I F _ N E E D _ R E S C H E D | _ T I F _ M C C K _ P E N D I N G | \
2005-04-17 02:20:36 +04:00
_ TIF_ R E S T A R T _ S V C | _ T I F _ S I N G L E _ S T E P )
2005-06-26 01:55:30 +04:00
_ TIF_ W O R K _ I N T = ( _ T I F _ S I G P E N D I N G | _ T I F _ N E E D _ R E S C H E D | _ T I F _ M C C K _ P E N D I N G )
2005-04-17 02:20:36 +04:00
# define B A S E D ( n a m e ) n a m e - s y s t e m _ c a l l ( % r13 )
.macro STORE_TIMER lc_ o f f s e t
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
stpt \ l c _ o f f s e t
# endif
.endm
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
.macro UPDATE_VTIME lc_ f r o m ,l c _ t o ,l c _ s u m
lg % r10 ,\ l c _ f r o m
slg % r10 ,\ l c _ t o
alg % r10 ,\ l c _ s u m
stg % r10 ,\ l c _ s u m
.endm
# endif
/ *
* Register u s a g e i n i n t e r r u p t h a n d l e r s :
* R9 - p o i n t e r t o c u r r e n t t a s k s t r u c t u r e
* R1 3 - p o i n t e r t o l i t e r a l p o o l
* R1 4 - r e t u r n r e g i s t e r f o r f u n c t i o n c a l l s
* R1 5 - k e r n e l s t a c k p o i n t e r
* /
.macro SAVE_ALL_BASE savearea
stmg % r12 ,% r15 ,\ s a v e a r e a
larl % r13 ,s y s t e m _ c a l l
.endm
.macro SAVE_ALL psworg,s a v e a r e a ,s y n c
la % r12 ,\ p s w o r g
.if \ sync
tm \ p s w o r g + 1 ,0 x01 # t e s t p r o b l e m s t a t e b i t
jz 2 f # s k i p s t a c k s e t u p s a v e
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K # p r o b l e m s t a t e - > l o a d k s p
.else
tm \ p s w o r g + 1 ,0 x01 # t e s t p r o b l e m s t a t e b i t
jnz 1 f # f r o m u s e r - > l o a d k e r n e l s t a c k
clc \ p s w o r g + 8 ( 8 ) ,B A S E D ( . L c r i t i c a l _ e n d )
jhe 0 f
clc \ p s w o r g + 8 ( 8 ) ,B A S E D ( . L c r i t i c a l _ s t a r t )
jl 0 f
brasl % r14 ,c l e a n u p _ c r i t i c a l
tm 0 ( % r12 ) ,0 x01 # r e t e s t p r o b l e m s t a t e a f t e r c l e a n u p
jnz 1 f
0 : lg % r14 ,_ _ L C _ A S Y N C _ S T A C K # a r e w e a l r e a d y o n t h e a s y n c . s t a c k ?
slgr % r14 ,% r15
srag % r14 ,% r14 ,S T A C K _ S H I F T
jz 2 f
1 : lg % r15 ,_ _ L C _ A S Y N C _ S T A C K # l o a d a s y n c s t a c k
.endif
# ifdef C O N F I G _ C H E C K _ S T A C K
j 3 f
2 : tml % r15 ,S T A C K _ S I Z E - C O N F I G _ S T A C K _ G U A R D
jz s t a c k _ o v e r f l o w
3 :
# endif
2005-06-26 01:55:30 +04:00
2 :
.endm
.macro CREATE_STACK_FRAME psworg,s a v e a r e a
aghi % r15 ,- S P _ S I Z E # m a k e r o o m f o r r e g i s t e r s & p s w
2005-04-17 02:20:36 +04:00
mvc S P _ P S W ( 1 6 ,% r15 ) ,0 ( % r12 ) # m o v e u s e r P S W t o s t a c k
la % r12 ,\ p s w o r g
stg % r2 ,S P _ O R I G _ R 2 ( % r15 ) # s t o r e o r i g i n a l c o n t e n t o f g p r 2
icm % r12 ,1 2 ,_ _ L C _ S V C _ I L C
stmg % r0 ,% r11 ,S P _ R 0 ( % r15 ) # s t o r e g p r s % r 0 - % r11 t o k e r n e l s t a c k
st % r12 ,S P _ I L C ( % r15 )
mvc S P _ R 1 2 ( 3 2 ,% r15 ) ,\ s a v e a r e a # m o v e % r 12 - % r15 t o s t a c k
la % r12 ,0
stg % r12 ,_ _ S F _ B A C K C H A I N ( % r15 )
.endm
.macro RESTORE_ALL sync
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,S P _ P S W ( % r15 ) # m o v e u s e r P S W t o l o w c o r e
.if ! \ sync
ni _ _ L C _ R E T U R N _ P S W + 1 ,0 x f d # c l e a r w a i t s t a t e b i t
.endif
lmg % r0 ,% r15 ,S P _ R 0 ( % r15 ) # l o a d g p r s 0 - 1 5 o f u s e r
STORE_ T I M E R _ _ L C _ E X I T _ T I M E R
lpswe _ _ L C _ R E T U R N _ P S W # b a c k t o c a l l e r
.endm
/ *
* Scheduler r e s u m e f u n c t i o n , c a l l e d b y s w i t c h _ t o
* gpr2 = ( t a s k _ s t r u c t * ) p r e v
* gpr3 = ( t a s k _ s t r u c t * ) n e x t
* Returns :
* gpr2 = p r e v
* /
.globl __switch_to
__switch_to :
tm _ _ T H R E A D _ p e r + 4 ( % r3 ) ,0 x e 8 # i s t h e n e w p r o c e s s u s i n g p e r ?
jz _ _ s w i t c h _ t o _ n o p e r # i f n o t w e ' r e f i n e
stctg % c9 ,% c11 ,_ _ S F _ E M P T Y ( % r15 ) # W e a r e u s i n g p e r s t u f f
clc _ _ T H R E A D _ p e r ( 2 4 ,% r3 ) ,_ _ S F _ E M P T Y ( % r15 )
je _ _ s w i t c h _ t o _ n o p e r # w e g o t a w a y w i t h o u t b a s h i n g T L B ' s
lctlg % c9 ,% c11 ,_ _ T H R E A D _ p e r ( % r3 ) # N o p e w e d i d n ' t
__switch_to_noper :
2005-06-26 01:55:30 +04:00
lg % r4 ,_ _ T H R E A D _ i n f o ( % r2 ) # g e t t h r e a d _ i n f o o f p r e v
tm _ _ T I _ f l a g s + 7 ( % r4 ) ,_ T I F _ M C C K _ P E N D I N G # m a c h i n e c h e c k p e n d i n g ?
jz _ _ s w i t c h _ t o _ n o _ m c c k
ni _ _ T I _ f l a g s + 7 ( % r4 ) ,2 5 5 - _ T I F _ M C C K _ P E N D I N G # c l e a r f l a g i n p r e v
lg % r4 ,_ _ T H R E A D _ i n f o ( % r3 ) # g e t t h r e a d _ i n f o o f n e x t
oi _ _ T I _ f l a g s + 7 ( % r4 ) ,_ T I F _ M C C K _ P E N D I N G # s e t i t i n n e x t
__switch_to_no_mcck :
2005-04-17 02:20:36 +04:00
stmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # s t o r e _ _ s w i t c h _ t o r e g i s t e r s o f p r e v t a s k
stg % r15 ,_ _ T H R E A D _ k s p ( % r2 ) # s t o r e k e r n e l s t a c k t o p r e v - > t s s . k s p
lg % r15 ,_ _ T H R E A D _ k s p ( % r3 ) # l o a d k e r n e l s t a c k f r o m n e x t - > t s s . k s p
lmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # l o a d _ _ s w i t c h _ t o r e g i s t e r s o f n e x t t a s k
stg % r3 ,_ _ L C _ C U R R E N T # _ _ L C _ C U R R E N T = c u r r e n t t a s k s t r u c t
lctl % c4 ,% c4 ,_ _ T A S K _ p i d ( % r3 ) # l o a d p i d t o c o n t r o l r e g . 4
lg % r3 ,_ _ T H R E A D _ i n f o ( % r3 ) # l o a d t h r e a d _ i n f o f r o m t a s k s t r u c t
stg % r3 ,_ _ L C _ T H R E A D _ I N F O
aghi % r3 ,S T A C K _ S I Z E
stg % r3 ,_ _ L C _ K E R N E L _ S T A C K # _ _ L C _ K E R N E L _ S T A C K = n e w k e r n e l s t a c k
br % r14
__critical_start :
/ *
* SVC i n t e r r u p t h a n d l e r r o u t i n e . S y s t e m c a l l s a r e s y n c h r o n o u s e v e n t s a n d
* are e x e c u t e d w i t h i n t e r r u p t s e n a b l e d .
* /
.globl system_call
system_call :
STORE_ T I M E R _ _ L C _ S Y N C _ E N T E R _ T I M E R
sysc_saveall :
SAVE_ A L L _ B A S E _ _ L C _ S A V E _ A R E A
SAVE_ A L L _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A ,1
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A
2005-04-17 02:20:36 +04:00
llgh % r7 ,_ _ L C _ S V C _ I N T _ C O D E # g e t s v c n u m b e r f r o m l o w c o r e
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
sysc_vtime :
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz s y s c _ d o _ s v c
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
sysc_stime :
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
sysc_update :
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
# endif
sysc_do_svc :
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
slag % r7 ,% r7 ,2 # * 4 a n d t e s t f o r s v c 0
jnz s y s c _ n r _ o k
# svc 0 : system c a l l n u m b e r i n % r1
cl % r1 ,B A S E D ( . L n r _ s y s c a l l s )
jnl s y s c _ n r _ o k
lgfr % r7 ,% r1 # c l e a r h i g h w o r d i n r 1
slag % r7 ,% r7 ,2 # s v c 0 : s y s t e m c a l l n u m b e r i n % r1
sysc_nr_ok :
mvc S P _ A R G S ( 8 ,% r15 ) ,S P _ R 7 ( % r15 )
sysc_do_restart :
larl % r10 ,s y s _ c a l l _ t a b l e
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
tm S P _ P S W + 3 ( % r15 ) ,0 x01 # a r e w e r u n n i n g i n 31 b i t m o d e ?
jo s y s c _ n o e m u
larl % r10 ,s y s _ c a l l _ t a b l e _ e m u # u s e 31 b i t e m u l a t i o n s y s t e m c a l l s
sysc_noemu :
# endif
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T )
lgf % r8 ,0 ( % r7 ,% r10 ) # l o a d a d d r e s s o f s y s t e m c a l l r o u t i n e
jnz s y s c _ t r a c e s y s
basr % r14 ,% r8 # c a l l s y s _ x x x x
stg % r2 ,S P _ R 2 ( % r15 ) # s t o r e r e t u r n v a l u e ( c h a n g e R 2 o n s t a c k )
# ATTENTION : check s y s _ e x e c v e _ g l u e b e f o r e
# changing a n y t h i n g h e r e ! !
sysc_return :
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # r e t u r n i n g t o u s e r ?
jno s y s c _ l e a v e
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ W O R K _ S V C
jnz s y s c _ w o r k # t h e r e i s w o r k t o d o ( s i g n a l s e t c . )
sysc_leave :
RESTORE_ A L L 1
#
# recheck i f t h e r e i s m o r e w o r k t o d o
#
sysc_work_loop :
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ W O R K _ S V C
jz s y s c _ l e a v e # t h e r e i s n o w o r k t o d o
#
# One o f t h e w o r k b i t s i s o n . F i n d o u t w h i c h o n e .
#
sysc_work :
2005-06-26 01:55:30 +04:00
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ M C C K _ P E N D I N G
jo s y s c _ m c c k _ p e n d i n g
2005-04-17 02:20:36 +04:00
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ N E E D _ R E S C H E D
jo s y s c _ r e s c h e d u l e
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I G P E N D I N G
jo s y s c _ s i g p e n d i n g
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ R E S T A R T _ S V C
jo s y s c _ r e s t a r t
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I N G L E _ S T E P
jo s y s c _ s i n g l e s t e p
j s y s c _ l e a v e
#
# _ TIF_ N E E D _ R E S C H E D i s s e t , c a l l s c h e d u l e
#
sysc_reschedule :
larl % r14 ,s y s c _ w o r k _ l o o p
jg s c h e d u l e # r e t u r n p o i n t i s s y s c _ r e t u r n
2005-06-26 01:55:30 +04:00
#
# _ TIF_ M C C K _ P E N D I N G i s s e t , c a l l h a n d l e r
#
sysc_mcck_pending :
larl % r14 ,s y s c _ w o r k _ l o o p
jg s39 0 _ h a n d l e _ m c c k # T I F b i t w i l l b e c l e a r e d b y h a n d l e r
2005-04-17 02:20:36 +04:00
#
# _ TIF_ S I G P E N D I N G i s s e t , c a l l d o _ s i g n a l
#
sysc_sigpending :
ni _ _ T I _ f l a g s + 7 ( % r9 ) ,2 5 5 - _ T I F _ S I N G L E _ S T E P # c l e a r T I F _ S I N G L E _ S T E P
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
sgr % r3 ,% r3 # c l e a r * o l d s e t
brasl % r14 ,d o _ s i g n a l # c a l l d o _ s i g n a l
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ R E S T A R T _ S V C
jo s y s c _ r e s t a r t
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I N G L E _ S T E P
jo s y s c _ s i n g l e s t e p
j s y s c _ l e a v e # o u t o f h e r e , d o N O T r e c h e c k
#
# _ TIF_ R E S T A R T _ S V C i s s e t , s e t u p r e g i s t e r s a n d r e s t a r t s v c
#
sysc_restart :
ni _ _ T I _ f l a g s + 7 ( % r9 ) ,2 5 5 - _ T I F _ R E S T A R T _ S V C # c l e a r T I F _ R E S T A R T _ S V C
lg % r7 ,S P _ R 2 ( % r15 ) # l o a d n e w s v c n u m b e r
slag % r7 ,% r7 ,2 # * 4
mvc S P _ R 2 ( 8 ,% r15 ) ,S P _ O R I G _ R 2 ( % r15 ) # r e s t o r e f i r s t a r g u m e n t
lmg % r2 ,% r6 ,S P _ R 2 ( % r15 ) # l o a d s v c a r g u m e n t s
j s y s c _ d o _ r e s t a r t # r e s t a r t s v c
#
# _ TIF_ S I N G L E _ S T E P i s s e t , c a l l d o _ s i n g l e _ s t e p
#
sysc_singlestep :
ni _ _ T I _ f l a g s + 7 ( % r9 ) ,2 5 5 - _ T I F _ S I N G L E _ S T E P # c l e a r T I F _ S I N G L E _ S T E P
lhi % r0 ,_ _ L C _ P G M _ O L D _ P S W
sth % r0 ,S P _ T R A P ( % r15 ) # s e t t r a p i n d i c a t i o n t o p g m c h e c k
la % r2 ,S P _ P T R E G S ( % r15 ) # a d d r e s s o f r e g i s t e r - s a v e a r e a
larl % r14 ,s y s c _ r e t u r n # l o a d a d r . o f s y s t e m r e t u r n
jg d o _ s i n g l e _ s t e p # b r a n c h t o d o _ s i g t r a p
__critical_end :
#
# call s y s c a l l _ t r a c e b e f o r e a n d a f t e r s y s t e m c a l l
# special l i n k a g e : % r12 c o n t a i n s t h e r e t u r n a d d r e s s f o r t r a c e _ s v c
#
sysc_tracesys :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
la % r3 ,0
srl % r7 ,2
stg % r7 ,S P _ R 2 ( % r15 )
brasl % r14 ,s y s c a l l _ t r a c e
lghi % r0 ,N R _ s y s c a l l s
clg % r0 ,S P _ R 2 ( % r15 )
jnh s y s c _ t r a c e n o g o
lg % r7 ,S P _ R 2 ( % r15 ) # s t r a c e m i g h t h a v e c h a n g e d t h e
sll % r7 ,2 # s y s t e m c a l l
lgf % r8 ,0 ( % r7 ,% r10 )
sysc_tracego :
lmg % r3 ,% r6 ,S P _ R 3 ( % r15 )
lg % r2 ,S P _ O R I G _ R 2 ( % r15 )
basr % r14 ,% r8 # c a l l s y s _ x x x
stg % r2 ,S P _ R 2 ( % r15 ) # s t o r e r e t u r n v a l u e
sysc_tracenogo :
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T )
jz s y s c _ r e t u r n
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
la % r3 ,1
larl % r14 ,s y s c _ r e t u r n # r e t u r n p o i n t i s s y s c _ r e t u r n
jg s y s c a l l _ t r a c e
#
# a n e w p r o c e s s e x i t s t h e k e r n e l w i t h r e t _ f r o m _ f o r k
#
.globl ret_from_fork
ret_from_fork :
lg % r13 ,_ _ L C _ S V C _ N E W _ P S W + 8
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # f o r k i n g a k e r n e l t h r e a d ?
jo 0 f
stg % r15 ,S P _ R 1 5 ( % r15 ) # s t o r e s t a c k p o i n t e r f o r n e w k t h r e a d
0 : brasl % r14 ,s c h e d u l e _ t a i l
stosm 2 4 ( % r15 ) ,0 x03 # r e e n a b l e i n t e r r u p t s
j s y s c _ r e t u r n
#
# clone, f o r k , v f o r k , e x e c a n d s i g r e t u r n n e e d g l u e ,
# because t h e y a l l e x p e c t p t _ r e g s a s p a r a m e t e r ,
# but a r e c a l l e d w i t h d i f f e r e n t p a r a m e t e r .
# return- a d d r e s s i s s e t u p a b o v e
#
sys_clone_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
jg s y s _ c l o n e # b r a n c h t o s y s _ c l o n e
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_clone_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
jg s y s32 _ c l o n e # b r a n c h t o s y s 32 _ c l o n e
# endif
sys_fork_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
jg s y s _ f o r k # b r a n c h t o s y s _ f o r k
sys_vfork_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
jg s y s _ v f o r k # b r a n c h t o s y s _ v f o r k
sys_execve_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
lgr % r12 ,% r14 # s a v e r e t u r n a d d r e s s
brasl % r14 ,s y s _ e x e c v e # c a l l s y s _ e x e c v e
ltgr % r2 ,% r2 # c h e c k i f e x e c v e f a i l e d
bnz 0 ( % r12 ) # i t d i d f a i l - > s t o r e r e s u l t i n g p r 2
b 6 ( % r12 ) # S K I P S T G 2 ,S P _ R 2 ( 1 5 ) i n
# system_ c a l l / s y s c _ t r a c e s y s
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_execve_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
lgr % r12 ,% r14 # s a v e r e t u r n a d d r e s s
brasl % r14 ,s y s32 _ e x e c v e # c a l l s y s 32 _ e x e c v e
ltgr % r2 ,% r2 # c h e c k i f e x e c v e f a i l e d
bnz 0 ( % r12 ) # i t d i d f a i l - > s t o r e r e s u l t i n g p r 2
b 6 ( % r12 ) # S K I P S T G 2 ,S P _ R 2 ( 1 5 ) i n
# system_ c a l l / s y s c _ t r a c e s y s
# endif
sys_sigreturn_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s _ s i g r e t u r n # b r a n c h t o s y s _ s i g r e t u r n
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_sigreturn_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s32 _ s i g r e t u r n # b r a n c h t o s y s 32 _ s i g r e t u r n
# endif
sys_rt_sigreturn_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s _ r t _ s i g r e t u r n # b r a n c h t o s y s _ s i g r e t u r n
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_rt_sigreturn_glue :
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s32 _ r t _ s i g r e t u r n # b r a n c h t o s y s 32 _ s i g r e t u r n
# endif
#
# sigsuspend a n d r t _ s i g s u s p e n d n e e d p t _ r e g s a s a n a d d i t i o n a l
# parameter a n d t h e y h a v e t o s k i p t h e s t o r e o f % r2 i n t o t h e
# user r e g i s t e r % r2 b e c a u s e t h e r e t u r n v a l u e w a s s e t i n
# sigsuspend a n d r t _ s i g s u s p e n d a l r e a d y a n d m u s t n o t b e o v e r w r i t t e n !
#
sys_sigsuspend_glue :
lgr % r5 ,% r4 # m o v e m a s k b a c k
lgr % r4 ,% r3 # m o v e h i s t o r y 1 p a r a m e t e r
lgr % r3 ,% r2 # m o v e h i s t o r y 0 p a r a m e t e r
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s f i r s t p a r a m e t e r
la % r14 ,6 ( % r14 ) # s k i p s t o r e o f r e t u r n v a l u e
jg s y s _ s i g s u s p e n d # b r a n c h t o s y s _ s i g s u s p e n d
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_sigsuspend_glue :
llgfr % r4 ,% r4 # u n s i g n e d l o n g
lgr % r5 ,% r4 # m o v e m a s k b a c k
lgfr % r3 ,% r3 # i n t
lgr % r4 ,% r3 # m o v e h i s t o r y 1 p a r a m e t e r
lgfr % r2 ,% r2 # i n t
lgr % r3 ,% r2 # m o v e h i s t o r y 0 p a r a m e t e r
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s f i r s t p a r a m e t e r
la % r14 ,6 ( % r14 ) # s k i p s t o r e o f r e t u r n v a l u e
jg s y s32 _ s i g s u s p e n d # b r a n c h t o s y s 32 _ s i g s u s p e n d
# endif
sys_rt_sigsuspend_glue :
lgr % r4 ,% r3 # m o v e s i g s e t s i z e p a r a m e t e r
lgr % r3 ,% r2 # m o v e u n e w s e t p a r a m e t e r
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s f i r s t p a r a m e t e r
la % r14 ,6 ( % r14 ) # s k i p s t o r e o f r e t u r n v a l u e
jg s y s _ r t _ s i g s u s p e n d # b r a n c h t o s y s _ r t _ s i g s u s p e n d
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_rt_sigsuspend_glue :
llgfr % r3 ,% r3 # s i z e _ t
lgr % r4 ,% r3 # m o v e s i g s e t s i z e p a r a m e t e r
llgtr % r2 ,% r2 # s i g s e t _ e m u 31 _ t *
lgr % r3 ,% r2 # m o v e u n e w s e t p a r a m e t e r
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s f i r s t p a r a m e t e r
la % r14 ,6 ( % r14 ) # s k i p s t o r e o f r e t u r n v a l u e
jg s y s32 _ r t _ s i g s u s p e n d # b r a n c h t o s y s 32 _ r t _ s i g s u s p e n d
# endif
sys_sigaltstack_glue :
la % r4 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s _ s i g a l t s t a c k # b r a n c h t o s y s _ s i g r e t u r n
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
sys32_sigaltstack_glue :
la % r4 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s a s p a r a m e t e r
jg s y s32 _ s i g a l t s t a c k _ w r a p p e r # b r a n c h t o s y s _ s i g r e t u r n
# endif
/ *
* Program c h e c k h a n d l e r r o u t i n e
* /
.globl pgm_check_handler
pgm_check_handler :
/ *
* First w e n e e d t o c h e c k f o r a s p e c i a l c a s e :
* Single s t e p p i n g a n i n s t r u c t i o n t h a t d i s a b l e s t h e P E R e v e n t m a s k w i l l
* cause a P E R e v e n t A F T E R t h e m a s k h a s b e e n s e t . E x a m p l e : S V C o r L P S W .
* For a s i n g l e s t e p p e d S V C t h e p r o g r a m c h e c k h a n d l e r g e t s c o n t r o l a f t e r
* the S V C n e w P S W h a s b e e n l o a d e d . B u t w e w a n t t o e x e c u t e t h e S V C f i r s t a n d
* then h a n d l e t h e P E R e v e n t . T h e r e f o r e w e u p d a t e t h e S V C o l d P S W t o p o i n t
* to t h e p g m _ c h e c k _ h a n d l e r a n d b r a n c h t o t h e S V C h a n d l e r a f t e r w e c h e c k e d
* if w e h a v e t o l o a d t h e k e r n e l s t a c k r e g i s t e r .
* For e v e r y o t h e r p o s s i b l e c a u s e f o r P E R e v e n t w i t h o u t t h e P E R m a s k s e t
* we j u s t i g n o r e t h e P E R e v e n t ( F I X M E : i s t h e r e a n y t h i n g w e h a v e t o d o
* for L P S W ? ) .
* /
STORE_ T I M E R _ _ L C _ S Y N C _ E N T E R _ T I M E R
SAVE_ A L L _ B A S E _ _ L C _ S A V E _ A R E A
tm _ _ L C _ P G M _ I N T _ C O D E + 1 ,0 x80 # c h e c k w h e t h e r w e g o t a p e r e x c e p t i o n
jnz p g m _ p e r # g o t p e r e x c e p t i o n - > s p e c i a l c a s e
SAVE_ A L L _ _ L C _ P G M _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A ,1
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ P G M _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz p g m _ n o _ v t i m e
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
pgm_no_vtime :
# endif
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
lgf % r3 ,_ _ L C _ P G M _ I L C # l o a d p r o g r a m i n t e r r u p t i o n c o d e
lghi % r8 ,0 x7 f
ngr % r8 ,% r3
pgm_do_call :
sll % r8 ,3
larl % r1 ,p g m _ c h e c k _ t a b l e
lg % r1 ,0 ( % r8 ,% r1 ) # l o a d a d d r e s s o f h a n d l e r r o u t i n e
la % r2 ,S P _ P T R E G S ( % r15 ) # a d d r e s s o f r e g i s t e r - s a v e a r e a
larl % r14 ,s y s c _ r e t u r n
br % r1 # b r a n c h t o i n t e r r u p t - h a n d l e r
#
# handle p e r e x c e p t i o n
#
pgm_per :
tm _ _ L C _ P G M _ O L D _ P S W ,0 x40 # t e s t i f p e r e v e n t r e c o r d i n g i s o n
jnz p g m _ p e r _ s t d # o k , n o r m a l p e r e v e n t f r o m u s e r s p a c e
# ok i t s o n e o f t h e s p e c i a l c a s e s , n o w w e n e e d t o f i n d o u t w h i c h o n e
clc _ _ L C _ P G M _ O L D _ P S W ( 1 6 ) ,_ _ L C _ S V C _ N E W _ P S W
je p g m _ s v c p e r
# no i n t e r e s t i n g s p e c i a l c a s e , i g n o r e P E R e v e n t
lmg % r12 ,% r15 ,_ _ L C _ S A V E _ A R E A
lpswe _ _ L C _ P G M _ O L D _ P S W
#
# Normal p e r e x c e p t i o n
#
pgm_per_std :
SAVE_ A L L _ _ L C _ P G M _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A ,1
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ P G M _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz p g m _ n o _ v t i m e 2
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
pgm_no_vtime2 :
# endif
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
lg % r1 ,_ _ T I _ t a s k ( % r9 )
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a t m i d ( 2 ,% r1 ) ,_ _ L C _ P E R _ A T M I D
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a d d r e s s ( 8 ,% r1 ) ,_ _ L C _ P E R _ A D D R E S S
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a c c e s s _ i d ( 1 ,% r1 ) ,_ _ L C _ P E R _ A C C E S S _ I D
oi _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I N G L E _ S T E P # s e t T I F _ S I N G L E _ S T E P
lgf % r3 ,_ _ L C _ P G M _ I L C # l o a d p r o g r a m i n t e r r u p t i o n c o d e
lghi % r8 ,0 x7 f
ngr % r8 ,% r3 # c l e a r p e r - e v e n t - b i t a n d i l c
je s y s c _ r e t u r n
j p g m _ d o _ c a l l
#
# it w a s a s i n g l e s t e p p e d S V C t h a t i s c a u s i n g a l l t h e t r o u b l e
#
pgm_svcper :
SAVE_ A L L _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A ,1
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz p g m _ n o _ v t i m e 3
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
pgm_no_vtime3 :
# endif
llgh % r7 ,_ _ L C _ S V C _ I N T _ C O D E # g e t s v c n u m b e r f r o m l o w c o r e
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
lg % r1 ,_ _ T I _ t a s k ( % r9 )
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a t m i d ( 2 ,% r1 ) ,_ _ L C _ P E R _ A T M I D
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a d d r e s s ( 8 ,% r1 ) ,_ _ L C _ P E R _ A D D R E S S
mvc _ _ T H R E A D _ p e r + _ _ P E R _ a c c e s s _ i d ( 1 ,% r1 ) ,_ _ L C _ P E R _ A C C E S S _ I D
oi _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I N G L E _ S T E P # s e t T I F _ S I N G L E _ S T E P
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x03 # r e e n a b l e i n t e r r u p t s
j s y s c _ d o _ s v c
/ *
* IO i n t e r r u p t h a n d l e r r o u t i n e
* /
.globl io_int_handler
io_int_handler :
STORE_ T I M E R _ _ L C _ A S Y N C _ E N T E R _ T I M E R
stck _ _ L C _ I N T _ C L O C K
SAVE_ A L L _ B A S E _ _ L C _ S A V E _ A R E A + 3 2
SAVE_ A L L _ _ L C _ I O _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A + 3 2 ,0
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ I O _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A + 3 2
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz i o _ n o _ v t i m e
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
io_no_vtime :
# endif
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
la % r2 ,S P _ P T R E G S ( % r15 ) # a d d r e s s o f r e g i s t e r - s a v e a r e a
brasl % r14 ,d o _ I R Q # c a l l s t a n d a r d i r q h a n d l e r
io_return :
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # r e t u r n i n g t o u s e r ?
# ifdef C O N F I G _ P R E E M P T
jno i o _ p r e e m p t # n o - > c h e c k f o r p r e e m p t i v e s c h e d u l i n g
# else
jno i o _ l e a v e # n o - > s k i p r e s c h e d & s i g n a l
# endif
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ W O R K _ I N T
jnz i o _ w o r k # t h e r e i s w o r k t o d o ( s i g n a l s e t c . )
io_leave :
RESTORE_ A L L 0
# ifdef C O N F I G _ P R E E M P T
io_preempt :
icm % r0 ,1 5 ,_ _ T I _ p r e c o u n t ( % r9 )
jnz i o _ l e a v e
# switch t o k e r n e l s t a c k
lg % r1 ,S P _ R 1 5 ( % r15 )
aghi % r1 ,- S P _ S I Z E
mvc S P _ P T R E G S ( _ _ P T _ S I Z E ,% r1 ) ,S P _ P T R E G S ( % r15 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 ) # c l e a r b a c k c h a i n
lgr % r15 ,% r1
io_resume_loop :
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ N E E D _ R E S C H E D
jno i o _ l e a v e
larl % r1 ,. L c _ p a c t i v e
mvc _ _ T I _ p r e c o u n t ( 4 ,% r9 ) ,0 ( % r1 )
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x03 # r e e n a b l e i n t e r r u p t s
brasl % r14 ,s c h e d u l e # c a l l s c h e d u l e
stnsm _ _ S F _ E M P T Y ( % r15 ) ,0 x f c # d i s a b l e I / O a n d e x t . i n t e r r u p t s
xc _ _ T I _ p r e c o u n t ( 4 ,% r9 ) ,_ _ T I _ p r e c o u n t ( % r9 )
j i o _ r e s u m e _ l o o p
# endif
#
# switch t o k e r n e l s t a c k , t h e n c h e c k T I F b i t s
#
io_work :
lg % r1 ,_ _ L C _ K E R N E L _ S T A C K
aghi % r1 ,- S P _ S I Z E
mvc S P _ P T R E G S ( _ _ P T _ S I Z E ,% r1 ) ,S P _ P T R E G S ( % r15 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 ) # c l e a r b a c k c h a i n
lgr % r15 ,% r1
#
# One o f t h e w o r k b i t s i s o n . F i n d o u t w h i c h o n e .
2005-06-26 01:55:30 +04:00
# Checked a r e : _ T I F _ S I G P E N D I N G , _ T I F _ N E E D _ R E S C H E D a n d _ T I F _ M C C K _ P E N D I N G
2005-04-17 02:20:36 +04:00
#
io_work_loop :
2005-06-26 01:55:30 +04:00
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ M C C K _ P E N D I N G
jo i o _ m c c k _ p e n d i n g
2005-04-17 02:20:36 +04:00
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ N E E D _ R E S C H E D
jo i o _ r e s c h e d u l e
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ S I G P E N D I N G
jo i o _ s i g p e n d i n g
j i o _ l e a v e
2005-06-26 01:55:30 +04:00
#
# _ TIF_ M C C K _ P E N D I N G i s s e t , c a l l h a n d l e r
#
io_mcck_pending :
larl % r14 ,i o _ w o r k _ l o o p
jg s39 0 _ h a n d l e _ m c c k # T I F b i t w i l l b e c l e a r e d b y h a n d l e r
2005-04-17 02:20:36 +04:00
#
# _ TIF_ N E E D _ R E S C H E D i s s e t , c a l l s c h e d u l e
#
io_reschedule :
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x03 # r e e n a b l e i n t e r r u p t s
brasl % r14 ,s c h e d u l e # c a l l s c h e d u l e r
stnsm _ _ S F _ E M P T Y ( % r15 ) ,0 x f c # d i s a b l e I / O a n d e x t . i n t e r r u p t s
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ W O R K _ I N T
jz i o _ l e a v e # t h e r e i s n o w o r k t o d o
j i o _ w o r k _ l o o p
#
# _ TIF_ S I G P E N D I N G i s s e t , c a l l d o _ s i g n a l
#
io_sigpending :
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x03 # r e e n a b l e i n t e r r u p t s
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
slgr % r3 ,% r3 # c l e a r * o l d s e t
brasl % r14 ,d o _ s i g n a l # c a l l d o _ s i g n a l
stnsm _ _ S F _ E M P T Y ( % r15 ) ,0 x f c # d i s a b l e I / O a n d e x t . i n t e r r u p t s
j s y s c _ l e a v e # o u t o f h e r e , d o N O T r e c h e c k
/ *
* External i n t e r r u p t h a n d l e r r o u t i n e
* /
.globl ext_int_handler
ext_int_handler :
STORE_ T I M E R _ _ L C _ A S Y N C _ E N T E R _ T I M E R
stck _ _ L C _ I N T _ C L O C K
SAVE_ A L L _ B A S E _ _ L C _ S A V E _ A R E A + 3 2
SAVE_ A L L _ _ L C _ E X T _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A + 3 2 ,0
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ E X T _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A + 3 2
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz e x t _ n o _ v t i m e
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
ext_no_vtime :
# endif
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
la % r2 ,S P _ P T R E G S ( % r15 ) # a d d r e s s o f r e g i s t e r - s a v e a r e a
llgh % r3 ,_ _ L C _ E X T _ I N T _ C O D E # g e t i n t e r r u p t i o n c o d e
brasl % r14 ,d o _ e x t i n t
j i o _ r e t u r n
/ *
* Machine c h e c k h a n d l e r r o u t i n e s
* /
.globl mcck_int_handler
mcck_int_handler :
2005-06-26 01:55:30 +04:00
la % r1 ,4 0 9 5 # r e v a l i d a t e r 1
spt _ _ L C _ C P U _ T I M E R _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # r e v a l i d a t e c p u t i m e r
lmg % r0 ,% r15 ,_ _ L C _ G P R E G S _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # r e v a l i d a t e g p r s
2005-04-17 02:20:36 +04:00
SAVE_ A L L _ B A S E _ _ L C _ S A V E _ A R E A + 6 4
2005-06-26 01:55:30 +04:00
la % r12 ,_ _ L C _ M C K _ O L D _ P S W
tm _ _ L C _ M C C K _ C O D E ,0 x80 # s y s t e m d a m a g e ?
jo m c c k _ i n t _ m a i n # y e s - > r e s t o f m c c k c o d e i n v a l i d
tm _ _ L C _ M C C K _ C O D E + 5 ,0 x02 # s t o r e d c p u t i m e r v a l u e v a l i d ?
jo 0 f
spt _ _ L C _ L A S T _ U P D A T E _ T I M E R
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
2005-07-27 22:45:06 +04:00
mvc _ _ L C _ A S Y N C _ E N T E R _ T I M E R ( 8 ) ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
mvc _ _ L C _ S Y N C _ E N T E R _ T I M E R ( 8 ) ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
mvc _ _ L C _ E X I T _ T I M E R ( 8 ) ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
2005-06-26 01:55:30 +04:00
0 : tm _ _ L C _ M C C K _ C O D E + 2 ,0 x08 # m w p o f o l d p s w v a l i d ?
jno m c c k _ n o _ v t i m e # n o - > n o t i m e r u p d a t e
tm _ _ L C _ M C K _ O L D _ P S W + 1 ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
2005-04-17 02:20:36 +04:00
jz m c c k _ n o _ v t i m e
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
mcck_no_vtime :
# endif
2005-06-26 01:55:30 +04:00
0 :
tm _ _ L C _ M C C K _ C O D E + 2 ,0 x09 # m w p + i a o f o l d p s w v a l i d ?
jno m c c k _ i n t _ m a i n # n o - > s k i p c l e a n u p c r i t i c a l
tm _ _ L C _ M C K _ O L D _ P S W + 1 ,0 x01 # t e s t p r o b l e m s t a t e b i t
jnz m c c k _ i n t _ m a i n # f r o m u s e r - > l o a d k e r n e l s t a c k
clc _ _ L C _ M C K _ O L D _ P S W + 8 ( 8 ) ,B A S E D ( . L c r i t i c a l _ e n d )
jhe m c c k _ i n t _ m a i n
clc _ _ L C _ M C K _ O L D _ P S W + 8 ( 8 ) ,B A S E D ( . L c r i t i c a l _ s t a r t )
jl m c c k _ i n t _ m a i n
brasl % r14 ,c l e a n u p _ c r i t i c a l
mcck_int_main :
lg % r14 ,_ _ L C _ P A N I C _ S T A C K # a r e w e a l r e a d y o n t h e p a n i c s t a c k ?
slgr % r14 ,% r15
srag % r14 ,% r14 ,P A G E _ S H I F T
jz 0 f
lg % r15 ,_ _ L C _ P A N I C _ S T A C K # l o a d p a n i c s t a c k
0 : CREATE_ S T A C K _ F R A M E _ _ L C _ M C K _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A + 6 4
lg % r9 ,_ _ L C _ T H R E A D _ I N F O # l o a d p o i n t e r t o t h r e a d _ i n f o s t r u c t
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
brasl % r14 ,s39 0 _ d o _ m a c h i n e _ c h e c k
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # r e t u r n i n g t o u s e r ?
jno m c c k _ r e t u r n
lg % r1 ,_ _ L C _ K E R N E L _ S T A C K # s w i t c h t o k e r n e l s t a c k
aghi % r1 ,- S P _ S I Z E
mvc S P _ P T R E G S ( _ _ P T _ S I Z E ,% r1 ) ,S P _ P T R E G S ( % r15 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 ) # c l e a r b a c k c h a i n
lgr % r15 ,% r1
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x04 # t u r n d a t o n
tm _ _ T I _ f l a g s + 7 ( % r9 ) ,_ T I F _ M C C K _ P E N D I N G
jno m c c k _ r e t u r n
brasl % r14 ,s39 0 _ h a n d l e _ m c c k
2005-04-17 02:20:36 +04:00
mcck_return :
RESTORE_ A L L 0
# ifdef C O N F I G _ S M P
/ *
* Restart i n t e r r u p t i o n h a n d l e r , k i c k s t a r t e r f o r a d d i t i o n a l C P U s
* /
.globl restart_int_handler
restart_int_handler :
lg % r15 ,_ _ L C _ S A V E _ A R E A + 1 2 0 # l o a d k s p
lghi % r10 ,_ _ L C _ C R E G S _ S A V E _ A R E A
lctlg % c0 ,% c15 ,0 ( % r10 ) # g e t n e w c t l r e g s
lghi % r10 ,_ _ L C _ A R E G S _ S A V E _ A R E A
lam % a0 ,% a15 ,0 ( % r10 )
lmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # l o a d r e g i s t e r s f r o m c l o n e
stosm _ _ S F _ E M P T Y ( % r15 ) ,0 x04 # n o w w e c a n t u r n d a t o n
jg s t a r t _ s e c o n d a r y
# else
/ *
* If w e d o n o t r u n w i t h S M P e n a b l e d , l e t t h e n e w C P U c r a s h . . .
* /
.globl restart_int_handler
restart_int_handler :
basr % r1 ,0
restart_base :
lpswe r e s t a r t _ c r a s h - r e s t a r t _ b a s e ( % r1 )
.align 8
restart_crash :
.long 0 x0 0 0 a00 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0
restart_go :
# endif
# ifdef C O N F I G _ C H E C K _ S T A C K
/ *
* The s y n c h r o n o u s o r t h e a s y n c h r o n o u s s t a c k o v e r f l o w e d . W e a r e d e a d .
* No n e e d t o p r o p e r l y s a v e t h e r e g i s t e r s , w e a r e g o i n g t o p a n i c a n y w a y .
* Setup a p t _ r e g s s o t h a t s h o w _ t r a c e c a n p r o v i d e a g o o d c a l l t r a c e .
* /
stack_overflow :
lg % r15 ,_ _ L C _ P A N I C _ S T A C K # c h a n g e t o p a n i c s t a c k
aghi % r1 ,- S P _ S I Z E
mvc S P _ P S W ( 1 6 ,% r15 ) ,0 ( % r12 ) # m o v e u s e r P S W t o s t a c k
stmg % r0 ,% r11 ,S P _ R 0 ( % r15 ) # s t o r e g p r s % r 0 - % r11 t o k e r n e l s t a c k
la % r1 ,_ _ L C _ S A V E _ A R E A
chi % r12 ,_ _ L C _ S V C _ O L D _ P S W
je 0 f
chi % r12 ,_ _ L C _ P G M _ O L D _ P S W
je 0 f
la % r1 ,_ _ L C _ S A V E _ A R E A + 1 6
0 : mvc S P _ R 1 2 ( 3 2 ,% r15 ) ,0 ( % r1 ) # m o v e % r 12 - % r15 t o s t a c k
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 ) # c l e a r b a c k c h a i n
la % r2 ,S P _ P T R E G S ( % r15 ) # l o a d p t _ r e g s
jg k e r n e l _ s t a c k _ o v e r f l o w
# endif
cleanup_table_system_call :
.quad system_ c a l l , s y s c _ d o _ s v c
cleanup_table_sysc_return :
.quad sysc_ r e t u r n , s y s c _ l e a v e
cleanup_table_sysc_leave :
.quad sysc_ l e a v e , s y s c _ w o r k _ l o o p
cleanup_table_sysc_work_loop :
.quad sysc_ w o r k _ l o o p , s y s c _ r e s c h e d u l e
cleanup_critical :
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s t e m _ c a l l )
jl 0 f
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s t e m _ c a l l + 8 )
jl c l e a n u p _ s y s t e m _ c a l l
0 :
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ r e t u r n )
jl 0 f
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ r e t u r n + 8 )
jl c l e a n u p _ s y s c _ r e t u r n
0 :
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ l e a v e )
jl 0 f
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ l e a v e + 8 )
jl c l e a n u p _ s y s c _ l e a v e
0 :
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ w o r k _ l o o p )
jl 0 f
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ w o r k _ l o o p + 8 )
2005-06-26 01:55:30 +04:00
jl c l e a n u p _ s y s c _ r e t u r n
2005-04-17 02:20:36 +04:00
0 :
br % r14
cleanup_system_call :
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,0 ( % r12 )
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
clc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 8 )
jh 0 f
mvc _ _ L C _ S Y N C _ E N T E R _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
0 : clc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 1 6 )
jhe c l e a n u p _ v t i m e
# endif
clc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n )
jh 0 f
mvc _ _ L C _ S A V E _ A R E A ( 3 2 ) ,_ _ L C _ S A V E _ A R E A + 3 2
0 : stg % r13 ,_ _ L C _ S A V E _ A R E A + 4 0
SAVE_ A L L _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A ,1
2005-06-26 01:55:30 +04:00
CREATE_ S T A C K _ F R A M E _ _ L C _ S V C _ O L D _ P S W ,_ _ L C _ S A V E _ A R E A
2005-04-17 02:20:36 +04:00
stg % r15 ,_ _ L C _ S A V E _ A R E A + 5 6
llgh % r7 ,_ _ L C _ S V C _ I N T _ C O D E
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
cleanup_vtime :
clc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 2 4 )
jhe c l e a n u p _ s t i m e
tm S P _ P S W + 1 ( % r15 ) ,0 x01 # i n t e r r u p t i n g f r o m u s e r ?
jz c l e a n u p _ n o v t i m e
UPDATE_ V T I M E _ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y N C _ E N T E R _ T I M E R ,_ _ L C _ U S E R _ T I M E R
cleanup_stime :
clc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 3 2 )
jh c l e a n u p _ u p d a t e
UPDATE_ V T I M E _ _ L C _ L A S T _ U P D A T E _ T I M E R ,_ _ L C _ E X I T _ T I M E R ,_ _ L C _ S Y S T E M _ T I M E R
cleanup_update :
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
cleanup_novtime :
# endif
mvc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s t e m _ c a l l + 8 )
la % r12 ,_ _ L C _ R E T U R N _ P S W
br % r14
cleanup_system_call_insn :
.quad sysc_saveall
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
.quad system_call
.quad sysc_vtime
.quad sysc_stime
.quad sysc_update
# endif
cleanup_sysc_return :
mvc _ _ L C _ R E T U R N _ P S W ( 8 ) ,0 ( % r12 )
mvc _ _ L C _ R E T U R N _ P S W + 8 ( 8 ) ,B A S E D ( c l e a n u p _ t a b l e _ s y s c _ r e t u r n )
la % r12 ,_ _ L C _ R E T U R N _ P S W
br % r14
cleanup_sysc_leave :
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ s y s c _ l e a v e _ i n s n )
je 0 f
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
mvc _ _ L C _ E X I T _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
clc 8 ( 8 ,% r12 ) ,B A S E D ( c l e a n u p _ s y s c _ l e a v e _ i n s n + 8 )
je 0 f
# endif
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,S P _ P S W ( % r15 )
mvc _ _ L C _ S A V E _ A R E A + 3 2 ( 3 2 ) ,S P _ R 1 2 ( % r15 )
lmg % r0 ,% r11 ,S P _ R 0 ( % r15 )
lg % r15 ,S P _ R 1 5 ( % r15 )
0 : la % r12 ,_ _ L C _ R E T U R N _ P S W
br % r14
cleanup_sysc_leave_insn :
# ifdef C O N F I G _ V I R T _ C P U _ A C C O U N T I N G
.quad sysc_leave + 1 6
# endif
.quad sysc_leave + 1 2
/ *
* Integer c o n s t a n t s
* /
.align 4
.Lconst :
.Lc_pactive : .long PREEMPT_ACTIVE
.Lnr_syscalls : .long NR_syscalls
.L0x0130 : .short 0x130
.L0x0140 : .short 0x140
.L0x0150 : .short 0x150
.L0x0160 : .short 0x160
.L0x0170 : .short 0x170
.Lcritical_start :
.quad __critical_start
.Lcritical_end :
.quad __critical_end
# define S Y S C A L L ( e s a ,e s a m e ,e m u ) . l o n g e s a m e
.globl sys_call_table
sys_call_table :
# include " s y s c a l l s . S "
# undef S Y S C A L L
# ifdef C O N F I G _ S 3 9 0 _ S U P P O R T
# define S Y S C A L L ( e s a ,e s a m e ,e m u ) . l o n g e m u
.globl sys_call_table_emu
sys_call_table_emu :
# include " s y s c a l l s . S "
# undef S Y S C A L L
# endif