2005-04-16 15:20:36 -07:00
/ *
* This f i l e c o n t a i n s m i s c e l l a n e o u s l o w - l e v e l f u n c t i o n s .
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
*
* Largely r e w r i t t e n b y C o r t D o u g a n ( c o r t @cs.nmt.edu)
* and P a u l M a c k e r r a s .
*
* 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 s 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 s 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 < a s m / u n i s t d . h >
# include < a s m / e r r n o . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / p a g e . h >
# include < a s m / c a c h e . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / m m u . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / t h r e a d _ i n f o . h >
2005-09-09 20:57:26 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
2005-11-05 14:06:24 -02:00
# ifdef C O N F I G _ 8 x x
# define I S Y N C _ 8 x x i s y n c
# else
# define I S Y N C _ 8 x x
# endif
2005-04-16 15:20:36 -07:00
.text
.align 5
_ GLOBAL( _ _ d e l a y )
cmpwi 0 ,r3 ,0
mtctr r3
beqlr
1 : bdnz 1 b
blr
/ *
* Returns ( a d d r e s s w e ' r e r u n n i n g a t ) - ( a d d r e s s w e w e r e l i n k e d a t )
* for u s e b e f o r e t h e t e x t a n d d a t a a r e m a p p e d t o K E R N E L B A S E .
* /
_ GLOBAL( r e l o c _ o f f s e t )
mflr r0
bl 1 f
1 : mflr r3
lis r4 ,1 b @ha
addi r4 ,r4 ,1 b @l
subf r3 ,r4 ,r3
mtlr r0
blr
/ *
* add_ r e l o c _ o f f s e t ( x ) r e t u r n s x + r e l o c _ o f f s e t ( ) .
* /
_ GLOBAL( a d d _ r e l o c _ o f f s e t )
mflr r0
bl 1 f
1 : mflr r5
lis r4 ,1 b @ha
addi r4 ,r4 ,1 b @l
subf r5 ,r4 ,r5
add r3 ,r3 ,r5
mtlr r0
blr
/ *
* sub_ r e l o c _ o f f s e t ( x ) r e t u r n s x - r e l o c _ o f f s e t ( ) .
* /
_ GLOBAL( s u b _ r e l o c _ o f f s e t )
mflr r0
bl 1 f
1 : mflr r5
lis r4 ,1 b @ha
addi r4 ,r4 ,1 b @l
subf r5 ,r4 ,r5
subf r3 ,r5 ,r3
mtlr r0
blr
/ *
* reloc_ g o t 2 r u n s t h r o u g h t h e . g o t 2 s e c t i o n a d d i n g a n o f f s e t
* to e a c h e n t r y .
* /
_ GLOBAL( r e l o c _ g o t 2 )
mflr r11
lis r7 ,_ _ g o t 2 _ s t a r t @ha
addi r7 ,r7 ,_ _ g o t 2 _ s t a r t @l
lis r8 ,_ _ g o t 2 _ e n d @ha
addi r8 ,r8 ,_ _ g o t 2 _ e n d @l
subf r8 ,r7 ,r8
srwi. r8 ,r8 ,2
beqlr
mtctr r8
bl 1 f
1 : mflr r0
lis r4 ,1 b @ha
addi r4 ,r4 ,1 b @l
subf r0 ,r4 ,r0
add r7 ,r0 ,r7
2 : lwz r0 ,0 ( r7 )
add r0 ,r0 ,r3
stw r0 ,0 ( r7 )
addi r7 ,r7 ,4
bdnz 2 b
mtlr r11
blr
/ *
* call_ s e t u p _ c p u - c a l l t h e s e t u p _ c p u f u n c t i o n f o r t h i s c p u
* r3 = d a t a o f f s e t , r24 = c p u n u m b e r
*
* Setup f u n c t i o n i s c a l l e d w i t h :
* r3 = d a t a o f f s e t
2005-09-27 15:13:12 -05:00
* r4 = p t r t o C P U s p e c ( r e l o c a t e d )
2005-04-16 15:20:36 -07:00
* /
_ GLOBAL( c a l l _ s e t u p _ c p u )
2005-09-27 15:13:12 -05:00
addis r4 ,r3 ,c u r _ c p u _ s p e c @ha
addi r4 ,r4 ,c u r _ c p u _ s p e c @l
lwz r4 ,0 ( r4 )
add r4 ,r4 ,r3
lwz r5 ,C P U _ S P E C _ S E T U P ( r4 )
cmpi 0 ,r5 ,0
2005-04-16 15:20:36 -07:00
add r5 ,r5 ,r3
2005-09-27 15:13:12 -05:00
beqlr
mtctr r5
2005-04-16 15:20:36 -07:00
bctr
/ *
* complement m a s k o n t h e m s r t h e n " o r " s o m e v a l u e s o n .
* _ nmask_ a n d _ o r _ m s r ( n m a s k , v a l u e _ t o _ o r )
* /
_ GLOBAL( _ n m a s k _ a n d _ o r _ m s r )
mfmsr r0 / * G e t c u r r e n t m s r * /
andc r0 ,r0 ,r3 / * A n d o f f t h e b i t s s e t i n r3 ( f i r s t p a r m ) * /
or r0 ,r0 ,r4 / * O r o n t h e b i t s i n r4 ( s e c o n d p a r m ) * /
SYNC / * S o m e c h i p r e v s h a v e p r o b l e m s h e r e . . . * /
mtmsr r0 / * U p d a t e m a c h i n e s t a t e * /
isync
blr / * D o n e * /
/ *
* Flush M M U T L B
* /
_ GLOBAL( _ t l b i a )
# if d e f i n e d ( C O N F I G _ 4 0 x )
sync / * F l u s h t o m e m o r y b e f o r e c h a n g i n g m a p p i n g * /
tlbia
isync / * F l u s h s h a d o w T L B * /
# elif d e f i n e d ( C O N F I G _ 4 4 x )
li r3 ,0
sync
/* Load high watermark */
lis r4 ,t l b _ 4 4 x _ h w a t e r @ha
lwz r5 ,t l b _ 4 4 x _ h w a t e r @l(r4)
1 : tlbwe r3 ,r3 ,P P C 4 4 x _ T L B _ P A G E I D
addi r3 ,r3 ,1
cmpw 0 ,r3 ,r5
ble 1 b
isync
# elif d e f i n e d ( C O N F I G _ F S L _ B O O K E )
/* Invalidate all entries in TLB0 */
li r3 , 0 x04
tlbivax 0 ,3
/* Invalidate all entries in TLB1 */
li r3 , 0 x0 c
tlbivax 0 ,3
/* Invalidate all entries in TLB2 */
li r3 , 0 x14
tlbivax 0 ,3
/* Invalidate all entries in TLB3 */
li r3 , 0 x1 c
tlbivax 0 ,3
msync
# ifdef C O N F I G _ S M P
tlbsync
# endif / * C O N F I G _ S M P * /
# else / * ! ( C O N F I G _ 4 0 x | | C O N F I G _ 4 4 x | | C O N F I G _ F S L _ B O O K E ) * /
# if d e f i n e d ( C O N F I G _ S M P )
rlwinm r8 ,r1 ,0 ,0 ,1 8
lwz r8 ,T I _ C P U ( r8 )
oris r8 ,r8 ,1 0
mfmsr r10
SYNC
rlwinm r0 ,r10 ,0 ,1 7 ,1 5 / * c l e a r b i t 1 6 ( M S R _ E E ) * /
rlwinm r0 ,r0 ,0 ,2 8 ,2 6 / * c l e a r D R * /
mtmsr r0
SYNC_ 6 0 1
isync
lis r9 ,m m u _ h a s h _ l o c k @h
ori r9 ,r9 ,m m u _ h a s h _ l o c k @l
tophys( r9 ,r9 )
10 : lwarx r7 ,0 ,r9
cmpwi 0 ,r7 ,0
bne- 1 0 b
stwcx. r8 ,0 ,r9
bne- 1 0 b
sync
tlbia
sync
TLBSYNC
li r0 ,0
stw r0 ,0 ( r9 ) / * c l e a r m m u _ h a s h _ l o c k * /
mtmsr r10
SYNC_ 6 0 1
isync
# else / * C O N F I G _ S M P * /
sync
tlbia
sync
# endif / * C O N F I G _ S M P * /
# endif / * ! d e f i n e d ( C O N F I G _ 4 0 x ) * /
blr
/ *
* Flush M M U T L B f o r a p a r t i c u l a r a d d r e s s
* /
_ GLOBAL( _ t l b i e )
# if d e f i n e d ( C O N F I G _ 4 0 x )
tlbsx. r3 , 0 , r3
bne 1 0 f
sync
/ * There a r e o n l y 6 4 T L B e n t r i e s , s o r3 < 6 4 , w h i c h m e a n s b i t 2 5 i s c l e a r .
* Since 2 5 i s t h e V b i t i n t h e T L B _ T A G , l o a d i n g t h i s v a l u e w i l l i n v a l i d a t e
* the T L B e n t r y . * /
tlbwe r3 , r3 , T L B _ T A G
isync
10 :
# elif d e f i n e d ( C O N F I G _ 4 4 x )
mfspr r4 ,S P R N _ M M U C R
mfspr r5 ,S P R N _ P I D / * G e t P I D * /
rlwimi r4 ,r5 ,0 ,2 4 ,3 1 / * S e t T I D * /
mtspr S P R N _ M M U C R ,r4
tlbsx. r3 , 0 , r3
bne 1 0 f
sync
/ * There a r e o n l y 6 4 T L B e n t r i e s , s o r3 < 6 4 ,
* which m e a n s b i t 2 2 , i s c l e a r . S i n c e 2 2 i s
* the V b i t i n t h e T L B _ P A G E I D , l o a d i n g t h i s
* value w i l l i n v a l i d a t e t h e T L B e n t r y .
* /
tlbwe r3 , r3 , P P C 4 4 x _ T L B _ P A G E I D
isync
10 :
# elif d e f i n e d ( C O N F I G _ F S L _ B O O K E )
rlwinm r4 , r3 , 0 , 0 , 1 9
ori r5 , r4 , 0 x08 / * T L B S E L = 1 * /
ori r6 , r4 , 0 x10 / * T L B S E L = 2 * /
ori r7 , r4 , 0 x18 / * T L B S E L = 3 * /
tlbivax 0 , r4
tlbivax 0 , r5
tlbivax 0 , r6
tlbivax 0 , r7
msync
# if d e f i n e d ( C O N F I G _ S M P )
tlbsync
# endif / * C O N F I G _ S M P * /
# else / * ! ( C O N F I G _ 4 0 x | | C O N F I G _ 4 4 x | | C O N F I G _ F S L _ B O O K E ) * /
# if d e f i n e d ( C O N F I G _ S M P )
rlwinm r8 ,r1 ,0 ,0 ,1 8
lwz r8 ,T I _ C P U ( r8 )
oris r8 ,r8 ,1 1
mfmsr r10
SYNC
rlwinm r0 ,r10 ,0 ,1 7 ,1 5 / * c l e a r b i t 1 6 ( M S R _ E E ) * /
rlwinm r0 ,r0 ,0 ,2 8 ,2 6 / * c l e a r D R * /
mtmsr r0
SYNC_ 6 0 1
isync
lis r9 ,m m u _ h a s h _ l o c k @h
ori r9 ,r9 ,m m u _ h a s h _ l o c k @l
tophys( r9 ,r9 )
10 : lwarx r7 ,0 ,r9
cmpwi 0 ,r7 ,0
bne- 1 0 b
stwcx. r8 ,0 ,r9
bne- 1 0 b
eieio
tlbie r3
sync
TLBSYNC
li r0 ,0
stw r0 ,0 ( r9 ) / * c l e a r m m u _ h a s h _ l o c k * /
mtmsr r10
SYNC_ 6 0 1
isync
# else / * C O N F I G _ S M P * /
tlbie r3
sync
# endif / * C O N F I G _ S M P * /
# endif / * ! C O N F I G _ 4 0 x * /
blr
/ *
* Flush i n s t r u c t i o n c a c h e .
* This i s a n o - o p o n t h e 6 0 1 .
* /
_ GLOBAL( f l u s h _ i n s t r u c t i o n _ c a c h e )
# if d e f i n e d ( C O N F I G _ 8 x x )
isync
lis r5 , I D C _ I N V A L L @h
mtspr S P R N _ I C _ C S T , r5
# elif d e f i n e d ( C O N F I G _ 4 x x )
# ifdef C O N F I G _ 4 0 3 G C X
li r3 , 5 1 2
mtctr r3
lis r4 , K E R N E L B A S E @h
1 : iccci 0 , r4
addi r4 , r4 , 1 6
bdnz 1 b
# else
lis r3 , K E R N E L B A S E @h
iccci 0 ,r3
# endif
# elif C O N F I G _ F S L _ B O O K E
2005-06-25 14:54:37 -07:00
BEGIN_ F T R _ S E C T I O N
mfspr r3 ,S P R N _ L 1 C S R 0
ori r3 ,r3 ,L 1 C S R 0 _ C F I | L 1 C S R 0 _ C L F C
/* msync; isync recommended here */
mtspr S P R N _ L 1 C S R 0 ,r3
isync
blr
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ S P L I T _ I D _ C A C H E )
2005-04-16 15:20:36 -07:00
mfspr r3 ,S P R N _ L 1 C S R 1
ori r3 ,r3 ,L 1 C S R 1 _ I C F I | L 1 C S R 1 _ I C L F R
mtspr S P R N _ L 1 C S R 1 ,r3
# else
mfspr r3 ,S P R N _ P V R
rlwinm r3 ,r3 ,1 6 ,1 6 ,3 1
cmpwi 0 ,r3 ,1
beqlr / * f o r 6 0 1 , d o n o t h i n g * /
/* 603/604 processor - use invalidate-all bit in HID0 */
mfspr r3 ,S P R N _ H I D 0
ori r3 ,r3 ,H I D 0 _ I C F I
mtspr S P R N _ H I D 0 ,r3
# endif / * C O N F I G _ 8 x x / 4 x x * /
isync
blr
/ *
* Write a n y m o d i f i e d d a t a c a c h e b l o c k s o u t t o m e m o r y
* and i n v a l i d a t e t h e c o r r e s p o n d i n g i n s t r u c t i o n c a c h e b l o c k s .
* This i s a n o - o p o n t h e 6 0 1 .
*
[PATCH] powerpc: Merge cacheflush.h and cache.h
The ppc32 and ppc64 versions of cacheflush.h were almost identical.
The two versions of cache.h are fairly similar, except for a bunch of
register definitions in the ppc32 version which probably belong better
elsewhere. This patch, therefore, merges both headers. Notable
points:
- there are several functions in cacheflush.h which exist only
on ppc32 or only on ppc64. These are handled by #ifdef for now, but
these should probably be consolidated, along with the actual code
behind them later.
- Confusingly, both ppc32 and ppc64 have a
flush_dcache_range(), but they're subtly different: it uses dcbf on
ppc32 and dcbst on ppc64, ppc64 has a flush_inval_dcache_range() which
uses dcbf. These too should be merged and consolidated later.
- Also flush_dcache_range() was defined in cacheflush.h on
ppc64, and in cache.h on ppc32. In the merged version it's in
cacheflush.h
- On ppc32 flush_icache_range() is a normal function from
misc.S. On ppc64, it was wrapper, testing a feature bit before
calling __flush_icache_range() which does the actual flush. This
patch takes the ppc64 approach, which amounts to no change on ppc32,
since CPU_FTR_COHERENT_ICACHE will never be set there, but does mean
renaming flush_icache_range() to __flush_icache_range() in
arch/ppc/kernel/misc.S and arch/powerpc/kernel/misc_32.S
- The PReP register info from asm-ppc/cache.h has moved to
arch/ppc/platforms/prep_setup.c
- The 8xx register info from asm-ppc/cache.h has moved to a
new asm-powerpc/reg_8xx.h, included from reg.h
- flush_dcache_all() was defined on ppc32 (only), but was
never called (although it was exported). Thus this patch removes it
from cacheflush.h and from ARCH=powerpc (misc_32.S) entirely. It's
left in ARCH=ppc for now, with the prototype moved to ppc_ksyms.c.
Built for Walnut (ARCH=ppc), 32-bit multiplatform (pmac, CHRP and PReP
ARCH=ppc, pmac and CHRP ARCH=powerpc). Built and booted on POWER5
LPAR (ARCH=powerpc and ARCH=ppc64).
Built for 32-bit powermac (ARCH=ppc and ARCH=powerpc). Built and
booted on POWER5 LPAR (ARCH=powerpc and ARCH=ppc64). Built and booted
on G5 (ARCH=powerpc)
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 11:50:16 +11:00
* _ _ flush_ i c a c h e _ r a n g e ( u n s i g n e d l o n g s t a r t , u n s i g n e d l o n g s t o p )
2005-04-16 15:20:36 -07:00
* /
[PATCH] powerpc: Merge cacheflush.h and cache.h
The ppc32 and ppc64 versions of cacheflush.h were almost identical.
The two versions of cache.h are fairly similar, except for a bunch of
register definitions in the ppc32 version which probably belong better
elsewhere. This patch, therefore, merges both headers. Notable
points:
- there are several functions in cacheflush.h which exist only
on ppc32 or only on ppc64. These are handled by #ifdef for now, but
these should probably be consolidated, along with the actual code
behind them later.
- Confusingly, both ppc32 and ppc64 have a
flush_dcache_range(), but they're subtly different: it uses dcbf on
ppc32 and dcbst on ppc64, ppc64 has a flush_inval_dcache_range() which
uses dcbf. These too should be merged and consolidated later.
- Also flush_dcache_range() was defined in cacheflush.h on
ppc64, and in cache.h on ppc32. In the merged version it's in
cacheflush.h
- On ppc32 flush_icache_range() is a normal function from
misc.S. On ppc64, it was wrapper, testing a feature bit before
calling __flush_icache_range() which does the actual flush. This
patch takes the ppc64 approach, which amounts to no change on ppc32,
since CPU_FTR_COHERENT_ICACHE will never be set there, but does mean
renaming flush_icache_range() to __flush_icache_range() in
arch/ppc/kernel/misc.S and arch/powerpc/kernel/misc_32.S
- The PReP register info from asm-ppc/cache.h has moved to
arch/ppc/platforms/prep_setup.c
- The 8xx register info from asm-ppc/cache.h has moved to a
new asm-powerpc/reg_8xx.h, included from reg.h
- flush_dcache_all() was defined on ppc32 (only), but was
never called (although it was exported). Thus this patch removes it
from cacheflush.h and from ARCH=powerpc (misc_32.S) entirely. It's
left in ARCH=ppc for now, with the prototype moved to ppc_ksyms.c.
Built for Walnut (ARCH=ppc), 32-bit multiplatform (pmac, CHRP and PReP
ARCH=ppc, pmac and CHRP ARCH=powerpc). Built and booted on POWER5
LPAR (ARCH=powerpc and ARCH=ppc64).
Built for 32-bit powermac (ARCH=ppc and ARCH=powerpc). Built and
booted on POWER5 LPAR (ARCH=powerpc and ARCH=ppc64). Built and booted
on G5 (ARCH=powerpc)
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 11:50:16 +11:00
_ GLOBAL( _ _ f l u s h _ i c a c h e _ r a n g e )
2005-04-16 15:20:36 -07:00
BEGIN_ F T R _ S E C T I O N
blr / * f o r 6 0 1 , d o n o t h i n g * /
2005-06-06 13:35:57 -07:00
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ S P L I T _ I D _ C A C H E )
2005-10-17 11:50:32 +10:00
li r5 ,L 1 _ C A C H E _ B Y T E S - 1
2005-04-16 15:20:36 -07:00
andc r3 ,r3 ,r5
subf r4 ,r3 ,r4
add r4 ,r4 ,r5
2005-10-17 11:50:32 +10:00
srwi. r4 ,r4 ,L 1 _ C A C H E _ S H I F T
2005-04-16 15:20:36 -07:00
beqlr
mtctr r4
mr r6 ,r3
1 : dcbst 0 ,r3
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync / * w a i t f o r d c b s t ' s t o g e t t o r a m * /
mtctr r4
2 : icbi 0 ,r6
2005-10-17 11:50:32 +10:00
addi r6 ,r6 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 2 b
sync / * a d d i t i o n a l s y n c n e e d e d o n g 4 * /
isync
blr
/ *
* Write a n y m o d i f i e d d a t a c a c h e b l o c k s o u t t o m e m o r y .
* Does n o t i n v a l i d a t e t h e c o r r e s p o n d i n g c a c h e l i n e s ( e s p e c i a l l y f o r
* any c o r r e s p o n d i n g i n s t r u c t i o n c a c h e ) .
*
* clean_ d c a c h e _ r a n g e ( u n s i g n e d l o n g s t a r t , u n s i g n e d l o n g s t o p )
* /
_ GLOBAL( c l e a n _ d c a c h e _ r a n g e )
2005-10-17 11:50:32 +10:00
li r5 ,L 1 _ C A C H E _ B Y T E S - 1
2005-04-16 15:20:36 -07:00
andc r3 ,r3 ,r5
subf r4 ,r3 ,r4
add r4 ,r4 ,r5
2005-10-17 11:50:32 +10:00
srwi. r4 ,r4 ,L 1 _ C A C H E _ S H I F T
2005-04-16 15:20:36 -07:00
beqlr
mtctr r4
1 : dcbst 0 ,r3
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync / * w a i t f o r d c b s t ' s t o g e t t o r a m * /
blr
/ *
* Write a n y m o d i f i e d d a t a c a c h e b l o c k s o u t t o m e m o r y a n d i n v a l i d a t e t h e m .
* Does n o t i n v a l i d a t e t h e c o r r e s p o n d i n g i n s t r u c t i o n c a c h e b l o c k s .
*
* flush_ d c a c h e _ r a n g e ( u n s i g n e d l o n g s t a r t , u n s i g n e d l o n g s t o p )
* /
_ GLOBAL( f l u s h _ d c a c h e _ r a n g e )
2005-10-17 11:50:32 +10:00
li r5 ,L 1 _ C A C H E _ B Y T E S - 1
2005-04-16 15:20:36 -07:00
andc r3 ,r3 ,r5
subf r4 ,r3 ,r4
add r4 ,r4 ,r5
2005-10-17 11:50:32 +10:00
srwi. r4 ,r4 ,L 1 _ C A C H E _ S H I F T
2005-04-16 15:20:36 -07:00
beqlr
mtctr r4
1 : dcbf 0 ,r3
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync / * w a i t f o r d c b s t ' s t o g e t t o r a m * /
blr
/ *
* Like a b o v e , b u t i n v a l i d a t e t h e D - c a c h e . T h i s i s u s e d b y t h e 8 x x
* to i n v a l i d a t e t h e c a c h e s o t h e P P C c o r e d o e s n ' t g e t s t a l e d a t a
* from t h e C P M ( n o c a c h e s n o o p i n g h e r e : - ) .
*
* invalidate_ d c a c h e _ r a n g e ( u n s i g n e d l o n g s t a r t , u n s i g n e d l o n g s t o p )
* /
_ GLOBAL( i n v a l i d a t e _ d c a c h e _ r a n g e )
2005-10-17 11:50:32 +10:00
li r5 ,L 1 _ C A C H E _ B Y T E S - 1
2005-04-16 15:20:36 -07:00
andc r3 ,r3 ,r5
subf r4 ,r3 ,r4
add r4 ,r4 ,r5
2005-10-17 11:50:32 +10:00
srwi. r4 ,r4 ,L 1 _ C A C H E _ S H I F T
2005-04-16 15:20:36 -07:00
beqlr
mtctr r4
1 : dcbi 0 ,r3
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync / * w a i t f o r d c b i ' s t o g e t t o r a m * /
blr
# ifdef C O N F I G _ N O T _ C O H E R E N T _ C A C H E
/ *
* 4 0 x c o r e s h a v e 8 K o r 1 6 K d c a c h e a n d 3 2 b y t e l i n e s i z e .
* 4 4 x h a s a 3 2 K d c a c h e a n d 3 2 b y t e l i n e s i z e .
* 8 xx h a s 1 , 2 , 4 , 8 K v a r i a n t s .
* For n o w , c o v e r t h e w o r s t c a s e o f t h e 4 4 x .
* Must b e c a l l e d w i t h e x t e r n a l i n t e r r u p t s d i s a b l e d .
* /
# define C A C H E _ N W A Y S 6 4
# define C A C H E _ N L I N E S 1 6
_ GLOBAL( f l u s h _ d c a c h e _ a l l )
li r4 , ( 2 * C A C H E _ N W A Y S * C A C H E _ N L I N E S )
mtctr r4
lis r5 , K E R N E L B A S E @h
1 : lwz r3 , 0 ( r5 ) / * L o a d o n e w o r d f r o m e v e r y l i n e * /
2005-10-17 11:50:32 +10:00
addi r5 , r5 , L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
blr
# endif / * C O N F I G _ N O T _ C O H E R E N T _ C A C H E * /
/ *
* Flush a p a r t i c u l a r p a g e f r o m t h e d a t a c a c h e t o R A M .
* Note : this i s n e c e s s a r y b e c a u s e t h e i n s t r u c t i o n c a c h e d o e s * n o t *
* snoop f r o m t h e d a t a c a c h e .
* This i s a n o - o p o n t h e 6 0 1 w h i c h h a s a u n i f i e d c a c h e .
*
* void _ _ f l u s h _ d c a c h e _ i c a c h e ( v o i d * p a g e )
* /
_ GLOBAL( _ _ f l u s h _ d c a c h e _ i c a c h e )
BEGIN_ F T R _ S E C T I O N
blr / * f o r 6 0 1 , d o n o t h i n g * /
2005-06-06 13:35:57 -07:00
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ S P L I T _ I D _ C A C H E )
2005-04-16 15:20:36 -07:00
rlwinm r3 ,r3 ,0 ,0 ,1 9 / * G e t p a g e b a s e a d d r e s s * /
2005-10-17 11:50:32 +10:00
li r4 ,4 0 9 6 / L 1 _ C A C H E _ B Y T E S / * N u m b e r o f l i n e s i n a p a g e * /
2005-04-16 15:20:36 -07:00
mtctr r4
mr r6 ,r3
0 : dcbst 0 ,r3 / * W r i t e l i n e t o r a m * /
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 0 b
sync
mtctr r4
1 : icbi 0 ,r6
2005-10-17 11:50:32 +10:00
addi r6 ,r6 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync
isync
blr
/ *
* Flush a p a r t i c u l a r p a g e f r o m t h e d a t a c a c h e t o R A M , i d e n t i f i e d
* by i t s p h y s i c a l a d d r e s s . W e t u r n o f f t h e M M U s o w e c a n j u s t u s e
* the p h y s i c a l a d d r e s s ( t h i s m a y b e a h i g h m e m p a g e w i t h o u t a k e r n e l
* mapping) .
*
* void _ _ f l u s h _ d c a c h e _ i c a c h e _ p h y s ( u n s i g n e d l o n g p h y s a d d r )
* /
_ GLOBAL( _ _ f l u s h _ d c a c h e _ i c a c h e _ p h y s )
BEGIN_ F T R _ S E C T I O N
blr / * f o r 6 0 1 , d o n o t h i n g * /
2005-06-06 13:35:57 -07:00
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ S P L I T _ I D _ C A C H E )
2005-04-16 15:20:36 -07:00
mfmsr r10
rlwinm r0 ,r10 ,0 ,2 8 ,2 6 / * c l e a r D R * /
mtmsr r0
isync
rlwinm r3 ,r3 ,0 ,0 ,1 9 / * G e t p a g e b a s e a d d r e s s * /
2005-10-17 11:50:32 +10:00
li r4 ,4 0 9 6 / L 1 _ C A C H E _ B Y T E S / * N u m b e r o f l i n e s i n a p a g e * /
2005-04-16 15:20:36 -07:00
mtctr r4
mr r6 ,r3
0 : dcbst 0 ,r3 / * W r i t e l i n e t o r a m * /
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 0 b
sync
mtctr r4
1 : icbi 0 ,r6
2005-10-17 11:50:32 +10:00
addi r6 ,r6 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
sync
mtmsr r10 / * r e s t o r e D R * /
isync
blr
/ *
* Clear p a g e s u s i n g t h e d c b z i n s t r u c t i o n , w h i c h d o e s n ' t c a u s e a n y
* memory t r a f f i c ( e x c e p t t o w r i t e o u t a n y c a c h e l i n e s w h i c h g e t
* displaced) . T h i s o n l y w o r k s o n c a c h e a b l e m e m o r y .
*
* void c l e a r _ p a g e s ( v o i d * p a g e , i n t o r d e r ) ;
* /
_ GLOBAL( c l e a r _ p a g e s )
2005-10-17 11:50:32 +10:00
li r0 ,4 0 9 6 / L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
slw r0 ,r0 ,r4
mtctr r0
# ifdef C O N F I G _ 8 x x
li r4 , 0
1 : stw r4 , 0 ( r3 )
stw r4 , 4 ( r3 )
stw r4 , 8 ( r3 )
stw r4 , 1 2 ( r3 )
# else
1 : dcbz 0 ,r3
# endif
2005-10-17 11:50:32 +10:00
addi r3 ,r3 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 b
blr
/ *
* Copy a w h o l e p a g e . W e u s e t h e d c b z i n s t r u c t i o n o n t h e d e s t i n a t i o n
* to r e d u c e m e m o r y t r a f f i c ( i t e l i m i n a t e s t h e u n n e c e s s a r y r e a d s o f
* the d e s t i n a t i o n i n t o c a c h e ) . T h i s r e q u i r e s t h a t t h e d e s t i n a t i o n
* is c a c h e a b l e .
* /
# define C O P Y _ 1 6 _ B Y T E S \
lwz r6 ,4 ( r4 ) ; \
lwz r7 ,8 ( r4 ) ; \
lwz r8 ,1 2 ( r4 ) ; \
lwzu r9 ,1 6 ( r4 ) ; \
stw r6 ,4 ( r3 ) ; \
stw r7 ,8 ( r3 ) ; \
stw r8 ,1 2 ( r3 ) ; \
stwu r9 ,1 6 ( r3 )
_ GLOBAL( c o p y _ p a g e )
addi r3 ,r3 ,- 4
addi r4 ,r4 ,- 4
# ifdef C O N F I G _ 8 x x
/* don't use prefetch on 8xx */
2005-10-17 11:50:32 +10:00
li r0 ,4 0 9 6 / L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
mtctr r0
1 : COPY_ 1 6 _ B Y T E S
bdnz 1 b
blr
# else / * n o t 8 x x , w e c a n p r e f e t c h * /
li r5 ,4
# if M A X _ C O P Y _ P R E F E T C H > 1
li r0 ,M A X _ C O P Y _ P R E F E T C H
li r11 ,4
mtctr r0
11 : dcbt r11 ,r4
2005-10-17 11:50:32 +10:00
addi r11 ,r11 ,L 1 _ C A C H E _ B Y T E S
2005-04-16 15:20:36 -07:00
bdnz 1 1 b
# else / * M A X _ C O P Y _ P R E F E T C H = = 1 * /
dcbt r5 ,r4
2005-10-17 11:50:32 +10:00
li r11 ,L 1 _ C A C H E _ B Y T E S + 4
2005-04-16 15:20:36 -07:00
# endif / * M A X _ C O P Y _ P R E F E T C H * /
2005-10-17 11:50:32 +10:00
li r0 ,4 0 9 6 / L 1 _ C A C H E _ B Y T E S - M A X _ C O P Y _ P R E F E T C H
2005-04-16 15:20:36 -07:00
crclr 4 * c r0 + e q
2 :
mtctr r0
1 :
dcbt r11 ,r4
dcbz r5 ,r3
COPY_ 1 6 _ B Y T E S
2005-10-17 11:50:32 +10:00
# if L 1 _ C A C H E _ B Y T E S > = 3 2
2005-04-16 15:20:36 -07:00
COPY_ 1 6 _ B Y T E S
2005-10-17 11:50:32 +10:00
# if L 1 _ C A C H E _ B Y T E S > = 6 4
2005-04-16 15:20:36 -07:00
COPY_ 1 6 _ B Y T E S
COPY_ 1 6 _ B Y T E S
2005-10-17 11:50:32 +10:00
# if L 1 _ C A C H E _ B Y T E S > = 1 2 8
2005-04-16 15:20:36 -07:00
COPY_ 1 6 _ B Y T E S
COPY_ 1 6 _ B Y T E S
COPY_ 1 6 _ B Y T E S
COPY_ 1 6 _ B Y T E S
# endif
# endif
# endif
bdnz 1 b
beqlr
crnot 4 * c r0 + e q ,4 * c r0 + e q
li r0 ,M A X _ C O P Y _ P R E F E T C H
li r11 ,4
b 2 b
# endif / * C O N F I G _ 8 x x * /
/ *
* void a t o m i c _ c l e a r _ m a s k ( a t o m i c _ t m a s k , a t o m i c _ t * a d d r )
* void a t o m i c _ s e t _ m a s k ( a t o m i c _ t m a s k , a t o m i c _ t * a d d r ) ;
* /
_ GLOBAL( a t o m i c _ c l e a r _ m a s k )
10 : lwarx r5 ,0 ,r4
andc r5 ,r5 ,r3
PPC4 0 5 _ E R R 7 7 ( 0 ,r4 )
stwcx. r5 ,0 ,r4
bne- 1 0 b
blr
_ GLOBAL( a t o m i c _ s e t _ m a s k )
10 : lwarx r5 ,0 ,r4
or r5 ,r5 ,r3
PPC4 0 5 _ E R R 7 7 ( 0 ,r4 )
stwcx. r5 ,0 ,r4
bne- 1 0 b
blr
/ *
* I/ O s t r i n g o p e r a t i o n s
*
* insb( p o r t , b u f , l e n )
* outsb( p o r t , b u f , l e n )
* insw( p o r t , b u f , l e n )
* outsw( p o r t , b u f , l e n )
* insl( p o r t , b u f , l e n )
* outsl( p o r t , b u f , l e n )
* insw_ n s ( p o r t , b u f , l e n )
* outsw_ n s ( p o r t , b u f , l e n )
* insl_ n s ( p o r t , b u f , l e n )
* outsl_ n s ( p o r t , b u f , l e n )
*
* The * _ n s v e r s i o n s d o n ' t d o b y t e - s w a p p i n g .
* /
_ GLOBAL( _ i n s b )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,1
blelr-
00 : lbz r5 ,0 ( r3 )
2005-11-05 14:06:24 -02:00
01 : eieio
02 : stbu r5 ,1 ( r4 )
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
_ GLOBAL( _ o u t s b )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,1
blelr-
00 : lbzu r5 ,1 ( r4 )
2005-11-05 14:06:24 -02:00
01 : stb r5 ,0 ( r3 )
02 : eieio
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
_ GLOBAL( _ i n s w _ n s )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,2
blelr-
00 : lhz r5 ,0 ( r3 )
2005-11-05 14:06:24 -02:00
01 : eieio
02 : sthu r5 ,2 ( r4 )
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
_ GLOBAL( _ o u t s w _ n s )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,2
blelr-
00 : lhzu r5 ,2 ( r4 )
2005-11-05 14:06:24 -02:00
01 : sth r5 ,0 ( r3 )
02 : eieio
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
_ GLOBAL( _ i n s l _ n s )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,4
blelr-
00 : lwz r5 ,0 ( r3 )
2005-11-05 14:06:24 -02:00
01 : eieio
02 : stwu r5 ,4 ( r4 )
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
_ GLOBAL( _ o u t s l _ n s )
cmpwi 0 ,r5 ,0
mtctr r5
subi r4 ,r4 ,4
blelr-
00 : lwzu r5 ,4 ( r4 )
2005-11-05 14:06:24 -02:00
01 : stw r5 ,0 ( r3 )
02 : eieio
ISYNC_ 8 x x
.section .fixup , " ax"
03 : blr
.text
.section _ _ ex_ t a b l e , " a "
.align 2
.long 0 0 b, 0 3 b
.long 0 1 b, 0 3 b
.long 0 2 b, 0 3 b
.text
2005-04-16 15:20:36 -07:00
bdnz 0 0 b
blr
/ *
* Extended p r e c i s i o n s h i f t s .
*
* Updated t o b e v a l i d f o r s h i f t c o u n t s f r o m 0 t o 6 3 i n c l u s i v e .
* - - Gabriel
*
* R3 / R 4 h a s 6 4 b i t v a l u e
* R5 h a s s h i f t c o u n t
* result i n R 3 / R 4
*
* ashrdi3 : arithmetic r i g h t s h i f t ( s i g n p r o p a g a t i o n )
* lshrdi3 : logical r i g h t s h i f t
* ashldi3 : left s h i f t
* /
_ GLOBAL( _ _ a s h r d i 3 )
subfic r6 ,r5 ,3 2
srw r4 ,r4 ,r5 # L S W = c o u n t > 31 ? 0 : L S W > > c o u n t
addi r7 ,r5 ,3 2 # c o u l d b e x o r i , o r a d d i w i t h - 32
slw r6 ,r3 ,r6 # t 1 = c o u n t > 3 1 ? 0 : M S W < < ( 3 2 - c o u n t )
rlwinm r8 ,r7 ,0 ,3 2 # t 3 = ( c o u n t < 3 2 ) ? 3 2 : 0
sraw r7 ,r3 ,r7 # t 2 = M S W > > ( c o u n t - 3 2 )
or r4 ,r4 ,r6 # L S W | = t 1
slw r7 ,r7 ,r8 # t 2 = ( c o u n t < 3 2 ) ? 0 : t 2
sraw r3 ,r3 ,r5 # M S W = M S W > > c o u n t
or r4 ,r4 ,r7 # L S W | = t 2
blr
_ GLOBAL( _ _ a s h l d i 3 )
subfic r6 ,r5 ,3 2
slw r3 ,r3 ,r5 # M S W = c o u n t > 31 ? 0 : M S W < < c o u n t
addi r7 ,r5 ,3 2 # c o u l d b e x o r i , o r a d d i w i t h - 32
srw r6 ,r4 ,r6 # t 1 = c o u n t > 3 1 ? 0 : L S W > > ( 3 2 - c o u n t )
slw r7 ,r4 ,r7 # t 2 = c o u n t < 3 2 ? 0 : L S W < < ( c o u n t - 3 2 )
or r3 ,r3 ,r6 # M S W | = t 1
slw r4 ,r4 ,r5 # L S W = L S W < < c o u n t
or r3 ,r3 ,r7 # M S W | = t 2
blr
_ GLOBAL( _ _ l s h r d i 3 )
subfic r6 ,r5 ,3 2
srw r4 ,r4 ,r5 # L S W = c o u n t > 31 ? 0 : L S W > > c o u n t
addi r7 ,r5 ,3 2 # c o u l d b e x o r i , o r a d d i w i t h - 32
slw r6 ,r3 ,r6 # t 1 = c o u n t > 3 1 ? 0 : M S W < < ( 3 2 - c o u n t )
srw r7 ,r3 ,r7 # t 2 = c o u n t < 3 2 ? 0 : M S W > > ( c o u n t - 3 2 )
or r4 ,r4 ,r6 # L S W | = t 1
srw r3 ,r3 ,r5 # M S W = M S W > > c o u n t
or r4 ,r4 ,r7 # L S W | = t 2
blr
_ GLOBAL( a b s )
srawi r4 ,r3 ,3 1
xor r3 ,r3 ,r4
sub r3 ,r3 ,r4
blr
_ GLOBAL( _ g e t _ S P )
mr r3 ,r1 / * C l o s e e n o u g h * /
blr
/ *
* Create a k e r n e l t h r e a d
* kernel_ t h r e a d ( f n , a r g , f l a g s )
* /
_ GLOBAL( k e r n e l _ t h r e a d )
stwu r1 ,- 1 6 ( r1 )
stw r30 ,8 ( r1 )
stw r31 ,1 2 ( r1 )
mr r30 ,r3 / * f u n c t i o n * /
mr r31 ,r4 / * a r g u m e n t * /
ori r3 ,r5 ,C L O N E _ V M / * f l a g s * /
oris r3 ,r3 ,C L O N E _ U N T R A C E D > > 1 6
li r4 ,0 / * n e w s p ( u n u s e d ) * /
li r0 ,_ _ N R _ c l o n e
sc
cmpwi 0 ,r3 ,0 / * p a r e n t o r c h i l d ? * /
bne 1 f / * r e t u r n i f p a r e n t * /
li r0 ,0 / * m a k e t o p - l e v e l s t a c k f r a m e * /
stwu r0 ,- 1 6 ( r1 )
mtlr r30 / * f n a d d r i n l r * /
mr r3 ,r31 / * l o a d a r g a n d c a l l f n * /
2005-07-31 22:34:52 -07:00
PPC4 4 0 E P _ E R R 4 2
2005-04-16 15:20:36 -07:00
blrl
li r0 ,_ _ N R _ e x i t / * e x i t i f f u n c t i o n r e t u r n s * /
li r3 ,0
sc
1 : lwz r30 ,8 ( r1 )
lwz r31 ,1 2 ( r1 )
addi r1 ,r1 ,1 6
blr
2006-10-02 02:18:34 -07:00
_ GLOBAL( k e r n e l _ e x e c v e )
li r0 ,_ _ N R _ e x e c v e
sc
bnslr
neg r3 ,r3
blr
2005-04-16 15:20:36 -07:00
/ *
* This r o u t i n e i s j u s t h e r e t o k e e p G C C h a p p y - s i g h . . .
* /
_ GLOBAL( _ _ m a i n )
blr