2010-05-29 07:09:12 +04:00
/ *
* Copyright 2 0 1 0 T i l e r a C o r p o r a t i o n . A l l R i g h t s R e s e r v e d .
*
* 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 , v e r s i o n 2 .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l , b u t
* WITHOUT A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY O R F I T N E S S F O R A P A R T I C U L A R P U R P O S E , G O O D T I T L E o r
* NON I N F R I N G E M E N T . S e e 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 f o r
* more d e t a i l s .
* /
# include < l i n u x / l i n k a g e . h >
2010-06-26 01:04:17 +04:00
# include < l i n u x / u n i s t d . h >
2010-05-29 07:09:12 +04:00
# include < a s m / i r q f l a g s . h >
2010-10-15 00:23:03 +04:00
# include < a s m / p r o c e s s o r . h >
2010-06-26 01:04:17 +04:00
# include < a r c h / a b i . h >
2010-10-15 00:23:03 +04:00
# include < a r c h / s p r _ d e f . h >
2010-05-29 07:09:12 +04:00
# ifdef _ _ t i l e g x _ _
# define b n z t b n e z t
# endif
STD_ E N T R Y ( c u r r e n t _ t e x t _ a d d r )
{ move r0 , l r ; jrp lr }
STD_ E N D P R O C ( c u r r e n t _ t e x t _ a d d r )
/ *
* Implement e x e c v e ( ) . T h e i 3 8 6 c o d e h a s a n o t e t h a t f o r k i n g f r o m k e r n e l
* space r e s u l t s i n n o c o p y o n w r i t e u n t i l t h e e x e c v e , s o w e s h o u l d b e
* careful n o t t o w r i t e t o t h e s t a c k h e r e .
* /
STD_ E N T R Y ( k e r n e l _ e x e c v e )
moveli T R E G _ S Y S C A L L _ N R _ N A M E , _ _ N R _ e x e c v e
swint1
jrp l r
STD_ E N D P R O C ( k e r n e l _ e x e c v e )
/* Delay a fixed number of cycles. */
STD_ E N T R Y ( _ _ d e l a y )
{ addi r0 , r0 , - 1 ; bnzt r0, . }
jrp l r
STD_ E N D P R O C ( _ _ d e l a y )
/ *
* We d o n ' t r u n t h i s f u n c t i o n d i r e c t l y , b u t i n s t e a d c o p y i t t o a p a g e
* we m a p i n t o e v e r y u s e r p r o c e s s . S e e v d s o _ s e t u p ( ) .
*
* Note t h a t l i b c h a s a c o p y o f t h i s f u n c t i o n t h a t i t u s e s t o c o m p a r e
* against t h e P C w h e n a s t a c k b a c k t r a c e e n d s , s o i f t h i s c o d e i s
* changed, t h e l i b c i m p l e m e n t a t i o n ( s ) s h o u l d a l s o b e u p d a t e d .
* /
.pushsection .data
ENTRY( _ _ r t _ s i g r e t u r n )
moveli T R E G _ S Y S C A L L _ N R _ N A M E ,_ _ N R _ r t _ s i g r e t u r n
swint1
ENDPROC( _ _ r t _ s i g r e t u r n )
ENTRY( _ _ r t _ s i g r e t u r n _ e n d )
.popsection
STD_ E N T R Y ( d u m p _ s t a c k )
{ move r2 , l r ; lnk r1 }
{ move r4 , r52 ; addli r1, r1, dump_stack - . }
{ move r3 , s p ; j _dump_stack }
jrp l r / * k e e p b a c k t r a c e r h a p p y * /
STD_ E N D P R O C ( d u m p _ s t a c k )
STD_ E N T R Y ( K B a c k t r a c e I t e r a t o r _ i n i t _ c u r r e n t )
{ move r2 , l r ; lnk r1 }
{ move r4 , r52 ; addli r1, r1, KBacktraceIterator_init_current - . }
{ move r3 , s p ; j _KBacktraceIterator_init_current }
jrp l r / * k e e p b a c k t r a c e r h a p p y * /
STD_ E N D P R O C ( K B a c k t r a c e I t e r a t o r _ i n i t _ c u r r e n t )
/ *
* Reset o u r s t a c k t o r1 / r2 ( s p a n d k s p0 + c p u r e s p e c t i v e l y ) , t h e n
* free t h e o l d s t a c k ( p a s s e d i n r0 ) a n d r e - i n v o k e c p u _ i d l e ( ) .
* We u p d a t e s p a n d k s p0 s i m u l t a n e o u s l y t o a v o i d b a c k t r a c e r w a r n i n g s .
* /
STD_ E N T R Y ( c p u _ i d l e _ o n _ n e w _ s t a c k )
{
move s p , r1
2010-10-15 00:23:03 +04:00
mtspr S P R _ S Y S T E M _ S A V E _ K _ 0 , r2
2010-05-29 07:09:12 +04:00
}
jal f r e e _ t h r e a d _ i n f o
j c p u _ i d l e
STD_ E N D P R O C ( c p u _ i d l e _ o n _ n e w _ s t a c k )
/* Loop forever on a nap during SMP boot. */
STD_ E N T R Y ( s m p _ n a p )
nap
j s m p _ n a p / * w e a r e n o t a r c h i t e c t u r a l l y g u a r a n t e e d n o t t o e x i t n a p * /
jrp l r / * c l u e i n t h e b a c k t r a c e r * /
STD_ E N D P R O C ( s m p _ n a p )
/ *
* Enable i n t e r r u p t s r a c e l e s s l y a n d t h e n n a p u n t i l i n t e r r u p t e d .
* This f u n c t i o n ' s _ c p u _ i d l e _ n a p a d d r e s s i s s p e c i a l ; see intvec.S.
* When i n t e r r u p t e d a t _ c p u _ i d l e _ n a p , w e b u m p t h e P C f o r w a r d 8 , a n d
* as a r e s u l t r e t u r n t o t h e f u n c t i o n t h a t c a l l e d _ c p u _ i d l e ( ) .
* /
STD_ E N T R Y ( _ c p u _ i d l e )
{
lnk r0
2010-10-15 00:23:03 +04:00
movei r1 , K E R N E L _ P L
2010-05-29 07:09:12 +04:00
}
{
addli r0 , r0 , _ c p u _ i d l e _ n a p - .
mtspr I N T E R R U P T _ C R I T I C A L _ S E C T I O N , r1
}
2010-10-15 00:23:03 +04:00
IRQ_ E N A B L E ( r2 , r3 ) / * u n m a s k , b u t s t i l l w i t h I C S s e t * /
mtspr S P R _ E X _ C O N T E X T _ K _ 1 , r1 / * K e r n e l P L , I C S c l e a r * /
mtspr S P R _ E X _ C O N T E X T _ K _ 0 , r0
2010-05-29 07:09:12 +04:00
iret
.global _cpu_idle_nap
_cpu_idle_nap :
nap
jrp l r
STD_ E N D P R O C ( _ c p u _ i d l e )