| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include <linux/types.h>
 | 
					
						
							|  |  |  | #include <linux/netdevice.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "lmc_debug.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Prints out len, max to 80 octets using printk, 20 per line | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | #ifdef LMC_PACKET_LOG
 | 
					
						
							| 
									
										
										
										
											2005-09-09 23:17:28 -07:00
										 |  |  | void lmcConsoleLog(char *type, unsigned char *ucData, int iLen) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |   int iNewLine = 1; | 
					
						
							|  |  |  |   char str[80], *pstr; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   sprintf(str, KERN_DEBUG "lmc: %s: ", type); | 
					
						
							|  |  |  |   pstr = str+strlen(str); | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   if(iLen > 240){ | 
					
						
							|  |  |  |       printk(KERN_DEBUG "lmc: Printing 240 chars... out of: %d\n", iLen); | 
					
						
							|  |  |  |     iLen = 240; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else{ | 
					
						
							|  |  |  |       printk(KERN_DEBUG "lmc: Printing %d chars\n", iLen); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   while(iLen > 0)  | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       sprintf(pstr, "%02x ", *ucData); | 
					
						
							|  |  |  |       pstr+=3; | 
					
						
							|  |  |  |       ucData++; | 
					
						
							|  |  |  |       if( !(iNewLine % 20)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	  sprintf(pstr, "\n"); | 
					
						
							|  |  |  | 	  printk(str); | 
					
						
							|  |  |  | 	  sprintf(str, KERN_DEBUG "lmc: %s: ", type); | 
					
						
							|  |  |  | 	  pstr=str+strlen(str); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |       iNewLine++; | 
					
						
							|  |  |  |       iLen--; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   sprintf(pstr, "\n"); | 
					
						
							|  |  |  |   printk(str); | 
					
						
							| 
									
										
										
										
											2005-09-09 23:17:28 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							| 
									
										
										
										
											2008-07-03 00:39:46 +02:00
										 |  |  | u32 lmcEventLogIndex; | 
					
						
							|  |  |  | u32 lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS]; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-03 00:39:46 +02:00
										 |  |  | void lmcEventLog(u32 EventNum, u32 arg2, u32 arg3) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							|  |  |  |   lmcEventLogBuf[lmcEventLogIndex++] = EventNum; | 
					
						
							|  |  |  |   lmcEventLogBuf[lmcEventLogIndex++] = arg2; | 
					
						
							|  |  |  |   lmcEventLogBuf[lmcEventLogIndex++] = arg3; | 
					
						
							|  |  |  |   lmcEventLogBuf[lmcEventLogIndex++] = jiffies; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-09-09 23:17:28 -07:00
										 |  |  | #endif  /*  DEBUG  */
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | void lmc_trace(struct net_device *dev, char *msg){ | 
					
						
							|  |  |  | #ifdef LMC_TRACE
 | 
					
						
							|  |  |  |     unsigned long j = jiffies + 3; /* Wait for 50 ms */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(in_interrupt()){ | 
					
						
							|  |  |  |         printk("%s: * %s\n", dev->name, msg); | 
					
						
							|  |  |  | //        while(time_before(jiffies, j+10))
 | 
					
						
							|  |  |  | //            ;
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         printk("%s: %s\n", dev->name, msg); | 
					
						
							|  |  |  |         while(time_before(jiffies, j)) | 
					
						
							|  |  |  |             schedule(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* --------------------------- end if_lmc_linux.c ------------------------ */ |