2011-06-04 12:05:39 +04:00
/ *
* OpenRISC h e a d . S
*
* Linux a r c h i t e c t u r a l p o r t b o r r o w i n g l i b e r a l l y f r o m s i m i l a r w o r k s o f
* others. A l l o r i g i n a l c o p y r i g h t s a p p l y a s p e r t h e o r i g i n a l s o u r c e
* declaration.
*
* Modifications f o r t h e O p e n R I S C a r c h i t e c t u r e :
* Copyright ( C ) 2 0 0 3 M a t j a z B r e s k v a r < p h o e n i x @bsemi.com>
* Copyright ( C ) 2 0 1 0 - 2 0 1 1 J o n a s B o n n < j o n a s @southpole.se>
*
* 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 / l i n k a g e . h >
# include < l i n u x / t h r e a d s . h >
# include < l i n u x / e r r n o . h >
# include < l i n u x / i n i t . h >
2013-02-26 10:36:29 +04:00
# include < l i n u x / s e r i a l _ r e g . h >
2011-06-04 12:05:39 +04:00
# 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 / p g t a b l e . h >
# include < a s m / c a c h e . h >
# include < a s m / s p r _ d e f s . h >
# include < a s m / a s m - o f f s e t s . h >
2011-11-10 19:38:29 +04:00
# include < l i n u x / o f _ f d t . h >
2011-06-04 12:05:39 +04:00
# define t o p h y s ( r d ,r s ) \
l. m o v h i r d ,h i ( - K E R N E L B A S E ) ;\
l. a d d r d ,r d ,r s
# define C L E A R _ G P R ( g p r ) \
l. o r g p r ,r0 ,r0
# define L O A D _ S Y M B O L _ 2 _ G P R ( g p r ,s y m b o l ) \
l. m o v h i g p r ,h i ( s y m b o l ) ;\
l. o r i g p r ,g p r ,l o ( s y m b o l )
# define U A R T _ B A S E _ A D D 0 x90 0 0 0 0 0 0
# define E X C E P T I O N _ S R ( S P R _ S R _ D M E | S P R _ S R _ I M E | S P R _ S R _ D C E | S P R _ S R _ I C E | S P R _ S R _ S M )
# define S Y S C A L L _ S R ( S P R _ S R _ D M E | S P R _ S R _ I M E | S P R _ S R _ D C E | S P R _ S R _ I C E | S P R _ S R _ I E E | S P R _ S R _ T E E | S P R _ S R _ S M )
/* ============================================[ tmp store locations ]=== */
/ *
* emergency_ p r i n t t e m p o r a r y s t o r e s
* /
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 4 l . s w 0 x20 ( r0 ) ,r4
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 4 l . l w z r4 ,0 x20 ( r0 )
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 5 l . s w 0 x24 ( r0 ) ,r5
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 5 l . l w z r5 ,0 x24 ( r0 )
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 6 l . s w 0 x28 ( r0 ) ,r6
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 6 l . l w z r6 ,0 x28 ( r0 )
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 7 l . s w 0 x2 c ( r0 ) ,r7
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 7 l . l w z r7 ,0 x2 c ( r0 )
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 8 l . s w 0 x30 ( r0 ) ,r8
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 8 l . l w z r8 ,0 x30 ( r0 )
# define E M E R G E N C Y _ P R I N T _ S T O R E _ G P R 9 l . s w 0 x34 ( r0 ) ,r9
# define E M E R G E N C Y _ P R I N T _ L O A D _ G P R 9 l . l w z r9 ,0 x34 ( r0 )
/ *
* TLB m i s s h a n d l e r s t e m o r a r y s t o r e s
* /
# define E X C E P T I O N _ S T O R E _ G P R 9 l . s w 0 x10 ( r0 ) ,r9
# define E X C E P T I O N _ L O A D _ G P R 9 l . l w z r9 ,0 x10 ( r0 )
# define E X C E P T I O N _ S T O R E _ G P R 2 l . s w 0 x64 ( r0 ) ,r2
# define E X C E P T I O N _ L O A D _ G P R 2 l . l w z r2 ,0 x64 ( r0 )
# define E X C E P T I O N _ S T O R E _ G P R 3 l . s w 0 x68 ( r0 ) ,r3
# define E X C E P T I O N _ L O A D _ G P R 3 l . l w z r3 ,0 x68 ( r0 )
# define E X C E P T I O N _ S T O R E _ G P R 4 l . s w 0 x6 c ( r0 ) ,r4
# define E X C E P T I O N _ L O A D _ G P R 4 l . l w z r4 ,0 x6 c ( r0 )
# define E X C E P T I O N _ S T O R E _ G P R 5 l . s w 0 x70 ( r0 ) ,r5
# define E X C E P T I O N _ L O A D _ G P R 5 l . l w z r5 ,0 x70 ( r0 )
# define E X C E P T I O N _ S T O R E _ G P R 6 l . s w 0 x74 ( r0 ) ,r6
# define E X C E P T I O N _ L O A D _ G P R 6 l . l w z r6 ,0 x74 ( r0 )
/ *
* EXCEPTION_ H A N D L E t e m p o r a r y s t o r e s
* /
# define E X C E P T I O N _ T _ S T O R E _ G P R 3 0 l . s w 0 x78 ( r0 ) ,r30
# define E X C E P T I O N _ T _ L O A D _ G P R 3 0 ( r e g ) l . l w z r e g ,0 x78 ( r0 )
# define E X C E P T I O N _ T _ S T O R E _ G P R 1 0 l . s w 0 x7 c ( r0 ) ,r10
# define E X C E P T I O N _ T _ L O A D _ G P R 1 0 ( r e g ) l . l w z r e g ,0 x7 c ( r0 )
# define E X C E P T I O N _ T _ S T O R E _ S P l . s w 0 x80 ( r0 ) ,r1
# define E X C E P T I O N _ T _ L O A D _ S P ( r e g ) l . l w z r e g ,0 x80 ( r0 )
/ *
* For U N H A N L D E D _ E X C E P T I O N
* /
# define E X C E P T I O N _ T _ S T O R E _ G P R 3 1 l . s w 0 x84 ( r0 ) ,r31
# define E X C E P T I O N _ T _ L O A D _ G P R 3 1 ( r e g ) l . l w z r e g ,0 x84 ( r0 )
/* =========================================================[ macros ]=== */
# define G E T _ C U R R E N T _ P G D ( r e g ,t 1 ) \
LOAD_ S Y M B O L _ 2 _ G P R ( r e g ,c u r r e n t _ p g d ) ;\
tophys ( t 1 ,r e g ) ;\
l. l w z r e g ,0 ( t 1 )
/ *
* DSCR : this i s a c o m m o n h o o k f o r h a n d l i n g e x c e p t i o n s . i t w i l l s a v e
* the n e e d e d r e g i s t e r s , s e t u p s t a c k a n d p o i n t e r t o c u r r e n t
* then j u m p t o t h e h a n d l e r w h i l e e n a b l i n g M M U
*
* PRMS : handler - a f u n c t i o n t o j u m p t o . i t h a s t o s a v e t h e
* remaining r e g i s t e r s t o k e r n e l s t a c k , c a l l
* appropriate a r c h - i n d e p e n d a n t e x c e p t i o n h a n d l e r
* and f i n a l y j u m p t o r e t _ f r o m _ e x c e p t
*
* PREQ : unchanged s t a t e f r o m t h e t i m e e x c e p t i o n h a p p e n e d
*
* POST : SAVED t h e f o l l o w i n g r e g i s t e r s o r i g i n a l v a l u e
* to t h e n e w c r e a t e d e x c e p t i o n f r a m e p o i n t e d t o b y r1
*
* r1 - k s p p o i n t i n g t o t h e n e w ( e x c e p t i o n ) f r a m e
* r4 - E E A R e x c e p t i o n E A
* r1 0 - c u r r e n t p o i n t i n g t o c u r r e n t _ t h r e a d _ i n f o s t r u c t
* r1 2 - s y s c a l l 0 , s i n c e w e d i d n ' t c o m e f r o m s y s c a l l
* r1 3 - t e m p i t a c t u a l l y c o n t a i n s n e w S R , n o t n e e d e d a n y m o r e
* r3 1 - h a n d l e r a d d r e s s o f t h e h a n d l e r w e ' l l j u m p t o
*
* handler h a s t o s a v e r e m a i n i n g r e g i s t e r s t o t h e e x c e p t i o n
* ksp f r a m e * b e f o r e * t a i n t i n g t h e m !
*
* NOTE : this f u n c t i o n i s n o t r e e n t r a n t p e r s e . r e e n t r a n c y i s g u a r a n t e e d
* by p r o c e s s o r d i s a b l i n g a l l e x c e p t i o n s / i n t e r r u p t s w h e n e x c e p t i o n
* accours.
*
* OPTM : no n e e d t o m a k e i t s o w a s t e f u l t o e x t r a c t k s p w h e n i n u s e r m o d e
* /
# define E X C E P T I O N _ H A N D L E ( h a n d l e r ) \
EXCEPTION_ T _ S T O R E _ G P R 3 0 ;\
l. m f s p r r30 ,r0 ,S P R _ E S R _ B A S E ;\
l. a n d i r30 ,r30 ,S P R _ S R _ S M ;\
l. s f e q i r30 ,0 ;\
EXCEPTION_ T _ S T O R E _ G P R 1 0 ;\
l. b n f 2 f / * k e r n e l _ m o d e * / ;\
EXCEPTION_ T _ S T O R E _ S P / * d e l a y s l o t * / ;\
1 : /* user_mode: */ ;\
LOAD_ S Y M B O L _ 2 _ G P R ( r1 ,c u r r e n t _ t h r e a d _ i n f o _ s e t ) ;\
tophys ( r30 ,r1 ) ;\
/* r10: current_thread_info */ ;\
l. l w z r10 ,0 ( r30 ) ;\
tophys ( r30 ,r10 ) ;\
l. l w z r1 ,( T I _ K S P ) ( r30 ) ;\
/* fall through */ ;\
2 : /* kernel_mode: */ ;\
/* create new stack frame, save only needed gprs */ ;\
/* r1: KSP, r10: current, r4: EEAR, r31: __pa(KSP) */ ;\
/* r12: temp, syscall indicator */ ;\
l. a d d i r1 ,r1 ,- ( I N T _ F R A M E _ S I Z E ) ;\
/* r1 is KSP, r30 is __pa(KSP) */ ;\
tophys ( r30 ,r1 ) ;\
l. s w P T _ G P R 1 2 ( r30 ) ,r12 ;\
l. m f s p r r12 ,r0 ,S P R _ E P C R _ B A S E ;\
l. s w P T _ P C ( r30 ) ,r12 ;\
l. m f s p r r12 ,r0 ,S P R _ E S R _ B A S E ;\
l. s w P T _ S R ( r30 ) ,r12 ;\
/* save r30 */ ;\
EXCEPTION_ T _ L O A D _ G P R 3 0 ( r12 ) ;\
l. s w P T _ G P R 3 0 ( r30 ) ,r12 ;\
/* save r10 as was prior to exception */ ;\
EXCEPTION_ T _ L O A D _ G P R 1 0 ( r12 ) ;\
l. s w P T _ G P R 1 0 ( r30 ) ,r12 ;\
/* save PT_SP as was prior to exception */ ;\
EXCEPTION_ T _ L O A D _ S P ( r12 ) ;\
l. s w P T _ S P ( r30 ) ,r12 ;\
/* save exception r4, set r4 = EA */ ;\
l. s w P T _ G P R 4 ( r30 ) ,r4 ;\
l. m f s p r r4 ,r0 ,S P R _ E E A R _ B A S E ;\
/* r12 == 1 if we come from syscall */ ;\
CLEAR_ G P R ( r12 ) ;\
/* ----- turn on MMU ----- */ ;\
l. o r i r30 ,r0 ,( E X C E P T I O N _ S R ) ;\
l. m t s p r r0 ,r30 ,S P R _ E S R _ B A S E ;\
/* r30: EA address of handler */ ;\
LOAD_ S Y M B O L _ 2 _ G P R ( r30 ,h a n d l e r ) ;\
l. m t s p r r0 ,r30 ,S P R _ E P C R _ B A S E ;\
l. r f e
/ *
* this d o e s n ' t w o r k
*
*
* # ifdef C O N F I G _ J U M P _ U P O N _ U N H A N D L E D _ E X C E P T I O N
* # define U N H A N D L E D _ E X C E P T I O N ( h a n d l e r ) \
* l. o r i r3 ,r0 ,0 x1 ;\
* l. m t s p r r0 ,r3 ,S P R _ S R ;\
* l. m o v h i r3 ,h i ( 0 x f00 0 0 1 0 0 ) ;\
* l. o r i r3 ,r3 ,l o ( 0 x f00 0 0 1 0 0 ) ;\
* l. j r r3 ;\
* l. n o p 1
*
* # endif
* /
/ * DSCR : this i s t h e s a m e a s E X C E P T I O N _ H A N D L E ( ) , w e a r e j u s t
* a b i t m o r e c a r e f u l l ( i f w e h a v e a P T _ S P o r c u r r e n t p o i n t e r
* corruption) a n d s e t t h e m u p f r o m ' c u r r e n t _ s e t '
*
* /
# define U N H A N D L E D _ E X C E P T I O N ( h a n d l e r ) \
EXCEPTION_ T _ S T O R E _ G P R 3 1 ;\
EXCEPTION_ T _ S T O R E _ G P R 1 0 ;\
EXCEPTION_ T _ S T O R E _ S P ;\
/* temporary store r3, r9 into r1, r10 */ ;\
l. a d d i r1 ,r3 ,0 x0 ;\
l. a d d i r10 ,r9 ,0 x0 ;\
/* the string referenced by r3 must be low enough */ ;\
l. j a l _ e m e r g e n c y _ p r i n t ;\
l. o r i r3 ,r0 ,l o ( _ s t r i n g _ u n h a n d l e d _ e x c e p t i o n ) ;\
l. m f s p r r3 ,r0 ,S P R _ N P C ;\
l. j a l _ e m e r g e n c y _ p r i n t _ n r ;\
l. a n d i r3 ,r3 ,0 x1 f00 ;\
/* the string referenced by r3 must be low enough */ ;\
l. j a l _ e m e r g e n c y _ p r i n t ;\
l. o r i r3 ,r0 ,l o ( _ s t r i n g _ e p c _ p r e f i x ) ;\
l. j a l _ e m e r g e n c y _ p r i n t _ n r ;\
l. m f s p r r3 ,r0 ,S P R _ E P C R _ B A S E ;\
l. j a l _ e m e r g e n c y _ p r i n t ;\
l. o r i r3 ,r0 ,l o ( _ s t r i n g _ n l ) ;\
/* end of printing */ ;\
l. a d d i r3 ,r1 ,0 x0 ;\
l. a d d i r9 ,r10 ,0 x0 ;\
/* extract current, ksp from current_set */ ;\
LOAD_ S Y M B O L _ 2 _ G P R ( r1 ,_ u n h a n d l e d _ s t a c k _ t o p ) ;\
LOAD_ S Y M B O L _ 2 _ G P R ( r10 ,i n i t _ t h r e a d _ u n i o n ) ;\
/* create new stack frame, save only needed gprs */ ;\
/* r1: KSP, r10: current, r31: __pa(KSP) */ ;\
/* r12: temp, syscall indicator, r13 temp */ ;\
l. a d d i r1 ,r1 ,- ( I N T _ F R A M E _ S I Z E ) ;\
/* r1 is KSP, r31 is __pa(KSP) */ ;\
tophys ( r31 ,r1 ) ;\
l. s w P T _ G P R 1 2 ( r31 ) ,r12 ;\
l. m f s p r r12 ,r0 ,S P R _ E P C R _ B A S E ;\
l. s w P T _ P C ( r31 ) ,r12 ;\
l. m f s p r r12 ,r0 ,S P R _ E S R _ B A S E ;\
l. s w P T _ S R ( r31 ) ,r12 ;\
/* save r31 */ ;\
EXCEPTION_ T _ L O A D _ G P R 3 1 ( r12 ) ;\
l. s w P T _ G P R 3 1 ( r31 ) ,r12 ;\
/* save r10 as was prior to exception */ ;\
EXCEPTION_ T _ L O A D _ G P R 1 0 ( r12 ) ;\
l. s w P T _ G P R 1 0 ( r31 ) ,r12 ;\
/* save PT_SP as was prior to exception */ ;\
EXCEPTION_ T _ L O A D _ S P ( r12 ) ;\
l. s w P T _ S P ( r31 ) ,r12 ;\
l. s w P T _ G P R 1 3 ( r31 ) ,r13 ;\
/* --> */ ;\
/* save exception r4, set r4 = EA */ ;\
l. s w P T _ G P R 4 ( r31 ) ,r4 ;\
l. m f s p r r4 ,r0 ,S P R _ E E A R _ B A S E ;\
/* r12 == 1 if we come from syscall */ ;\
CLEAR_ G P R ( r12 ) ;\
/* ----- play a MMU trick ----- */ ;\
l. o r i r31 ,r0 ,( E X C E P T I O N _ S R ) ;\
l. m t s p r r0 ,r31 ,S P R _ E S R _ B A S E ;\
/* r31: EA address of handler */ ;\
LOAD_ S Y M B O L _ 2 _ G P R ( r31 ,h a n d l e r ) ;\
l. m t s p r r0 ,r31 ,S P R _ E P C R _ B A S E ;\
l. r f e
/* =====================================================[ exceptions] === */
/* ---[ 0x100: RESET exception ]----------------------------------------- */
.org 0x100
/ * Jump t o . i n i t c o d e a t _ s t a r t w h i c h l i v e s i n t h e . h e a d s e c t i o n
* and w i l l b e d i s c a r d e d a f t e r b o o t .
* /
2012-10-12 10:38:18 +04:00
LOAD_ S Y M B O L _ 2 _ G P R ( r15 , _ s t a r t )
tophys ( r13 ,r15 ) / * M M U d i s a b l e d * /
l. j r r13
2011-06-04 12:05:39 +04:00
l. n o p
/* ---[ 0x200: BUS exception ]------------------------------------------- */
.org 0x200
_dispatch_bus_fault :
EXCEPTION_ H A N D L E ( _ b u s _ f a u l t _ h a n d l e r )
/* ---[ 0x300: Data Page Fault exception ]------------------------------- */
.org 0x300
_dispatch_do_dpage_fault :
/ / totaly d i s a b l e t i m e r i n t e r r u p t
/ / l. m t s p r r0 ,r0 ,S P R _ T T M R
/ / DEBUG_ T L B _ P R O B E ( 0 x30 0 )
/ / EXCEPTION_ D E B U G _ V A L U E _ E R _ E N A B L E D ( 0 x30 0 )
EXCEPTION_ H A N D L E ( _ d a t a _ p a g e _ f a u l t _ h a n d l e r )
/* ---[ 0x400: Insn Page Fault exception ]------------------------------- */
.org 0x400
_dispatch_do_ipage_fault :
/ / totaly d i s a b l e t i m e r i n t e r r u p t
/ / l. m t s p r r0 ,r0 ,S P R _ T T M R
/ / DEBUG_ T L B _ P R O B E ( 0 x40 0 )
/ / EXCEPTION_ D E B U G _ V A L U E _ E R _ E N A B L E D ( 0 x40 0 )
EXCEPTION_ H A N D L E ( _ i n s n _ p a g e _ f a u l t _ h a n d l e r )
/* ---[ 0x500: Timer exception ]----------------------------------------- */
.org 0x500
EXCEPTION_ H A N D L E ( _ t i m e r _ h a n d l e r )
/* ---[ 0x600: Aligment exception ]-------------------------------------- */
.org 0x600
EXCEPTION_ H A N D L E ( _ a l i g n m e n t _ h a n d l e r )
/* ---[ 0x700: Illegal insn exception ]---------------------------------- */
.org 0x700
EXCEPTION_ H A N D L E ( _ i l l e g a l _ i n s t r u c t i o n _ h a n d l e r )
/* ---[ 0x800: External interrupt exception ]---------------------------- */
.org 0x800
EXCEPTION_ H A N D L E ( _ e x t e r n a l _ i r q _ h a n d l e r )
/* ---[ 0x900: DTLB miss exception ]------------------------------------- */
.org 0x900
l. j b o o t _ d t l b _ m i s s _ h a n d l e r
l. n o p
/* ---[ 0xa00: ITLB miss exception ]------------------------------------- */
.org 0xa00
l. j b o o t _ i t l b _ m i s s _ h a n d l e r
l. n o p
/* ---[ 0xb00: Range exception ]----------------------------------------- */
.org 0xb00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x b00 )
/* ---[ 0xc00: Syscall exception ]--------------------------------------- */
.org 0xc00
EXCEPTION_ H A N D L E ( _ s y s _ c a l l _ h a n d l e r )
/* ---[ 0xd00: Trap exception ]------------------------------------------ */
.org 0xd00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x d00 )
/* ---[ 0xe00: Trap exception ]------------------------------------------ */
.org 0xe00
/ / UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x e 0 0 )
EXCEPTION_ H A N D L E ( _ t r a p _ h a n d l e r )
/* ---[ 0xf00: Reserved exception ]-------------------------------------- */
.org 0xf00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x f00 )
/* ---[ 0x1000: Reserved exception ]------------------------------------- */
.org 0x1000
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x10 0 0 )
/* ---[ 0x1100: Reserved exception ]------------------------------------- */
.org 0x1100
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x11 0 0 )
/* ---[ 0x1200: Reserved exception ]------------------------------------- */
.org 0x1200
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x12 0 0 )
/* ---[ 0x1300: Reserved exception ]------------------------------------- */
.org 0x1300
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x13 0 0 )
/* ---[ 0x1400: Reserved exception ]------------------------------------- */
.org 0x1400
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x14 0 0 )
/* ---[ 0x1500: Reserved exception ]------------------------------------- */
.org 0x1500
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x15 0 0 )
/* ---[ 0x1600: Reserved exception ]------------------------------------- */
.org 0x1600
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x16 0 0 )
/* ---[ 0x1700: Reserved exception ]------------------------------------- */
.org 0x1700
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x17 0 0 )
/* ---[ 0x1800: Reserved exception ]------------------------------------- */
.org 0x1800
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x18 0 0 )
/* ---[ 0x1900: Reserved exception ]------------------------------------- */
.org 0x1900
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x19 0 0 )
/* ---[ 0x1a00: Reserved exception ]------------------------------------- */
.org 0x1a00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 a00 )
/* ---[ 0x1b00: Reserved exception ]------------------------------------- */
.org 0x1b00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 b00 )
/* ---[ 0x1c00: Reserved exception ]------------------------------------- */
.org 0x1c00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 c00 )
/* ---[ 0x1d00: Reserved exception ]------------------------------------- */
.org 0x1d00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 d00 )
/* ---[ 0x1e00: Reserved exception ]------------------------------------- */
.org 0x1e00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 e 0 0 )
/* ---[ 0x1f00: Reserved exception ]------------------------------------- */
.org 0x1f00
UNHANDLED_ E X C E P T I O N ( _ v e c t o r _ 0 x1 f00 )
.org 0x2000
/* ===================================================[ kernel start ]=== */
/* .text*/
/ * This e a r l y s t u f f b e l o n g s i n H E A D , b u t s o m e o f t h e f u n c t i o n s b e l o w d e f i n i t e l y
* don' t . . . * /
_ _ HEAD
.global _start
_start :
2011-11-10 19:38:29 +04:00
/* save kernel parameters */
l. o r r25 ,r0 ,r3 / * p o i n t e r t o f d t * /
2011-06-04 12:05:39 +04:00
/ *
* ensure a d e t e r m i n i s t i c s t a r t
* /
l. o r i r3 ,r0 ,0 x1
l. m t s p r r0 ,r3 ,S P R _ S R
CLEAR_ G P R ( r1 )
CLEAR_ G P R ( r2 )
CLEAR_ G P R ( r3 )
CLEAR_ G P R ( r4 )
CLEAR_ G P R ( r5 )
CLEAR_ G P R ( r6 )
CLEAR_ G P R ( r7 )
CLEAR_ G P R ( r8 )
CLEAR_ G P R ( r9 )
CLEAR_ G P R ( r10 )
CLEAR_ G P R ( r11 )
CLEAR_ G P R ( r12 )
CLEAR_ G P R ( r13 )
CLEAR_ G P R ( r14 )
CLEAR_ G P R ( r15 )
CLEAR_ G P R ( r16 )
CLEAR_ G P R ( r17 )
CLEAR_ G P R ( r18 )
CLEAR_ G P R ( r19 )
CLEAR_ G P R ( r20 )
CLEAR_ G P R ( r21 )
CLEAR_ G P R ( r22 )
CLEAR_ G P R ( r23 )
CLEAR_ G P R ( r24 )
CLEAR_ G P R ( r26 )
CLEAR_ G P R ( r27 )
CLEAR_ G P R ( r28 )
CLEAR_ G P R ( r29 )
CLEAR_ G P R ( r30 )
CLEAR_ G P R ( r31 )
/ *
* set u p i n i t i a l k s p a n d c u r r e n t
* /
LOAD_ S Y M B O L _ 2 _ G P R ( r1 ,i n i t _ t h r e a d _ u n i o n + 0 x20 0 0 ) / / s e t u p k e r n e l s t a c k
LOAD_ S Y M B O L _ 2 _ G P R ( r10 ,i n i t _ t h r e a d _ u n i o n ) / / s e t u p c u r r e n t
tophys ( r31 ,r10 )
l. s w T I _ K S P ( r31 ) , r1
l. o r i r4 ,r0 ,0 x0
/ *
* .data contains initialized d a t a ,
* .bss contains uninitialized d a t a - c l e a r i t u p
* /
clear_bss :
LOAD_ S Y M B O L _ 2 _ G P R ( r24 , _ _ b s s _ s t a r t )
LOAD_ S Y M B O L _ 2 _ G P R ( r26 , _ e n d )
tophys( r28 ,r24 )
tophys( r30 ,r26 )
CLEAR_ G P R ( r24 )
CLEAR_ G P R ( r26 )
1 :
l. s w ( 0 ) ( r28 ) ,r0
l. s f l t u r28 ,r30
l. b f 1 b
l. a d d i r28 ,r28 ,4
enable_ic :
l. j a l _ i c _ e n a b l e
l. n o p
enable_dc :
l. j a l _ d c _ e n a b l e
l. n o p
flush_tlb :
/ *
* I N V A L I D A T E T L B e n t r i e s
* /
LOAD_ S Y M B O L _ 2 _ G P R ( r5 ,S P R _ D T L B M R _ B A S E ( 0 ) )
LOAD_ S Y M B O L _ 2 _ G P R ( r6 ,S P R _ I T L B M R _ B A S E ( 0 ) )
l. a d d i r7 ,r0 ,1 2 8 / * M a x i m u m n u m b e r o f s e t s * /
1 :
l. m t s p r r5 ,r0 ,0 x0
l. m t s p r r6 ,r0 ,0 x0
l. a d d i r5 ,r5 ,1
l. a d d i r6 ,r6 ,1
l. s f e q r7 ,r0
l. b n f 1 b
l. a d d i r7 ,r7 ,- 1
/* The MMU needs to be enabled before or32_early_setup is called */
enable_mmu :
/ *
* enable d m m u & i m m u
* SR[ 5 ] = 0 , S R [ 6 ] = 0 , 6 t h a n d 7 t h b i t o f S R s e t t o 0
* /
l. m f s p r r30 ,r0 ,S P R _ S R
l. m o v h i r28 ,h i ( S P R _ S R _ D M E | S P R _ S R _ I M E )
l. o r i r28 ,r28 ,l o ( S P R _ S R _ D M E | S P R _ S R _ I M E )
l. o r r30 ,r30 ,r28
l. m t s p r r0 ,r30 ,S P R _ S R
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
/ / reset t h e s i m u l a t i o n c o u n t e r s
l. n o p 5
2011-11-10 19:38:29 +04:00
/* check fdt header magic word */
l. l w z r3 ,0 ( r25 ) / * l o a d m a g i c f r o m f d t i n t o r3 * /
l. m o v h i r4 ,h i ( O F _ D T _ H E A D E R )
l. o r i r4 ,r4 ,l o ( O F _ D T _ H E A D E R )
l. s f e q r3 ,r4
l. b f _ f d t _ f o u n d
l. n o p
/* magic number mismatch, set fdt pointer to null */
l. o r r25 ,r0 ,r0
_fdt_found :
/* pass fdt pointer to or32_early_setup in r3 */
l. o r r3 ,r0 ,r25
2011-06-04 12:05:39 +04:00
LOAD_ S Y M B O L _ 2 _ G P R ( r24 , o r32 _ e a r l y _ s e t u p )
l. j a l r r24
l. n o p
clear_regs :
/ *
* clear a l l G P R S t o i n c r e a s e d e t e r m i n i s m
* /
CLEAR_ G P R ( r2 )
CLEAR_ G P R ( r3 )
CLEAR_ G P R ( r4 )
CLEAR_ G P R ( r5 )
CLEAR_ G P R ( r6 )
CLEAR_ G P R ( r7 )
CLEAR_ G P R ( r8 )
CLEAR_ G P R ( r9 )
CLEAR_ G P R ( r11 )
CLEAR_ G P R ( r12 )
CLEAR_ G P R ( r13 )
CLEAR_ G P R ( r14 )
CLEAR_ G P R ( r15 )
CLEAR_ G P R ( r16 )
CLEAR_ G P R ( r17 )
CLEAR_ G P R ( r18 )
CLEAR_ G P R ( r19 )
CLEAR_ G P R ( r20 )
CLEAR_ G P R ( r21 )
CLEAR_ G P R ( r22 )
CLEAR_ G P R ( r23 )
CLEAR_ G P R ( r24 )
CLEAR_ G P R ( r25 )
CLEAR_ G P R ( r26 )
CLEAR_ G P R ( r27 )
CLEAR_ G P R ( r28 )
CLEAR_ G P R ( r29 )
CLEAR_ G P R ( r30 )
CLEAR_ G P R ( r31 )
jump_start_kernel :
/ *
* jump t o k e r n e l e n t r y ( s t a r t _ k e r n e l )
* /
LOAD_ S Y M B O L _ 2 _ G P R ( r30 , s t a r t _ k e r n e l )
l. j r r30
l. n o p
/* ========================================[ cache ]=== */
/ * aligment h e r e s o w e d o n ' t c h a n g e m e m o r y o f f s e t s w i t h
* memory c o n t r o l e r d e f i n e d
* /
.align 0x2000
_ic_enable :
/* Check if IC present and skip enabling otherwise */
l. m f s p r r24 ,r0 ,S P R _ U P R
l. a n d i r26 ,r24 ,S P R _ U P R _ I C P
l. s f e q r26 ,r0
l. b f 9 f
l. n o p
/* Disable IC */
l. m f s p r r6 ,r0 ,S P R _ S R
l. a d d i r5 ,r0 ,- 1
l. x o r i r5 ,r5 ,S P R _ S R _ I C E
l. a n d r5 ,r6 ,r5
l. m t s p r r0 ,r5 ,S P R _ S R
/ * Establish c a c h e b l o c k s i z e
If B S =0 , 1 6 ;
If B S =1 , 3 2 ;
r1 4 c o n t a i n b l o c k s i z e
* /
l. m f s p r r24 ,r0 ,S P R _ I C C F G R
l. a n d i r26 ,r24 ,S P R _ I C C F G R _ C B S
l. s r l i r28 ,r26 ,7
l. o r i r30 ,r0 ,1 6
l. s l l r14 ,r30 ,r28
/ * Establish n u m b e r o f c a c h e s e t s
r1 6 c o n t a i n s n u m b e r o f c a c h e s e t s
r2 8 c o n t a i n s l o g ( # o f c a c h e s e t s )
* /
l. a n d i r26 ,r24 ,S P R _ I C C F G R _ N C S
l. s r l i r28 ,r26 ,3
l. o r i r30 ,r0 ,1
l. s l l r16 ,r30 ,r28
/* Invalidate IC */
l. a d d i r6 ,r0 ,0
l. s l l r5 ,r14 ,r28
/ / l. m u l r5 ,r14 ,r16
/ / l. t r a p 1
/ / l. a d d i r5 ,r0 ,I C _ S I Z E
1 :
l. m t s p r r0 ,r6 ,S P R _ I C B I R
l. s f n e r6 ,r5
l. b f 1 b
l. a d d r6 ,r6 ,r14
/ / l. a d d i r6 ,r6 ,I C _ L I N E
/* Enable IC */
l. m f s p r r6 ,r0 ,S P R _ S R
l. o r i r6 ,r6 ,S P R _ S R _ I C E
l. m t s p r r0 ,r6 ,S P R _ S R
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
l. n o p
9 :
l. j r r9
l. n o p
_dc_enable :
/* Check if DC present and skip enabling otherwise */
l. m f s p r r24 ,r0 ,S P R _ U P R
l. a n d i r26 ,r24 ,S P R _ U P R _ D C P
l. s f e q r26 ,r0
l. b f 9 f
l. n o p
/* Disable DC */
l. m f s p r r6 ,r0 ,S P R _ S R
l. a d d i r5 ,r0 ,- 1
l. x o r i r5 ,r5 ,S P R _ S R _ D C E
l. a n d r5 ,r6 ,r5
l. m t s p r r0 ,r5 ,S P R _ S R
/ * Establish c a c h e b l o c k s i z e
If B S =0 , 1 6 ;
If B S =1 , 3 2 ;
r1 4 c o n t a i n b l o c k s i z e
* /
l. m f s p r r24 ,r0 ,S P R _ D C C F G R
l. a n d i r26 ,r24 ,S P R _ D C C F G R _ C B S
l. s r l i r28 ,r26 ,7
l. o r i r30 ,r0 ,1 6
l. s l l r14 ,r30 ,r28
/ * Establish n u m b e r o f c a c h e s e t s
r1 6 c o n t a i n s n u m b e r o f c a c h e s e t s
r2 8 c o n t a i n s l o g ( # o f c a c h e s e t s )
* /
l. a n d i r26 ,r24 ,S P R _ D C C F G R _ N C S
l. s r l i r28 ,r26 ,3
l. o r i r30 ,r0 ,1
l. s l l r16 ,r30 ,r28
/* Invalidate DC */
l. a d d i r6 ,r0 ,0
l. s l l r5 ,r14 ,r28
1 :
l. m t s p r r0 ,r6 ,S P R _ D C B I R
l. s f n e r6 ,r5
l. b f 1 b
l. a d d r6 ,r6 ,r14
/* Enable DC */
l. m f s p r r6 ,r0 ,S P R _ S R
l. o r i r6 ,r6 ,S P R _ S R _ D C E
l. m t s p r r0 ,r6 ,S P R _ S R
9 :
l. j r r9
l. n o p
/* ===============================================[ page table masks ]=== */
# define D T L B _ U P _ C O N V E R T _ M A S K 0 x3 f a
# define I T L B _ U P _ C O N V E R T _ M A S K 0 x3 a
/ * for S M P w e ' d h a v e ( t h i s i s a b i t s u b t l e , C C m u s t b e a l w a y s s e t
* for S M P , b u t s i n c e w e h a v e _ P A G E _ P R E S E N T b i t a l w a y s d e f i n e d
* we c a n j u s t m o d i f y t h e m a s k )
* /
# define D T L B _ S M P _ C O N V E R T _ M A S K 0 x3 f b
# define I T L B _ S M P _ C O N V E R T _ M A S K 0 x3 b
/* ---[ boot dtlb miss handler ]----------------------------------------- */
boot_dtlb_miss_handler :
/ * mask f o r D T L B _ M R r e g i s t e r : - ( 0 ) s e t s V ( v a l i d ) b i t ,
* - ( 3 1 - 1 2 ) sets b i t s b e l o n g i n g t o V P N ( 3 1 - 1 2 )
* /
# define D T L B _ M R _ M A S K 0 x f f f f f00 1
/ * mask f o r D T L B _ T R r e g i s t e r : - ( 2 ) s e t s C I ( c a c h e i n h i b i t ) b i t ,
* - ( 4 ) sets A ( a c c e s s ) b i t ,
* - ( 5 ) sets D ( d i r t y ) b i t ,
* - ( 8 ) sets S R E ( s u p e r u s e r r e a d ) b i t
* - ( 9 ) sets S W E ( s u p e r u s e r w r i t e ) b i t
* - ( 3 1 - 1 2 ) sets b i t s b e l o n g i n g t o V P N ( 3 1 - 1 2 )
* /
# define D T L B _ T R _ M A S K 0 x f f f f f33 2
/ * These a r e f o r m a s k i n g o u t t h e V P N / P P N v a l u e f r o m t h e M R / T R r e g i s t e r s . . .
* it' s n o t t h e s a m e a s t h e P F N * /
# define V P N _ M A S K 0 x f f f f f00 0
# define P P N _ M A S K 0 x f f f f f00 0
EXCEPTION_ S T O R E _ G P R 6
# if 0
l. m f s p r r6 ,r0 ,S P R _ E S R _ B A S E / /
l. a n d i r6 ,r6 ,S P R _ S R _ S M / / a r e w e i n k e r n e l m o d e ?
l. s f e q i r6 ,0 / / r6 = = 0 x1 - - > S M
l. b f e x i t _ w i t h _ n o _ d t r a n s l a t i o n / /
l. n o p
# endif
/ * this c o u l d b e o p t i m i z e d b y m o v i n g s t o r i n g o f
* non r6 r e g i s t e r s h e r e , a n d j u m p i n g r6 r e s t o r e
* if n o t i n s u p e r v i s o r m o d e
* /
EXCEPTION_ S T O R E _ G P R 2
EXCEPTION_ S T O R E _ G P R 3
EXCEPTION_ S T O R E _ G P R 4
EXCEPTION_ S T O R E _ G P R 5
l. m f s p r r4 ,r0 ,S P R _ E E A R _ B A S E / / g e t t h e o f f e n d i n g E A
immediate_translation :
CLEAR_ G P R ( r6 )
l. s r l i r3 ,r4 ,0 x d / / r3 < - r4 / 8 1 9 2 ( s e t s a r e r e l a t i v e t o p a g e s i z e ( 8 K b ) N O T V P N s i z e ( 4 K b )
l. m f s p r r6 , r0 , S P R _ D M M U C F G R
l. a n d i r6 , r6 , S P R _ D M M U C F G R _ N T S
l. s r l i r6 , r6 , S P R _ D M M U C F G R _ N T S _ O F F
l. o r i r5 , r0 , 0 x1
l. s l l r5 , r5 , r6 / / r5 = n u m b e r D M M U s e t s
l. a d d i r6 , r5 , - 1 / / r6 = n s e t s m a s k
l. a n d r2 , r3 , r6 / / r2 < - r3 % N S E T S _ M A S K
l. o r r6 ,r6 ,r4 / / r6 < - r4
l. o r i r6 ,r6 ,~ ( V P N _ M A S K ) / / r6 < - V P N : V P N . x f f f - c l e a r u p l o ( r6 ) t o 0 x * * * * * f f f
l. m o v h i r5 ,h i ( D T L B _ M R _ M A S K ) / / r5 < - f f f f : 0 0 0 0 . x00 0
l. o r i r5 ,r5 ,l o ( D T L B _ M R _ M A S K ) / / r5 < - f f f f : 1 1 1 1 . x00 1 - a p p l y D T L B _ M R _ M A S K
l. a n d r5 ,r5 ,r6 / / r5 < - V P N : V P N . x00 1 - w e h a v e D T L B M R e n t r y
l. m t s p r r2 ,r5 ,S P R _ D T L B M R _ B A S E ( 0 ) / / s e t D T L B M R
/* set up DTLB with no translation for EA <= 0xbfffffff */
LOAD_ S Y M B O L _ 2 _ G P R ( r6 ,0 x b f f f f f f f )
l. s f g e u r6 ,r4 / / f l a g i f r6 > = r4 ( i f 0 x b f f f f f f f > = E A )
l. b f 1 f / / g o t o o u t
l. a n d r3 ,r4 ,r4 / / d e l a y s l o t : : 2 4 < - r4 ( i f f l a g = =1 )
tophys( r3 ,r4 ) / / r3 < - P A
1 :
l. o r i r3 ,r3 ,~ ( P P N _ M A S K ) / / r3 < - P P N : P P N . x f f f - c l e a r u p l o ( r6 ) t o 0 x * * * * * f f f
l. m o v h i r5 ,h i ( D T L B _ T R _ M A S K ) / / r5 < - f f f f : 0 0 0 0 . x00 0
l. o r i r5 ,r5 ,l o ( D T L B _ T R _ M A S K ) / / r5 < - f f f f : 1 1 1 1 . x33 0 - a p p l y D T L B _ M R _ M A S K
l. a n d r5 ,r5 ,r3 / / r5 < - P P N : P P N . x33 0 - w e h a v e D T L B T R e n t r y
l. m t s p r r2 ,r5 ,S P R _ D T L B T R _ B A S E ( 0 ) / / s e t D T L B T R
EXCEPTION_ L O A D _ G P R 6
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 2
l. r f e / / S R < - E S R , P C < - E P C
exit_with_no_dtranslation :
/* EA out of memory or not in supervisor mode */
EXCEPTION_ L O A D _ G P R 6
EXCEPTION_ L O A D _ G P R 4
l. j _ d i s p a t c h _ b u s _ f a u l t
/* ---[ boot itlb miss handler ]----------------------------------------- */
boot_itlb_miss_handler :
/ * mask f o r I T L B _ M R r e g i s t e r : - s e t s V ( v a l i d ) b i t ,
* - sets b i t s b e l o n g i n g t o V P N ( 1 5 - 1 2 )
* /
# define I T L B _ M R _ M A S K 0 x f f f f f00 1
/ * mask f o r I T L B _ T R r e g i s t e r : - s e t s A ( a c c e s s ) b i t ,
* - sets S X E ( s u p e r u s e r e x e c u t e ) b i t
* - sets b i t s b e l o n g i n g t o V P N ( 1 5 - 1 2 )
* /
# define I T L B _ T R _ M A S K 0 x f f f f f05 0
/ *
# define V P N _ M A S K 0 x f f f f e 0 0 0
# define P P N _ M A S K 0 x f f f f e 0 0 0
* /
EXCEPTION_ S T O R E _ G P R 2
EXCEPTION_ S T O R E _ G P R 3
EXCEPTION_ S T O R E _ G P R 4
EXCEPTION_ S T O R E _ G P R 5
EXCEPTION_ S T O R E _ G P R 6
# if 0
l. m f s p r r6 ,r0 ,S P R _ E S R _ B A S E / /
l. a n d i r6 ,r6 ,S P R _ S R _ S M / / a r e w e i n k e r n e l m o d e ?
l. s f e q i r6 ,0 / / r6 = = 0 x1 - - > S M
l. b f e x i t _ w i t h _ n o _ i t r a n s l a t i o n
l. n o p
# endif
l. m f s p r r4 ,r0 ,S P R _ E E A R _ B A S E / / g e t t h e o f f e n d i n g E A
earlyearly :
CLEAR_ G P R ( r6 )
l. s r l i r3 ,r4 ,0 x d / / r3 < - r4 / 8 1 9 2 ( s e t s a r e r e l a t i v e t o p a g e s i z e ( 8 K b ) N O T V P N s i z e ( 4 K b )
l. m f s p r r6 , r0 , S P R _ I M M U C F G R
l. a n d i r6 , r6 , S P R _ I M M U C F G R _ N T S
l. s r l i r6 , r6 , S P R _ I M M U C F G R _ N T S _ O F F
l. o r i r5 , r0 , 0 x1
l. s l l r5 , r5 , r6 / / r5 = n u m b e r I M M U s e t s f r o m I M M U C F G R
l. a d d i r6 , r5 , - 1 / / r6 = n s e t s m a s k
l. a n d r2 , r3 , r6 / / r2 < - r3 % N S E T S _ M A S K
l. o r r6 ,r6 ,r4 / / r6 < - r4
l. o r i r6 ,r6 ,~ ( V P N _ M A S K ) / / r6 < - V P N : V P N . x f f f - c l e a r u p l o ( r6 ) t o 0 x * * * * * f f f
l. m o v h i r5 ,h i ( I T L B _ M R _ M A S K ) / / r5 < - f f f f : 0 0 0 0 . x00 0
l. o r i r5 ,r5 ,l o ( I T L B _ M R _ M A S K ) / / r5 < - f f f f : 1 1 1 1 . x00 1 - a p p l y I T L B _ M R _ M A S K
l. a n d r5 ,r5 ,r6 / / r5 < - V P N : V P N . x00 1 - w e h a v e I T L B M R e n t r y
l. m t s p r r2 ,r5 ,S P R _ I T L B M R _ B A S E ( 0 ) / / s e t I T L B M R
/ *
* set u p I T L B w i t h n o t r a n s l a t i o n f o r E A < = 0 x0 f f f f f f f
*
* we n e e d t h i s f o r h e a d . S m a p p i n g ( E A = P A ) . i f w e m o v e a l l f u n c t i o n s
* which r u n w i t h m m u e n a b l e d i n t o e n t r y . S , w e m i g h t b e a b l e t o e l i m i n a t e t h i s .
*
* /
LOAD_ S Y M B O L _ 2 _ G P R ( r6 ,0 x0 f f f f f f f )
l. s f g e u r6 ,r4 / / f l a g i f r6 > = r4 ( i f 0 x b0 f f f f f f > = E A )
l. b f 1 f / / g o t o o u t
l. a n d r3 ,r4 ,r4 / / d e l a y s l o t : : 2 4 < - r4 ( i f f l a g = =1 )
tophys( r3 ,r4 ) / / r3 < - P A
1 :
l. o r i r3 ,r3 ,~ ( P P N _ M A S K ) / / r3 < - P P N : P P N . x f f f - c l e a r u p l o ( r6 ) t o 0 x * * * * * f f f
l. m o v h i r5 ,h i ( I T L B _ T R _ M A S K ) / / r5 < - f f f f : 0 0 0 0 . x00 0
l. o r i r5 ,r5 ,l o ( I T L B _ T R _ M A S K ) / / r5 < - f f f f : 1 1 1 1 . x05 0 - a p p l y I T L B _ M R _ M A S K
l. a n d r5 ,r5 ,r3 / / r5 < - P P N : P P N . x05 0 - w e h a v e I T L B T R e n t r y
l. m t s p r r2 ,r5 ,S P R _ I T L B T R _ B A S E ( 0 ) / / s e t I T L B T R
EXCEPTION_ L O A D _ G P R 6
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 2
l. r f e / / S R < - E S R , P C < - E P C
exit_with_no_itranslation :
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 6
l. j _ d i s p a t c h _ b u s _ f a u l t
l. n o p
/* ====================================================================== */
/ *
* Stuff b e l o w h e r e s h o u l d n ' t g o i n t o . h e a d s e c t i o n . . . m a y b e t h i s s t u f f
* can b e m o v e d t o e n t r y . S ? ? ?
* /
/* ==============================================[ DTLB miss handler ]=== */
/ *
* Comments :
* Exception h a n d l e r s a r e e n t e r e d w i t h M M U o f f s o t h e f o l l o w i n g h a n d l e r
* needs t o u s e p h y s i c a l a d d r e s s i n g
*
* /
.text
ENTRY( d t l b _ m i s s _ h a n d l e r )
EXCEPTION_ S T O R E _ G P R 2
EXCEPTION_ S T O R E _ G P R 3
EXCEPTION_ S T O R E _ G P R 4
EXCEPTION_ S T O R E _ G P R 5
EXCEPTION_ S T O R E _ G P R 6
/ *
* get E A o f t h e m i s s
* /
l. m f s p r r2 ,r0 ,S P R _ E E A R _ B A S E
/ *
* pmd = ( p m d _ t * ) ( c u r r e n t _ p g d + p g d _ i n d e x ( d a d d r ) ) ;
* /
GET_ C U R R E N T _ P G D ( r3 ,r5 ) / / r3 i s c u r r e n t _ p g d , r5 i s t e m p
l. s r l i r4 ,r2 ,0 x18 / / > > P A G E _ S H I F T + ( P A G E _ S H I F T - 2 )
l. s l l i r4 ,r4 ,0 x2 / / t o g e t a d d r e s s < < 2
l. a d d r5 ,r4 ,r3 / / r4 i s p g d _ i n d e x ( d a d d r )
/ *
* if ( p m d _ n o n e ( * p m d ) )
* goto p m d _ n o n e :
* /
tophys ( r4 ,r5 )
l. l w z r3 ,0 x0 ( r4 ) / / g e t * p m d v a l u e
l. s f n e r3 ,r0
l. b n f d _ p m d _ n o n e
l. a n d i r3 ,r3 ,~ P A G E _ M A S K / / 0 x1 f f f / / ~ P A G E _ M A S K
/ *
* if ( p m d _ b a d ( * p m d ) )
* pmd_ c l e a r ( p m d )
* goto p m d _ b a d :
* /
/ / l. s f e q r3 ,r0 / / c h e c k * p m d v a l u e
/ / l. b f d _ p m d _ g o o d
l. a d d i r3 ,r0 ,0 x f f f f e 0 0 0 / / P A G E _ M A S K
/ / l. j d _ p m d _ b a d
/ / l. s w 0 x0 ( r4 ) ,r0 / / c l e a r p m d
d_pmd_good :
/ *
* pte = * p t e _ o f f s e t ( p m d , d a d d r ) ;
* /
l. l w z r4 ,0 x0 ( r4 ) / / g e t * * p m d v a l u e
l. a n d r4 ,r4 ,r3 / / & P A G E _ M A S K
l. s r l i r5 ,r2 ,0 x d / / > > P A G E _ S H I F T , r2 = = E E A R
l. a n d i r3 ,r5 ,0 x7 f f / / ( 1 U L < < P A G E _ S H I F T - 2 ) - 1
l. s l l i r3 ,r3 ,0 x2 / / t o g e t a d d r e s s < < 2
l. a d d r3 ,r3 ,r4
l. l w z r2 ,0 x0 ( r3 ) / / t h i s i s p t e a t l a s t
/ *
* if ( ! p t e _ p r e s e n t ( p t e ) )
* /
l. a n d i r4 ,r2 ,0 x1
l. s f n e r4 ,r0 / / i s p t e p r e s e n t
l. b n f d _ p t e _ n o t _ p r e s e n t
l. a d d i r3 ,r0 ,0 x f f f f e 3 f a / / P A G E _ M A S K | D T L B _ U P _ C O N V E R T _ M A S K
/ *
* fill D T L B T R r e g i s t e r
* /
l. a n d r4 ,r2 ,r3 / / a p p l y t h e m a s k
/ / Determine n u m b e r o f D M M U s e t s
l. m f s p r r6 , r0 , S P R _ D M M U C F G R
l. a n d i r6 , r6 , S P R _ D M M U C F G R _ N T S
l. s r l i r6 , r6 , S P R _ D M M U C F G R _ N T S _ O F F
l. o r i r3 , r0 , 0 x1
l. s l l r3 , r3 , r6 / / r3 = n u m b e r D M M U s e t s D M M U C F G R
l. a d d i r6 , r3 , - 1 / / r6 = n s e t s m a s k
l. a n d r5 , r5 , r6 / / c a l c o f f s e t : & ( N U M _ T L B _ E N T R I E S - 1 )
/ / NUM_ T L B _ E N T R I E S
l. m t s p r r5 ,r4 ,S P R _ D T L B T R _ B A S E ( 0 )
/ *
* fill D T L B M R r e g i s t e r
* /
l. m f s p r r2 ,r0 ,S P R _ E E A R _ B A S E
l. a d d i r3 ,r0 ,0 x f f f f e 0 0 0 / / P A G E _ M A S K
l. a n d r4 ,r2 ,r3 / / a p p l y P A G E _ M A S K t o E A ( _ _ P H X _ _ d o w e r e a l l y n e e d t h i s ? )
l. o r i r4 ,r4 ,0 x1 / / s e t h a r d w a r e v a l i d b i t : D T B L _ M R e n t r y
l. m t s p r r5 ,r4 ,S P R _ D T L B M R _ B A S E ( 0 )
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
l. r f e
d_pmd_bad :
l. n o p 1
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
l. r f e
d_pmd_none :
d_pte_not_present :
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
2013-02-14 19:16:49 +04:00
EXCEPTION_ H A N D L E ( _ d t l b _ m i s s _ p a g e _ f a u l t _ h a n d l e r )
2011-06-04 12:05:39 +04:00
/* ==============================================[ ITLB miss handler ]=== */
ENTRY( i t l b _ m i s s _ h a n d l e r )
EXCEPTION_ S T O R E _ G P R 2
EXCEPTION_ S T O R E _ G P R 3
EXCEPTION_ S T O R E _ G P R 4
EXCEPTION_ S T O R E _ G P R 5
EXCEPTION_ S T O R E _ G P R 6
/ *
* get E A o f t h e m i s s
* /
l. m f s p r r2 ,r0 ,S P R _ E E A R _ B A S E
/ *
* pmd = ( p m d _ t * ) ( c u r r e n t _ p g d + p g d _ i n d e x ( d a d d r ) ) ;
*
* /
GET_ C U R R E N T _ P G D ( r3 ,r5 ) / / r3 i s c u r r e n t _ p g d , r5 i s t e m p
l. s r l i r4 ,r2 ,0 x18 / / > > P A G E _ S H I F T + ( P A G E _ S H I F T - 2 )
l. s l l i r4 ,r4 ,0 x2 / / t o g e t a d d r e s s < < 2
l. a d d r5 ,r4 ,r3 / / r4 i s p g d _ i n d e x ( d a d d r )
/ *
* if ( p m d _ n o n e ( * p m d ) )
* goto p m d _ n o n e :
* /
tophys ( r4 ,r5 )
l. l w z r3 ,0 x0 ( r4 ) / / g e t * p m d v a l u e
l. s f n e r3 ,r0
l. b n f i _ p m d _ n o n e
l. a n d i r3 ,r3 ,0 x1 f f f / / ~ P A G E _ M A S K
/ *
* if ( p m d _ b a d ( * p m d ) )
* pmd_ c l e a r ( p m d )
* goto p m d _ b a d :
* /
/ / l. s f e q r3 ,r0 / / c h e c k * p m d v a l u e
/ / l. b f i _ p m d _ g o o d
l. a d d i r3 ,r0 ,0 x f f f f e 0 0 0 / / P A G E _ M A S K
/ / l. j i _ p m d _ b a d
/ / l. s w 0 x0 ( r4 ) ,r0 / / c l e a r p m d
i_pmd_good :
/ *
* pte = * p t e _ o f f s e t ( p m d , i a d d r ) ;
*
* /
l. l w z r4 ,0 x0 ( r4 ) / / g e t * * p m d v a l u e
l. a n d r4 ,r4 ,r3 / / & P A G E _ M A S K
l. s r l i r5 ,r2 ,0 x d / / > > P A G E _ S H I F T , r2 = = E E A R
l. a n d i r3 ,r5 ,0 x7 f f / / ( 1 U L < < P A G E _ S H I F T - 2 ) - 1
l. s l l i r3 ,r3 ,0 x2 / / t o g e t a d d r e s s < < 2
l. a d d r3 ,r3 ,r4
l. l w z r2 ,0 x0 ( r3 ) / / t h i s i s p t e a t l a s t
/ *
* if ( ! p t e _ p r e s e n t ( p t e ) )
*
* /
l. a n d i r4 ,r2 ,0 x1
l. s f n e r4 ,r0 / / i s p t e p r e s e n t
l. b n f i _ p t e _ n o t _ p r e s e n t
l. a d d i r3 ,r0 ,0 x f f f f e 0 3 a / / P A G E _ M A S K | I T L B _ U P _ C O N V E R T _ M A S K
/ *
* fill I T L B T R r e g i s t e r
* /
l. a n d r4 ,r2 ,r3 / / a p p l y t h e m a s k
l. a n d i r3 ,r2 ,0 x7 c0 / / _ P A G E _ E X E C | _ P A G E _ S R E | _ P A G E _ S W E | _ P A G E _ U R E | _ P A G E _ U W E
/ / l. a n d i r3 ,r2 ,0 x40 0 / / _ P A G E _ E X E C
l. s f e q r3 ,r0
l. b f i t l b _ t r _ f i l l / / _ w o r k a r o u n d
/ / Determine n u m b e r o f I M M U s e t s
l. m f s p r r6 , r0 , S P R _ I M M U C F G R
l. a n d i r6 , r6 , S P R _ I M M U C F G R _ N T S
l. s r l i r6 , r6 , S P R _ I M M U C F G R _ N T S _ O F F
l. o r i r3 , r0 , 0 x1
l. s l l r3 , r3 , r6 / / r3 = n u m b e r I M M U s e t s I M M U C F G R
l. a d d i r6 , r3 , - 1 / / r6 = n s e t s m a s k
l. a n d r5 , r5 , r6 / / c a l c o f f s e t : & ( N U M _ T L B _ E N T R I E S - 1 )
/ *
* _ _ PHX_ _ : : f i x m e
* we s h o u l d n o t j u s t b l i n d l y s e t e x e c u t a b l e f l a g s ,
* but i t d o e s h e l p w i t h p i n g . t h e c l e a n w a y w o u l d b e t o f i n d o u t
* ( and f i x i t ) w h y s t a c k d o e s n ' t h a v e e x e c u t i o n p e r m i s s i o n s
* /
itlb_tr_fill_workaround :
l. o r i r4 ,r4 ,0 x c0 / / | ( S P R _ I T L B T R _ U X E | I T L B T R _ S X E )
itlb_tr_fill :
l. m t s p r r5 ,r4 ,S P R _ I T L B T R _ B A S E ( 0 )
/ *
* fill D T L B M R r e g i s t e r
* /
l. m f s p r r2 ,r0 ,S P R _ E E A R _ B A S E
l. a d d i r3 ,r0 ,0 x f f f f e 0 0 0 / / P A G E _ M A S K
l. a n d r4 ,r2 ,r3 / / a p p l y P A G E _ M A S K t o E A ( _ _ P H X _ _ d o w e r e a l l y n e e d t h i s ? )
l. o r i r4 ,r4 ,0 x1 / / s e t h a r d w a r e v a l i d b i t : D T B L _ M R e n t r y
l. m t s p r r5 ,r4 ,S P R _ I T L B M R _ B A S E ( 0 )
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
l. r f e
i_pmd_bad :
l. n o p 1
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
l. r f e
i_pmd_none :
i_pte_not_present :
EXCEPTION_ L O A D _ G P R 2
EXCEPTION_ L O A D _ G P R 3
EXCEPTION_ L O A D _ G P R 4
EXCEPTION_ L O A D _ G P R 5
EXCEPTION_ L O A D _ G P R 6
2013-02-14 19:16:49 +04:00
EXCEPTION_ H A N D L E ( _ i t l b _ m i s s _ p a g e _ f a u l t _ h a n d l e r )
2011-06-04 12:05:39 +04:00
/* ==============================================[ boot tlb handlers ]=== */
/* =================================================[ debugging aids ]=== */
.align 64
_immu_trampoline :
.space 64
_immu_trampoline_top :
# define T R A M P _ S L O T _ 0 ( 0 x0 )
# define T R A M P _ S L O T _ 1 ( 0 x4 )
# define T R A M P _ S L O T _ 2 ( 0 x8 )
# define T R A M P _ S L O T _ 3 ( 0 x c )
# define T R A M P _ S L O T _ 4 ( 0 x10 )
# define T R A M P _ S L O T _ 5 ( 0 x14 )
# define T R A M P _ F R A M E _ S I Z E ( 0 x18 )
ENTRY( _ i m m u _ t r a m p o l i n e _ w o r k a r o u n d )
/ / r2 E E A
/ / r6 i s p h y s i c a l E E A
tophys( r6 ,r2 )
LOAD_ S Y M B O L _ 2 _ G P R ( r5 ,_ i m m u _ t r a m p o l i n e )
tophys ( r3 ,r5 ) / / r3 i s t r a m p o l i n e ( p h y s i c a l )
LOAD_ S Y M B O L _ 2 _ G P R ( r4 ,0 x15 0 0 0 0 0 0 )
l. s w T R A M P _ S L O T _ 0 ( r3 ) ,r4
l. s w T R A M P _ S L O T _ 1 ( r3 ) ,r4
l. s w T R A M P _ S L O T _ 4 ( r3 ) ,r4
l. s w T R A M P _ S L O T _ 5 ( r3 ) ,r4
/ / EPC = E E A - 0 x4
l. l w z r4 ,0 x0 ( r6 ) / / l o a d o p @ EEA + 0x0 (fc address)
l. s w T R A M P _ S L O T _ 3 ( r3 ) ,r4 / / s t o r e i t t o _ i m m u _ t r a m p o l i n e _ d a t a
l. l w z r4 ,- 0 x4 ( r6 ) / / l o a d o p @ EEA - 0x4 (f8 address)
l. s w T R A M P _ S L O T _ 2 ( r3 ) ,r4 / / s t o r e i t t o _ i m m u _ t r a m p o l i n e _ d a t a
l. s r l i r5 ,r4 ,2 6 / / c h e c k o p c o d e f o r w r i t e a c c e s s
l. s f e q i r5 ,0 / / l . j
l. b f 0 f
l. s f e q i r5 ,0 x11 / / l . j r
l. b f 1 f
l. s f e q i r5 ,1 / / l . j a l
l. b f 2 f
l. s f e q i r5 ,0 x12 / / l . j a l r
l. b f 3 f
l. s f e q i r5 ,3 / / l . b n f
l. b f 4 f
l. s f e q i r5 ,4 / / l . b f
l. b f 5 f
99 :
l. n o p
l. j 9 9 b / / s h o u l d n e v e r h a p p e n
l. n o p 1
/ / r2 i s E E A
/ / r3 i s t r a m p o l i n e a d d r e s s ( p h y s i c a l )
/ / r4 i s i n s t r u c t i o n
/ / r6 i s p h y s i c a l ( E E A )
/ /
/ / r5
2 : / / l. j a l
/ * 1 9 2 0 aa a a l . m o v h i r9 ,0 x a a a a
* a9 2 9 b b b b l . o r i r9 ,0 x b b b b
*
* where 0 x a a a a b b b b i s E E A + 0 x4 s h i f t e d r i g h t 2
* /
l. a d d i r6 ,r2 ,0 x4 / / t h i s i s 0 x a a a a b b b b
/ / l. m o v h i r9 ,0 x a a a a
l. o r i r5 ,r0 ,0 x19 2 0 / / 0 x19 2 0 = = l . m o v h i r9
l. s h ( T R A M P _ S L O T _ 0 + 0 x0 ) ( r3 ) ,r5
l. s r l i r5 ,r6 ,1 6
l. s h ( T R A M P _ S L O T _ 0 + 0 x2 ) ( r3 ) ,r5
/ / l. o r i r9 ,0 x b b b b
l. o r i r5 ,r0 ,0 x a92 9 / / 0 x a92 9 = = l . o r i r9
l. s h ( T R A M P _ S L O T _ 1 + 0 x0 ) ( r3 ) ,r5
l. a n d i r5 ,r6 ,0 x f f f f
l. s h ( T R A M P _ S L O T _ 1 + 0 x2 ) ( r3 ) ,r5
/* falthrough, need to set up new jump offset */
0 : / / l. j
l. s l l i r6 ,r4 ,6 / / o r i g i n a l o f f s e t s h i f t e d l e f t 6 - 2
/ / l. s r l i r6 ,r6 ,6 / / o r i g i n a l o f f s e t s h i f t e d r i g h t 2
l. s l l i r4 ,r2 ,4 / / o l d j u m p p o s i t i o n : E E A s h i f t e d l e f t 4
/ / l. s r l i r4 ,r4 ,6 / / o l d j u m p p o s i t i o n : s h i f t e d r i g h t 2
l. a d d i r5 ,r3 ,0 x c / / n e w j u m p p o s i t i o n ( p h y s i c a l )
l. s l l i r5 ,r5 ,4 / / n e w j u m p p o s i t i o n : s h i f t e d l e f t 4
/ / calculate n e w j u m p o f f s e t
/ / new_ o f f = o l d _ o f f + ( o l d _ j u m p - n e w _ j u m p )
l. s u b r5 ,r4 ,r5 / / o l d _ j u m p - n e w _ j u m p
l. a d d r5 ,r6 ,r5 / / o r i g _ o f f + ( o l d _ j u m p - n e w _ j u m p )
l. s r l i r5 ,r5 ,6 / / n e w o f f s e t s h i f t e d r i g h t 2
/ / r5 i s n e w j u m p o f f s e t
/ / l. j h a s o p c o d e 0 x0 . . .
l. s w T R A M P _ S L O T _ 2 ( r3 ) ,r5 / / w r i t e i t b a c k
l. j t r a m p o l i n e _ o u t
l. n o p
/* ----------------------------- */
3 : / / l. j a l r
/ * 1 9 2 0 aa a a l . m o v h i r9 ,0 x a a a a
* a9 2 9 b b b b l . o r i r9 ,0 x b b b b
*
* where 0 x a a a a b b b b i s E E A + 0 x4 s h i f t e d r i g h t 2
* /
l. a d d i r6 ,r2 ,0 x4 / / t h i s i s 0 x a a a a b b b b
/ / l. m o v h i r9 ,0 x a a a a
l. o r i r5 ,r0 ,0 x19 2 0 / / 0 x19 2 0 = = l . m o v h i r9
l. s h ( T R A M P _ S L O T _ 0 + 0 x0 ) ( r3 ) ,r5
l. s r l i r5 ,r6 ,1 6
l. s h ( T R A M P _ S L O T _ 0 + 0 x2 ) ( r3 ) ,r5
/ / l. o r i r9 ,0 x b b b b
l. o r i r5 ,r0 ,0 x a92 9 / / 0 x a92 9 = = l . o r i r9
l. s h ( T R A M P _ S L O T _ 1 + 0 x0 ) ( r3 ) ,r5
l. a n d i r5 ,r6 ,0 x f f f f
l. s h ( T R A M P _ S L O T _ 1 + 0 x2 ) ( r3 ) ,r5
l. l h z r5 ,( T R A M P _ S L O T _ 2 + 0 x0 ) ( r3 ) / / l o a d h i p a r t o f j u m p i n s t r u c t i o n
l. a n d i r5 ,r5 ,0 x3 f f / / c l e a r o u t o p c o d e p a r t
l. o r i r5 ,r5 ,0 x44 0 0 / / o p c o d e c h a n g e d f r o m l . j a l r - > l . j r
l. s h ( T R A M P _ S L O T _ 2 + 0 x0 ) ( r3 ) ,r5 / / w r i t e i t b a c k
/* falthrough */
1 : / / l. j r
l. j t r a m p o l i n e _ o u t
l. n o p
/* ----------------------------- */
4 : / / l. b n f
5 : / / l. b f
l. s l l i r6 ,r4 ,6 / / o r i g i n a l o f f s e t s h i f t e d l e f t 6 - 2
/ / l. s r l i r6 ,r6 ,6 / / o r i g i n a l o f f s e t s h i f t e d r i g h t 2
l. s l l i r4 ,r2 ,4 / / o l d j u m p p o s i t i o n : E E A s h i f t e d l e f t 4
/ / l. s r l i r4 ,r4 ,6 / / o l d j u m p p o s i t i o n : s h i f t e d r i g h t 2
l. a d d i r5 ,r3 ,0 x c / / n e w j u m p p o s i t i o n ( p h y s i c a l )
l. s l l i r5 ,r5 ,4 / / n e w j u m p p o s i t i o n : s h i f t e d l e f t 4
/ / calculate n e w j u m p o f f s e t
/ / new_ o f f = o l d _ o f f + ( o l d _ j u m p - n e w _ j u m p )
l. a d d r6 ,r6 ,r4 / / ( o r i g _ o f f + o l d _ j u m p )
l. s u b r6 ,r6 ,r5 / / ( o r i g _ o f f + o l d _ j u m p ) - n e w _ j u m p
l. s r l i r6 ,r6 ,6 / / n e w o f f s e t s h i f t e d r i g h t 2
/ / r6 i s n e w j u m p o f f s e t
l. l w z r4 ,( T R A M P _ S L O T _ 2 + 0 x0 ) ( r3 ) / / l o a d j u m p i n s t r u c t i o n
l. s r l i r4 ,r4 ,1 6
l. a n d i r4 ,r4 ,0 x f c00 / / g e t o p c o d e p a r t
l. s l l i r4 ,r4 ,1 6
l. o r r6 ,r4 ,r6 / / l . b ( n ) f n e w o f f s e t
l. s w T R A M P _ S L O T _ 2 ( r3 ) ,r6 / / w r i t e i t b a c k
/* we need to add l.j to EEA + 0x8 */
tophys ( r4 ,r2 ) / / m a y n o t b e n e e d e d ( d u e t o s h i f t s d o w n _
l. a d d i r4 ,r4 ,( 0 x8 - 0 x8 ) / / j u m p t a r g e t = r2 + 0 x8 ( c o m p e n s a t e f o r 0 x8 )
/ / jump p o s i t i o n = r5 + 0 x8 ( 0 x8 c o m p e n s a t e d )
l. s u b r4 ,r4 ,r5 / / j u m p o f f s e t = t a r g e t - n e w _ p o s i t i o n + 0 x8
l. s l l i r4 ,r4 ,4 / / t h e a m o u n t o f i n f o i n i m e d i a t e o f j u m p
l. s r l i r4 ,r4 ,6 / / j u m p i n s t r u c t i o n w i t h o f f s e t
l. s w T R A M P _ S L O T _ 4 ( r3 ) ,r4 / / w r i t e i t t o 4 t h s l o t
/* fallthrough */
trampoline_out :
/ / set u p n e w E P C t o p o i n t t o o u r t r a m p o l i n e c o d e
LOAD_ S Y M B O L _ 2 _ G P R ( r5 ,_ i m m u _ t r a m p o l i n e )
l. m t s p r r0 ,r5 ,S P R _ E P C R _ B A S E
/ / immu_ t r a m p o l i n e i s ( 4 x ) C A C H E _ L I N E a l i g n e d
/ / and o n l y 6 i n s t r u c t i o n s l o n g ,
/ / so w e n e e d t o i n v a l i d a t e o n l y 2 l i n e s
/ * Establish c a c h e b l o c k s i z e
If B S =0 , 1 6 ;
If B S =1 , 3 2 ;
r1 4 c o n t a i n b l o c k s i z e
* /
l. m f s p r r21 ,r0 ,S P R _ I C C F G R
l. a n d i r21 ,r21 ,S P R _ I C C F G R _ C B S
l. s r l i r21 ,r21 ,7
l. o r i r23 ,r0 ,1 6
l. s l l r14 ,r23 ,r21
l. m t s p r r0 ,r5 ,S P R _ I C B I R
l. a d d r5 ,r5 ,r14
l. m t s p r r0 ,r5 ,S P R _ I C B I R
l. j r r9
l. n o p
/ *
* DSCR : prints a s t r i n g r e f e r e n c e d b y r3 .
*
* PRMS : r3 - a d d r e s s o f t h e f i r s t c h a r a c t e r o f n u l l
* terminated s t r i n g t o b e p r i n t e d
*
* PREQ : UART a t U A R T _ B A S E _ A D D h a s t o b e i n i t i a l i z e d
*
* POST : caller s h o u l d b e a w a r e t h a t r3 , r9 a r e c h a n g e d
* /
ENTRY( _ e m e r g e n c y _ p r i n t )
EMERGENCY_ P R I N T _ S T O R E _ G P R 4
EMERGENCY_ P R I N T _ S T O R E _ G P R 5
EMERGENCY_ P R I N T _ S T O R E _ G P R 6
EMERGENCY_ P R I N T _ S T O R E _ G P R 7
2 :
l. l b z r7 ,0 ( r3 )
l. s f e q r7 ,r0
l. b f 9 f
l. n o p
/ / putc :
l. m o v h i r4 ,h i ( U A R T _ B A S E _ A D D )
l. a d d i r6 ,r0 ,0 x20
1 : l. l b z r5 ,5 ( r4 )
l. a n d i r5 ,r5 ,0 x20
l. s f e q r5 ,r6
l. b n f 1 b
l. n o p
l. s b 0 ( r4 ) ,r7
l. a d d i r6 ,r0 ,0 x60
1 : l. l b z r5 ,5 ( r4 )
l. a n d i r5 ,r5 ,0 x60
l. s f e q r5 ,r6
l. b n f 1 b
l. n o p
/* next character */
l. j 2 b
l. a d d i r3 ,r3 ,0 x1
9 :
EMERGENCY_ P R I N T _ L O A D _ G P R 7
EMERGENCY_ P R I N T _ L O A D _ G P R 6
EMERGENCY_ P R I N T _ L O A D _ G P R 5
EMERGENCY_ P R I N T _ L O A D _ G P R 4
l. j r r9
l. n o p
ENTRY( _ e m e r g e n c y _ p r i n t _ n r )
EMERGENCY_ P R I N T _ S T O R E _ G P R 4
EMERGENCY_ P R I N T _ S T O R E _ G P R 5
EMERGENCY_ P R I N T _ S T O R E _ G P R 6
EMERGENCY_ P R I N T _ S T O R E _ G P R 7
EMERGENCY_ P R I N T _ S T O R E _ G P R 8
l. a d d i r8 ,r0 ,3 2 / / s h i f t r e g i s t e r
1 : /* remove leading zeros */
l. a d d i r8 ,r8 ,- 0 x4
l. s r l r7 ,r3 ,r8
l. a n d i r7 ,r7 ,0 x f
/* don't skip the last zero if number == 0x0 */
l. s f e q i r8 ,0 x4
l. b f 2 f
l. n o p
l. s f e q r7 ,r0
l. b f 1 b
l. n o p
2 :
l. s r l r7 ,r3 ,r8
l. a n d i r7 ,r7 ,0 x f
l. s f l t s r8 ,r0
l. b f 9 f
l. s f g t u i r7 ,0 x9
l. b n f 8 f
l. n o p
l. a d d i r7 ,r7 ,0 x27
8 :
l. a d d i r7 ,r7 ,0 x30
/ / putc :
l. m o v h i r4 ,h i ( U A R T _ B A S E _ A D D )
l. a d d i r6 ,r0 ,0 x20
1 : l. l b z r5 ,5 ( r4 )
l. a n d i r5 ,r5 ,0 x20
l. s f e q r5 ,r6
l. b n f 1 b
l. n o p
l. s b 0 ( r4 ) ,r7
l. a d d i r6 ,r0 ,0 x60
1 : l. l b z r5 ,5 ( r4 )
l. a n d i r5 ,r5 ,0 x60
l. s f e q r5 ,r6
l. b n f 1 b
l. n o p
/* next character */
l. j 2 b
l. a d d i r8 ,r8 ,- 0 x4
9 :
EMERGENCY_ P R I N T _ L O A D _ G P R 8
EMERGENCY_ P R I N T _ L O A D _ G P R 7
EMERGENCY_ P R I N T _ L O A D _ G P R 6
EMERGENCY_ P R I N T _ L O A D _ G P R 5
EMERGENCY_ P R I N T _ L O A D _ G P R 4
l. j r r9
l. n o p
/ *
* This s h o u l d b e u s e d f o r d e b u g g i n g o n l y .
* It m e s s e s u p t h e L i n u x e a r l y s e r i a l o u t p u t
* somehow, s o u s e i t s p a r i n g l y a n d e s s e n t i a l l y
* only i f y o u n e e d t o d e b u g s o m e t h i n g t h a t g o e s w r o n g
* before L i n u x g e t s t h e e a r l y s e r i a l g o i n g .
*
* Furthermore, y o u ' l l h a v e t o m a k e s u r e y o u s e t t h e
* UART_ D E V I S O R c o r r e c t l y a c c o r d i n g t o t h e s y s t e m
* clock r a t e .
*
*
* /
# define S Y S _ C L K 2 0 0 0 0 0 0 0
/ / # define S Y S _ C L K 1 8 4 3 2 0 0
# define O R 3 2 _ C O N S O L E _ B A U D 1 1 5 2 0 0
# define U A R T _ D I V I S O R S Y S _ C L K / ( 1 6 * O R 3 2 _ C O N S O L E _ B A U D )
ENTRY( _ e a r l y _ u a r t _ i n i t )
l. m o v h i r3 ,h i ( U A R T _ B A S E _ A D D )
l. a d d i r4 ,r0 ,0 x7
l. s b 0 x2 ( r3 ) ,r4
l. a d d i r4 ,r0 ,0 x0
l. s b 0 x1 ( r3 ) ,r4
l. a d d i r4 ,r0 ,0 x3
l. s b 0 x3 ( r3 ) ,r4
l. l b z r5 ,3 ( r3 )
l. o r i r4 ,r5 ,0 x80
l. s b 0 x3 ( r3 ) ,r4
l. a d d i r4 ,r0 ,( ( U A R T _ D I V I S O R > > 8 ) & 0 x00 0 0 0 0 f f )
l. s b U A R T _ D L M ( r3 ) ,r4
l. a d d i r4 ,r0 ,( ( U A R T _ D I V I S O R ) & 0 x00 0 0 0 0 f f )
l. s b U A R T _ D L L ( r3 ) ,r4
l. s b 0 x3 ( r3 ) ,r5
l. j r r9
l. n o p
_string_copying_linux :
.string " \ n\ n \ n \ n \ n \ r C o p y i n g L i n u x . . . \ 0 "
_string_ok_booting :
.string " Ok, b o o t i n g t h e k e r n e l . \ n \ r \ 0 "
_string_unhandled_exception :
.string " \ n\ r R u n a r u n a r o u n d : U n h a n d l e d e x c e p t i o n 0 x \ 0 "
_string_epc_prefix :
.string " : EPC=0x \ 0 "
_string_nl :
.string " \ n\ r \ 0 "
.global _string_esr_irq_bug
_string_esr_irq_bug :
.string " \ n\ r E S R e x t e r n a l i n t e r r u p t b u g , f o r d e t a i l s l o o k i n t o e n t r y . S \ n \ r \ 0 "
/* ========================================[ page aligned structures ]=== */
/ *
* .data section should b e p a g e a l i g n e d
* ( look i n t o a r c h / o r32 / k e r n e l / v m l i n u x . l d s )
* /
.section .data , " aw"
.align 8192
.global empty_zero_page
empty_zero_page :
.space 8192
.global swapper_pg_dir
swapper_pg_dir :
.space 8192
.global _unhandled_stack
_unhandled_stack :
.space 8192
_unhandled_stack_top :
/* ============================================================[ EOF ]=== */