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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [isdn/] [icn/] [icn.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* $Id: icn.h,v 1.1.1.1 2004-04-15 02:03:57 phoenix Exp $
2
 *
3
 * ISDN lowlevel-module for the ICN active ISDN-Card.
4
 *
5
 * Copyright 1994 by Fritz Elfert (fritz@isdn4linux.de)
6
 *
7
 * This software may be used and distributed according to the terms
8
 * of the GNU General Public License, incorporated herein by reference.
9
 *
10
 */
11
 
12
#ifndef icn_h
13
#define icn_h
14
 
15
#define ICN_IOCTL_SETMMIO   0
16
#define ICN_IOCTL_GETMMIO   1
17
#define ICN_IOCTL_SETPORT   2
18
#define ICN_IOCTL_GETPORT   3
19
#define ICN_IOCTL_LOADBOOT  4
20
#define ICN_IOCTL_LOADPROTO 5
21
#define ICN_IOCTL_LEASEDCFG 6
22
#define ICN_IOCTL_GETDOUBLE 7
23
#define ICN_IOCTL_DEBUGVAR  8
24
#define ICN_IOCTL_ADDCARD   9
25
 
26
/* Struct for adding new cards */
27
typedef struct icn_cdef {
28
        int port;
29
        char id1[10];
30
        char id2[10];
31
} icn_cdef;
32
 
33
#if defined(__KERNEL__) || defined(__DEBUGVAR__)
34
 
35
#ifdef __KERNEL__
36
/* Kernel includes */
37
 
38
#include <linux/version.h>
39
#include <linux/errno.h>
40
#include <linux/fs.h>
41
#include <linux/major.h>
42
#include <asm/segment.h>
43
#include <asm/io.h>
44
#include <linux/kernel.h>
45
#include <linux/signal.h>
46
#include <linux/slab.h>
47
#include <linux/mm.h>
48
#include <linux/mman.h>
49
#include <linux/ioport.h>
50
#include <linux/timer.h>
51
#include <linux/wait.h>
52
#include <linux/delay.h>
53
#include <linux/isdnif.h>
54
 
55
#endif                          /* __KERNEL__ */
56
 
57
/* some useful macros for debugging */
58
#ifdef ICN_DEBUG_PORT
59
#define OUTB_P(v,p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n",v,p); outb_p(v,p);}
60
#else
61
#define OUTB_P outb
62
#endif
63
 
64
/* Defaults for Port-Address and shared-memory */
65
#define ICN_BASEADDR 0x320
66
#define ICN_PORTLEN (0x04)
67
#define ICN_MEMADDR 0x0d0000
68
 
69
#define ICN_FLAGS_B1ACTIVE 1    /* B-Channel-1 is open                     */
70
#define ICN_FLAGS_B2ACTIVE 2    /* B-Channel-2 is open                     */
71
#define ICN_FLAGS_RUNNING  4    /* Cards driver activated                  */
72
#define ICN_FLAGS_RBTIMER  8    /* cyclic scheduling of B-Channel-poll     */
73
 
74
#define ICN_BOOT_TIMEOUT1  (HZ) /* Delay for Boot-download (jiffies)       */
75
#define ICN_CHANLOCK_DELAY (HZ/10)      /* Delay for Channel-mapping (jiffies)     */
76
 
77
#define ICN_TIMER_BCREAD (HZ/100)       /* B-Channel poll-cycle                    */
78
#define ICN_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle                    */
79
 
80
#define ICN_CODE_STAGE1 4096    /* Size of bootcode                        */
81
#define ICN_CODE_STAGE2 65536   /* Size of protocol-code                   */
82
 
83
#define ICN_MAX_SQUEUE 8000     /* Max. outstanding send-data (2* hw-buf.) */
84
#define ICN_FRAGSIZE (250)      /* Max. size of send-fragments             */
85
#define ICN_BCH 2               /* Number of supported channels per card   */
86
 
87
/* type-definitions for accessing the mmap-io-areas */
88
 
89
#define SHM_DCTL_OFFSET (0)     /* Offset to data-controlstructures in shm */
90
#define SHM_CCTL_OFFSET (0x1d2) /* Offset to comm-controlstructures in shm */
91
#define SHM_CBUF_OFFSET (0x200) /* Offset to comm-buffers in shm           */
92
#define SHM_DBUF_OFFSET (0x2000)        /* Offset to data-buffers in shm           */
93
 
94
/*
95
 * Layout of card's data buffers
96
 */
97
typedef struct {
98
        unsigned char length;   /* Bytecount of fragment (max 250)    */
99
        unsigned char endflag;  /* 0=last frag., 0xff=frag. continued */
100
        unsigned char data[ICN_FRAGSIZE];       /* The data                           */
101
        /* Fill to 256 bytes */
102
        char unused[0x100 - ICN_FRAGSIZE - 2];
103
} frag_buf;
104
 
105
/*
106
 * Layout of card's shared memory
107
 */
108
typedef union {
109
        struct {
110
                unsigned char scns;     /* Index to free SendFrag.             */
111
                unsigned char scnr;     /* Index to active SendFrag   READONLY */
112
                unsigned char ecns;     /* Index to free RcvFrag.     READONLY */
113
                unsigned char ecnr;     /* Index to valid RcvFrag              */
114
                char unused[6];
115
                unsigned short fuell1;  /* Internal Buf Bytecount              */
116
        } data_control;
117
        struct {
118
                char unused[SHM_CCTL_OFFSET];
119
                unsigned char iopc_i;   /* Read-Ptr Status-Queue      READONLY */
120
                unsigned char iopc_o;   /* Write-Ptr Status-Queue              */
121
                unsigned char pcio_i;   /* Write-Ptr Command-Queue             */
122
                unsigned char pcio_o;   /* Read-Ptr Command Queue     READONLY */
123
        } comm_control;
124
        struct {
125
                char unused[SHM_CBUF_OFFSET];
126
                unsigned char pcio_buf[0x100];  /* Ring-Buffer Command-Queue           */
127
                unsigned char iopc_buf[0x100];  /* Ring-Buffer Status-Queue            */
128
        } comm_buffers;
129
        struct {
130
                char unused[SHM_DBUF_OFFSET];
131
                frag_buf receive_buf[0x10];
132
                frag_buf send_buf[0x10];
133
        } data_buffers;
134
} icn_shmem;
135
 
136
/*
137
 * Per card driver data
138
 */
139
typedef struct icn_card {
140
        struct icn_card *next;  /* Pointer to next device struct    */
141
        struct icn_card *other; /* Pointer to other card for ICN4B  */
142
        unsigned short port;    /* Base-port-address                */
143
        int myid;               /* Driver-Nr. assigned by linklevel */
144
        int rvalid;             /* IO-portregion has been requested */
145
        int leased;             /* Flag: This Adapter is connected  */
146
        /*       to a leased line           */
147
        unsigned short flags;   /* Statusflags                      */
148
        int doubleS0;           /* Flag: ICN4B                      */
149
        int secondhalf;         /* Flag: Second half of a doubleS0  */
150
        int fw_rev;             /* Firmware revision loaded         */
151
        int ptype;              /* Protocol type (1TR6 or Euro)     */
152
        struct timer_list st_timer;     /* Timer for Status-Polls           */
153
        struct timer_list rb_timer;     /* Timer for B-Channel-Polls        */
154
        u_char rcvbuf[ICN_BCH][4096];   /* B-Channel-Receive-Buffers        */
155
        int rcvidx[ICN_BCH];    /* Index for above buffers          */
156
        int l2_proto[ICN_BCH];  /* Current layer-2-protocol         */
157
        isdn_if interface;      /* Interface to upper layer         */
158
        int iptr;               /* Index to imsg-buffer             */
159
        char imsg[60];          /* Internal buf for status-parsing  */
160
        char msg_buf[2048];     /* Buffer for status-messages       */
161
        char *msg_buf_write;    /* Writepointer for statusbuffer    */
162
        char *msg_buf_read;     /* Readpointer for statusbuffer     */
163
        char *msg_buf_end;      /* Pointer to end of statusbuffer   */
164
        int sndcount[ICN_BCH];  /* Byte-counters for B-Ch.-send     */
165
        int xlen[ICN_BCH];      /* Byte-counters/Flags for sent-ACK */
166
        struct sk_buff *xskb[ICN_BCH];
167
                                /* Current transmitted skb          */
168
        struct sk_buff_head
169
         spqueue[ICN_BCH];      /* Sendqueue                        */
170
        char regname[35];       /* Name used for request_region     */
171
        u_char xmit_lock[ICN_BCH];      /* Semaphore for pollbchan_send()   */
172
} icn_card;
173
 
174
/*
175
 * Main driver data
176
 */
177
typedef struct icn_dev {
178
        unsigned long memaddr;  /* Address of memory mapped buffers */
179
        icn_shmem *shmem;       /* Pointer to memory-mapped-buffers */
180
        int mvalid;             /* IO-shmem has been requested      */
181
        int channel;            /* Currently mapped channel         */
182
        struct icn_card *mcard; /* Currently mapped card            */
183
        int chanlock;           /* Semaphore for channel-mapping    */
184
        int firstload;          /* Flag: firmware never loaded      */
185
} icn_dev;
186
 
187
typedef icn_dev *icn_devptr;
188
 
189
#ifdef __KERNEL__
190
 
191
static icn_card *cards = (icn_card *) 0;
192
static u_char chan2bank[] =
193
{0, 4, 8, 12};                  /* for icn_map_channel() */
194
 
195
static icn_dev dev;
196
 
197
#endif                          /* __KERNEL__ */
198
 
199
/* Utility-Macros */
200
 
201
/* Macros for accessing ports */
202
#define ICN_CFG    (card->port)
203
#define ICN_MAPRAM (card->port+1)
204
#define ICN_RUN    (card->port+2)
205
#define ICN_BANK   (card->port+3)
206
 
207
/* Return true, if there is a free transmit-buffer */
208
#define sbfree (((readb(&dev.shmem->data_control.scns)+1) & 0xf) != \
209
                readb(&dev.shmem->data_control.scnr))
