Blame view

include/linux/n_r3964.h 4.06 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
  /* r3964 linediscipline for linux
   *
   * -----------------------------------------------------------
   * Copyright by
   * Philips Automation Projects
   * Kassel (Germany)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
   * -----------------------------------------------------------
   * This software may be used and distributed according to the terms of
   * the GNU General Public License, incorporated herein by reference.
   *
   * Author:
   * L. Haag
   *
   * $Log: r3964.h,v $
01e33b5a2   Kurt Huwig   [PATCH] n_r3964: ...
15
16
17
18
   * Revision 1.4  2005/12/21 19:54:24  Kurt Huwig <kurt huwig de>
   * Fixed HZ usage on 2.6 kernels
   * Removed unnecessary include
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
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
   * Revision 1.3  2001/03/18 13:02:24  dwmw2
   * Fix timer usage, use spinlocks properly.
   *
   * Revision 1.2  2001/03/18 12:53:15  dwmw2
   * Merge changes in 2.4.2
   *
   * Revision 1.1.1.1  1998/10/13 16:43:14  dwmw2
   * This'll screw the version control
   *
   * Revision 1.6  1998/09/30 00:40:38  dwmw2
   * Updated to use kernel's N_R3964 if available
   *
   * Revision 1.4  1998/04/02 20:29:44  lhaag
   * select, blocking, ...
   *
   * Revision 1.3  1998/02/12 18:58:43  root
   * fixed some memory leaks
   * calculation of checksum characters
   *
   * Revision 1.2  1998/02/07 13:03:17  root
   * ioctl read_telegram
   *
   * Revision 1.1  1998/02/06 19:19:43  root
   * Initial revision
   *
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
  #ifndef __LINUX_N_R3964_H__
  #define __LINUX_N_R3964_H__
01e33b5a2   Kurt Huwig   [PATCH] n_r3964: ...
48
49
  
  #include <linux/param.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
50
  #include <uapi/linux/n_r3964.h>
01e33b5a2   Kurt Huwig   [PATCH] n_r3964: ...
51

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
54
55
56
57
58
59
60
61
  /*
   * Common ascii handshake characters:
   */
  
  #define STX 0x02
  #define ETX 0x03
  #define DLE 0x10
  #define NAK 0x15
  
  /*
01e33b5a2   Kurt Huwig   [PATCH] n_r3964: ...
62
   * Timeouts (from milliseconds to jiffies)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
   */
01e33b5a2   Kurt Huwig   [PATCH] n_r3964: ...
64
65
66
67
68
  #define R3964_TO_QVZ ((550)*HZ/1000)
  #define R3964_TO_ZVZ ((220)*HZ/1000)
  #define R3964_TO_NO_BUF ((400)*HZ/1000)
  #define R3964_NO_TX_ROOM ((100)*HZ/1000)
  #define R3964_TO_RX_PANIC ((4000)*HZ/1000)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
  #define R3964_MAX_RETRIES 5
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  
  enum { R3964_IDLE, 
  	   R3964_TX_REQUEST, R3964_TRANSMITTING, 
  	   R3964_WAIT_ZVZ_BEFORE_TX_RETRY, R3964_WAIT_FOR_TX_ACK,
  	   R3964_WAIT_FOR_RX_BUF,
  	   R3964_RECEIVING, R3964_WAIT_FOR_BCC, R3964_WAIT_FOR_RX_REPEAT
  	   };
  
  /*
   * All open file-handles are 'clients' and are stored in a linked list:
   */
  
  struct r3964_message;
  
  struct r3964_client_info {
  	spinlock_t     lock;
3cec556a8   Eric W. Biederman   [PATCH] n_r3964: ...
86
  	struct pid    *pid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87
88
89
90
91
92
93
94
95
  	unsigned int   sig_flags;
  
  	struct r3964_client_info *next;
  
  	struct r3964_message *first_msg;
  	struct r3964_message *last_msg;
  	struct r3964_block_header *next_block_to_read;
  	int            msg_count;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  
  struct r3964_block_header;
  
  /* internal version of client_message: */
  struct r3964_message {
  	  int     msg_id;
  	  int     arg;
  	  int     error_code;
  	  struct r3964_block_header *block;
  	  struct r3964_message *next;
  };
  
  /*
   * Header of received block in rx_buf/tx_buf:
   */
  
  struct r3964_block_header 
  {
  	unsigned int length;             /* length in chars without header */
  	unsigned char *data;             /* usually data is located 
                                          immediately behind this struct */
  	unsigned int locks;              /* only used in rx_buffer */
  	  
      struct r3964_block_header *next;
  	struct r3964_client_info *owner;  /* =NULL in rx_buffer */
  };
  
  /*
   * If rx_buf hasn't enough space to store R3964_MTU chars,
   * we will reject all incoming STX-requests by sending NAK.
   */
  
  #define RX_BUF_SIZE    4000
  #define TX_BUF_SIZE    4000
  #define R3964_MAX_BLOCKS_IN_RX_QUEUE 100
  
  #define R3964_PARITY 0x0001
  #define R3964_FRAME  0x0002
  #define R3964_OVERRUN 0x0004
  #define R3964_UNKNOWN 0x0008
  #define R3964_BREAK   0x0010
  #define R3964_CHECKSUM 0x0020
  #define R3964_ERROR  0x003f
  #define R3964_BCC   0x4000
  #define R3964_DEBUG 0x8000
  
  
  struct r3964_info {
  	spinlock_t     lock;
  	struct tty_struct *tty;
  	unsigned char priority;
  	unsigned char *rx_buf;            /* ring buffer */
  	unsigned char *tx_buf;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
151
152
153
154
155
156
157
  	struct r3964_block_header *rx_first;
  	struct r3964_block_header *rx_last;
  	struct r3964_block_header *tx_first;
  	struct r3964_block_header *tx_last;
  	unsigned int tx_position;
          unsigned int rx_position;
  	unsigned char last_rx;
  	unsigned char bcc;
          unsigned int  blocks_in_rx_queue;
aba24888d   Peter Hurley   tty: r3964: Repla...
158
159
  
  	struct mutex read_lock;		/* serialize r3964_read */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
161
162
163
164
165
166
  	struct r3964_client_info *firstClient;
  	unsigned int state;
  	unsigned int flags;
  
  	struct timer_list tmr;
  	int nRetry;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
167
  #endif