2005-04-16 15:20:36 -07:00
/ *
* PowerPC v e r s i o n
* 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)
* Rewritten b y C o r t D o u g a n ( c o r t @cs.nmt.edu) for PReP
* Copyright ( C ) 1 9 9 6 C o r t D o u g a n < c o r t @cs.nmt.edu>
* Low- l e v e l e x c e p t i o n h a n d l e r s a n d M M U s u p p o r t
* rewritten b y P a u l M a c k e r r a s .
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
* MPC8 x x m o d i f i c a t i o n s b y D a n M a l e k
* Copyright ( C ) 1 9 9 7 D a n M a l e k ( d m a l e k @jlc.net).
*
* This f i l e c o n t a i n s l o w - l e v e l s u p p o r t a n d s e t u p f o r P o w e r P C 8 x x
* embedded p r o c e s s o r s , i n c l u d i n g t r a p a n d i n t e r r u p t d i s p a t c h .
*
* 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 < 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 / m m u . h >
# include < a s m / c a c h e . h >
# include < a s m / p g t a b l e . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p p c _ a s m . 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
/* Macro to make the code more readable. */
# ifdef C O N F I G _ 8 x x _ C P U 6
# define D O _ 8 x x _ C P U 6 ( v a l , r e g ) \
li r e g , v a l ; \
stw r e g , 1 2 ( r0 ) ; \
lwz r e g , 1 2 ( r0 ) ;
# else
# define D O _ 8 x x _ C P U 6 ( v a l , r e g )
# endif
.text
.globl _stext
_stext :
.text
.globl _start
_start :
/ * MPC8 x x
* This p o r t w a s d o n e o n a n M B X b o a r d w i t h a n 8 6 0 . R i g h t n o w I o n l y
* support a n E L F c o m p r e s s e d ( z I m a g e ) b o o t f r o m E P P C - B u g b e c a u s e t h e
* code t h e r e l o a d s u p s o m e r e g i s t e r s b e f o r e c a l l i n g u s :
* r3 : ptr t o b o a r d i n f o d a t a
* r4 : initrd_ s t a r t o r i f n o i n i t r d t h e n 0
* r5 : initrd_ e n d - u n u s e d i f r4 i s 0
* r6 : Start o f c o m m a n d l i n e s t r i n g
* r7 : End o f c o m m a n d l i n e s t r i n g
*
* I d e c i d e d t o u s e c o n d i t i o n a l c o m p i l a t i o n i n s t e a d o f c h e c k i n g P V R a n d
* adding m o r e p r o c e s s o r s p e c i f i c b r a n c h e s a r o u n d c o d e I d o n ' t n e e d .
* Since t h i s i s a n e m b e d d e d p r o c e s s o r , I a l s o a p p r e c i a t e a n y m e m o r y
* savings I c a n g e t .
*
* The M P C 8 x x d o e s n o t h a v e a n y B A T s , b u t i t s u p p o r t s l a r g e p a g e s i z e s .
* We f i r s t i n i t i a l i z e t h e M M U t o s u p p o r t 8 M b y t e p a g e s , t h e n l o a d o n e
* entry i n t o e a c h o f t h e i n s t r u c t i o n a n d d a t a T L B s t o m a p t h e f i r s t
* 8 M 1 : 1 . I a l s o m a p p e d a n a d d i t i o n a l I / O s p a c e 1 : 1 s o w e c a n g e t t o
* the " i n t e r n a l " p r o c e s s o r r e g i s t e r s b e f o r e M M U _ i n i t i s c a l l e d .
*
* The T L B c o d e c u r r e n t l y c o n t a i n s a m a j o r h a c k . S i n c e I u s e t h e c o n d i t i o n
* code r e g i s t e r , I h a v e t o s a v e a n d r e s t o r e i t . I a m o u t o f r e g i s t e r s , s o
* I j u s t s t o r e i t i n m e m o r y l o c a t i o n 0 ( t h e T L B h a n d l e r s a r e n o t r e e n t r a n t ) .
* To a v o i d m a k i n g a n y d e c i s i o n s , I n e e d t o u s e t h e " s e g m e n t " v a l i d b i t
* in t h e f i r s t l e v e l t a b l e , b u t t h a t w o u l d r e q u i r e m a n y c h a n g e s t o t h e
* Linux p a g e d i r e c t o r y / t a b l e f u n c t i o n s t h a t I d o n ' t w a n t t o d o r i g h t n o w .
*
* I u s e d t o u s e S P R G 2 f o r a t e m p o r a r y r e g i s t e r i n t h e T L B h a n d l e r , b u t i t
* has s i n c e b e e n p u t t o o t h e r u s e s . I n o w u s e a h a c k t o s a v e a r e g i s t e r
* and t h e C C R a t m e m o r y l o c a t i o n 0 . . . . . S o m e d a y I ' l l f i x t h i s . . . . .
* - - Dan
* /
.globl __start
__start :
mr r31 ,r3 / * s a v e p a r a m e t e r s * /
mr r30 ,r4
mr r29 ,r5
mr r28 ,r6
mr r27 ,r7
/ * We h a v e t o t u r n o n t h e M M U r i g h t a w a y s o w e g e t c a c h e m o d e s
* set c o r r e c t l y .
* /
bl i n i t i a l _ m m u
/ * We n o w h a v e t h e l o w e r 8 M e g m a p p e d i n t o T L B e n t r i e s , a n d t h e c a c h e s
* ready t o w o r k .
* /
turn_on_mmu :
mfmsr r0
ori r0 ,r0 ,M S R _ D R | M S R _ I R
mtspr S P R N _ S R R 1 ,r0
lis r0 ,s t a r t _ h e r e @h
ori r0 ,r0 ,s t a r t _ h e r e @l
mtspr S P R N _ S R R 0 ,r0
SYNC
rfi / * e n a b l e s M M U * /
/ *
* Exception e n t r y c o d e . T h i s c o d e r u n s w i t h a d d r e s s t r a n s l a t i o n
* turned o f f , i . e . u s i n g p h y s i c a l a d d r e s s e s .
* We a s s u m e s p r g 3 h a s t h e p h y s i c a l a d d r e s s o f t h e c u r r e n t
* task' s t h r e a d _ s t r u c t .
* /
# define E X C E P T I O N _ P R O L O G \
mtspr S P R N _ S P R G 0 ,r10 ; \
mtspr S P R N _ S P R G 1 ,r11 ; \
mfcr r10 ; \
EXCEPTION_ P R O L O G _ 1 ; \
EXCEPTION_ P R O L O G _ 2
# define E X C E P T I O N _ P R O L O G _ 1 \
mfspr r11 ,S P R N _ S R R 1 ; /* check whether user or kernel */ \
andi. r11 ,r11 ,M S R _ P R ; \
tophys( r11 ,r1 ) ; /* use tophys(r1) if kernel */ \
beq 1 f ; \
mfspr r11 ,S P R N _ S P R G 3 ; \
lwz r11 ,T H R E A D _ I N F O - T H R E A D ( r11 ) ; \
addi r11 ,r11 ,T H R E A D _ S I Z E ; \
tophys( r11 ,r11 ) ; \
1 : subi r11 ,r11 ,I N T _ F R A M E _ S I Z E / * a l l o c e x c . f r a m e * /
# define E X C E P T I O N _ P R O L O G _ 2 \
CLR_ T O P 3 2 ( r11 ) ; \
stw r10 ,_ C C R ( r11 ) ; /* save registers */ \
stw r12 ,G P R 1 2 ( r11 ) ; \
stw r9 ,G P R 9 ( r11 ) ; \
mfspr r10 ,S P R N _ S P R G 0 ; \
stw r10 ,G P R 1 0 ( r11 ) ; \
mfspr r12 ,S P R N _ S P R G 1 ; \
stw r12 ,G P R 1 1 ( r11 ) ; \
mflr r10 ; \
stw r10 ,_ L I N K ( r11 ) ; \
mfspr r12 ,S P R N _ S R R 0 ; \
mfspr r9 ,S P R N _ S R R 1 ; \
stw r1 ,G P R 1 ( r11 ) ; \
stw r1 ,0 ( r11 ) ; \
tovirt( r1 ,r11 ) ; /* set new kernel sp */ \
li r10 ,M S R _ K E R N E L & ~ ( M S R _ I R | M S R _ D R ) ; /* can take exceptions */ \
MTMSRD( r10 ) ; /* (except for mach check in rtas) */ \
stw r0 ,G P R 0 ( r11 ) ; \
SAVE_ 4 G P R S ( 3 , r11 ) ; \
SAVE_ 2 G P R S ( 7 , r11 )
/ *
* Note : code w h i c h f o l l o w s t h i s u s e s c r0 . e q ( s e t i f f r o m k e r n e l ) ,
* r1 1 , r12 ( S R R 0 ) , a n d r9 ( S R R 1 ) .
*
* Note2 : once w e h a v e s e t r1 w e a r e i n a p o s i t i o n t o t a k e e x c e p t i o n s
* again, a n d w e c o u l d t h u s s e t M S R : R I a t t h a t p o i n t .
* /
/ *
* Exception v e c t o r s .
* /
# define E X C E P T I O N ( n , l a b e l , h d l r , x f e r ) \
. = n; \
label : \
EXCEPTION_ P R O L O G ; \
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D ; \
xfer( n , h d l r )
# define E X C _ X F E R _ T E M P L A T E ( n , h d l r , t r a p , c o p y e e , t f e r , r e t ) \
li r10 ,t r a p ; \
stw r10 ,T R A P ( r11 ) ; \
li r10 ,M S R _ K E R N E L ; \
copyee( r10 , r9 ) ; \
bl t f e r ; \
i## n : \
.long hdlr; \
.long ret
# define C O P Y _ E E ( d , s ) r l w i m i d ,s ,0 ,1 6 ,1 6
# define N O C O P Y ( d , s )
# define E X C _ X F E R _ S T D ( n , h d l r ) \
EXC_ X F E R _ T E M P L A T E ( n , h d l r , n , N O C O P Y , t r a n s f e r _ t o _ h a n d l e r _ f u l l , \
ret_ f r o m _ e x c e p t _ f u l l )
# define E X C _ X F E R _ L I T E ( n , h d l r ) \
EXC_ X F E R _ T E M P L A T E ( n , h d l r , n + 1 , N O C O P Y , t r a n s f e r _ t o _ h a n d l e r , \
ret_ f r o m _ e x c e p t )
# define E X C _ X F E R _ E E ( n , h d l r ) \
EXC_ X F E R _ T E M P L A T E ( n , h d l r , n , C O P Y _ E E , t r a n s f e r _ t o _ h a n d l e r _ f u l l , \
ret_ f r o m _ e x c e p t _ f u l l )
# define E X C _ X F E R _ E E _ L I T E ( n , h d l r ) \
EXC_ X F E R _ T E M P L A T E ( n , h d l r , n + 1 , C O P Y _ E E , t r a n s f e r _ t o _ h a n d l e r , \
ret_ f r o m _ e x c e p t )
/* System reset */
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x10 0 , R e s e t , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ S T D )
2005-04-16 15:20:36 -07:00
/* Machine check */
. = 0 x2 0 0
MachineCheck :
EXCEPTION_ P R O L O G
mfspr r4 ,S P R N _ D A R
stw r4 ,_ D A R ( r11 )
mfspr r5 ,S P R N _ D S I S R
stw r5 ,_ D S I S R ( r11 )
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
2005-10-01 18:43:42 +10:00
EXC_ X F E R _ S T D ( 0 x20 0 , m a c h i n e _ c h e c k _ e x c e p t i o n )
2005-04-16 15:20:36 -07:00
/ * Data a c c e s s e x c e p t i o n .
* This i s " n e v e r g e n e r a t e d " b y t h e M P C 8 x x . W e j u m p t o i t f o r o t h e r
* translation e r r o r s .
* /
. = 0 x3 0 0
DataAccess :
EXCEPTION_ P R O L O G
mfspr r10 ,S P R N _ D S I S R
stw r10 ,_ D S I S R ( r11 )
mr r5 ,r10
mfspr r4 ,S P R N _ D A R
EXC_ X F E R _ E E _ L I T E ( 0 x30 0 , h a n d l e _ p a g e _ f a u l t )
/ * Instruction a c c e s s e x c e p t i o n .
* This i s " n e v e r g e n e r a t e d " b y t h e M P C 8 x x . W e j u m p t o i t f o r o t h e r
* translation e r r o r s .
* /
. = 0 x4 0 0
InstructionAccess :
EXCEPTION_ P R O L O G
mr r4 ,r12
mr r5 ,r9
EXC_ X F E R _ E E _ L I T E ( 0 x40 0 , h a n d l e _ p a g e _ f a u l t )
/* External interrupt */
EXCEPTION( 0 x50 0 , H a r d w a r e I n t e r r u p t , d o _ I R Q , E X C _ X F E R _ L I T E )
/* Alignment exception */
. = 0 x6 0 0
Alignment :
EXCEPTION_ P R O L O G
mfspr r4 ,S P R N _ D A R
stw r4 ,_ D A R ( r11 )
mfspr r5 ,S P R N _ D S I S R
stw r5 ,_ D S I S R ( r11 )
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
2005-10-01 18:43:42 +10:00
EXC_ X F E R _ E E ( 0 x60 0 , a l i g n m e n t _ e x c e p t i o n )
2005-04-16 15:20:36 -07:00
/* Program check exception */
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x70 0 , P r o g r a m C h e c k , p r o g r a m _ c h e c k _ e x c e p t i o n , E X C _ X F E R _ S T D )
2005-04-16 15:20:36 -07:00
/ * No F P U o n M P C 8 x x . T h i s e x c e p t i o n i s n o t s u p p o s e d t o h a p p e n .
* /
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x80 0 , F P U n a v a i l a b l e , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ S T D )
2005-04-16 15:20:36 -07:00
/* Decrementer */
EXCEPTION( 0 x90 0 , D e c r e m e n t e r , t i m e r _ i n t e r r u p t , E X C _ X F E R _ L I T E )
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x a00 , T r a p _ 0 a , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x b00 , T r a p _ 0 b , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
2005-04-16 15:20:36 -07:00
/* System call */
. = 0 xc0 0
SystemCall :
EXCEPTION_ P R O L O G
EXC_ X F E R _ E E _ L I T E ( 0 x c00 , D o S y s c a l l )
/* Single step - not used on 601 */
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x d00 , S i n g l e S t e p , s i n g l e _ s t e p _ e x c e p t i o n , E X C _ X F E R _ S T D )
EXCEPTION( 0 x e 0 0 , T r a p _ 0 e , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x f00 , T r a p _ 0 f , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
2005-04-16 15:20:36 -07:00
/ * On t h e M P C 8 x x , t h i s i s a s o f t w a r e e m u l a t i o n i n t e r r u p t . I t o c c u r s
* for a l l u n i m p l e m e n t e d a n d i l l e g a l i n s t r u c t i o n s .
* /
EXCEPTION( 0 x10 0 0 , S o f t E m u , S o f t w a r e E m u l a t i o n , E X C _ X F E R _ S T D )
. = 0 x1 1 0 0
/ *
* For t h e M P C 8 x x , t h i s i s a s o f t w a r e t a b l e w a l k t o l o a d t h e i n s t r u c t i o n
* TLB. I t i s m o d e l l e d a f t e r t h e e x a m p l e i n t h e M o t o r o l a m a n u a l . T h e t a s k
* switch l o a d s t h e M _ T W B r e g i s t e r w i t h t h e p o i n t e r t o t h e f i r s t l e v e l t a b l e .
2005-07-27 11:44:08 -07:00
* If w e d i s c o v e r t h e r e i s n o s e c o n d l e v e l t a b l e ( v a l u e i s z e r o ) o r i f t h e r e
* is a n i n v a l i d p t e , w e l o a d t h a t i n t o t h e T L B , w h i c h c a u s e s a n o t h e r f a u l t
* into t h e T L B E r r o r i n t e r r u p t w h e r e w e c a n h a n d l e s u c h p r o b l e m s .
* We h a v e t o u s e t h e M D _ x x x r e g i s t e r s f o r t h e t a b l e w a l k b e c a u s e t h e
* equivalent M I _ x x x r e g i s t e r s o n l y p e r f o r m t h e a t t r i b u t e f u n c t i o n s .
2005-04-16 15:20:36 -07:00
* /
InstructionTLBMiss :
# ifdef C O N F I G _ 8 x x _ C P U 6
stw r3 , 8 ( r0 )
# endif
DO_ 8 x x _ C P U 6 ( 0 x3 f80 , r3 )
mtspr S P R N _ M _ T W , r10 / * S a v e a c o u p l e o f w o r k i n g r e g i s t e r s * /
mfcr r10
stw r10 , 0 ( r0 )
stw r11 , 4 ( r0 )
mfspr r10 , S P R N _ S R R 0 / * G e t e f f e c t i v e a d d r e s s o f f a u l t * /
DO_ 8 x x _ C P U 6 ( 0 x37 8 0 , r3 )
mtspr S P R N _ M D _ E P N , r10 / * H a v e t o u s e M D _ E P N f o r w a l k , M I _ E P N c a n ' t * /
mfspr r10 , S P R N _ M _ T W B / * G e t l e v e l 1 t a b l e e n t r y a d d r e s s * /
/ * If w e a r e f a u l t i n g a k e r n e l a d d r e s s , w e h a v e t o u s e t h e
* kernel p a g e t a b l e s .
* /
andi. r11 , r10 , 0 x08 0 0 / * A d d r e s s > = 0 x80 0 0 0 0 0 0 * /
beq 3 f
lis r11 , s w a p p e r _ p g _ d i r @h
ori r11 , r11 , s w a p p e r _ p g _ d i r @l
rlwimi r10 , r11 , 0 , 2 , 1 9
3 :
lwz r11 , 0 ( r10 ) / * G e t t h e l e v e l 1 e n t r y * /
rlwinm. r10 , r11 ,0 ,0 ,1 9 / * E x t r a c t p a g e d e s c r i p t o r p a g e a d d r e s s * /
beq 2 f / * I f z e r o , d o n ' t t r y t o f i n d a p t e * /
/ * We h a v e a p t e t a b l e , s o l o a d t h e M I _ T W C w i t h t h e a t t r i b u t e s
* for t h i s " s e g m e n t . "
* /
ori r11 ,r11 ,1 / * S e t v a l i d b i t * /
DO_ 8 x x _ C P U 6 ( 0 x2 b80 , r3 )
mtspr S P R N _ M I _ T W C , r11 / * S e t s e g m e n t a t t r i b u t e s * /
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11 / * L o a d p t e t a b l e b a s e a d d r e s s * /
mfspr r11 , S P R N _ M D _ T W C / * . . . . a n d g e t t h e p t e a d d r e s s * /
lwz r10 , 0 ( r11 ) / * G e t t h e p t e * /
ori r10 , r10 , _ P A G E _ A C C E S S E D
stw r10 , 0 ( r11 )
/ * The L i n u x P T E w o n ' t g o e x a c t l y i n t o t h e M M U T L B .
* Software i n d i c a t o r b i t s 2 1 , 2 2 a n d 2 8 m u s t b e c l e a r .
* Software i n d i c a t o r b i t s 2 4 , 2 5 , 2 6 , a n d 2 7 m u s t b e
* set. A l l o t h e r L i n u x P T E b i t s c o n t r o l t h e b e h a v i o r
* of t h e M M U .
* /
2 : li r11 , 0 x00 f0
rlwimi r10 , r11 , 0 , 2 4 , 2 8 / * S e t 2 4 - 2 7 , c l e a r 2 8 * /
DO_ 8 x x _ C P U 6 ( 0 x2 d80 , r3 )
mtspr S P R N _ M I _ R P N , r10 / * U p d a t e T L B e n t r y * /
mfspr r10 , S P R N _ M _ T W / * R e s t o r e r e g i s t e r s * /
lwz r11 , 0 ( r0 )
mtcr r11
lwz r11 , 4 ( r0 )
# ifdef C O N F I G _ 8 x x _ C P U 6
lwz r3 , 8 ( r0 )
# endif
rfi
. = 0 x1 2 0 0
DataStoreTLBMiss :
stw r3 , 8 ( r0 )
DO_ 8 x x _ C P U 6 ( 0 x3 f80 , r3 )
mtspr S P R N _ M _ T W , r10 / * S a v e a c o u p l e o f w o r k i n g r e g i s t e r s * /
mfcr r10
stw r10 , 0 ( r0 )
stw r11 , 4 ( r0 )
mfspr r10 , S P R N _ M _ T W B / * G e t l e v e l 1 t a b l e e n t r y a d d r e s s * /
/ * If w e a r e f a u l t i n g a k e r n e l a d d r e s s , w e h a v e t o u s e t h e
* kernel p a g e t a b l e s .
* /
andi. r11 , r10 , 0 x08 0 0
beq 3 f
lis r11 , s w a p p e r _ p g _ d i r @h
ori r11 , r11 , s w a p p e r _ p g _ d i r @l
rlwimi r10 , r11 , 0 , 2 , 1 9
2006-01-13 14:16:12 -02:00
stw r12 , 1 6 ( r0 )
b L o a d L a r g e D T L B
2005-04-16 15:20:36 -07:00
3 :
lwz r11 , 0 ( r10 ) / * G e t t h e l e v e l 1 e n t r y * /
rlwinm. r10 , r11 ,0 ,0 ,1 9 / * E x t r a c t p a g e d e s c r i p t o r p a g e a d d r e s s * /
beq 2 f / * I f z e r o , d o n ' t t r y t o f i n d a p t e * /
/ * We h a v e a p t e t a b l e , s o l o a d f e t c h t h e p t e f r o m t h e t a b l e .
* /
ori r11 , r11 , 1 / * S e t v a l i d b i t i n p h y s i c a l L 2 p a g e * /
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11 / * L o a d p t e t a b l e b a s e a d d r e s s * /
mfspr r10 , S P R N _ M D _ T W C / * . . . . a n d g e t t h e p t e a d d r e s s * /
lwz r10 , 0 ( r10 ) / * G e t t h e p t e * /
/ * Insert t h e G u a r d e d f l a g i n t o t h e T W C f r o m t h e L i n u x P T E .
* It i s b i t 2 7 o f b o t h t h e L i n u x P T E a n d t h e T W C ( a t l e a s t
* I g o t t h a t r i g h t : - ) . I t w i l l b e b e t t e r w h e n w e c a n p u t
* this i n t o t h e L i n u x p g d / p m d a n d l o a d i t i n t h e o p e r a t i o n
* above.
* /
rlwimi r11 , r10 , 0 , 2 7 , 2 7
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11
mfspr r11 , S P R N _ M D _ T W C / * g e t t h e p t e a d d r e s s a g a i n * /
ori r10 , r10 , _ P A G E _ A C C E S S E D
stw r10 , 0 ( r11 )
/ * The L i n u x P T E w o n ' t g o e x a c t l y i n t o t h e M M U T L B .
* Software i n d i c a t o r b i t s 2 1 , 2 2 a n d 2 8 m u s t b e c l e a r .
* Software i n d i c a t o r b i t s 2 4 , 2 5 , 2 6 , a n d 2 7 m u s t b e
* set. A l l o t h e r L i n u x P T E b i t s c o n t r o l t h e b e h a v i o r
* of t h e M M U .
* /
2 : li r11 , 0 x00 f0
rlwimi r10 , r11 , 0 , 2 4 , 2 8 / * S e t 2 4 - 2 7 , c l e a r 2 8 * /
DO_ 8 x x _ C P U 6 ( 0 x3 d80 , r3 )
mtspr S P R N _ M D _ R P N , r10 / * U p d a t e T L B e n t r y * /
mfspr r10 , S P R N _ M _ T W / * R e s t o r e r e g i s t e r s * /
lwz r11 , 0 ( r0 )
mtcr r11
lwz r11 , 4 ( r0 )
lwz r3 , 8 ( r0 )
rfi
/ * This i s a n i n s t r u c t i o n T L B e r r o r o n t h e M P C 8 x x . T h i s c o u l d b e d u e
* to m a n y r e a s o n s , s u c h a s e x e c u t i n g g u a r d e d m e m o r y o r i l l e g a l i n s t r u c t i o n
* addresses. T h e r e i s n o t h i n g t o d o b u t h a n d l e a b i g t i m e e r r o r f a u l t .
* /
. = 0 x1 3 0 0
InstructionTLBError :
b I n s t r u c t i o n A c c e s s
2006-01-13 14:16:12 -02:00
LoadLargeDTLB :
li r12 , 0
lwz r11 , 0 ( r10 ) / * G e t t h e l e v e l 1 e n t r y * /
rlwinm. r10 , r11 ,0 ,0 ,1 9 / * E x t r a c t p a g e d e s c r i p t o r p a g e a d d r e s s * /
beq 3 f / * I f z e r o , d o n ' t t r y t o f i n d a p t e * /
/ * We h a v e a p t e t a b l e , s o l o a d f e t c h t h e p t e f r o m t h e t a b l e .
* /
ori r11 , r11 , 1 / * S e t v a l i d b i t i n p h y s i c a l L 2 p a g e * /
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11 / * L o a d p t e t a b l e b a s e a d d r e s s * /
mfspr r10 , S P R N _ M D _ T W C / * . . . . a n d g e t t h e p t e a d d r e s s * /
lwz r10 , 0 ( r10 ) / * G e t t h e p t e * /
/ * Insert t h e G u a r d e d f l a g i n t o t h e T W C f r o m t h e L i n u x P T E .
* It i s b i t 2 7 o f b o t h t h e L i n u x P T E a n d t h e T W C ( a t l e a s t
* I g o t t h a t r i g h t : - ) . I t w i l l b e b e t t e r w h e n w e c a n p u t
* this i n t o t h e L i n u x p g d / p m d a n d l o a d i t i n t h e o p e r a t i o n
* above.
* /
rlwimi r11 , r10 , 0 , 2 7 , 2 7
rlwimi r12 , r10 , 0 , 0 , 9 / * e x t r a c t p h y s . a d d r * /
mfspr r3 , S P R N _ M D _ E P N
rlwinm r3 , r3 , 0 , 0 , 9 / * e x t r a c t v i r t u a l a d d r e s s * /
tophys( r3 , r3 )
cmpw r3 , r12 / * o n l y u s e 8 M p a g e i f i t i s a d i r e c t
kernel m a p p i n g * /
bne 1 f
ori r11 , r11 , M D _ P S 8 M E G
li r12 , 1
b 2 f
1 :
li r12 , 0 / * c a n ' t u s e 8 M B T L B , s o z e r o r12 . * /
2 :
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11
/ * The L i n u x P T E w o n ' t g o e x a c t l y i n t o t h e M M U T L B .
* Software i n d i c a t o r b i t s 2 1 , 2 2 a n d 2 8 m u s t b e c l e a r .
* Software i n d i c a t o r b i t s 2 4 , 2 5 , 2 6 , a n d 2 7 m u s t b e
* set. A l l o t h e r L i n u x P T E b i t s c o n t r o l t h e b e h a v i o r
* of t h e M M U .
* /
3 : li r11 , 0 x00 f0
rlwimi r10 , r11 , 0 , 2 4 , 2 8 / * S e t 2 4 - 2 7 , c l e a r 2 8 * /
cmpwi r12 , 1
bne 4 f
ori r10 , r10 , 0 x8
mfspr r12 , S P R N _ M D _ E P N
lis r3 , 0 x f f80 / * 1 0 - 1 9 m u s t b e c l e a r f o r 8 M B T L B * /
ori r3 , r3 , 0 x0 f f f
and r12 , r3 , r12
DO_ 8 x x _ C P U 6 ( 0 x37 8 0 , r3 )
mtspr S P R N _ M D _ E P N , r12
lis r3 , 0 x f f80 / * 1 0 - 1 9 m u s t b e c l e a r f o r 8 M B T L B * /
ori r3 , r3 , 0 x0 f f f
and r10 , r3 , r10
4 :
DO_ 8 x x _ C P U 6 ( 0 x3 d80 , r3 )
mtspr S P R N _ M D _ R P N , r10 / * U p d a t e T L B e n t r y * /
mfspr r10 , S P R N _ M _ T W / * R e s t o r e r e g i s t e r s * /
lwz r11 , 0 ( r0 )
mtcr r11
lwz r11 , 4 ( r0 )
lwz r12 , 1 6 ( r0 )
# ifdef C O N F I G _ 8 x x _ C P U 6
lwz r3 , 8 ( r0 )
# endif
rfi
2005-04-16 15:20:36 -07:00
/ * This i s t h e d a t a T L B e r r o r o n t h e M P C 8 x x . T h i s c o u l d b e d u e t o
* many r e a s o n s , i n c l u d i n g a d i r t y u p d a t e t o a p t e . W e c a n c a t c h t h a t
* one h e r e , b u t a n y t h i n g e l s e i s a n e r r o r . F i r s t , w e t r a c k d o w n t h e
* Linux p t e . I f i t i s v a l i d , w r i t e a c c e s s i s a l l o w e d , b u t t h e
* page d i r t y b i t i s n o t s e t , w e w i l l s e t i t a n d r e l o a d t h e T L B . F o r
* any o t h e r c a s e , w e b a i l o u t t o a h i g h e r l e v e l f u n c t i o n t h a t c a n
* handle i t .
* /
. = 0 x1 4 0 0
DataTLBError :
# ifdef C O N F I G _ 8 x x _ C P U 6
stw r3 , 8 ( r0 )
# endif
DO_ 8 x x _ C P U 6 ( 0 x3 f80 , r3 )
mtspr S P R N _ M _ T W , r10 / * S a v e a c o u p l e o f w o r k i n g r e g i s t e r s * /
mfcr r10
stw r10 , 0 ( r0 )
stw r11 , 4 ( r0 )
/ * First, m a k e s u r e t h i s w a s a s t o r e o p e r a t i o n .
* /
mfspr r10 , S P R N _ D S I S R
andis. r11 , r10 , 0 x02 0 0 / * I f s e t , i n d i c a t e s s t o r e o p * /
beq 2 f
/ * The E A o f a d a t a T L B m i s s i s a u t o m a t i c a l l y s t o r e d i n t h e M D _ E P N
* register. T h e E A o f a d a t a T L B e r r o r i s a u t o m a t i c a l l y s t o r e d i n
* the D A R , b u t n o t t h e M D _ E P N r e g i s t e r . W e m u s t c o p y t h e 2 0 m o s t
* significant b i t s o f t h e E A f r o m t h e D A R t o M D _ E P N b e f o r e w e
* start w a l k i n g t h e p a g e t a b l e s . W e a l s o n e e d t o c o p y t h e C A S I D
* value f r o m t h e M _ C A S I D r e g i s t e r .
* Addendum : The E A o f a d a t a T L B e r r o r i s _ s u p p o s e d _ t o b e s t o r e d
* in D A R , b u t i t s e e m s t h a t t h i s d o e s n ' t h a p p e n i n s o m e c a s e s , s u c h
* as w h e n t h e e r r o r i s d u e t o a d c b i i n s t r u c t i o n t o a p a g e w i t h a
* TLB t h a t d o e s n ' t h a v e t h e c h a n g e d b i t s e t . I n s u c h c a s e s , t h e r e
* does n o t a p p e a r t o b e a n y w a y t o r e c o v e r t h e E A o f t h e e r r o r
* since i t i s n e i t h e r i n D A R n o r M D _ E P N . A s a w o r k a r o u n d , t h e
* _ PAGE_ H W W R I T E b i t i s s e t f o r a l l k e r n e l d a t a p a g e s w h e n t h e P T E s
* are i n i t i a l i z e d i n m a p i n _ r a m ( ) . T h i s w i l l a v o i d t h e p r o b l e m ,
* assuming w e o n l y u s e t h e d c b i i n s t r u c t i o n o n k e r n e l a d d r e s s e s .
* /
mfspr r10 , S P R N _ D A R
rlwinm r11 , r10 , 0 , 0 , 1 9
ori r11 , r11 , M D _ E V A L I D
mfspr r10 , S P R N _ M _ C A S I D
rlwimi r11 , r10 , 0 , 2 8 , 3 1
DO_ 8 x x _ C P U 6 ( 0 x37 8 0 , r3 )
mtspr S P R N _ M D _ E P N , r11
mfspr r10 , S P R N _ M _ T W B / * G e t l e v e l 1 t a b l e e n t r y a d d r e s s * /
/ * If w e a r e f a u l t i n g a k e r n e l a d d r e s s , w e h a v e t o u s e t h e
* kernel p a g e t a b l e s .
* /
andi. r11 , r10 , 0 x08 0 0
beq 3 f
lis r11 , s w a p p e r _ p g _ d i r @h
ori r11 , r11 , s w a p p e r _ p g _ d i r @l
rlwimi r10 , r11 , 0 , 2 , 1 9
3 :
lwz r11 , 0 ( r10 ) / * G e t t h e l e v e l 1 e n t r y * /
rlwinm. r10 , r11 ,0 ,0 ,1 9 / * E x t r a c t p a g e d e s c r i p t o r p a g e a d d r e s s * /
beq 2 f / * I f z e r o , b a i l * /
/ * We h a v e a p t e t a b l e , s o f e t c h t h e p t e f r o m t h e t a b l e .
* /
ori r11 , r11 , 1 / * S e t v a l i d b i t i n p h y s i c a l L 2 p a g e * /
DO_ 8 x x _ C P U 6 ( 0 x3 b80 , r3 )
mtspr S P R N _ M D _ T W C , r11 / * L o a d p t e t a b l e b a s e a d d r e s s * /
mfspr r11 , S P R N _ M D _ T W C / * . . . . a n d g e t t h e p t e a d d r e s s * /
lwz r10 , 0 ( r11 ) / * G e t t h e p t e * /
andi. r11 , r10 , _ P A G E _ R W / * I s i t w r i t e a b l e ? * /
beq 2 f / * B a i l o u t i f n o t * /
/ * Update ' c h a n g e d ' , a m o n g o t h e r s .
* /
ori r10 , r10 , _ P A G E _ D I R T Y | _ P A G E _ A C C E S S E D | _ P A G E _ H W W R I T E
mfspr r11 , S P R N _ M D _ T W C / * G e t p t e a d d r e s s a g a i n * /
stw r10 , 0 ( r11 ) / * a n d u p d a t e p t e i n t a b l e * /
/ * The L i n u x P T E w o n ' t g o e x a c t l y i n t o t h e M M U T L B .
* Software i n d i c a t o r b i t s 2 1 , 2 2 a n d 2 8 m u s t b e c l e a r .
* Software i n d i c a t o r b i t s 2 4 , 2 5 , 2 6 , a n d 2 7 m u s t b e
* set. A l l o t h e r L i n u x P T E b i t s c o n t r o l t h e b e h a v i o r
* of t h e M M U .
* /
li r11 , 0 x00 f0
rlwimi r10 , r11 , 0 , 2 4 , 2 8 / * S e t 2 4 - 2 7 , c l e a r 2 8 * /
DO_ 8 x x _ C P U 6 ( 0 x3 d80 , r3 )
mtspr S P R N _ M D _ R P N , r10 / * U p d a t e T L B e n t r y * /
mfspr r10 , S P R N _ M _ T W / * R e s t o r e r e g i s t e r s * /
lwz r11 , 0 ( r0 )
mtcr r11
lwz r11 , 4 ( r0 )
# ifdef C O N F I G _ 8 x x _ C P U 6
lwz r3 , 8 ( r0 )
# endif
rfi
2 :
mfspr r10 , S P R N _ M _ T W / * R e s t o r e r e g i s t e r s * /
lwz r11 , 0 ( r0 )
mtcr r11
lwz r11 , 4 ( r0 )
# ifdef C O N F I G _ 8 x x _ C P U 6
lwz r3 , 8 ( r0 )
# endif
b D a t a A c c e s s
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x15 0 0 , T r a p _ 1 5 , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x16 0 0 , T r a p _ 1 6 , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x17 0 0 , T r a p _ 1 7 , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x18 0 0 , T r a p _ 1 8 , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x19 0 0 , T r a p _ 1 9 , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x1 a00 , T r a p _ 1 a , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x1 b00 , T r a p _ 1 b , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
2005-04-16 15:20:36 -07:00
/ * On t h e M P C 8 x x , t h e s e n e x t f o u r t r a p s a r e u s e d f o r d e v e l o p m e n t
* support o f b r e a k p o i n t s a n d s u c h . S o m e d a y I w i l l g e t a r o u n d t o
* using t h e m .
* /
2005-10-01 18:43:42 +10:00
EXCEPTION( 0 x1 c00 , T r a p _ 1 c , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x1 d00 , T r a p _ 1 d , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x1 e 0 0 , T r a p _ 1 e , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
EXCEPTION( 0 x1 f00 , T r a p _ 1 f , u n k n o w n _ e x c e p t i o n , E X C _ X F E R _ E E )
2005-04-16 15:20:36 -07:00
. = 0 x2 0 0 0
.globl giveup_fpu
giveup_fpu :
blr
/ *
* This i s w h e r e t h e m a i n k e r n e l c o d e s t a r t s .
* /
start_here :
/* ptr to current */
lis r2 ,i n i t _ t a s k @h
ori r2 ,r2 ,i n i t _ t a s k @l
/* ptr to phys current thread */
tophys( r4 ,r2 )
addi r4 ,r4 ,T H R E A D / * i n i t t a s k ' s T H R E A D * /
mtspr S P R N _ S P R G 3 ,r4
li r3 ,0
mtspr S P R N _ S P R G 2 ,r3 / * 0 = > r1 h a s k e r n e l s p * /
/* stack */
lis r1 ,i n i t _ t h r e a d _ u n i o n @ha
addi r1 ,r1 ,i n i t _ t h r e a d _ u n i o n @l
li r0 ,0
stwu r0 ,T H R E A D _ S I Z E - S T A C K _ F R A M E _ O V E R H E A D ( r1 )
bl e a r l y _ i n i t / * W e h a v e t o d o t h i s w i t h M M U o n * /
/ *
* Decide w h a t s o r t o f m a c h i n e t h i s i s a n d i n i t i a l i z e t h e M M U .
* /
mr r3 ,r31
mr r4 ,r30
mr r5 ,r29
mr r6 ,r28
mr r7 ,r27
bl m a c h i n e _ i n i t
bl M M U _ i n i t
/ *
* Go b a c k t o r u n n i n g u n m a p p e d s o w e c a n l o a d u p n e w v a l u e s
* and c h a n g e t o u s i n g o u r e x c e p t i o n v e c t o r s .
* On t h e 8 x x , a l l w e h a v e t o d o i s i n v a l i d a t e t h e T L B t o c l e a r
* the o l d 8 M b y t e T L B m a p p i n g s a n d l o a d t h e p a g e t a b l e b a s e r e g i s t e r .
* /
/ * The r i g h t w a y t o d o t h i s w o u l d b e t o t r a c k i t d o w n t h r o u g h
* init' s T H R E A D l i k e t h e c o n t e x t s w i t c h c o d e d o e s , b u t t h i s i s
* easier. . . . . . u n t i l s o m e o n e c h a n g e s i n i t ' s s t a t i c s t r u c t u r e s .
* /
lis r6 , s w a p p e r _ p g _ d i r @h
ori r6 , r6 , s w a p p e r _ p g _ d i r @l
tophys( r6 ,r6 )
# ifdef C O N F I G _ 8 x x _ C P U 6
lis r4 , c p u 6 _ e r r a t a _ w o r d @h
ori r4 , r4 , c p u 6 _ e r r a t a _ w o r d @l
li r3 , 0 x39 8 0
stw r3 , 1 2 ( r4 )
lwz r3 , 1 2 ( r4 )
# endif
mtspr S P R N _ M _ T W B , r6
lis r4 ,2 f @h
ori r4 ,r4 ,2 f @l
tophys( r4 ,r4 )
li r3 ,M S R _ K E R N E L & ~ ( M S R _ I R | M S R _ D R )
mtspr S P R N _ S R R 0 ,r4
mtspr S P R N _ S R R 1 ,r3
rfi
/* Load up the kernel context */
2 :
SYNC / * F o r c e a l l P T E u p d a t e s t o f i n i s h * /
tlbia / * C l e a r a l l T L B e n t r i e s * /
sync / * w a i t f o r t l b i a / t l b i e t o f i n i s h * /
TLBSYNC / * . . . o n a l l C P U s * /
/ * set u p t h e P T E p o i n t e r s f o r t h e A b a t r o n b d i G D B .
* /
tovirt( r6 ,r6 )
lis r5 , a b a t r o n _ p t e p t r s @h
ori r5 , r5 , a b a t r o n _ p t e p t r s @l
stw r5 , 0 x f0 ( r0 ) / * M u s t m a t c h y o u r A b a t r o n c o n f i g f i l e * /
tophys( r5 ,r5 )
stw r6 , 0 ( r5 )
/* Now turn on the MMU for real! */
li r4 ,M S R _ K E R N E L
lis r3 ,s t a r t _ k e r n e l @h
ori r3 ,r3 ,s t a r t _ k e r n e l @l
mtspr S P R N _ S R R 0 ,r3
mtspr S P R N _ S R R 1 ,r4
rfi / * e n a b l e M M U a n d j u m p t o s t a r t _ k e r n e l * /
/ * Set u p t h e i n i t i a l M M U s t a t e s o w e c a n d o t h e f i r s t l e v e l o f
* kernel i n i t i a l i z a t i o n . T h i s m a p s t h e f i r s t 8 M B y t e s o f m e m o r y 1 : 1
* virtual t o p h y s i c a l . A l s o , s e t t h e c a c h e m o d e s i n c e t h a t i s d e f i n e d
* by T L B e n t r i e s a n d p e r f o r m a n y a d d i t i o n a l m a p p i n g ( l i k e o f t h e I M M R ) .
* If c o n f i g u r e d t o p i n s o m e T L B s , w e p i n t h e f i r s t 8 M b y t e s o f k e r n e l ,
* 2 4 Mbytes o f d a t a , a n d t h e 8 M I M M R s p a c e . A n y t h i n g n o t c o v e r e d b y
* these m a p p i n g s i s m a p p e d b y p a g e t a b l e s .
* /
initial_mmu :
tlbia / * I n v a l i d a t e a l l T L B e n t r i e s * /
# ifdef C O N F I G _ P I N _ T L B
lis r8 , M I _ R S V 4 I @h
ori r8 , r8 , 0 x1 c00
# else
li r8 , 0
# endif
mtspr S P R N _ M I _ C T R , r8 / * S e t i n s t r u c t i o n M M U c o n t r o l * /
# ifdef C O N F I G _ P I N _ T L B
lis r10 , ( M D _ R S V 4 I | M D _ R E S E T V A L ) @h
ori r10 , r10 , 0 x1 c00
mr r8 , r10
# else
lis r10 , M D _ R E S E T V A L @h
# endif
# ifndef C O N F I G _ 8 x x _ C O P Y B A C K
oris r10 , r10 , M D _ W T D E F @h
# endif
mtspr S P R N _ M D _ C T R , r10 / * S e t d a t a T L B c o n t r o l * /
/ * Now m a p t h e l o w e r 8 M e g i n t o t h e T L B s . F o r t h i s q u i c k h a c k ,
* we c a n l o a d t h e i n s t r u c t i o n a n d d a t a T L B r e g i s t e r s w i t h t h e
* same v a l u e s .
* /
lis r8 , K E R N E L B A S E @h /* Create vaddr for TLB */
ori r8 , r8 , M I _ E V A L I D / * M a r k i t v a l i d * /
mtspr S P R N _ M I _ E P N , r8
mtspr S P R N _ M D _ E P N , r8
li r8 , M I _ P S 8 M E G / * S e t 8 M b y t e p a g e * /
ori r8 , r8 , M I _ S V A L I D / * M a k e i t v a l i d * /
mtspr S P R N _ M I _ T W C , r8
mtspr S P R N _ M D _ T W C , r8
li r8 , M I _ B O O T I N I T / * C r e a t e R P N f o r a d d r e s s 0 * /
mtspr S P R N _ M I _ R P N , r8 / * S t o r e T L B e n t r y * /
mtspr S P R N _ M D _ R P N , r8
lis r8 , M I _ K p @h /* Set the protection mode */
mtspr S P R N _ M I _ A P , r8
mtspr S P R N _ M D _ A P , r8
/ * Map a n o t h e r 8 M B y t e a t t h e I M M R t o g e t t h e p r o c e s s o r
* internal r e g i s t e r s ( a m o n g o t h e r t h i n g s ) .
* /
# ifdef C O N F I G _ P I N _ T L B
addi r10 , r10 , 0 x01 0 0
mtspr S P R N _ M D _ C T R , r10
# endif
mfspr r9 , 6 3 8 / * G e t c u r r e n t I M M R * /
andis. r9 , r9 , 0 x f f80 / * G e t 8 M b y t e b o u n d a r y * /
mr r8 , r9 / * C r e a t e v a d d r f o r T L B * /
ori r8 , r8 , M D _ E V A L I D / * M a r k i t v a l i d * /
mtspr S P R N _ M D _ E P N , r8
li r8 , M D _ P S 8 M E G / * S e t 8 M b y t e p a g e * /
ori r8 , r8 , M D _ S V A L I D / * M a k e i t v a l i d * /
mtspr S P R N _ M D _ T W C , r8
mr r8 , r9 / * C r e a t e p a d d r f o r T L B * /
ori r8 , r8 , M I _ B O O T I N I T | 0 x2 / * I n h i b i t c a c h e - - C o r t * /
mtspr S P R N _ M D _ R P N , r8
# ifdef C O N F I G _ P I N _ T L B
/ * Map t w o m o r e 8 M k e r n e l d a t a p a g e s .
* /
addi r10 , r10 , 0 x01 0 0
mtspr S P R N _ M D _ C T R , r10
lis r8 , K E R N E L B A S E @h /* Create vaddr for TLB */
addis r8 , r8 , 0 x00 8 0 / * A d d 8 M * /
ori r8 , r8 , M I _ E V A L I D / * M a r k i t v a l i d * /
mtspr S P R N _ M D _ E P N , r8
li r9 , M I _ P S 8 M E G / * S e t 8 M b y t e p a g e * /
ori r9 , r9 , M I _ S V A L I D / * M a k e i t v a l i d * /
mtspr S P R N _ M D _ T W C , r9
li r11 , M I _ B O O T I N I T / * C r e a t e R P N f o r a d d r e s s 0 * /
addis r11 , r11 , 0 x00 8 0 / * A d d 8 M * /
2006-01-23 13:57:06 -02:00
mtspr S P R N _ M D _ R P N , r11
addi r10 , r10 , 0 x01 0 0
mtspr S P R N _ M D _ C T R , r10
2005-04-16 15:20:36 -07:00
addis r8 , r8 , 0 x00 8 0 / * A d d 8 M * /
mtspr S P R N _ M D _ E P N , r8
mtspr S P R N _ M D _ T W C , r9
addis r11 , r11 , 0 x00 8 0 / * A d d 8 M * /
2006-01-23 13:57:06 -02:00
mtspr S P R N _ M D _ R P N , r11
2005-04-16 15:20:36 -07:00
# endif
/ * Since t h e c a c h e i s e n a b l e d a c c o r d i n g t o t h e i n f o r m a t i o n w e
* just l o a d e d i n t o t h e T L B , i n v a l i d a t e a n d e n a b l e t h e c a c h e s h e r e .
* We s h o u l d p r o b a b l y c h e c k / s e t o t h e r m o d e s . . . . l a t e r .
* /
lis r8 , I D C _ I N V A L L @h
mtspr S P R N _ I C _ C S T , r8
mtspr S P R N _ D C _ C S T , r8
lis r8 , I D C _ E N A B L E @h
mtspr S P R N _ I C _ C S T , r8
# ifdef C O N F I G _ 8 x x _ C O P Y B A C K
mtspr S P R N _ D C _ C S T , r8
# else
/ * For a d e b u g o p t i o n , I l e f t t h i s h e r e t o e a s i l y e n a b l e
* the w r i t e t h r o u g h c a c h e m o d e
* /
lis r8 , D C _ S F W T @h
mtspr S P R N _ D C _ C S T , r8
lis r8 , I D C _ E N A B L E @h
mtspr S P R N _ D C _ C S T , r8
# endif
blr
/ *
* Set u p t o u s e a g i v e n M M U c o n t e x t .
* r3 i s c o n t e x t n u m b e r , r4 i s P G D p o i n t e r .
*
* We p l a c e t h e p h y s i c a l a d d r e s s o f t h e n e w t a s k p a g e d i r e c t o r y l o a d e d
* into t h e M M U b a s e r e g i s t e r , a n d s e t t h e A S I D c o m p a r e r e g i s t e r w i t h
* the n e w " c o n t e x t . "
* /
_ GLOBAL( s e t _ c o n t e x t )
# ifdef C O N F I G _ B D I _ S W I T C H
/ * Context s w i t c h t h e P T E p o i n t e r f o r t h e A b a t r o n B D I 2 0 0 0 .
* The P G D I R i s p a s s e d a s s e c o n d a r g u m e n t .
* /
lis r5 , K E R N E L B A S E @h
lwz r5 , 0 x f0 ( r5 )
stw r4 , 0 x4 ( r5 )
# endif
# ifdef C O N F I G _ 8 x x _ C P U 6
lis r6 , c p u 6 _ e r r a t a _ w o r d @h
ori r6 , r6 , c p u 6 _ e r r a t a _ w o r d @l
tophys ( r4 , r4 )
li r7 , 0 x39 8 0
stw r7 , 1 2 ( r6 )
lwz r7 , 1 2 ( r6 )
mtspr S P R N _ M _ T W B , r4 / * U p d a t e M M U b a s e a d d r e s s * /
li r7 , 0 x33 8 0
stw r7 , 1 2 ( r6 )
lwz r7 , 1 2 ( r6 )
mtspr S P R N _ M _ C A S I D , r3 / * U p d a t e c o n t e x t * /
# else
mtspr S P R N _ M _ C A S I D ,r3 / * U p d a t e c o n t e x t * /
tophys ( r4 , r4 )
mtspr S P R N _ M _ T W B , r4 / * a n d p g d * /
# endif
SYNC
blr
# ifdef C O N F I G _ 8 x x _ C P U 6
/ * It' s h e r e b e c a u s e i t i s u n i q u e t o t h e 8 x x .
* It i s i m p o r t a n t w e g e t c a l l e d w i t h i n t e r r u p t s d i s a b l e d . I u s e d t o
* do t h a t , b u t i t a p p e a r s t h a t a l l c o d e t h a t c a l l s t h i s a l r e a d y h a d
* interrupt d i s a b l e d .
* /
.globl set_dec_cpu6
set_dec_cpu6 :
lis r7 , c p u 6 _ e r r a t a _ w o r d @h
ori r7 , r7 , c p u 6 _ e r r a t a _ w o r d @l
li r4 , 0 x2 c00
stw r4 , 8 ( r7 )
lwz r4 , 8 ( r7 )
mtspr 2 2 , r3 / * U p d a t e D e c r e m e n t e r * /
SYNC
blr
# endif
/ *
* We p u t a f e w t h i n g s h e r e t h a t h a v e t o b e p a g e - a l i g n e d .
* This s t u f f g o e s a t t h e b e g i n n i n g o f t h e d a t a s e g m e n t ,
* which i s p a g e - a l i g n e d .
* /
.data
.globl sdata
sdata :
.globl empty_zero_page
empty_zero_page :
.space 4096
.globl swapper_pg_dir
swapper_pg_dir :
.space 4096
/ *
* This s p a c e g e t s a c o p y o f o p t i o n a l i n f o p a s s e d t o u s b y t h e b o o t s t r a p
* Used t o p a s s p a r a m e t e r s i n t o t h e k e r n e l l i k e r o o t = / d e v / s d a1 , e t c .
* /
.globl cmd_line
cmd_line :
.space 512
/ * Room f o r t w o P T E t a b l e p o i n e r s , u s u a l l y t h e k e r n e l a n d c u r r e n t u s e r
* pointer t o t h e i r r e s p e c t i v e r o o t p a g e t a b l e ( p g d i r ) .
* /
abatron_pteptrs :
.space 8
# ifdef C O N F I G _ 8 x x _ C P U 6
.globl cpu6_errata_word
cpu6_errata_word :
.space 16
# endif