2005-04-17 02:20:36 +04:00
/ *
* Copyright ( C ) 1 9 9 5 , 1 9 9 6 , 1 9 9 7 P a u l M . A n t o i n e a n d H a r a l d K o e r f g e n
2005-07-01 20:10:40 +04:00
* Copyright ( C ) 2 0 0 0 , 2 0 0 1 , 2 0 0 2 , 2 0 0 3 , 2 0 0 5 M a c i e j W . R o z y c k i
2005-04-17 02:20:36 +04:00
*
2005-07-01 20:10:40 +04:00
* Written b y R a l f B a e c h l e a n d A n d r e a s B u s s e , m o d i f i e d f o r D E C s t a t i o n
2005-04-17 02:20:36 +04:00
* support b y P a u l A n t o i n e a n d H a r a l d K o e r f g e n .
*
* completly r e w r i t t e n :
* Copyright ( C ) 1 9 9 8 H a r a l d K o e r f g e n
*
* Rewritten e x t e n s i v e l y f o r c o n t r o l l e r - d r i v e n I R Q s u p p o r t
* by M a c i e j W . R o z y c k i .
* /
2005-07-01 20:10:40 +04:00
# include < a s m / a d d r s p a c e . h >
2005-04-17 02:20:36 +04:00
# include < a s m / a s m . h >
# include < a s m / m i p s r e g s . h >
2005-07-01 20:10:40 +04:00
# include < a s m / r e g d e f . h >
2005-04-17 02:20:36 +04:00
# include < a s m / s t a c k f r a m e . h >
# include < a s m / d e c / i n t e r r u p t s . h >
# include < a s m / d e c / i o a s i c _ a d d r s . h >
# include < a s m / d e c / i o a s i c _ i n t s . h >
# include < a s m / d e c / k n 0 1 . h >
# include < a s m / d e c / k n 0 2 . h >
# include < a s m / d e c / k n 0 2 x a . h >
# include < a s m / d e c / k n 0 3 . h >
2005-07-01 20:10:40 +04:00
# define K N 0 2 _ C S R _ B A S E C K S E G 1 A D D R ( K N 0 2 _ S L O T _ B A S E + K N 0 2 _ C S R )
# define K N 0 2 X A _ I O A S I C _ B A S E C K S E G 1 A D D R ( K N 0 2 X A _ S L O T _ B A S E + I O A S I C _ I O C T L )
# define K N 0 3 _ I O A S I C _ B A S E C K S E G 1 A D D R ( K N 0 3 _ S L O T _ B A S E + I O A S I C _ I O C T L )
2005-04-17 02:20:36 +04:00
.text
.set noreorder
/ *
2006-04-03 20:56:36 +04:00
* plat_irq_dispatch : Interrupt h a n d l e r f o r D E C s t a t i o n s
2005-04-17 02:20:36 +04:00
*
* We f o l l o w t h e m o d e l i n t h e I n d y i n t e r r u p t c o d e b y D a v i d M i l l e r , w h e r e h e
* says : a l o t o f c o m p l i c a t i o n h e r e i s t a k e n a w a y b e c a u s e :
*
* 1 ) We h a n d l e o n e i n t e r r u p t a n d r e t u r n , s i t t i n g i n a l o o p
* and m o v i n g a c r o s s a l l t h e p e n d i n g I R Q b i t s i n t h e c a u s e
* register i s _ N O T _ t h e a n s w e r , t h e c o m m o n c a s e i s o n e
* pending I R Q s o o p t i m i z e i n t h a t d i r e c t i o n .
*
* 2 ) We n e e d n o t c h e c k a g a i n s t b i t s i n t h e s t a t u s r e g i s t e r
* IRQ m a s k , t h a t w o u l d m a k e t h i s r o u t i n e s l o w a s h e l l .
*
* 3 ) Linux o n l y t h i n k s i n t e r m s o f a l l I R Q s o n o r a l l I R Q s
* off, n o t h i n g i n b e t w e e n l i k e B S D s p l ( ) b r a i n - d a m a g e .
*
2005-07-01 20:10:40 +04:00
* Furthermore, t h e I R Q s o n t h e D E C s t a t i o n s l o o k b a s i c a l l y ( b a r r i n g
2005-04-17 02:20:36 +04:00
* software I R Q s w h i c h w e d o n ' t u s e a t a l l ) l i k e . . .
*
* DS2 1 0 0 / 3 1 0 0 ' s , a k a k n 0 1 , a k a P m a x :
*
* MIPS I R Q S o u r c e
2013-01-22 15:59:30 +04:00
* - - - - - - - - - - - - - -
* 0 Software ( i g n o r e d )
* 1 Software ( i g n o r e d )
* 2 SCSI
* 3 Lance E t h e r n e t
* 4 DZ1 1 s e r i a l
* 5 RTC
* 6 Memory C o n t r o l l e r & V i d e o
* 7 FPU
2005-04-17 02:20:36 +04:00
*
* DS5 0 0 0 / 2 0 0 , a k a k n 0 2 , a k a 3 m a x :
*
* MIPS I R Q S o u r c e
2013-01-22 15:59:30 +04:00
* - - - - - - - - - - - - - -
* 0 Software ( i g n o r e d )
* 1 Software ( i g n o r e d )
* 2 TurboChannel
* 3 RTC
* 4 Reserved
* 5 Memory C o n t r o l l e r
* 6 Reserved
* 7 FPU
2005-04-17 02:20:36 +04:00
*
* DS5 0 0 0 / 1 x x ' s , a k a k n 0 2 b a , a k a 3 m i n :
*
* MIPS I R Q S o u r c e
2013-01-22 15:59:30 +04:00
* - - - - - - - - - - - - - -
* 0 Software ( i g n o r e d )
* 1 Software ( i g n o r e d )
* 2 TurboChannel S l o t 0
* 3 TurboChannel S l o t 1
* 4 TurboChannel S l o t 2
* 5 TurboChannel S l o t 3 ( A S I C )
* 6 Halt b u t t o n
* 7 FPU/ R 4 k t i m e r
2005-04-17 02:20:36 +04:00
*
* DS5 0 0 0 / 2 x ' s , a k a k n 0 2 c a , a k a m a x i n e :
*
* MIPS I R Q S o u r c e
2013-01-22 15:59:30 +04:00
* - - - - - - - - - - - - - -
* 0 Software ( i g n o r e d )
* 1 Software ( i g n o r e d )
* 2 Periodic I n t e r r u p t ( 1 0 0 u s e c )
* 3 RTC
* 4 I/ O w r i t e t i m e o u t
* 5 TurboChannel ( A S I C )
* 6 Halt K e y c o d e f r o m A c c e s s . B u s k e y b o a r d ( C T R L - A L T - E N T E R )
* 7 FPU/ R 4 k t i m e r
2005-04-17 02:20:36 +04:00
*
* DS5 0 0 0 / 2 x x ' s , a k a k n 0 3 , a k a 3 m a x p l u s :
*
* MIPS I R Q S o u r c e
2013-01-22 15:59:30 +04:00
* - - - - - - - - - - - - - -
* 0 Software ( i g n o r e d )
* 1 Software ( i g n o r e d )
* 2 System B o a r d ( A S I C )
* 3 RTC
* 4 Reserved
* 5 Memory
* 6 Halt B u t t o n
* 7 FPU/ R 4 k t i m e r
2005-04-17 02:20:36 +04:00
*
* We h a n d l e t h e I R Q a c c o r d i n g t o _ o u r _ p r i o r i t y ( s e e s e t u p . c ) ,
2013-01-22 15:59:30 +04:00
* then w e j u s t r e t u r n . I f m u l t i p l e I R Q s a r e p e n d i n g t h e n w e w i l l
2005-04-17 02:20:36 +04:00
* just t a k e a n o t h e r e x c e p t i o n , b i g d e a l .
* /
.align 5
2006-04-03 20:56:36 +04:00
NESTED( p l a t _ i r q _ d i s p a t c h , P T _ S I Z E , r a )
2005-04-17 02:20:36 +04:00
.set noreorder
/ *
* Get p e n d i n g I n t e r r u p t s
* /
mfc0 t 0 ,C P 0 _ C A U S E # g e t p e n d i n g i n t e r r u p t s
mfc0 t 1 ,C P 0 _ S T A T U S
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 3 2 B I T
2005-04-17 02:20:36 +04:00
lw t 2 ,c p u _ f p u _ m a s k
# endif
andi t 0 ,S T 0 _ I M # C A U S E . C E m a y b e n o n - z e r o !
and t 0 ,t 1 # i s o l a t e a l l o w e d o n e s
beqz t 0 ,s p u r i o u s
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 3 2 B I T
2005-04-17 02:20:36 +04:00
and t 2 ,t 0
bnez t 2 ,f p u # h a n d l e F P U i m m e d i a t e l y
# endif
/ *
* Find i r q w i t h h i g h e s t p r i o r i t y
* /
2013-01-22 15:59:30 +04:00
PTR_ L A t 1 ,c p u _ m a s k _ n r _ t b l
2005-04-17 02:20:36 +04:00
1 : lw t 2 ,( t 1 )
nop
and t 2 ,t 0
beqz t 2 ,1 b
addu t 1 ,2 * P T R S I Z E # d e l a y s l o t
/ *
* Do t h e l o w - l e v e l s t u f f
* /
lw a0 ,( - P T R S I Z E ) ( t 1 )
nop
bgez a0 ,h a n d l e _ i t # i r q _ n r > = 0 ?
# irq_ n r < 0 : i t i s a n a d d r e s s
nop
jr a0
# a t r i c k t o s a v e a b r a n c h :
lui t 2 ,( K N 0 3 _ I O A S I C _ B A S E > > 1 6 ) & 0 x f f f f
# upper p a r t o f I O A S I C A d d r e s s
/ *
* Handle " I R Q C o n t r o l l e r " I n t e r r u p t s
* Masked I n t e r r u p t s a r e s t i l l v i s i b l e a n d h a v e t o b e m a s k e d " b y h a n d " .
* /
FEXPORT( k n 0 2 _ i o _ i n t ) # 3 m a x
lui t 0 ,( K N 0 2 _ C S R _ B A S E > > 1 6 ) & 0 x f f f f
# get i n t e r r u p t s t a t u s a n d m a s k
lw t 0 ,( t 0 )
nop
andi t 1 ,t 0 ,K N 0 2 _ I R Q _ A L L
b 1 f
srl t 0 ,1 6 # s h i f t i n t e r r u p t m a s k
FEXPORT( k n 0 2 x a _ i o _ i n t ) # 3 m i n / m a x i n e
lui t 2 ,( K N 0 2 X A _ I O A S I C _ B A S E > > 1 6 ) & 0 x f f f f
# upper p a r t o f I O A S I C A d d r e s s
FEXPORT( k n 0 3 _ i o _ i n t ) # 3 m a x + ( t 2 l o a d e d e a r l i e r )
lw t 0 ,I O _ R E G _ S I R ( t 2 ) # g e t s t a t u s : I O A S I C s i r
lw t 1 ,I O _ R E G _ S I M R ( t 2 ) # g e t m a s k : I O A S I C s i m r
nop
1 : and t 0 ,t 1 # m a s k o u t a l l o w e d o n e s
beqz t 0 ,s p u r i o u s
/ *
* Find i r q w i t h h i g h e s t p r i o r i t y
* /
2013-01-22 15:59:30 +04:00
PTR_ L A t 1 ,a s i c _ m a s k _ n r _ t b l
2005-04-17 02:20:36 +04:00
2 : lw t 2 ,( t 1 )
nop
and t 2 ,t 0
beq z e r o ,t 2 ,2 b
addu t 1 ,2 * P T R S I Z E # d e l a y s l o t
/ *
* Do t h e l o w - l e v e l s t u f f
* /
lw a0 ,% l o ( - P T R S I Z E ) ( t 1 )
nop
bgez a0 ,h a n d l e _ i t # i r q _ n r > = 0 ?
# irq_ n r < 0 : i t i s a n a d d r e s s
nop
jr a0
nop # d e l a y s l o t
/ *
* Dispatch l o w - p r i o r i t y i n t e r r u p t s . W e r e c o n s i d e r a l l s t a t u s
* bits a g a i n , w h i c h l o o k s l i k e a l o s e , b u t i t m a k e s t h e c o d e
* simple a n d O ( l o g n ) , s o i t g e t s c o m p e n s a t e d .
* /
FEXPORT( c p u _ a l l _ i n t ) # H A L T , t i m e r s , s o f t w a r e j u n k
li a0 ,D E C _ C P U _ I R Q _ B A S E
srl t 0 ,C A U S E B _ I P
2013-01-22 15:59:30 +04:00
li t 1 ,C A U S E F _ I P > > C A U S E B _ I P # m a s k
2005-04-17 02:20:36 +04:00
b 1 f
li t 2 ,4 # n r o f b i t s / 2
FEXPORT( k n 0 2 _ a l l _ i n t ) # i m p o s s i b l e ?
li a0 ,K N 0 2 _ I R Q _ B A S E
li t 1 ,K N 0 2 _ I R Q _ A L L # m a s k
b 1 f
li t 2 ,4 # n r o f b i t s / 2
FEXPORT( a s i c _ a l l _ i n t ) # v a r i o u s I / O A S I C j u n k
li a0 ,I O _ I R Q _ B A S E
li t 1 ,I O _ I R Q _ A L L # m a s k
b 1 f
li t 2 ,8 # n r o f b i t s / 2
/ *
* Dispatch D M A i n t e r r u p t s - - O ( l o g n ) .
* /
FEXPORT( a s i c _ d m a _ i n t ) # I / O A S I C D M A e v e n t s
li a0 ,I O _ I R Q _ B A S E + I O _ I N R _ D M A
srl t 0 ,I O _ I N R _ D M A
li t 1 ,I O _ I R Q _ D M A > > I O _ I N R _ D M A # m a s k
li t 2 ,8 # n r o f b i t s / 2
/ *
* Find i r q w i t h h i g h e s t p r i o r i t y .
* Highest i r q n u m b e r t a k e s p r e c e d e n c e .
* /
1 : srlv t 3 ,t 1 ,t 2
2 : xor t 1 ,t 3
and t 3 ,t 0 ,t 1
beqz t 3 ,3 f
nop
move t 0 ,t 3
addu a0 ,t 2
3 : srl t 2 ,1
bnez t 2 ,2 b
srlv t 3 ,t 1 ,t 2
handle_it :
2006-10-25 18:57:04 +04:00
j d e c _ i r q _ d i s p a t c h
2005-04-17 02:20:36 +04:00
nop
2005-09-04 02:56:16 +04:00
# ifdef C O N F I G _ 3 2 B I T
2005-04-17 02:20:36 +04:00
fpu :
j h a n d l e _ f p e _ i n t
nop
# endif
spurious :
2006-10-08 20:24:23 +04:00
j s p u r i o u s _ i n t e r r u p t
2005-04-17 02:20:36 +04:00
nop
2006-04-03 20:56:36 +04:00
END( p l a t _ i r q _ d i s p a t c h )
2005-04-17 02:20:36 +04:00
/ *
* Generic u n i m p l e m e n t e d i n t e r r u p t r o u t i n e s - - c p u _ m a s k _ n r _ t b l
* and a s i c _ m a s k _ n r _ t b l a r e i n i t i a l i z e d t o p o i n t a l l i n t e r r u p t s h e r e .
* The t a b l e s a r e t h e n f i l l e d i n b y m a c h i n e - s p e c i f i c i n i t i a l i s a t i o n
* in d e c _ s e t u p ( ) .
* /
FEXPORT( d e c _ i n t r _ u n i m p l e m e n t e d )
move a1 ,t 0 # c h e a t s w a y o f p r i n t i n g a n a r g !
PANIC( " U n i m p l e m e n t e d c p u i n t e r r u p t ! C P 0 _ C A U S E : 0 x % 0 8 x " ) ;
FEXPORT( a s i c _ i n t r _ u n i m p l e m e n t e d )
move a1 ,t 0 # c h e a t s w a y o f p r i n t i n g a n a r g !
PANIC( " U n i m p l e m e n t e d a s i c i n t e r r u p t ! A S I C I S R : 0 x % 0 8 x " ) ;