2007-08-22 13:44:58 +10:00
/ *
* Low l e v e l r o u t i n e s f o r l e g a c y i S e r i e s s u p p o r t .
*
* Extracted f r o m h e a d _ 6 4 . S
*
* PowerPC v e r s i o n
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
*
* Rewritten b y C o r t D o u g a n ( c o r t @cs.nmt.edu) for PReP
* Copyright ( C ) 1 9 9 6 C o r t D o u g a n < c o r t @cs.nmt.edu>
* Adapted f o r P o w e r M a c i n t o s h b y P a u l M a c k e r r a s .
* Low- l e v e l e x c e p t i o n h a n d l e r s a n d M M U s u p p o r t
* rewritten b y P a u l M a c k e r r a s .
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
*
* Adapted f o r 6 4 b i t P o w e r P C b y D a v e E n g e b r e t s e n , P e t e r B e r g n e r , a n d
* Mike C o r r i g a n { e n g e b r e t | b e r g n e r | m i k e j c } @us.ibm.com
*
* This f i l e c o n t a i n s t h e l o w - l e v e l s u p p o r t a n d s e t u p f o r t h e
* PowerPC- 6 4 p l a t f o r m , i n c l u d i n g t r a p a n d i n t e r r u p t d i s p a t c h .
*
* 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 / r e g . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p t r a c e . h >
2007-08-22 13:47:24 +10:00
# include < a s m / c p u t a b l e . h >
2007-08-22 13:44:58 +10:00
2007-08-22 13:48:37 +10:00
# include " e x c e p t i o n . h "
2007-08-22 13:44:58 +10:00
.text
.globl system_reset_iSeries
system_reset_iSeries :
mfspr r13 ,S P R N _ S P R G 3 / * G e t p a c a a d d r e s s * /
mfmsr r24
ori r24 ,r24 ,M S R _ R I
mtmsrd r24 / * R I o n * /
lhz r24 ,P A C A P A C A I N D E X ( r13 ) / * G e t p r o c e s s o r # * /
cmpwi 0 ,r24 ,0 / * A r e w e p r o c e s s o r 0 ? * /
bne 1 f
b . _ _ s t a r t _ i n i t i a l i z a t i o n _ i S e r i e s / * S t a r t u p t h e f i r s t p r o c e s s o r * /
1 : mfspr r4 ,S P R N _ C T R L F
li r5 ,C T R L _ R U N L A T C H / * T u r n o f f t h e r u n l i g h t * /
andc r4 ,r4 ,r5
mtspr S P R N _ C T R L T ,r4
1 :
HMT_ L O W
# ifdef C O N F I G _ S M P
lbz r23 ,P A C A P R O C S T A R T ( r13 ) / * T e s t i f t h i s p r o c e s s o r
* should s t a r t * /
sync
LOAD_ R E G _ I M M E D I A T E ( r3 ,c u r r e n t _ s e t )
sldi r28 ,r24 ,3 / * g e t c u r r e n t _ s e t [ c p u #] * /
ldx r3 ,r3 ,r28
addi r1 ,r3 ,T H R E A D _ S I Z E
subi r1 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
cmpwi 0 ,r23 ,0
beq i S e r i e s _ s e c o n d a r y _ s m p _ l o o p / * L o o p u n t i l t o l d t o g o * /
b _ _ s e c o n d a r y _ s t a r t / * L o o p u n t i l t o l d t o g o * /
iSeries_secondary_smp_loop :
/* Let the Hypervisor know we are alive */
/* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
lis r3 ,0 x80 0 2
rldicr r3 ,r3 ,3 2 ,1 5 / * r0 = ( r3 < < 3 2 ) & 0 x f f f f00 0 0 0 0 0 0 0 0 0 0 * /
# else / * C O N F I G _ S M P * /
/ * Yield t h e p r o c e s s o r . T h i s i s r e q u i r e d f o r n o n - S M P k e r n e l s
which a r e r u n n i n g o n m u l t i - t h r e a d e d m a c h i n e s . * /
lis r3 ,0 x80 0 0
rldicr r3 ,r3 ,3 2 ,1 5 / * r3 = ( r3 < < 3 2 ) & 0 x f f f f00 0 0 0 0 0 0 0 0 0 0 * /
addi r3 ,r3 ,1 8 / * r3 = 0 x80 0 0 0 0 0 0 0 0 0 0 0 0 1 2 w h i c h i s " y i e l d " * /
li r4 ,0 / * " y i e l d t i m e d " * /
li r5 ,- 1 / * " y i e l d f o r e v e r " * /
# endif / * C O N F I G _ S M P * /
li r0 ,- 1 / * r0 = - 1 i n d i c a t e s a H y p e r v i s o r c a l l * /
sc / * I n v o k e t h e h y p e r v i s o r v i a a s y s t e m c a l l * /
mfspr r13 ,S P R N _ S P R G 3 / * P u t r13 b a c k ? ? ? ? * /
b 1 b / * I f S M P n o t c o n f i g u r e d , s e c o n d a r i e s
* loop f o r e v e r * /
2007-08-22 13:47:24 +10:00
/*** ISeries-LPAR interrupt handlers ***/
2007-08-22 13:49:41 +10:00
STD_ E X C E P T I O N _ I S E R I E S ( m a c h i n e _ c h e c k , P A C A _ E X M C )
2007-08-22 13:47:24 +10:00
.globl data_access_iSeries
data_access_iSeries :
mtspr S P R N _ S P R G 1 ,r13
BEGIN_ F T R _ S E C T I O N
mtspr S P R N _ S P R G 2 ,r12
mfspr r13 ,S P R N _ D A R
mfspr r12 ,S P R N _ D S I S R
srdi r13 ,r13 ,6 0
rlwimi r13 ,r12 ,1 6 ,0 x20
mfcr r12
cmpwi r13 ,0 x2 c
beq . d o _ s t a b _ b o l t e d _ i S e r i e s
mtcrf 0 x80 ,r12
mfspr r12 ,S P R N _ S P R G 2
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ S L B )
2007-08-22 13:48:37 +10:00
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X G E N )
EXCEPTION_ P R O L O G _ I S E R I E S _ 1
2007-08-22 13:47:24 +10:00
b d a t a _ a c c e s s _ c o m m o n
.do_stab_bolted_iSeries :
mtcrf 0 x80 ,r12
mfspr r12 ,S P R N _ S P R G 2
2007-08-22 13:48:37 +10:00
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X S L B )
EXCEPTION_ P R O L O G _ I S E R I E S _ 1
2007-08-22 13:47:24 +10:00
b . d o _ s t a b _ b o l t e d
.globl data_access_slb_iSeries
data_access_slb_iSeries :
mtspr S P R N _ S P R G 1 ,r13 / * s a v e r13 * /
mfspr r13 ,S P R N _ S P R G 3 / * g e t p a c a a d d r e s s i n t o r13 * /
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
mfspr r3 ,S P R N _ D A R
std r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
mfcr r9
# ifdef _ _ D I S A B L E D _ _
cmpdi r3 ,0
bge s l b _ m i s s _ u s e r _ i s e r i e s
# endif
std r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
std r11 ,P A C A _ E X S L B + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X S L B + E X _ R 1 2 ( r13 )
mfspr r10 ,S P R N _ S P R G 1
std r10 ,P A C A _ E X S L B + E X _ R 1 3 ( r13 )
ld r12 ,P A C A L P P A C A P T R ( r13 )
ld r12 ,L P P A C A S R R 1 ( r12 )
b . s l b _ m i s s _ r e a l m o d e
2007-08-22 13:49:41 +10:00
STD_ E X C E P T I O N _ I S E R I E S ( i n s t r u c t i o n _ a c c e s s , P A C A _ E X G E N )
2007-08-22 13:47:24 +10:00
.globl instruction_access_slb_iSeries
instruction_access_slb_iSeries :
mtspr S P R N _ S P R G 1 ,r13 / * s a v e r13 * /
mfspr r13 ,S P R N _ S P R G 3 / * g e t p a c a a d d r e s s i n t o r13 * /
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
ld r3 ,P A C A L P P A C A P T R ( r13 )
ld r3 ,L P P A C A S R R 0 ( r3 ) / * g e t S R R 0 v a l u e * /
std r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
mfcr r9
# ifdef _ _ D I S A B L E D _ _
cmpdi r3 ,0
bge s l b _ m i s s _ u s e r _ i s e r i e s
# endif
std r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
std r11 ,P A C A _ E X S L B + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X S L B + E X _ R 1 2 ( r13 )
mfspr r10 ,S P R N _ S P R G 1
std r10 ,P A C A _ E X S L B + E X _ R 1 3 ( r13 )
ld r12 ,P A C A L P P A C A P T R ( r13 )
ld r12 ,L P P A C A S R R 1 ( r12 )
b . s l b _ m i s s _ r e a l m o d e
# ifdef _ _ D I S A B L E D _ _
slb_miss_user_iseries :
std r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
std r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
mfspr r10 ,S P R G 1
ld r11 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
ld r12 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
std r10 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
std r11 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
std r12 ,P A C A _ E X G E N + E X _ R 3 ( r13 )
2007-08-22 13:48:37 +10:00
EXCEPTION_ P R O L O G _ I S E R I E S _ 1
2007-08-22 13:47:24 +10:00
b s l b _ m i s s _ u s e r _ c o m m o n
# endif
2007-08-22 13:49:41 +10:00
MASKABLE_ E X C E P T I O N _ I S E R I E S ( h a r d w a r e _ i n t e r r u p t )
STD_ E X C E P T I O N _ I S E R I E S ( a l i g n m e n t , P A C A _ E X G E N )
STD_ E X C E P T I O N _ I S E R I E S ( p r o g r a m _ c h e c k , P A C A _ E X G E N )
STD_ E X C E P T I O N _ I S E R I E S ( f p _ u n a v a i l a b l e , P A C A _ E X G E N )
MASKABLE_ E X C E P T I O N _ I S E R I E S ( d e c r e m e n t e r )
STD_ E X C E P T I O N _ I S E R I E S ( t r a p _ 0 a , P A C A _ E X G E N )
STD_ E X C E P T I O N _ I S E R I E S ( t r a p _ 0 b , P A C A _ E X G E N )
2007-08-22 13:47:24 +10:00
.globl system_call_iSeries
system_call_iSeries :
mr r9 ,r13
mfspr r13 ,S P R N _ S P R G 3
2007-08-22 13:48:37 +10:00
EXCEPTION_ P R O L O G _ I S E R I E S _ 1
2007-08-22 13:47:24 +10:00
b s y s t e m _ c a l l _ c o m m o n
2007-08-22 13:49:41 +10:00
STD_ E X C E P T I O N _ I S E R I E S ( s i n g l e _ s t e p , P A C A _ E X G E N )
STD_ E X C E P T I O N _ I S E R I E S ( t r a p _ 0 e , P A C A _ E X G E N )
STD_ E X C E P T I O N _ I S E R I E S ( p e r f o r m a n c e _ m o n i t o r , P A C A _ E X G E N )
2007-08-22 13:47:24 +10:00
decrementer_iSeries_masked :
/* We may not have a valid TOC pointer in here. */
li r11 ,1
ld r12 ,P A C A L P P A C A P T R ( r13 )
stb r11 ,L P P A C A D E C R I N T ( r12 )
LOAD_ R E G _ I M M E D I A T E ( r12 , t b _ t i c k s _ p e r _ j i f f y )
lwz r12 ,0 ( r12 )
mtspr S P R N _ D E C ,r12
/* fall through */
hardware_interrupt_iSeries_masked :
mtcrf 0 x80 ,r9 / * R e s t o r e r e g s * /
ld r12 ,P A C A L P P A C A P T R ( r13 )
ld r11 ,L P P A C A S R R 0 ( r12 )
ld r12 ,L P P A C A S R R 1 ( r12 )
mtspr S P R N _ S R R 0 ,r11
mtspr S P R N _ S R R 1 ,r12
ld r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
ld r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
ld r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
ld r13 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
rfid
b . / * p r e v e n t s p e c u l a t i v e e x e c u t i o n * /
2007-08-22 13:44:58 +10:00
_ INIT_ S T A T I C ( _ _ s t a r t _ i n i t i a l i z a t i o n _ i S e r i e s )
/* Clear out the BSS */
LOAD_ R E G _ I M M E D I A T E ( r11 ,_ _ b s s _ s t o p )
LOAD_ R E G _ I M M E D I A T E ( r8 ,_ _ b s s _ s t a r t )
sub r11 ,r11 ,r8 / * b s s s i z e * /
addi r11 ,r11 ,7 / * r o u n d u p t o a n e v e n d o u b l e w o r d * /
rldicl. r11 ,r11 ,6 1 ,3 / * s h i f t r i g h t b y 3 * /
beq 4 f
addi r8 ,r8 ,- 8
li r0 ,0
mtctr r11 / * z e r o t h i s m a n y d o u b l e w o r d s * /
3 : stdu r0 ,8 ( r8 )
bdnz 3 b
4 :
LOAD_ R E G _ I M M E D I A T E ( r1 ,i n i t _ t h r e a d _ u n i o n )
addi r1 ,r1 ,T H R E A D _ S I Z E
li r0 ,0
stdu r0 ,- S T A C K _ F R A M E _ O V E R H E A D ( r1 )
LOAD_ R E G _ I M M E D I A T E ( r2 ,_ _ t o c _ s t a r t )
addi r2 ,r2 ,0 x40 0 0
addi r2 ,r2 ,0 x40 0 0
bl . i S e r i e s _ e a r l y _ s e t u p
bl . e a r l y _ s e t u p
/* relocation is on at this point */
b . s t a r t _ h e r e _ c o m m o n