2008-02-08 15:19:31 +03:00
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# MN1 0 3 0 0 C o n t e x t s w i t c h o p e r a t i o n
#
# Copyright ( C ) 2 0 0 7 R e d H a t , I n c . A l l R i g h t s R e s e r v e d .
# Written b y D a v i d H o w e l l s ( d h o w e l l s @redhat.com)
#
# This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
# modify i t u n d e r t h e 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 c e
# as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
# 2 of t h e L i c e n c e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# include < l i n u x / s y s . h >
# include < l i n u x / l i n k a g e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / c p u - r e g s . h >
2010-10-27 20:28:55 +04:00
# ifdef C O N F I G _ S M P
# include < p r o c / s m p - r e g s . h >
# endif / * C O N F I G _ S M P * /
2008-02-08 15:19:31 +03:00
.text
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# struct t a s k _ s t r u c t * _ _ s w i t c h _ t o ( s t r u c t t h r e a d _ s t r u c t * p r e v ,
# struct t h r e a d _ s t r u c t * n e x t ,
# struct t a s k _ s t r u c t * p r e v _ t a s k )
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
ENTRY( _ _ s w i t c h _ t o )
movm [ d2 ,d3 ,a2 ,a3 ,e x r e g 1 ] ,( s p )
or E P S W _ N M I D ,e p s w
mov ( 4 4 ,s p ) ,d2
mov d0 ,a0
mov d1 ,a1
# save p r e v c o n t e x t
mov _ _ s w i t c h _ b a c k ,d0
mov s p ,a2
mov a2 ,( T H R E A D _ S P ,a0 )
mov a3 ,( T H R E A D _ A 3 ,a0 )
2011-03-18 19:54:32 +03:00
# ifdef C O N F I G _ K G D B
btst 0 x f f ,( k g d b _ s i n g l e _ s t e p )
bne _ _ s w i t c h _ t o _ _ l i f t _ s s t e p _ b p
__switch_to__continue :
# endif
mov d0 ,( T H R E A D _ P C ,a0 )
2008-02-08 15:19:31 +03:00
mov ( T H R E A D _ A 3 ,a1 ) ,a3
mov ( T H R E A D _ S P ,a1 ) ,a2
# switch
mov a2 ,s p
# load n e x t c o n t e x t
GET_ T H R E A D _ I N F O a2
mov a2 ,( _ _ c u r r e n t _ t i )
mov ( T I _ t a s k ,a2 ) ,a2
mov a2 ,( _ _ c u r r e n t )
# ifdef C O N F I G _ M N 1 0 3 0 0 _ C U R R E N T _ I N _ E 2
mov a2 ,e 2
# endif
mov ( T H R E A D _ P C ,a1 ) ,a2
mov d2 ,d0 # f o r r e t _ f r o m _ f o r k
mov d0 ,a0 # f o r _ _ s w i t c h _ t o
jmp ( a2 )
__switch_back :
and ~ E P S W _ N M I D ,e p s w
ret [ d2 ,d3 ,a2 ,a3 ,e x r e g 1 ] ,3 2
2011-03-18 19:54:32 +03:00
# ifdef C O N F I G _ K G D B
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Lift t h e s i n g l e - s t e p b r e a k p o i n t s w h e n t h e t a s k b e i n g t r a c e d i s s w i t c h e d o u t
# A0 = p r e v
# A1 = n e x t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
__switch_to__lift_sstep_bp :
add - 1 2 ,s p
mov a0 ,e 4
mov a1 ,e 5
# Clear t h e s i n g l e - s t e p f l a g t o p r e v e n t u s c o m i n g t h i s w a y u n t i l w e g e t
# switched b a c k i n
bclr 0 x f f ,( k g d b _ s i n g l e _ s t e p )
# Remove f i r s t b r e a k p o i n t
mov ( k g d b _ s s t e p _ b p _ a d d r ) ,a2
cmp 0 ,a2
beq 1 f
movbu ( k g d b _ s s t e p _ b p ) ,d0
movbu d0 ,( a2 )
# if d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ F L U S H _ I C A C H E ) | | d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ I N V _ I C A C H E )
mov a2 ,d0
mov a2 ,d1
add 1 ,d1
calls f l u s h _ i c a c h e _ r a n g e
# endif
1 :
# Remove s e c o n d b r e a k p o i n t
mov ( k g d b _ s s t e p _ b p _ a d d r + 4 ) ,a2
cmp 0 ,a2
beq 2 f
movbu ( k g d b _ s s t e p _ b p + 1 ) ,d0
movbu d0 ,( a2 )
# if d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ F L U S H _ I C A C H E ) | | d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ I N V _ I C A C H E )
mov a2 ,d0
mov a2 ,d1
add 1 ,d1
calls f l u s h _ i c a c h e _ r a n g e
# endif
2 :
# Change t h e r e s u m p t i o n a d d r e s s a n d r e t u r n
mov _ _ s w i t c h _ b a c k _ _ r e i n s t a l l _ s s t e p _ b p ,d0
mov e 4 ,a0
mov e 5 ,a1
add 1 2 ,s p
bra _ _ s w i t c h _ t o _ _ c o n t i n u e
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Reinstall t h e s i n g l e - s t e p b r e a k p o i n t s w h e n t h e t a s k b e i n g t r a c e d i s s w i t c h e d
# back i n ( A 1 p o i n t s t o t h e n e w t h r e a d _ s t r u c t ) .
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
__switch_back__reinstall_sstep_bp :
add - 1 2 ,s p
mov a0 ,e 4 # s a v e t h e r e t u r n v a l u e
mov 0 x f f ,d3
# Reinstall f i r s t b r e a k p o i n t
mov ( k g d b _ s s t e p _ b p _ a d d r ) ,a2
cmp 0 ,a2
beq 1 f
movbu ( a2 ) ,d0
movbu d0 ,( k g d b _ s s t e p _ b p )
movbu d3 ,( a2 )
# if d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ F L U S H _ I C A C H E ) | | d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ I N V _ I C A C H E )
mov a2 ,d0
mov a2 ,d1
add 1 ,d1
calls f l u s h _ i c a c h e _ r a n g e
# endif
1 :
# Reinstall s e c o n d b r e a k p o i n t
mov ( k g d b _ s s t e p _ b p _ a d d r + 4 ) ,a2
cmp 0 ,a2
beq 2 f
movbu ( a2 ) ,d0
movbu d0 ,( k g d b _ s s t e p _ b p + 1 )
movbu d3 ,( a2 )
# if d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ F L U S H _ I C A C H E ) | | d e f i n e d ( C O N F I G _ M N 1 0 3 0 0 _ C A C H E _ I N V _ I C A C H E )
mov a2 ,d0
mov a2 ,d1
add 1 ,d1
calls f l u s h _ i c a c h e _ r a n g e
# endif
2 :
mov d3 ,( k g d b _ s i n g l e _ s t e p )
# Restore t h e r e t u r n v a l u e ( t h e p r e v i o u s t h r e a d _ s t r u c t p o i n t e r )
mov e 4 ,a0
mov a0 ,d0
add 1 2 ,s p
bra _ _ s w i t c h _ b a c k
# endif / * C O N F I G _ K G D B * /