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