lmc_debug.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #include <linux/types.h>
  2. #include <linux/sched.h>
  3. #include <linux/netdevice.h>
  4. #include <linux/interrupt.h>
  5. #include <linux/version.h>
  6. #include "lmc_ver.h"
  7. #include "lmc_debug.h"
  8. /*
  9.  * Prints out len, max to 80 octets using printk, 20 per line
  10.  */
  11. void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
  12. {
  13. #ifdef DEBUG
  14. #ifdef LMC_PACKET_LOG
  15.   int iNewLine = 1;
  16.   char str[80], *pstr;
  17.   
  18.   sprintf(str, KERN_DEBUG "lmc: %s: ", type);
  19.   pstr = str+strlen(str);
  20.   
  21.   if(iLen > 240){
  22.       printk(KERN_DEBUG "lmc: Printing 240 chars... out of: %dn", iLen);
  23.     iLen = 240;
  24.   }
  25.   else{
  26.       printk(KERN_DEBUG "lmc: Printing %d charsn", iLen);
  27.   }
  28.   while(iLen > 0) 
  29.     {
  30.       sprintf(pstr, "%02x ", *ucData);
  31.       pstr+=3;
  32.       ucData++;
  33.       if( !(iNewLine % 20))
  34. {
  35.   sprintf(pstr, "n");
  36.   printk(str);
  37.   sprintf(str, KERN_DEBUG "lmc: %s: ", type);
  38.   pstr=str+strlen(str);
  39. }
  40.       iNewLine++;
  41.       iLen--;
  42.     }
  43.   sprintf(pstr, "n");
  44.   printk(str);
  45. #endif
  46. #endif
  47. }
  48. #ifdef DEBUG
  49. u_int32_t lmcEventLogIndex = 0;
  50. u_int32_t lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS];
  51. #endif
  52. void lmcEventLog (u_int32_t EventNum, u_int32_t arg2, u_int32_t arg3)
  53. {
  54. #ifdef DEBUG
  55.   lmcEventLogBuf[lmcEventLogIndex++] = EventNum;
  56.   lmcEventLogBuf[lmcEventLogIndex++] = arg2;
  57.   lmcEventLogBuf[lmcEventLogIndex++] = arg3;
  58.   lmcEventLogBuf[lmcEventLogIndex++] = jiffies;
  59.   lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1;
  60. #endif
  61. }
  62. inline void lmc_trace(struct net_device *dev, char *msg){
  63. #ifdef LMC_TRACE
  64.     unsigned long j = jiffies + 3; /* Wait for 50 ms */
  65.     if(in_interrupt()){
  66.         printk("%s: * %sn", dev->name, msg);
  67. //        while(jiffies < j+10)
  68. //            ;
  69.     }
  70.     else {
  71.         printk("%s: %sn", dev->name, msg);
  72.         while(jiffies < j)
  73.             schedule();
  74.     }
  75. #endif
  76. }
  77. /* --------------------------- end if_lmc_linux.c ------------------------ */