2011-04-15 02:32:01 +04:00
/ *
* A2 s p e c i f i c a s s e m b l y s u p p o r t c o d e
*
* Copyright 2 0 0 9 B e n H e r r e n s c h m i d t , I B M C o r p .
*
* 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 / a s m - o f f s e t s . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / p p c - o p c o d e . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / r e g _ a2 . h >
# include < a s m / r e g . h >
# include < a s m / t h r e a d _ i n f o . h >
/ *
* Disable t h d i d a n d c l a s s f i e l d s i n E R A T s t o b u m p P I D t o f u l l 1 4 b i t s c a p a c i t y .
* This a l s o p r e v e n t s e x t e r n a l L P I D a c c e s s e s b u t t h a t i s n ' t a p r o b l e m w h e n n o t a
* guest. U n d e r P V , t h i s s e t t i n g w i l l b e i g n o r e d a n d M M U C R w i l l r e t u r n t h e r i g h t
* number o f P I D b i t s w e c a n u s e .
* /
# define M M U C R 1 _ E X T E N D _ P I D \
( MMUCR1 _ I C T I D | M M U C R 1 _ I T T I D | M M U C R 1 _ D C T I D | \
MMUCR1 _ D T T I D | M M U C R 1 _ D C C D )
/ *
* Use e x t e n d e d P I D s i f e n a b l e d .
* Don' t c l e a r t h e E R A T s o n c o n t e x t s y n c e v e n t s a n d e n a b l e I & D L R U .
* Enable E R A T b a c k i n v a l i d a t e w h e n t l b w e o v e r w r i t e s a n e n t r y .
* /
# define I N I T I A L _ M M U C R 1 \
( MMUCR1 _ E X T E N D _ P I D | M M U C R 1 _ C S I N V _ N E V E R | M M U C R 1 _ I R R E | \
MMUCR1 _ D R R E | M M U C R 1 _ T L B W E _ B I N V )
_ GLOBAL( _ _ s e t u p _ c p u _ a2 )
/ * Some o f t h e s e a r e a c t u a l l y t h r e a d l o c a l a n d s o m e a r e
* core l o c a l b u t d o i n g i t a l w a y s w o n ' t h u r t
* /
2011-09-29 14:55:13 +04:00
# ifdef C O N F I G _ P P C _ I C S W X
2011-04-15 02:32:01 +04:00
/* Make sure ACOP starts out as zero */
li r3 ,0
mtspr S P R N _ A C O P ,r3
2011-09-29 14:55:13 +04:00
/* Skip the following if we are in Guest mode */
mfmsr r3
andis. r0 ,r3 ,M S R _ G S @h
bne _ i c s w x _ s k i p _ g u e s t
2011-04-15 02:32:01 +04:00
/* Enable icswx instruction */
mfspr r3 ,S P R N _ A 2 _ C C R 2
ori r3 ,r3 ,A 2 _ C C R 2 _ E N A B L E _ I C S W X
mtspr S P R N _ A 2 _ C C R 2 ,r3
/* Unmask all CTs in HACOP */
li r3 ,- 1
mtspr S P R N _ H A C O P ,r3
2011-09-29 14:55:13 +04:00
_icswx_skip_guest :
# endif / * C O N F I G _ P P C _ I C S W X * /
2011-04-15 02:32:01 +04:00
/* Enable doorbell */
mfspr r3 ,S P R N _ A 2 _ C C R 2
oris r3 ,r3 ,A 2 _ C C R 2 _ E N A B L E _ P C @h
mtspr S P R N _ A 2 _ C C R 2 ,r3
isync
/ * Setup C C R 0 t o d i s a b l e p o w e r s a v i n g f o r n o w a s i t ' s b u s t e d
* in t h e c u r r e n t i m p l e m e n t a t i o n s . S e t u p C C R 1 t o w a k e o n
* interrupts n o r m a l l y ( w e w r i t e t h e d e f a u l t v a l u e b u t w h o
* knows w h a t F W m a y h a v e c l o b b e r e d . . . )
* /
li r3 ,0
mtspr S P R N _ A 2 _ C C R 0 , r3
LOAD_ R E G _ I M M E D I A T E ( r3 ,0 x0 f0 f0 f0 f )
mtspr S P R N _ A 2 _ C C R 1 , r3
/* Initialise MMUCR1 */
lis r3 ,I N I T I A L _ M M U C R 1 @h
ori r3 ,r3 ,I N I T I A L _ M M U C R 1 @l
mtspr S P R N _ M M U C R 1 ,r3
/* Set MMUCR2 to enable 4K, 64K, 1M, 16M and 1G pages */
LOAD_ R E G _ I M M E D I A T E ( r3 , 0 x00 0 a75 3 1 )
mtspr S P R N _ M M U C R 2 ,r3
/* Set MMUCR3 to write all thids bit to the TLB */
LOAD_ R E G _ I M M E D I A T E ( r3 , 0 x00 0 0 0 0 0 f )
mtspr S P R N _ M M U C R 3 ,r3
/* Don't do ERAT stuff if running guest mode */
mfmsr r3
andis. r0 ,r3 ,M S R _ G S @h
bne 1 f
/* Now set the I-ERAT watermark to 15 */
lis r4 ,( M M U C R 0 _ T L B S E L _ I | M M U C R 0 _ E C L ) @h
mtspr S P R N _ M M U C R 0 , r4
li r4 ,A 2 _ I E R A T _ S I Z E - 1
2012-06-25 17:33:10 +04:00
PPC_ E R A T W E ( R 4 ,R 4 ,3 )
2011-04-15 02:32:01 +04:00
/* Now set the D-ERAT watermark to 31 */
lis r4 ,( M M U C R 0 _ T L B S E L _ D | M M U C R 0 _ E C L ) @h
mtspr S P R N _ M M U C R 0 , r4
li r4 ,A 2 _ D E R A T _ S I Z E - 1
2012-06-25 17:33:10 +04:00
PPC_ E R A T W E ( R 4 ,R 4 ,3 )
2011-04-15 02:32:01 +04:00
/ * And i n v a l i d a t e t h e b e a s t j u s t i n c a s e . T h a t w o n ' t g e t r i d o f
* a b o l t e d e n t r y t h o u g h i t w i l l b e i n L R U a n d s o w i l l g o a w a y e v e n t u a l l y
* but l e t ' s n o t b o t h e r f o r n o w
* /
2012-06-25 17:33:25 +04:00
PPC_ E R A T I L X ( 0 ,0 ,R 0 )
2011-04-15 02:32:01 +04:00
1 :
blr
_ GLOBAL( _ _ r e s t o r e _ c p u _ a2 )
b _ _ s e t u p _ c p u _ a2