2013-01-18 13:42:18 +04:00
/ *
* Copyright ( C ) 2 0 0 4 , 2 0 0 7 - 2 0 1 0 , 2 0 1 1 - 2 0 1 2 S y n o p s y s , I n c . ( w w w . s y n o p s y s . c o m )
*
* 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
* it 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 v e r s i o n 2 a s
* published 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 .
*
* Vineetg : Aug 2 0 0 9
* - Moved c o r e c o n t e x t s w i t c h m a c r o o u t o f e n t r y . S i n t o t h i s f i l e .
* - This i s t h e m o r e " n a t u r a l " h a n d w r i t t e n a s s e m b l e r
* /
# include < a s m / e n t r y . h > / * F o r t h e S A V E _ * m a c r o s * /
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / l i n k a g e . h >
2013-11-01 09:16:40 +04:00
# define K S P _ W O R D _ O F F ( ( T A S K _ T H R E A D + T H R E A D _ K S P ) / 4 )
2013-01-18 13:42:18 +04:00
;################### Low Level Context Switch ##########################
.section .sched .text , " ax" ,@progbits
.align 4
.global __switch_to
.type _ _ switch_ t o , @function
__switch_to :
/* Save regs on kernel mode stack of task */
st. a b l i n k , [ s p , - 4 ]
st. a f p , [ s p , - 4 ]
SAVE_ C A L L E E _ S A V E D _ K E R N E L
/* Save the now KSP in task->thread.ksp */
2013-11-01 09:16:40 +04:00
# if K S P _ W O R D _ O F F < = 2 5 5
st. a s s p , [ r0 , K S P _ W O R D _ O F F ]
# else
/* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
add2 r24 , r0 , K S P _ W O R D _ O F F
st s p , [ r24 ]
# endif
2013-01-18 13:42:18 +04:00
/ *
* Return l a s t t a s k i n r0 ( r e t u r n r e g )
* On A R C , R e t u r n r e g = F i r s t A r g r e g = r0 .
* Since w e a l r e a d y h a v e l a s t t a s k i n r0 ,
* don' t n e e d t o d o a n y t h i n g s p e c i a l t o r e t u r n i t
* /
/* hardware memory barrier */
sync
/ *
* switch t o n e w t a s k , c o n t a i n e d i n r1
* Temp r e g r3 i s r e q u i r e d t o g e t t h e p t r t o s t o r e v a l
* /
SET_ C U R R _ T A S K _ O N _ C P U r1 , r3
/* reload SP with kernel mode stack pointer in task->thread.ksp */
ld. a s s p , [ r1 , ( T A S K _ T H R E A D + T H R E A D _ K S P ) / 4 ]
/* restore the registers */
RESTORE_ C A L L E E _ S A V E D _ K E R N E L
ld. a b f p , [ s p , 4 ]
ld. a b b l i n k , [ s p , 4 ]
j [ b l i n k ]
2014-02-07 12:17:43 +04:00
END( _ _ s w i t c h _ t o )