]> rtime.felk.cvut.cz Git - can-usb1.git/blob - ulan/host/ul_drv/ul_drv/ul_debug.c
Initializing repo
[can-usb1.git] / ulan / host / ul_drv / ul_drv / ul_debug.c
1 /*******************************************************************
2   uLan Communication - uL_DRV - multiplatform uLan driver
3
4   ul_debug.c    - common debugging routines
5
6   (C) Copyright 1996-2004 by Pavel Pisa - project originator
7         http://cmp.felk.cvut.cz/~pisa
8   (C) Copyright 1996-2004 PiKRON Ltd.
9         http://www.pikron.com
10   (C) Copyright 2002-2004 Petr Smolik
11   
12
13   The uLan driver project can be used and distributed 
14   in compliance with any of next licenses
15    - GPL - GNU Public License
16      See file COPYING for details.
17    - LGPL - Lesser GNU Public License
18    - MPL - Mozilla Public License
19    - and other licenses added by project originator
20
21   Code can be modified and re-distributed under any combination
22   of the above listed licenses. If contributor does not agree with
23   some of the licenses, he/she can delete appropriate line.
24   WARNING: if you delete all lines, you are not allowed to
25   distribute code or sources in any form.
26  *******************************************************************/
27
28 void printblk(ul_mem_blk *blk)
29 {
30   ul_mem_blk *prev_blk=NULL;
31   while(blk)
32   {
33     if(prev_blk) if(UL_BLK_HEAD(blk).prev!=prev_blk)
34        UL_PRINTF(KERN_CRIT "Inconsistency in BLL list !!!\n");
35
36     UL_PRINTF("BLK : dadr=%02X sadr=%02X cmd=%02X flg=%04X retry=%02X len=%04X\n",
37      UL_BLK_HEAD(blk).dadr,
38      UL_BLK_HEAD(blk).sadr,
39      UL_BLK_HEAD(blk).cmd,
40      UL_BLK_HEAD(blk).flg,
41      UL_BLK_HEAD(blk).retry_cnt,
42      UL_BLK_HEAD(blk).len
43     );
44     {
45       ul_data_it di;
46       uchar ch;
47       int cnt=128;
48       UL_PRINTF("      |");
49       ul_di_init(&di,blk);
50       di.trans_len=UL_BLK_HEAD(blk).len;
51       while((di.pos<di.trans_len)&& --cnt)
52       {
53         ch=ul_di_read1(&di);
54         if(ch>=0x20&&ch<0x7F) UL_PRINTF("%c",ch);
55         else UL_PRINTF("<%X>",ch);
56       };
57       if(!cnt) UL_PRINTF("<...>...");
58       UL_PRINTF("|\n");
59     };
60     prev_blk=blk;
61     blk=UL_BLK_HEAD(blk).next;
62   };
63 };
64
65 void printudrvbll(ul_drv *udrv)
66 {
67   UL_PRINTF("\nprep_bll : frames = %d\n",udrv->prep_bll.cnt);
68   printblk(udrv->prep_bll.first);
69
70   UL_PRINTF("\nwork_bll : frames = %d\n",udrv->work_bll.cnt);
71   printblk(udrv->work_bll.first);
72
73   UL_PRINTF("\nproc_bll : frames = %d\n",udrv->proc_bll.cnt);
74   printblk(udrv->proc_bll.first);
75   UL_PRINTF("\nopan_bll : frames = %d\n",udrv->opan_bll.cnt);
76   printblk(udrv->opan_bll.first);
77   UL_PRINTF("\nfree_blk = %d",udrv->free_blk_cnt);
78   UL_PRINTF("\n");
79  #ifdef ENABLE_UL_MEM_CHECK
80   UL_PRINTF("MEM_CHECK: malloc-free=%d\n",
81                  (int)atomic_read(&ul_mem_check_counter));
82  #endif /* ENABLE_UL_MEM_CHECK */
83 };
84
85 void printudrvoperators(ul_drv *udrv)
86 {
87   UL_DRV_LOCK_FINI
88   ul_opdata *opdata;
89   ul_opchain *opmember,**opchain;
90   int reccnt,filtcnt,opcnt;
91   UL_PRINTF("\nul_drv operators (open handles)\n");
92   UL_DRV_LOCK;
93   opcnt=0;
94   for(opdata=udrv->operators;opdata;opdata=opdata->opnext)
95   { opchain=&opdata->recchain;reccnt=0;
96     if((opmember=*opchain)!=NULL)do{
97       reccnt++; if(reccnt>1000) break;
98     }while((opmember=opmember->next)!=*opchain);
99     opchain=&opdata->filtchain;filtcnt=0;
100     if((opmember=*opchain)!=NULL)do{
101       filtcnt++; if(filtcnt>1000) break;
102     }while((opmember=opmember->next)!=*opchain);
103     UL_PRINTF("  operator %d, in recchain %d, in filtchain %d\n",
104                     opcnt,reccnt,filtcnt);
105     opcnt++;if(opcnt>100) break;
106   }
107   UL_DRV_UNLOCK;
108 }
109
110 void printudrvfncstack(ul_drv *udrv)
111 {
112   ul_call_fnc **p;
113   UL_PRINTF("ul_drv: fnc_act:%08lx fnc_stack:",(long)udrv->fnc_act);
114   p=udrv->fnc_sp;
115   while(p!=&udrv->fnc_stack[0]){
116     p--;
117     UL_PRINTF("%08lx ",(long)*p);
118   };
119   UL_PRINTF("\n");
120 }
121