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
* Copyright ( C ) 1 9 9 4 , 9 5 , 9 6 , 9 7 , 9 8 , 9 9 , 2 0 0 3 R a l f B a e c h l e
* 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 / c o n f i g . h >
# 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 >
# include < a s m / a s m . h >
# include < a s m / r e g d e f . h >
# include < a s m / p a g e . 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
.macro ARC64_TWIDDLE_PC
# if d e f i n e d ( C O N F I G _ A R C 6 4 ) | | d e f i n e d ( C O N F I G _ M A P P E D _ K E R N E L )
/ * We g e t l a u n c h e d a t a X K P H Y S a d d r e s s b u t t h e k e r n e l i s l i n k e d t o
run a t a K S E G 0 a d d r e s s , s o j u m p t h e r e . * /
PTR_ L A t 0 , \ @f
jr t 0
\ @:
# endif
.endm
/ *
* inputs a r e t h e t e x t n a s i d i n t 1 , d a t a n a s i d i n t 2 .
* /
.macro MAPPED_KERNEL_SETUP_TLB
# ifdef C O N F I G _ M A P P E D _ K E R N E L
/ *
* This n e e d s t o r e a d t h e n a s i d - a s s u m e 0 f o r n o w .
* Drop i n 0 x f f f f f f f f c00 0 0 0 0 0 i n t l b h i , 0 + V G i n t l b l o _ 0 ,
* 0 + DVG i n t l b l o _ 1 .
* /
dli t 0 , 0 x f f f f f f f f c00 0 0 0 0 0
dmtc0 t 0 , C P 0 _ E N T R Y H I
li t 0 , 0 x1 c00 0 # O f f s e t o f t e x t i n t o n o d e m e m o r y
dsll t 1 , N A S I D _ S H F T # S h i f t t e x t n a s i d i n t o p l a c e
dsll t 2 , N A S I D _ S H F T # S a m e f o r d a t a n a s i d
or t 1 , t 1 , t 0 # P h y s i c a l l o a d a d d r e s s o f k e r n e l t e x t
or t 2 , t 2 , t 0 # P h y s i c a l l o a d a d d r e s s o f k e r n e l d a t a
dsrl t 1 , 1 2 # 4 K p f n
dsrl t 2 , 1 2 # 4 K p f n
dsll t 1 , 6 # G e t p f n i n t o p l a c e
dsll t 2 , 6 # G e t p f n i n t o p l a c e
li t 0 , ( ( _ P A G E _ G L O B A L | _ P A G E _ V A L I D | _ C A C H E _ C A C H A B L E _ C O W ) > > 6 )
or t 0 , t 0 , t 1
mtc0 t 0 , C P 0 _ E N T R Y L O 0 # p h y s a d d r , V G , c a c h e x l w r
li t 0 , ( ( _ P A G E _ G L O B A L | _ P A G E _ V A L I D | _ P A G E _ D I R T Y | _ C A C H E _ C A C H A B L E _ C O W ) > > 6 )
or t 0 , t 0 , t 2
mtc0 t 0 , C P 0 _ E N T R Y L O 1 # p h y s a d d r , D V G , c a c h e x l w r
li t 0 , 0 x1 f f e 0 0 0 # M A P P E D _ K E R N _ T L B M A S K , T L B P G M A S K _ 16 M
mtc0 t 0 , C P 0 _ P A G E M A S K
li t 0 , 0 # K M A P _ I N X
mtc0 t 0 , C P 0 _ I N D E X
li t 0 , 1
mtc0 t 0 , C P 0 _ W I R E D
tlbwi
# else
mtc0 z e r o , C P 0 _ W I R E D
# endif
.endm
/ *
* 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
/ *
* 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
EXPORT( s t e x t ) # u s e d f o r p r o f i l i n g
EXPORT( _ s t e x t )
2005-09-30 16:59:37 +04:00
# if d e f i n e d ( C O N F I G _ Q E M U ) | | d e f i n e d ( C O N F I G _ M I P S _ S I M )
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
* 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
* not h a v e a E L F l o a d e r y e t .
* /
j k e r n e l _ e n t r y
# endif
2005-04-17 02:20:36 +04:00
_ _ INIT
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
ARC6 4 _ T W I D D L E _ P C
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 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
PTR_ A D D I U s p , $ 2 8 , _ T H R E A D _ S I Z E - 3 2
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 )
2005-07-11 15:53:44 +04:00
# ifdef C O N F I G _ Q E M U
_ _ INIT
# endif
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ S M P
/ *
* 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
* 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 )
setup_ c0 _ s t a t u s _ s e c
2005-07-14 13:42:32 +04:00
smp_ s l a v e _ s e t u p
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 * /
_ _ FINIT
.comm kernelsp, N R _ C P U S * 8 , 8
.comm pgd_ c u r r e n t , N R _ C P U S * 8 , 8
.comm fw_ a r g 0 , S Z R E G , S Z R E G # f i r m w a r e a r g u m e n t s
.comm fw_ a r g 1 , S Z R E G , S Z R E G
.comm fw_ a r g 2 , S Z R E G , S Z R E G
.comm fw_ a r g 3 , S Z R E G , S Z R E G
2004-12-23 11:21:39 +03:00
.macro page name, o r d e r
.comm \ name, ( _ P A G E _ S I Z E < < \ o r d e r ) , ( _ P A G E _ S I Z E < < \ o r d e r )
2005-04-17 02:20:36 +04:00
.endm
/ *
2004-12-23 11:21:39 +03:00
* On 6 4 - b i t w e ' v e g o t t h r e e - l e v e l p a g e t a b l e s w i t h a s l i g h t l y
* different l a y o u t . . .
2005-04-17 02:20:36 +04:00
* /
page s w a p p e r _ p g _ d i r , _ P G D _ O R D E R
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
page i n v a l i d _ p m d _ t a b l e , _ P M D _ O R D E R
# endif
page i n v a l i d _ p t e _ t a b l e , _ P T E _ O R D E R