2008-02-08 04:19:31 -08:00
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# TLB l o a d i n g f u n c t i o n s
#
# Copyright ( C ) 2 0 0 7 M a t s u s h i t a E l e c t r i c I n d u s t r i a l C o . , L t d .
# 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 .
# Modified 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 / s m p . h >
# include < a s m / i n t c t l - r e g s . h >
# include < a s m / f r a m e . i n c >
# include < a s m / p a g e . h >
# include < a s m / p g t a b l e . h >
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Instruction T L B M i s s h a n d l e r e n t r y p o i n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type itlb_ m i s s ,@function
ENTRY( i t l b _ m i s s )
# ifdef C O N F I G _ G D B S T U B
movm [ d2 ,d3 ,a2 ] ,( s p )
# else
or E P S W _ n A R ,e p s w # s w i t c h D 0 - D 3 & A 0 - A 3 t o t h e a l t e r n a t e
# register b a n k
nop
nop
nop
# endif
2010-10-27 17:28:48 +01:00
# if d e f i n e d ( C O N F I G _ E R R A T U M _ N E E D _ T O _ R E L O A D _ M M U C T R )
mov ( M M U C T R ) ,d2
mov d2 ,( M M U C T R )
# endif
and ~ E P S W _ N M I D ,e p s w
2008-02-08 04:19:31 -08:00
mov ( I P T E U ) ,d3
mov ( P T B R ) ,a2
mov d3 ,d2
and 0 x f f c00 0 0 0 ,d2
lsr 2 0 ,d2
mov ( a2 ,d2 ) ,a2 # P T D * p t d = P G D [ a d d r 31 . . 2 2 ]
btst _ P A G E _ V A L I D ,a2
beq i t l b _ m i s s _ f a u l t # j u m p i f d o e s n ' t p o i n t a n y w h e r e
and ~ ( P A G E _ S I Z E - 1 ) ,a2
mov d3 ,d2
and 0 x00 3 f f00 0 ,d2
lsr 1 0 ,d2
add d2 ,a2
mov ( a2 ) ,d2 # g e t p t e f r o m P T D [ a d d r 21 . . 1 2 ]
btst _ P A G E _ V A L I D ,d2
beq i t l b _ m i s s _ f a u l t # j u m p i f d o e s n ' t p o i n t t o a p a g e
# ( might b e a s w a p i d )
2010-10-27 17:28:50 +01:00
# if ( ( _ P A G E _ A C C E S S E D & 0 x f f f f f f00 ) = = 0 )
2008-02-08 04:19:31 -08:00
bset _ P A G E _ A C C E S S E D ,( 0 ,a2 )
2010-10-27 17:28:50 +01:00
# elif ( ( _ P A G E _ A C C E S S E D & 0 x f f f f00 f f ) = = 0 )
bset + ( _ P A G E _ A C C E S S E D > > 8 ) ,( 1 ,a2 )
# else
# error " _ P A G E _ A C C E S S E D v a l u e i s o u t o f r a n g e "
# endif
and ~ x P T E L 2 _ U N U S E D 1 ,d2
2008-02-08 04:19:31 -08:00
itlb_miss_set :
2010-10-27 17:28:50 +01:00
mov d2 ,( I P T E L 2 ) # c h a n g e t h e T L B
2008-02-08 04:19:31 -08:00
# ifdef C O N F I G _ G D B S T U B
movm ( s p ) ,[ d2 ,d3 ,a2 ]
# endif
rti
itlb_miss_fault :
mov _ P A G E _ V A L I D ,d2 # f o r c e a d d r e s s e r r o r h a n d l e r t o b e
# invoked
bra i t l b _ m i s s _ s e t
.size itlb_ m i s s , . - i t l b _ m i s s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Data T L B M i s s h a n d l e r e n t r y p o i n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type dtlb_ m i s s ,@function
ENTRY( d t l b _ m i s s )
# ifdef C O N F I G _ G D B S T U B
movm [ d2 ,d3 ,a2 ] ,( s p )
# else
or E P S W _ n A R ,e p s w # s w i t c h D 0 - D 3 & A 0 - A 3 t o t h e a l t e r n a t e
# register b a n k
nop
nop
nop
# endif
2010-10-27 17:28:48 +01:00
# if d e f i n e d ( C O N F I G _ E R R A T U M _ N E E D _ T O _ R E L O A D _ M M U C T R )
mov ( M M U C T R ) ,d2
mov d2 ,( M M U C T R )
# endif
and ~ E P S W _ N M I D ,e p s w
2008-02-08 04:19:31 -08:00
mov ( D P T E U ) ,d3
mov ( P T B R ) ,a2
mov d3 ,d2
and 0 x f f c00 0 0 0 ,d2
lsr 2 0 ,d2
mov ( a2 ,d2 ) ,a2 # P T D * p t d = P G D [ a d d r 31 . . 2 2 ]
btst _ P A G E _ V A L I D ,a2
beq d t l b _ m i s s _ f a u l t # j u m p i f d o e s n ' t p o i n t a n y w h e r e
and ~ ( P A G E _ S I Z E - 1 ) ,a2
mov d3 ,d2
and 0 x00 3 f f00 0 ,d2
lsr 1 0 ,d2
add d2 ,a2
mov ( a2 ) ,d2 # g e t p t e f r o m P T D [ a d d r 21 . . 1 2 ]
btst _ P A G E _ V A L I D ,d2
beq d t l b _ m i s s _ f a u l t # j u m p i f d o e s n ' t p o i n t t o a p a g e
# ( might b e a s w a p i d )
2010-10-27 17:28:50 +01:00
# if ( ( _ P A G E _ A C C E S S E D & 0 x f f f f f f00 ) = = 0 )
2008-02-08 04:19:31 -08:00
bset _ P A G E _ A C C E S S E D ,( 0 ,a2 )
2010-10-27 17:28:50 +01:00
# elif ( ( _ P A G E _ A C C E S S E D & 0 x f f f f00 f f ) = = 0 )
bset + ( _ P A G E _ A C C E S S E D > > 8 ) ,( 1 ,a2 )
# else
# error " _ P A G E _ A C C E S S E D v a l u e i s o u t o f r a n g e "
# endif
and ~ x P T E L 2 _ U N U S E D 1 ,d2
2008-02-08 04:19:31 -08:00
dtlb_miss_set :
2010-10-27 17:28:50 +01:00
mov d2 ,( D P T E L 2 ) # c h a n g e t h e T L B
2008-02-08 04:19:31 -08:00
# ifdef C O N F I G _ G D B S T U B
movm ( s p ) ,[ d2 ,d3 ,a2 ]
# endif
rti
dtlb_miss_fault :
mov _ P A G E _ V A L I D ,d2 # f o r c e a d d r e s s e r r o r h a n d l e r t o b e
# invoked
bra d t l b _ m i s s _ s e t
.size dtlb_ m i s s , . - d t l b _ m i s s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Instruction T L B A d d r e s s E r r o r h a n d l e r e n t r y p o i n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type itlb_ a e r r o r ,@function
ENTRY( i t l b _ a e r r o r )
add - 4 ,s p
SAVE_ A L L
2010-10-27 17:28:48 +01:00
# if d e f i n e d ( C O N F I G _ E R R A T U M _ N E E D _ T O _ R E L O A D _ M M U C T R )
mov ( M M U C T R ) ,d1
mov d1 ,( M M U C T R )
# endif
and ~ E P S W _ N M I D ,e p s w
2008-02-08 04:19:31 -08:00
add - 4 ,s p # n e e d t o p a s s t h r e e p a r a m s
# calculate t h e f a u l t c o d e
movhu ( M M U F C R _ I F C ) ,d1
or 0 x00 0 1 0 0 0 0 ,d1 # i t ' s a n i n s t r u c t i o n f e t c h
# determine t h e p a g e a d d r e s s
2010-10-27 17:28:50 +01:00
mov ( I P T E U ) ,d0
2008-02-08 04:19:31 -08:00
and P A G E _ M A S K ,d0
mov d0 ,( 1 2 ,s p )
clr d0
2010-10-27 17:28:50 +01:00
mov d0 ,( I P T E L 2 )
2008-02-08 04:19:31 -08:00
or E P S W _ I E ,e p s w
mov f p ,d0
call d o _ p a g e _ f a u l t [ ] ,0 # d o _ p a g e _ f a u l t ( r e g s , c o d e , a d d r
jmp r e t _ f r o m _ e x c e p t i o n
.size itlb_ a e r r o r , . - i t l b _ a e r r o r
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Data T L B A d d r e s s E r r o r h a n d l e r e n t r y p o i n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type dtlb_ a e r r o r ,@function
ENTRY( d t l b _ a e r r o r )
add - 4 ,s p
SAVE_ A L L
2010-10-27 17:28:48 +01:00
# if d e f i n e d ( C O N F I G _ E R R A T U M _ N E E D _ T O _ R E L O A D _ M M U C T R )
mov ( M M U C T R ) ,d1
mov d1 ,( M M U C T R )
# endif
2008-02-08 04:19:31 -08:00
add - 4 ,s p # n e e d t o p a s s t h r e e p a r a m s
2010-10-27 17:28:48 +01:00
and ~ E P S W _ N M I D ,e p s w
2008-02-08 04:19:31 -08:00
# calculate t h e f a u l t c o d e
movhu ( M M U F C R _ D F C ) ,d1
# determine t h e p a g e a d d r e s s
mov ( D P T E U ) ,a2
mov a2 ,d0
and P A G E _ M A S K ,d0
mov d0 ,( 1 2 ,s p )
clr d0
2010-10-27 17:28:50 +01:00
mov d0 ,( D P T E L 2 )
2008-02-08 04:19:31 -08:00
or E P S W _ I E ,e p s w
mov f p ,d0
call d o _ p a g e _ f a u l t [ ] ,0 # d o _ p a g e _ f a u l t ( r e g s , c o d e , a d d r
jmp r e t _ f r o m _ e x c e p t i o n
.size dtlb_ a e r r o r , . - d t l b _ a e r r o r