1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 
  31 
  32 
  33 
  34 
  35 
  36 
  37 
  38 
  39 
  40 
  41 
  42 
  43 
  44 
  45 
  46 #ifndef __LINUX_N_R3964_H__
  47 #define __LINUX_N_R3964_H__
  48 
  49 
  50 #include <linux/param.h>
  51 #include <uapi/linux/n_r3964.h>
  52 
  53 
  54 
  55 
  56 
  57 #define STX 0x02
  58 #define ETX 0x03
  59 #define DLE 0x10
  60 #define NAK 0x15
  61 
  62 
  63 
  64 
  65 
  66 #define R3964_TO_QVZ ((550)*HZ/1000)
  67 #define R3964_TO_ZVZ ((220)*HZ/1000)
  68 #define R3964_TO_NO_BUF ((400)*HZ/1000)
  69 #define R3964_NO_TX_ROOM ((100)*HZ/1000)
  70 #define R3964_TO_RX_PANIC ((4000)*HZ/1000)
  71 #define R3964_MAX_RETRIES 5
  72 
  73 
  74 enum { R3964_IDLE, 
  75            R3964_TX_REQUEST, R3964_TRANSMITTING, 
  76            R3964_WAIT_ZVZ_BEFORE_TX_RETRY, R3964_WAIT_FOR_TX_ACK,
  77            R3964_WAIT_FOR_RX_BUF,
  78            R3964_RECEIVING, R3964_WAIT_FOR_BCC, R3964_WAIT_FOR_RX_REPEAT
  79            };
  80 
  81 
  82 
  83 
  84 
  85 struct r3964_message;
  86 
  87 struct r3964_client_info {
  88         spinlock_t     lock;
  89         struct pid    *pid;
  90         unsigned int   sig_flags;
  91 
  92         struct r3964_client_info *next;
  93 
  94         struct r3964_message *first_msg;
  95         struct r3964_message *last_msg;
  96         struct r3964_block_header *next_block_to_read;
  97         int            msg_count;
  98 };
  99 
 100 
 101 
 102 struct r3964_block_header;
 103 
 104 
 105 struct r3964_message {
 106           int     msg_id;
 107           int     arg;
 108           int     error_code;
 109           struct r3964_block_header *block;
 110           struct r3964_message *next;
 111 };
 112 
 113 
 114 
 115 
 116 
 117 struct r3964_block_header 
 118 {
 119         unsigned int length;             
 120         unsigned char *data;             
 121 
 122         unsigned int locks;              
 123           
 124     struct r3964_block_header *next;
 125         struct r3964_client_info *owner;  
 126 };
 127 
 128 
 129 
 130 
 131 
 132 
 133 #define RX_BUF_SIZE    4000
 134 #define TX_BUF_SIZE    4000
 135 #define R3964_MAX_BLOCKS_IN_RX_QUEUE 100
 136 
 137 #define R3964_PARITY 0x0001
 138 #define R3964_FRAME  0x0002
 139 #define R3964_OVERRUN 0x0004
 140 #define R3964_UNKNOWN 0x0008
 141 #define R3964_BREAK   0x0010
 142 #define R3964_CHECKSUM 0x0020
 143 #define R3964_ERROR  0x003f
 144 #define R3964_BCC   0x4000
 145 #define R3964_DEBUG 0x8000
 146 
 147 
 148 struct r3964_info {
 149         spinlock_t     lock;
 150         struct tty_struct *tty;
 151         unsigned char priority;
 152         unsigned char *rx_buf;            
 153         unsigned char *tx_buf;
 154 
 155         struct r3964_block_header *rx_first;
 156         struct r3964_block_header *rx_last;
 157         struct r3964_block_header *tx_first;
 158         struct r3964_block_header *tx_last;
 159         unsigned int tx_position;
 160         unsigned int rx_position;
 161         unsigned char last_rx;
 162         unsigned char bcc;
 163         unsigned int  blocks_in_rx_queue;
 164 
 165         struct mutex read_lock;         
 166 
 167         struct r3964_client_info *firstClient;
 168         unsigned int state;
 169         unsigned int flags;
 170 
 171         struct timer_list tmr;
 172         int nRetry;
 173 };
 174 
 175 #endif