2005-04-17 02:20:36 +04: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 ) 1 9 9 4 - 2 0 0 0 , 2 0 0 1 , 2 0 0 3 R a l f B a e c h l e
* Copyright ( C ) 1 9 9 9 , 2 0 0 0 S i l i c o n G r a p h i c s , I n c .
* Copyright ( C ) 2 0 0 1 M I P S T e c h n o l o g i e s , I n c .
* Copyright ( C ) 2 0 0 2 M a c i e j W . R o z y c k i
* /
# include < l i n u x / c o n f i g . h >
# include < l i n u x / i n i t . h >
# include < a s m / a s m . 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 / f p 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 / w a r . h >
# define P A N I C _ P I C ( m s g ) \
.set push; \
.set reorder; \
PTR_ L A a0 ,8 f ; \
.set noat; \
PTR_ L A A T , p a n i c ; \
jr A T ; \
9 : b 9 b ; \
.set pop; \
TEXT( m s g )
_ _ INIT
NESTED( e x c e p t _ v e c0 _ g e n e r i c , 0 , s p )
PANIC_ P I C ( " E x c e p t i o n v e c t o r 0 c a l l e d " )
END( e x c e p t _ v e c0 _ g e n e r i c )
NESTED( e x c e p t _ v e c1 _ g e n e r i c , 0 , s p )
PANIC_ P I C ( " E x c e p t i o n v e c t o r 1 c a l l e d " )
END( e x c e p t _ v e c1 _ g e n e r i c )
/ *
* General e x c e p t i o n v e c t o r f o r a l l o t h e r C P U s .
*
* Be c a r e f u l w h e n c h a n g i n g t h i s , i t h a s t o b e a t m o s t 1 2 8 b y t e s
* to f i t i n t o s p a c e r e s e r v e d f o r t h e e x c e p t i o n h a n d l e r .
* /
NESTED( e x c e p t _ v e c3 _ g e n e r i c , 0 , s p )
.set push
.set noat
# if R 5 4 3 2 _ C P 0 _ I N T E R R U P T _ W A R
mfc0 k 0 , C P 0 _ I N D E X
# endif
mfc0 k 1 , C P 0 _ C A U S E
andi k 1 , k 1 , 0 x7 c
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
dsll k 1 , k 1 , 1
# endif
PTR_ L k 0 , e x c e p t i o n _ h a n d l e r s ( k 1 )
jr k 0
.set pop
END( e x c e p t _ v e c3 _ g e n e r i c )
/ *
* General e x c e p t i o n h a n d l e r f o r C P U s w i t h v i r t u a l c o h e r e n c y e x c e p t i o n .
*
* Be c a r e f u l w h e n c h a n g i n g t h i s , i t h a s t o b e a t m o s t 2 5 6 ( a s a s p e c i a l
* exception) b y t e s t o f i t i n t o s p a c e r e s e r v e d f o r t h e e x c e p t i o n h a n d l e r .
* /
NESTED( e x c e p t _ v e c3 _ r40 0 0 , 0 , s p )
.set push
.set mips3
.set noat
mfc0 k 1 , C P 0 _ C A U S E
li k 0 , 3 1 < < 2
andi k 1 , k 1 , 0 x7 c
.set push
.set noreorder
.set nomacro
beq k 1 , k 0 , h a n d l e _ v c e d
li k 0 , 1 4 < < 2
beq k 1 , k 0 , h a n d l e _ v c e i
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 6 4 B I T
2004-12-08 13:32:45 +03:00
dsll k 1 , k 1 , 1
2005-04-17 02:20:36 +04:00
# endif
.set pop
PTR_ L k 0 , e x c e p t i o n _ h a n d l e r s ( k 1 )
jr k 0
/ *
* Big s h i t , w e n o w m a y h a v e t w o d i r t y p r i m a r y c a c h e l i n e s f o r t h e s a m e
2004-12-08 13:32:45 +03:00
* physical a d d r e s s . W e c a n s a f e l y i n v a l i d a t e t h e l i n e p o i n t e d t o b y
2005-04-17 02:20:36 +04:00
* c0 _ b a d v a d d r b e c a u s e a f t e r r e t u r n f r o m t h i s e x c e p t i o n h a n d l e r t h e
* load / s t o r e w i l l b e r e - e x e c u t e d .
* /
handle_vced :
2004-12-08 13:32:45 +03:00
MFC0 k 0 , C P 0 _ B A D V A D D R
2005-04-17 02:20:36 +04:00
li k 1 , - 4 # I s t h i s . . .
and k 0 , k 1 # . . . r e a l l y n e e d e d ?
mtc0 z e r o , C P 0 _ T A G L O
2004-12-08 13:32:45 +03:00
cache I n d e x _ S t o r e _ T a g _ D , ( k 0 )
cache H i t _ W r i t e b a c k _ I n v _ S D , ( k 0 )
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ P R O C _ F S
PTR_ L A k 0 , v c e d _ c o u n t
lw k 1 , ( k 0 )
addiu k 1 , 1
sw k 1 , ( k 0 )
# endif
eret
handle_vcei :
MFC0 k 0 , C P 0 _ B A D V A D D R
cache H i t _ W r i t e b a c k _ I n v _ S D , ( k 0 ) # a l s o c l e a n s p i
# ifdef C O N F I G _ P R O C _ F S
PTR_ L A k 0 , v c e i _ c o u n t
lw k 1 , ( k 0 )
addiu k 1 , 1
sw k 1 , ( k 0 )
# endif
eret
.set pop
END( e x c e p t _ v e c3 _ r40 0 0 )
/ *
* Special i n t e r r u p t v e c t o r f o r M I P S 6 4 I S A & e m b e d d e d M I P S p r o c e s s o r s .
* This i s a d e d i c a t e d i n t e r r u p t e x c e p t i o n v e c t o r w h i c h r e d u c e s t h e
* interrupt p r o c e s s i n g o v e r h e a d . T h e j u m p i n s t r u c t i o n w i l l b e r e p l a c e d
* at t h e i n i t i a l i z a t i o n t i m e .
*
* Be c a r e f u l w h e n c h a n g i n g t h i s , i t h a s t o b e a t m o s t 1 2 8 b y t e s
* to f i t i n t o s p a c e r e s e r v e d f o r t h e e x c e p t i o n h a n d l e r .
* /
NESTED( e x c e p t _ v e c4 , 0 , s p )
1 : j 1 b / * D u m m y , w i l l b e r e p l a c e d * /
END( e x c e p t _ v e c4 )
/ *
* EJTAG d e b u g e x c e p t i o n h a n d l e r .
* The E J T A G d e b u g e x c e p t i o n e n t r y p o i n t i s 0 x b f c00 4 8 0 , w h i c h
* normally i s i n t h e b o o t P R O M , s o t h e b o o t P R O M m u s t d o a
* unconditional j u m p t o t h i s v e c t o r .
* /
NESTED( e x c e p t _ v e c _ e j t a g _ d e b u g , 0 , s p )
j e j t a g _ d e b u g _ h a n d l e r
END( e x c e p t _ v e c _ e j t a g _ d e b u g )
_ _ FINIT
2005-07-14 19:57:16 +04:00
/ *
* Vectored i n t e r r u p t h a n d l e r .
* This p r o t o t y p e i s c o p i e d t o e b a s e + n * I n t C t l . V S a n d p a t c h e d
* to i n v o k e t h e h a n d l e r
* /
NESTED( e x c e p t _ v e c _ v i , 0 , s p )
SAVE_ S O M E
SAVE_ A T
.set push
.set noreorder
EXPORT( e x c e p t _ v e c _ v i _ l u i )
lui v0 , 0 / * P a t c h e d * /
j e x c e p t _ v e c _ v i _ h a n d l e r
EXPORT( e x c e p t _ v e c _ v i _ o r i )
ori v0 , 0 / * P a t c h e d * /
.set pop
END( e x c e p t _ v e c _ v i )
EXPORT( e x c e p t _ v e c _ v i _ e n d )
/ *
* Common V e c t o r e d I n t e r r u p t c o d e
* Complete t h e r e g i s t e r s a v e s a n d i n v o k e t h e h a n d l e r w h i c h i s p a s s e d i n $ v0
* /
NESTED( e x c e p t _ v e c _ v i _ h a n d l e r , 0 , s p )
SAVE_ T E M P
SAVE_ S T A T I C
CLI
move a0 , s p
jalr v0
j r e t _ f r o m _ i r q
END( e x c e p t _ v e c _ v i _ h a n d l e r )
2005-04-17 02:20:36 +04:00
/ *
* EJTAG d e b u g e x c e p t i o n h a n d l e r .
* /
NESTED( e j t a g _ d e b u g _ h a n d l e r , P T _ S I Z E , s p )
.set push
.set noat
MTC0 k 0 , C P 0 _ D E S A V E
mfc0 k 0 , C P 0 _ D E B U G
sll k 0 , k 0 , 3 0 # C h e c k f o r S D B B P .
bgez k 0 , e j t a g _ r e t u r n
PTR_ L A k 0 , e j t a g _ d e b u g _ b u f f e r
LONG_ S k 1 , 0 ( k 0 )
SAVE_ A L L
move a0 , s p
jal e j t a g _ e x c e p t i o n _ h a n d l e r
RESTORE_ A L L
PTR_ L A k 0 , e j t a g _ d e b u g _ b u f f e r
LONG_ L k 1 , 0 ( k 0 )
ejtag_return :
MFC0 k 0 , C P 0 _ D E S A V E
.set mips32
deret
.set pop
END( e j t a g _ d e b u g _ h a n d l e r )
/ *
* This b u f f e r i s r e s e r v e d f o r t h e u s e o f t h e E J T A G d e b u g
* handler.
* /
.data
EXPORT( e j t a g _ d e b u g _ b u f f e r )
.fill LONGSIZE
.previous
_ _ INIT
/ *
* NMI d e b u g e x c e p t i o n h a n d l e r f o r M I P S r e f e r e n c e b o a r d s .
* The N M I d e b u g e x c e p t i o n e n t r y p o i n t i s 0 x b f c00 0 0 0 , w h i c h
* normally i s i n t h e b o o t P R O M , s o t h e b o o t P R O M m u s t d o a
* unconditional j u m p t o t h i s v e c t o r .
* /
NESTED( e x c e p t _ v e c _ n m i , 0 , s p )
j n m i _ h a n d l e r
END( e x c e p t _ v e c _ n m i )
_ _ FINIT
NESTED( n m i _ h a n d l e r , P T _ S I Z E , s p )
.set push
.set noat
.set mips3
SAVE_ A L L
move a0 , s p
jal n m i _ e x c e p t i o n _ h a n d l e r
RESTORE_ A L L
eret
.set pop
END( n m i _ h a n d l e r )
.macro __build_clear_none
.endm
.macro __build_clear_sti
STI
.endm
.macro __build_clear_cli
CLI
.endm
.macro __build_clear_fpe
cfc1 a1 , f c r31
li a2 , ~ ( 0 x3 f < < 1 2 )
and a2 , a1
ctc1 a2 , f c r31
STI
.endm
.macro __build_clear_ade
MFC0 t 0 , C P 0 _ B A D V A D D R
PTR_ S t 0 , P T _ B V A D D R ( s p )
KMODE
.endm
.macro __BUILD_silent exception
.endm
/ * Gas t r i e s t o p a r s e t h e P R I N T a r g u m e n t a s a s t r i n g c o n t a i n i n g
string e s c a p e s a n d e m i t s b o g u s w a r n i n g s i f i t b e l i e v e s t o
recognize a n u n k n o w n e s c a p e c o d e . S o m a k e t h e a r g u m e n t s
start w i t h a n n a n d g a s w i l l b e l i e v e \ n i s o k . . . * /
.macro __BUILD_verbose nexception
LONG_ L a1 , P T _ E P C ( s p )
2005-09-04 02:56:22 +04:00
# ifdef C O N F I G _ 3 2 B I T
2005-04-17 02:20:36 +04:00
PRINT( " G o t \ n e x c e p t i o n a t % 0 8 l x \ 0 1 2 " )
2005-09-04 02:56:17 +04:00
# endif
2005-09-04 02:56:22 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
PRINT( " G o t \ n e x c e p t i o n a t % 0 1 6 l x \ 0 1 2 " )
2005-09-04 02:56:17 +04:00
# endif
2005-04-17 02:20:36 +04:00
.endm
.macro __BUILD_count exception
LONG_ L t 0 ,e x c e p t i o n _ c o u n t _ \ e x c e p t i o n
LONG_ A D D I U t 0 , 1
LONG_ S t 0 ,e x c e p t i o n _ c o u n t _ \ e x c e p t i o n
.comm exception_ c o u n t \ e x c e p t i o n , 8 , 8
.endm
.macro __BUILD_HANDLER exception h a n d l e r c l e a r v e r b o s e e x t
.align 5
NESTED( h a n d l e _ \ e x c e p t i o n , P T _ S I Z E , s p )
.set noat
SAVE_ A L L
FEXPORT( h a n d l e _ \ e x c e p t i o n \ e x t )
_ _ BUILD_ c l e a r _ \ c l e a r
.set at
_ _ BUILD_ \ v e r b o s e \ e x c e p t i o n
move a0 , s p
jal d o _ \ h a n d l e r
j r e t _ f r o m _ e x c e p t i o n
END( h a n d l e _ \ e x c e p t i o n )
.endm
.macro BUILD_HANDLER exception h a n d l e r c l e a r v e r b o s e
_ _ BUILD_ H A N D L E R \ e x c e p t i o n \ h a n d l e r \ c l e a r \ v e r b o s e _ i n t
.endm
BUILD_ H A N D L E R a d e l a d e a d e s i l e n t / * #4 * /
BUILD_ H A N D L E R a d e s a d e a d e s i l e n t / * #5 * /
BUILD_ H A N D L E R i b e b e c l i s i l e n t / * #6 * /
BUILD_ H A N D L E R d b e b e c l i s i l e n t / * #7 * /
BUILD_ H A N D L E R b p b p s t i s i l e n t / * #9 * /
BUILD_ H A N D L E R r i r i s t i s i l e n t / * #10 * /
BUILD_ H A N D L E R c p u c p u s t i s i l e n t / * #11 * /
BUILD_ H A N D L E R o v o v s t i s i l e n t / * #12 * /
BUILD_ H A N D L E R t r t r s t i s i l e n t / * #13 * /
BUILD_ H A N D L E R f p e f p e f p e s i l e n t / * #15 * /
BUILD_ H A N D L E R m d m x m d m x s t i s i l e n t / * #22 * /
BUILD_ H A N D L E R w a t c h w a t c h s t i v e r b o s e / * #23 * /
BUILD_ H A N D L E R m c h e c k m c h e c k c l i v e r b o s e / * #24 * /
2005-08-17 21:44:08 +04:00
BUILD_ H A N D L E R m t m t s t i v e r b o s e / * #25 * /
2005-05-31 15:49:19 +04:00
BUILD_ H A N D L E R d s p d s p s t i s i l e n t / * #26 * /
2005-04-17 02:20:36 +04:00
BUILD_ H A N D L E R r e s e r v e d r e s e r v e d s t i v e r b o s e / * o t h e r s * /
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/* A temporary overflow handler used by check_daddi(). */
_ _ INIT
BUILD_ H A N D L E R d a d d i _ o v d a d d i _ o v n o n e s i l e n t / * #12 * /
# endif