OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [isdn/] [icn/] [icn.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* $Id: icn.h,v 1.1.1.1 2001-09-10 07:44:19 simons Exp $
2
 
3
 * ISDN lowlevel-module for the ICN active ISDN-Card.
4
 *
5
 * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de)
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2, or (at your option)
10
 * any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 *
21
 * $Log: not supported by cvs2svn $
22
 * Revision 1.1.1.1  2001/07/02 17:58:31  simons
23
 * Initial revision
24
 *
25
 * Revision 1.26.2.1  1998/11/05 22:13:06  fritz
26
 * Changed mail-address.
27
 *
28
 * Revision 1.26  1997/02/14 12:23:16  fritz
29
 * Added support for new insmod parameter handling.
30
 *
31
 * Revision 1.25  1997/02/10 10:10:31  fritz
32
 * Changes for Kernel 2.1.X compatibility.
33
 * Enhanced initialization, can recover from
34
 * misconfiguration by other autoprobing drivers.
35
 *
36
 * Revision 1.24  1997/01/29 22:34:46  fritz
37
 * Cleanup, Corrected D64S setup of 2nd channel.
38
 *
39
 * Revision 1.23  1996/12/17 18:47:55  tsbogend
40
 * changed timeouts from absolute numbers to HZ based values
41
 *
42
 * Revision 1.22  1996/11/13 02:37:33  fritz
43
 * Added delay include.
44
 *
45
 * Revision 1.21  1996/08/29 20:35:57  fritz
46
 * Speed up B-Channel polling interval.
47
 *
48
 * Revision 1.20  1996/06/24 17:20:37  fritz
49
 * Bugfixes in pollbchan_send():
50
 *   - Using lock field of skbuff breaks networking.
51
 *   - Added channel locking
52
 *   - changed dequeuing scheme.
53
 * Eliminated misc. compiler warnings.
54
 *
55
 * Revision 1.19  1996/06/06 13:58:35  fritz
56
 * Changed code to be architecture independent
57
 *
58
 * Revision 1.18  1996/06/03 19:59:30  fritz
59
 * Removed include of config.h
60
 *
61
 * Revision 1.17  1996/05/18 00:47:04  fritz
62
 * Removed callback debug code.
63
 *
64
 * Revision 1.16  1996/05/17 15:46:43  fritz
65
 * Removed own queue management.
66
 * Changed queue management to use sk_buffs.
67
 *
68
 * Revision 1.15  1996/05/02 04:01:57  fritz
69
 * Removed ICN_MAXCARDS
70
 *
71
 * Revision 1.14  1996/05/02 00:40:29  fritz
72
 * Major rewrite to support more than one card
73
 * with a single module.
74
 * Support for new firmware.
75
 *
76
 * Revision 1.13  1996/04/20 16:51:41  fritz
77
 * Increased status buffer.
78
 * Misc. typos
79
 *
80
 * Revision 1.12  1996/01/22 05:01:22  fritz
81
 * Revert to GPL.
82
 *
83
 * Revision 1.11  1995/12/18  18:25:00  fritz
84
 * Support for ICN-2B Cards.
85
 * Change for supporting user-settable service-octet.
86
 *
87
 * Revision 1.10  1995/10/29  21:43:10  fritz
88
 * Added support for leased lines.
89
 *
90
 * Revision 1.9  1995/04/23  13:42:10  fritz
91
 * Added some constants for distinguishing 1TR6 and DSS1
92
 *
93
 * Revision 1.8  1995/03/25  23:18:55  fritz
94
 * Changed ICN_PORTLEN to reflect correct number of ports.
95
 *
96
 * Revision 1.7  1995/03/15  12:52:06  fritz
97
 * Some cleanup
98
 *
99
 * Revision 1.6  1995/02/20  03:49:22  fritz
100
 * Fixed ICN_MAX_SQUEUE to correctly reflect outstanding bytes, not number
101
 * of buffers.
102
 *
103
 * Revision 1.5  1995/01/29  23:36:50  fritz
104
 * Minor cleanup.
105
 *
106
 * Revision 1.4  1995/01/09  07:41:20  fritz
107
 * Added GPL-Notice
108
 *
109
 * Revision 1.3  1995/01/04  05:14:20  fritz
110
 * removed include of linux/asm/string.h for compiling with Linux 1.1.76
111
 *
112
 * Revision 1.2  1995/01/02  02:15:57  fritz
113
 * Misc. Bugfixes
