2 // Copyright (c) 2002-2010 Xilinx, Inc. All rights reserved.
5 // XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
6 // COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
7 // ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
8 // STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
9 // IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
10 // FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
11 // XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
12 // THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
13 // ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
14 // FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
15 // AND FITNESS FOR A PARTICULAR PURPOSE.
17 // $Id: profile_cg.c,v 1.1.2.1 2011/05/17 04:37:57 sadanan Exp $
21 #include "_profile_timer_hw.h"
22 #ifdef PROC_MICROBLAZE
23 #include "mblaze_nt_types.h"
27 * The mcount fucntion is excluded from the library, if the user defines
30 #ifndef PROFILE_NO_GRAPH
36 extern struct gmonparam *_gmonparam;
38 #ifdef PROFILE_NO_FUNCPTR
39 int searchpc( struct fromto_struct *cgtable, int cgtable_size, unsigned long frompc )
43 while( (index < cgtable_size) && (cgtable[index].frompc != frompc) ){
46 if( index == cgtable_size )
52 int searchpc( struct fromstruct *froms, int fromssize, unsigned long frompc )
56 while( (index < fromssize) && (froms[index].frompc != frompc) ){
59 if( index == fromssize )
64 #endif /* PROFILE_NO_FUNCPTR */
67 void mcount( unsigned long frompc, unsigned long selfpc )
69 register struct gmonparam *p = NULL;
70 register long toindex, fromindex;
75 //print("CG: "); putnum(frompc); print("->"); putnum(selfpc); print("\r\n");
76 // check that frompcindex is a reasonable pc value.
77 // for example: signal catchers get called from the stack,
78 // not from text space. too bad.
80 for(j = 0; j < n_gmon_sections; j++ ){
81 if((frompc >= _gmonparam[j].lowpc) && (frompc < _gmonparam[j].highpc)) {
86 if( j == n_gmon_sections )
89 #ifdef PROFILE_NO_FUNCPTR
90 fromindex = searchpc( p->cgtable, p->cgtable_size, frompc ) ;
91 if( fromindex == -1 ) {
92 fromindex = p->cgtable_size ;
94 p->cgtable[fromindex].frompc = frompc ;
95 p->cgtable[fromindex].selfpc = selfpc ;
96 p->cgtable[fromindex].count = 1 ;
99 p->cgtable[fromindex].count++ ;
101 fromindex = searchpc( p->froms, p->fromssize, frompc ) ;
102 if( fromindex == -1 ) {
103 fromindex = p->fromssize ;
105 //if( fromindex >= N_FROMS ) {
106 //print("Error : From PC table overflow\r\n") ;
109 p->froms[fromindex].frompc = frompc ;
110 p->froms[fromindex].link = -1 ;
112 toindex = p->froms[fromindex].link ;
113 while(toindex != -1) {
114 toindex = (p->tossize - toindex)-1 ;
115 if( p->tos[toindex].selfpc == selfpc ) {
116 p->tos[toindex].count++ ;
119 toindex = p->tos[toindex].link ;
123 //if( toindex == -1 ) {
126 //if( toindex >= N_TOS ) {
127 //print("Error : To PC table overflow\r\n") ;
130 p->tos[0].selfpc = selfpc ;
131 p->tos[0].count = 1 ;
132 p->tos[0].link = p->froms[fromindex].link ;
133 p->froms[fromindex].link = p->tossize-1 ;
137 p->state = GMON_PROF_ON;
140 p->state = GMON_PROF_ERROR;
147 #endif /* PROFILE_NO_GRAPH */