2005-04-17 02:20:36 +04:00
/ *
* Copyright ( C ) 2 0 0 0 A n t o n B l a n c h a r d ( a n t o n @linuxcare.com)
*
* This f i l e i m p l e m e n t s m c o u n t ( ) , w h i c h i s u s e d t o c o l l e c t p r o f i l i n g d a t a .
* This c a n a l s o b e t w e a k e d f o r k e r n e l s t a c k o v e r f l o w d e t e c t i o n .
* /
# include < l i n u x / l i n k a g e . h >
2016-01-17 05:39:30 +03:00
# include < a s m / e x p o r t . h >
2005-04-17 02:20:36 +04:00
/ *
* This i s t h e m a i n v a r i a n t a n d i s c a l l e d b y C c o d e . G C C ' s - p g o p t i o n
* automatically i n s t r u m e n t s e v e r y C f u n c t i o n w i t h a c a l l t o t h i s .
* /
.text
2008-05-14 09:06:59 +04:00
.align 32
.globl _mcount
.type _ mcount,#f u n c t i o n
2016-01-17 05:39:30 +03:00
EXPORT_ S Y M B O L ( _ m c o u n t )
2008-05-14 09:06:59 +04:00
.globl mcount
.type mcount,#f u n c t i o n
2005-04-17 02:20:36 +04:00
_mcount :
2008-05-14 09:06:59 +04:00
mcount :
2008-10-07 03:06:12 +04:00
# ifdef C O N F I G _ F U N C T I O N _ T R A C E R
2008-05-14 09:06:59 +04:00
# ifdef C O N F I G _ D Y N A M I C _ F T R A C E
2010-04-13 09:35:24 +04:00
/* Do nothing, the retl/nop below is all we need. */
2008-05-14 09:06:59 +04:00
# else
2014-06-25 20:22:53 +04:00
sethi % h i ( f t r a c e _ t r a c e _ f u n c t i o n ) , % g 1
2008-05-14 09:06:59 +04:00
sethi % h i ( f t r a c e _ s t u b ) , % g 2
ldx [ % g 1 + % l o ( f t r a c e _ t r a c e _ f u n c t i o n ) ] , % g 1
or % g 2 , % l o ( f t r a c e _ s t u b ) , % g 2
cmp % g 1 , % g 2
be,p n % i c c , 1 f
2010-04-07 15:41:33 +04:00
mov % i 7 , % g 3
2010-04-14 05:59:02 +04:00
save % s p , - 1 7 6 , % s p
2010-04-07 15:41:33 +04:00
mov % g 3 , % o 1
2010-04-07 06:59:46 +04:00
jmpl % g 1 , % o 7
mov % i 7 , % o 0
ret
restore
2008-05-14 09:06:59 +04:00
/* not reached */
1 :
2010-04-07 15:41:33 +04:00
# ifdef C O N F I G _ F U N C T I O N _ G R A P H _ T R A C E R
sethi % h i ( f t r a c e _ g r a p h _ r e t u r n ) , % g 1
ldx [ % g 1 + % l o ( f t r a c e _ g r a p h _ r e t u r n ) ] , % g 3
cmp % g 2 , % g 3
bne,p n % x c c , 5 f
sethi % h i ( f t r a c e _ g r a p h _ e n t r y _ s t u b ) , % g 2
sethi % h i ( f t r a c e _ g r a p h _ e n t r y ) , % g 1
or % g 2 , % l o ( f t r a c e _ g r a p h _ e n t r y _ s t u b ) , % g 2
ldx [ % g 1 + % l o ( f t r a c e _ g r a p h _ e n t r y ) ] , % g 1
cmp % g 1 , % g 2
be,p t % x c c , 2 f
nop
5 : mov % i 7 , % g 2
mov % f p , % g 3
2010-04-14 05:59:02 +04:00
save % s p , - 1 7 6 , % s p
2010-04-07 15:41:33 +04:00
mov % g 2 , % l 0
ba,p t % x c c , f t r a c e _ g r a p h _ c a l l e r
mov % g 3 , % l 1
# endif
2 :
2005-04-17 02:20:36 +04:00
# endif
2008-05-14 09:06:59 +04:00
# endif
retl
2005-04-17 02:20:36 +04:00
nop
2008-05-14 09:06:59 +04:00
.size _ mcount,. - _ m c o u n t
.size mcount,. - m c o u n t
2008-10-07 03:06:12 +04:00
# ifdef C O N F I G _ F U N C T I O N _ T R A C E R
2008-05-14 09:06:59 +04:00
.globl ftrace_stub
.type ftrace_ s t u b ,#f u n c t i o n
ftrace_stub :
retl
nop
.size ftrace_ s t u b ,. - f t r a c e _ s t u b
# ifdef C O N F I G _ D Y N A M I C _ F T R A C E
.globl ftrace_caller
.type ftrace_ c a l l e r ,#f u n c t i o n
ftrace_caller :
2010-04-07 06:59:46 +04:00
mov % i 7 , % g 2
2014-06-25 20:22:53 +04:00
mov % f p , % g 3
2010-04-14 05:59:02 +04:00
save % s p , - 1 7 6 , % s p
2010-04-07 06:59:46 +04:00
mov % g 2 , % o 1
2010-04-07 15:41:33 +04:00
mov % g 2 , % l 0
mov % g 3 , % l 1
2008-05-14 09:06:59 +04:00
.globl ftrace_call
ftrace_call :
call f t r a c e _ s t u b
2010-04-07 06:59:46 +04:00
mov % i 7 , % o 0
2010-04-07 15:41:33 +04:00
# ifdef C O N F I G _ F U N C T I O N _ G R A P H _ T R A C E R
.globl ftrace_graph_call
ftrace_graph_call :
call f t r a c e _ s t u b
nop
# endif
2010-04-07 06:59:46 +04:00
ret
restore
2010-04-07 15:41:33 +04:00
# ifdef C O N F I G _ F U N C T I O N _ G R A P H _ T R A C E R
.size ftrace_ g r a p h _ c a l l ,. - f t r a c e _ g r a p h _ c a l l
# endif
2010-04-13 09:35:24 +04:00
.size ftrace_ c a l l ,. - f t r a c e _ c a l l
2008-05-14 09:06:59 +04:00
.size ftrace_ c a l l e r ,. - f t r a c e _ c a l l e r
# endif
# endif
2010-04-07 15:41:33 +04:00
# ifdef C O N F I G _ F U N C T I O N _ G R A P H _ T R A C E R
ENTRY( f t r a c e _ g r a p h _ c a l l e r )
mov % l 0 , % o 0
mov % i 7 , % o 1
call p r e p a r e _ f t r a c e _ r e t u r n
mov % l 1 , % o 2
ret
restore % o 0 , - 8 , % i 7
END( f t r a c e _ g r a p h _ c a l l e r )
ENTRY( r e t u r n _ t o _ h a n d l e r )
2010-04-14 05:59:02 +04:00
save % s p , - 1 7 6 , % s p
2010-04-07 15:41:33 +04:00
call f t r a c e _ r e t u r n _ t o _ h a n d l e r
mov % f p , % o 0
jmpl % o 0 + 8 , % g 0
restore
END( r e t u r n _ t o _ h a n d l e r )
# endif