2005-04-17 02:20:36 +04:00
/ * $ Id : entry. S ,v 1 . 1 4 4 2 0 0 2 / 0 2 / 0 9 1 9 : 4 9 : 3 0 d a v e m E x p $
* arch/ s p a r c64 / k e r n e l / e n t r y . S : S p a r c64 t r a p l o w - l e v e l e n t r y p o i n t s .
*
* Copyright ( C ) 1 9 9 5 ,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 6 E d d i e C . D o s t ( e c d @skynet.be)
* Copyright ( C ) 1 9 9 6 M i g u e l d e I c a z a ( m i g u e l @nuclecu.unam.mx)
* Copyright ( C ) 1 9 9 6 ,9 8 ,9 9 J a k u b J e l i n e k ( j j @sunsite.mff.cuni.cz)
* /
# include < l i n u x / c o n f i g . h >
# include < l i n u x / e r r n o . h >
# include < a s m / h e a d . h >
# include < a s m / a s i . h >
# include < a s m / s m p . 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 i g n a l . h >
# include < a s m / p g t a b l e . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / v i s a s m . h >
# include < a s m / e s t a t e . h >
# include < a s m / a u x i o . h >
# define c u r p t r g 6
# define N R _ S Y S C A L L S 2 8 4 / * E a c h O S i s d i f f e r e n t . . . * /
.text
.align 32
.globl sparc64_vpte_patchme1
.globl sparc64_vpte_patchme2
/ *
* On a s e c o n d l e v e l v p t e m i s s , c h e c k w h e t h e r t h e o r i g i n a l f a u l t i s t o t h e O B P
* range ( n o t e t h a t t h i s i s o n l y p o s s i b l e f o r i n s t r u c t i o n m i s s , d a t a m i s s e s t o
* obp r a n g e d o n o t u s e v p t e ) . I f s o , g o b a c k d i r e c t l y t o t h e f a u l t i n g a d d r e s s .
* This i s b e c a u s e w e w a n t t o r e a d t h e t p c , o t h e r w i s e w e h a v e n o w a y o f k n o w i n g
* the 8 k a l i g n e d f a u l t i n g a d d r e s s i f w e a r e u s i n g > 8 k k e r n e l p a g e s i z e . T h i s
* also e n s u r e s n o v p t e r a n g e a d d r e s s e s a r e d r o p p e d i n t o t l b w h i l e o b p i s
* executing ( s e e i n h e r i t _ l o c k e d _ p r o m _ m a p p i n g s ( ) r a n t ) .
* /
sparc64_vpte_nucleus :
/* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
mov 0 x f , % g 5
sllx % g 5 , 2 8 , % g 5
/* Is addr >= LOW_OBP_ADDRESS? */
cmp % g 4 , % g 5
blu,p n % x c c , s p a r c64 _ v p t e _ p a t c h m e 1
mov 0 x1 , % g 5
/* Load 0x100000000, which is HI_OBP_ADDRESS. */
sllx % g 5 , 3 2 , % g 5
/* Is addr < HI_OBP_ADDRESS? */
cmp % g 4 , % g 5
blu,p n % x c c , o b p _ i a d d r _ p a t c h
nop
/* These two instructions are patched by paginig_init(). */
sparc64_vpte_patchme1 :
sethi % h i ( 0 ) , % g 5
sparc64_vpte_patchme2 :
or % g 5 , % l o ( 0 ) , % g 5
/* With kernel PGD in %g5, branch back into dtlb_backend. */
ba,p t % x c c , s p a r c64 _ k p t e _ c o n t i n u e
andn % g 1 , 0 x3 , % g 1 / * F i n i s h P M D o f f s e t a d j u s t m e n t . * /
vpte_noent :
/ * Restore p r e v i o u s T A G _ A C C E S S , % g 5 i s z e r o , a n d w e w i l l
* skip o v e r t h e t r a p i n s t r u c t i o n s o t h a t t h e t o p l e v e l
* TLB m i s s h a n d l e r w i l l t h i n g t h i s % g 5 v a l u e i s j u s t a n
* invalid P T E , t h u s b r a n c h i n g t o f u l l f a u l t p r o c e s s i n g .
* /
mov T L B _ S F S R , % g 1
stxa % g 4 , [ % g 1 + % g 1 ] A S I _ D M M U
done
.globl obp_iaddr_patch
obp_iaddr_patch :
/* These two instructions patched by inherit_prom_mappings(). */
sethi % h i ( 0 ) , % g 5
or % g 5 , % l o ( 0 ) , % g 5
/* Behave as if we are at TL0. */
wrpr % g 0 , 1 , % t l
rdpr % t p c , % g 4 / * F i n d o r i g i n a l f a u l t i n g i a d d r * /
srlx % g 4 , 1 3 , % g 4 / * T h r o w o u t c o n t e x t b i t s * /
sllx % g 4 , 1 3 , % g 4 / * g 4 h a s v p n + c t x0 n o w * /
/* Restore previous TAG_ACCESS. */
mov T L B _ S F S R , % g 1
stxa % g 4 , [ % g 1 + % g 1 ] A S I _ I M M U
/* Get PMD offset. */
srlx % g 4 , 2 3 , % g 6
and % g 6 , 0 x7 f f , % g 6
sllx % g 6 , 2 , % g 6
/* Load PMD, is it valid? */
lduwa [ % g 5 + % g 6 ] A S I _ P H Y S _ U S E _ E C , % g 5
brz,p n % g 5 , l o n g p a t h
sllx % g 5 , 1 1 , % g 5
/* Get PTE offset. */
srlx % g 4 , 1 3 , % g 6
and % g 6 , 0 x3 f f , % g 6
sllx % g 6 , 3 , % g 6
/* Load PTE. */
ldxa [ % g 5 + % g 6 ] A S I _ P H Y S _ U S E _ E C , % g 5
brgez,p n % g 5 , l o n g p a t h
nop
/* TLB load and return from trap. */
stxa % g 5 , [ % g 0 ] A S I _ I T L B _ D A T A _ I N
retry
.globl obp_daddr_patch
obp_daddr_patch :
/* These two instructions patched by inherit_prom_mappings(). */
sethi % h i ( 0 ) , % g 5
or % g 5 , % l o ( 0 ) , % g 5
/* Get PMD offset. */
srlx % g 4 , 2 3 , % g 6
and % g 6 , 0 x7 f f , % g 6
sllx % g 6 , 2 , % g 6
/* Load PMD, is it valid? */
lduwa [ % g 5 + % g 6 ] A S I _ P H Y S _ U S E _ E C , % g 5
brz,p n % g 5 , l o n g p a t h
sllx % g 5 , 1 1 , % g 5
/* Get PTE offset. */
srlx % g 4 , 1 3 , % g 6
and % g 6 , 0 x3 f f , % g 6
sllx % g 6 , 3 , % g 6
/* Load PTE. */
ldxa [ % g 5 + % g 6 ] A S I _ P H Y S _ U S E _ E C , % g 5
brgez,p n % g 5 , l o n g p a t h
nop
/* TLB load and return from trap. */
stxa % g 5 , [ % g 0 ] A S I _ D T L B _ D A T A _ I N
retry
/ *
* On a f i r s t l e v e l d a t a m i s s , c h e c k w h e t h e r t h i s i s t o t h e O B P r a n g e ( n o t e
* that s u c h a c c e s s e s c a n b e m a d e b y p r o m , a s w e l l a s b y k e r n e l u s i n g
* prom_ g e t p r o p e r t y o n " a d d r e s s " ) , a n d i f s o , d o n o t u s e v p t e a c c e s s . . .
* rather, u s e i n f o r m a t i o n s a v e d d u r i n g i n h e r i t _ p r o m _ m a p p i n g s ( ) u s i n g 8 k
* pagesize.
* /
kvmap :
/* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
mov 0 x f , % g 5
sllx % g 5 , 2 8 , % g 5
/* Is addr >= LOW_OBP_ADDRESS? */
cmp % g 4 , % g 5
blu,p n % x c c , v m a l l o c _ a d d r
mov 0 x1 , % g 5
/* Load 0x100000000, which is HI_OBP_ADDRESS. */
sllx % g 5 , 3 2 , % g 5
/* Is addr < HI_OBP_ADDRESS? */
cmp % g 4 , % g 5
blu,p n % x c c , o b p _ d a d d r _ p a t c h
nop
vmalloc_addr :
/* If we get here, a vmalloc addr accessed, load kernel VPTE. */
ldxa [ % g 3 + % g 6 ] A S I _ N , % g 5
brgez,p n % g 5 , l o n g p a t h
nop
/* PTE is valid, load into TLB and return from trap. */
stxa % g 5 , [ % g 0 ] A S I _ D T L B _ D A T A _ I N ! R e l o a d T L B
retry
/* This is trivial with the new code... */
.globl do_fpdis
do_fpdis :
sethi % h i ( T S T A T E _ P E F ) , % g 4 ! I E U 0
rdpr % t s t a t e , % g 5
andcc % g 5 , % g 4 , % g 0
be,p t % x c c , 1 f
nop
rd % f p r s , % g 5
andcc % g 5 , F P R S _ F E F , % g 0
be,p t % x c c , 1 f
nop
/* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
add % g 0 , % g 0 , % g 0
ba,a ,p t % x c c , r t r a p _ c l r _ l 6
1 : ldub [ % g 6 + T I _ F P S A V E D ] , % g 5 ! L o a d G r o u p
wr % g 0 , F P R S _ F E F , % f p r s ! L S U G r o u p + 4 b u b b l e s
andcc % g 5 , F P R S _ F E F , % g 0 ! I E U 1 G r o u p
be,a ,p t % i c c , 1 f ! C T I
clr % g 7 ! I E U 0
ldx [ % g 6 + T I _ G S R ] , % g 7 ! L o a d G r o u p
1 : andcc % g 5 , F P R S _ D L , % g 0 ! I E U 1
bne,p n % i c c , 2 f ! C T I
fzero % f0 ! F P A
andcc % g 5 , F P R S _ D U , % g 0 ! I E U 1 G r o u p
bne,p n % i c c , 1 f ! C T I
fzero % f2 ! F P A
faddd % f0 , % f2 , % f4
fmuld % f0 , % f2 , % f6
faddd % f0 , % f2 , % f8
fmuld % f0 , % f2 , % f10
faddd % f0 , % f2 , % f12
fmuld % f0 , % f2 , % f14
faddd % f0 , % f2 , % f16
fmuld % f0 , % f2 , % f18
faddd % f0 , % f2 , % f20
fmuld % f0 , % f2 , % f22
faddd % f0 , % f2 , % f24
fmuld % f0 , % f2 , % f26
faddd % f0 , % f2 , % f28
fmuld % f0 , % f2 , % f30
faddd % f0 , % f2 , % f32
fmuld % f0 , % f2 , % f34
faddd % f0 , % f2 , % f36
fmuld % f0 , % f2 , % f38
faddd % f0 , % f2 , % f40
fmuld % f0 , % f2 , % f42
faddd % f0 , % f2 , % f44
fmuld % f0 , % f2 , % f46
faddd % f0 , % f2 , % f48
fmuld % f0 , % f2 , % f50
faddd % f0 , % f2 , % f52
fmuld % f0 , % f2 , % f54
faddd % f0 , % f2 , % f56
fmuld % f0 , % f2 , % f58
b,p t % x c c , f p d i s _ e x i t 2
faddd % f0 , % f2 , % f60
1 : mov S E C O N D A R Y _ C O N T E X T , % g 3
add % g 6 , T I _ F P R E G S + 0 x80 , % g 1
faddd % f0 , % f2 , % f4
fmuld % f0 , % f2 , % f6
ldxa [ % g 3 ] A S I _ D M M U , % g 5
cplus_fptrap_insn_1 :
sethi % h i ( 0 ) , % g 2
stxa % g 2 , [ % g 3 ] A S I _ D M M U
membar #S y n c
add % g 6 , T I _ F P R E G S + 0 x c0 , % g 2
faddd % f0 , % f2 , % f8
fmuld % f0 , % f2 , % f10
ldda [ % g 1 ] A S I _ B L K _ S , % f32 ! g r r r , w h e r e i s A S I _ B L K _ N U C L E U S 8 - (
ldda [ % g 2 ] A S I _ B L K _ S , % f48
faddd % f0 , % f2 , % f12
fmuld % f0 , % f2 , % f14
faddd % f0 , % f2 , % f16
fmuld % f0 , % f2 , % f18
faddd % f0 , % f2 , % f20
fmuld % f0 , % f2 , % f22
faddd % f0 , % f2 , % f24
fmuld % f0 , % f2 , % f26
faddd % f0 , % f2 , % f28
fmuld % f0 , % f2 , % f30
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-28 02:42:04 +04:00
membar #S y n c
2005-04-17 02:20:36 +04:00
b,p t % x c c , f p d i s _ e x i t
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-28 02:42:04 +04:00
nop
2005-04-17 02:20:36 +04:00
2 : andcc % g 5 , F P R S _ D U , % g 0
bne,p t % i c c , 3 f
fzero % f32
mov S E C O N D A R Y _ C O N T E X T , % g 3
fzero % f34
ldxa [ % g 3 ] A S I _ D M M U , % g 5
add % g 6 , T I _ F P R E G S , % g 1
cplus_fptrap_insn_2 :
sethi % h i ( 0 ) , % g 2
stxa % g 2 , [ % g 3 ] A S I _ D M M U
membar #S y n c
add % g 6 , T I _ F P R E G S + 0 x40 , % g 2
faddd % f32 , % f34 , % f36
fmuld % f32 , % f34 , % f38
ldda [ % g 1 ] A S I _ B L K _ S , % f0 ! g r r r , w h e r e i s A S I _ B L K _ N U C L E U S 8 - (
ldda [ % g 2 ] A S I _ B L K _ S , % f16
faddd % f32 , % f34 , % f40
fmuld % f32 , % f34 , % f42
faddd % f32 , % f34 , % f44
fmuld % f32 , % f34 , % f46
faddd % f32 , % f34 , % f48
fmuld % f32 , % f34 , % f50
faddd % f32 , % f34 , % f52
fmuld % f32 , % f34 , % f54
faddd % f32 , % f34 , % f56
fmuld % f32 , % f34 , % f58
faddd % f32 , % f34 , % f60
fmuld % f32 , % f34 , % f62
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-28 02:42:04 +04:00
membar #S y n c
2005-04-17 02:20:36 +04:00
ba,p t % x c c , f p d i s _ e x i t
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-28 02:42:04 +04:00
nop
2005-04-17 02:20:36 +04:00
3 : mov S E C O N D A R Y _ C O N T E X T , % g 3
add % g 6 , T I _ F P R E G S , % g 1
ldxa [ % g 3 ] A S I _ D M M U , % g 5
cplus_fptrap_insn_3 :
sethi % h i ( 0 ) , % g 2
stxa % g 2 , [ % g 3 ] A S I _ D M M U
membar #S y n c
mov 0 x40 , % g 2
ldda [ % g 1 ] A S I _ B L K _ S , % f0 ! g r r r , w h e r e i s A S I _ B L K _ N U C L E U S 8 - (
ldda [ % g 1 + % g 2 ] A S I _ B L K _ S , % f16
add % g 1 , 0 x80 , % g 1
ldda [ % g 1 ] A S I _ B L K _ S , % f32
ldda [ % g 1 + % g 2 ] A S I _ B L K _ S , % f48
membar #S y n c
fpdis_exit :
stxa % g 5 , [ % g 3 ] A S I _ D M M U
membar #S y n c
fpdis_exit2 :
wr % g 7 , 0 , % g s r
ldx [ % g 6 + T I _ X F S R ] , % f s r
rdpr % t s t a t e , % g 3
or % g 3 , % g 4 , % g 3 ! a n a l . . .
wrpr % g 3 , % t s t a t e
wr % g 0 , F P R S _ F E F , % f p r s ! c l e a n D U / D L b i t s
retry
.align 32
fp_other_bounce :
call d o _ f p o t h e r
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl do_fpother_check_fitos
.align 32
do_fpother_check_fitos :
sethi % h i ( f p _ o t h e r _ b o u n c e - 4 ) , % g 7
or % g 7 , % l o ( f p _ o t h e r _ b o u n c e - 4 ) , % g 7
/ * NOTE : Need t o p r e s e r v e % g 7 u n t i l w e f u l l y c o m m i t
* to t h e f i t o s f i x u p .
* /
stx % f s r , [ % g 6 + T I _ X F S R ]
rdpr % t s t a t e , % g 3
andcc % g 3 , T S T A T E _ P R I V , % g 0
bne,p n % x c c , d o _ f p t r a p _ a f t e r _ f s r
nop
ldx [ % g 6 + T I _ X F S R ] , % g 3
srlx % g 3 , 1 4 , % g 1
and % g 1 , 7 , % g 1
cmp % g 1 , 2 ! U n f i n i s h e d F P - O P
bne,p n % x c c , d o _ f p t r a p _ a f t e r _ f s r
sethi % h i ( 1 < < 2 3 ) , % g 1 ! I n e x a c t
andcc % g 3 , % g 1 , % g 0
bne,p n % x c c , d o _ f p t r a p _ a f t e r _ f s r
rdpr % t p c , % g 1
lduwa [ % g 1 ] A S I _ A I U P , % g 3 ! T h i s c a n n o t e v e r f a i l
# define F I T O S _ M A S K 0 x c1 f83 f e 0
# define F I T O S _ C O M P A R E 0 x81 a01 8 8 0
sethi % h i ( F I T O S _ M A S K ) , % g 1
or % g 1 , % l o ( F I T O S _ M A S K ) , % g 1
and % g 3 , % g 1 , % g 1
sethi % h i ( F I T O S _ C O M P A R E ) , % g 2
or % g 2 , % l o ( F I T O S _ C O M P A R E ) , % g 2
cmp % g 1 , % g 2
bne,p n % x c c , d o _ f p t r a p _ a f t e r _ f s r
nop
std % f62 , [ % g 6 + T I _ F P R E G S + ( 6 2 * 4 ) ]
sethi % h i ( f i t o s _ t a b l e _ 1 ) , % g 1
and % g 3 , 0 x1 f , % g 2
or % g 1 , % l o ( f i t o s _ t a b l e _ 1 ) , % g 1
sllx % g 2 , 2 , % g 2
jmpl % g 1 + % g 2 , % g 0
ba,p t % x c c , f i t o s _ e m u l _ c o n t i n u e
fitos_table_1 :
fitod % f0 , % f62
fitod % f1 , % f62
fitod % f2 , % f62
fitod % f3 , % f62
fitod % f4 , % f62
fitod % f5 , % f62
fitod % f6 , % f62
fitod % f7 , % f62
fitod % f8 , % f62
fitod % f9 , % f62
fitod % f10 , % f62
fitod % f11 , % f62
fitod % f12 , % f62
fitod % f13 , % f62
fitod % f14 , % f62
fitod % f15 , % f62
fitod % f16 , % f62
fitod % f17 , % f62
fitod % f18 , % f62
fitod % f19 , % f62
fitod % f20 , % f62
fitod % f21 , % f62
fitod % f22 , % f62
fitod % f23 , % f62
fitod % f24 , % f62
fitod % f25 , % f62
fitod % f26 , % f62
fitod % f27 , % f62
fitod % f28 , % f62
fitod % f29 , % f62
fitod % f30 , % f62
fitod % f31 , % f62
fitos_emul_continue :
sethi % h i ( f i t o s _ t a b l e _ 2 ) , % g 1
srl % g 3 , 2 5 , % g 2
or % g 1 , % l o ( f i t o s _ t a b l e _ 2 ) , % g 1
and % g 2 , 0 x1 f , % g 2
sllx % g 2 , 2 , % g 2
jmpl % g 1 + % g 2 , % g 0
ba,p t % x c c , f i t o s _ e m u l _ f i n i
fitos_table_2 :
fdtos % f62 , % f0
fdtos % f62 , % f1
fdtos % f62 , % f2
fdtos % f62 , % f3
fdtos % f62 , % f4
fdtos % f62 , % f5
fdtos % f62 , % f6
fdtos % f62 , % f7
fdtos % f62 , % f8
fdtos % f62 , % f9
fdtos % f62 , % f10
fdtos % f62 , % f11
fdtos % f62 , % f12
fdtos % f62 , % f13
fdtos % f62 , % f14
fdtos % f62 , % f15
fdtos % f62 , % f16
fdtos % f62 , % f17
fdtos % f62 , % f18
fdtos % f62 , % f19
fdtos % f62 , % f20
fdtos % f62 , % f21
fdtos % f62 , % f22
fdtos % f62 , % f23
fdtos % f62 , % f24
fdtos % f62 , % f25
fdtos % f62 , % f26
fdtos % f62 , % f27
fdtos % f62 , % f28
fdtos % f62 , % f29
fdtos % f62 , % f30
fdtos % f62 , % f31
fitos_emul_fini :
ldd [ % g 6 + T I _ F P R E G S + ( 6 2 * 4 ) ] , % f62
done
.globl do_fptrap
.align 32
do_fptrap :
stx % f s r , [ % g 6 + T I _ X F S R ]
do_fptrap_after_fsr :
ldub [ % g 6 + T I _ F P S A V E D ] , % g 3
rd % f p r s , % g 1
or % g 3 , % g 1 , % g 3
stb % g 3 , [ % g 6 + T I _ F P S A V E D ]
rd % g s r , % g 3
stx % g 3 , [ % g 6 + T I _ G S R ]
mov S E C O N D A R Y _ C O N T E X T , % g 3
ldxa [ % g 3 ] A S I _ D M M U , % g 5
cplus_fptrap_insn_4 :
sethi % h i ( 0 ) , % g 2
stxa % g 2 , [ % g 3 ] A S I _ D M M U
membar #S y n c
add % g 6 , T I _ F P R E G S , % g 2
andcc % g 1 , F P R S _ D L , % g 0
be,p n % i c c , 4 f
mov 0 x40 , % g 3
stda % f0 , [ % g 2 ] A S I _ B L K _ S
stda % f16 , [ % g 2 + % g 3 ] A S I _ B L K _ S
andcc % g 1 , F P R S _ D U , % g 0
be,p n % i c c , 5 f
4 : add % g 2 , 1 2 8 , % g 2
stda % f32 , [ % g 2 ] A S I _ B L K _ S
stda % f48 , [ % g 2 + % g 3 ] A S I _ B L K _ S
5 : mov S E C O N D A R Y _ C O N T E X T , % g 1
membar #S y n c
stxa % g 5 , [ % g 1 ] A S I _ D M M U
membar #S y n c
ba,p t % x c c , e t r a p
wr % g 0 , 0 , % f p r s
cplus_fptrap_1 :
sethi % h i ( C T X _ C H E E T A H _ P L U S _ C T X 0 ) , % g 2
.globl cheetah_plus_patch_fpdis
cheetah_plus_patch_fpdis :
/ * We c o n f i g u r e t h e d T L B 5 1 2 _ 0 f o r 4 M B p a g e s a n d t h e
* dTLB5 1 2 _ 1 f o r 8 K p a g e s w h e n i n c o n t e x t z e r o .
* /
sethi % h i ( c p l u s _ f p t r a p _ 1 ) , % o 0
lduw [ % o 0 + % l o ( c p l u s _ f p t r a p _ 1 ) ] , % o 1
set c p l u s _ f p t r a p _ i n s n _ 1 , % o 2
stw % o 1 , [ % o 2 ]
flush % o 2
set c p l u s _ f p t r a p _ i n s n _ 2 , % o 2
stw % o 1 , [ % o 2 ]
flush % o 2
set c p l u s _ f p t r a p _ i n s n _ 3 , % o 2
stw % o 1 , [ % o 2 ]
flush % o 2
set c p l u s _ f p t r a p _ i n s n _ 4 , % o 2
stw % o 1 , [ % o 2 ]
flush % o 2
retl
nop
/ * The r e g i s t e r s f o r c r o s s c a l l s w i l l b e :
*
* DATA 0 : [ l o w 3 2 - b i t s ] A d d r e s s o f f u n c t i o n t o c a l l , j m p t o t h i s
* [ high 3 2 - b i t s ] M M U C o n t e x t A r g u m e n t 0 , p l a c e i n % g 5
* DATA 1 : A d d r e s s A r g u m e n t 1 , p l a c e i n % g 6
* DATA 2 : A d d r e s s A r g u m e n t 2 , p l a c e i n % g 7
*
* With t h i s m e t h o d w e c a n d o m o s t o f t h e c r o s s - c a l l t l b / c a c h e
* flushing v e r y q u i c k l y .
*
* Current C P U ' s I R Q w o r k l i s t t a b l e i s l o c k e d i n t o % g 1 ,
* don' t t o u c h .
* /
.text
.align 32
.globl do_ivec
do_ivec :
mov 0 x40 , % g 3
ldxa [ % g 3 + % g 0 ] A S I _ I N T R _ R , % g 3
sethi % h i ( K E R N B A S E ) , % g 4
cmp % g 3 , % g 4
bgeu,p n % x c c , d o _ i v e c _ x c a l l
srlx % g 3 , 3 2 , % g 5
stxa % g 0 , [ % g 0 ] A S I _ I N T R _ R E C E I V E
membar #S y n c
sethi % h i ( i v e c t o r _ t a b l e ) , % g 2
sllx % g 3 , 5 , % g 3
or % g 2 , % l o ( i v e c t o r _ t a b l e ) , % g 2
add % g 2 , % g 3 , % g 3
ldub [ % g 3 + 0 x04 ] , % g 4 / * p i l * /
2005-07-05 00:24:38 +04:00
mov 1 , % g 2
2005-04-17 02:20:36 +04:00
sllx % g 2 , % g 4 , % g 2
sllx % g 4 , 2 , % g 4
2005-07-05 00:24:38 +04:00
2005-04-17 02:20:36 +04:00
lduw [ % g 6 + % g 4 ] , % g 5 / * g 5 = i r q _ w o r k ( c p u , p i l ) * /
stw % g 5 , [ % g 3 + 0 x00 ] / * b u c k e t - > i r q _ c h a i n = g 5 * /
stw % g 3 , [ % g 6 + % g 4 ] / * i r q _ w o r k ( c p u , p i l ) = b u c k e t * /
wr % g 2 , 0 x0 , % s e t _ s o f t i n t
retry
do_ivec_xcall :
mov 0 x50 , % g 1
ldxa [ % g 1 + % g 0 ] A S I _ I N T R _ R , % g 1
srl % g 3 , 0 , % g 3
2005-07-05 00:24:38 +04:00
2005-04-17 02:20:36 +04:00
mov 0 x60 , % g 7
ldxa [ % g 7 + % g 0 ] A S I _ I N T R _ R , % g 7
stxa % g 0 , [ % g 0 ] A S I _ I N T R _ R E C E I V E
membar #S y n c
ba,p t % x c c , 1 f
nop
.align 32
1 : jmpl % g 3 , % g 0
nop
.globl save_alternate_globals
save_alternate_globals : /* %o0 = save_area */
rdpr % p s t a t e , % o 5
andn % o 5 , P S T A T E _ I E , % o 1
wrpr % o 1 , P S T A T E _ A G , % p s t a t e
stx % g 0 , [ % o 0 + 0 x00 ]
stx % g 1 , [ % o 0 + 0 x08 ]
stx % g 2 , [ % o 0 + 0 x10 ]
stx % g 3 , [ % o 0 + 0 x18 ]
stx % g 4 , [ % o 0 + 0 x20 ]
stx % g 5 , [ % o 0 + 0 x28 ]
stx % g 6 , [ % o 0 + 0 x30 ]
stx % g 7 , [ % o 0 + 0 x38 ]
wrpr % o 1 , P S T A T E _ I G , % p s t a t e
stx % g 0 , [ % o 0 + 0 x40 ]
stx % g 1 , [ % o 0 + 0 x48 ]
stx % g 2 , [ % o 0 + 0 x50 ]
stx % g 3 , [ % o 0 + 0 x58 ]
stx % g 4 , [ % o 0 + 0 x60 ]
stx % g 5 , [ % o 0 + 0 x68 ]
stx % g 6 , [ % o 0 + 0 x70 ]
stx % g 7 , [ % o 0 + 0 x78 ]
wrpr % o 1 , P S T A T E _ M G , % p s t a t e
stx % g 0 , [ % o 0 + 0 x80 ]
stx % g 1 , [ % o 0 + 0 x88 ]
stx % g 2 , [ % o 0 + 0 x90 ]
stx % g 3 , [ % o 0 + 0 x98 ]
stx % g 4 , [ % o 0 + 0 x a0 ]
stx % g 5 , [ % o 0 + 0 x a8 ]
stx % g 6 , [ % o 0 + 0 x b0 ]
stx % g 7 , [ % o 0 + 0 x b8 ]
wrpr % o 5 , 0 x0 , % p s t a t e
retl
nop
.globl restore_alternate_globals
restore_alternate_globals : /* %o0 = save_area */
rdpr % p s t a t e , % o 5
andn % o 5 , P S T A T E _ I E , % o 1
wrpr % o 1 , P S T A T E _ A G , % p s t a t e
ldx [ % o 0 + 0 x00 ] , % g 0
ldx [ % o 0 + 0 x08 ] , % g 1
ldx [ % o 0 + 0 x10 ] , % g 2
ldx [ % o 0 + 0 x18 ] , % g 3
ldx [ % o 0 + 0 x20 ] , % g 4
ldx [ % o 0 + 0 x28 ] , % g 5
ldx [ % o 0 + 0 x30 ] , % g 6
ldx [ % o 0 + 0 x38 ] , % g 7
wrpr % o 1 , P S T A T E _ I G , % p s t a t e
ldx [ % o 0 + 0 x40 ] , % g 0
ldx [ % o 0 + 0 x48 ] , % g 1
ldx [ % o 0 + 0 x50 ] , % g 2
ldx [ % o 0 + 0 x58 ] , % g 3
ldx [ % o 0 + 0 x60 ] , % g 4
ldx [ % o 0 + 0 x68 ] , % g 5
ldx [ % o 0 + 0 x70 ] , % g 6
ldx [ % o 0 + 0 x78 ] , % g 7
wrpr % o 1 , P S T A T E _ M G , % p s t a t e
ldx [ % o 0 + 0 x80 ] , % g 0
ldx [ % o 0 + 0 x88 ] , % g 1
ldx [ % o 0 + 0 x90 ] , % g 2
ldx [ % o 0 + 0 x98 ] , % g 3
ldx [ % o 0 + 0 x a0 ] , % g 4
ldx [ % o 0 + 0 x a8 ] , % g 5
ldx [ % o 0 + 0 x b0 ] , % g 6
ldx [ % o 0 + 0 x b8 ] , % g 7
wrpr % o 5 , 0 x0 , % p s t a t e
retl
nop
.globl getcc, s e t c c
getcc :
ldx [ % o 0 + P T _ V 9 _ T S T A T E ] , % o 1
srlx % o 1 , 3 2 , % o 1
and % o 1 , 0 x f , % o 1
retl
stx % o 1 , [ % o 0 + P T _ V 9 _ G 1 ]
setcc :
ldx [ % o 0 + P T _ V 9 _ T S T A T E ] , % o 1
ldx [ % o 0 + P T _ V 9 _ G 1 ] , % o 2
or % g 0 , % u l o ( T S T A T E _ I C C ) , % o 3
sllx % o 3 , 3 2 , % o 3
andn % o 1 , % o 3 , % o 1
sllx % o 2 , 3 2 , % o 2
and % o 2 , % o 3 , % o 2
or % o 1 , % o 2 , % o 1
retl
stx % o 1 , [ % o 0 + P T _ V 9 _ T S T A T E ]
.globl utrap, u t r a p _ i l l
utrap : brz,p n % g 1 , e t r a p
nop
save % s p , - 1 2 8 , % s p
rdpr % t s t a t e , % l 6
rdpr % c w p , % l 7
andn % l 6 , T S T A T E _ C W P , % l 6
wrpr % l 6 , % l 7 , % t s t a t e
rdpr % t p c , % l 6
rdpr % t n p c , % l 7
wrpr % g 1 , 0 , % t n p c
done
utrap_ill :
call b a d _ t r a p
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
/* XXX Here is stuff we still need to write... -DaveM XXX */
.globl netbsd_syscall
netbsd_syscall :
retl
nop
.globl __do_data_access_exception
.globl __do_data_access_exception_tl1
__do_data_access_exception_tl1 :
rdpr % p s t a t e , % g 4
wrpr % g 4 , P S T A T E _ M G | P S T A T E _ A G , % p s t a t e
mov T L B _ S F S R , % g 3
mov D M M U _ S F A R , % g 5
ldxa [ % g 3 ] A S I _ D M M U , % g 4 ! G e t S F S R
ldxa [ % g 5 ] A S I _ D M M U , % g 5 ! G e t S F A R
stxa % g 0 , [ % g 3 ] A S I _ D M M U ! C l e a r S F S R . F a u l t V a l i d b i t
membar #S y n c
ba,p t % x c c , w i n f i x _ d a x
rdpr % t p c , % g 3
__do_data_access_exception :
rdpr % p s t a t e , % g 4
wrpr % g 4 , P S T A T E _ M G | P S T A T E _ A G , % p s t a t e
mov T L B _ S F S R , % g 3
mov D M M U _ S F A R , % g 5
ldxa [ % g 3 ] A S I _ D M M U , % g 4 ! G e t S F S R
ldxa [ % g 5 ] A S I _ D M M U , % g 5 ! G e t S F A R
stxa % g 0 , [ % g 3 ] A S I _ D M M U ! C l e a r S F S R . F a u l t V a l i d b i t
membar #S y n c
sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call d a t a _ a c c e s s _ e x c e p t i o n
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl __do_instruction_access_exception
.globl __do_instruction_access_exception_tl1
__do_instruction_access_exception_tl1 :
rdpr % p s t a t e , % g 4
wrpr % g 4 , P S T A T E _ M G | P S T A T E _ A G , % p s t a t e
mov T L B _ S F S R , % g 3
2005-08-29 23:44:40 +04:00
ldxa [ % g 3 ] A S I _ I M M U , % g 4 ! G e t S F S R
rdpr % t p c , % g 5 ! I M M U h a s n o S F A R , u s e T P C
2005-04-17 02:20:36 +04:00
stxa % g 0 , [ % g 3 ] A S I _ I M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p t l 1
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call i n s t r u c t i o n _ a c c e s s _ e x c e p t i o n _ t l 1
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
__do_instruction_access_exception :
rdpr % p s t a t e , % g 4
wrpr % g 4 , P S T A T E _ M G | P S T A T E _ A G , % p s t a t e
mov T L B _ S F S R , % g 3
2005-08-29 23:44:40 +04:00
ldxa [ % g 3 ] A S I _ I M M U , % g 4 ! G e t S F S R
rdpr % t p c , % g 5 ! I M M U h a s n o S F A R , u s e T P C
2005-04-17 02:20:36 +04:00
stxa % g 0 , [ % g 3 ] A S I _ I M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call i n s t r u c t i o n _ a c c e s s _ e x c e p t i o n
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
/ * This i s t h e t r a p h a n d l e r e n t r y p o i n t f o r E C C c o r r e c t a b l e
* errors. T h e y a r e c o r r e c t e d , b u t w e l i s t e n f o r t h e t r a p
* so t h a t t h e e v e n t c a n b e l o g g e d .
*
* Disrupting e r r o r s a r e e i t h e r :
* 1 ) single- b i t E C C e r r o r s d u r i n g U D B r e a d s t o s y s t e m
* memory
* 2 ) data p a r i t y e r r o r s d u r i n g w r i t e - b a c k e v e n t s
*
* As f a r a s I c a n m a k e o u t f r o m t h e m a n u a l , t h e C E E t r a p
* is o n l y f o r c o r r e c t a b l e e r r o r s d u r i n g m e m o r y r e a d
* accesses b y t h e f r o n t - e n d o f t h e p r o c e s s o r .
*
* The c o d e b e l o w i s o n l y f o r t r a p l e v e l 1 C E E e v e n t s ,
* as i t i s t h e o n l y s i t u a t i o n w h e r e w e c a n s a f e l y r e c o r d
* and l o g . F o r t r a p l e v e l > 1 w e j u s t c l e a r t h e C E b i t
* in t h e A F S R a n d r e t u r n .
* /
/ * Our t r a p h a n d l i n g i n f r a s t r u c t u r e a l l o w s u s t o p r e s e r v e
* two 6 4 - b i t v a l u e s d u r i n g e t r a p f o r a r g u m e n t s t o
* subsequent C c o d e . T h e r e f o r e w e e n c o d e t h e i n f o r m a t i o n
* as f o l l o w s :
*
* value 1 ) F u l l 6 4 - b i t s o f A F A R
* value 2 ) L o w 3 3 - b i t s o f A F S R , t h e n b i t s 3 3 - - > 4 2
* are U D B L e r r o r s t a t u s a n d b i t s 4 3 - - > 5 2
* are U D B H e r r o r s t a t u s
* /
.align 64
.globl cee_trap
cee_trap :
ldxa [ % g 0 ] A S I _ A F S R , % g 1 ! R e a d A F S R
ldxa [ % g 0 ] A S I _ A F A R , % g 2 ! R e a d A F A R
sllx % g 1 , 3 1 , % g 1 ! C l e a r r e s e r v e d b i t s
srlx % g 1 , 3 1 , % g 1 ! i n A F S R
/ * NOTE : UltraSparc- I / I I h a v e h i g h a n d l o w U D B e r r o r
* registers, c o r r e s p o n d i n g t o t h e t w o U D B u n i t s
* present o n t h o s e c h i p s . U l t r a S p a r c - I I i o n l y
* has a s i n g l e U D B , c a l l e d " S D B " i n t h e m a n u a l .
* For I I i t h e u p p e r U D B r e g i s t e r a l w a y s r e a d s
* as z e r o s o f o r o u r p u r p o s e s t h i n g s w i l l j u s t
* work w i t h t h e c h e c k s b e l o w .
* /
ldxa [ % g 0 ] A S I _ U D B L _ E R R O R _ R , % g 3 ! R e a d U D B - L o w e r r o r s t a t u s
andcc % g 3 , ( 1 < < 8 ) , % g 4 ! C h e c k C E b i t
sllx % g 3 , ( 6 4 - 1 0 ) , % g 3 ! C l e a r r e s e r v e d b i t s
srlx % g 3 , ( 6 4 - 1 0 ) , % g 3 ! i n U D B - L o w e r r o r s t a t u s
sllx % g 3 , ( 3 3 + 0 ) , % g 3 ! S h i f t u p t o e n c o d i n g a r e a
or % g 1 , % g 3 , % g 1 ! O r i t i n
be,p n % x c c , 1 f ! B r a n c h i f C E b i t w a s c l e a r
nop
stxa % g 4 , [ % g 0 ] A S I _ U D B _ E R R O R _ W ! C l e a r C E s t i c k y b i t i n U D B L
membar #S y n c ! S y n c h r o n i z e A S I s t o r e s
1 : mov 0 x18 , % g 5 ! A d d r o f U D B - H i g h e r r o r s t a t u s
ldxa [ % g 5 ] A S I _ U D B H _ E R R O R _ R , % g 3 ! R e a d i t
andcc % g 3 , ( 1 < < 8 ) , % g 4 ! C h e c k C E b i t
sllx % g 3 , ( 6 4 - 1 0 ) , % g 3 ! C l e a r r e s e r v e d b i t s
srlx % g 3 , ( 6 4 - 1 0 ) , % g 3 ! i n U D B - H i g h e r r o r s t a t u s
sllx % g 3 , ( 3 3 + 1 0 ) , % g 3 ! S h i f t u p t o e n c o d i n g a r e a
or % g 1 , % g 3 , % g 1 ! O r i t i n
be,p n % x c c , 1 f ! B r a n c h i f C E b i t w a s c l e a r
nop
nop
stxa % g 4 , [ % g 5 ] A S I _ U D B _ E R R O R _ W ! C l e a r C E s t i c k y b i t i n U D B H
membar #S y n c ! S y n c h r o n i z e A S I s t o r e s
1 : mov 1 , % g 5 ! A F S R C E b i t i s
sllx % g 5 , 2 0 , % g 5 ! b i t 2 0
stxa % g 5 , [ % g 0 ] A S I _ A F S R ! C l e a r C E s t i c k y b i t i n A F S R
membar #S y n c ! S y n c h r o n i z e A S I s t o r e s
sllx % g 2 , ( 6 4 - 4 1 ) , % g 2 ! C l e a r r e s e r v e d b i t s
srlx % g 2 , ( 6 4 - 4 1 ) , % g 2 ! i n l a t c h e d A F A R
andn % g 2 , 0 x0 f , % g 2 ! F i n i s h r e s v b i t c l e a r i n g
mov % g 1 , % g 4 ! M o v e A F S R + U D B * i n t o s a v e r e g
mov % g 2 , % g 5 ! M o v e A F A R i n t o s a v e r e g
rdpr % p i l , % g 2
wrpr % g 0 , 1 5 , % p i l
ba,p t % x c c , e t r a p _ i r q
rd % p c , % g 7
mov % l 4 , % o 0
mov % l 5 , % o 1
call c e e _ l o g
add % s p , P T R E G S _ O F F , % o 2
ba,a ,p t % x c c , r t r a p _ i r q
/ * Capture I / D / E - c a c h e s t a t e i n t o p e r - c p u e r r o r s c o r e b o a r d .
*
* % g1 : ( TL> =0 ) ? 1 : 0
* % g2 : scratch
* % g3 : scratch
* % g4 : AFSR
* % g5 : AFAR
* % g6 : current t h r e a d p t r
* % g7 : scratch
* /
# define C H E E T A H _ L O G _ E R R O R \
/* Put "TL1" software bit into AFSR. */ \
and % g 1 , 0 x1 , % g 1 ; \
sllx % g 1 , 6 3 , % g 2 ; \
or % g 4 , % g 2 , % g 4 ; \
/* Get log entry pointer for this cpu at this trap level. */ \
BRANCH_ I F _ J A L A P E N O ( g 2 ,g 3 ,5 0 f ) \
ldxa [ % g 0 ] A S I _ S A F A R I _ C O N F I G , % g 2 ; \
srlx % g 2 , 1 7 , % g 2 ; \
ba,p t % x c c , 6 0 f ; \
and % g 2 , 0 x3 f f , % g 2 ; \
50 : ldxa [ % g 0 ] A S I _ J B U S _ C O N F I G , % g 2 ; \
srlx % g 2 , 1 7 , % g 2 ; \
and % g 2 , 0 x1 f , % g 2 ; \
60 : sllx % g 2 , 9 , % g 2 ; \
sethi % h i ( c h e e t a h _ e r r o r _ l o g ) , % g 3 ; \
ldx [ % g 3 + % l o ( c h e e t a h _ e r r o r _ l o g ) ] , % g 3 ; \
brz,p n % g 3 , 8 0 f ; \
nop; \
add % g 3 , % g 2 , % g 3 ; \
sllx % g 1 , 8 , % g 1 ; \
add % g 3 , % g 1 , % g 1 ; \
/* %g1 holds pointer to the top of the logging scoreboard */ \
ldx [ % g 1 + 0 x0 ] , % g 7 ; \
cmp % g 7 , - 1 ; \
bne,p n % x c c , 8 0 f ; \
nop; \
stx % g 4 , [ % g 1 + 0 x0 ] ; \
stx % g 5 , [ % g 1 + 0 x8 ] ; \
add % g 1 , 0 x10 , % g 1 ; \
/* %g1 now points to D-cache logging area */ \
set 0 x3 f f8 , % g 2 ; /* DC_addr mask */ \
and % g 5 , % g 2 , % g 2 ; /* DC_addr bits of AFAR */ \
srlx % g 5 , 1 2 , % g 3 ; \
or % g 3 , 1 , % g 3 ; /* PHYS tag + valid */ \
10 : ldxa [ % g 2 ] A S I _ D C A C H E _ T A G , % g 7 ; \
cmp % g 3 , % g 7 ; /* TAG match? */ \
bne,p t % x c c , 1 3 f ; \
nop; \
/* Yep, what we want, capture state. */ \
stx % g 2 , [ % g 1 + 0 x20 ] ; \
stx % g 7 , [ % g 1 + 0 x28 ] ; \
/* A membar Sync is required before and after utag access. */ \
membar #S y n c ; \
ldxa [ % g 2 ] A S I _ D C A C H E _ U T A G , % g 7 ; \
membar #S y n c ; \
stx % g 7 , [ % g 1 + 0 x30 ] ; \
ldxa [ % g 2 ] A S I _ D C A C H E _ S N O O P _ T A G , % g 7 ; \
stx % g 7 , [ % g 1 + 0 x38 ] ; \
clr % g 3 ; \
12 : ldxa [ % g 2 + % g 3 ] A S I _ D C A C H E _ D A T A , % g 7 ; \
stx % g 7 , [ % g 1 ] ; \
add % g 3 , ( 1 < < 5 ) , % g 3 ; \
cmp % g 3 , ( 4 < < 5 ) ; \
bl,p t % x c c , 1 2 b ; \
add % g 1 , 0 x8 , % g 1 ; \
ba,p t % x c c , 2 0 f ; \
add % g 1 , 0 x20 , % g 1 ; \
13 : sethi % h i ( 1 < < 1 4 ) , % g 7 ; \
add % g 2 , % g 7 , % g 2 ; \
srlx % g 2 , 1 4 , % g 7 ; \
cmp % g 7 , 4 ; \
bl,p t % x c c , 1 0 b ; \
nop; \
add % g 1 , 0 x40 , % g 1 ; \
20 : /* %g1 now points to I-cache logging area */ \
set 0 x1 f e 0 , % g 2 ; /* IC_addr mask */ \
and % g 5 , % g 2 , % g 2 ; /* IC_addr bits of AFAR */ \
sllx % g 2 , 1 , % g 2 ; /* IC_addr[13:6]==VA[12:5] */ \
srlx % g 5 , ( 1 3 - 8 ) , % g 3 ; /* Make PTAG */ \
andn % g 3 , 0 x f f , % g 3 ; /* Mask off undefined bits */ \
21 : ldxa [ % g 2 ] A S I _ I C _ T A G , % g 7 ; \
andn % g 7 , 0 x f f , % g 7 ; \
cmp % g 3 , % g 7 ; \
bne,p t % x c c , 2 3 f ; \
nop; \
/* Yep, what we want, capture state. */ \
stx % g 2 , [ % g 1 + 0 x40 ] ; \
stx % g 7 , [ % g 1 + 0 x48 ] ; \
add % g 2 , ( 1 < < 3 ) , % g 2 ; \
ldxa [ % g 2 ] A S I _ I C _ T A G , % g 7 ; \
add % g 2 , ( 1 < < 3 ) , % g 2 ; \
stx % g 7 , [ % g 1 + 0 x50 ] ; \
ldxa [ % g 2 ] A S I _ I C _ T A G , % g 7 ; \
add % g 2 , ( 1 < < 3 ) , % g 2 ; \
stx % g 7 , [ % g 1 + 0 x60 ] ; \
ldxa [ % g 2 ] A S I _ I C _ T A G , % g 7 ; \
stx % g 7 , [ % g 1 + 0 x68 ] ; \
sub % g 2 , ( 3 < < 3 ) , % g 2 ; \
ldxa [ % g 2 ] A S I _ I C _ S T A G , % g 7 ; \
stx % g 7 , [ % g 1 + 0 x58 ] ; \
clr % g 3 ; \
srlx % g 2 , 2 , % g 2 ; \
22 : ldxa [ % g 2 + % g 3 ] A S I _ I C _ I N S T R , % g 7 ; \
stx % g 7 , [ % g 1 ] ; \
add % g 3 , ( 1 < < 3 ) , % g 3 ; \
cmp % g 3 , ( 8 < < 3 ) ; \
bl,p t % x c c , 2 2 b ; \
add % g 1 , 0 x8 , % g 1 ; \
ba,p t % x c c , 3 0 f ; \
add % g 1 , 0 x30 , % g 1 ; \
23 : sethi % h i ( 1 < < 1 4 ) , % g 7 ; \
add % g 2 , % g 7 , % g 2 ; \
srlx % g 2 , 1 4 , % g 7 ; \
cmp % g 7 , 4 ; \
bl,p t % x c c , 2 1 b ; \
nop; \
add % g 1 , 0 x70 , % g 1 ; \
30 : /* %g1 now points to E-cache logging area */ \
andn % g 5 , ( 3 2 - 1 ) , % g 2 ; /* E-cache subblock */ \
stx % g 2 , [ % g 1 + 0 x20 ] ; \
ldxa [ % g 2 ] A S I _ E C _ T A G _ D A T A , % g 7 ; \
stx % g 7 , [ % g 1 + 0 x28 ] ; \
ldxa [ % g 2 ] A S I _ E C _ R , % g 0 ; \
clr % g 3 ; \
31 : ldxa [ % g 3 ] A S I _ E C _ D A T A , % g 7 ; \
stx % g 7 , [ % g 1 + % g 3 ] ; \
add % g 3 , 0 x8 , % g 3 ; \
cmp % g 3 , 0 x20 ; \
bl,p t % x c c , 3 1 b ; \
nop; \
80 : /* DONE */
/ * These g e t p a t c h e d i n t o t h e t r a p t a b l e a t b o o t t i m e
* once w e k n o w w e h a v e a c h e e t a h p r o c e s s o r .
* /
.globl cheetah_ f e c c _ t r a p _ v e c t o r , c h e e t a h _ f e c c _ t r a p _ v e c t o r _ t l 1
cheetah_fecc_trap_vector :
membar #S y n c
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1
andn % g 1 , D C U _ D C | D C U _ I C , % g 1
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
sethi % h i ( c h e e t a h _ f a s t _ e c c ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ f a s t _ e c c ) , % g 0
mov 0 , % g 1
cheetah_fecc_trap_vector_tl1 :
membar #S y n c
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1
andn % g 1 , D C U _ D C | D C U _ I C , % g 1
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
sethi % h i ( c h e e t a h _ f a s t _ e c c ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ f a s t _ e c c ) , % g 0
mov 1 , % g 1
.globl cheetah_ c e e _ t r a p _ v e c t o r , c h e e t a h _ c e e _ t r a p _ v e c t o r _ t l 1
cheetah_cee_trap_vector :
membar #S y n c
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1
andn % g 1 , D C U _ I C , % g 1
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
sethi % h i ( c h e e t a h _ c e e ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ c e e ) , % g 0
mov 0 , % g 1
cheetah_cee_trap_vector_tl1 :
membar #S y n c
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1
andn % g 1 , D C U _ I C , % g 1
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
sethi % h i ( c h e e t a h _ c e e ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ c e e ) , % g 0
mov 1 , % g 1
.globl cheetah_ d e f e r r e d _ t r a p _ v e c t o r , c h e e t a h _ d e f e r r e d _ t r a p _ v e c t o r _ t l 1
cheetah_deferred_trap_vector :
membar #S y n c
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1 ;
andn % g 1 , D C U _ D C | D C U _ I C , % g 1 ;
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G ;
membar #S y n c ;
sethi % h i ( c h e e t a h _ d e f e r r e d _ t r a p ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ d e f e r r e d _ t r a p ) , % g 0
mov 0 , % g 1
cheetah_deferred_trap_vector_tl1 :
membar #S y n c ;
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1 ;
andn % g 1 , D C U _ D C | D C U _ I C , % g 1 ;
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G ;
membar #S y n c ;
sethi % h i ( c h e e t a h _ d e f e r r e d _ t r a p ) , % g 2
jmpl % g 2 + % l o ( c h e e t a h _ d e f e r r e d _ t r a p ) , % g 0
mov 1 , % g 1
/ * Cheetah+ s p e c i f i c t r a p s . T h e s e a r e f o r t h e n e w I / D c a c h e p a r i t y
* error t r a p s . T h e f i r s t a r g u m e n t t o c h e e t a h _ p l u s _ p a r i t y _ h a n d l e r
* is e n c o d e d a s f o l l o w s :
*
* Bit0 : 0 = dcache,1 =icache
* Bit1 : 0 = recoverable,1 =unrecoverable
* /
.globl cheetah_ p l u s _ d c p e _ t r a p _ v e c t o r , c h e e t a h _ p l u s _ d c p e _ t r a p _ v e c t o r _ t l 1
cheetah_plus_dcpe_trap_vector :
membar #S y n c
sethi % h i ( d o _ c h e e t a h _ p l u s _ d a t a _ p a r i t y ) , % g 7
jmpl % g 7 + % l o ( d o _ c h e e t a h _ p l u s _ d a t a _ p a r i t y ) , % g 0
nop
nop
nop
nop
nop
do_cheetah_plus_data_parity :
ba,p t % x c c , e t r a p
rd % p c , % g 7
mov 0 x0 , % o 0
call c h e e t a h _ p l u s _ p a r i t y _ e r r o r
add % s p , P T R E G S _ O F F , % o 1
ba,p t % x c c , r t r a p
clr % l 6
cheetah_plus_dcpe_trap_vector_tl1 :
membar #S y n c
wrpr P S T A T E _ I G | 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
sethi % h i ( d o _ d c p e _ t l 1 ) , % g 3
jmpl % g 3 + % l o ( d o _ d c p e _ t l 1 ) , % g 0
nop
nop
nop
nop
.globl cheetah_ p l u s _ i c p e _ t r a p _ v e c t o r , c h e e t a h _ p l u s _ i c p e _ t r a p _ v e c t o r _ t l 1
cheetah_plus_icpe_trap_vector :
membar #S y n c
sethi % h i ( d o _ c h e e t a h _ p l u s _ i n s n _ p a r i t y ) , % g 7
jmpl % g 7 + % l o ( d o _ c h e e t a h _ p l u s _ i n s n _ p a r i t y ) , % g 0
nop
nop
nop
nop
nop
do_cheetah_plus_insn_parity :
ba,p t % x c c , e t r a p
rd % p c , % g 7
mov 0 x1 , % o 0
call c h e e t a h _ p l u s _ p a r i t y _ e r r o r
add % s p , P T R E G S _ O F F , % o 1
ba,p t % x c c , r t r a p
clr % l 6
cheetah_plus_icpe_trap_vector_tl1 :
membar #S y n c
wrpr P S T A T E _ I G | 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
sethi % h i ( d o _ i c p e _ t l 1 ) , % g 3
jmpl % g 3 + % l o ( d o _ i c p e _ t l 1 ) , % g 0
nop
nop
nop
nop
/ * If w e t a k e o n e o f t h e s e t r a p s w h e n t l > = 1 , t h e n w e
* jump t o i n t e r r u p t g l o b a l s . I f s o m e t r a p l e v e l a b o v e u s
* was a l s o u s i n g i n t e r r u p t g l o b a l s , w e c a n n o t r e c o v e r .
* We m a y u s e a l l i n t e r r u p t g l o b a l r e g i s t e r s e x c e p t % g 6 .
* /
.globl do_ d c p e _ t l 1 , d o _ i c p e _ t l 1
do_dcpe_tl1 :
rdpr % t l , % g 1 ! S a v e o r i g i n a l t r a p l e v e l
mov 1 , % g 2 ! S e t u p T S T A T E c h e c k i n g l o o p
sethi % h i ( T S T A T E _ I G ) , % g 3 ! T S T A T E m a s k b i t
1 : wrpr % g 2 , % t l ! S e t t r a p l e v e l t o c h e c k
rdpr % t s t a t e , % g 4 ! R e a d T S T A T E f o r t h i s l e v e l
andcc % g 4 , % g 3 , % g 0 ! I n t e r r u p t g l o b a l s i n u s e ?
bne,a ,p n % x c c , d o _ d c p e _ t l 1 _ f a t a l ! Y e p , i r r e c o v e r a b l e
wrpr % g 1 , % t l ! R e s t o r e o r i g i n a l t r a p l e v e l
add % g 2 , 1 , % g 2 ! N e x t t r a p l e v e l
cmp % g 2 , % g 1 ! H i t t h e m a l l y e t ?
ble,p t % i c c , 1 b ! N o t y e t
nop
wrpr % g 1 , % t l ! R e s t o r e o r i g i n a l t r a p l e v e l
do_dcpe_tl1_nonfatal : /* Ok we may use interrupt globals safely. */
/* Reset D-cache parity */
sethi % h i ( 1 < < 1 6 ) , % g 1 ! D - c a c h e s i z e
mov ( 1 < < 5 ) , % g 2 ! D - c a c h e l i n e s i z e
sub % g 1 , % g 2 , % g 1 ! M o v e d o w n 1 c a c h e l i n e
1 : srl % g 1 , 1 4 , % g 3 ! C o m p u t e U T A G
membar #S y n c
stxa % g 3 , [ % g 1 ] A S I _ D C A C H E _ U T A G
membar #S y n c
sub % g 2 , 8 , % g 3 ! 6 4 - b i t d a t a w o r d w i t h i n l i n e
2 : membar #S y n c
stxa % g 0 , [ % g 1 + % g 3 ] A S I _ D C A C H E _ D A T A
membar #S y n c
subcc % g 3 , 8 , % g 3 ! N e x t 6 4 - b i t d a t a w o r d
bge,p t % i c c , 2 b
nop
subcc % g 1 , % g 2 , % g 1 ! N e x t c a c h e l i n e
bge,p t % i c c , 1 b
nop
ba,p t % x c c , d c p e _ i c p e _ t l 1 _ c o m m o n
nop
do_dcpe_tl1_fatal :
sethi % h i ( 1 f ) , % g 7
ba,p t % x c c , e t r a p t l 1
1 : or % g 7 , % l o ( 1 b ) , % g 7
mov 0 x2 , % o 0
call c h e e t a h _ p l u s _ p a r i t y _ e r r o r
add % s p , P T R E G S _ O F F , % o 1
ba,p t % x c c , r t r a p
clr % l 6
do_icpe_tl1 :
rdpr % t l , % g 1 ! S a v e o r i g i n a l t r a p l e v e l
mov 1 , % g 2 ! S e t u p T S T A T E c h e c k i n g l o o p
sethi % h i ( T S T A T E _ I G ) , % g 3 ! T S T A T E m a s k b i t
1 : wrpr % g 2 , % t l ! S e t t r a p l e v e l t o c h e c k
rdpr % t s t a t e , % g 4 ! R e a d T S T A T E f o r t h i s l e v e l
andcc % g 4 , % g 3 , % g 0 ! I n t e r r u p t g l o b a l s i n u s e ?
bne,a ,p n % x c c , d o _ i c p e _ t l 1 _ f a t a l ! Y e p , i r r e c o v e r a b l e
wrpr % g 1 , % t l ! R e s t o r e o r i g i n a l t r a p l e v e l
add % g 2 , 1 , % g 2 ! N e x t t r a p l e v e l
cmp % g 2 , % g 1 ! H i t t h e m a l l y e t ?
ble,p t % i c c , 1 b ! N o t y e t
nop
wrpr % g 1 , % t l ! R e s t o r e o r i g i n a l t r a p l e v e l
do_icpe_tl1_nonfatal : /* Ok we may use interrupt globals safely. */
/* Flush I-cache */
sethi % h i ( 1 < < 1 5 ) , % g 1 ! I - c a c h e s i z e
mov ( 1 < < 5 ) , % g 2 ! I - c a c h e l i n e s i z e
sub % g 1 , % g 2 , % g 1
1 : or % g 1 , ( 2 < < 3 ) , % g 3
stxa % g 0 , [ % g 3 ] A S I _ I C _ T A G
membar #S y n c
subcc % g 1 , % g 2 , % g 1
bge,p t % i c c , 1 b
nop
ba,p t % x c c , d c p e _ i c p e _ t l 1 _ c o m m o n
nop
do_icpe_tl1_fatal :
sethi % h i ( 1 f ) , % g 7
ba,p t % x c c , e t r a p t l 1
1 : or % g 7 , % l o ( 1 b ) , % g 7
mov 0 x3 , % o 0
call c h e e t a h _ p l u s _ p a r i t y _ e r r o r
add % s p , P T R E G S _ O F F , % o 1
ba,p t % x c c , r t r a p
clr % l 6
dcpe_icpe_tl1_common :
/ * Flush D - c a c h e , r e - e n a b l e D / I c a c h e s i n D C U a n d f i n a l l y
* retry t h e t r a p p i n g i n s t r u c t i o n .
* /
sethi % h i ( 1 < < 1 6 ) , % g 1 ! D - c a c h e s i z e
mov ( 1 < < 5 ) , % g 2 ! D - c a c h e l i n e s i z e
sub % g 1 , % g 2 , % g 1
1 : stxa % g 0 , [ % g 1 ] A S I _ D C A C H E _ T A G
membar #S y n c
subcc % g 1 , % g 2 , % g 1
bge,p t % i c c , 1 b
nop
ldxa [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G , % g 1
or % g 1 , ( D C U _ D C | D C U _ I C ) , % g 1
stxa % g 1 , [ % g 0 ] A S I _ D C U _ C O N T R O L _ R E G
membar #S y n c
retry
/ * Cheetah F E C C t r a p h a n d l i n g , w e g e t h e r e f r o m t l { 0 ,1 } _ f e c c
* in t h e t r a p t a b l e . T h a t c o d e h a s d o n e a m e m o r y b a r r i e r
* and h a s d i s a b l e d b o t h t h e I - c a c h e a n d D - c a c h e i n t h e D C U
* control r e g i s t e r . T h e I - c a c h e i s d i s a b l e d s o t h a t w e m a y
* capture t h e c o r r u p t e d c a c h e l i n e , a n d t h e D - c a c h e i s d i s a b l e d
* because c o r r u p t d a t a m a y h a v e b e e n p l a c e d t h e r e a n d w e d o n ' t
* want t o r e f e r e n c e i t .
*
* % g1 i s o n e i f t h i s t r a p o c c u r r e d a t % t l > = 1 .
*
* Next, w e t u r n o f f e r r o r r e p o r t i n g s o t h a t w e d o n ' t r e c u r s e .
* /
.globl cheetah_fast_ecc
cheetah_fast_ecc :
ldxa [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N , % g 2
andn % g 2 , E S T A T E _ E R R O R _ N C E E N | E S T A T E _ E R R O R _ C E E N , % g 2
stxa % g 2 , [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N
membar #S y n c
/* Fetch and clear AFSR/AFAR */
ldxa [ % g 0 ] A S I _ A F S R , % g 4
ldxa [ % g 0 ] A S I _ A F A R , % g 5
stxa % g 4 , [ % g 0 ] A S I _ A F S R
membar #S y n c
CHEETAH_ L O G _ E R R O R
rdpr % p i l , % g 2
wrpr % g 0 , 1 5 , % p i l
ba,p t % x c c , e t r a p _ i r q
rd % p c , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call c h e e t a h _ f e c c _ h a n d l e r
add % s p , P T R E G S _ O F F , % o 0
ba,a ,p t % x c c , r t r a p _ i r q
/* Our caller has disabled I-cache and performed membar Sync. */
.globl cheetah_cee
cheetah_cee :
ldxa [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N , % g 2
andn % g 2 , E S T A T E _ E R R O R _ C E E N , % g 2
stxa % g 2 , [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N
membar #S y n c
/* Fetch and clear AFSR/AFAR */
ldxa [ % g 0 ] A S I _ A F S R , % g 4
ldxa [ % g 0 ] A S I _ A F A R , % g 5
stxa % g 4 , [ % g 0 ] A S I _ A F S R
membar #S y n c
CHEETAH_ L O G _ E R R O R
rdpr % p i l , % g 2
wrpr % g 0 , 1 5 , % p i l
ba,p t % x c c , e t r a p _ i r q
rd % p c , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call c h e e t a h _ c e e _ h a n d l e r
add % s p , P T R E G S _ O F F , % o 0
ba,a ,p t % x c c , r t r a p _ i r q
/* Our caller has disabled I-cache+D-cache and performed membar Sync. */
.globl cheetah_deferred_trap
cheetah_deferred_trap :
ldxa [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N , % g 2
andn % g 2 , E S T A T E _ E R R O R _ N C E E N | E S T A T E _ E R R O R _ C E E N , % g 2
stxa % g 2 , [ % g 0 ] A S I _ E S T A T E _ E R R O R _ E N
membar #S y n c
/* Fetch and clear AFSR/AFAR */
ldxa [ % g 0 ] A S I _ A F S R , % g 4
ldxa [ % g 0 ] A S I _ A F A R , % g 5
stxa % g 4 , [ % g 0 ] A S I _ A F S R
membar #S y n c
CHEETAH_ L O G _ E R R O R
rdpr % p i l , % g 2
wrpr % g 0 , 1 5 , % p i l
ba,p t % x c c , e t r a p _ i r q
rd % p c , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call c h e e t a h _ d e f e r r e d _ h a n d l e r
add % s p , P T R E G S _ O F F , % o 0
ba,a ,p t % x c c , r t r a p _ i r q
.globl __do_privact
__do_privact :
mov T L B _ S F S R , % g 3
stxa % g 0 , [ % g 3 ] A S I _ D M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
call d o _ p r i v a c t
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl do_mna
do_mna :
rdpr % t l , % g 3
cmp % g 3 , 1
/ * Setup % g 4 / % g 5 n o w a s t h e y a r e u s e d i n t h e
* winfixup c o d e .
* /
mov T L B _ S F S R , % g 3
mov D M M U _ S F A R , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 4
ldxa [ % g 3 ] A S I _ D M M U , % g 5
stxa % g 0 , [ % g 3 ] A S I _ D M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
bgu,p n % i c c , w i n f i x _ m n a
rdpr % t p c , % g 3
1 : sethi % h i ( 1 0 9 f ) , % g 7
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call m e m _ a d d r e s s _ u n a l i g n e d
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl do_lddfmna
do_lddfmna :
sethi % h i ( 1 0 9 f ) , % g 7
mov T L B _ S F S R , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 5
stxa % g 0 , [ % g 4 ] A S I _ D M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
mov D M M U _ S F A R , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 4
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call h a n d l e _ l d d f m n a
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl do_stdfmna
do_stdfmna :
sethi % h i ( 1 0 9 f ) , % g 7
mov T L B _ S F S R , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 5
stxa % g 0 , [ % g 4 ] A S I _ D M M U ! C l e a r F a u l t V a l i d b i t
membar #S y n c
mov D M M U _ S F A R , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 4
ba,p t % x c c , e t r a p
109 : or % g 7 , % l o ( 1 0 9 b ) , % g 7
mov % l 4 , % o 1
mov % l 5 , % o 2
call h a n d l e _ s t d f m n a
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
clr % l 6
.globl breakpoint_trap
breakpoint_trap :
call s p a r c _ b r e a k p o i n t
add % s p , P T R E G S _ O F F , % o 0
ba,p t % x c c , r t r a p
nop
# if d e f i n e d ( C O N F I G _ S U N O S _ E M U L ) | | d e f i n e d ( C O N F I G _ S O L A R I S _ E M U L ) | | \
defined( C O N F I G _ S O L A R I S _ E M U L _ M O D U L E )
/ * SunOS u s e s s y s c a l l z e r o a s t h e ' i n d i r e c t s y s c a l l ' i t l o o k s
* like i n d i r _ s y s c a l l ( s c a l l _ n u m , a r g 0 , a r g 1 , a r g 2 . . . ) ; etc.
* This i s c o m p l e t e b r a i n d a m a g e .
* /
.globl sunos_indir
sunos_indir :
srl % o 0 , 0 , % o 0
mov % o 7 , % l 4
cmp % o 0 , N R _ S Y S C A L L S
blu,a ,p t % i c c , 1 f
sll % o 0 , 0 x2 , % o 0
sethi % h i ( s u n o s _ n o s y s ) , % l 6
b,p t % x c c , 2 f
or % l 6 , % l o ( s u n o s _ n o s y s ) , % l 6
1 : sethi % h i ( s u n o s _ s y s _ t a b l e ) , % l 7
or % l 7 , % l o ( s u n o s _ s y s _ t a b l e ) , % l 7
lduw [ % l 7 + % o 0 ] , % l 6
2 : mov % o 1 , % o 0
mov % o 2 , % o 1
mov % o 3 , % o 2
mov % o 4 , % o 3
mov % o 5 , % o 4
call % l 6
mov % l 4 , % o 7
.globl sunos_getpid
sunos_getpid :
call s y s _ g e t p p i d
nop
call s y s _ g e t p i d
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 1 ]
b,p t % x c c , r e t _ s y s _ c a l l
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
/* SunOS getuid() returns uid in %o0 and euid in %o1 */
.globl sunos_getuid
sunos_getuid :
call s y s32 _ g e t e u i d16
nop
call s y s32 _ g e t u i d16
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 1 ]
b,p t % x c c , r e t _ s y s _ c a l l
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
/* SunOS getgid() returns gid in %o0 and egid in %o1 */
.globl sunos_getgid
sunos_getgid :
call s y s32 _ g e t e g i d16
nop
call s y s32 _ g e t g i d16
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 1 ]
b,p t % x c c , r e t _ s y s _ c a l l
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
# endif
/ * SunOS' s e x e c v ( ) c a l l o n l y s p e c i f i e s t h e a r g v a r g u m e n t , t h e
* environment s e t t i n g s a r e t h e s a m e a s t h e c a l l i n g p r o c e s s e s .
* /
.globl sunos_execv
sys_execve :
sethi % h i ( s p a r c _ e x e c v e ) , % g 1
ba,p t % x c c , e x e c v e _ m e r g e
or % g 1 , % l o ( s p a r c _ e x e c v e ) , % g 1
# ifdef C O N F I G _ C O M P A T
.globl sys_execve
sunos_execv :
stx % g 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 2 ]
.globl sys32_execve
sys32_execve :
sethi % h i ( s p a r c32 _ e x e c v e ) , % g 1
or % g 1 , % l o ( s p a r c32 _ e x e c v e ) , % g 1
# endif
execve_merge :
flushw
jmpl % g 1 , % g 0
add % s p , P T R E G S _ O F F , % o 0
.globl sys_ p i p e , s y s _ s i g p a u s e , s y s _ n i s _ s y s c a l l
.globl sys_ s i g s u s p e n d , s y s _ r t _ s i g s u s p e n d
.globl sys_rt_sigreturn
.globl sys_ptrace
.globl sys_sigaltstack
.align 32
sys_pipe : ba,p t % x c c , s p a r c _ p i p e
add % s p , P T R E G S _ O F F , % o 0
sys_nis_syscall : ba,p t % x c c , c _ s y s _ n i s _ s y s c a l l
add % s p , P T R E G S _ O F F , % o 0
sys_memory_ordering :
ba,p t % x c c , s p a r c _ m e m o r y _ o r d e r i n g
add % s p , P T R E G S _ O F F , % o 1
sys_sigaltstack : ba,p t % x c c , d o _ s i g a l t s t a c k
add % i 6 , S T A C K _ B I A S , % o 2
# ifdef C O N F I G _ C O M P A T
.globl sys32_sigstack
sys32_sigstack : ba,p t % x c c , d o _ s y s32 _ s i g s t a c k
mov % i 6 , % o 2
.globl sys32_sigaltstack
sys32_sigaltstack :
ba,p t % x c c , d o _ s y s32 _ s i g a l t s t a c k
mov % i 6 , % o 2
# endif
.align 32
sys_sigsuspend : add % s p , P T R E G S _ O F F , % o 0
call d o _ s i g s u s p e n d
add % o 7 , 1 f - . - 4 , % o 7
nop
sys_rt_sigsuspend : /* NOTE: %o0,%o1 have a correct value already */
add % s p , P T R E G S _ O F F , % o 2
call d o _ r t _ s i g s u s p e n d
add % o 7 , 1 f - . - 4 , % o 7
nop
# ifdef C O N F I G _ C O M P A T
.globl sys32_rt_sigsuspend
sys32_rt_sigsuspend : /* NOTE: %o0,%o1 have a correct value already */
srl % o 0 , 0 , % o 0
add % s p , P T R E G S _ O F F , % o 2
call d o _ r t _ s i g s u s p e n d32
add % o 7 , 1 f - . - 4 , % o 7
# endif
/* NOTE: %o0 has a correct value already */
sys_sigpause : add % s p , P T R E G S _ O F F , % o 1
call d o _ s i g p a u s e
add % o 7 , 1 f - . - 4 , % o 7
nop
# ifdef C O N F I G _ C O M P A T
.globl sys32_sigreturn
sys32_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ s i g r e t u r n 3 2
add % o 7 , 1 f - . - 4 , % o 7
nop
# endif
sys_rt_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ r t _ s i g r e t u r n
add % o 7 , 1 f - . - 4 , % o 7
nop
# ifdef C O N F I G _ C O M P A T
.globl sys32_rt_sigreturn
sys32_rt_sigreturn :
add % s p , P T R E G S _ O F F , % o 0
call d o _ r t _ s i g r e t u r n 3 2
add % o 7 , 1 f - . - 4 , % o 7
nop
# endif
sys_ptrace : add % s p , P T R E G S _ O F F , % o 0
call d o _ p t r a c e
add % o 7 , 1 f - . - 4 , % o 7
nop
.align 32
1 : ldx [ % c u r p t r + T I _ F L A G S ] , % l 5
2005-07-11 06:29:45 +04:00
andcc % l 5 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T ) , % g 0
2005-04-17 02:20:36 +04:00
be,p t % i c c , r t r a p
clr % l 6
2005-07-11 03:55:48 +04:00
add % s p , P T R E G S _ O F F , % o 0
2005-04-17 02:20:36 +04:00
call s y s c a l l _ t r a c e
2005-07-11 03:55:48 +04:00
mov 1 , % o 1
2005-04-17 02:20:36 +04:00
ba,p t % x c c , r t r a p
clr % l 6
/ * This i s h o w f o r k ( ) w a s m e a n t t o b e d o n e , 8 i n s t r u c t i o n e n t r y .
*
* I q u e s t i o n e d t h e f o l l o w i n g c o d e b r i e f l y , l e t m e c l e a r t h i n g s
* up s o y o u m u s t n o t r e a s o n o n i t l i k e I d i d .
*
* Know t h e f o r k _ k p s r e t c . w e u s e i n t h e s p a r c32 p o r t ? W e d o n ' t
* need i t h e r e b e c a u s e t h e o n l y p i e c e o f w i n d o w s t a t e w e c o p y t o
* the c h i l d i s t h e C W P r e g i s t e r . E v e n i f t h e p a r e n t s l e e p s ,
* we a r e s a f e b e c a u s e w e s t u c k i t i n t o p t _ r e g s o f t h e p a r e n t
* so i t w i l l n o t c h a n g e .
*
* XXX T h i s r a i s e s t h e q u e s t i o n , w h e t h e r w e c a n d o t h e s a m e o n
* XXX s p a r c32 t o g e t r i d o f f o r k _ k p s r _ a n d _ f o r k _ k w i m . T h e
* XXX a n s w e r i s y e s . W e s t i c k f o r k _ k p s r i n U R E G _ G 0 a n d
* XXX f o r k _ k w i m i n U R E G _ G 1 ( g l o b a l r e g i s t e r s a r e c o n s i d e r e d
* XXX v o l a t i l e a c r o s s a s y s t e m c a l l i n t h e s p a r c A B I I t h i n k
* XXX i f i t i s n ' t w e c a n u s e r e g s - > y i n s t e a d , a n y o n e w h o d e p e n d s
* XXX u p o n t h e Y r e g i s t e r b e i n g p r e s e r v e d a c r o s s a f o r k d e s e r v e s
* XXX t o l o s e ) .
*
* In f a c t w e s h o u l d t a k e a d v a n t a g e o f t h a t f a c t f o r o t h e r t h i n g s
* during s y s t e m c a l l s . . .
* /
.globl sys_ f o r k , s y s _ v f o r k , s y s _ c l o n e , s p a r c _ e x i t
.globl ret_from_syscall
.align 32
sys_vfork : /* Under Linux, vfork and fork are just special cases of clone. */
sethi % h i ( 0 x40 0 0 | 0 x01 0 0 | S I G C H L D ) , % o 0
or % o 0 , % l o ( 0 x40 0 0 | 0 x01 0 0 | S I G C H L D ) , % o 0
ba,p t % x c c , s y s _ c l o n e
sys_fork : clr % o 1
mov S I G C H L D , % o 0
sys_clone : flushw
movrz % o 1 , % f p , % o 1
mov 0 , % o 3
ba,p t % x c c , s p a r c _ d o _ f o r k
add % s p , P T R E G S _ O F F , % o 2
ret_from_syscall :
2005-07-25 06:36:26 +04:00
/ * Clear c u r r e n t _ t h r e a d _ i n f o ( ) - > n e w _ c h i l d , a n d
* check p e r f o r m a n c e c o u n t e r s t u f f t o o .
2005-04-17 02:20:36 +04:00
* /
2005-07-25 06:36:26 +04:00
stb % g 0 , [ % g 6 + T I _ N E W _ C H I L D ]
ldx [ % g 6 + T I _ F L A G S ] , % l 0
2005-04-17 02:20:36 +04:00
call s c h e d u l e _ t a i l
mov % g 7 , % o 0
andcc % l 0 , _ T I F _ P E R F C T R , % g 0
be,p t % i c c , 1 f
nop
ldx [ % g 6 + T I _ P C R ] , % o 7
wr % g 0 , % o 7 , % p c r
/ * Blackbird e r r a t a w o r k a r o u n d . S e e c o m m e n t a r y i n
* smp. c : s m p _ p e r c p u _ t i m e r _ i n t e r r u p t ( ) f o r m o r e
* information.
* /
ba,p t % x c c , 9 9 f
nop
.align 64
99 : wr % g 0 , % g 0 , % p i c
rd % p i c , % g 0
1 : b,p t % x c c , r e t _ s y s _ c a l l
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ] , % o 0
sparc_exit : wrpr % g 0 , ( P S T A T E _ 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
rdpr % o t h e r w i n , % g 1
rdpr % c a n s a v e , % g 3
add % g 3 , % g 1 , % g 3
wrpr % g 3 , 0 x0 , % c a n s a v e
wrpr % g 0 , 0 x0 , % o t h e r w i n
wrpr % g 0 , ( P S T A T E _ 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 ) , % p s t a t e
ba,p t % x c c , s y s _ e x i t
stb % g 0 , [ % g 6 + T I _ W S A V E D ]
linux_sparc_ni_syscall :
sethi % h i ( s y s _ n i _ s y s c a l l ) , % l 7
b,p t % x c c , 4 f
or % l 7 , % l o ( s y s _ n i _ s y s c a l l ) , % l 7
linux_syscall_trace32 :
2005-07-11 03:55:48 +04:00
add % s p , P T R E G S _ O F F , % o 0
2005-04-17 02:20:36 +04:00
call s y s c a l l _ t r a c e
2005-07-11 03:55:48 +04:00
clr % o 1
2005-04-17 02:20:36 +04:00
srl % i 0 , 0 , % o 0
2005-07-11 03:55:48 +04:00
srl % i 4 , 0 , % o 4
2005-04-17 02:20:36 +04:00
srl % i 1 , 0 , % o 1
srl % i 2 , 0 , % o 2
b,p t % x c c , 2 f
srl % i 3 , 0 , % o 3
linux_syscall_trace :
2005-07-11 03:55:48 +04:00
add % s p , P T R E G S _ O F F , % o 0
2005-04-17 02:20:36 +04:00
call s y s c a l l _ t r a c e
2005-07-11 03:55:48 +04:00
clr % o 1
2005-04-17 02:20:36 +04:00
mov % i 0 , % o 0
mov % i 1 , % o 1
mov % i 2 , % o 2
mov % i 3 , % o 3
b,p t % x c c , 2 f
mov % i 4 , % o 4
/* Linux 32-bit and SunOS system calls enter here... */
.align 32
.globl linux_sparc_syscall32
linux_sparc_syscall32 :
/* Direct access to user regs, much faster. */
cmp % g 1 , N R _ S Y S C A L L S ! I E U 1 G r o u p
bgeu,p n % x c c , l i n u x _ s p a r c _ n i _ s y s c a l l ! C T I
srl % i 0 , 0 , % o 0 ! I E U 0
sll % g 1 , 2 , % l 4 ! I E U 0 G r o u p
srl % i 4 , 0 , % o 4 ! I E U 1
lduw [ % l 7 + % l 4 ] , % l 7 ! L o a d
srl % i 1 , 0 , % o 1 ! I E U 0 G r o u p
ldx [ % c u r p t r + T I _ F L A G S ] , % l 0 ! L o a d
srl % i 5 , 0 , % o 5 ! I E U 1
srl % i 2 , 0 , % o 2 ! I E U 0 G r o u p
2005-07-11 06:29:45 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T ) , % g 0
2005-04-17 02:20:36 +04:00
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e 3 2 ! C T I
mov % i 0 , % l 5 ! I E U 1
call % l 7 ! C T I G r o u p b r k f o r c e d
srl % i 3 , 0 , % o 3 ! I E U 0
ba,a ,p t % x c c , 3 f
/* Linux native and SunOS system calls enter here... */
.align 32
.globl linux_ s p a r c _ s y s c a l l , r e t _ s y s _ c a l l
linux_sparc_syscall :
/* Direct access to user regs, much faster. */
cmp % g 1 , N R _ S Y S C A L L S ! I E U 1 G r o u p
bgeu,p n % x c c , l i n u x _ s p a r c _ n i _ s y s c a l l ! C T I
mov % i 0 , % o 0 ! I E U 0
sll % g 1 , 2 , % l 4 ! I E U 0 G r o u p
mov % i 1 , % o 1 ! I E U 1
lduw [ % l 7 + % l 4 ] , % l 7 ! L o a d
4 : mov % i 2 , % o 2 ! I E U 0 G r o u p
ldx [ % c u r p t r + T I _ F L A G S ] , % l 0 ! L o a d
mov % i 3 , % o 3 ! I E U 1
mov % i 4 , % o 4 ! I E U 0 G r o u p
2005-07-11 06:29:45 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T ) , % g 0
2005-04-17 02:20:36 +04:00
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e ! C T I G r o u p
mov % i 0 , % l 5 ! I E U 0
2 : call % l 7 ! C T I G r o u p b r k f o r c e d
mov % i 5 , % o 5 ! I E U 0
nop
3 : stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
ret_sys_call :
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ T S T A T E ] , % g 3
ldx [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ] , % l 1 ! p c = n p c
sra % o 0 , 0 , % o 0
mov % u l o ( T S T A T E _ X C A R R Y | T S T A T E _ I C A R R Y ) , % g 2
sllx % g 2 , 3 2 , % g 2
/ * Check i f f o r c e _ s u c c e s s f u l _ s y s c a l l _ r e t u r n ( )
* was i n v o k e d .
* /
2005-07-25 06:36:26 +04:00
ldub [ % c u r p t r + T I _ S Y S _ N O E R R O R ] , % l 0
brz,p t % l 0 , 1 f
nop
2005-04-17 02:20:36 +04:00
ba,p t % x c c , 8 0 f
2005-07-25 06:36:26 +04:00
stb % g 0 , [ % c u r p t r + T I _ S Y S _ N O E R R O R ]
2005-04-17 02:20:36 +04:00
1 :
cmp % o 0 , - E R E S T A R T _ R E S T A R T B L O C K
bgeu,p n % x c c , 1 f
2005-07-11 06:29:45 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T ) , % l 6
2005-04-17 02:20:36 +04:00
80 :
/* System call success, clear Carry condition code. */
andn % g 3 , % g 2 , % g 3
stx % g 3 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T S T A T E ]
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e 2
add % l 1 , 0 x4 , % l 2 ! n p c = n p c + 4
stx % l 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T P C ]
ba,p t % x c c , r t r a p _ c l r _ l 6
stx % l 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ]
1 :
/ * System c a l l f a i l u r e , s e t C a r r y c o n d i t i o n c o d e .
* Also, g e t a b s ( e r r n o ) t o r e t u r n t o t h e p r o c e s s .
* /
2005-07-11 06:29:45 +04:00
andcc % l 0 , ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S E C C O M P | _ T I F _ S Y S C A L L _ A U D I T ) , % l 6
2005-04-17 02:20:36 +04:00
sub % g 0 , % o 0 , % o 0
or % g 3 , % g 2 , % g 3
stx % o 0 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ I 0 ]
mov 1 , % l 6
stx % g 3 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T S T A T E ]
bne,p n % i c c , l i n u x _ s y s c a l l _ t r a c e 2
add % l 1 , 0 x4 , % l 2 ! n p c = n p c + 4
stx % l 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T P C ]
b,p t % x c c , r t r a p
stx % l 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ]
linux_syscall_trace2 :
2005-07-11 03:55:48 +04:00
add % s p , P T R E G S _ O F F , % o 0
2005-04-17 02:20:36 +04:00
call s y s c a l l _ t r a c e
2005-07-11 03:55:48 +04:00
mov 1 , % o 1
2005-04-17 02:20:36 +04:00
stx % l 1 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T P C ]
ba,p t % x c c , r t r a p
stx % l 2 , [ % s p + P T R E G S _ O F F + P T _ V 9 _ T N P C ]
.align 32
.globl __flushw_user
__flushw_user :
rdpr % o t h e r w i n , % g 1
brz,p n % g 1 , 2 f
clr % g 2
1 : save % s p , - 1 2 8 , % s p
rdpr % o t h e r w i n , % g 1
brnz,p t % g 1 , 1 b
add % g 2 , 1 , % g 2
1 : sub % g 2 , 1 , % g 2
brnz,p t % g 2 , 1 b
restore % g 0 , % g 0 , % g 0
2 : retl
nop