1 #include <linux/kernel.h>
2 #include <linux/slab.h>
3 #include <linux/time.h>
6 #define TRACE_ARR_LEN 800
11 unsigned int callback_val1
;
12 unsigned int callback_val2
;
15 static unsigned int (*trc_callback1
) (unsigned char) = NULL
;
16 static unsigned int (*trc_callback2
) (unsigned char) = NULL
;
17 static unsigned char trc_param1
= 0;
18 static unsigned char trc_param2
= 0;
19 struct trace
*trc_arr
;
21 static int trc_active
= 0;
33 void TRC_INIT(void *callback1
, void *callback2
, unsigned char callback1_param
, unsigned char callback2_param
)
35 printk("Marvell debug tracing is on\n");
36 trc_arr
= (struct trace
*)kmalloc(TRACE_ARR_LEN
*sizeof(struct trace
),GFP_KERNEL
);
39 printk("Can't allocate Debug Trace buffer\n");
42 memset(trc_arr
,0,TRACE_ARR_LEN
*sizeof(struct trace
));
44 trc_callback1
= callback1
;
45 trc_callback2
= callback2
;
46 trc_param1
= callback1_param
;
47 trc_param2
= callback2_param
;
49 void TRC_REC(char *fmt
,...)
52 struct trace
*trc
= &trc_arr
[trc_index
];
57 do_gettimeofday(&trc
->tv
);
59 trc
->callback_val1
= trc_callback1(trc_param1
);
61 trc
->callback_val2
= trc_callback2(trc_param2
);
63 vsprintf(trc
->str
,fmt
,args
);
66 if((++trc_index
) == TRACE_ARR_LEN
) {
74 printk("\n\nTrace %d items\n",TRACE_ARR_LEN
);
75 for(i
=0,j
=trc_index
; i
<TRACE_ARR_LEN
; i
++,j
++) {
76 if(j
== TRACE_ARR_LEN
)
83 plast
= &trc_arr
[TRACE_ARR_LEN
-1];
86 if(p
->tv
.tv_sec
== ((plast
)->tv
.tv_sec
))
87 uoffs
= (p
->tv
.tv_usec
- ((plast
)->tv
.tv_usec
));
89 uoffs
= (1000000 - ((plast
)->tv
.tv_usec
)) +
90 ((p
->tv
.tv_sec
- ((plast
)->tv
.tv_sec
) - 1) * 1000000) +
92 printk("%03d: [+%ld usec]", j
, (unsigned long)uoffs
);
94 printk("[%u]",p
->callback_val1
);
96 printk("[%u]",p
->callback_val2
);
97 printk(": %s",p
->str
);
101 memset(trc_arr
,0,TRACE_ARR_LEN
*sizeof(struct trace
));
104 void TRC_RELEASE(void)
This page took 0.044633 seconds and 5 git commands to generate.