lmc_debug.c 1.8 KB

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