114
 *
115
 * Revision 1.1  1994/12/14  18:02:38  fritz
116
 * Initial revision
117
 *
118
 */
119
 
120
#ifndef icn_h
121
#define icn_h
122
 
123
#define ICN_IOCTL_SETMMIO   0
124
#define ICN_IOCTL_GETMMIO   1
125
#define ICN_IOCTL_SETPORT   2
126
#define ICN_IOCTL_GETPORT   3
127
#define ICN_IOCTL_LOADBOOT  4
128
#define ICN_IOCTL_LOADPROTO 5
129
#define ICN_IOCTL_LEASEDCFG 6
130
#define ICN_IOCTL_GETDOUBLE 7
131
#define ICN_IOCTL_DEBUGVAR  8
132
#define ICN_IOCTL_ADDCARD   9
133
 
134
/* Struct for adding new cards */
135
typedef struct icn_cdef {
136
        int port;
137
        char id1[10];
138
        char id2[10];
139
} icn_cdef;
140
 
141
#if defined(__KERNEL__) || defined(__DEBUGVAR__)
142
 
143
#ifdef __KERNEL__
144
/* Kernel includes */
145
 
146
#include <linux/module.h>
147
#include <linux/version.h>
148
#include <linux/errno.h>
149
#include <linux/fs.h>
150
#include <linux/major.h>
151
#include <asm/segment.h>
152
#include <asm/io.h>
153
#include <linux/kernel.h>
154
#include <linux/signal.h>
155
#include <linux/malloc.h>
156
#include <linux/mm.h>
157
#include <linux/mman.h>
158
#include <linux/ioport.h>
159
#include <linux/timer.h>
160
#include <linux/wait.h>
161
#include <linux/delay.h>
162
#include <linux/isdnif.h>
163
 
164
#endif                          /* __KERNEL__ */
165
 
166
/* some useful macros for debugging */
167
#ifdef ICN_DEBUG_PORT
168
#define OUTB_P(v,p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n",v,p); outb_p(v,p);}
169
#else
170
#define OUTB_P outb
171
#endif
172
 
173
/* Defaults for Port-Address and shared-memory */
174
#define ICN_BASEADDR 0x320
175
#define ICN_PORTLEN (0x04)
176
#define ICN_MEMADDR 0x0d0000
177
 
178
#define ICN_FLAGS_B1ACTIVE 1    /* B-Channel-1 is open                     */
179
#define ICN_FLAGS_B2ACTIVE 2    /* B-Channel-2 is open                     */
180
#define ICN_FLAGS_RUNNING  4    /* Cards driver activated                  */
181
#define ICN_FLAGS_RBTIMER  8    /* cyclic scheduling of B-Channel-poll     */
182
 
183
#define ICN_BOOT_TIMEOUT1  (HZ) /* Delay for Boot-download (jiffies)       */
184
#define ICN_CHANLOCK_DELAY (HZ/10)      /* Delay for Channel-mapping (jiffies)     */
185
 
186
#define ICN_TIMER_BCREAD (HZ/100)       /* B-Channel poll-cycle                    */
187
#define ICN_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle                    */
188
 
189
#define ICN_CODE_STAGE1 4096    /* Size of bootcode                        */
190
#define ICN_CODE_STAGE2 65536   /* Size of protocol-code                   */
191
 
192
#define ICN_MAX_SQUEUE 8000     /* Max. outstanding send-data (2* hw-buf.) */
193
#define ICN_FRAGSIZE (250)      /* Max. size of send-fragments             */
194
#define ICN_BCH 2               /* Number of supported channels per card   */
195
 
196
/* type-definitions for accessing the mmap-io-areas */
197
 
198
#define SHM_DCTL_OFFSET (0)     /* Offset to data-controlstructures in shm */
199
#define SHM_CCTL_OFFSET (0x1d2) /* Offset to comm-controlstructures in shm */
200
#define SHM_CBUF_OFFSET (0x200) /* Offset to comm-buffers in shm           */
201
#define SHM_DBUF_OFFSET (0x2000)        /* Offset to data-buffers in shm           */
202
 
203
/*
204
 * Layout of card's data buffers
205
 */
206
typedef struct {
207
        unsigned char length;   /* Bytecount of fragment (max 250)    */
208
        unsigned char endflag;  /* 0=last frag., 0xff=frag. continued */
209
        unsigned char data[ICN_FRAGSIZE];       /* The data                           */
210
        /* Fill to 256 bytes */
211
        char unused[0x100 - ICN_FRAGSIZE - 2];
212
} frag_buf;
213
 
