2005-04-17 02:20:36 +04:00
/ /
/ / assembly p o r t i o n o f t h e I A 6 4 M C A h a n d l i n g
/ /
/ / Mods b y c f l e c k t o i n t e g r a t e i n t o k e r n e l b u i l d
/ / 0 0 / 0 3 / 1 5 davidm A d d e d v a r i o u s s t o p b i t s t o g e t a c l e a n c o m p i l e
/ /
/ / 0 0 / 0 3 / 2 9 cfleck A d d e d c o d e t o s a v e I N I T h a n d o f f s t a t e i n p t _ r e g s f o r m a t , s w i t c h t o t e m p
/ / kstack, s w i t c h m o d e s , j u m p t o C I N I T h a n d l e r
/ /
/ / 0 2 / 0 1 / 0 4 J. H a l l < j e n n a . s . h a l l @intel.com>
/ / Before e n t e r i n g v i r t u a l m o d e c o d e :
/ / 1 . Check f o r T L B C P U e r r o r
/ / 2 . Restore c u r r e n t t h r e a d p o i n t e r t o k r6
/ / 3 . Move s t a c k p t r 1 6 b y t e s t o c o n f o r m t o C c a l l i n g c o n v e n t i o n
/ /
/ / 0 4 / 1 1 / 1 2 Russ A n d e r s o n < r j a @sgi.com>
/ / Added p e r c p u M C A / I N I T s t a c k s a v e a r e a s .
/ /
2005-09-11 11:22:53 +04:00
/ / 1 2 / 0 8 / 0 5 Keith O w e n s < k a o s @sgi.com>
/ / Use p e r c p u M C A / I N I T s t a c k s f o r a l l d a t a .
/ /
2005-04-17 02:20:36 +04:00
# include < l i n u x / c o n f i g . h >
# include < l i n u x / t h r e a d s . h >
# include < a s m / a s m m a c r o . h >
# include < a s m / p g t a b l e . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / m c a _ a s m . h >
# include < a s m / m c a . h >
2005-09-11 11:22:53 +04:00
# include " e n t r y . h "
2005-04-17 02:20:36 +04:00
# define G E T _ I A 6 4 _ M C A _ D A T A ( r e g ) \
GET_ T H I S _ P A D D R ( r e g , i a64 _ m c a _ d a t a ) \
;; \
ld8 r e g = [ r e g ]
2005-04-23 01:44:40 +04:00
.global ia64_do_tlb_purge
2005-09-11 11:22:53 +04:00
.global ia64_os_mca_dispatch
.global ia64_os_init_dispatch_monarch
.global ia64_os_init_dispatch_slave
2005-04-17 02:20:36 +04:00
.text
.align 16
2005-09-11 11:22:53 +04:00
/ / StartMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
2005-04-23 01:44:40 +04:00
/ *
* Just t h e T L B p u r g e p a r t i s m o v e d t o a s e p a r a t e f u n c t i o n
* so w e c a n r e - u s e t h e c o d e f o r c p u h o t p l u g c o d e a s w e l l
* Caller s h o u l d n o w s e t u p b1 , s o w e c a n b r a n c h o n c e t h e
* tlb f l u s h i s c o m p l e t e .
* /
2005-04-17 02:20:36 +04:00
2005-04-23 01:44:40 +04:00
ia64_do_tlb_purge :
2005-04-17 02:20:36 +04:00
# define O ( m e m b e r ) I A 6 4 _ C P U I N F O _ ## m e m b e r # # _ O F F S E T
GET_ T H I S _ P A D D R ( r2 , c p u _ i n f o ) / / l o a d p h y s a d d r o f c p u _ i n f o i n t o r2
;;
addl r17 =O ( P T C E _ S T R I D E ) ,r2
addl r2 =O ( P T C E _ B A S E ) ,r2
;;
ld8 r18 = [ r2 ] ,( O ( P T C E _ C O U N T ) - O ( P T C E _ B A S E ) ) ;; // r18=ptce_base
ld4 r19 = [ r2 ] ,4 / / r19 =ptce_count [ 0 ]
ld4 r21 = [ r17 ] ,4 / / r21 =ptce_stride [ 0 ]
;;
ld4 r20 = [ r2 ] / / r20 =ptce_count [ 1 ]
ld4 r22 = [ r17 ] / / r22 =ptce_stride [ 1 ]
mov r24 =0
;;
adds r20 = - 1 ,r20
;;
# undef O
2 :
cmp. l t u p6 ,p7 =r24 ,r19
( p7 ) b r . c o n d . d p n t . f e w 4 f
mov a r . l c =r20
3 :
ptc. e r18
;;
add r18 =r22 ,r18
br. c l o o p . s p t k . f e w 3 b
;;
add r18 =r21 ,r18
add r24 =1 ,r24
;;
br. s p t k . f e w 2 b
4 :
srlz. i / / s r l z . i i m p l i e s s r l z . d
;;
/ / Now p u r g e a d d r e s s e s f o r m e r l y m a p p e d b y T R r e g i s t e r s
/ / 1 . Purge I T R & D T R f o r k e r n e l .
movl r16 =KERNEL_START
mov r18 =KERNEL_TR_PAGE_SHIFT < < 2
;;
ptr. i r16 , r18
ptr. d r16 , r18
;;
srlz. i
;;
srlz. d
;;
/ / 2 . Purge D T R f o r P E R C P U d a t a .
movl r16 =PERCPU_ADDR
mov r18 =PERCPU_PAGE_SHIFT < < 2
;;
ptr. d r16 ,r18
;;
srlz. d
;;
/ / 3 . Purge I T R f o r P A L c o d e .
GET_ T H I S _ P A D D R ( r2 , i a64 _ m c a _ p a l _ b a s e )
;;
ld8 r16 = [ r2 ]
mov r18 =IA64_GRANULE_SHIFT < < 2
;;
ptr. i r16 ,r18
;;
srlz. i
;;
/ / 4 . Purge D T R f o r s t a c k .
mov r16 =IA64_KR ( C U R R E N T _ S T A C K )
;;
shl r16 =r16 ,I A 6 4 _ G R A N U L E _ S H I F T
movl r19 =PAGE_OFFSET
;;
add r16 =r19 ,r16
mov r18 =IA64_GRANULE_SHIFT < < 2
;;
ptr. d r16 ,r18
;;
srlz. i
;;
2005-04-23 01:44:40 +04:00
/ / Now b r a n c h a w a y t o c a l l e r .
br. s p t k . m a n y b1
;;
2005-09-11 11:22:53 +04:00
/ / EndMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / StartMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
2005-04-23 01:44:40 +04:00
2005-09-11 11:22:53 +04:00
ia64_os_mca_dispatch :
2005-04-23 01:44:40 +04:00
/ / Serialize a l l M C A p r o c e s s i n g
mov r3 =1 ;;
LOAD_ P H Y S I C A L ( p0 ,r2 ,i a64 _ m c a _ s e r i a l i z e ) ;;
ia64_os_mca_spin :
2005-09-11 11:22:53 +04:00
xchg4 r4 = [ r2 ] ,r3 ;;
2005-04-23 01:44:40 +04:00
cmp. n e p6 ,p0 =r4 ,r0
( p6 ) b r i a64 _ o s _ m c a _ s p i n
2005-09-11 11:22:53 +04:00
mov r3 =IA64_MCA_CPU_MCA_STACK_OFFSET / / u s e t h e M C A s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
mov r19 =1 / / A l l M C A e v e n t s a r e t r e a t e d a s m o n a r c h ( f o r n o w )
br. s p t k i a64 _ s t a t e _ s a v e / / s a v e t h e s t a t e t h a t i s n o t i n m i n s t a t e
1 :
2005-04-23 01:44:40 +04:00
2005-09-11 11:22:53 +04:00
GET_ I A 6 4 _ M C A _ D A T A ( r2 )
/ / Using M C A s t a c k , s t r u c t i a64 _ s a l _ o s _ s t a t e , v a r i a b l e p r o c _ s t a t e _ p a r a m
;;
add r3 =IA64_MCA_CPU_MCA_STACK_OFFSET + M C A _ S O S _ O F F S E T + I A 6 4 _ S A L _ O S _ S T A T E _ P R O C _ S T A T E _ P A R A M _ O F F S E T , r2
2005-04-23 01:44:40 +04:00
;;
2005-09-11 11:22:53 +04:00
ld8 r18 = [ r3 ] / / G e t p r o c e s s o r s t a t e p a r a m e t e r o n e x i s t i n g P A L E _ C H E C K .
2005-04-23 01:44:40 +04:00
;;
tbit. n z p6 ,p7 =r18 ,6 0
( p7 ) b r . s p n t d o n e _ t l b _ p u r g e _ a n d _ r e l o a d
/ / The f o l l o w i n g c o d e p u r g e s T C a n d T R e n t r i e s . T h e n r e l o a d a l l T C e n t r i e s .
/ / Purge p e r c p u d a t a T C e n t r i e s .
begin_tlb_purge_and_reload :
movl r18 =ia64_reload_tr ;;
LOAD_ P H Y S I C A L ( p0 ,r18 ,i a64 _ r e l o a d _ t r ) ;;
mov b1 =r18 ;;
br. s p t k . m a n y i a64 _ d o _ t l b _ p u r g e ;;
ia64_reload_tr :
2005-04-17 02:20:36 +04:00
/ / Finally r e l o a d t h e T R r e g i s t e r s .
/ / 1 . Reload D T R / I T R r e g i s t e r s f o r k e r n e l .
mov r18 =KERNEL_TR_PAGE_SHIFT < < 2
movl r17 =KERNEL_START
;;
mov c r . i t i r =r18
mov c r . i f a =r17
mov r16 =IA64_TR_KERNEL
mov r19 =ip
movl r18 =PAGE_KERNEL
;;
dep r17 =0 ,r19 ,0 , K E R N E L _ T R _ P A G E _ S H I F T
;;
or r18 =r17 ,r18
;;
itr. i i t r [ r16 ] =r18
;;
itr. d d t r [ r16 ] =r18
;;
srlz. i
srlz. d
;;
/ / 2 . Reload D T R r e g i s t e r f o r P E R C P U d a t a .
GET_ T H I S _ P A D D R ( r2 , i a64 _ m c a _ p e r _ c p u _ p t e )
;;
movl r16 =PERCPU_ADDR / / v a d d r
movl r18 =PERCPU_PAGE_SHIFT < < 2
;;
mov c r . i t i r =r18
mov c r . i f a =r16
;;
ld8 r18 = [ r2 ] / / l o a d p e r - C P U P T E
mov r16 =IA64_TR_PERCPU_DATA ;
;;
itr. d d t r [ r16 ] =r18
;;
srlz. d
;;
/ / 3 . Reload I T R f o r P A L c o d e .
GET_ T H I S _ P A D D R ( r2 , i a64 _ m c a _ p a l _ p t e )
;;
ld8 r18 = [ r2 ] / / l o a d P A L P T E
;;
GET_ T H I S _ P A D D R ( r2 , i a64 _ m c a _ p a l _ b a s e )
;;
ld8 r16 = [ r2 ] / / l o a d P A L v a d d r
mov r19 =IA64_GRANULE_SHIFT < < 2
;;
mov c r . i t i r =r19
mov c r . i f a =r16
mov r20 =IA64_TR_PALCODE
;;
itr. i i t r [ r20 ] =r18
;;
srlz. i
;;
/ / 4 . Reload D T R f o r s t a c k .
mov r16 =IA64_KR ( C U R R E N T _ S T A C K )
;;
shl r16 =r16 ,I A 6 4 _ G R A N U L E _ S H I F T
movl r19 =PAGE_OFFSET
;;
add r18 =r19 ,r16
movl r20 =PAGE_KERNEL
;;
add r16 =r20 ,r16
mov r19 =IA64_GRANULE_SHIFT < < 2
;;
mov c r . i t i r =r19
mov c r . i f a =r18
mov r20 =IA64_TR_CURRENT_STACK
;;
itr. d d t r [ r20 ] =r16
;;
srlz. d
done_tlb_purge_and_reload :
2005-09-11 11:22:53 +04:00
/ / switch t o p e r c p u M C A s t a c k
mov r3 =IA64_MCA_CPU_MCA_STACK_OFFSET / / u s e t h e M C A s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ n e w _ s t a c k
1 :
/ / everything s a v e d , n o w w e c a n s e t t h e k e r n e l r e g i s t e r s
mov r3 =IA64_MCA_CPU_MCA_STACK_OFFSET / / u s e t h e M C A s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ s e t _ k e r n e l _ r e g i s t e r s
1 :
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / This m u s t b e d o n e i n p h y s i c a l m o d e
2005-04-17 02:20:36 +04:00
GET_ I A 6 4 _ M C A _ D A T A ( r2 )
;;
2005-09-11 11:22:53 +04:00
mov r7 =r2
2005-04-17 02:20:36 +04:00
/ / Enter v i r t u a l m o d e f r o m p h y s i c a l m o d e
VIRTUAL_ M O D E _ E N T E R ( r2 , r3 , i a64 _ o s _ m c a _ v i r t u a l _ b e g i n , r4 )
2005-09-11 11:22:53 +04:00
/ / This c o d e r e t u r n s t o S A L v i a S O S r2 , i n g e n e r a l S A L h a s n o u n w i n d
/ / data. T o g e t a c l e a n t e r m i n a t i o n w h e n b a c k t r a c i n g t h e C M C A / I N I T
/ / handler, s e t a d u m m y r e t u r n a d d r e s s o f 0 i n t h i s r o u t i n e . T h a t
/ / requires t h a t i a64 _ o s _ m c a _ v i r t u a l _ b e g i n b e a g l o b a l f u n c t i o n .
ENTRY( i a64 _ o s _ m c a _ v i r t u a l _ b e g i n )
.prologue
.save rp,r0
.body
mov a r . r s c =3 / / s e t e a g e r m o d e f o r C h a n d l e r
mov r2 =r7 / / s e e G E T _ I A 6 4 _ M C A _ D A T A a b o v e
;;
2005-04-17 02:20:36 +04:00
/ / Call v i r t u a l m o d e h a n d l e r
2005-09-11 11:22:53 +04:00
alloc r14 =ar . p f s ,0 ,0 ,3 ,0
;;
DATA_ P A _ T O _ V A ( r2 ,r7 )
;;
add o u t 0 =IA64_MCA_CPU_MCA_STACK_OFFSET + M C A _ P T _ R E G S _ O F F S E T , r2
add o u t 1 =IA64_MCA_CPU_MCA_STACK_OFFSET + M C A _ S W I T C H _ S T A C K _ O F F S E T , r2
add o u t 2 =IA64_MCA_CPU_MCA_STACK_OFFSET + M C A _ S O S _ O F F S E T , r2
br. c a l l . s p t k . m a n y b0 =ia64_mca_handler
2005-04-17 02:20:36 +04:00
/ / Revert b a c k t o p h y s i c a l m o d e b e f o r e g o i n g b a c k t o S A L
PHYSICAL_ M O D E _ E N T E R ( r2 , r3 , i a64 _ o s _ m c a _ v i r t u a l _ e n d , r4 )
ia64_os_mca_virtual_end :
2005-09-11 11:22:53 +04:00
END( i a64 _ o s _ m c a _ v i r t u a l _ b e g i n )
/ / switch b a c k t o p r e v i o u s s t a c k
alloc r14 =ar . p f s ,0 ,0 ,0 ,0 / / r e m o v e t h e M C A h a n d l e r f r a m e
mov r3 =IA64_MCA_CPU_MCA_STACK_OFFSET / / u s e t h e M C A s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ o l d _ s t a c k
1 :
mov r3 =IA64_MCA_CPU_MCA_STACK_OFFSET / / u s e t h e M C A s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ s t a t e _ r e s t o r e / / r e s t o r e t h e S A L s t a t e
1 :
mov b0 =r12 / / S A L _ C H E C K r e t u r n a d d r e s s
/ / release l o c k
LOAD_ P H Y S I C A L ( p0 ,r3 ,i a64 _ m c a _ s e r i a l i z e ) ;;
st4 . r e l [ r3 ] =r0
br b0
/ / EndMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / StartMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ /
/ / SAL t o O S e n t r y p o i n t f o r I N I T o n a l l p r o c e s s o r s . T h i s h a s b e e n d e f i n e d f o r
/ / registration p u r p o s e s w i t h S A L a s a p a r t o f i a64 _ m c a _ i n i t . M o n a r c h a n d
/ / slave I N I T h a v e i d e n t i c a l p r o c e s s i n g , e x c e p t f o r t h e v a l u e o f t h e
/ / sos- > m o n a r c h f l a g i n r19 .
/ /
ia64_os_init_dispatch_monarch :
mov r19 =1 / / B o w , b o w , y e l o w e r m i d d l e c l a s s e s !
br. s p t k i a64 _ o s _ i n i t _ d i s p a t c h
ia64_os_init_dispatch_slave :
mov r19 =0 / / < i g o r > y e t h , m a t h t e r < / i g o r >
ia64_os_init_dispatch :
mov r3 =IA64_MCA_CPU_INIT_STACK_OFFSET / / u s e t h e I N I T s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ s t a t e _ s a v e / / s a v e t h e s t a t e t h a t i s n o t i n m i n s t a t e
1 :
/ / switch t o p e r c p u I N I T s t a c k
mov r3 =IA64_MCA_CPU_INIT_STACK_OFFSET / / u s e t h e I N I T s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ n e w _ s t a c k
1 :
/ / everything s a v e d , n o w w e c a n s e t t h e k e r n e l r e g i s t e r s
mov r3 =IA64_MCA_CPU_INIT_STACK_OFFSET / / u s e t h e I N I T s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ s e t _ k e r n e l _ r e g i s t e r s
1 :
/ / This m u s t b e d o n e i n p h y s i c a l m o d e
2005-04-17 02:20:36 +04:00
GET_ I A 6 4 _ M C A _ D A T A ( r2 )
;;
2005-09-11 11:22:53 +04:00
mov r7 =r2
/ / Enter v i r t u a l m o d e f r o m p h y s i c a l m o d e
VIRTUAL_ M O D E _ E N T E R ( r2 , r3 , i a64 _ o s _ i n i t _ v i r t u a l _ b e g i n , r4 )
/ / This c o d e r e t u r n s t o S A L v i a S O S r2 , i n g e n e r a l S A L h a s n o u n w i n d
/ / data. T o g e t a c l e a n t e r m i n a t i o n w h e n b a c k t r a c i n g t h e C M C A / I N I T
/ / handler, s e t a d u m m y r e t u r n a d d r e s s o f 0 i n t h i s r o u t i n e . T h a t
/ / requires t h a t i a64 _ o s _ i n i t _ v i r t u a l _ b e g i n b e a g l o b a l f u n c t i o n .
ENTRY( i a64 _ o s _ i n i t _ v i r t u a l _ b e g i n )
.prologue
.save rp,r0
.body
mov a r . r s c =3 / / s e t e a g e r m o d e f o r C h a n d l e r
mov r2 =r7 / / s e e G E T _ I A 6 4 _ M C A _ D A T A a b o v e
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
/ / Call v i r t u a l m o d e h a n d l e r
alloc r14 =ar . p f s ,0 ,0 ,3 ,0
;;
DATA_ P A _ T O _ V A ( r2 ,r7 )
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
add o u t 0 =IA64_MCA_CPU_INIT_STACK_OFFSET + M C A _ P T _ R E G S _ O F F S E T , r2
add o u t 1 =IA64_MCA_CPU_INIT_STACK_OFFSET + M C A _ S W I T C H _ S T A C K _ O F F S E T , r2
add o u t 2 =IA64_MCA_CPU_INIT_STACK_OFFSET + M C A _ S O S _ O F F S E T , r2
br. c a l l . s p t k . m a n y b0 =ia64_init_handler
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / Revert b a c k t o p h y s i c a l m o d e b e f o r e g o i n g b a c k t o S A L
PHYSICAL_ M O D E _ E N T E R ( r2 , r3 , i a64 _ o s _ i n i t _ v i r t u a l _ e n d , r4 )
ia64_os_init_virtual_end :
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
END( i a64 _ o s _ i n i t _ v i r t u a l _ b e g i n )
mov r3 =IA64_MCA_CPU_INIT_STACK_OFFSET / / u s e t h e I N I T s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ s t a t e _ r e s t o r e / / r e s t o r e t h e S A L s t a t e
1 :
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / switch b a c k t o p r e v i o u s s t a c k
alloc r14 =ar . p f s ,0 ,0 ,0 ,0 / / r e m o v e t h e I N I T h a n d l e r f r a m e
mov r3 =IA64_MCA_CPU_INIT_STACK_OFFSET / / u s e t h e I N I T s t a c k
LOAD_ P H Y S I C A L ( p0 ,r2 ,1 f ) / / r e t u r n a d d r e s s
br. s p t k i a64 _ o l d _ s t a c k
1 :
mov b0 =r12 / / S A L _ C H E C K r e t u r n a d d r e s s
2005-04-17 02:20:36 +04:00
br b0
2005-09-11 11:22:53 +04:00
2005-04-17 02:20:36 +04:00
/ / EndMain/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
2005-09-11 11:22:53 +04:00
/ / common d e f i n e s f o r t h e s t u b s
# define m s r4
# define r e g s r5
# define t e m p1 r2 / * c a r e f u l , i t o v e r l a p s w i t h i n p u t r e g i s t e r s * /
# define t e m p2 r3 / * c a r e f u l , i t o v e r l a p s w i t h i n p u t r e g i s t e r s * /
# define t e m p3 r7
# define t e m p4 r14
2005-04-17 02:20:36 +04:00
/ / + +
/ / Name :
2005-09-11 11:22:53 +04:00
/ / ia6 4 _ s t a t e _ s a v e ( )
2005-04-17 02:20:36 +04:00
/ /
/ / Stub D e s c r i p t i o n :
/ /
2005-09-11 11:22:53 +04:00
/ / Save t h e s t a t e t h a t i s n o t i n m i n s t a t e . T h i s i s s e n s i t i v e t o t h e l a y o u t o f
/ / struct i a64 _ s a l _ o s _ s t a t e i n m c a . h .
/ /
/ / r2 c o n t a i n s t h e r e t u r n a d d r e s s , r3 c o n t a i n s e i t h e r
/ / IA6 4 _ M C A _ C P U _ M C A _ S T A C K _ O F F S E T o r I A 6 4 _ M C A _ C P U _ I N I T _ S T A C K _ O F F S E T .
/ /
/ / The O S t o S A L s e c t i o n o f s t r u c t i a64 _ s a l _ o s _ s t a t e i s s e t t o a d e f a u l t
/ / value o f c o l d b o o t ( M C A ) o r w a r m b o o t ( I N I T ) a n d r e t u r n t o t h e s a m e
/ / context. i a64 _ s a l _ o s _ s t a t e i s a l s o u s e d t o h o l d s o m e r e g i s t e r s t h a t
/ / need t o b e s a v e d a n d r e s t o r e d a c r o s s t h e s t a c k s w i t c h e s .
/ /
/ / Most i n p u t r e g i s t e r s t o t h i s s t u b c o m e f r o m P A L / S A L
/ / r1 o s g p , p h y s i c a l
/ / r8 p a l _ p r o c e n t r y p o i n t
/ / r9 s a l _ p r o c e n t r y p o i n t
/ / r1 0 s a l g p
/ / r1 1 M C A - r e n d e v z o u s s t a t e , I N I T - r e a s o n c o d e
/ / r1 2 s a l r e t u r n a d d r e s s
/ / r1 7 p a l m i n _ s t a t e
/ / r1 8 p r o c e s s o r s t a t e p a r a m e t e r
/ / r1 9 m o n a r c h f l a g , s e t b y t h e c a l l e r o f t h i s r o u t i n e
/ /
/ / In a d d i t i o n t o t h e S A L t o O S s t a t e , t h i s r o u t i n e s a v e s a l l t h e
/ / registers t h a t a p p e a r i n s t r u c t p t _ r e g s a n d s t r u c t s w i t c h _ s t a c k ,
/ / excluding t h o s e t h a t a r e a l r e a d y i n t h e P A L m i n s t a t e a r e a . T h i s
/ / results i n a p a r t i a l p t _ r e g s a n d s w i t c h _ s t a c k , t h e C c o d e c o p i e s t h e
/ / remaining r e g i s t e r s f r o m P A L m i n s t a t e t o p t _ r e g s a n d s w i t c h _ s t a c k . T h e
/ / resulting s t r u c t u r e s c o n t a i n a l l t h e s t a t e o f t h e o r i g i n a l p r o c e s s w h e n
/ / MCA/ I N I T o c c u r r e d .
2005-04-17 02:20:36 +04:00
/ /
/ / - -
2005-09-11 11:22:53 +04:00
ia64_state_save :
add r e g s =MCA_SOS_OFFSET , r3
add m s =MCA_SOS_OFFSET + 8 , r3
mov b0 =r2 / / s a v e r e t u r n a d d r e s s
cmp. e q p1 ,p2 =IA64_MCA_CPU_MCA_STACK_OFFSET , r3
;;
GET_ I A 6 4 _ M C A _ D A T A ( t e m p2 )
;;
add t e m p1 =temp2 , r e g s / / s t r u c t i a64 _ s a l _ o s _ s t a t e o n M C A o r I N I T s t a c k
add t e m p2 =temp2 , m s / / s t r u c t i a64 _ s a l _ o s _ s t a t e + 8 o n M C A o r I N I T s t a c k
;;
mov r e g s =temp1 / / s a v e t h e s t a r t o f s o s
st8 [ t e m p1 ] =r1 ,1 6 / / o s _ g p
st8 [ t e m p2 ] =r8 ,1 6 / / p a l _ p r o c
;;
st8 [ t e m p1 ] =r9 ,1 6 / / s a l _ p r o c
st8 [ t e m p2 ] =r11 ,1 6 / / r v _ r c
mov r11 =cr . i i p a
;;
st8 [ t e m p1 ] =r18 ,1 6 / / p r o c _ s t a t e _ p a r a m
st8 [ t e m p2 ] =r19 ,1 6 / / m o n a r c h
mov r6 =IA64_KR ( C U R R E N T )
;;
st8 [ t e m p1 ] =r12 ,1 6 / / s a l _ r a
st8 [ t e m p2 ] =r10 ,1 6 / / s a l _ g p
mov r12 =cr . i s r
;;
st8 [ t e m p1 ] =r17 ,1 6 / / p a l _ m i n _ s t a t e
st8 [ t e m p2 ] =r6 ,1 6 / / p r e v _ I A 6 4 _ K R _ C U R R E N T
mov r6 =cr . i f a
;;
st8 [ t e m p1 ] =r0 ,1 6 / / p r e v _ t a s k , s t a r t s o f f a s N U L L
st8 [ t e m p2 ] =r12 ,1 6 / / c r . i s r
mov r12 =cr . i t i r
;;
st8 [ t e m p1 ] =r6 ,1 6 / / c r . i f a
st8 [ t e m p2 ] =r12 ,1 6 / / c r . i t i r
mov r12 =cr . i i m
;;
st8 [ t e m p1 ] =r11 ,1 6 / / c r . i i p a
st8 [ t e m p2 ] =r12 ,1 6 / / c r . i i m
mov r6 =cr . i h a
( p1 ) m o v r12 =IA64_MCA_COLD_BOOT
( p2 ) m o v r12 =IA64_INIT_WARM_BOOT
;;
st8 [ t e m p1 ] =r6 ,1 6 / / c r . i h a
st8 [ t e m p2 ] =r12 / / o s _ s t a t u s , d e f a u l t i s c o l d b o o t
mov r6 =IA64_MCA_SAME_CONTEXT
;;
st8 [ t e m p1 ] =r6 / / c o n t e x t , d e f a u l t i s s a m e c o n t e x t
/ / Save t h e p t _ r e g s d a t a t h a t i s n o t i n m i n s t a t e . T h e p r e v i o u s c o d e
/ / left r e g s a t s o s .
add r e g s =MCA_PT_REGS_OFFSET - M C A _ S O S _ O F F S E T , r e g s
;;
add t e m p1 =PT ( B 6 ) , r e g s
mov t e m p3 =b6
mov t e m p4 =b7
add t e m p2 =PT ( B 7 ) , r e g s
;;
st8 [ t e m p1 ] =temp3 ,P T ( A R _ C S D ) - P T ( B 6 ) / / s a v e b6
st8 [ t e m p2 ] =temp4 ,P T ( A R _ S S D ) - P T ( B 7 ) / / s a v e b7
mov t e m p3 =ar . c s d
mov t e m p4 =ar . s s d
cover / / m u s t b e l a s t i n g r o u p
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
st8 [ t e m p1 ] =temp3 ,P T ( A R _ U N A T ) - P T ( A R _ C S D ) / / s a v e a r . c s d
st8 [ t e m p2 ] =temp4 ,P T ( A R _ P F S ) - P T ( A R _ S S D ) / / s a v e a r . s s d
mov t e m p3 =ar . u n a t
mov t e m p4 =ar . p f s
;;
st8 [ t e m p1 ] =temp3 ,P T ( A R _ R N A T ) - P T ( A R _ U N A T ) / / s a v e a r . u n a t
st8 [ t e m p2 ] =temp4 ,P T ( A R _ B S P S T O R E ) - P T ( A R _ P F S ) / / s a v e a r . p f s
mov t e m p3 =ar . r n a t
mov t e m p4 =ar . b s p s t o r e
;;
st8 [ t e m p1 ] =temp3 ,P T ( L O A D R S ) - P T ( A R _ R N A T ) / / s a v e a r . r n a t
st8 [ t e m p2 ] =temp4 ,P T ( A R _ F P S R ) - P T ( A R _ B S P S T O R E ) / / s a v e a r . b s p s t o r e
mov t e m p3 =ar . b s p
;;
sub t e m p3 =temp3 , t e m p4 / / a r . b s p - a r . b s p s t o r e
mov t e m p4 =ar . f p s r
;;
shl t e m p3 =temp3 ,1 6 / / c o m p u t e a r . r s c t o b e u s e d f o r " l o a d r s "
;;
st8 [ t e m p1 ] =temp3 ,P T ( A R _ C C V ) - P T ( L O A D R S ) / / s a v e l o a d r s
st8 [ t e m p2 ] =temp4 ,P T ( F 6 ) - P T ( A R _ F P S R ) / / s a v e a r . f p s r
mov t e m p3 =ar . c c v
;;
st8 [ t e m p1 ] =temp3 ,P T ( F 7 ) - P T ( A R _ C C V ) / / s a v e a r . c c v
stf. s p i l l [ t e m p2 ] =f6 ,P T ( F 8 ) - P T ( F 6 )
;;
stf. s p i l l [ t e m p1 ] =f7 ,P T ( F 9 ) - P T ( F 7 )
stf. s p i l l [ t e m p2 ] =f8 ,P T ( F 1 0 ) - P T ( F 8 )
;;
stf. s p i l l [ t e m p1 ] =f9 ,P T ( F 1 1 ) - P T ( F 9 )
stf. s p i l l [ t e m p2 ] =f10
;;
stf. s p i l l [ t e m p1 ] =f11
/ / Save t h e s w i t c h _ s t a c k d a t a t h a t i s n o t i n m i n s t a t e n o r p t _ r e g s . T h e
/ / previous c o d e l e f t r e g s a t p t _ r e g s .
add r e g s =MCA_SWITCH_STACK_OFFSET - M C A _ P T _ R E G S _ O F F S E T , r e g s
;;
add t e m p1 =SW ( F 2 ) , r e g s
add t e m p2 =SW ( F 3 ) , r e g s
;;
stf. s p i l l [ t e m p1 ] =f2 ,3 2
stf. s p i l l [ t e m p2 ] =f3 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f4 ,3 2
stf. s p i l l [ t e m p2 ] =f5 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f12 ,3 2
stf. s p i l l [ t e m p2 ] =f13 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f14 ,3 2
stf. s p i l l [ t e m p2 ] =f15 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f16 ,3 2
stf. s p i l l [ t e m p2 ] =f17 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f18 ,3 2
stf. s p i l l [ t e m p2 ] =f19 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f20 ,3 2
stf. s p i l l [ t e m p2 ] =f21 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f22 ,3 2
stf. s p i l l [ t e m p2 ] =f23 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f24 ,3 2
stf. s p i l l [ t e m p2 ] =f25 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f26 ,3 2
stf. s p i l l [ t e m p2 ] =f27 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f28 ,3 2
stf. s p i l l [ t e m p2 ] =f29 ,3 2
;;
stf. s p i l l [ t e m p1 ] =f30 ,S W ( B 2 ) - S W ( F 3 0 )
stf. s p i l l [ t e m p2 ] =f31 ,S W ( B 3 ) - S W ( F 3 1 )
mov t e m p3 =b2
mov t e m p4 =b3
;;
st8 [ t e m p1 ] =temp3 ,1 6 / / s a v e b2
st8 [ t e m p2 ] =temp4 ,1 6 / / s a v e b3
mov t e m p3 =b4
mov t e m p4 =b5
;;
st8 [ t e m p1 ] =temp3 ,S W ( A R _ L C ) - S W ( B 4 ) / / s a v e b4
st8 [ t e m p2 ] =temp4 / / s a v e b5
mov t e m p3 =ar . l c
;;
st8 [ t e m p1 ] =temp3 / / s a v e a r . l c
/ / FIXME : Some p r o m s a r e i n c o r r e c t l y a c c e s s i n g t h e m i n s t a t e a r e a a s
/ / cached d a t a . T h e C c o d e u s e s r e g i o n 6 , u n c a c h e d v i r t u a l . E n s u r e
/ / that t h e r e i s n o c a c h e d a t a l y i n g a r o u n d f o r t h e f i r s t 1 K o f t h e
/ / minstate a r e a .
/ / Remove t h i s c o d e i n S e p t e m b e r 2 0 0 6 , t h a t g i v e s p l a t f o r m s a y e a r t o
/ / fix t h e i r p r o m s a n d g e t t h e i r c u s t o m e r s u p d a t e d .
add r1 =32 * 1 ,r17
add r2 =32 * 2 ,r17
add r3 =32 * 3 ,r17
add r4 =32 * 4 ,r17
add r5 =32 * 5 ,r17
add r6 =32 * 6 ,r17
add r7 =32 * 7 ,r17
;;
fc r17
fc r1
fc r2
fc r3
fc r4
fc r5
fc r6
fc r7
add r17 =32 * 8 ,r17
add r1 =32 * 8 ,r1
add r2 =32 * 8 ,r2
add r3 =32 * 8 ,r3
add r4 =32 * 8 ,r4
add r5 =32 * 8 ,r5
add r6 =32 * 8 ,r6
add r7 =32 * 8 ,r7
;;
fc r17
fc r1
fc r2
fc r3
fc r4
fc r5
fc r6
fc r7
add r17 =32 * 8 ,r17
add r1 =32 * 8 ,r1
add r2 =32 * 8 ,r2
add r3 =32 * 8 ,r3
add r4 =32 * 8 ,r4
add r5 =32 * 8 ,r5
add r6 =32 * 8 ,r6
add r7 =32 * 8 ,r7
;;
fc r17
fc r1
fc r2
fc r3
fc r4
fc r5
fc r6
fc r7
add r17 =32 * 8 ,r17
add r1 =32 * 8 ,r1
add r2 =32 * 8 ,r2
add r3 =32 * 8 ,r3
add r4 =32 * 8 ,r4
add r5 =32 * 8 ,r5
add r6 =32 * 8 ,r6
add r7 =32 * 8 ,r7
;;
fc r17
fc r1
fc r2
fc r3
fc r4
fc r5
fc r6
fc r7
br. s p t k b0
2005-04-17 02:20:36 +04:00
/ / EndStub/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / + +
/ / Name :
2005-09-11 11:22:53 +04:00
/ / ia6 4 _ s t a t e _ r e s t o r e ( )
2005-04-17 02:20:36 +04:00
/ /
/ / Stub D e s c r i p t i o n :
/ /
2005-09-11 11:22:53 +04:00
/ / Restore t h e S A L / O S s t a t e . T h i s i s s e n s i t i v e t o t h e l a y o u t o f s t r u c t
/ / ia6 4 _ s a l _ o s _ s t a t e i n m c a . h .
/ /
/ / r2 c o n t a i n s t h e r e t u r n a d d r e s s , r3 c o n t a i n s e i t h e r
/ / IA6 4 _ M C A _ C P U _ M C A _ S T A C K _ O F F S E T o r I A 6 4 _ M C A _ C P U _ I N I T _ S T A C K _ O F F S E T .
/ /
/ / In a d d i t i o n t o t h e S A L t o O S s t a t e , t h i s r o u t i n e r e s t o r e s a l l t h e
/ / registers t h a t a p p e a r i n s t r u c t p t _ r e g s a n d s t r u c t s w i t c h _ s t a c k ,
/ / excluding t h o s e i n t h e P A L m i n s t a t e a r e a .
2005-04-17 02:20:36 +04:00
/ /
/ / - -
2005-09-11 11:22:53 +04:00
ia64_state_restore :
/ / Restore t h e s w i t c h _ s t a c k d a t a t h a t i s n o t i n m i n s t a t e n o r p t _ r e g s .
add r e g s =MCA_SWITCH_STACK_OFFSET , r3
mov b0 =r2 / / s a v e r e t u r n a d d r e s s
;;
GET_ I A 6 4 _ M C A _ D A T A ( t e m p2 )
;;
add r e g s =temp2 , r e g s
;;
add t e m p1 =SW ( F 2 ) , r e g s
add t e m p2 =SW ( F 3 ) , r e g s
;;
ldf. f i l l f2 = [ t e m p1 ] ,3 2
ldf. f i l l f3 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f4 = [ t e m p1 ] ,3 2
ldf. f i l l f5 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f12 = [ t e m p1 ] ,3 2
ldf. f i l l f13 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f14 = [ t e m p1 ] ,3 2
ldf. f i l l f15 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f16 = [ t e m p1 ] ,3 2
ldf. f i l l f17 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f18 = [ t e m p1 ] ,3 2
ldf. f i l l f19 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f20 = [ t e m p1 ] ,3 2
ldf. f i l l f21 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f22 = [ t e m p1 ] ,3 2
ldf. f i l l f23 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f24 = [ t e m p1 ] ,3 2
ldf. f i l l f25 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f26 = [ t e m p1 ] ,3 2
ldf. f i l l f27 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f28 = [ t e m p1 ] ,3 2
ldf. f i l l f29 = [ t e m p2 ] ,3 2
;;
ldf. f i l l f30 = [ t e m p1 ] ,S W ( B 2 ) - S W ( F 3 0 )
ldf. f i l l f31 = [ t e m p2 ] ,S W ( B 3 ) - S W ( F 3 1 )
;;
ld8 t e m p3 = [ t e m p1 ] ,1 6 / / r e s t o r e b2
ld8 t e m p4 = [ t e m p2 ] ,1 6 / / r e s t o r e b3
;;
mov b2 =temp3
mov b3 =temp4
ld8 t e m p3 = [ t e m p1 ] ,S W ( A R _ L C ) - S W ( B 4 ) / / r e s t o r e b4
ld8 t e m p4 = [ t e m p2 ] / / r e s t o r e b5
;;
mov b4 =temp3
mov b5 =temp4
ld8 t e m p3 = [ t e m p1 ] / / r e s t o r e a r . l c
;;
mov a r . l c =temp3
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / Restore t h e p t _ r e g s d a t a t h a t i s n o t i n m i n s t a t e . T h e p r e v i o u s c o d e
/ / left r e g s a t s w i t c h _ s t a c k .
add r e g s =MCA_PT_REGS_OFFSET - M C A _ S W I T C H _ S T A C K _ O F F S E T , r e g s
;;
add t e m p1 =PT ( B 6 ) , r e g s
add t e m p2 =PT ( B 7 ) , r e g s
;;
ld8 t e m p3 = [ t e m p1 ] ,P T ( A R _ C S D ) - P T ( B 6 ) / / r e s t o r e b6
ld8 t e m p4 = [ t e m p2 ] ,P T ( A R _ S S D ) - P T ( B 7 ) / / r e s t o r e b7
;;
mov b6 =temp3
mov b7 =temp4
ld8 t e m p3 = [ t e m p1 ] ,P T ( A R _ U N A T ) - P T ( A R _ C S D ) / / r e s t o r e a r . c s d
ld8 t e m p4 = [ t e m p2 ] ,P T ( A R _ P F S ) - P T ( A R _ S S D ) / / r e s t o r e a r . s s d
;;
mov a r . c s d =temp3
mov a r . s s d =temp4
ld8 t e m p3 = [ t e m p1 ] / / r e s t o r e a r . u n a t
add t e m p1 =PT ( A R _ C C V ) - P T ( A R _ U N A T ) , t e m p1
ld8 t e m p4 = [ t e m p2 ] ,P T ( A R _ F P S R ) - P T ( A R _ P F S ) / / r e s t o r e a r . p f s
;;
mov a r . u n a t =temp3
mov a r . p f s =temp4
/ / ar. r n a t , a r . b s p s t o r e , l o a d r s a r e r e s t o r e i n i a64 _ o l d _ s t a c k .
ld8 t e m p3 = [ t e m p1 ] ,P T ( F 6 ) - P T ( A R _ C C V ) / / r e s t o r e a r . c c v
ld8 t e m p4 = [ t e m p2 ] ,P T ( F 7 ) - P T ( A R _ F P S R ) / / r e s t o r e a r . f p s r
;;
mov a r . c c v =temp3
mov a r . f p s r =temp4
ldf. f i l l f6 = [ t e m p1 ] ,P T ( F 8 ) - P T ( F 6 )
ldf. f i l l f7 = [ t e m p2 ] ,P T ( F 9 ) - P T ( F 7 )
;;
ldf. f i l l f8 = [ t e m p1 ] ,P T ( F 1 0 ) - P T ( F 8 )
ldf. f i l l f9 = [ t e m p2 ] ,P T ( F 1 1 ) - P T ( F 9 )
;;
ldf. f i l l f10 = [ t e m p1 ]
ldf. f i l l f11 = [ t e m p2 ]
/ / Restore t h e S A L t o O S s t a t e . T h e p r e v i o u s c o d e l e f t r e g s a t p t _ r e g s .
add r e g s =MCA_SOS_OFFSET - M C A _ P T _ R E G S _ O F F S E T , r e g s
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
add t e m p1 =IA64_SAL_OS_STATE_COMMON_OFFSET , r e g s
add t e m p2 =IA64_SAL_OS_STATE_COMMON_OFFSET + 8 , r e g s
;;
ld8 r12 = [ t e m p1 ] ,1 6 / / s a l _ r a
ld8 r9 = [ t e m p2 ] ,1 6 / / s a l _ g p
;;
ld8 r22 = [ t e m p1 ] ,2 4 / / p a l _ m i n _ s t a t e , v i r t u a l . s k i p p r e v _ t a s k
ld8 r21 = [ t e m p2 ] ,1 6 / / p r e v _ I A 6 4 _ K R _ C U R R E N T
;;
ld8 t e m p3 = [ t e m p1 ] ,1 6 / / c r . i s r
ld8 t e m p4 = [ t e m p2 ] ,1 6 / / c r . i f a
;;
mov c r . i s r =temp3
mov c r . i f a =temp4
ld8 t e m p3 = [ t e m p1 ] ,1 6 / / c r . i t i r
ld8 t e m p4 = [ t e m p2 ] ,1 6 / / c r . i i p a
;;
mov c r . i t i r =temp3
mov c r . i i p a =temp4
ld8 t e m p3 = [ t e m p1 ] ,1 6 / / c r . i i m
ld8 t e m p4 = [ t e m p2 ] ,1 6 / / c r . i h a
;;
mov c r . i i m =temp3
mov c r . i h a =temp4
dep r22 =0 ,r22 ,6 2 ,2 / / p a l _ m i n _ s t a t e , p h y s i c a l , u n c a c h e d
mov I A 6 4 _ K R ( C U R R E N T ) =r21
ld8 r8 = [ t e m p1 ] / / o s _ s t a t u s
ld8 r10 = [ t e m p2 ] / / c o n t e x t
br. s p t k b0
2005-04-17 02:20:36 +04:00
/ / EndStub/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
2005-09-11 11:22:53 +04:00
/ / + +
/ / Name :
/ / ia6 4 _ n e w _ s t a c k ( )
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / Stub D e s c r i p t i o n :
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / Switch t o t h e M C A / I N I T s t a c k .
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / r2 c o n t a i n s t h e r e t u r n a d d r e s s , r3 c o n t a i n s e i t h e r
/ / IA6 4 _ M C A _ C P U _ M C A _ S T A C K _ O F F S E T o r I A 6 4 _ M C A _ C P U _ I N I T _ S T A C K _ O F F S E T .
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / On e n t r y R B S i s s t i l l o n t h e o r i g i n a l s t a c k , t h i s r o u t i n e s w i t c h e s R B S
/ / to u s e t h e M C A / I N I T s t a c k .
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / On e n t r y , s o s - > p a l _ m i n _ s t a t e i s p h y s i c a l , o n e x i t i t i s v i r t u a l .
/ /
/ / - -
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
ia64_new_stack :
add r e g s =MCA_PT_REGS_OFFSET , r3
add t e m p2 =MCA_SOS_OFFSET + I A 6 4 _ S A L _ O S _ S T A T E _ P A L _ M I N _ S T A T E _ O F F S E T , r3
mov b0 =r2 / / s a v e r e t u r n a d d r e s s
GET_ I A 6 4 _ M C A _ D A T A ( t e m p1 )
invala
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
add t e m p2 =temp2 , t e m p1 / / s t r u c t i a64 _ s a l _ o s _ s t a t e . p a l _ m i n _ s t a t e o n M C A o r I N I T s t a c k
add r e g s =regs , t e m p1 / / s t r u c t p t _ r e g s o n M C A o r I N I T s t a c k
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
/ / Address o f m i n s t a t e a r e a p r o v i d e d b y P A L i s p h y s i c a l , u n c a c h e a b l e .
/ / Convert t o L i n u x v i r t u a l a d d r e s s i n r e g i o n 6 f o r C c o d e .
ld8 m s = [ t e m p2 ] / / p a l _ m i n _ s t a t e , p h y s i c a l
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
dep t e m p1 = - 1 ,m s ,6 2 ,2 / / s e t r e g i o n 6
mov t e m p3 =IA64_RBS_OFFSET - M C A _ P T _ R E G S _ O F F S E T
;;
st8 [ t e m p2 ] =temp1 / / p a l _ m i n _ s t a t e , v i r t u a l
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
add t e m p4 =temp3 , r e g s / / s t a r t o f b s p s t o r e o n n e w s t a c k
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
mov a r . b s p s t o r e =temp4 / / s w i t c h R B S t o M C A / I N I T s t a c k
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
flushrs / / m u s t b e f i r s t i n g r o u p
br. s p t k b0
/ / EndStub/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / + +
/ / Name :
/ / ia6 4 _ o l d _ s t a c k ( )
/ /
/ / Stub D e s c r i p t i o n :
/ /
/ / Switch t o t h e o l d s t a c k .
/ /
/ / r2 c o n t a i n s t h e r e t u r n a d d r e s s , r3 c o n t a i n s e i t h e r
/ / IA6 4 _ M C A _ C P U _ M C A _ S T A C K _ O F F S E T o r I A 6 4 _ M C A _ C P U _ I N I T _ S T A C K _ O F F S E T .
/ /
/ / On e n t r y , p a l _ m i n _ s t a t e i s v i r t u a l , o n e x i t i t i s p h y s i c a l .
/ /
/ / On e n t r y R B S i s o n t h e M C A / I N I T s t a c k , t h i s r o u t i n e s w i t c h e s R B S
/ / back t o t h e p r e v i o u s s t a c k .
/ /
/ / The p s r i s s e t t o a l l z e r o e s . S A L r e t u r n r e q u i r e s e i t h e r a l l z e r o e s o r
/ / just p s r . m c s e t . L e a v i n g p s r . m c o f f a l l o w s I N I T t o b e i s s u e d i f t h i s
/ / code d o e s n o t p e r f o r m c o r r e c t l y .
/ /
/ / The d i r t y r e g i s t e r s a t t h e t i m e o f t h e e v e n t w e r e f l u s h e d t o t h e
/ / MCA/ I N I T s t a c k i n i a64 _ p t _ r e g s _ s a v e ( ) . R e s t o r e t h e d i r t y r e g i s t e r s
/ / before r e v e r t i n g t o t h e p r e v i o u s b s p s t o r e .
/ / - -
ia64_old_stack :
add r e g s =MCA_PT_REGS_OFFSET , r3
mov b0 =r2 / / s a v e r e t u r n a d d r e s s
GET_ I A 6 4 _ M C A _ D A T A ( t e m p2 )
LOAD_ P H Y S I C A L ( p0 ,t e m p1 ,1 f )
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
mov c r . i p s r =r0
mov c r . i f s =r0
mov c r . i i p =temp1
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
invala
2005-04-17 02:20:36 +04:00
rfi
2005-09-11 11:22:53 +04:00
1 :
add r e g s =regs , t e m p2 / / s t r u c t p t _ r e g s o n M C A o r I N I T s t a c k
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
add t e m p1 =PT ( L O A D R S ) , r e g s
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
ld8 t e m p2 = [ t e m p1 ] ,P T ( A R _ B S P S T O R E ) - P T ( L O A D R S ) / / r e s t o r e l o a d r s
2005-04-17 02:20:36 +04:00
;;
2005-09-11 11:22:53 +04:00
ld8 t e m p3 = [ t e m p1 ] ,P T ( A R _ R N A T ) - P T ( A R _ B S P S T O R E ) / / r e s t o r e a r . b s p s t o r e
mov a r . r s c =temp2
;;
loadrs
ld8 t e m p4 = [ t e m p1 ] / / r e s t o r e a r . r n a t
;;
mov a r . b s p s t o r e =temp3 / / b a c k t o o l d s t a c k
;;
mov a r . r n a t =temp4
;;
br. s p t k b0
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / EndStub/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / + +
/ / Name :
/ / ia6 4 _ s e t _ k e r n e l _ r e g i s t e r s ( )
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / Stub D e s c r i p t i o n :
/ /
/ / Set t h e r e g i s t e r s t h a t a r e r e q u i r e d b y t h e C c o d e i n o r d e r t o r u n o n a n
/ / MCA/ I N I T s t a c k .
/ /
/ / r2 c o n t a i n s t h e r e t u r n a d d r e s s , r3 c o n t a i n s e i t h e r
/ / IA6 4 _ M C A _ C P U _ M C A _ S T A C K _ O F F S E T o r I A 6 4 _ M C A _ C P U _ I N I T _ S T A C K _ O F F S E T .
2005-04-17 02:20:36 +04:00
/ /
2005-09-11 11:22:53 +04:00
/ / - -
ia64_set_kernel_registers :
add t e m p3 =MCA_SP_OFFSET , r3
add t e m p4 =MCA_SOS_OFFSET + I A 6 4 _ S A L _ O S _ S T A T E _ O S _ G P _ O F F S E T , r3
mov b0 =r2 / / s a v e r e t u r n a d d r e s s
GET_ I A 6 4 _ M C A _ D A T A ( t e m p1 )
;;
add t e m p4 =temp4 , t e m p1 / / & s t r u c t i a64 _ s a l _ o s _ s t a t e . o s _ g p
add r12 =temp1 , t e m p3 / / k e r n e l s t a c k p o i n t e r o n M C A / I N I T s t a c k
add r13 =temp1 , r3 / / s e t c u r r e n t t o s t a r t o f M C A / I N I T s t a c k
;;
ld8 r1 = [ t e m p4 ] / / O S G P f r o m S A L O S s t a t e
;;
DATA_ P A _ T O _ V A ( r1 ,t e m p1 )
DATA_ P A _ T O _ V A ( r12 ,t e m p2 )
DATA_ P A _ T O _ V A ( r13 ,t e m p3 )
;;
mov I A 6 4 _ K R ( C U R R E N T ) =r13
/ / FIXME : do I n e e d t o w i r e I A 6 4 _ K R _ C U R R E N T _ S T A C K a n d I A 6 4 _ T R _ C U R R E N T _ S T A C K ?
br. s p t k b0
/ / EndStub/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
# undef m s
# undef r e g s
# undef t e m p1
# undef t e m p2
# undef t e m p3
# undef t e m p4
2005-04-17 02:20:36 +04:00
2005-09-11 11:22:53 +04:00
/ / Support f u n c t i o n f o r m c a . c , i t i s h e r e t o a v o i d u s i n g i n l i n e a s m . G i v e n t h e
/ / address o f a n r n a t s l o t , i f t h a t a d d r e s s i s b e l o w t h e c u r r e n t a r . b s p s t o r e
/ / then r e t u r n t h e c o n t e n t s o f t h a t s l o t , o t h e r w i s e r e t u r n t h e c o n t e n t s o f
/ / ar. r n a t .
GLOBAL_ E N T R Y ( i a64 _ g e t _ r n a t )
alloc r14 =ar . p f s ,1 ,0 ,0 ,0
mov a r . r s c =0
;;
mov r14 =ar . b s p s t o r e
;;
cmp. l t p6 ,p7 =in0 ,r14
;;
( p6 ) l d8 r8 = [ i n 0 ]
( p7 ) m o v r8 =ar . r n a t
mov a r . r s c =3
br. r e t . s p t k . m a n y r p
END( i a64 _ g e t _ r n a t )