2022-05-31 13:04:11 +03:00
/* SPDX-License-Identifier: GPL-2.0 */
/ *
* Copyright ( C ) 2 0 2 0 - 2 0 2 2 L o o n g s o n T e c h n o l o g y C o r p o r a t i o n L i m i t 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 >
# include < a s m / a d d r s p a c e . h >
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
# include < a s m / r e g d e f . h >
# include < a s m / l o o n g a r c h . h >
# include < a s m / s t a c k f r a m e . h >
_ _ REF
SYM_ C O D E _ S T A R T ( k e r n e l _ e n t r y ) # k e r n e l e n t r y p o i n t
/* Config direct window and set PG */
li. d t 0 , C S R _ D M W 0 _ I N I T # U C , P L V 0 , 0 x80 0 0 x x x x x x x x x x x x
csrwr t 0 , L O O N G A R C H _ C S R _ D M W I N 0
li. d t 0 , C S R _ D M W 1 _ I N I T # C A , P L V 0 , 0 x90 0 0 x x x x x x x x x x x x
csrwr t 0 , L O O N G A R C H _ C S R _ D M W I N 1
/* Enable PG */
li. w t 0 , 0 x b0 # P L V = 0 , I E =0 , P G =1
csrwr t 0 , L O O N G A R C H _ C S R _ C R M D
li. w t 0 , 0 x04 # P L V = 0 , P I E =1 , P W E =0
csrwr t 0 , L O O N G A R C H _ C S R _ P R M D
li. w t 0 , 0 x00 # F P E = 0 , S X E =0 , A S X E =0 , B T E =0
csrwr t 0 , L O O N G A R C H _ C S R _ E U E N
/ * 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 . * /
la. a b s t 0 , 0 f
2022-07-26 18:57:17 +03:00
jr t 0
2022-05-31 13:04:11 +03:00
0 :
la t 0 , _ _ b s s _ s t a r t # c l e a r . b s s
st. d z e r o , t 0 , 0
la t 1 , _ _ b s s _ s t o p - L O N G S I Z E
1 :
addi. d t 0 , t 0 , L O N G S I Z E
st. d z e r o , t 0 , 0
bne t 0 , t 1 , 1 b
la t 0 , f w _ a r g 0
st. d a0 , t 0 , 0 # f i r m w a r e a r g u m e n t s
la t 0 , f w _ a r g 1
st. d a1 , t 0 , 0
/* KSave3 used for percpu base, initialized as 0 */
csrwr z e r o , P E R C P U _ B A S E _ K S
/* GPR21 used for percpu base (runtime), initialized as 0 */
2022-07-26 18:57:18 +03:00
move u 0 , z e r o
2022-05-31 13:04:11 +03:00
la t p , i n i t _ t h r e a d _ u n i o n
/* 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 )
PTR_ A D D s p , s p , t p
set_ s a v e d _ s p s p , t 0 , t 1
PTR_ A D D I s p , s p , - 4 * S Z R E G # i n i t s t a c k p o i n t e r
bl s t a r t _ k e r n e l
SYM_ C O D E _ E N D ( k e r n e l _ e n t r y )
2022-05-31 13:04:12 +03: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 t p r e g i s t e r s .
* /
SYM_ C O D E _ S T A R T ( s m p b o o t _ e n t r y )
li. d t 0 , C S R _ D M W 0 _ I N I T # U C , P L V 0
csrwr t 0 , L O O N G A R C H _ C S R _ D M W I N 0
li. d t 0 , C S R _ D M W 1 _ I N I T # C A , P L V 0
csrwr t 0 , L O O N G A R C H _ C S R _ D M W I N 1
li. w t 0 , 0 x b0 # P L V = 0 , I E =0 , P G =1
csrwr t 0 , L O O N G A R C H _ C S R _ C R M D
li. w t 0 , 0 x04 # P L V = 0 , P I E =1 , P W E =0
csrwr t 0 , L O O N G A R C H _ C S R _ P R M D
li. w t 0 , 0 x00 # F P E = 0 , S X E =0 , A S X E =0 , B T E =0
csrwr t 0 , L O O N G A R C H _ C S R _ E U E N
la. a b s t 0 , c p u b o o t _ d a t a
ld. d s p , t 0 , C P U _ B O O T _ S T A C K
ld. d t p , t 0 , C P U _ B O O T _ T I N F O
2022-07-26 18:57:22 +03:00
la. a b s t 0 , 0 f
jr t 0
2022-05-31 13:04:12 +03:00
0 :
bl s t a r t _ s e c o n d a r y
SYM_ C O D E _ E N D ( s m p b o o t _ e n t r y )
# endif / * C O N F I G _ S M P * /
2022-05-31 13:04:11 +03:00
SYM_ E N T R Y ( k e r n e l _ e n t r y _ e n d , S Y M _ L _ G L O B A L , S Y M _ A _ N O N E )