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