2005-04-17 02:20:36 +04:00
/ *
* Copyright ( C ) 2 0 0 1 ,2 0 0 2 ,2 0 0 3 B r o a d c o m C o r p o r a t i o n
*
* 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 .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y 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
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e - S u i t e 3 3 0 , B o s t o n , M A 0 2 1 1 1 - 1 3 0 7 , U S A .
* /
# include < l i n u x / i n i t . h >
# include < a s m / a s m . 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 / c a c h e o p s . h >
# include < a s m / s i b y t e / b o a r d . h >
# define C 0 _ E R R C T L $ 2 6 / * C P 0 : E r r o r i n f o * /
# define C 0 _ C E R R _ I $ 2 7 / * C P 0 : I c a c h e e r r o r * /
# define C 0 _ C E R R _ D $ 2 7 ,1 / * C P 0 : D c a c h e e r r o r * /
/ *
* Based o n S i B y t e s a m p l e s o f t w a r e c a c h e - e r r / c e r r . S
* CVS r e v i s i o n 1 . 8 . O n l y t h e ' u n r e c o v e r a b l e ' c a s e
* is c h a n g e d .
* /
.set mips64
.set noreorder
.set noat
/ *
* sb1_cerr_vec : code t o b e c o p i e d t o t h e C a c h e E r r o r
* Exception v e c t o r . T h e c o d e m u s t b e p u s h e d o u t t o m e m o r y
* ( either b y c o p y i n g t o K s e g 0 a n d K s e g 1 b o t h , o r b y f l u s h i n g
* the L 1 a n d L 2 ) s i n c e i t i s f e t c h e d a s 0 x a00 0 0 1 0 0 .
*
* NOTE : Be s u r e t h i s h a n d l e r i s a t m o s t 2 8 i n s t r u c t i o n s l o n g
* since t h e f i n a l 1 6 b y t e s o f t h e e x c e p t i o n v e c t o r m e m o r y
* ( 0 x1 7 0 - 0 x17 f ) a r e u s e d t o p r e s e r v e k 0 , k 1 , a n d r a .
* /
2008-03-08 12:56:28 +03:00
_ _ CPUINIT
2005-04-17 02:20:36 +04:00
LEAF( e x c e p t _ v e c2 _ s b1 )
/ *
* If t h i s e r r o r i s r e c o v e r a b l e , w e n e e d t o e x i t t h e h a n d l e r
* without h a v i n g d i r t i e d a n y r e g i s t e r s . T o d o t h i s ,
* save/ r e s t o r e k 0 a n d k 1 f r o m l o w m e m o r y ( U s e g i s d i r e c t
* mapped w h i l e E R L =1 ) . N o t e t h a t w e c a n ' t s a v e t o a
* CPU- s p e c i f i c l o c a t i o n w i t h o u t r u i n i n g a r e g i s t e r i n t h e
* process. T h i s m e a n s w e a r e v u l n e r a b l e t o d a t a c o r r u p t i o n
* whenever t h e h a n d l e r i s r e e n t e r e d b y a s e c o n d C P U .
* /
sd k 0 ,0 x17 0 ( $ 0 )
sd k 1 ,0 x17 8 ( $ 0 )
2005-11-10 19:35:03 +03:00
# ifdef C O N F I G _ S B 1 _ C E X _ A L W A Y S _ F A T A L
2005-10-20 10:57:40 +04:00
j h a n d l e _ v e c2 _ s b1
nop
# else
2005-04-17 02:20:36 +04:00
/ *
* M_ E R R C T L _ R E C O V E R A B L E i s b i t 3 1 , w h i c h m a k e s i t e a s y t o t e l l
* if w e c a n f a s t - p a t h o u t o f h e r e f o r a h / w - r e c o v e r e d e r r o r .
* /
mfc0 k 1 ,C 0 _ E R R C T L
bgtz k 1 ,a t t e m p t _ r e c o v e r y
sll k 0 ,k 1 ,1
recovered_dcache :
/ *
* Unlock C a c h e E r r - D ( w h i c h i n t u r n u n l o c k s C a c h e E r r - D P A ) .
2011-03-31 05:57:33 +04:00
* Ought t o l o g t h e o c c u r r e n c e o f t h i s r e c o v e r e d d c a c h e e r r o r .
2005-04-17 02:20:36 +04:00
* /
b r e c o v e r e d
mtc0 $ 0 ,C 0 _ C E R R _ D
attempt_recovery :
/ *
* k0 h a s C 0 _ E R R C T L < < 1 , w h i c h p u t s ' D C ' a t b i t 3 1 . A n y
* Dcache e r r o r s w e c a n r e c o v e r f r o m w i l l t a k e m o r e e x t e n s i v e
* processing. F o r n o w , t h e y a r e c o n s i d e r e d " u n r e c o v e r a b l e " .
* Note t h a t ' D C ' b e c o m i n g s e t ( o u t s i d e o f E R L m o d e ) w i l l
* cause ' I C ' t o c l e a r ; so if there's an Icache error, we'll
* only f i n d o u t a b o u t i t i f w e r e c o v e r f r o m t h i s e r r o r a n d
* continue e x e c u t i n g .
* /
bltz k 0 ,u n r e c o v e r a b l e
sll k 0 ,1
/ *
* k0 h a s C 0 _ E R R C T L < < 2 , w h i c h p u t s ' I C ' a t b i t 3 1 . I f a n
* Icache e r r o r i s n ' t i n d i c a t e d , I ' m n o t s u r e w h y w e g o t h e r e .
* Consider t h a t c a s e " u n r e c o v e r a b l e " f o r n o w .
* /
bgez k 0 ,u n r e c o v e r a b l e
attempt_icache_recovery :
/ *
* External i c a c h e e r r o r s a r e d u e t o u n c o r r e c t a b l e E C C e r r o r s
* in t h e L 2 c a c h e o r M e m o r y C o n t r o l l e r a n d c a n n o t b e
* recovered h e r e .
* /
mfc0 k 0 ,C 0 _ C E R R _ I / * d e l a y s l o t * /
li k 1 ,1 < < 2 6 / * I C A C H E _ E X T E R N A L * /
and k 1 ,k 0
bnez k 1 ,u n r e c o v e r a b l e
andi k 0 ,0 x1 f e 0
/ *
* Since t h e e r r o r i s i n t e r n a l , t h e ' I D X ' f i e l d f r o m
* CacheErr- I i s v a l i d a n d w e c a n j u s t i n v a l i d a t e a l l b l o c k s
* in t h a t s e t .
* /
cache I n d e x _ I n v a l i d a t e _ I ,( 0 < < 1 3 ) ( k 0 )
cache I n d e x _ I n v a l i d a t e _ I ,( 1 < < 1 3 ) ( k 0 )
cache I n d e x _ I n v a l i d a t e _ I ,( 2 < < 1 3 ) ( k 0 )
cache I n d e x _ I n v a l i d a t e _ I ,( 3 < < 1 3 ) ( k 0 )
/* Ought to log this recovered icache error */
recovered :
/* Restore the saved registers */
ld k 0 ,0 x17 0 ( $ 0 )
ld k 1 ,0 x17 8 ( $ 0 )
eret
unrecoverable :
/* Unrecoverable Icache or Dcache error; log it and/or fail */
j h a n d l e _ v e c2 _ s b1
nop
2005-10-20 10:57:40 +04:00
# endif
2005-04-17 02:20:36 +04:00
END( e x c e p t _ v e c2 _ s b1 )
_ _ FINIT
LEAF( h a n d l e _ v e c2 _ s b1 )
mfc0 k 0 ,C P 0 _ C O N F I G
li k 1 ,~ C O N F _ C M _ C M A S K
and k 0 ,k 0 ,k 1
ori k 0 ,k 0 ,C O N F _ C M _ U N C A C H E D
mtc0 k 0 ,C P 0 _ C O N F I G
SSNOP
SSNOP
SSNOP
SSNOP
bnezl $ 0 , 1 f
1 :
mfc0 k 0 , C P 0 _ S T A T U S
sll k 0 , k 0 , 3 # c h e c k C U 0 ( k e r n e l ? )
bltz k 0 , 2 f
nop
/ * Get a v a l i d K s e g 0 s t a c k p o i n t e r . A n y t a s k ' s s t a c k p o i n t e r
* will d o , a l t h o u g h i f w e e v e r w a n t t o r e s u m e e x e c u t i o n w e
* better n o t h a v e c o r r u p t e d a n y s t a t e . * /
get_ s a v e d _ s p
move s p , k 1
2 :
j s b1 _ c a c h e _ e r r o r
nop
END( h a n d l e _ v e c2 _ s b1 )