2016-02-03 18:14:50 -08:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( C ) 2 0 1 1 - 2 0 1 2 b y B r o a d c o m C o r p o r a t i o n
*
* Init f o r b m i p s 5 0 0 0 .
* Used t o i n i t s e c o n d c o r e i n d u a l c o r e 5 0 0 0 ' s .
* /
# include < l i n u x / i n i t . h >
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
# include < a s m / c a c h e o p s . h >
# include < a s m / r e g d e f . h >
# include < a s m / m i p s r e g s . h >
# include < a s m / s t a c k f r a m e . h >
# include < a s m / a d d r s p a c e . h >
# include < a s m / h a z a r d s . h >
# include < a s m / b m i p s . h >
# ifdef C O N F I G _ C P U _ B M I P S 5 0 0 0
# define c a c h e o p ( k v a , s i z e , l i n e s i z e , o p ) \
.set noreorder ; \
2016-04-13 01:17:57 +02:00
addu t 1 , k v a , s i z e ; \
subu t 2 , l i n e s i z e , 1 ; \
not t 2 ; \
and t 0 , k v a , t 2 ; \
addiu t 1 , t 1 , - 1 ; \
and t 1 , t 2 ; \
9 : cache o p , 0 ( t 0 ) ; \
bne t 0 , t 1 , 9 b ; \
addu t 0 , l i n e s i z e ; \
.set reorder ;
2016-02-03 18:14:50 -08:00
# define I S _ S H I F T 2 2
# define I L _ S H I F T 1 9
# define I A _ S H I F T 1 6
# define D S _ S H I F T 1 3
# define D L _ S H I F T 1 0
# define D A _ S H I F T 7
# define I S _ M A S K 7
# define I L _ M A S K 7
# define I A _ M A S K 7
# define D S _ M A S K 7
# define D L _ M A S K 7
# define D A _ M A S K 7
# define I C E _ M A S K 0 x80 0 0 0 0 0 0
# define D C E _ M A S K 0 x40 0 0 0 0 0 0
# define C P 0 _ B R C M _ C O N F I G 0 $ 2 2 , 0
# define C P 0 _ B R C M _ M O D E $ 2 2 , 1
# define C P 0 _ C O N F I G _ K 0 _ M A S K 7
2016-04-13 01:17:57 +02:00
# define C P 0 _ I C A C H E _ T A G _ L O $ 2 8
# define C P 0 _ I C A C H E _ D A T A _ L O $ 2 8 , 1
# define C P 0 _ D C A C H E _ T A G _ L O $ 2 8 , 2
2016-02-03 18:14:50 -08:00
# define C P 0 _ D _ S E C _ C A C H E _ D A T A _ L O $ 2 8 , 3
2016-04-13 01:17:57 +02:00
# define C P 0 _ I C A C H E _ T A G _ H I $ 2 9
# define C P 0 _ I C A C H E _ D A T A _ H I $ 2 9 , 1
# define C P 0 _ D C A C H E _ T A G _ H I $ 2 9 , 2
2016-02-03 18:14:50 -08:00
# define C P 0 _ B R C M _ M O D E _ L u c _ M A S K ( 1 < < 1 1 )
# define C P 0 _ B R C M _ C O N F I G 0 _ C W F _ M A S K ( 1 < < 2 0 )
# define C P 0 _ B R C M _ C O N F I G 0 _ T S E _ M A S K ( 1 < < 1 9 )
# define C P 0 _ B R C M _ M O D E _ S E T _ M A S K ( 1 < < 7 )
# define C P 0 _ B R C M _ M O D E _ C l k R A T I O _ M A S K ( 7 < < 4 )
# define C P 0 _ B R C M _ M O D E _ B r P R E D _ M A S K ( 3 < < 2 4 )
# define C P 0 _ B R C M _ M O D E _ B r P R E D _ S H I F T 2 4
# define C P 0 _ B R C M _ M O D E _ B r H I S T _ M A S K ( 0 x1 f < < 2 0 )
# define C P 0 _ B R C M _ M O D E _ B r H I S T _ S H I F T 2 0
/* ZSC L2 Cache Register Access Register Definitions */
2016-04-13 01:17:57 +02:00
# define B R C M _ Z S C _ A L L _ R E G S _ S E L E C T 0 x7 < < 2 4
2016-02-03 18:14:50 -08:00
# define B R C M _ Z S C _ C O N F I G _ R E G 0 < < 3
# define B R C M _ Z S C _ R E Q _ B U F F E R _ R E G 2 < < 3
# define B R C M _ Z S C _ R B U S _ A D D R _ M A P P I N G _ R E G 0 4 < < 3
# define B R C M _ Z S C _ R B U S _ A D D R _ M A P P I N G _ R E G 1 6 < < 3
# define B R C M _ Z S C _ R B U S _ A D D R _ M A P P I N G _ R E G 2 8 < < 3
# define B R C M _ Z S C _ S C B 0 _ A D D R _ M A P P I N G _ R E G 0 0 x a < < 3
# define B R C M _ Z S C _ S C B 0 _ A D D R _ M A P P I N G _ R E G 1 0 x c < < 3
# define B R C M _ Z S C _ S C B 1 _ A D D R _ M A P P I N G _ R E G 0 0 x e < < 3
# define B R C M _ Z S C _ S C B 1 _ A D D R _ M A P P I N G _ R E G 1 0 x10 < < 3
# define B R C M _ Z S C _ C O N F I G _ L M B 1 E n 1 < < ( 1 5 )
# define B R C M _ Z S C _ C O N F I G _ L M B 0 E n 1 < < ( 1 4 )
/* branch predition values */
# define B R C M _ B r P R E D _ A L L _ T A K E N ( 0 x0 )
# define B R C M _ B r P R E D _ A L L _ N O T _ T A K E N ( 0 x1 )
# define B R C M _ B r P R E D _ B H T _ E N A B L E ( 0 x2 )
# define B R C M _ B r P R E D _ P R E D I C T _ B A C K W A R D ( 0 x3 )
.align 2
/ *
* Function : size_ i _ c a c h e
* Arguments : None
* Returns : v0 = i c a c h e s i z e , v1 = I c a c h e l i n e s i z e
* Description : compute t h e I - c a c h e s i z e a n d I - c a c h e l i n e s i z e
* Trashes : v0 , v1 , a0 , t 0
*
* pseudo c o d e :
*
* /
LEAF( s i z e _ i _ c a c h e )
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
mfc0 a0 , C P 0 _ C O N F I G , 1
2016-02-03 18:14:50 -08:00
move t 0 , a0
/ *
* Determine s e t s p e r w a y : I S
*
* This f i e l d c o n t a i n s t h e n u m b e r o f s e t s ( i . e . , i n d i c e s ) p e r w a y o f
* the i n s t r u c t i o n c a c h e :
* i) 0 x0 : 6 4 , i i ) 0 x1 : 1 2 8 , i i i ) 0 x2 : 2 5 6 , i v ) 0 x3 : 5 1 2 , v ) 0 x4 : 1 k
* vi) 0 x5 - 0 x7 : R e s e r v e d .
* /
2016-04-13 01:17:57 +02:00
srl a0 , a0 , I S _ S H I F T
and a0 , a0 , I S _ M A S K
2016-02-03 18:14:50 -08:00
/* sets per way = (64<<IS) */
li v0 , 0 x40
2016-04-13 01:17:57 +02:00
sllv v0 , v0 , a0
2016-02-03 18:14:50 -08:00
/ *
* Determine l i n e s i z e
*
* This f i e l d c o n t a i n s t h e l i n e s i z e o f t h e i n s t r u c t i o n c a c h e :
* i) 0 x0 : N o I - c a c h e p r e s e n t , i ) 0 x3 : 1 6 b y t e s , i i ) 0 x4 : 3 2 b y t e s , i i i )
* 0x5 : 6 4 bytes, i v ) t h e r e s t : R e s e r v e d .
* /
move a0 , t 0
srl a0 , a0 , I L _ S H I F T
and a0 , a0 , I L _ M A S K
beqz a0 , n o _ i _ c a c h e
nop
/* line size = 2 ^ (IL+1) */
addi a0 , a0 , 1
li v1 , 1
sll v1 , v1 , a0
/ * v0 n o w h a v e s e t s p e r w a y , m u l t i p l y i t b y l i n e s i z e n o w
* that w i l l g i v e t h e s e t s i z e
* /
sll v0 , v0 , a0
/ *
* Determine s e t a s s o c i a t i v i t y
*
* This f i e l d c o n t a i n s t h e s e t a s s o c i a t i v i t y o f t h e i n s t r u c t i o n c a c h e .
* i) 0 x0 : D i r e c t m a p p e d , i i ) 0 x1 : 2 - w a y , i i i ) 0 x2 : 3 - w a y , i v ) 0 x3 :
* 4 - way, v ) 0 x4 - 0 x7 : R e s e r v e d .
* /
move a0 , t 0
srl a0 , a0 , I A _ S H I F T
and a0 , a0 , I A _ M A S K
addi a0 , a0 , 0 x1
/ * v0 h a s t h e s e t s i z e , m u l t i p l y i t b y
* set a s s o c i a t i v i y , t o g e t t h e c a c h e s i z e
* /
multu v0 , a0 / * m u l t u i s i n t e r l o c k e d , s o n o n e e d t o i n s e r t n o p s * /
2016-04-13 01:17:57 +02:00
mflo v0
2016-02-03 18:14:50 -08:00
b 1 f
nop
no_i_cache :
2016-04-13 01:17:57 +02:00
move v0 , z e r o
2016-02-03 18:14:50 -08:00
move v1 , z e r o
1 :
2016-04-13 01:17:57 +02:00
jr r a
2016-02-03 18:14:50 -08:00
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s i z e _ i _ c a c h e )
/ *
* Function : size_ d _ c a c h e
* Arguments : None
* Returns : v0 = d c a c h e s i z e , v1 = d c a c h e l i n e s i z e
* Description : compute t h e D - c a c h e s i z e a n d D - c a c h e l i n e s i z e .
* Trashes : v0 , v1 , a0 , t 0
*
* /
LEAF( s i z e _ d _ c a c h e )
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
mfc0 a0 , C P 0 _ C O N F I G , 1
2016-02-03 18:14:50 -08:00
move t 0 , a0
/ *
* Determine s e t s p e r w a y : I S
*
* This f i e l d c o n t a i n s t h e n u m b e r o f s e t s ( i . e . , i n d i c e s ) p e r w a y o f
* the i n s t r u c t i o n c a c h e :
* i) 0 x0 : 6 4 , i i ) 0 x1 : 1 2 8 , i i i ) 0 x2 : 2 5 6 , i v ) 0 x3 : 5 1 2 , v ) 0 x4 : 1 k
* vi) 0 x5 - 0 x7 : R e s e r v e d .
* /
2016-04-13 01:17:57 +02:00
srl a0 , a0 , D S _ S H I F T
and a0 , a0 , D S _ M A S K
2016-02-03 18:14:50 -08:00
/* sets per way = (64<<IS) */
li v0 , 0 x40
2016-04-13 01:17:57 +02:00
sllv v0 , v0 , a0
2016-02-03 18:14:50 -08:00
/ *
* Determine l i n e s i z e
*
* This f i e l d c o n t a i n s t h e l i n e s i z e o f t h e i n s t r u c t i o n c a c h e :
* i) 0 x0 : N o I - c a c h e p r e s e n t , i ) 0 x3 : 1 6 b y t e s , i i ) 0 x4 : 3 2 b y t e s , i i i )
* 0x5 : 6 4 bytes, i v ) t h e r e s t : R e s e r v e d .
* /
move a0 , t 0
srl a0 , a0 , D L _ S H I F T
and a0 , a0 , D L _ M A S K
beqz a0 , n o _ d _ c a c h e
nop
/* line size = 2 ^ (IL+1) */
addi a0 , a0 , 1
li v1 , 1
sll v1 , v1 , a0
/ * v0 n o w h a v e s e t s p e r w a y , m u l t i p l y i t b y l i n e s i z e n o w
* that w i l l g i v e t h e s e t s i z e
* /
sll v0 , v0 , a0
/ * determine s e t a s s o c i a t i v i t y
*
* This f i e l d c o n t a i n s t h e s e t a s s o c i a t i v i t y o f t h e i n s t r u c t i o n c a c h e .
* i) 0 x0 : D i r e c t m a p p e d , i i ) 0 x1 : 2 - w a y , i i i ) 0 x2 : 3 - w a y , i v ) 0 x3 :
* 4 - way, v ) 0 x4 - 0 x7 : R e s e r v e d .
* /
move a0 , t 0
srl a0 , a0 , D A _ S H I F T
and a0 , a0 , D A _ M A S K
addi a0 , a0 , 0 x1
/ * v0 h a s t h e s e t s i z e , m u l t i p l y i t b y
* set a s s o c i a t i v i y , t o g e t t h e c a c h e s i z e
* /
multu v0 , a0 / * m u l t u i s i n t e r l o c k e d , s o n o n e e d t o i n s e r t n o p s * /
2016-04-13 01:17:57 +02:00
mflo v0
2016-02-03 18:14:50 -08:00
b 1 f
nop
no_d_cache :
2016-04-13 01:17:57 +02:00
move v0 , z e r o
2016-02-03 18:14:50 -08:00
move v1 , z e r o
1 :
jr r a
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s i z e _ d _ c a c h e )
/ *
* Function : enable_ I D
* Arguments : None
* Returns : None
* Description : Enable I a n d D c a c h e s , i n i t i a l i z e I a n d D - c a c h e s , a l s o s e t
2016-04-13 01:17:57 +02:00
* hardware d e l a y f o r d - c a c h e ( T P 0 ) .
2016-02-03 18:14:50 -08:00
* Trashes : t0
*
* /
.global enable_ID
.ent enable_ID
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
enable_ID :
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ B R C M _ C O N F I G 0
2016-02-03 18:14:50 -08:00
or t 0 , t 0 , ( I C E _ M A S K | D C E _ M A S K )
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ B R C M _ C O N F I G 0
2016-02-03 18:14:50 -08:00
jr r a
nop
.end enable_ID
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
/ *
* Function : l1 _ i n i t
* Arguments : None
* Returns : None
* Description : Enable I a n d D c a c h e s , a n d i n i t i a l i z e I a n d D - c a c h e s
* Trashes : a0 , v0 , v1 , t 0 , t 1 , t 2 , t 8
*
* /
.globl l1_init
.ent l1_init
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
l1_init :
/* save return address */
2016-04-13 01:17:57 +02:00
move t 8 , r a
2016-02-03 18:14:50 -08:00
/* initialize I and D cache Data and Tag registers. */
2016-04-13 01:17:57 +02:00
mtc0 z e r o , C P 0 _ I C A C H E _ T A G _ L O
mtc0 z e r o , C P 0 _ I C A C H E _ T A G _ H I
2016-02-03 18:14:50 -08:00
mtc0 z e r o , C P 0 _ I C A C H E _ D A T A _ L O
mtc0 z e r o , C P 0 _ I C A C H E _ D A T A _ H I
mtc0 z e r o , C P 0 _ D C A C H E _ T A G _ L O
mtc0 z e r o , C P 0 _ D C A C H E _ T A G _ H I
/ * Enable C a c h e s b e f o r e C l e a r i n g . I f t h e c a c h e s a r e d i s a b l e d
* then t h e c a c h e o p e r a t i o n s t o c l e a r t h e c a c h e w i l l b e i g n o r e d
* /
jal e n a b l e _ I D
nop
jal s i z e _ i _ c a c h e / * v0 = i - c a c h e s i z e , v1 = i - c a c h e l i n e s i z e * /
nop
/* run uncached in kseg 1 */
la k 0 , 1 f
lui k 1 , 0 x20 0 0
or k 0 , k 1 , k 0
jr k 0
nop
1 :
/ *
* set K 0 c a c h e m o d e
* /
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ C O N F I G
and t 0 , t 0 , ~ C P 0 _ C O N F I G _ K 0 _ M A S K
or t 0 , t 0 , 3 / * W r i t e B a c k m o d e * /
mtc0 t 0 , C P 0 _ C O N F I G
2016-02-03 18:14:50 -08:00
/ *
2016-04-13 01:17:57 +02:00
* Initialize i n s t r u c t i o n c a c h e .
2016-02-03 18:14:50 -08:00
* /
li a0 , K S E G 0
cacheop( a0 , v0 , v1 , I n d e x _ S t o r e _ T a g _ I )
/ *
* Now w e c a n r u n f r o m I - $ , k s e g 0
* /
la k 0 , 1 f
lui k 1 , 0 x20 0 0
or k 0 , k 1 , k 0
xor k 0 , k 1 , k 0
jr k 0
nop
1 :
/ *
2016-04-13 01:17:57 +02:00
* Initialize d a t a c a c h e .
2016-02-03 18:14:50 -08:00
* /
jal s i z e _ d _ c a c h e / * v0 = d - c a c h e s i z e , v1 = d - c a c h e l i n e s i z e * /
nop
2016-04-13 01:17:57 +02:00
li a0 , K S E G 0
2016-02-03 18:14:50 -08:00
cacheop( a0 , v0 , v1 , I n d e x _ S t o r e _ T a g _ D )
jr t 8
nop
.end l1_init
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
/ *
* Function : set_ o t h e r _ c o n f i g
* Arguments : none
* Returns : None
* Description : initialize o t h e r r e m a i n d e r c o n f i g u r a t i o n t o d e f a u l t s .
* Trashes : t0 , t 1
*
* pseudo c o d e :
*
* /
LEAF( s e t _ o t h e r _ c o n f i g )
.set noreorder
2016-04-13 01:17:57 +02:00
/* enable Bus error for I-fetch */
mfc0 t 0 , C P 0 _ C A C H E E R R , 0
li t 1 , 0 x4
or t 0 , t 1
2016-02-03 18:14:50 -08:00
mtc0 t 0 , C P 0 _ C A C H E E R R , 0
2016-04-13 01:17:57 +02:00
/* enable Bus error for Load */
mfc0 t 0 , C P 0 _ C A C H E E R R , 1
li t 1 , 0 x4
or t 0 , t 1
2016-02-03 18:14:50 -08:00
mtc0 t 0 , C P 0 _ C A C H E E R R , 1
/* enable Bus Error for Store */
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ C A C H E E R R , 2
2016-02-03 18:14:50 -08:00
li t 1 , 0 x4
or t 0 , t 1
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ C A C H E E R R , 2
2016-02-03 18:14:50 -08:00
jr r a
nop
.set reorder
END( s e t _ o t h e r _ c o n f i g )
/ *
* Function : set_ b r a n c h _ p r e d
* Arguments : none
* Returns : None
* Description :
* Trashes : t0 , t 1
*
* pseudo c o d e :
*
* /
LEAF( s e t _ b r a n c h _ p r e d )
.set noreorder
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
li t 1 , ~ ( C P 0 _ B R C M _ M O D E _ B r P R E D _ M A S K | C P 0 _ B R C M _ M O D E _ B r H I S T _ M A S K )
and t 0 , t 0 , t 1
/* enable Branch prediction */
li t 1 , B R C M _ B r P R E D _ B H T _ E N A B L E
sll t 1 , C P 0 _ B R C M _ M O D E _ B r P R E D _ S H I F T
or t 0 , t 0 , t 1
/* set history count to 8 */
li t 1 , 8
sll t 1 , C P 0 _ B R C M _ M O D E _ B r H I S T _ S H I F T
or t 0 , t 0 , t 1
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
jr r a
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s e t _ b r a n c h _ p r e d )
/ *
* Function : set_ l u c
* Arguments : set l i n k u n c a c h e d .
* Returns : None
* Description :
* Trashes : t0 , t 1
*
* /
LEAF( s e t _ l u c )
.set noreorder
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
li t 1 , ~ ( C P 0 _ B R C M _ M O D E _ L u c _ M A S K )
and t 0 , t 0 , t 1
/* set Luc */
2016-04-13 01:17:57 +02:00
ori t 0 , t 0 , C P 0 _ B R C M _ M O D E _ L u c _ M A S K
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
jr r a
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s e t _ l u c )
/ *
* Function : set_ c w f _ t s e
* Arguments : set C W F a n d T S E b i t s
* Returns : None
* Description :
* Trashes : t0 , t 1
*
* /
LEAF( s e t _ c w f _ t s e )
.set noreorder
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ B R C M _ C O N F I G 0
2016-02-03 18:14:50 -08:00
li t 1 , ( C P 0 _ B R C M _ C O N F I G 0 _ C W F _ M A S K | C P 0 _ B R C M _ C O N F I G 0 _ T S E _ M A S K )
or t 0 , t 0 , t 1
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ B R C M _ C O N F I G 0
2016-02-03 18:14:50 -08:00
jr r a
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s e t _ c w f _ t s e )
/ *
* Function : set_ c l o c k _ r a t i o
2016-04-13 01:17:57 +02:00
* Arguments : set c l o c k r a t i o s p e c i f i e d b y a0
2016-02-03 18:14:50 -08:00
* Returns : None
* Description :
* Trashes : v0 , v1 , a0 , a1
*
* pseudo c o d e :
*
* /
LEAF( s e t _ c l o c k _ r a t i o )
.set noreorder
2016-04-13 01:17:57 +02:00
mfc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
li t 1 , ~ ( C P 0 _ B R C M _ M O D E _ S E T _ M A S K | C P 0 _ B R C M _ M O D E _ C l k R A T I O _ M A S K )
and t 0 , t 0 , t 1
li t 1 , C P 0 _ B R C M _ M O D E _ S E T _ M A S K
or t 0 , t 0 , t 1
or t 0 , t 0 , a0
2016-04-13 01:17:57 +02:00
mtc0 t 0 , C P 0 _ B R C M _ M O D E
2016-02-03 18:14:50 -08:00
jr r a
nop
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
END( s e t _ c l o c k _ r a t i o )
/ *
* Function : set_ z e p h y r
2016-04-13 01:17:57 +02:00
* Arguments : None
* Returns : None
2016-02-03 18:14:50 -08:00
* Description : Set a n y z e p h y r b i t s
2016-04-13 01:17:57 +02:00
* Trashes : t0 & t 1
2016-02-03 18:14:50 -08:00
*
* /
LEAF( s e t _ z e p h y r )
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
/* enable read/write of CP0 #22 sel. 8 */
li t 0 , 0 x5 a45 5 0 4 8
.word 0x4088b00f /* mtc0 t0, $22, 15 */
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
.word 0x4008b008 /* mfc0 t0, $22, 8 */
li t 1 , 0 x09 0 0 8 0 0 0 / * t u r n o f f p r e f , j t b * /
or t 0 , t 0 , t 1
.word 0x4088b008 /* mtc0 t0, $22, 8 */
sync
2016-02-03 18:14:50 -08:00
/* disable read/write of CP0 #22 sel 8 */
2016-04-13 01:17:57 +02:00
li t 0 , 0 x0
.word 0x4088b00f /* mtc0 t0, $22, 15 */
2016-02-03 18:14:50 -08:00
2016-04-13 01:17:57 +02:00
jr r a
nop
2016-02-03 18:14:50 -08:00
.set reorder
END( s e t _ z e p h y r )
/ *
2016-04-13 01:17:57 +02:00
* Function : set_ l l m b
* Arguments : a0 =0 d i s a b l e l l m b , a0 =1 e n a b l e s l l m b
* Returns : None
2016-02-03 18:14:50 -08:00
* Description :
2016-04-13 01:17:57 +02:00
* Trashes : t0 , t 1 , t 2
2016-02-03 18:14:50 -08:00
*
* pseudo c o d e :
*
* /
LEAF( s e t _ l l m b )
.set noreorder
li t 2 , 0 x90 0 0 0 0 0 0 | B R C M _ Z S C _ A L L _ R E G S _ S E L E C T | B R C M _ Z S C _ C O N F I G _ R E G
sync
cache 0 x7 , 0 x0 ( t 2 )
sync
mfc0 t 0 , C P 0 _ D _ S E C _ C A C H E _ D A T A _ L O
li t 1 , ~ ( B R C M _ Z S C _ C O N F I G _ L M B 1 E n | B R C M _ Z S C _ C O N F I G _ L M B 0 E n )
and t 0 , t 0 , t 1
beqz a0 , s v l m b
nop
enable_lmb :
li t 1 , ( B R C M _ Z S C _ C O N F I G _ L M B 1 E n | B R C M _ Z S C _ C O N F I G _ L M B 0 E n )
or t 0 , t 0 , t 1
svlmb :
mtc0 t 0 , C P 0 _ D _ S E C _ C A C H E _ D A T A _ L O
sync
cache 0 x b , 0 x0 ( t 2 )
sync
2016-04-13 01:17:57 +02:00
jr r a
2016-02-03 18:14:50 -08:00
nop
.set reorder
END( s e t _ l l m b )
/ *
* Function : core_ i n i t
* Arguments : none
* Returns : None
* Description : initialize c o r e r e l a t e d c o n f i g u r a t i o n
* Trashes : v0 ,v1 ,a0 ,a1 ,t 8
*
* pseudo c o d e :
*
* /
.globl core_init
2016-04-13 01:17:57 +02:00
.ent core_init
2016-02-03 18:14:50 -08:00
.set noreorder
core_init :
move t 8 , r a
/* set Zephyr bits. */
bal s e t _ z e p h y r
nop
# if E N A B L E _ F P U = =1
/* initialize the Floating point unit (both TPs) */
bal i n i t _ f p u
nop
# endif
/* set low latency memory bus */
2016-04-13 01:17:57 +02:00
li a0 , 1
bal s e t _ l l m b
2016-02-03 18:14:50 -08:00
nop
/* set branch prediction (TP0 only) */
bal s e t _ b r a n c h _ p r e d
nop
/* set link uncached */
bal s e t _ l u c
nop
/* set CWF and TSE */
2016-04-13 01:17:57 +02:00
bal s e t _ c w f _ t s e
2016-02-03 18:14:50 -08:00
nop
/ *
* set c l o c k r a t i o b y s e t t i n g 1 t o ' s e t '
* and 0 t o C l k R a t i o , ( T P 0 o n l y )
* /
li a0 , 0
bal s e t _ c l o c k _ r a t i o
nop
/* set other configuration to defaults */
bal s e t _ o t h e r _ c o n f i g
nop
move r a , t 8
jr r a
nop
.set reorder
.end core_init
/ *
* Function : clear_ j u m p _ t a r g e t _ b u f f e r
2016-04-13 01:17:57 +02:00
* Arguments : None
* Returns : None
2016-02-03 18:14:50 -08:00
* Description :
2016-04-13 01:17:57 +02:00
* Trashes : t0 , t 1 , t 2
2016-02-03 18:14:50 -08:00
*
* /
2016-04-13 01:17:57 +02:00
# define R E S E T _ C A L L _ R E T U R N _ S T A C K _ T H I S _ T H R E A D ( 0 x06 < < 1 6 )
# define R E S E T _ J U M P _ T A R G E T _ B U F F E R _ T H I S _ T H R E A D ( 0 x04 < < 1 6 )
2016-02-03 18:14:50 -08:00
# define J T B _ C S _ C N T L _ M A S K ( 0 x F F < < 1 6 )
2016-04-13 01:17:57 +02:00
.globl clear_jump_target_buffer
.ent clear_jump_target_buffer
.set noreorder
2016-02-03 18:14:50 -08:00
clear_jump_target_buffer :
2016-04-13 01:17:57 +02:00
mfc0 t 0 , $ 2 2 , 2
nop
nop
li t 1 , ~ J T B _ C S _ C N T L _ M A S K
and t 0 , t 0 , t 1
li t 2 , R E S E T _ C A L L _ R E T U R N _ S T A C K _ T H I S _ T H R E A D
or t 0 , t 0 , t 2
mtc0 t 0 , $ 2 2 , 2
nop
nop
and t 0 , t 0 , t 1
li t 2 , R E S E T _ J U M P _ T A R G E T _ B U F F E R _ T H I S _ T H R E A D
or t 0 , t 0 , t 2
mtc0 t 0 , $ 2 2 , 2
nop
nop
jr r a
nop
.end clear_jump_target_buffer
.set reorder
2016-02-03 18:14:50 -08:00
/ *
* Function : bmips_ c a c h e _ i n i t
* Arguments : None
* Returns : None
* Description : Enable I a n d D c a c h e s , a n d i n i t i a l i z e I a n d D - c a c h e s
* Trashes : v0 , v1 , t 0 , t 1 , t 2 , t 5 , t 7 , t 8
*
* /
.globl bmips_5xxx_init
.ent bmips_5xxx_init
2016-04-13 01:17:57 +02:00
.set noreorder
2016-02-03 18:14:50 -08:00
bmips_5xxx_init :
2016-04-13 01:17:57 +02:00
/* save return address and A0 */
move t 7 , r a
2016-02-03 18:14:50 -08:00
move t 5 , a0
jal l 1 _ i n i t
nop
jal c o r e _ i n i t
nop
jal c l e a r _ j u m p _ t a r g e t _ b u f f e r
nop
2016-04-13 01:17:57 +02:00
mtc0 z e r o , C P 0 _ C A U S E
2016-02-03 18:14:50 -08:00
move a0 , t 5
jr t 7
nop
.end bmips_5xxx_init
2016-04-13 01:17:57 +02:00
.set reorder
2016-02-03 18:14:50 -08:00
# endif