@ -150,10 +150,14 @@ __secondary_start_page:
# define t o r e s e t ( x ) ( x - _ _ s e c o n d a r y _ s t a r t _ p a g e + 0 x f f f f f00 0 )
/* get our PIR to figure out our table entry */
lis r3 ,t o r e s e t ( _ _ s p i n _ t a b l e ) @h
ori r3 ,r3 ,t o r e s e t ( _ _ s p i n _ t a b l e ) @l
lis r3 ,t o r e s e t ( _ _ s p i n _ t a b l e _ a d d r ) @h
ori r3 ,r3 ,t o r e s e t ( _ _ s p i n _ t a b l e _ a d d r ) @l
lwz r3 ,0 ( r3 )
/* r10 has the base address for the entry */
/ *
* r1 0 h a s t h e b a s e a d d r e s s f o r t h e e n t r y .
* we c a n n o t a c c e s s i t y e t b e f o r e s e t t i n g u p a n e w T L B
* /
mfspr r0 ,S P R N _ P I R
# if d e f i n e d ( C O N F I G _ E 6 5 0 0 )
/ *
@ -180,7 +184,7 @@ __secondary_start_page:
# else
mr r4 ,r0
# endif
slwi r8 ,r4 ,5
slwi r8 ,r4 ,6 / * s p i n t a b l e i s p a d d e d t o 6 4 b y t e * /
add r10 ,r3 ,r8
# ifdef C O N F I G _ E 6 5 0 0
@ -277,73 +281,111 @@ __secondary_start_page:
beq 2 b
# endif
3 :
# define E P A P R _ M A G I C ( 0 x45 5 0 4 1 5 0 )
# define E N T R Y _ A D D R _ U P P E R 0
# define E N T R Y _ A D D R _ L O W E R 4
# define E N T R Y _ R 3 _ U P P E R 8
# define E N T R Y _ R 3 _ L O W E R 1 2
# define E N T R Y _ R E S V 1 6
# define E N T R Y _ P I R 2 0
# define E N T R Y _ R 6 _ U P P E R 2 4
# define E N T R Y _ R 6 _ L O W E R 2 8
# define E N T R Y _ S I Z E 3 2
/* setup the entry */
li r3 ,0
li r8 ,1
stw r4 ,E N T R Y _ P I R ( r10 )
stw r3 ,E N T R Y _ A D D R _ U P P E R ( r10 )
stw r8 ,E N T R Y _ A D D R _ L O W E R ( r10 )
stw r3 ,E N T R Y _ R 3 _ U P P E R ( r10 )
stw r4 ,E N T R Y _ R 3 _ L O W E R ( r10 )
stw r3 ,E N T R Y _ R 6 _ U P P E R ( r10 )
stw r3 ,E N T R Y _ R 6 _ L O W E R ( r10 )
/* load r13 with the address of the 'bootpg' in SDRAM */
lis r13 ,t o r e s e t ( _ _ b o o t p g _ a d d r ) @h
ori r13 ,r13 ,t o r e s e t ( _ _ b o o t p g _ a d d r ) @l
/* setup mapping for the spin table, WIMGE=0b00100 */
lis r13 ,t o r e s e t ( _ _ s p i n _ t a b l e _ a d d r ) @h
ori r13 ,r13 ,t o r e s e t ( _ _ s p i n _ t a b l e _ a d d r ) @l
lwz r13 ,0 ( r13 )
/* mask by 4K */
rlwinm r13 ,r13 ,0 ,0 ,1 9
/* setup mapping for AS = 1, and jump there */
lis r11 ,( M A S 0 _ T L B S E L ( 1 ) | M A S 0 _ E S E L ( 1 ) ) @h
mtspr S P R N _ M A S 0 ,r11
lis r11 ,( M A S 1 _ V A L I D | M A S 1 _ I P R O T ) @h
ori r11 ,r11 ,( M A S 1 _ T S | M A S 1 _ T S I Z E ( B O O K E _ P A G E S Z _ 4 K ) ) @l
mtspr S P R N _ M A S 1 ,r11
oris r11 ,r13 ,( M A S 2 _ I | M A S 2 _ G ) @h
ori r11 ,r13 ,( M A S 2 _ I | M A S 2 _ G ) @l
oris r11 ,r13 ,( M A S 2 _ M | M A S 2 _ G ) @h
ori r11 ,r13 ,( M A S 2 _ M | M A S 2 _ G ) @l
mtspr S P R N _ M A S 2 ,r11
oris r11 ,r13 ,( M A S 3 _ S X | M A S 3 _ S W | M A S 3 _ S R ) @h
ori r11 ,r13 ,( M A S 3 _ S X | M A S 3 _ S W | M A S 3 _ S R ) @l
mtspr S P R N _ M A S 3 ,r11
li r11 ,0
mtspr S P R N _ M A S 7 ,r11
tlbwe
bl 1 f
1 : mflr r11
/ *
* OR i n 0 x f f f t o c r e a t e a m a s k o f t h e b o o t p g S D R A M a d d r e s s . W e u s e
* this m a s k t o f i x u p t h e c p u s p i n t a b l e a n d t h e a d d r e s s t h a t w e w a n t
* to j u m p t o , e g c h a n g e t h e m f r o m 0 x f f f f f x x x t o 0 x7 f f f f x x x i f t h e
* bootpg i s a t 0 x7 f f f f00 0 i n S D R A M .
* _ _ bootpg_ a d d r h a s t h e a d d r e s s o f _ _ s e c o n d _ h a l f _ b o o t _ p a g e
* jump t h e r e i n A S =1 s p a c e w i t h c a c h e e n a b l e d
* /
ori r13 ,r13 ,0 x f f f
and r11 , r11 , r13
and r10 , r10 , r13
addi r11 ,r11 ,( 2 f - 1 b )
lis r13 ,t o r e s e t ( _ _ b o o t p g _ a d d r ) @h
ori r13 ,r13 ,t o r e s e t ( _ _ b o o t p g _ a d d r ) @l
lwz r11 ,0 ( r13 )
mtspr S P R N _ S R R 0 ,r11
mfmsr r13
ori r12 ,r13 ,M S R _ I S | M S R _ D S @l
mtspr S P R N _ S R R 0 ,r11
mtspr S P R N _ S R R 1 ,r12
rfi
/ *
* Allocate s o m e s p a c e f o r t h e S D R A M a d d r e s s o f t h e b o o t p g .
* This v a r i a b l e h a s t o b e i n t h e b o o t p a g e s o t h a t i t c a n
* be a c c e s s e d b y s e c o n d a r y c o r e s w h e n t h e y c o m e o u t o f r e s e t .
* /
.align L1_CACHE_SHIFT
.globl __bootpg_addr
__bootpg_addr :
.long 0
.global __spin_table_addr
__spin_table_addr :
.long 0
/ *
* This v a r i a b l e i s s e t b y c p u _ i n i t _ r ( ) a f t e r p a r s i n g h w c o n f i g
* to e n a b l e w o r k a r o u n d f o r e r r a t u m N M G _ C P U _ A 0 1 1 .
* /
.align L1_CACHE_SHIFT
.global enable_cpu_a011_workaround
enable_cpu_a011_workaround :
.long 1
/ * Fill i n t h e e m p t y s p a c e . T h e a c t u a l r e s e t v e c t o r i s
* the l a s t w o r d o f t h e p a g e * /
__secondary_start_code_end :
.space 4092 - ( _ _ secondary_ s t a r t _ c o d e _ e n d - _ _ s e c o n d a r y _ s t a r t _ p a g e )
__secondary_reset_vector :
b _ _ s e c o n d a r y _ s t a r t _ p a g e
/* this is a separated page for the spin table and cacheable boot code */
.align L1_CACHE_SHIFT
.global __second_half_boot_page
__second_half_boot_page :
# define E P A P R _ M A G I C 0 x45 5 0 4 1 5 0
# define E N T R Y _ A D D R _ U P P E R 0
# define E N T R Y _ A D D R _ L O W E R 4
# define E N T R Y _ R 3 _ U P P E R 8
# define E N T R Y _ R 3 _ L O W E R 1 2
# define E N T R Y _ R E S V 1 6
# define E N T R Y _ P I R 2 0
# define E N T R Y _ S I Z E 6 4
/ *
* setup t h e e n t r y
* r1 0 h a s t h e b a s e a d d r e s s o f t h e s p i n t a b l e .
* spin t a b l e i s d e f i n e d a s
* struct {
* uint6 4 _ t e n t r y _ a d d r ;
* uint6 4 _ t r3 ;
* uint3 2 _ t r s v d1 ;
* uint3 2 _ t p i r ;
* } ;
* we p a d t h i s s t r u c t t o 6 4 b y t e s s o e a c h e n t r y i s i n i t s o w n c a c h e l i n e
* /
li r3 ,0
li r8 ,1
mfspr r4 ,S P R N _ P I R
stw r3 ,E N T R Y _ A D D R _ U P P E R ( r10 )
stw r3 ,E N T R Y _ R 3 _ U P P E R ( r10 )
stw r4 ,E N T R Y _ R 3 _ L O W E R ( r10 )
stw r3 ,E N T R Y _ R E S V ( r10 )
stw r4 ,E N T R Y _ P I R ( r10 )
msync
stw r8 ,E N T R Y _ A D D R _ L O W E R ( r10 )
/* spin waiting for addr */
2 :
lwz r4 ,E N T R Y _ A D D R _ L O W E R ( r10 )
3 : lwz r4 ,E N T R Y _ A D D R _ L O W E R ( r10 )
andi. r11 ,r4 ,1
bne 2 b
bne 3 b
isync
/* setup IVORs to match fixed offsets */
@ -362,8 +404,17 @@ __secondary_start_page:
/* mask by ~64M to setup our tlb we will jump to */
rlwinm r12 ,r4 ,0 ,0 ,5
/* setup r3, r4, r5, r6, r7, r8, r9 */
/ *
* setup r3 , r4 , r5 , r6 , r7 , r8 , r9
* r3 c o n t a i n s t h e v a l u e t o p u t i n t h e r3 r e g i s t e r a t s e c o n d a r y c p u
* entry. T h e h i g h 3 2 - b i t s a r e i g n o r e d o n 3 2 - b i t c h i p i m p l e m e n t a t i o n s .
* 6 4 - bit c h i p i m p l e m e n t a t i o n s h o w e v e r s h a l l l o a d a l l 6 4 - b i t s
* /
# ifdef C O N F I G _ S Y S _ P P C 6 4
ld r3 ,E N T R Y _ R 3 _ U P P E R ( r10 )
# else
lwz r3 ,E N T R Y _ R 3 _ L O W E R ( r10 )
# endif
li r4 ,0
li r5 ,0
li r6 ,0
@ -404,32 +455,10 @@ __secondary_start_page:
mtspr S P R N _ S R R 1 ,r13
rfi
/ *
* Allocate s o m e s p a c e f o r t h e S D R A M a d d r e s s o f t h e b o o t p g .
* This v a r i a b l e h a s t o b e i n t h e b o o t p a g e s o t h a t i t c a n
* be a c c e s s e d b y s e c o n d a r y c o r e s w h e n t h e y c o m e o u t o f r e s e t .
* /
.globl __bootpg_addr
__bootpg_addr :
.long 0
.align L1_CACHE_SHIFT
.align 6
.globl __spin_table
__spin_table :
.space CONFIG_ M A X _ C P U S * E N T R Y _ S I Z E
/ *
* This v a r i a b l e i s s e t b y c p u _ i n i t _ r ( ) a f t e r p a r s i n g h w c o n f i g
* to e n a b l e w o r k a r o u n d f o r e r r a t u m N M G _ C P U _ A 0 1 1 .
* /
.align L1_CACHE_SHIFT
.global enable_cpu_a011_workaround
enable_cpu_a011_workaround :
.long 1
/ * Fill i n t h e e m p t y s p a c e . T h e a c t u a l r e s e t v e c t o r i s
* the l a s t w o r d o f t h e p a g e * /
__secondary_start_code_end :
.space 4092 - ( _ _ secondary_ s t a r t _ c o d e _ e n d - _ _ s e c o n d a r y _ s t a r t _ p a g e )
__secondary_reset_vector :
b _ _ s e c o n d a r y _ s t a r t _ p a g e
__spin_table_end :
.space 4096 - ( _ _ spin_ t a b l e _ e n d - _ _ s p i n _ t a b l e )