2005-04-16 15:20:36 -07: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 , 1 9 9 5 W a l d o r f E l e c t r o n i c s
* 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
2006-07-07 14:07:18 +01:00
* Copyright ( C ) 1 9 9 4 - 9 9 , 2 0 0 3 , 0 6 R a l f B a e c h l e
2005-04-16 15:20:36 -07:00
* Copyright ( C ) 1 9 9 6 P a u l M . A n t o i n e
* Modified f o r D E C S t a t i o n a n d h e n c e R 3 0 0 0 s u p p o r t b y P a u l M . A n t o i n e
* Further m o d i f i c a t i o n s b y D a v i d S . M i l l e r a n d H a r a l d K o e r f g e n
* Copyright ( C ) 1 9 9 9 S i l i c o n G r a p h i c s , I n c .
* Kevin K i s s e l l , k e v i n k @mips.com and Carsten Langgaard, carstenl@mips.com
* Copyright ( C ) 2 0 0 0 M I P S T e c h n o l o g i e s , I n c . A l l r i g h t s r e s e r v e d .
* /
# include < l i n u x / i n i t . h >
# include < l i n u x / t h r e a d s . h >
2007-06-14 15:55:31 -06:00
# include < a s m / a d d r s p a c e . h >
2005-04-16 15:20:36 -07:00
# include < a s m / a s m . h >
2006-04-05 09:45:45 +01:00
# include < a s m / a s m m a c r o . h >
2006-07-07 14:07:18 +01:00
# include < a s m / i r q f l a g s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / r e g d e f . h >
2008-10-03 22:43:38 +01:00
# include < a s m / p g t a b l e - b i t s . h >
2005-04-16 15:20:36 -07:00
# 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 >
2005-07-14 09:42:32 +00:00
# include < k e r n e l - e n t r y - i n i t . h >
2005-04-16 15:20:36 -07:00
/ *
* For t h e m o m e n t d i s a b l e i n t e r r u p t s , m a r k t h e k e r n e l m o d e a n d
* set S T 0 _ K X s o t h a t t h e C P U d o e s n o t s p i t f i r e w h e n u s i n g
* 6 4 - bit a d d r e s s e s . A f u l l i n i t i a l i z a t i o n o f t h e C P U ' s s t a t u s
* register i s d o n e l a t e r i n p e r _ c p u _ t r a p _ i n i t ( ) .
* /
.macro setup_c0_status set c l r
.set push
2006-04-05 09:45:45 +01:00
# ifdef C O N F I G _ M I P S _ M T _ S M T C
/ *
* For S M T C , w e n e e d t o s e t p r i v i l e g e a n d d i s a b l e i n t e r r u p t s o n l y f o r
* the c u r r e n t T C , u s i n g t h e T C S t a t u s r e g i s t e r .
* /
mfc0 t 0 , C P 0 _ T C S T A T U S
/* Fortunately CU 0 is in the same place in both registers */
/* Set TCU0, TMX, TKSU (for later inversion) and IXMT */
li t 1 , S T 0 _ C U 0 | 0 x08 0 0 1 c00
or t 0 , t 1
/* Clear TKSU, leave IXMT */
xori t 0 , 0 x00 0 0 1 8 0 0
mtc0 t 0 , C P 0 _ T C S T A T U S
2006-06-03 22:40:15 +01:00
_ ehb
2006-04-05 09:45:45 +01:00
/* We need to leave the global IE bit set, but clear EXL...*/
mfc0 t 0 , C P 0 _ S T A T U S
or t 0 , S T 0 _ C U 0 | S T 0 _ E X L | S T 0 _ E R L | \ s e t | \ c l r
xor t 0 , S T 0 _ E X L | S T 0 _ E R L | \ c l r
mtc0 t 0 , C P 0 _ S T A T U S
# else
2005-04-16 15:20:36 -07:00
mfc0 t 0 , C P 0 _ S T A T U S
or t 0 , S T 0 _ C U 0 | \ s e t | 0 x1 f | \ c l r
xor t 0 , 0 x1 f | \ c l r
mtc0 t 0 , C P 0 _ S T A T U S
.set noreorder
sll z e r o ,3 # e h b
2006-04-05 09:45:45 +01:00
# endif
2005-04-16 15:20:36 -07:00
.set pop
.endm
.macro setup_c0_status_pri
2005-09-03 15:56:16 -07:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-16 15:20:36 -07:00
setup_ c0 _ s t a t u s S T 0 _ K X 0
# else
setup_ c0 _ s t a t u s 0 0
# endif
.endm
.macro setup_c0_status_sec
2005-09-03 15:56:16 -07:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-16 15:20:36 -07:00
setup_ c0 _ s t a t u s S T 0 _ K X S T 0 _ B E V
# else
setup_ c0 _ s t a t u s 0 S T 0 _ B E V
# endif
.endm
2007-06-14 15:55:31 -06:00
# ifndef C O N F I G _ N O _ E X C E P T _ F I L L
2005-04-16 15:20:36 -07:00
/ *
* Reserved s p a c e f o r e x c e p t i o n h a n d l e r s .
* Necessary f o r m a c h i n e s w h i c h l i n k t h e i r k e r n e l s a t K S E G 0 .
* /
.fill 0x400
2007-06-14 15:55:31 -06:00
# endif
2005-04-16 15:20:36 -07:00
EXPORT( _ s t e x t )
2007-10-16 20:05:18 +01:00
# ifdef C O N F I G _ B O O T _ R A W
2005-07-11 11:53:44 +00:00
/ *
* Give u s a f i g h t i n g c h a n c e o f r u n n i n g i f e x e c u t i o n b e i n g s a t t h e
2013-01-22 12:59:30 +01:00
* kernel l o a d a d d r e s s . T h i s i s n e e d e d b e c a u s e t h i s p l a t f o r m d o e s
2005-07-11 11:53:44 +00:00
* not h a v e a E L F l o a d e r y e t .
* /
2008-01-07 15:09:50 +00:00
FEXPORT( _ _ k e r n e l _ e n t r y )
j k e r n e l _ e n t r y
2007-07-10 17:32:56 +01:00
# endif
2005-04-16 15:20:36 -07:00
2008-01-30 12:14:59 +00:00
_ _ REF
2007-10-16 20:05:18 +01:00
2005-04-16 15:20:36 -07:00
NESTED( k e r n e l _ e n t r y , 1 6 , s p ) # k e r n e l e n t r y p o i n t
2005-07-14 09:42:32 +00:00
kernel_ e n t r y _ s e t u p # c p u s p e c i f i c s e t u p
setup_ c0 _ s t a t u s _ p r i
2005-04-16 15:20:36 -07:00
2007-09-13 20:23:48 +02:00
/ * We m i g h t n o t g e t l a u n c h e d a t t h e a d d r e s s t h e k e r n e l i s l i n k e d t o ,
so w e j u m p t h e r e . * /
PTR_ L A t 0 , 0 f
jr t 0
0 :
2005-04-16 15:20:36 -07:00
2006-04-05 09:45:45 +01:00
# ifdef C O N F I G _ M I P S _ M T _ S M T C
/ *
* In S M T C k e r n e l , " C L I " i s t h r e a d - s p e c i f i c , i n T C S t a t u s .
* We s t i l l n e e d t o e n a b l e i n t e r r u p t s g l o b a l l y i n S t a t u s ,
* and c l e a r E X L / E R L .
*
* TCContext i s u s e d t o t r a c k i n t e r r u p t l e v e l s u n d e r
* service i n S M T C k e r n e l . C l e a r f o r b o o t T C b e f o r e
* allowing a n y i n t e r r u p t s .
* /
mtc0 z e r o , C P 0 _ T C C O N T E X T
mfc0 t 0 , C P 0 _ S T A T U S
ori t 0 , t 0 , 0 x f f1 f
xori t 0 , t 0 , 0 x00 1 e
mtc0 t 0 , C P 0 _ S T A T U S
# endif / * C O N F I G _ M I P S _ M T _ S M T C * /
2005-04-16 15:20:36 -07:00
PTR_ L A t 0 , _ _ b s s _ s t a r t # c l e a r . b s s
LONG_ S z e r o , ( t 0 )
PTR_ L A t 1 , _ _ b s s _ s t o p - L O N G S I Z E
1 :
PTR_ A D D I U t 0 , L O N G S I Z E
LONG_ S z e r o , ( t 0 )
bne t 0 , t 1 , 1 b
LONG_ S a0 , f w _ a r g 0 # f i r m w a r e a r g u m e n t s
LONG_ S a1 , f w _ a r g 1
LONG_ S a2 , f w _ a r g 2
LONG_ S a3 , f w _ a r g 3
2005-04-01 14:07:13 +00:00
MTC0 z e r o , C P 0 _ C O N T E X T # c l e a r c o n t e x t r e g i s t e r
2005-04-16 15:20:36 -07:00
PTR_ L A $ 2 8 , i n i t _ t h r e a d _ u n i o n
2009-07-08 10:07:50 -07:00
/* Set the SP after an empty pt_regs. */
PTR_ L I s p , _ T H R E A D _ S I Z E - 3 2 - P T _ S I Z E
2006-10-24 02:29:01 +01:00
PTR_ A D D U s p , $ 2 8
2009-10-13 23:23:28 +02:00
back_ t o _ b a c k _ c0 _ h a z a r d
2005-04-16 15:20:36 -07:00
set_ s a v e d _ s p s p , t 0 , t 1
PTR_ S U B U s p , 4 * S Z R E G # i n i t s t a c k p o i n t e r
j s t a r t _ k e r n e l
END( k e r n e l _ e n t r y )
# ifdef C O N F I G _ S M P
/ *
2013-01-22 12:59:30 +01:00
* SMP s l a v e c p u s e n t r y p o i n t . B o a r d s p e c i f i c c o d e f o r b o o t s t r a p c a l l s t h i s
2005-04-16 15:20:36 -07:00
* function a f t e r s e t t i n g u p t h e s t a c k a n d g p r e g i s t e r s .
* /
NESTED( s m p _ b o o t s t r a p , 1 6 , s p )
2006-04-05 09:45:45 +01:00
# ifdef C O N F I G _ M I P S _ M T _ S M T C
/ *
* Read- m o d i f y - w r i t e s o f S t a t u s m u s t b e a t o m i c , a n d t h i s
* is o n e c a s e w h e r e C L I i s i n v o k e d w i t h o u t E X L b e i n g
* necessarily s e t . T h e C L I a n d s e t u p _ c0 _ s t a t u s w i l l
* in f a c t b e r e d u n d a n t f o r a l l b u t t h e f i r s t T C o f
* each V P E b e i n g b o o t e d .
* /
DMT 1 0 # d m t t 2 / * t 0 , t 1 a r e u s e d b y C L I a n d s e t u p _ c0 _ s t a t u s ( ) * /
jal m i p s _ i h b
# endif / * C O N F I G _ M I P S _ M T _ S M T C * /
2005-04-16 15:20:36 -07:00
setup_ c0 _ s t a t u s _ s e c
2005-07-14 09:42:32 +00:00
smp_ s l a v e _ s e t u p
2006-04-05 09:45:45 +01:00
# ifdef C O N F I G _ M I P S _ M T _ S M T C
andi t 2 , t 2 , V P E C O N T R O L _ T E
beqz t 2 , 2 f
EMT # e m t
2 :
# endif / * C O N F I G _ M I P S _ M T _ S M T C * /
2005-04-16 15:20:36 -07:00
j s t a r t _ s e c o n d a r y
END( s m p _ b o o t s t r a p )
# endif / * C O N F I G _ S M P * /