1
/* $Id: eicon.h,v 1.1 2002/07/19 18:42:02 armin Exp $
3
* ISDN low-level module for Eicon active ISDN-Cards.
5
* Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de)
6
* Copyright 1998-2000 by Armin Schindler (mac@melware.de)
7
* Copyright 1999,2000 Cytronics & Melware (info@melware.de)
9
* This software may be used and distributed according to the terms
10
* of the GNU General Public License, incorporated herein by reference.
17
#define EICON_IOCTL_SETMMIO 0
18
#define EICON_IOCTL_GETMMIO 1
19
#define EICON_IOCTL_SETIRQ 2
20
#define EICON_IOCTL_GETIRQ 3
21
#define EICON_IOCTL_LOADBOOT 4
22
#define EICON_IOCTL_ADDCARD 5
23
#define EICON_IOCTL_GETTYPE 6
24
#define EICON_IOCTL_LOADPCI 7
25
#define EICON_IOCTL_LOADISA 8
26
#define EICON_IOCTL_GETVER 9
27
#define EICON_IOCTL_GETXLOG 10
29
#define EICON_IOCTL_MANIF 90
31
#define EICON_IOCTL_FREEIT 97
32
#define EICON_IOCTL_TEST 98
33
#define EICON_IOCTL_DEBUGVAR 99
35
#define EICON_IOCTL_DIA_OFFSET 100
38
#define EICON_BUS_ISA 1
39
#define EICON_BUS_MCA 2
40
#define EICON_BUS_PCI 3
42
/* Constants for describing Card-Type */
43
#define EICON_CTYPE_S 0
44
#define EICON_CTYPE_SX 1
45
#define EICON_CTYPE_SCOM 2
46
#define EICON_CTYPE_QUADRO 3
47
#define EICON_CTYPE_S2M 4
48
#define EICON_CTYPE_MAESTRA 5
49
#define EICON_CTYPE_MAESTRAQ 6
50
#define EICON_CTYPE_MAESTRAQ_U 7
51
#define EICON_CTYPE_MAESTRAP 8
52
#define EICON_CTYPE_ISABRI 0x10
53
#define EICON_CTYPE_ISAPRI 0x20
54
#define EICON_CTYPE_MASK 0x0f
55
#define EICON_CTYPE_QUADRO_NR(n) (n<<4)
57
#define MAX_HEADER_LEN 10
59
#define MAX_STATUS_BUFFER 150
61
/* Struct for adding new cards */
62
typedef struct eicon_cdef {
68
#define EICON_ISA_BOOT_MEMCHK 1
69
#define EICON_ISA_BOOT_NORMAL 2
71
/* Struct for downloading protocol via ioctl for ISA cards */
72
/* same struct for downloading protocol via ioctl for MCA cards */
74
/* start-up parameters */
78
unsigned char WatchDog;
79
unsigned char Permanent;
80
unsigned char XInterface;
81
unsigned char StableL2;
82
unsigned char NoOrderCheck;
83
unsigned char HandsetType;
85
unsigned char LowChannel;
86
unsigned char ProtVersion;
88
unsigned char Loopback;
89
unsigned char oad[32];
90
unsigned char osa[32];
91
unsigned char spid[32];
92
unsigned char boot_opt;
93
unsigned long bootstrap_len;
94
unsigned long firmware_len;
95
unsigned char code[1]; /* Rest (bootstrap- and firmware code) will be allocated */
98
/* Data for downloading protocol via ioctl */
100
eicon_isa_codebuf isa;
101
eicon_isa_codebuf mca;
104
/* Data for Management interface */
109
unsigned char data[700];
116
/* Kernel includes */
117
#include <linux/config.h>
118
#include <linux/sched.h>
119
#include <linux/string.h>
120
#include <linux/tqueue.h>
121
#include <linux/interrupt.h>
122
#include <linux/skbuff.h>
123
#include <linux/errno.h>
124
#include <linux/fs.h>
125
#include <linux/major.h>
126
#include <asm/segment.h>
128
#include <linux/kernel.h>
129
#include <linux/signal.h>
130
#include <linux/slab.h>
131
#include <linux/mm.h>
132
#include <linux/mman.h>
133
#include <linux/ioport.h>
134
#include <linux/timer.h>
135
#include <linux/wait.h>
136
#include <linux/delay.h>
137
#include <linux/ctype.h>
138
#include <linux/pci.h>
140
#include <linux/isdn.h>
141
#include <linux/isdnif.h>
145
__u16 length __attribute__ ((packed)); /* length of data/parameter field */
146
__u8 P[1]; /* data/parameter field */
149
#include "eicon_isa.h"
154
__u16 NextReq __attribute__ ((packed)); /* pointer to next Req Buffer */
155
__u16 NextRc __attribute__ ((packed)); /* pointer to next Rc Buffer */
156
__u16 NextInd __attribute__ ((packed)); /* pointer to next Ind Buffer */
157
__u8 ReqInput __attribute__ ((packed)); /* number of Req Buffers sent */
158
__u8 ReqOutput __attribute__ ((packed)); /* number of Req Buffers returned */
159
__u8 ReqReserved __attribute__ ((packed));/*number of Req Buffers reserved */
160
__u8 Int __attribute__ ((packed)); /* ISDN-P interrupt */
161
__u8 XLock __attribute__ ((packed)); /* Lock field for arbitration */
162
__u8 RcOutput __attribute__ ((packed)); /* number of Rc buffers received */
163
__u8 IndOutput __attribute__ ((packed)); /* number of Ind buffers received */
164
__u8 IMask __attribute__ ((packed)); /* Interrupt Mask Flag */
165
__u8 Reserved1[2] __attribute__ ((packed)); /* reserved field, do not use */
166
__u8 ReadyInt __attribute__ ((packed)); /* request field for ready int */
167
__u8 Reserved2[12] __attribute__ ((packed)); /* reserved field, do not use */
168
__u8 InterfaceType __attribute__ ((packed)); /* interface type 1=16K */
169
__u16 Signature __attribute__ ((packed)); /* ISDN-P initialized ind */
170
__u8 B[1]; /* buffer space for Req,Ind and Rc */
173
/* Macro for delay via schedule() */
175
set_current_state(TASK_UNINTERRUPTIBLE); \
176
schedule_timeout(j); \
180
__u8 Req; /* pending request */
181
__u8 Rc; /* return code received */
182
__u8 Ind; /* indication received */
183
__u8 ReqCh; /* channel of current Req */
184
__u8 RcCh; /* channel of current Rc */
185
__u8 IndCh; /* channel of current Ind */
186
__u8 D3Id; /* ID used by this entity */
187
__u8 B2Id; /* ID used by this entity */
188
__u8 GlobalId; /* reserved field */
189
__u8 XNum; /* number of X-buffers */
190
__u8 RNum; /* number of R-buffers */
191
struct sk_buff_head X; /* X-buffer queue */
192
struct sk_buff_head R; /* R-buffer queue */
193
__u8 RNR; /* receive not ready flag */
194
__u8 complete; /* receive complete status */
195
__u8 busy; /* busy flag */
196
__u16 ref; /* saved reference */
199
#define FAX_MAX_SCANLINE 256
204
__u8 abLine[FAX_MAX_SCANLINE];
205
__u8 abFrame[FAX_MAX_SCANLINE];
206
unsigned int LineLen;
207
unsigned int LineDataLen;
209
unsigned int NullBytesPos;
217
int No; /* Channel Number */
218
unsigned short fsm_state; /* Current D-Channel state */
219
unsigned short statectrl; /* State controling bits */
220
unsigned short eazmask; /* EAZ-Mask for this Channel */
221
int queued; /* User-Data Bytes in TX queue */
222
int pqueued; /* User-Data Packets in TX queue */
223
int waitq; /* User-Data Bytes in wait queue */
224
int waitpq; /* User-Data Bytes in packet queue */
225
struct sk_buff *tskb1; /* temp skb 1 */
226
struct sk_buff *tskb2; /* temp skb 2 */
227
unsigned char l2prot; /* Layer 2 protocol */
228
unsigned char l3prot; /* Layer 3 protocol */
229
#ifdef CONFIG_ISDN_TTY_FAX
230
T30_s *fax; /* pointer to fax data in LL */
231
eicon_ch_fax_buf fax2; /* fax related struct */
233
entity e; /* Native Entity */
234
ENTITY de; /* Divas D Entity */
235
ENTITY be; /* Divas B Entity */
236
char cpn[32]; /* remember cpn */
237
char oad[32]; /* remember oad */
238
char dsa[32]; /* remember dsa */
239
char osa[32]; /* remember osa */
240
unsigned char cause[2]; /* Last Cause */
244
unsigned char screen;
251
#include "eicon_pci.h"
253
#define EICON_FLAGS_RUNNING 1 /* Cards driver activated */
254
#define EICON_FLAGS_PVALID 2 /* Cards port is valid */
255
#define EICON_FLAGS_IVALID 4 /* Cards irq is valid */
256
#define EICON_FLAGS_MVALID 8 /* Cards membase is valid */
257
#define EICON_FLAGS_LOADED 8 /* Firmware loaded */
259
/* D-Channel states */
260
#define EICON_STATE_NULL 0
261
#define EICON_STATE_ICALL 1
262
#define EICON_STATE_OCALL 2
263
#define EICON_STATE_IWAIT 3
264
#define EICON_STATE_OWAIT 4
265
#define EICON_STATE_IBWAIT 5
266
#define EICON_STATE_OBWAIT 6
267
#define EICON_STATE_BWAIT 7
268
#define EICON_STATE_BHWAIT 8
269
#define EICON_STATE_BHWAIT2 9
270
#define EICON_STATE_DHWAIT 10
271
#define EICON_STATE_DHWAIT2 11
272
#define EICON_STATE_BSETUP 12
273
#define EICON_STATE_ACTIVE 13
274
#define EICON_STATE_ICALLW 14
275
#define EICON_STATE_LISTEN 15
276
#define EICON_STATE_WMCONN 16
278
#define EICON_MAX_QUEUE 2138
306
* Per card driver data
308
typedef struct eicon_card {
309
eicon_hwif hwif; /* Hardware dependant interface */
310
DESCRIPTOR *d; /* IDI Descriptor */
311
u_char ptype; /* Protocol type (1TR6 or Euro) */
312
u_char bus; /* Bustype (ISA, MCA, PCI) */
313
u_char type; /* Cardtype (EICON_CTYPE_...) */
314
struct eicon_card *qnext; /* Pointer to next quadro adapter */
315
int Feature; /* Protocol Feature Value */
316
struct eicon_card *next; /* Pointer to next device struct */
317
int myid; /* Driver-Nr. assigned by linklevel */
318
unsigned long flags; /* Statusflags */
319
struct sk_buff_head rcvq; /* Receive-Message queue */
320
struct sk_buff_head sndq; /* Send-Message queue */
321
struct sk_buff_head rackq; /* Req-Ack-Message queue */
322
struct sk_buff_head sackq; /* Data-Ack-Message queue */
323
struct sk_buff_head statq; /* Status-Message queue */
325
struct tq_struct snd_tq; /* Task struct for xmit bh */
326
struct tq_struct rcv_tq; /* Task struct for rcv bh */
327
struct tq_struct ack_tq; /* Task struct for ack bh */
328
eicon_chan* IdTable[256]; /* Table to find entity */
331
int nchannels; /* Number of B-Channels */
332
int ReadyInt; /* Ready Interrupt */
333
eicon_chan *bch; /* B-Channel status/control */
334
DBUFFER *dbuf; /* Dbuffer for Diva Server */
335
BUFFERS *sbuf; /* Buffer for Diva Server */
336
char *sbufp; /* Data Buffer for Diva Server */
337
isdn_if interface; /* Interface to upper layer */
338
char regname[35]; /* Drivers card name */
340
int mca_slot; /* # of cards MCA slot */
341
int mca_io; /* MCA cards IO port */
342
#endif /* CONFIG_MCA */
345
#include "eicon_idi.h"
347
extern eicon_card *cards;
348
extern char *eicon_ctype_name[];
351
extern __inline__ void eicon_schedule_tx(eicon_card *card)
353
queue_task(&card->snd_tq, &tq_immediate);
354
mark_bh(IMMEDIATE_BH);
357
extern __inline__ void eicon_schedule_rx(eicon_card *card)
359
queue_task(&card->rcv_tq, &tq_immediate);
360
mark_bh(IMMEDIATE_BH);
363
extern __inline__ void eicon_schedule_ack(eicon_card *card)
365
queue_task(&card->ack_tq, &tq_immediate);
366
mark_bh(IMMEDIATE_BH);
369
extern int eicon_addcard(int, int, int, char *, int);
370
extern void eicon_io_transmit(eicon_card *card);
371
extern void eicon_irq(int irq, void *dev_id, struct pt_regs *regs);
372
extern void eicon_io_rcv_dispatch(eicon_card *ccard);
373
extern void eicon_io_ack_dispatch(eicon_card *ccard);
375
extern int eicon_mca_find_card(int, int, int, char *);
376
extern int eicon_mca_probe(int, int, int, int, char *);
377
extern int eicon_info(char *, int , void *);
378
#endif /* CONFIG_MCA */
380
extern ulong DebugVar;
381
extern void eicon_log(eicon_card * card, int level, const char *fmt, ...);
382
extern void eicon_putstatus(eicon_card * card, char * buf);
384
extern spinlock_t eicon_lock;
386
#endif /* __KERNEL__ */