2007-07-11 23:18:53 +04:00
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
*
* Copyright ( C ) 1 9 9 1 , 1 9 9 2 L i n u s T o r v a l d s
* Copyright 2 0 0 7 r P a t h , I n c . - A l l R i g h t s R e s e r v e d
*
* This f i l e i s p a r t o f t h e L i n u x k e r n e l , a n d i s m a d e a v a i l a b l e u n d e r
* the t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 .
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /
/ *
* The a c t u a l t r a n s i t i o n i n t o p r o t e c t e d m o d e
* /
# include < a s m / b o o t . h >
2008-01-30 15:33:02 +03:00
# include < a s m / p r o c e s s o r - f l a g s . h >
2007-07-11 23:18:53 +04:00
# include < a s m / s e g m e n t . h >
.text
.globl protected_mode_jump
.type protected_ m o d e _ j u m p , @function
.code16
/ *
* void p r o t e c t e d _ m o d e _ j u m p ( u 3 2 e n t r y p o i n t , u 3 2 b o o t p a r a m s ) ;
* /
protected_mode_jump :
movl % e d x , % e s i # P o i n t e r t o b o o t _ p a r a m s t a b l e
2008-01-30 15:33:01 +03:00
xorl % e b x , % e b x
movw % c s , % b x
shll $ 4 , % e b x
addl % e b x , 2 f
2008-07-01 02:42:47 +04:00
jmp 1 f # S h o r t j u m p t o s e r i a l i z e o n 386 / 4 8 6
1 :
2007-07-11 23:18:53 +04:00
movw $ _ _ B O O T _ D S , % c x
2008-01-30 15:33:02 +03:00
movw $ _ _ B O O T _ T S S , % d i
2007-07-11 23:18:53 +04:00
movl % c r0 , % e d x
2008-01-30 15:33:02 +03:00
orb $ X 8 6 _ C R 0 _ P E , % d l # P r o t e c t e d m o d e
2007-07-11 23:18:53 +04:00
movl % e d x , % c r0
2008-01-30 15:33:01 +03:00
# Transition t o 3 2 - b i t m o d e
2007-07-11 23:18:53 +04:00
.byte 0 x6 6 , 0 x e a # l j m p l o p c o d e
2008-01-30 15:33:01 +03:00
2 : .long i n _ p m 32 # offset
2007-07-11 23:18:53 +04:00
.word __BOOT_CS # segment
.size protected_ m o d e _ j u m p , . - p r o t e c t e d _ m o d e _ j u m p
2008-01-30 15:33:01 +03:00
.code32
.type in_ p m 3 2 , @function
in_pm32 :
# Set u p d a t a s e g m e n t s f o r f l a t 3 2 - b i t m o d e
movl % e c x , % d s
movl % e c x , % e s
movl % e c x , % f s
movl % e c x , % g s
movl % e c x , % s s
# The 3 2 - b i t c o d e s e t s u p i t s o w n s t a c k , b u t t h i s w a y w e d o h a v e
# a v a l i d s t a c k i f s o m e d e b u g g i n g h a c k w a n t s t o u s e i t .
addl % e b x , % e s p
2008-01-30 15:33:02 +03:00
# Set u p T R t o m a k e I n t e l V T h a p p y
ltr % d i
2008-01-30 15:33:01 +03:00
# Clear r e g i s t e r s t o a l l o w f o r f u t u r e e x t e n s i o n s t o t h e
# 3 2 - bit b o o t p r o t o c o l
xorl % e c x , % e c x
xorl % e d x , % e d x
xorl % e b x , % e b x
xorl % e b p , % e b p
xorl % e d i , % e d i
2008-01-30 15:33:02 +03:00
# Set u p L D T R t o m a k e I n t e l V T h a p p y
lldt % c x
2008-01-30 15:33:01 +03:00
jmpl * % e a x # J u m p t o t h e 32 - b i t e n t r y p o i n t
.size in_ p m 3 2 , . - i n _ p m 3 2