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 >
2005-04-16 15:20:36 -07:00
# define S T K _ P A R M ( i ) ( 4 8 + ( ( i ) - 3 ) * 8 )
2006-09-06 16:23:12 -07:00
# ifdef C O N F I G _ H C A L L _ S T A T S
/ *
* 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 ( )
* 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 .
* /
# define H C A L L _ I N S T _ P R E C A L L \
std r3 ,S T K _ P A R M ( r3 ) ( r1 ) ; /* save opcode */ \
mftb r0 ; /* get timebase and */ \
std r0 ,S T K _ P A R M ( r5 ) ( r1 ) ; /* save for later */ \
BEGIN_ F T R _ S E C T I O N ; \
mfspr r0 ,S P R N _ P U R R ; /* get PURR and */ \
std r0 ,S T K _ P A R M ( r6 ) ( r1 ) ; /* save for later */ \
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ P U R R ) ;
/ *
* 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
* 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 .
* /
# define H C A L L _ I N S T _ P O S T C A L L \
ld r4 ,S T K _ P A R M ( r3 ) ( r1 ) ; /* validate opcode */ \
cmpldi c r7 ,r4 ,M A X _ H C A L L _ O P C O D E ; \
bgt- c r7 ,1 f ; \
\
/* get time and PURR snapshots after hcall */ \
mftb r7 ; /* timebase after */ \
BEGIN_ F T R _ S E C T I O N ; \
mfspr r8 ,S P R N _ P U R R ; /* PURR after */ \
ld r6 ,S T K _ P A R M ( r6 ) ( r1 ) ; /* PURR before */ \
subf r6 ,r6 ,r8 ; /* delta */ \
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ P U R R ) ; \
ld r5 ,S T K _ P A R M ( r5 ) ( r1 ) ; /* timebase before */ \
subf r5 ,r5 ,r7 ; /* time delta */ \
\
/* calculate address of stat structure r4 = opcode */ \
srdi r4 ,r4 ,2 ; /* index into array */ \
mulli r4 ,r4 ,H C A L L _ S T A T _ S I Z E ; \
LOAD_ R E G _ A D D R ( r7 , p e r _ c p u _ _ h c a l l _ s t a t s ) ; \
add r4 ,r4 ,r7 ; \
ld r7 ,P A C A _ D A T A _ O F F S E T ( r13 ) ; /* per cpu offset */ \
add r4 ,r4 ,r7 ; \
\
/* update stats */ \
ld r7 ,H C A L L _ S T A T _ C A L L S ( r4 ) ; /* count */ \
addi r7 ,r7 ,1 ; \
std r7 ,H C A L L _ S T A T _ C A L L S ( r4 ) ; \
ld r7 ,H C A L L _ S T A T _ T B ( r4 ) ; /* timebase */ \
add r7 ,r7 ,r5 ; \
std r7 ,H C A L L _ S T A T _ T B ( r4 ) ; \
BEGIN_ F T R _ S E C T I O N ; \
ld r7 ,H C A L L _ S T A T _ P U R R ( r4 ) ; /* PURR */ \
add r7 ,r7 ,r6 ; \
std r7 ,H C A L L _ S T A T _ P U R R ( r4 ) ; \
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ P U R R ) ; \
1 :
# else
# define H C A L L _ I N S T _ P R E C A L L
# define H C A L L _ I N S T _ P O S T C A L L
# 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 )
2006-09-06 16:23:12 -07:00
HCALL_ I N S T _ P R E C A L L
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-09-06 16:23:12 -07:00
HCALL_ I N S T _ P O S T C A L L
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 )
2006-09-06 16:23:12 -07:00
HCALL_ I N S T _ P R E C A L L
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
2006-09-06 16:23:12 -07:00
HCALL_ I N S T _ P O S T C A L L
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 * /
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 )
2006-09-06 16:23:12 -07:00
HCALL_ I N S T _ P R E C A L L
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 * /
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 )
std r12 ,6 4 ( r12 )
2006-03-30 22:47:14 +02:00
2006-09-06 16:23:12 -07:00
HCALL_ I N S T _ P O S T C A L L
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 * /