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