2005-04-17 02:20:36 +04:00
/ * $ Id : etrap. S ,v 1 . 4 6 2 0 0 2 / 0 2 / 0 9 1 9 : 4 9 : 3 0 d a v e m E x p $
* etrap. S : P r e p a r i n g f o r e n t r y i n t o t h e k e r n e l o n S p a r c V 9 .
*
* Copyright ( C ) 1 9 9 6 , 1 9 9 7 D a v i d S . M i l l e r ( d a v e m @caip.rutgers.edu)
* Copyright ( C ) 1 9 9 7 , 1 9 9 8 , 1 9 9 9 J a k u b J e l i n e k ( j j @ultra.linux.cz)
* /
# include < a s m / a s i . h >
# include < a s m / p s t a t e . h >
# include < a s m / p t r a c e . h >
# include < a s m / p a g e . h >
# include < a s m / s p i t f i r e . h >
# include < a s m / h e a d . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / m m u . h >
# define T A S K _ R E G O F F ( T H R E A D _ S I Z E - T R A C E R E G _ S Z - S T A C K F R A M E _ S Z )
# define E T R A P _ P S T A T E 1 ( P S T A T E _ R M O | P S T A T E _ P R I V )
# define E T R A P _ P S T A T E 2 \
( PSTATE_ R M O | P S T A T E _ P E F | P S T A T E _ P R I V | P S T A T E _ I E )
/ *
* On e n t r y , % g 7 i s r e t u r n a d d r e s s - 0 x4 .
* % g4 a n d % g 5 w i l l b e p r e s e r v e d % l 4 a n d % l 5 r e s p e c t i v e l y .
* /
.text
.align 64
.globl etrap, e t r a p _ i r q , e t r a p t l 1
etrap : rdpr % p i l , % g 2
etrap_irq :
2006-02-03 08:55:10 +03:00
TRAP_ L O A D _ T H R E A D _ R E G ( % g 6 , % g 1 )
2005-04-17 02:20:36 +04:00
rdpr % t s t a t e , % g 1
sllx % g 2 , 2 0 , % g 3
andcc % g 1 , T S T A T E _ P R I V , % g 0
or % g 1 , % g 3 , % g 1
bne,p n % x c c , 1 f
sub % s p , S T A C K F R A M E _ S Z + T R A C E R E G _ S Z - S T A C K _ B I A S , % g 2
wrpr % g 0 , 7 , % c l e a n w i n
sethi % h i ( T A S K _ R E G O F F ) , % g 2
sethi % h i ( T S T A T E _ P E F ) , % g 3
or % g 2 , % l o ( T A S K _ R E G O F F ) , % g 2
and % g 1 , % g 3 , % g 3
brnz,p n % g 3 , 1 f
add % g 6 , % g 2 , % g 2
wr % g 0 , 0 , % f p r s
1 : rdpr % t p c , % g 3
stx % g 1 , [ % g 2 + S T A C K F R A M E _ S Z + P T _ V 9 _ T S T A T E ]
rdpr % t n p c , % g 1
stx % g 3 , [ % g 2 + S T A C K F R A M E _ S Z + P T _ V 9 _ T P C ]
rd % y , % g 3
stx % g 1 , [ % g 2 + S T A C K F R A M E _ S Z + P T _ V 9 _ T N P C ]
2008-04-24 09:52:13 +04:00
rdpr % t t , % g 1
2005-04-17 02:20:36 +04:00
st % g 3 , [ % g 2 + S T A C K F R A M E _ S Z + P T _ V 9 _ Y ]
2008-04-24 09:52:13 +04:00
sethi % h i ( P T _ R E G S _ M A G I C ) , % g 3
or % g 3 , % g 1 , % g 1
st % g 1 , [ % g 2 + S T A C K F R A M E _ S Z + P T _ V 9 _ M A G I C ]
2006-02-04 11:10:01 +03:00
rdpr % c a n s a v e , % g 1
brnz,p t % g 1 , e t r a p _ s a v e
nop
rdpr % c w p , % g 1
add % g 1 , 2 , % g 1
wrpr % g 1 , % c w p
be,p t % x c c , e t r a p _ u s e r _ s p i l l
mov A S I _ A I U P , % g 3
rdpr % o t h e r w i n , % g 3
brz % g 3 , e t r a p _ k e r n e l _ s p i l l
mov A S I _ A I U S , % g 3
etrap_user_spill :
wr % g 3 , 0 x0 , % a s i
ldx [ % g 6 + T I _ F L A G S ] , % g 3
and % g 3 , _ T I F _ 3 2 B I T , % g 3
brnz,p t % g 3 , e t r a p _ u s e r _ s p i l l _ 3 2 b i t
nop
ba,a ,p t % x c c , e t r a p _ u s e r _ s p i l l _ 6 4 b i t
etrap_save : save % g 2 , - S T A C K _ B I A S , % s p
2005-04-17 02:20:36 +04:00
mov % g 6 , % l 6
bne,p n % x c c , 3 f
mov P R I M A R Y _ C O N T E X T , % l 4
rdpr % c a n r e s t o r e , % g 3
rdpr % w s t a t e , % g 2
wrpr % g 0 , 0 , % c a n r e s t o r e
sll % g 2 , 3 , % g 2
mov 1 , % l 5
stb % l 5 , [ % l 6 + T I _ F P D E P T H ]
wrpr % g 3 , 0 , % o t h e r w i n
wrpr % g 2 , 0 , % w s t a t e
2005-10-05 02:23:20 +04:00
sethi % h i ( s p a r c64 _ k e r n _ p r i _ c o n t e x t ) , % g 2
ldx [ % g 2 + % l o ( s p a r c64 _ k e r n _ p r i _ c o n t e x t ) ] , % g 3
2006-02-08 09:13:05 +03:00
661 : stxa % g 3 , [ % l 4 ] A S I _ D M M U
.section .sun4v_1insn_patch , " ax"
.word 661b
stxa % g 3 , [ % l 4 ] A S I _ M M U
.previous
2006-02-01 05:33:00 +03:00
sethi % h i ( K E R N B A S E ) , % l 4
flush % l 4
2006-02-06 07:47:26 +03:00
mov A S I _ A I U S , % l 7
2 : mov % g 4 , % l 4
2005-04-17 02:20:36 +04:00
mov % g 5 , % l 5
2006-02-06 07:47:26 +03:00
add % g 7 , 4 , % l 2
2006-02-06 08:29:28 +03:00
/* Go to trap time globals so we can save them. */
661 : wrpr % g 0 , E T R A P _ P S T A T E 1 , % p s t a t e
2006-02-07 11:00:16 +03:00
.section .sun4v_1insn_patch , " ax"
2006-02-06 08:29:28 +03:00
.word 661b
SET_ G L ( 0 )
.previous
2005-04-17 02:20:36 +04:00
stx % g 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 1 ]
stx % g 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 2 ]
2006-02-06 07:47:26 +03:00
sllx % l 7 , 2 4 , % l 7
2005-04-17 02:20:36 +04:00
stx % g 3 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 3 ]
2006-02-06 07:47:26 +03:00
rdpr % c w p , % l 0
2005-04-17 02:20:36 +04:00
stx % g 4 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 4 ]
stx % g 5 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 5 ]
stx % g 6 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 6 ]
stx % g 7 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ G 7 ]
2006-02-06 07:47:26 +03:00
or % l 7 , % l 0 , % l 7
sethi % h i ( T S T A T E _ R M O | T S T A T E _ P E F ) , % l 0
or % l 7 , % l 0 , % l 7
wrpr % l 2 , % t n p c
wrpr % l 7 , ( T S T A T E _ P R I V | T S T A T E _ I E ) , % t s t a t e
2005-04-17 02:20:36 +04:00
stx % i 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
stx % i 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 1 ]
stx % i 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 2 ]
stx % i 3 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 3 ]
stx % i 4 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 4 ]
stx % i 5 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 5 ]
stx % i 6 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 6 ]
mov % l 6 , % g 6
2006-02-06 07:47:26 +03:00
stx % i 7 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 7 ]
2006-02-03 08:55:10 +03:00
LOAD_ P E R _ C P U _ B A S E ( % g 5 , % g 6 , % g 4 , % g 3 , % l 1 )
2006-02-06 07:47:26 +03:00
ldx [ % g 6 + T I _ T A S K ] , % g 4
done
2005-04-17 02:20:36 +04:00
2006-02-06 07:47:26 +03:00
3 : mov A S I _ P , % l 7
ldub [ % l 6 + T I _ F P D E P T H ] , % l 5
2005-04-17 02:20:36 +04:00
add % l 6 , T I _ F P S A V E D + 1 , % l 4
srl % l 5 , 1 , % l 3
add % l 5 , 2 , % l 5
stb % l 5 , [ % l 6 + T I _ F P D E P T H ]
ba,p t % x c c , 2 b
stb % g 0 , [ % l 4 + % l 3 ]
nop
etraptl1 : / * Save t s t a t e / t p c / t n p c o f T L 1 - - > 4 a n d t h e t l r e g i s t e r i t s e l f .
* We p l a c e t h i s r i g h t a f t e r p t _ r e g s o n t h e t r a p s t a c k .
* The l a y o u t i s :
* 0 x0 0 T L 1 ' s T S T A T E
* 0 x0 8 T L 1 ' s T P C
* 0 x1 0 T L 1 ' s T N P C
* 0 x1 8 T L 1 ' s T T
* . . .
* 0 x5 8 T L 4 ' s T T
* 0 x6 0 T L
* /
2006-02-03 08:55:10 +03:00
TRAP_ L O A D _ T H R E A D _ R E G ( % g 6 , % g 1 )
2005-04-17 02:20:36 +04:00
sub % s p , ( ( 4 * 8 ) * 4 ) + 8 , % g 2
rdpr % t l , % g 1
wrpr % g 0 , 1 , % t l
rdpr % t s t a t e , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x00 ]
rdpr % t p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x08 ]
rdpr % t n p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x10 ]
rdpr % t t , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x18 ]
wrpr % g 0 , 2 , % t l
rdpr % t s t a t e , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x20 ]
rdpr % t p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x28 ]
rdpr % t n p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x30 ]
rdpr % t t , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x38 ]
2006-02-16 12:41:41 +03:00
sethi % h i ( i s _ s u n 4 v ) , % g 3
lduw [ % g 3 + % l o ( i s _ s u n 4 v ) ] , % g 3
brnz,p n % g 3 , f i n i s h _ t l 1 _ c a p t u r e
nop
2005-04-17 02:20:36 +04:00
wrpr % g 0 , 3 , % t l
rdpr % t s t a t e , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x40 ]
rdpr % t p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x48 ]
rdpr % t n p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x50 ]
rdpr % t t , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x58 ]
wrpr % g 0 , 4 , % t l
rdpr % t s t a t e , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x60 ]
rdpr % t p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x68 ]
rdpr % t n p c , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x70 ]
rdpr % t t , % g 3
stx % g 3 , [ % g 2 + S T A C K _ B I A S + 0 x78 ]
stx % g 1 , [ % g 2 + S T A C K _ B I A S + 0 x80 ]
2006-02-16 12:41:41 +03:00
finish_tl1_capture :
2006-02-06 08:29:28 +03:00
wrpr % g 0 , 1 , % t l
661 : nop
2006-02-07 11:00:16 +03:00
.section .sun4v_1insn_patch , " ax"
2006-02-06 08:29:28 +03:00
.word 661b
SET_ G L ( 1 )
.previous
2005-04-17 02:20:36 +04:00
rdpr % t s t a t e , % g 1
sub % g 2 , S T A C K F R A M E _ S Z + T R A C E R E G _ S Z - S T A C K _ B I A S , % g 2
ba,p t % x c c , 1 b
andcc % g 1 , T S T A T E _ P R I V , % g 0
# undef T A S K _ R E G O F F
# undef E T R A P _ P S T A T E 1