2011-01-20 18:50:55 +11:00
/ *
* This f i l e c o n t a i n s l o w l e v e l C P U s e t u p f u n c t i o n s .
* Copyright ( C ) 2 0 0 3 B e n j a m i n H e r r e n s c h m i d t ( b e n h @kernel.crashing.org)
*
* 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 / p r o c e s s o r . h >
# include < a s m / p a g e . h >
# include < a s m / c p u t a b l e . 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 / c a c h e . h >
/ * Entry : r3 = c r a p , r4 = p t r t o c p u t a b l e e n t r y
*
* Note t h a t w e c a n b e c a l l e d t w i c e f o r p s e u d o - P V R s
* /
_ GLOBAL( _ _ s e t u p _ c p u _ p o w e r7 )
mflr r11
bl _ _ i n i t _ h v m o d e _ 2 0 6
mtlr r11
beqlr
2011-03-01 15:46:09 +11:00
li r0 ,0
mtspr S P R N _ L P I D ,r0
2011-01-20 18:50:55 +11:00
bl _ _ i n i t _ L P C R
2011-03-01 15:46:09 +11:00
bl _ _ i n i t _ T L B
2011-01-20 18:50:55 +11:00
mtlr r11
blr
_ GLOBAL( _ _ r e s t o r e _ c p u _ p o w e r7 )
mflr r11
mfmsr r3
rldicl. r0 ,r3 ,4 ,6 3
beqlr
2011-03-01 15:46:09 +11:00
li r0 ,0
mtspr S P R N _ L P I D ,r0
2011-01-20 18:50:55 +11:00
bl _ _ i n i t _ L P C R
2011-03-01 15:46:09 +11:00
bl _ _ i n i t _ T L B
2011-01-20 18:50:55 +11:00
mtlr r11
blr
__init_hvmode_206 :
/* Disable CPU_FTR_HVMODE_206 and exit if MSR:HV is not set */
mfmsr r3
rldicl. r0 ,r3 ,4 ,6 3
bnelr
ld r5 ,C P U _ S P E C _ F E A T U R E S ( r4 )
LOAD_ R E G _ I M M E D I A T E ( r6 ,C P U _ F T R _ H V M O D E _ 2 0 6 )
xor r5 ,r5 ,r6
std r5 ,C P U _ S P E C _ F E A T U R E S ( r4 )
blr
__init_LPCR :
/ * Setup a s a n e L P C R :
*
2011-04-05 14:20:31 +10:00
* LPES = 0 b01 ( H S R R 0 / 1 u s e d f o r 0 x50 0 )
2011-01-20 18:50:55 +11:00
* PECE = 0 b11 1
2011-01-24 13:25:55 +11:00
* DPFD = 4
2011-01-20 18:50:55 +11:00
*
* Other b i t s u n t o u c h e d f o r n o w
* /
mfspr r3 ,S P R N _ L P C R
ori r3 ,r3 ,( L P C R _ L P E S 0 | L P C R _ L P E S 1 )
2011-04-05 14:20:31 +10:00
xori r3 ,r3 , L P C R _ L P E S 0
2011-01-20 18:50:55 +11:00
ori r3 ,r3 ,( L P C R _ P E C E 0 | L P C R _ P E C E 1 | L P C R _ P E C E 2 )
2011-01-24 13:25:55 +11:00
li r5 ,7
sldi r5 ,r5 ,L P C R _ D P F D _ S H
andc r3 ,r3 ,r5
li r5 ,4
sldi r5 ,r5 ,L P C R _ D P F D _ S H
or r3 ,r3 ,r5
2011-01-20 18:50:55 +11:00
mtspr S P R N _ L P C R ,r3
isync
blr
2011-03-01 15:46:09 +11:00
__init_TLB :
/* Clear the TLB */
li r6 ,1 2 8
mtctr r6
li r7 ,0 x c00 / * I S f i e l d = 0 b11 * /
ptesync
2 : tlbiel r7
addi r7 ,r7 ,0 x10 0 0
bdnz 2 b
ptesync
1 : blr