214
/*
215
 * Layout of card's shared memory
216
 */
217
typedef union {
218
        struct {
219
                unsigned char scns;     /* Index to free SendFrag.             */
220
                unsigned char scnr;     /* Index to active SendFrag   READONLY */
221
                unsigned char ecns;     /* Index to free RcvFrag.     READONLY */
222
                unsigned char ecnr;     /* Index to valid RcvFrag              */
223
                char unused[6];
224
                unsigned short fuell1;  /* Internal Buf Bytecount              */
225
        } data_control;
226
        struct {
227
                char unused[SHM_CCTL_OFFSET];
228
                unsigned char iopc_i;   /* Read-Ptr Status-Queue      READONLY */
229
                unsigned char iopc_o;   /* Write-Ptr Status-Queue              */
230
                unsigned char pcio_i;   /* Write-Ptr Command-Queue             */
231
                unsigned char pcio_o;   /* Read-Ptr Command Queue     READONLY */
232
        } comm_control;
233
        struct {
234
                char unused[SHM_CBUF_OFFSET];
235
                unsigned char pcio_buf[0x100];  /* Ring-Buffer Command-Queue           */
236
                unsigned char iopc_buf[0x100];  /* Ring-Buffer Status-Queue            */
237
        } comm_buffers;
238
        struct {
239
                char unused[SHM_DBUF_OFFSET];
240
                frag_buf receive_buf[0x10];
241
                frag_buf send_buf[0x10];
242
        } data_buffers;
243
} icn_shmem;
244
 
245
/*
246
 * Per card driver data
247
 */
248
typedef struct icn_card {
249
        struct icn_card *next;  /* Pointer to next device struct    */
250
        struct icn_card *other; /* Pointer to other card for ICN4B  */
251
        unsigned short port;    /* Base-port-address                */
252
        int myid;               /* Driver-Nr. assigned by linklevel */
253
        int rvalid;             /* IO-portregion has been requested */
254
        int leased;             /* Flag: This Adapter is connected  */
255
        /*       to a leased line           */
256
        unsigned short flags;   /* Statusflags                      */
257
        int doubleS0;           /* Flag: ICN4B                      */
258
        int secondhalf;         /* Flag: Second half of a doubleS0  */
259
        int fw_rev;             /* Firmware revision loaded         */
260
        int ptype;              /* Protocol type (1TR6 or Euro)     */
261
        struct timer_list st_timer;     /* Timer for Status-Polls           */
262
        struct timer_list rb_timer;     /* Timer for B-Channel-Polls        */
263
        u_char rcvbuf[ICN_BCH][4096];   /* B-Channel-Receive-Buffers        */
264
        int rcvidx[ICN_BCH];    /* Index for above buffers          */
265
        int l2_proto[ICN_BCH];  /* Current layer-2-protocol         */
266
        isdn_if interface;      /* Interface to upper layer         */
267
        int iptr;               /* Index to imsg-buffer             */
268
        char imsg[60];          /* Internal buf for status-parsing  */
269
        char msg_buf[2048];     /* Buffer for status-messages       */
270
        char *msg_buf_write;    /* Writepointer for statusbuffer    */
271
        char *msg_buf_read;     /* Readpointer for statusbuffer     */
272
        char *msg_buf_end;      /* Pointer to end of statusbuffer   */
273
        int sndcount[ICN_BCH];  /* Byte-counters for B-Ch.-send     */
274
        struct sk_buff_head
275
         spqueue[ICN_BCH];      /* Sendqueue                        */
276
        char regname[35];       /* Name used for request_region     */
277
        u_char xmit_lock[ICN_BCH];      /* Semaphore for pollbchan_send()   */
278
} icn_card;
279
 
280
/*
281
 * Main driver data
282
 */
283
typedef struct icn_dev {
284
        icn_shmem *shmem;       /* Pointer to memory-mapped-buffers */
285
        int mvalid;             /* IO-shmem has been requested      */
286
        int channel;            /* Currently mapped channel         */
287
        struct icn_card *mcard; /* Currently mapped card            */
288
        int chanlock;           /* Semaphore for channel-mapping    */
289
        int firstload;          /* Flag: firmware never loaded      */
290
} icn_dev;
291
 
292
typedef icn_dev *icn_devptr;
293
 
294
#ifdef __KERNEL__
295
 
