2005-04-16 15:20:36 -07: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 >
/ *
* 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-13 22:06:59 -07:00
.align 32
.globl _mcount
.type _ mcount,#f u n c t i o n
.globl mcount
.type mcount,#f u n c t i o n
2005-04-16 15:20:36 -07:00
_mcount :
2008-05-13 22:06:59 -07:00
mcount :
2008-10-06 19: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-13 22:06:59 -07:00
# ifdef C O N F I G _ D Y N A M I C _ F T R A C E
2010-04-12 22:35:24 -07:00
/* Do nothing, the retl/nop below is all we need. */
2008-05-13 22:06:59 -07:00
# else
2010-04-12 22:35:24 -07:00
sethi % h i ( f u n c t i o n _ t r a c e _ s t o p ) , % g 1
lduw [ % g 1 + % l o ( f u n c t i o n _ t r a c e _ s t o p ) ] , % g 2
brnz,p n % g 2 , 1 f
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-13 22:06:59 -07: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-06 19:59:46 -07:00
mov % i 7 , % g 2
save % s p , - 1 2 8 , % s p
mov % g 2 , % o 1
jmpl % g 1 , % o 7
mov % i 7 , % o 0
ret
restore
2008-05-13 22:06:59 -07:00
/* not reached */
1 :
2005-04-16 15:20:36 -07:00
# endif
2008-05-13 22:06:59 -07:00
# endif
retl
2005-04-16 15:20:36 -07:00
nop
2008-05-13 22:06:59 -07:00
.size _ mcount,. - _ m c o u n t
.size mcount,. - m c o u n t
2008-10-06 19: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-13 22:06:59 -07: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-12 22:35:24 -07:00
sethi % h i ( f u n c t i o n _ t r a c e _ s t o p ) , % g 1
2010-04-06 19:59:46 -07:00
mov % i 7 , % g 2
lduw [ % g 1 + % l o ( f u n c t i o n _ t r a c e _ s t o p ) ] , % g 3
brnz,p n % g 3 , f t r a c e _ s t u b
nop
save % s p , - 1 2 8 , % s p
mov % g 2 , % o 1
2008-05-13 22:06:59 -07:00
.globl ftrace_call
ftrace_call :
call f t r a c e _ s t u b
2010-04-06 19:59:46 -07:00
mov % i 7 , % o 0
ret
restore
2010-04-12 22:35:24 -07:00
.size ftrace_ c a l l ,. - f t r a c e _ c a l l
2008-05-13 22:06:59 -07:00
.size ftrace_ c a l l e r ,. - f t r a c e _ c a l l e r
# endif
# endif