210
 
211
/* Switch to next transmit-buffer */
212
#define sbnext (writeb((readb(&dev.shmem->data_control.scns)+1) & 0xf, \
213
                       &dev.shmem->data_control.scns))
214
 
215
/* Shortcuts for transmit-buffer-access */
216
#define sbuf_n dev.shmem->data_control.scns
217
#define sbuf_d dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].data
218
#define sbuf_l dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].length
219
#define sbuf_f dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].endflag
220
 
221
/* Return true, if there is receive-data is available */
222
#define rbavl  (readb(&dev.shmem->data_control.ecnr) != \
223
                readb(&dev.shmem->data_control.ecns))
224
 
225
/* Switch to next receive-buffer */
226
#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr)+1) & 0xf, \
227
                       &dev.shmem->data_control.ecnr))
228
 
229
/* Shortcuts for receive-buffer-access */
230
#define rbuf_n dev.shmem->data_control.ecnr
231
#define rbuf_d dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].data
232
#define rbuf_l dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].length
233
#define rbuf_f dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].endflag
234
 
235
/* Shortcuts for command-buffer-access */
236
#define cmd_o (dev.shmem->comm_control.pcio_o)
237
#define cmd_i (dev.shmem->comm_control.pcio_i)
238
 
239
/* Return free space in command-buffer */
240
#define cmd_free ((readb(&cmd_i)>=readb(&cmd_o))? \
241
                  0x100-readb(&cmd_i)+readb(&cmd_o): \
242
                  readb(&cmd_o)-readb(&cmd_i))
243
 
244
/* Shortcuts for message-buffer-access */
245
#define msg_o (dev.shmem->comm_control.iopc_o)
246
#define msg_i (dev.shmem->comm_control.iopc_i)
247
 
248
/* Return length of Message, if avail. */
249
#define msg_avail ((readb(&msg_o)>readb(&msg_i))? \
250
                   0x100-readb(&msg_o)+readb(&msg_i): \
251
                   readb(&msg_i)-readb(&msg_o))
252
 
253
#define CID (card->interface.id)
254
 
255
#endif                          /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
256
#endif                          /* icn_h */

powered by: WebSVN 2.1.0

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