2005-04-16 15:20:36 -07:00
/ *
* This f i l e c o n t a i n s t h e g e n e r i c c o d e t o p e r f o r m a c a l l t o t h e
* pSeries L P A R h y p e r v i s o r .
*
* 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 i t 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
* as p u b l i s h e d b y t h e 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 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
# include < a s m / h v c a l l . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / p p c _ a s m . h >
2006-09-06 16:23:12 -07:00
# include < a s m / a s m - o f f s e t s . h >
2010-11-18 15:06:17 +00:00
# include < a s m / p t r a c e . h >
2005-04-16 15:20:36 -07:00
# define S T K _ P A R M ( i ) ( 4 8 + ( ( i ) - 3 ) * 8 )
2009-10-26 18:50:29 +00:00
# ifdef C O N F I G _ T R A C E P O I N T S
.section " .toc " , " aw"
.globl hcall_tracepoint_refcount
hcall_tracepoint_refcount :
.llong 0
.section " .text "
2006-09-06 16:23:12 -07:00
/ *
* precall m u s t p r e s e r v e a l l r e g i s t e r s . u s e u n u s e d S T K _ P A R M ( )
2009-10-26 18:50:29 +00:00
* areas t o s a v e s n a p s h o t s a n d o p c o d e . W e b r a n c h a r o u n d t h i s
* in e a r l y i n i t ( e g w h e n p o p u l a t i n g t h e M M U h a s h t a b l e ) b y u s i n g a n
* unconditional c p u f e a t u r e .
2006-09-06 16:23:12 -07:00
* /
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P R E C A L L ( F I R S T _ R E G ) \
2006-09-06 16:23:12 -07:00
BEGIN_ F T R _ S E C T I O N ; \
2009-10-26 18:50:29 +00:00
b 1 f ; \
END_ F T R _ S E C T I O N ( 0 , 1 ) ; \
ld r12 ,h c a l l _ t r a c e p o i n t _ r e f c o u n t @toc(r2); \
2012-01-07 17:54:52 +00:00
std r12 ,3 2 ( r1 ) ; \
2009-10-26 18:50:29 +00:00
cmpdi r12 ,0 ; \
beq+ 1 f ; \
mflr r0 ; \
std r3 ,S T K _ P A R M ( r3 ) ( r1 ) ; \
std r4 ,S T K _ P A R M ( r4 ) ( r1 ) ; \
std r5 ,S T K _ P A R M ( r5 ) ( r1 ) ; \
std r6 ,S T K _ P A R M ( r6 ) ( r1 ) ; \
std r7 ,S T K _ P A R M ( r7 ) ( r1 ) ; \
std r8 ,S T K _ P A R M ( r8 ) ( r1 ) ; \
std r9 ,S T K _ P A R M ( r9 ) ( r1 ) ; \
std r10 ,S T K _ P A R M ( r10 ) ( r1 ) ; \
std r0 ,1 6 ( r1 ) ; \
2009-10-26 18:51:09 +00:00
addi r4 ,r1 ,S T K _ P A R M ( F I R S T _ R E G ) ; \
2009-10-26 18:50:29 +00:00
stdu r1 ,- S T A C K _ F R A M E _ O V E R H E A D ( r1 ) ; \
bl . _ _ t r a c e _ h c a l l _ e n t r y ; \
addi r1 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D ; \
ld r0 ,1 6 ( r1 ) ; \
ld r3 ,S T K _ P A R M ( r3 ) ( r1 ) ; \
ld r4 ,S T K _ P A R M ( r4 ) ( r1 ) ; \
ld r5 ,S T K _ P A R M ( r5 ) ( r1 ) ; \
ld r6 ,S T K _ P A R M ( r6 ) ( r1 ) ; \
ld r7 ,S T K _ P A R M ( r7 ) ( r1 ) ; \
ld r8 ,S T K _ P A R M ( r8 ) ( r1 ) ; \
ld r9 ,S T K _ P A R M ( r9 ) ( r1 ) ; \
ld r10 ,S T K _ P A R M ( r10 ) ( r1 ) ; \
mtlr r0 ; \
1 :
2006-09-06 16:23:12 -07:00
/ *
* postcall i s p e r f o r m e d i m m e d i a t e l y b e f o r e f u n c t i o n r e t u r n w h i c h
2007-03-20 14:29:54 -05:00
* allows l i b e r a l u s e o f v o l a t i l e r e g i s t e r s . W e b r a n c h a r o u n d t h i s
* in e a r l y i n i t ( e g w h e n p o p u l a t i n g t h e M M U h a s h t a b l e ) b y u s i n g a n
* unconditional c p u f e a t u r e .
2006-09-06 16:23:12 -07:00
* /
2009-10-26 18:51:09 +00:00
# define _ _ H C A L L _ I N S T _ P O S T C A L L \
2007-03-20 14:29:54 -05:00
BEGIN_ F T R _ S E C T I O N ; \
b 1 f ; \
END_ F T R _ S E C T I O N ( 0 , 1 ) ; \
2012-01-07 17:54:52 +00:00
ld r12 ,3 2 ( r1 ) ; \
2009-10-26 18:50:29 +00:00
cmpdi r12 ,0 ; \
beq+ 1 f ; \
mflr r0 ; \
ld r6 ,S T K _ P A R M ( r3 ) ( r1 ) ; \
std r3 ,S T K _ P A R M ( r3 ) ( r1 ) ; \
mr r4 ,r3 ; \
mr r3 ,r6 ; \
std r0 ,1 6 ( r1 ) ; \
stdu r1 ,- S T A C K _ F R A M E _ O V E R H E A D ( r1 ) ; \
bl . _ _ t r a c e _ h c a l l _ e x i t ; \
addi r1 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D ; \
ld r0 ,1 6 ( r1 ) ; \
ld r3 ,S T K _ P A R M ( r3 ) ( r1 ) ; \
mtlr r0 ; \
2006-09-06 16:23:12 -07:00
1 :
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P O S T C A L L _ N O R E T S \
li r5 ,0 ; \
_ _ HCALL_ I N S T _ P O S T C A L L
# define H C A L L _ I N S T _ P O S T C A L L ( B U F R E G ) \
mr r5 ,B U F R E G ; \
_ _ HCALL_ I N S T _ P O S T C A L L
2006-09-06 16:23:12 -07:00
# else
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P R E C A L L ( F I R S T _ A R G )
# define H C A L L _ I N S T _ P O S T C A L L _ N O R E T S
# define H C A L L _ I N S T _ P O S T C A L L ( B U F R E G )
2006-09-06 16:23:12 -07:00
# endif
2005-04-16 15:20:36 -07:00
.text
_ GLOBAL( p l p a r _ h c a l l _ n o r e t s )
2005-05-01 08:58:46 -07:00
HMT_ M E D I U M
2005-04-16 15:20:36 -07:00
mfcr r0
stw r0 ,8 ( r1 )
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P R E C A L L ( r4 )
2006-09-06 16:23:12 -07:00
2005-04-16 15:20:36 -07:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P O S T C A L L _ N O R E T S
2006-09-06 16:23:12 -07:00
2005-04-16 15:20:36 -07:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2006-07-19 08:01:28 +10:00
_ GLOBAL( p l p a r _ h c a l l )
2005-05-01 08:58:46 -07:00
HMT_ M E D I U M
2005-04-16 15:20:36 -07:00
mfcr r0
stw r0 ,8 ( r1 )
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P R E C A L L ( r5 )
2006-09-06 16:23:12 -07:00
2006-07-19 08:01:28 +10:00
std r4 ,S T K _ P A R M ( r4 ) ( r1 ) / * S a v e r e t b u f f e r * /
2005-04-16 15:20:36 -07:00
2006-07-19 08:01:28 +10:00
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
2005-04-16 15:20:36 -07:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2006-07-19 08:01:28 +10:00
ld r12 ,S T K _ P A R M ( r4 ) ( r1 )
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
2006-03-30 22:47:14 +02:00
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P O S T C A L L ( r12 )
2006-09-06 16:23:12 -07:00
2006-03-30 22:47:14 +02:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2007-03-21 11:21:32 +05:30
/ *
* plpar_ h c a l l _ r a w c a n b e c a l l e d i n r e a l m o d e . k e x e c / k d u m p n e e d s o m e
* hypervisor c a l l s t o b e e x e c u t e d i n r e a l m o d e . S o p l p a r _ h c a l l _ r a w
* does n o t a c c e s s t h e p e r c p u h y p e r v i s o r c a l l s t a t i s t i c s v a r i a b l e s ,
* since t h e s e v a r i a b l e s m a y n o t b e p r e s e n t i n t h e R M O r e g i o n .
* /
_ GLOBAL( p l p a r _ h c a l l _ r a w )
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
std r4 ,S T K _ P A R M ( r4 ) ( r1 ) / * S a v e r e t b u f f e r * /
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
HVSC / * i n v o k e t h e h y p e r v i s o r * /
ld r12 ,S T K _ P A R M ( r4 ) ( r1 )
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2006-07-19 08:01:28 +10:00
_ GLOBAL( p l p a r _ h c a l l 9 )
2006-03-30 22:47:14 +02:00
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P R E C A L L ( r5 )
2006-09-06 16:23:12 -07:00
2006-07-19 08:01:28 +10:00
std r4 ,S T K _ P A R M ( r4 ) ( r1 ) / * S a v e r e t b u f f e r * /
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
ld r10 ,S T K _ P A R M ( r11 ) ( r1 ) / * p u t a r g 7 i n R 1 0 * /
ld r11 ,S T K _ P A R M ( r12 ) ( r1 ) / * p u t a r g 8 i n R 1 1 * /
ld r12 ,S T K _ P A R M ( r13 ) ( r1 ) / * p u t a r g 9 i n R 1 2 * /
2006-03-30 22:47:14 +02:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2007-01-09 02:37:16 +11:00
mr r0 ,r12
2006-07-19 08:01:28 +10:00
ld r12 ,S T K _ P A R M ( r4 ) ( r1 )
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
std r8 , 3 2 ( r12 )
std r9 , 4 0 ( r12 )
std r10 ,4 8 ( r12 )
std r11 ,5 6 ( r12 )
2007-01-09 02:37:16 +11:00
std r0 , 6 4 ( r12 )
2006-03-30 22:47:14 +02:00
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P O S T C A L L ( r12 )
2006-09-06 16:23:12 -07:00
2006-03-30 22:47:14 +02:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2010-05-10 20:28:26 +00:00
/* See plpar_hcall_raw to see why this is needed */
_ GLOBAL( p l p a r _ h c a l l 9 _ r a w )
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
std r4 ,S T K _ P A R M ( r4 ) ( r1 ) / * S a v e r e t b u f f e r * /
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
ld r10 ,S T K _ P A R M ( r11 ) ( r1 ) / * p u t a r g 7 i n R 1 0 * /
ld r11 ,S T K _ P A R M ( r12 ) ( r1 ) / * p u t a r g 8 i n R 1 1 * /
ld r12 ,S T K _ P A R M ( r13 ) ( r1 ) / * p u t a r g 9 i n R 1 2 * /
HVSC / * i n v o k e t h e h y p e r v i s o r * /
mr r0 ,r12
ld r12 ,S T K _ P A R M ( r4 ) ( r1 )
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
std r8 , 3 2 ( r12 )
std r9 , 4 0 ( r12 )
std r10 ,4 8 ( r12 )
std r11 ,5 6 ( r12 )
std r0 , 6 4 ( r12 )
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /