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 , 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 17:07:18 +04: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-17 02:20:36 +04: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-15 01:55:31 +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 >
2006-04-05 12:45:45 +04:00
# include < a s m / a s m m a c r o . h >
2006-07-07 17:07:18 +04:00
# include < a s m / i r q f l a g s . h >
2005-04-17 02:20:36 +04:00
# 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 >
2005-07-14 13:42:32 +04:00
# include < k e r n e l - e n t r y - i n i t . h >
2005-04-17 02:20:36 +04: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
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
.set pop
.endm
.macro setup_c0_status_pri
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
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-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
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-15 01:55:31 +04:00
# ifndef C O N F I G _ N O _ E X C E P T _ F I L L
2005-04-17 02:20:36 +04: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-15 01:55:31 +04:00
# endif
2005-04-17 02:20:36 +04:00
EXPORT( _ s t e x t )
2007-10-16 23:05:18 +04:00
# ifdef C O N F I G _ B O O T _ R A W
2005-07-11 15:53:44 +04: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 15:59:30 +04: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 15:53:44 +04:00
* not h a v e a E L F l o a d e r y e t .
* /
2008-01-07 18:09:50 +03: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 20:32:56 +04:00
# endif
2005-04-17 02:20:36 +04:00
2008-01-30 15:14:59 +03:00
_ _ REF
2007-10-16 23:05:18 +04:00
2005-04-17 02:20:36 +04: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 13:42:32 +04: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-17 02:20:36 +04:00
2007-09-13 22:23:48 +04: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-17 02:20:36 +04:00
2016-06-20 12:27:37 +03:00
# ifdef C O N F I G _ U S E _ O F
2015-04-12 13:24:58 +03:00
# ifdef C O N F I G _ M I P S _ R A W _ A P P E N D E D _ D T B
2016-06-20 12:27:37 +03:00
PTR_ L A t 2 , _ _ a p p e n d e d _ d t b
2015-04-12 13:24:58 +03:00
# ifdef C O N F I G _ C P U _ B I G _ E N D I A N
li t 1 , 0 x d00 d f e e d
# else
li t 1 , 0 x e d f e 0 d d0
# endif
2016-06-20 12:27:37 +03:00
lw t 0 , ( t 2 )
beq t 0 , t 1 , d t b _ f o u n d
# endif
li t 1 , - 2
beq a0 , t 1 , d t b _ f o u n d
move t 2 , a1
2015-04-12 13:24:58 +03:00
2016-06-20 12:27:37 +03:00
li t 2 , 0
dtb_found :
2015-04-12 13:24:58 +03:00
# endif
2005-04-17 02:20:36 +04: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
2016-06-20 12:27:37 +03:00
# ifdef C O N F I G _ U S E _ O F
LONG_ S t 2 , f w _ p a s s e d _ d t b
# endif
2005-04-01 18:07:13 +04: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-17 02:20:36 +04:00
PTR_ L A $ 2 8 , i n i t _ t h r e a d _ u n i o n
2009-07-08 21:07:50 +04: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 05:29:01 +04:00
PTR_ A D D U s p , $ 2 8
2009-10-14 01:23:28 +04:00
back_ t o _ b a c k _ c0 _ h a z a r d
2005-04-17 02:20:36 +04: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
2016-03-31 12:05:37 +03:00
# ifdef C O N F I G _ R E L O C A T A B L E
/* Copy kernel and apply the relocations */
jal r e l o c a t e _ k e r n e l
/* Repoint the sp into the new kernel image */
PTR_ L I s p , _ T H R E A D _ S I Z E - 3 2 - P T _ S I Z E
PTR_ A D D U s p , $ 2 8
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
/ *
* relocate_ k e r n e l r e t u r n s t h e e n t r y p o i n t e i t h e r
* in t h e r e l o c a t e d k e r n e l o r t h e o r i g i n a l i f f o r
* some r e a s o n r e l o c a t i o n f a i l e d - j u m p t h e r e n o w
* with i n s t r u c t i o n h a z a r d b a r r i e r b e c a u s e o f t h e
* newly s y n c ' d i c a c h e .
* /
jr. h b v0
# else
2005-04-17 02:20:36 +04:00
j s t a r t _ k e r n e l
2016-03-31 12:05:37 +03:00
# endif
2005-04-17 02:20:36 +04:00
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 15:59:30 +04: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-17 02:20:36 +04: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 )
2005-07-14 13:42:32 +04:00
smp_ s l a v e _ s e t u p
2014-01-21 13:52:23 +04:00
setup_ c0 _ s t a t u s _ s e c
2005-04-17 02:20:36 +04: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 * /