lmc_debug.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
  9. {
  10. #ifdef DEBUG
  11. #ifdef LMC_PACKET_LOG
  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. #endif
  41. #endif
  42. }
  43. #ifdef DEBUG
  44. u_int32_t lmcEventLogIndex = 0;
  45. u_int32_t lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS];
  46. #endif
  47. void lmcEventLog (u_int32_t EventNum, u_int32_t arg2, u_int32_t arg3)
  48. {
  49. #ifdef DEBUG
  50. lmcEventLogBuf[lmcEventLogIndex++] = EventNum;
  51. lmcEventLogBuf[lmcEventLogIndex++] = arg2;
  52. lmcEventLogBuf[lmcEventLogIndex++] = arg3;
  53. lmcEventLogBuf[lmcEventLogIndex++] = jiffies;
  54. lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1;
  55. #endif
  56. }
  57. void lmc_trace(struct net_device *dev, char *msg){
  58. #ifdef LMC_TRACE
  59. unsigned long j = jiffies + 3; /* Wait for 50 ms */
  60. if(in_interrupt()){
  61. printk("%s: * %s\n", dev->name, msg);
  62. // while(time_before(jiffies, j+10))
  63. // ;
  64. }
  65. else {
  66. printk("%s: %s\n", dev->name, msg);
  67. while(time_before(jiffies, j))
  68. schedule();
  69. }
  70. #endif
  71. }
  72. /* --------------------------- end if_lmc_linux.c ------------------------ */