296
static icn_card *cards = (icn_card *) 0;
297
static u_char chan2bank[] =
298
{0, 4, 8, 12};                  /* for icn_map_channel() */
299
 
300
static icn_dev dev;
301
 
302
/* With modutils >= 1.1.67 Integers can be changed while loading a
303
 * module. For this reason define the Port-Base an Shmem-Base as
304
 * integers.
305
 */
306
static int portbase = ICN_BASEADDR;
307
static int membase = ICN_MEMADDR;
308
static char *icn_id = "\0";
309
static char *icn_id2 = "\0";
310
 
311
#ifdef MODULE
312
#if (LINUX_VERSION_CODE > 0x020111)
313
MODULE_AUTHOR("Fritz Elfert");
314
MODULE_PARM(portbase, "i");
315
MODULE_PARM_DESC(portbase, "Port adress of first card");
316
MODULE_PARM(membase, "i");
317
MODULE_PARM_DESC(membase, "Shared memory adress of all cards");
318
MODULE_PARM(icn_id, "s");
319
MODULE_PARM_DESC(icn_id, "ID-String of first card");
320
MODULE_PARM(icn_id2, "s");
321
MODULE_PARM_DESC(icn_id2, "ID-String of first card, second S0 (4B only)");
322
#endif
323
#endif
324
 
325
#endif                          /* __KERNEL__ */
326
 
327
/* Utility-Macros */
328
 
329
/* Macros for accessing ports */
330
#define ICN_CFG    (card->port)
331
#define ICN_MAPRAM (card->port+1)
332
#define ICN_RUN    (card->port+2)
333
#define ICN_BANK   (card->port+3)
334
 
335
/* Return true, if there is a free transmit-buffer */
336
#define sbfree (((readb(&dev.shmem->data_control.scns)+1) & 0xf) != \
337
                readb(&dev.shmem->data_control.scnr))
338
 
339
/* Switch to next transmit-buffer */
340
#define sbnext (writeb((readb(&dev.shmem->data_control.scns)+1) & 0xf, \
341
                       &dev.shmem->data_control.scns))
342
 
343
/* Shortcuts for transmit-buffer-access */
344
#define sbuf_n dev.shmem->data_control.scns
345
#define sbuf_d dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].data
346
#define sbuf_l dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].length
347
#define sbuf_f dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].endflag
348
 
349
/* Return true, if there is receive-data is available */
350
#define rbavl  (readb(&dev.shmem->data_control.ecnr) != \
351
                readb(&dev.shmem->data_control.ecns))
352
 
353
/* Switch to next receive-buffer */
354
#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr)+1) & 0xf, \
355
                       &dev.shmem->data_control.ecnr))
356
 
357
/* Shortcuts for receive-buffer-access */
358
#define rbuf_n dev.shmem->data_control.ecnr
359
#define rbuf_d dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].data
360
#define rbuf_l dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].length
361
#define rbuf_f dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].endflag
362
 
363
/* Shortcuts for command-buffer-access */
364
#define cmd_o (dev.shmem->comm_control.pcio_o)
365
#define cmd_i (dev.shmem->comm_control.pcio_i)
366
 
367
/* Return free space in command-buffer */
368
#define cmd_free ((readb(&cmd_i)>=readb(&cmd_o))? \
369
                  0x100-readb(&cmd_i)+readb(&cmd_o): \
370
                  readb(&cmd_o)-readb(&cmd_i))
371
 
372
/* Shortcuts for message-buffer-access */
373
#define msg_o (dev.shmem->comm_control.iopc_o)
374
#define msg_i (dev.shmem->comm_control.iopc_i)
375
 
376
/* Return length of Message, if avail. */
377
#define msg_avail ((readb(&msg_o)>readb(&msg_i))? \
378
                   0x100-readb(&msg_o)+readb(&msg_i): \
379
                   readb(&msg_i)-readb(&msg_o))
380
 
381
#define CID (card->interface.id)
382
 
383
#define MIN(a,b) ((a<b)?a:b)
384
#define MAX(a,b) ((a>b)?a:b)
385
 
386
/* Hopefully, a separate resource-registration-scheme for shared-memory
387
 * will be introduced into the kernel. Until then, we use the normal
388
 * routines, designed for port-registration.
389
 */
390
#define check_shmem   check_region
391
#define release_shmem release_region
392
#define request_shmem request_region
393
 
394
#endif                          /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
395
#endif                          /* icn_h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.