2006-01-31 18:29:18 -08:00
/ * tsb. S : S p a r c64 T S B t a b l e h a n d l i n g .
*
* Copyright ( C ) 2 0 0 6 D a v i d S . M i l l e r < d a v e m @davemloft.net>
* /
# include < a s m / t s b . h >
.text
.align 32
/ * Invoked f r o m T L B m i s s h a n d l e r , w e a r e i n t h e
* MMU g l o b a l r e g i s t e r s a n d t h e y a r e s e t u p l i k e
* this :
*
* % g1 : TSB e n t r y p o i n t e r
* % g2 : available t e m p o r a r y
* % g3 : FAULT_ C O D E _ { D ,I } T L B
* % g4 : available t e m p o r a r y
* % g5 : available t e m p o r a r y
* % g6 : TAG T A R G E T
* % g7 : physical a d d r e s s b a s e o f t h e l i n u x p a g e
* tables f o r t h e c u r r e n t a d d r e s s s p a c e
* /
.globl tsb_miss_dtlb
tsb_miss_dtlb :
mov T L B _ T A G _ A C C E S S , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 4
ba,p t % x c c , t s b _ m i s s _ p a g e _ t a b l e _ w a l k
nop
.globl tsb_miss_itlb
tsb_miss_itlb :
mov T L B _ T A G _ A C C E S S , % g 4
ldxa [ % g 4 ] A S I _ I M M U , % g 4
ba,p t % x c c , t s b _ m i s s _ p a g e _ t a b l e _ w a l k
nop
tsb_miss_page_table_walk :
2006-02-02 21:55:10 -08:00
TRAP_ L O A D _ P G D _ P H Y S ( % g 7 , % g 5 )
2006-02-26 23:24:22 -08:00
2006-01-31 18:29:18 -08:00
USER_ P G T A B L E _ W A L K _ T L 1 ( % g 4 , % g 7 , % g 5 , % g 2 , t s b _ d o _ f a u l t )
tsb_reload :
TSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 4 )
/* Load and check PTE. */
ldxa [ % g 5 ] A S I _ P H Y S _ U S E _ E C , % g 5
brgez,a ,p n % g 5 , t s b _ d o _ f a u l t
2006-02-01 15:55:21 -08:00
TSB_ S T O R E ( % g 1 , % g 0 )
2006-01-31 18:29:18 -08:00
2006-01-31 18:31:06 -08:00
/ * If i t i s l a r g e r t h a n t h e b a s e p a g e s i z e , d o n ' t
* bother p u t t i n g i t i n t o t h e T S B .
* /
srlx % g 5 , 3 2 , % g 2
sethi % h i ( _ P A G E _ A L L _ S Z _ B I T S > > 3 2 ) , % g 4
sethi % h i ( _ P A G E _ S Z B I T S > > 3 2 ) , % g 7
and % g 2 , % g 4 , % g 2
cmp % g 2 , % g 7
bne,a ,p n % x c c , t s b _ t l b _ r e l o a d
2006-02-01 15:55:21 -08:00
TSB_ S T O R E ( % g 1 , % g 0 )
2006-01-31 18:31:06 -08:00
2006-01-31 18:29:18 -08:00
TSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
/* Finally, load TLB and return from trap. */
tsb_tlb_reload :
cmp % g 3 , F A U L T _ C O D E _ D T L B
bne,p n % x c c , t s b _ i t l b _ l o a d
nop
tsb_dtlb_load :
stxa % g 5 , [ % g 0 ] A S I _ D T L B _ D A T A _ I N
retry
tsb_itlb_load :
stxa % g 5 , [ % g 0 ] A S I _ I T L B _ D A T A _ I N
retry
/ * No v a l i d e n t r y i n t h e p a g e t a b l e s , d o f u l l f a u l t
* processing.
* /
.globl tsb_do_fault
tsb_do_fault :
cmp % g 3 , F A U L T _ C O D E _ D T L B
rdpr % p s t a t e , % g 5
bne,p n % x c c , t s b _ d o _ i t l b _ f a u l t
wrpr % g 5 , P S T A T E _ A G | P S T A T E _ M G , % p s t a t e
tsb_do_dtlb_fault :
rdpr % t l , % g 4
cmp % g 4 , 1
mov T L B _ T A G _ A C C E S S , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 5
be,p t % x c c , s p a r c64 _ r e a l f a u l t _ c o m m o n
mov F A U L T _ C O D E _ D T L B , % g 4
ba,p t % x c c , w i n f i x _ t r a m p o l i n e
nop
tsb_do_itlb_fault :
rdpr % t p c , % g 5
ba,p t % x c c , s p a r c64 _ r e a l f a u l t _ c o m m o n
mov F A U L T _ C O D E _ I T L B , % g 4
.globl sparc64_realfault_common
sparc64_realfault_common :
2006-01-31 18:34:21 -08:00
/ * fault c o d e i n % g 4 , f a u l t a d d r e s s i n % g 5 , e t r a p w i l l
* preserve t h e s e t w o v a l u e s i n % l 4 a n d % l 5 r e s p e c t i v e l y
* /
2006-01-31 18:29:18 -08:00
ba,p t % x c c , e t r a p ! S a v e t r a p s t a t e
1 : rd % p c , % g 7 ! . . .
2006-01-31 18:34:21 -08:00
stb % l 4 , [ % g 6 + T I _ F A U L T _ C O D E ] ! S a v e f a u l t c o d e
stx % l 5 , [ % g 6 + T I _ F A U L T _ A D D R ] ! S a v e f a u l t a d d r e s s
2006-01-31 18:29:18 -08:00
call d o _ s p a r c64 _ f a u l t ! C a l l f a u l t h a n d l e r
add % s p , P T R E G S _ O F F , % o 0 ! C o m p u t e p t _ r e g s a r g
ba,p t % x c c , r t r a p _ c l r _ l 6 ! R e s t o r e c p u s t a t e
nop ! D e l a y s l o t ( f i l l m e )
winfix_trampoline :
rdpr % t p c , % g 3 ! P r e p a r e w i n f i x u p T N P C
or % g 3 , 0 x7 c , % g 3 ! C o m p u t e b r a n c h o f f s e t
wrpr % g 3 , % t n p c ! W r i t e i t i n t o T N P C
done ! T r a p r e t u r n
2006-01-31 18:32:04 -08:00
/ * Insert a n e n t r y i n t o t h e T S B .
*
2006-02-01 15:55:21 -08:00
* % o0 : TSB e n t r y p o i n t e r ( v i r t o r p h y s a d d r e s s )
2006-01-31 18:32:04 -08:00
* % o1 : tag
* % o2 : pte
* /
.align 32
2006-02-01 15:55:21 -08:00
.globl __tsb_insert
__tsb_insert :
2006-01-31 18:32:04 -08:00
rdpr % p s t a t e , % o 5
wrpr % o 5 , P S T A T E _ I E , % p s t a t e
TSB_ L O C K _ T A G ( % o 0 , % g 2 , % g 3 )
TSB_ W R I T E ( % o 0 , % o 2 , % o 1 )
wrpr % o 5 , % p s t a t e
retl
nop
2006-02-01 15:55:21 -08:00
/ * Flush t h e g i v e n T S B e n t r y i f i t h a s t h e m a t c h i n g
* tag.
*
* % o0 : TSB e n t r y p o i n t e r ( v i r t o r p h y s a d d r e s s )
* % o1 : tag
* /
.align 32
.globl tsb_flush
tsb_flush :
sethi % h i ( T S B _ T A G _ L O C K _ H I G H ) , % g 2
1 : TSB_ L O A D _ T A G ( % o 0 , % g 1 )
srlx % g 1 , 3 2 , % o 3
andcc % o 3 , % g 2 , % g 0
bne,p n % i c c , 1 b
membar #L o a d L o a d
cmp % g 1 , % o 1
bne,p t % x c c , 2 f
clr % o 3
TSB_ C A S _ T A G ( % o 0 , % g 1 , % o 3 )
cmp % g 1 , % o 3
bne,p n % x c c , 1 b
nop
2 : retl
TSB_ M E M B A R
2006-01-31 18:29:18 -08:00
/ * Reload M M U r e l a t e d c o n t e x t s w i t c h s t a t e a t
* schedule( ) t i m e .
*
* % o0 : page t a b l e p h y s i c a l a d d r e s s
2006-01-31 18:31:20 -08:00
* % o1 : TSB r e g i s t e r v a l u e
* % o2 : TSB v i r t u a l a d d r e s s
* % o3 : TSB m a p p i n g l o c k e d P T E
*
* We h a v e t o r u n t h i s w h o l e t h i n g w i t h i n t e r r u p t s
* disabled s o t h a t t h e c u r r e n t c p u d o e s n ' t c h a n g e
* due t o p r e e m p t i o n .
2006-01-31 18:29:18 -08:00
* /
2006-02-26 23:24:22 -08:00
.align 32
2006-01-31 18:31:20 -08:00
.globl __tsb_context_switch
__tsb_context_switch :
2006-02-26 23:24:22 -08:00
rdpr % p s t a t e , % o 5
wrpr % o 5 , P S T A T E _ I E , % p s t a t e
2006-01-31 18:29:18 -08:00
2006-01-31 18:31:20 -08:00
ldub [ % g 6 + T I _ C P U ] , % g 1
sethi % h i ( t r a p _ b l o c k ) , % g 2
sllx % g 1 , T R A P _ B L O C K _ S Z _ S H I F T , % g 1
or % g 2 , % l o ( t r a p _ b l o c k ) , % g 2
add % g 2 , % g 1 , % g 2
stx % o 0 , [ % g 2 + T R A P _ P E R _ C P U _ P G D _ P A D D R ]
2006-01-31 18:29:18 -08:00
mov T S B _ R E G , % g 1
2006-01-31 18:31:20 -08:00
stxa % o 1 , [ % g 1 ] A S I _ D M M U
2006-01-31 18:29:18 -08:00
membar #S y n c
2006-01-31 18:31:20 -08:00
stxa % o 1 , [ % g 1 ] A S I _ I M M U
2006-01-31 18:29:18 -08:00
membar #S y n c
2006-01-31 18:31:20 -08:00
brz % o 2 , 9 f
nop
2006-01-31 18:29:18 -08:00
2006-01-31 18:33:12 -08:00
sethi % h i ( s p a r c64 _ h i g h e s t _ u n l o c k e d _ t l b _ e n t ) , % o 4
mov T L B _ T A G _ A C C E S S , % g 1
lduw [ % o 4 + % l o ( s p a r c64 _ h i g h e s t _ u n l o c k e d _ t l b _ e n t ) ] , % g 2
stxa % o 2 , [ % g 1 ] A S I _ D M M U
membar #S y n c
sllx % g 2 , 3 , % g 2
stxa % o 3 , [ % g 2 ] A S I _ D T L B _ D A T A _ A C C E S S
membar #S y n c
2006-01-31 18:29:18 -08:00
9 :
2006-02-26 23:24:22 -08:00
wrpr % o 5 , % p s t a t e
2006-01-31 18:29:18 -08:00
retl
2006-01-31 18:31:20 -08:00
nop