~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/drivers/slip_common.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/um/drivers/slip_common.h (Architecture ppc) and /arch/alpha/drivers/slip_common.h (Architecture alpha)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #ifndef __UM_SLIP_COMMON_H                        
  3 #define __UM_SLIP_COMMON_H                        
  4                                                   
  5 #define BUF_SIZE 1500                             
  6  /* two bytes each for a (pathological) max pa    
  7   * terminating END char + initial END char       
  8 #define ENC_BUF_SIZE (2 * BUF_SIZE + 2)           
  9                                                   
 10 /* SLIP protocol characters. */                   
 11 #define SLIP_END             0300       /* ind    
 12 #define SLIP_ESC             0333       /* ind    
 13 #define SLIP_ESC_END         0334       /* ESC    
 14 #define SLIP_ESC_ESC         0335       /* ESC    
 15                                                   
 16 static inline int slip_unesc(unsigned char c,     
 17                              int *esc)            
 18 {                                                 
 19         int ret;                                  
 20                                                   
 21         switch(c){                                
 22         case SLIP_END:                            
 23                 *esc = 0;                         
 24                 ret=*pos;                         
 25                 *pos=0;                           
 26                 return(ret);                      
 27         case SLIP_ESC:                            
 28                 *esc = 1;                         
 29                 return(0);                        
 30         case SLIP_ESC_ESC:                        
 31                 if(*esc){                         
 32                         *esc = 0;                 
 33                         c = SLIP_ESC;             
 34                 }                                 
 35                 break;                            
 36         case SLIP_ESC_END:                        
 37                 if(*esc){                         
 38                         *esc = 0;                 
 39                         c = SLIP_END;             
 40                 }                                 
 41                 break;                            
 42         }                                         
 43         buf[(*pos)++] = c;                        
 44         return(0);                                
 45 }                                                 
 46                                                   
 47 static inline int slip_esc(unsigned char *s, u    
 48 {                                                 
 49         unsigned char *ptr = d;                   
 50         unsigned char c;                          
 51                                                   
 52         /*                                        
 53          * Send an initial END character to fl    
 54          * data that may have accumulated in t    
 55          * due to line noise.                     
 56          */                                       
 57                                                   
 58         *ptr++ = SLIP_END;                        
 59                                                   
 60         /*                                        
 61          * For each byte in the packet, send t    
 62          * character sequence, according to th    
 63          */                                       
 64                                                   
 65         while (len-- > 0) {                       
 66                 switch(c = *s++) {                
 67                 case SLIP_END:                    
 68                         *ptr++ = SLIP_ESC;        
 69                         *ptr++ = SLIP_ESC_END;    
 70                         break;                    
 71                 case SLIP_ESC:                    
 72                         *ptr++ = SLIP_ESC;        
 73                         *ptr++ = SLIP_ESC_ESC;    
 74                         break;                    
 75                 default:                          
 76                         *ptr++ = c;               
 77                         break;                    
 78                 }                                 
 79         }                                         
 80         *ptr++ = SLIP_END;                        
 81         return (ptr - d);                         
 82 }                                                 
 83                                                   
 84 struct slip_proto {                               
 85         unsigned char ibuf[ENC_BUF_SIZE];         
 86         unsigned char obuf[ENC_BUF_SIZE];         
 87         int more; /* more data: do not read fd    
 88         int pos;                                  
 89         int esc;                                  
 90 };                                                
 91                                                   
 92 static inline void slip_proto_init(struct slip    
 93 {                                                 
 94         memset(slip->ibuf, 0, sizeof(slip->ibu    
 95         memset(slip->obuf, 0, sizeof(slip->obu    
 96         slip->more = 0;                           
 97         slip->pos = 0;                            
 98         slip->esc = 0;                            
 99 }                                                 
100                                                   
101 extern int slip_proto_read(int fd, void *buf,     
102                            struct slip_proto *    
103 extern int slip_proto_write(int fd, void *buf,    
104                             struct slip_proto     
105                                                   
106 #endif                                            
107                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php