2005-04-17 02:20:36 +04:00
/ *
*
* Trampoline. S D e r i v e d f r o m S e t u p . S b y L i n u s T o r v a l d s
*
* 4 Jan 1 9 9 7 M i c h a e l C h a s t a i n : c h a n g e d t o g n u a s .
*
* This i s o n l y u s e d f o r b o o t i n g s e c o n d a r y C P U s i n S M P m a c h i n e
*
* Entry : CS : IP p o i n t t o t h e s t a r t o f o u r c o d e , w e a r e
* in r e a l m o d e w i t h n o s t a c k , b u t t h e r e s t o f t h e
* trampoline p a g e t o m a k e o u r s t a c k a n d e v e r y t h i n g e l s e
* is a m y s t e r y .
*
2008-02-04 18:48:01 +03:00
* We j u m p i n t o a r c h / x86 / k e r n e l / h e a d _ 3 2 . S .
2005-04-17 02:20:36 +04:00
*
* On e n t r y t o t r a m p o l i n e _ d a t a , t h e p r o c e s s o r i s i n r e a l m o d e
* with 1 6 - b i t a d d r e s s i n g a n d 1 6 - b i t d a t a . C S h a s s o m e v a l u e
* and I P i s z e r o . T h u s , d a t a a d d r e s s e s n e e d t o b e a b s o l u t e
* ( no r e l o c a t i o n ) a n d a r e t a k e n w i t h r e g a r d t o r _ b a s e .
*
* If y o u w o r k o n t h i s f i l e , c h e c k t h e o b j e c t m o d u l e w i t h
* objdump - - r e l o c t o m a k e s u r e t h e r e a r e n o r e l o c a t i o n
* entries e x c e p t f o r :
*
* TYPE V A L U E
* R_ 3 8 6 _ 3 2 s t a r t u p _ 3 2 _ s m p
2007-05-02 21:27:10 +04:00
* R_ 3 8 6 _ 3 2 b o o t _ g d t
2005-04-17 02:20:36 +04:00
* /
# include < l i n u x / l i n k a g e . h >
2009-09-04 12:16:22 +04:00
# include < l i n u x / i n i t . h >
2005-04-17 02:20:36 +04:00
# include < a s m / s e g m e n t . h >
2009-02-13 22:14:01 +03:00
# include < a s m / p a g e _ t y p e s . h >
2005-04-17 02:20:36 +04:00
2011-02-15 02:34:57 +03:00
# ifdef C O N F I G _ S M P
.section " .x86_trampoline " , " a"
.balign PAGE_SIZE
.code16
2005-04-17 02:20:36 +04:00
ENTRY( t r a m p o l i n e _ d a t a )
r_ b a s e = .
wbinvd # N e e d e d f o r N U M A - Q s h o u l d b e h a r m l e s s f o r o t h e r s
mov % c s , % a x # C o d e a n d d a t a i n t h e s a m e p l a c e
mov % a x , % d s
cli # W e s h o u l d b e s a f e a n y w a y
2011-02-15 02:34:57 +03:00
movl $ 0 x A 5 A 5 A 5 A 5 , t r a m p o l i n e _ s t a t u s - r _ b a s e
2005-04-17 02:20:36 +04:00
# write m a r k e r f o r m a s t e r k n o w s w e ' r e r u n n i n g
/ * GDT t a b l e s i n n o n d e f a u l t l o c a t i o n k e r n e l c a n b e b e y o n d 1 6 M B a n d
* lgdt w i l l n o t b e a b l e t o l o a d t h e a d d r e s s a s i n r e a l m o d e d e f a u l t
* operand s i z e i s 1 6 b i t . U s e l g d t l i n s t e a d t o f o r c e o p e r a n d s i z e
* to 3 2 b i t .
* /
2007-05-02 21:27:10 +04:00
lidtl b o o t _ i d t _ d e s c r - r _ b a s e # l o a d i d t w i t h 0 , 0
lgdtl b o o t _ g d t _ d e s c r - r _ b a s e # l o a d g d t w i t h w h a t e v e r i s a p p r o p r i a t e
2005-04-17 02:20:36 +04:00
xor % a x , % a x
inc % a x # p r o t e c t e d m o d e ( P E ) b i t
lmsw % a x # i n t o p r o t e c t e d m o d e
# flush p r e f e t c h a n d j u m p t o s t a r t u p _ 3 2 _ s m p i n a r c h / i 3 8 6 / k e r n e l / h e a d . S
ljmpl $ _ _ B O O T _ C S , $ ( s t a r t u p _ 3 2 _ s m p - _ _ P A G E _ O F F S E T )
# These n e e d t o b e i n t h e s a m e 6 4 K s e g m e n t a s t h e a b o v e ;
# hence w e d o n ' t u s e t h e b o o t _ g d t _ d e s c r d e f i n e d i n h e a d . S
2007-05-02 21:27:10 +04:00
boot_gdt_descr :
2005-04-17 02:20:36 +04:00
.word __BOOT_DS + 7 # gdt l i m i t
2007-05-02 21:27:10 +04:00
.long boot_gdt - _ _ PAGE_ O F F S E T # g d t b a s e
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:10 +04:00
boot_idt_descr :
2005-04-17 02:20:36 +04:00
.word 0 # idt l i m i t = 0
.long 0 # idt b a s e = 0 L
2011-02-15 02:34:57 +03:00
ENTRY( t r a m p o l i n e _ s t a t u s )
.long 0
2005-04-17 02:20:36 +04:00
.globl trampoline_end
trampoline_end :
2011-02-15 02:34:57 +03:00
# endif / * C O N F I G _ S M P * /