1
2
3
4
5
6
7
8
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
27typedef 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
37
38#include <linux/errno.h>
39#include <linux/fs.h>
40#include <linux/major.h>
41#include <asm/io.h>
42#include <linux/kernel.h>
43#include <linux/signal.h>
44#include <linux/slab.h>
45#include <linux/mm.h>
46#include <linux/mman.h>
47#include <linux/ioport.h>
48#include <linux/timer.h>
49#include <linux/wait.h>
50#include <linux/delay.h>
51#include <linux/isdnif.h>
52
53#endif
54
55
56#ifdef ICN_DEBUG_PORT
57#define OUTB_P(v,p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n",v,p); outb_p(v,p);}
58#else
59#define OUTB_P outb
60#endif
61
62
63#define ICN_BASEADDR 0x320
64#define ICN_PORTLEN (0x04)
65#define ICN_MEMADDR 0x0d0000
66
67#define ICN_FLAGS_B1ACTIVE 1
68#define ICN_FLAGS_B2ACTIVE 2
69#define ICN_FLAGS_RUNNING 4
70#define ICN_FLAGS_RBTIMER 8
71
72#define ICN_BOOT_TIMEOUT1 1000
73
74#define ICN_TIMER_BCREAD (HZ/100)
75#define ICN_TIMER_DCREAD (HZ/2)
76
77#define ICN_CODE_STAGE1 4096
78#define ICN_CODE_STAGE2 65536
79
80#define ICN_MAX_SQUEUE 8000
81#define ICN_FRAGSIZE (250)
82#define ICN_BCH 2
83
84
85
86#define SHM_DCTL_OFFSET (0)
87#define SHM_CCTL_OFFSET (0x1d2)
88#define SHM_CBUF_OFFSET (0x200)
89#define SHM_DBUF_OFFSET (0x2000)
90
91
92
93
94typedef struct {
95 unsigned char length;
96 unsigned char endflag;
97 unsigned char data[ICN_FRAGSIZE];
98
99 char unused[0x100 - ICN_FRAGSIZE - 2];
100} frag_buf;
101
102
103
104
105typedef union {
106 struct {
107 unsigned char scns;
108 unsigned char scnr;
109 unsigned char ecns;
110 unsigned char ecnr;
111 char unused[6];
112 unsigned short fuell1;
113 } data_control;
114 struct {
115 char unused[SHM_CCTL_OFFSET];
116 unsigned char iopc_i;
117 unsigned char iopc_o;
118 unsigned char pcio_i;
119 unsigned char pcio_o;
120 } comm_control;
121 struct {
122 char unused[SHM_CBUF_OFFSET];
123 unsigned char pcio_buf[0x100];
124 unsigned char iopc_buf[0x100];
125 } comm_buffers;
126 struct {
127 char unused[SHM_DBUF_OFFSET];
128 frag_buf receive_buf[0x10];
129 frag_buf send_buf[0x10];
130 } data_buffers;
131} icn_shmem;
132
133
134
135
136typedef struct icn_card {
137 struct icn_card *next;
138 struct icn_card *other;
139 unsigned short port;
140 int myid;
141 int rvalid;
142 int leased;
143
144 unsigned short flags;
145 int doubleS0;
146 int secondhalf;
147 int fw_rev;
148 int ptype;
149 struct timer_list st_timer;
150 struct timer_list rb_timer;
151 u_char rcvbuf[ICN_BCH][4096];
152 int rcvidx[ICN_BCH];
153 int l2_proto[ICN_BCH];
154 isdn_if interface;
155 int iptr;
156 char imsg[60];
157 char msg_buf[2048];
158 char *msg_buf_write;
159 char *msg_buf_read;
160 char *msg_buf_end;
161 int sndcount[ICN_BCH];
162 int xlen[ICN_BCH];
163 struct sk_buff *xskb[ICN_BCH];
164 struct sk_buff_head spqueue[ICN_BCH];
165 char regname[35];
166 u_char xmit_lock[ICN_BCH];
167 spinlock_t lock;
168} icn_card;
169
170
171
172
173typedef struct icn_dev {
174 spinlock_t devlock;
175 unsigned long memaddr;
176 icn_shmem __iomem *shmem;
177 int mvalid;
178 int channel;
179 struct icn_card *mcard;
180 int chanlock;
181 int firstload;
182} icn_dev;
183
184typedef icn_dev *icn_devptr;
185
186#ifdef __KERNEL__
187
188static icn_card *cards = (icn_card *) 0;
189static u_char chan2bank[] =
190{0, 4, 8, 12};
191
192static icn_dev dev;
193
194#endif
195
196
197
198
199#define ICN_CFG (card->port)
200#define ICN_MAPRAM (card->port+1)
201#define ICN_RUN (card->port+2)
202#define ICN_BANK (card->port+3)
203
204
205#define sbfree (((readb(&dev.shmem->data_control.scns)+1) & 0xf) != \
206 readb(&dev.shmem->data_control.scnr))
207
208
209#define sbnext (writeb((readb(&dev.shmem->data_control.scns)+1) & 0xf, \
210 &dev.shmem->data_control.scns))
211
212
213#define sbuf_n dev.shmem->data_control.scns
214#define sbuf_d dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].data
215#define sbuf_l dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].length
216#define sbuf_f dev.shmem->data_buffers.send_buf[readb(&sbuf_n)].endflag
217
218
219#define rbavl (readb(&dev.shmem->data_control.ecnr) != \
220 readb(&dev.shmem->data_control.ecns))
221
222
223#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr)+1) & 0xf, \
224 &dev.shmem->data_control.ecnr))
225
226
227#define rbuf_n dev.shmem->data_control.ecnr
228#define rbuf_d dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].data
229#define rbuf_l dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].length
230#define rbuf_f dev.shmem->data_buffers.receive_buf[readb(&rbuf_n)].endflag
231
232
233#define cmd_o (dev.shmem->comm_control.pcio_o)
234#define cmd_i (dev.shmem->comm_control.pcio_i)
235
236
237#define cmd_free ((readb(&cmd_i)>=readb(&cmd_o))? \
238 0x100-readb(&cmd_i)+readb(&cmd_o): \
239 readb(&cmd_o)-readb(&cmd_i))
240
241
242#define msg_o (dev.shmem->comm_control.iopc_o)
243#define msg_i (dev.shmem->comm_control.iopc_i)
244
245
246#define msg_avail ((readb(&msg_o)>readb(&msg_i))? \
247 0x100-readb(&msg_o)+readb(&msg_i): \
248 readb(&msg_i)-readb(&msg_o))
249
250#define CID (card->interface.id)
251
252#endif
253#endif
254