2005-04-17 02:20:36 +04:00
/ *
* PAL F i r m w a r e s u p p o r t
* IA- 6 4 P r o c e s s o r P r o g r a m m e r s R e f e r e n c e V o l 2
*
* Copyright ( C ) 1 9 9 9 D o n D u g g e r < d o n . d u g g e r @intel.com>
* Copyright ( C ) 1 9 9 9 W a l t D r u m m o n d < d r u m m o n d @valinux.com>
* Copyright ( C ) 1 9 9 9 - 2 0 0 1 , 2 0 0 3 H e w l e t t - P a c k a r d C o
* David M o s b e r g e r < d a v i d m @hpl.hp.com>
* Stephane E r a n i a n < e r a n i a n @hpl.hp.com>
*
* 0 5 / 2 2 / 2 0 0 0 eranian A d d e d s u p p o r t f o r s t a c k e d r e g i s t e r c a l l s
* 0 5 / 2 4 / 2 0 0 0 eranian A d d e d s u p p o r t f o r p h y s i c a l m o d e s t a t i c c a l l s
* /
# include < a s m / a s m m a c r o . h >
# include < a s m / p r o c e s s o r . h >
.data
pal_entry_point :
data8 i a64 _ p a l _ d e f a u l t _ h a n d l e r
.text
/ *
2006-10-13 02:21:17 +04:00
* Set t h e P A L e n t r y p o i n t a d d r e s s . T h i s c o u l d b e w r i t t e n i n C c o d e , b u t w e
* do i t h e r e t o k e e p i t a l l i n o n e m o d u l e ( b e s i d e s , i t ' s s o t r i v i a l t h a t i t ' s
2005-04-17 02:20:36 +04:00
* not a b i g d e a l ) .
*
2006-10-13 02:21:17 +04:00
* in0 A d d r e s s o f t h e P A L e n t r y p o i n t ( t e x t a d d r e s s , N O T a f u n c t i o n
* descriptor) .
2005-04-17 02:20:36 +04:00
* /
GLOBAL_ E N T R Y ( i a64 _ p a l _ h a n d l e r _ i n i t )
alloc r3 =ar . p f s ,1 ,0 ,0 ,0
movl r2 =pal_entry_point
;;
st8 [ r2 ] =in0
br. r e t . s p t k . m a n y r p
END( i a64 _ p a l _ h a n d l e r _ i n i t )
/ *
2006-10-13 02:21:17 +04:00
* Default P A L c a l l h a n d l e r . T h i s n e e d s t o b e c o d e d i n a s s e m b l y b e c a u s e i t
* uses t h e s t a t i c c a l l i n g c o n v e n t i o n , i . e . , t h e R S E m a y n o t b e u s e d a n d
* calls a r e d o n e v i a " b r . c o n d " ( n o t " b r . c a l l " ) .
2005-04-17 02:20:36 +04:00
* /
GLOBAL_ E N T R Y ( i a64 _ p a l _ d e f a u l t _ h a n d l e r )
mov r8 = - 1
br. c o n d . s p t k . m a n y r p
END( i a64 _ p a l _ d e f a u l t _ h a n d l e r )
/ *
* Make a P A L c a l l u s i n g t h e s t a t i c c a l l i n g c o n v e n t i o n .
*
* in0 I n d e x o f P A L s e r v i c e
* in1 - i n 3 R e m a i n i n g P A L a r g u m e n t s
* /
GLOBAL_ E N T R Y ( i a64 _ p a l _ c a l l _ s t a t i c )
2006-10-13 02:20:59 +04:00
.prologue ASM_ U N W _ P R L G _ R P | A S M _ U N W _ P R L G _ P F S , A S M _ U N W _ P R L G _ G R S A V E ( 4 )
alloc l o c1 = a r . p f s ,4 ,5 ,0 ,0
2005-04-17 02:20:36 +04:00
movl l o c2 = p a l _ e n t r y _ p o i n t
1 : {
mov r28 = i n 0
mov r29 = i n 1
mov r8 = i p
}
;;
ld8 l o c2 = [ l o c2 ] / / l o c2 < - e n t r y p o i n t
adds r8 = 1 f - 1 b ,r8
mov l o c4 =ar . r s c / / s a v e R S E c o n f i g u r a t i o n
;;
mov a r . r s c =0 / / p u t R S E i n e n f o r c e d l a z y , L E m o d e
mov l o c3 = p s r
mov l o c0 = r p
.body
mov r30 = i n 2
mov r31 = i n 3
mov b7 = l o c2
2006-10-13 02:20:59 +04:00
rsm p s r . i
2005-04-17 02:20:36 +04:00
;;
mov r p = r8
br. c o n d . s p t k . m a n y b7
1 : mov p s r . l = l o c3
mov a r . r s c = l o c4 / / r e s t o r e R S E c o n f i g u r a t i o n
mov a r . p f s = l o c1
mov r p = l o c0
;;
srlz. d / / s e r a l i z e r e s t o r a t i o n o f p s r . l
br. r e t . s p t k . m a n y b0
END( i a64 _ p a l _ c a l l _ s t a t i c )
/ *
* Make a P A L c a l l u s i n g t h e s t a c k e d r e g i s t e r s c a l l i n g c o n v e n t i o n .
*
* Inputs :
2006-10-13 02:21:17 +04:00
* in0 I n d e x o f P A L s e r v i c e
* in2 - i n 3 R e m a i n i n g P A L a r g u m e n t s
2005-04-17 02:20:36 +04:00
* /
GLOBAL_ E N T R Y ( i a64 _ p a l _ c a l l _ s t a c k e d )
.prologue ASM_ U N W _ P R L G _ R P | A S M _ U N W _ P R L G _ P F S , A S M _ U N W _ P R L G _ G R S A V E ( 4 )
alloc l o c1 = a r . p f s ,4 ,4 ,4 ,0
movl l o c2 = p a l _ e n t r y _ p o i n t
mov r28 = i n 0 / / I n d e x M U S T b e c o p i e d t o r28
mov o u t 0 = i n 0 / / A N D i n 0 o f P A L f u n c t i o n
mov l o c0 = r p
.body
;;
ld8 l o c2 = [ l o c2 ] / / l o c2 < - e n t r y p o i n t
mov o u t 1 = i n 1
mov o u t 2 = i n 2
mov o u t 3 = i n 3
mov l o c3 = p s r
;;
rsm p s r . i
mov b7 = l o c2
;;
br. c a l l . s p t k . m a n y r p =b7 / / n o w m a k e t h e c a l l
.ret0 : mov p s r . l = l o c3
mov a r . p f s = l o c1
mov r p = l o c0
;;
srlz. d / / s e r i a l i z e r e s t o r a t i o n o f p s r . l
br. r e t . s p t k . m a n y b0
END( i a64 _ p a l _ c a l l _ s t a c k e d )
/ *
* Make a p h y s i c a l m o d e P A L c a l l u s i n g t h e s t a t i c r e g i s t e r s c a l l i n g c o n v e n t i o n .
*
* Inputs :
2006-10-13 02:21:17 +04:00
* in0 I n d e x o f P A L s e r v i c e
* in2 - i n 3 R e m a i n i n g P A L a r g u m e n t s
2005-04-17 02:20:36 +04:00
*
* PSR_ L P , P S R _ T B , P S R _ I D , P S R _ D A a r e n e v e r s e t b y t h e k e r n e l .
* So w e d o n ' t n e e d t o c l e a r t h e m .
* /
2006-10-13 02:21:17 +04:00
# define P A L _ P S R _ B I T S _ T O _ C L E A R \
( IA6 4 _ P S R _ I | I A 6 4 _ P S R _ I T | I A 6 4 _ P S R _ D T | I A 6 4 _ P S R _ D B | I A 6 4 _ P S R _ R T | \
IA6 4 _ P S R _ D D | I A 6 4 _ P S R _ S S | I A 6 4 _ P S R _ R I | I A 6 4 _ P S R _ E D | \
2005-04-17 02:20:36 +04:00
IA6 4 _ P S R _ D F L | I A 6 4 _ P S R _ D F H )
2006-10-13 02:21:17 +04:00
# define P A L _ P S R _ B I T S _ T O _ S E T \
2005-04-17 02:20:36 +04:00
( IA6 4 _ P S R _ B N )
GLOBAL_ E N T R Y ( i a64 _ p a l _ c a l l _ p h y s _ s t a t i c )
.prologue ASM_ U N W _ P R L G _ R P | A S M _ U N W _ P R L G _ P F S , A S M _ U N W _ P R L G _ G R S A V E ( 4 )
alloc l o c1 = a r . p f s ,4 ,7 ,0 ,0
movl l o c2 = p a l _ e n t r y _ p o i n t
1 : {
mov r28 = i n 0 / / c o p y p r o c e d u r e i n d e x
mov r8 = i p / / s a v e i p t o c o m p u t e b r a n c h
mov l o c0 = r p / / s a v e r p
}
.body
;;
ld8 l o c2 = [ l o c2 ] / / l o c2 < - e n t r y p o i n t
mov r29 = i n 1 / / f i r s t a r g u m e n t
mov r30 = i n 2 / / c o p y a r g 2
mov r31 = i n 3 / / c o p y a r g 3
;;
mov l o c3 = p s r / / s a v e p s r
adds r8 = 1 f - 1 b ,r8 / / c a l c u l a t e r e t u r n a d d r e s s f o r c a l l
;;
mov l o c4 =ar . r s c / / s a v e R S E c o n f i g u r a t i o n
dep. z l o c2 =loc2 ,0 ,6 1 / / c o n v e r t p a l e n t r y p o i n t t o p h y s i c a l
tpa r8 =r8 / / c o n v e r t r p t o p h y s i c a l
;;
mov b7 = l o c2 / / i n s t a l l t a r g e t t o b r a n c h r e g
mov a r . r s c =0 / / p u t R S E i n e n f o r c e d l a z y , L E m o d e
movl r16 =PAL_PSR_BITS_TO_CLEAR
movl r17 =PAL_PSR_BITS_TO_SET
;;
or l o c3 =loc3 ,r17 / / a d d i n p s r t h e b i t s t o s e t
;;
andcm r16 =loc3 ,r16 / / r e m o v e s b i t s t o c l e a r f r o m p s r
br. c a l l . s p t k . m a n y r p =ia64_switch_mode_phys
2006-10-13 02:21:17 +04:00
mov r p = r8 / / i n s t a l l r e t u r n a d d r e s s ( p h y s i c a l )
2005-04-17 02:20:36 +04:00
mov l o c5 = r19
mov l o c6 = r20
br. c o n d . s p t k . m a n y b7
1 :
mov a r . r s c =0 / / p u t R S E i n e n f o r c e d l a z y , L E m o d e
mov r16 =loc3 / / r16 = o r i g i n a l p s r
mov r19 =loc5
mov r20 =loc6
br. c a l l . s p t k . m a n y r p =ia64_switch_mode_virt / / r e t u r n t o v i r t u a l m o d e
mov p s r . l = l o c3 / / r e s t o r e i n i t P S R
mov a r . p f s = l o c1
mov r p = l o c0
;;
mov a r . r s c =loc4 / / r e s t o r e R S E c o n f i g u r a t i o n
srlz. d / / s e r a l i z e r e s t o r a t i o n o f p s r . l
br. r e t . s p t k . m a n y b0
END( i a64 _ p a l _ c a l l _ p h y s _ s t a t i c )
/ *
* Make a P A L c a l l u s i n g t h e s t a c k e d r e g i s t e r s i n p h y s i c a l m o d e .
*
* Inputs :
2006-10-13 02:21:17 +04:00
* in0 I n d e x o f P A L s e r v i c e
* in2 - i n 3 R e m a i n i n g P A L a r g u m e n t s
2005-04-17 02:20:36 +04:00
* /
GLOBAL_ E N T R Y ( i a64 _ p a l _ c a l l _ p h y s _ s t a c k e d )
.prologue ASM_ U N W _ P R L G _ R P | A S M _ U N W _ P R L G _ P F S , A S M _ U N W _ P R L G _ G R S A V E ( 5 )
alloc l o c1 = a r . p f s ,5 ,7 ,4 ,0
movl l o c2 = p a l _ e n t r y _ p o i n t
1 : {
mov r28 = i n 0 / / c o p y p r o c e d u r e i n d e x
2006-10-13 02:21:17 +04:00
mov l o c0 = r p / / s a v e r p
2005-04-17 02:20:36 +04:00
}
.body
;;
ld8 l o c2 = [ l o c2 ] / / l o c2 < - e n t r y p o i n t
2006-07-26 03:26:51 +04:00
mov l o c3 = p s r / / s a v e p s r
2005-04-17 02:20:36 +04:00
;;
mov l o c4 =ar . r s c / / s a v e R S E c o n f i g u r a t i o n
dep. z l o c2 =loc2 ,0 ,6 1 / / c o n v e r t p a l e n t r y p o i n t t o p h y s i c a l
;;
mov a r . r s c =0 / / p u t R S E i n e n f o r c e d l a z y , L E m o d e
movl r16 =PAL_PSR_BITS_TO_CLEAR
movl r17 =PAL_PSR_BITS_TO_SET
;;
or l o c3 =loc3 ,r17 / / a d d i n p s r t h e b i t s t o s e t
mov b7 = l o c2 / / i n s t a l l t a r g e t t o b r a n c h r e g
;;
andcm r16 =loc3 ,r16 / / r e m o v e s b i t s t o c l e a r f r o m p s r
br. c a l l . s p t k . m a n y r p =ia64_switch_mode_phys
2006-07-26 03:26:51 +04:00
mov o u t 0 = i n 0 / / f i r s t a r g u m e n t
mov o u t 1 = i n 1 / / c o p y a r g 2
mov o u t 2 = i n 2 / / c o p y a r g 3
mov o u t 3 = i n 3 / / c o p y a r g 3
2005-04-17 02:20:36 +04:00
mov l o c5 = r19
mov l o c6 = r20
2006-07-26 03:26:51 +04:00
2005-04-17 02:20:36 +04:00
br. c a l l . s p t k . m a n y r p =b7 / / n o w m a k e t h e c a l l
2006-07-26 03:26:51 +04:00
2005-04-17 02:20:36 +04:00
mov a r . r s c =0 / / p u t R S E i n e n f o r c e d l a z y , L E m o d e
mov r16 =loc3 / / r16 = o r i g i n a l p s r
mov r19 =loc5
mov r20 =loc6
2006-10-13 02:21:17 +04:00
br. c a l l . s p t k . m a n y r p =ia64_switch_mode_virt / / r e t u r n t o v i r t u a l m o d e
2005-04-17 02:20:36 +04:00
2006-07-26 03:26:51 +04:00
mov p s r . l = l o c3 / / r e s t o r e i n i t P S R
2005-04-17 02:20:36 +04:00
mov a r . p f s = l o c1
mov r p = l o c0
;;
mov a r . r s c =loc4 / / r e s t o r e R S E c o n f i g u r a t i o n
srlz. d / / s e r a l i z e r e s t o r a t i o n o f p s r . l
br. r e t . s p t k . m a n y b0
END( i a64 _ p a l _ c a l l _ p h y s _ s t a c k e d )
/ *
2006-10-13 02:21:17 +04:00
* Save s c r a t c h f p s c r a t c h r e g s w h i c h a r e n ' t s a v e d i n p t _ r e g s a l r e a d y
* ( fp1 0 - f p15 ) .
2005-04-17 02:20:36 +04:00
*
2006-10-13 02:21:17 +04:00
* NOTE : We n e e d t o d o t h i s s i n c e f i r m w a r e ( S A L a n d P A L ) m a y u s e a n y o f t h e
* scratch r e g s f p - l o w p a r t i t i o n .
2005-04-17 02:20:36 +04:00
*
* Inputs :
* in0 A d d r e s s o f s t a c k s t o r a g e f o r f p r e g s
* /
GLOBAL_ E N T R Y ( i a64 _ s a v e _ s c r a t c h _ f p r e g s )
alloc r3 =ar . p f s ,1 ,0 ,0 ,0
add r2 =16 ,i n 0
;;
stf. s p i l l [ i n 0 ] = f10 ,3 2
stf. s p i l l [ r2 ] = f11 ,3 2
;;
stf. s p i l l [ i n 0 ] = f12 ,3 2
stf. s p i l l [ r2 ] = f13 ,3 2
;;
stf. s p i l l [ i n 0 ] = f14 ,3 2
stf. s p i l l [ r2 ] = f15 ,3 2
br. r e t . s p t k . m a n y r p
END( i a64 _ s a v e _ s c r a t c h _ f p r e g s )
/ *
* Load s c r a t c h f p s c r a t c h r e g s ( f p10 - f p15 )
*
* Inputs :
* in0 A d d r e s s o f s t a c k s t o r a g e f o r f p r e g s
* /
GLOBAL_ E N T R Y ( i a64 _ l o a d _ s c r a t c h _ f p r e g s )
alloc r3 =ar . p f s ,1 ,0 ,0 ,0
add r2 =16 ,i n 0
;;
ldf. f i l l f10 = [ i n 0 ] ,3 2
ldf. f i l l f11 = [ r2 ] ,3 2
;;
ldf. f i l l f12 = [ i n 0 ] ,3 2
ldf. f i l l f13 = [ r2 ] ,3 2
;;
ldf. f i l l f14 = [ i n 0 ] ,3 2
ldf. f i l l f15 = [ r2 ] ,3 2
br. r e t . s p t k . m a n y r p
END( i a64 _ l o a d _ s c r a t c h _ f p r e g s )