aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/pcbit/layer2.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/pcbit/layer2.h')
-rw-r--r--drivers/isdn/pcbit/layer2.h265
1 files changed, 129 insertions, 136 deletions
diff --git a/drivers/isdn/pcbit/layer2.h b/drivers/isdn/pcbit/layer2.h
index 2ac295e1a6e5..be1327bc162a 100644
--- a/drivers/isdn/pcbit/layer2.h
+++ b/drivers/isdn/pcbit/layer2.h
@@ -2,17 +2,17 @@
2 * PCBIT-D low-layer interface definitions 2 * PCBIT-D low-layer interface definitions
3 * 3 *
4 * Copyright (C) 1996 Universidade de Lisboa 4 * Copyright (C) 1996 Universidade de Lisboa
5 * 5 *
6 * Written by Pedro Roque Marques (roque@di.fc.ul.pt) 6 * Written by Pedro Roque Marques (roque@di.fc.ul.pt)
7 * 7 *
8 * This software may be used and distributed according to the terms of 8 * This software may be used and distributed according to the terms of
9 * the GNU General Public License, incorporated herein by reference. 9 * the GNU General Public License, incorporated herein by reference.
10 */ 10 */
11 11
12/* 12/*
13 * 19991203 - Fernando Carvalho - takion@superbofh.org 13 * 19991203 - Fernando Carvalho - takion@superbofh.org
14 * Hacked to compile with egcs and run with current version of isdn modules 14 * Hacked to compile with egcs and run with current version of isdn modules
15*/ 15 */
16 16
17#ifndef LAYER2_H 17#ifndef LAYER2_H
18#define LAYER2_H 18#define LAYER2_H
@@ -37,8 +37,8 @@
37 37
38/* TAM - XX - C - S - NUM */ 38/* TAM - XX - C - S - NUM */
39#define PREHDR_LEN 8 39#define PREHDR_LEN 8
40/* TT - M - I - TH - TD */ 40/* TT - M - I - TH - TD */
41#define FRAME_HDR_LEN 8 41#define FRAME_HDR_LEN 8
42 42
43#define MSG_CONN_REQ 0x08000100 43#define MSG_CONN_REQ 0x08000100
44#define MSG_CONN_CONF 0x00000101 44#define MSG_CONN_CONF 0x00000101
@@ -84,21 +84,21 @@
84#define MSG_DEBUG_188 0x0000ff00 84#define MSG_DEBUG_188 0x0000ff00
85 85
86/* 86/*
87 87
88 long 4 3 2 1 88 long 4 3 2 1
89 Intel 1 2 3 4 89 Intel 1 2 3 4
90*/ 90*/
91 91
92#ifdef __LITTLE_ENDIAN 92#ifdef __LITTLE_ENDIAN
93#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff))) 93#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff)))
94#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8)) 94#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8))
95#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16)) 95#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16))
96#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24)) 96#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24))
97 97
98#define GET_MSG_SCMD(msg) ((msg) & 0xFF) 98#define GET_MSG_SCMD(msg) ((msg) & 0xFF)
99#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF) 99#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF)
100#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF) 100#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF)
101#define GET_MSG_CPU(msg) ((msg) >> 24) 101#define GET_MSG_CPU(msg) ((msg) >> 24)
102 102
103#else 103#else
104#error "Non-Intel CPU" 104#error "Non-Intel CPU"
@@ -109,60 +109,60 @@
109#define SCHED_READ 0x01 109#define SCHED_READ 0x01
110#define SCHED_WRITE 0x02 110#define SCHED_WRITE 0x02
111 111
112#define SET_RUN_TIMEOUT 2*HZ /* 2 seconds */ 112#define SET_RUN_TIMEOUT 2 * HZ /* 2 seconds */
113 113
114struct frame_buf { 114struct frame_buf {
115 ulong msg; 115 ulong msg;
116 unsigned int refnum; 116 unsigned int refnum;
117 unsigned int dt_len; 117 unsigned int dt_len;
118 unsigned int hdr_len; 118 unsigned int hdr_len;
119 struct sk_buff *skb; 119 struct sk_buff *skb;
120 unsigned int copied; 120 unsigned int copied;
121 struct frame_buf * next; 121 struct frame_buf *next;
122}; 122};
123 123
124extern int pcbit_l2_write(struct pcbit_dev * dev, ulong msg, ushort refnum, 124extern int pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum,
125 struct sk_buff *skb, unsigned short hdr_len); 125 struct sk_buff *skb, unsigned short hdr_len);
126 126
127extern irqreturn_t pcbit_irq_handler(int interrupt, void *); 127extern irqreturn_t pcbit_irq_handler(int interrupt, void *);
128 128
129extern struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; 129extern struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS];
130 130
131#ifdef DEBUG 131#ifdef DEBUG
132static __inline__ void log_state(struct pcbit_dev *dev) { 132static __inline__ void log_state(struct pcbit_dev *dev) {
133 printk(KERN_DEBUG "writeptr = %ld\n", 133 printk(KERN_DEBUG "writeptr = %ld\n",
134 (ulong) (dev->writeptr - dev->sh_mem)); 134 (ulong) (dev->writeptr - dev->sh_mem));
135 printk(KERN_DEBUG "readptr = %ld\n", 135 printk(KERN_DEBUG "readptr = %ld\n",
136 (ulong) (dev->readptr - (dev->sh_mem + BANK2))); 136 (ulong) (dev->readptr - (dev->sh_mem + BANK2)));
137 printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n", 137 printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n",
138 dev->rcv_seq, dev->send_seq, dev->unack_seq); 138 dev->rcv_seq, dev->send_seq, dev->unack_seq);
139} 139}
140#endif 140#endif
141 141
142static __inline__ struct pcbit_dev * chan2dev(struct pcbit_chan * chan) 142static __inline__ struct pcbit_dev *chan2dev(struct pcbit_chan *chan)
143{ 143{
144 struct pcbit_dev * dev; 144 struct pcbit_dev *dev;
145 int i; 145 int i;
146 146
147 147
148 for (i=0; i<MAX_PCBIT_CARDS; i++) 148 for (i = 0; i < MAX_PCBIT_CARDS; i++)
149 if ((dev=dev_pcbit[i])) 149 if ((dev = dev_pcbit[i]))
150 if (dev->b1 == chan || dev->b2 == chan) 150 if (dev->b1 == chan || dev->b2 == chan)
151 return dev; 151 return dev;
152 return NULL; 152 return NULL;
153 153
154} 154}
155 155
156static __inline__ struct pcbit_dev * finddev(int id) 156static __inline__ struct pcbit_dev *finddev(int id)
157{ 157{
158 struct pcbit_dev * dev; 158 struct pcbit_dev *dev;
159 int i; 159 int i;
160 160
161 for (i=0; i<MAX_PCBIT_CARDS; i++) 161 for (i = 0; i < MAX_PCBIT_CARDS; i++)
162 if ((dev=dev_pcbit[i])) 162 if ((dev = dev_pcbit[i]))
163 if (dev->id == id) 163 if (dev->id == id)
164 return dev; 164 return dev;
165 return NULL; 165 return NULL;
166} 166}
167 167
168 168
@@ -172,117 +172,110 @@ static __inline__ struct pcbit_dev * finddev(int id)
172 172
173static __inline__ void pcbit_writeb(struct pcbit_dev *dev, unsigned char dt) 173static __inline__ void pcbit_writeb(struct pcbit_dev *dev, unsigned char dt)
174{ 174{
175 writeb(dt, dev->writeptr++); 175 writeb(dt, dev->writeptr++);
176 if (dev->writeptr == dev->sh_mem + BANKLEN) 176 if (dev->writeptr == dev->sh_mem + BANKLEN)
177 dev->writeptr = dev->sh_mem; 177 dev->writeptr = dev->sh_mem;
178} 178}
179 179
180static __inline__ void pcbit_writew(struct pcbit_dev *dev, unsigned short dt) 180static __inline__ void pcbit_writew(struct pcbit_dev *dev, unsigned short dt)
181{ 181{
182 int dist; 182 int dist;
183 183
184 dist = BANKLEN - (dev->writeptr - dev->sh_mem); 184 dist = BANKLEN - (dev->writeptr - dev->sh_mem);
185 switch (dist) { 185 switch (dist) {
186 case 2: 186 case 2:
187 writew(dt, dev->writeptr); 187 writew(dt, dev->writeptr);
188 dev->writeptr = dev->sh_mem; 188 dev->writeptr = dev->sh_mem;
189 break; 189 break;
190 case 1: 190 case 1:
191 writeb((u_char) (dt & 0x00ffU), dev->writeptr); 191 writeb((u_char) (dt & 0x00ffU), dev->writeptr);
192 dev->writeptr = dev->sh_mem; 192 dev->writeptr = dev->sh_mem;
193 writeb((u_char) (dt >> 8), dev->writeptr++); 193 writeb((u_char) (dt >> 8), dev->writeptr++);
194 break; 194 break;
195 default: 195 default:
196 writew(dt, dev->writeptr); 196 writew(dt, dev->writeptr);
197 dev->writeptr += 2; 197 dev->writeptr += 2;
198 break; 198 break;
199 }; 199 };
200} 200}
201 201
202static __inline__ void memcpy_topcbit(struct pcbit_dev * dev, u_char * data, 202static __inline__ void memcpy_topcbit(struct pcbit_dev *dev, u_char *data,
203 int len) 203 int len)
204{ 204{
205 int diff; 205 int diff;
206 206
207 diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem) ); 207 diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem));
208 208
209 if (diff > 0) 209 if (diff > 0)
210 { 210 {
211 memcpy_toio(dev->writeptr, data, len - diff); 211 memcpy_toio(dev->writeptr, data, len - diff);
212 memcpy_toio(dev->sh_mem, data + (len - diff), diff); 212 memcpy_toio(dev->sh_mem, data + (len - diff), diff);
213 dev->writeptr = dev->sh_mem + diff; 213 dev->writeptr = dev->sh_mem + diff;
214 } 214 }
215 else 215 else
216 { 216 {
217 memcpy_toio(dev->writeptr, data, len); 217 memcpy_toio(dev->writeptr, data, len);
218 218
219 dev->writeptr += len; 219 dev->writeptr += len;
220 if (diff == 0) 220 if (diff == 0)
221 dev->writeptr = dev->sh_mem; 221 dev->writeptr = dev->sh_mem;
222 } 222 }
223} 223}
224 224
225static __inline__ unsigned char pcbit_readb(struct pcbit_dev *dev) 225static __inline__ unsigned char pcbit_readb(struct pcbit_dev *dev)
226{ 226{
227 unsigned char val; 227 unsigned char val;
228 228
229 val = readb(dev->readptr++); 229 val = readb(dev->readptr++);
230 if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN) 230 if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN)
231 dev->readptr = dev->sh_mem + BANK2; 231 dev->readptr = dev->sh_mem + BANK2;
232 232
233 return val; 233 return val;
234} 234}
235 235
236static __inline__ unsigned short pcbit_readw(struct pcbit_dev *dev) 236static __inline__ unsigned short pcbit_readw(struct pcbit_dev *dev)
237{ 237{
238 int dist; 238 int dist;
239 unsigned short val; 239 unsigned short val;
240 240
241 dist = BANKLEN - ( dev->readptr - (dev->sh_mem + BANK2 ) ); 241 dist = BANKLEN - (dev->readptr - (dev->sh_mem + BANK2));
242 switch (dist) { 242 switch (dist) {
243 case 2: 243 case 2:
244 val = readw(dev->readptr); 244 val = readw(dev->readptr);
245 dev->readptr = dev->sh_mem + BANK2; 245 dev->readptr = dev->sh_mem + BANK2;
246 break; 246 break;
247 case 1: 247 case 1:
248 val = readb(dev->readptr); 248 val = readb(dev->readptr);
249 dev->readptr = dev->sh_mem + BANK2; 249 dev->readptr = dev->sh_mem + BANK2;
250 val = (readb(dev->readptr++) << 8) | val; 250 val = (readb(dev->readptr++) << 8) | val;
251 break; 251 break;
252 default: 252 default:
253 val = readw(dev->readptr); 253 val = readw(dev->readptr);
254 dev->readptr += 2; 254 dev->readptr += 2;
255 break; 255 break;
256 }; 256 };
257 return val; 257 return val;
258} 258}
259 259
260static __inline__ void memcpy_frompcbit(struct pcbit_dev * dev, u_char * data, int len) 260static __inline__ void memcpy_frompcbit(struct pcbit_dev *dev, u_char *data, int len)
261{ 261{
262 int diff; 262 int diff;
263 263
264 diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2) ) ); 264 diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2)));
265 if (diff > 0) 265 if (diff > 0)
266 { 266 {
267 memcpy_fromio(data, dev->readptr, len - diff); 267 memcpy_fromio(data, dev->readptr, len - diff);
268 memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff); 268 memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff);
269 dev->readptr = dev->sh_mem + BANK2 + diff; 269 dev->readptr = dev->sh_mem + BANK2 + diff;
270 } 270 }
271 else 271 else
272 { 272 {
273 memcpy_fromio(data, dev->readptr, len); 273 memcpy_fromio(data, dev->readptr, len);
274 dev->readptr += len; 274 dev->readptr += len;
275 if (diff == 0) 275 if (diff == 0)
276 dev->readptr = dev->sh_mem + BANK2; 276 dev->readptr = dev->sh_mem + BANK2;
277 } 277 }
278} 278}
279 279
280 280
281#endif 281#endif
282
283
284
285
286
287
288