@ -30,11 +30,23 @@
# include < a s m / a d d r s p a c e . h >
# include < a s m / c a c h e o p s . h >
# define R A t 8
/ * 1 6 KB i s t h e m a x i m u m s i z e o f i n s t r u c t i o n a n d d a t a c a c h e s o n
* MIPS 4 K .
* /
# define M I P S _ M A X _ C A C H E _ S I Z E 0 x40 0 0
# define I N D E X _ B A S E K S E G 0
.macro cache_op op a d d r
.set push
.set noreorder
.set mips3
cache \ o p , 0 ( \ a d d r )
.set pop
.endm
/ *
* cacheop m a c r o t o a u t o m a t e c a c h e o p e r a t i o n s
* first s o m e h e l p e r s . . .
@ -125,6 +137,56 @@
# endif
.endm
/ *
* mips_ i n i t _ i c a c h e ( u i n t P R I d , u l o n g i c a c h e _ s i z e , u n c h a r i c a c h e _ l i n e s z )
* /
LEAF( m i p s _ i n i t _ i c a c h e )
blez a1 , 9 f
mtc0 z e r o , C P 0 _ T A G L O
/* clear tag to invalidate */
PTR_ L I t 0 , I N D E X _ B A S E
PTR_ A D D U t 1 , t 0 , a1
1 : cache_ o p I n d e x _ S t o r e _ T a g _ I t 0
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 1 b
/* fill once, so data field parity is correct */
PTR_ L I t 0 , I N D E X _ B A S E
2 : cache_ o p F i l l t 0
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 2 b
/* invalidate again - prudent but not strictly neccessary */
PTR_ L I t 0 , I N D E X _ B A S E
1 : cache_ o p I n d e x _ S t o r e _ T a g _ I t 0
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 1 b
9 : jr r a
END( m i p s _ i n i t _ i c a c h e )
/ *
* mips_ i n i t _ d c a c h e ( u i n t P R I d , u l o n g d c a c h e _ s i z e , u n c h a r d c a c h e _ l i n e s z )
* /
LEAF( m i p s _ i n i t _ d c a c h e )
blez a1 , 9 f
mtc0 z e r o , C P 0 _ T A G L O
/* clear all tags */
PTR_ L I t 0 , I N D E X _ B A S E
PTR_ A D D U t 1 , t 0 , a1
1 : cache_ o p I n d e x _ S t o r e _ T a g _ D t 0
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 1 b
/* load from each line (in cached space) */
PTR_ L I t 0 , I N D E X _ B A S E
2 : LONG_ L z e r o , 0 ( t 0 )
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 2 b
/* clear all tags */
PTR_ L I t 0 , I N D E X _ B A S E
1 : cache_ o p I n d e x _ S t o r e _ T a g _ D t 0
PTR_ A D D U t 0 , a2
bne t 0 , t 1 , 1 b
9 : jr r a
END( m i p s _ i n i t _ d c a c h e )
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* mips_ c a c h e _ r e s e t - l o w l e v e l i n i t i a l i s a t i o n o f t h e p r i m a r y c a c h e s
@ -142,6 +204,7 @@
*
* /
NESTED( m i p s _ c a c h e _ r e s e t , 0 , r a )
move R A , r a
li t 2 , C F G _ I C A C H E _ S I Z E
li t 3 , C F G _ D C A C H E _ S I Z E
li t 4 , C F G _ C A C H E L I N E _ S I Z E
@ -158,57 +221,31 @@ NESTED(mips_cache_reset, 0, ra)
f_ f i l l 6 4 a0 , - 6 4 , z e r o
bne a0 , a1 , 2 b
/ * Set i n v a l i d t a g .
* /
mtc0 z e r o , C P 0 _ T A G L O
/ *
* The c a c h e s a r e p r o b a b l y i n a n i n d e t e r m i n a t e s t a t e ,
* so w e f o r c e g o o d p a r i t y i n t o t h e m b y d o i n g a n
* invalidate, l o a d / f i l l , i n v a l i d a t e f o r e a c h l i n e .
* /
/ * Assume b o t t o m o f R A M w i l l g e n e r a t e g o o d p a r i t y f o r t h e c a c h e .
* /
li a0 , K 0 B A S E
move a2 , t 2 # i c a c h e S i z e
move a3 , t 4 # i c a c h e L i n e S i z e
move a1 , a2
icacheopn( a0 ,a1 ,a2 ,a3 ,1 2 1 ,( I n d e x _ S t o r e _ T a g _ I ,F i l l ) )
/ * To s u p p o r t O r i o n / R 4 6 0 0 , w e i n i t i a l i s e t h e d a t a c a c h e i n 3 p a s s e s .
* /
/ * 1 : initialise d c a c h e t a g s .
/ *
* Assume b o t t o m o f R A M w i l l g e n e r a t e g o o d p a r i t y f o r t h e c a c h e .
* /
li a0 , K 0 B A S E
move a2 , t 3 # d c a c h e S i z e
move a3 , t 5 # d c a c h e L i n e S i z e
move a1 , a2
icacheop( a0 ,a1 ,a2 ,a3 ,I n d e x _ S t o r e _ T a g _ D )
/ * 2 : fill d c a c h e .
/ *
* Initialize t h e I - c a c h e f i r s t ,
* /
move a1 , t 2
move a2 , t 4
bal m i p s _ i n i t _ i c a c h e
li a0 , K 0 B A S E
move a2 , t 3 # d c a c h e S i z e
move a3 , t 5 # d c a c h e L i n e S i z e
move a1 , a2
icacheopn( a0 ,a1 ,a2 ,a3 ,1 l w ,( d u m m y ) )
/ * 3 : clear d c a c h e t a g s .
/ *
* then i n i t i a l i z e D - c a c h e .
* /
move a1 , t 3
move a2 , t 5
bal m i p s _ i n i t _ d c a c h e
li a0 , K 0 B A S E
move a2 , t 3 # d c a c h e S i z e
move a3 , t 5 # d c a c h e L i n e S i z e
move a1 , a2
icacheop( a0 ,a1 ,a2 ,a3 ,I n d e x _ S t o r e _ T a g _ D )
j r a
jr R A
END( m i p s _ c a c h e _ r e s e t )
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *