Fix to make jumbo frames work properly.
[dragonfly.git] / sys / i386 / include / cdk.h
1 /*****************************************************************************/
2
3 /*
4  * cdk.h  -- CDK interface definitions.
5  *
6  * Copyright (c) 1994-1998 Greg Ungerer (gerg@stallion.oz.au).
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Greg Ungerer.
20  * 4. Neither the name of the author nor the names of any co-contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * $FreeBSD: src/sys/i386/include/cdk.h,v 1.5.2.1 2001/08/30 12:29:57 murray Exp $
37  * $DragonFly: src/sys/i386/include/Attic/cdk.h,v 1.3 2003/06/28 04:16:03 dillon Exp $
38  */
39
40 #ifndef _CDK_H_
41 #define _CDK_H_
42
43 #pragma pack(2)
44
45 /*
46  *      The following set of definitions is used to communicate with the
47  *      shared memory interface of the Stallion intelligent multiport serial
48  *      boards. The definitions in this file are taken directly from the
49  *      document titled "Generic Stackable Interface, Downloader and
50  *      Communications Development Kit".
51  */
52
53 /*
54  *      Define the set of importrant shared memory addresses. These are
55  *      required to intialize the board and get things started. All of these
56  *      addresses are relative to the start of the shared memory.
57  */
58 #define CDK_SIGADDR     0x200
59 #define CDK_FEATADDR    0x280
60 #define CDK_CDKADDR     0x300
61 #define CDK_RDYADDR     0x262
62
63 #define CDK_ALIVEMARKER 13
64
65 /*
66  *      On hardware power up the ROMs located on the EasyConnection 8/64 will
67  *      fill out the following signature information into shared memory. This
68  *      way the host system can quickly determine that the board is present
69  *      and is operational.
70  */
71 typedef struct cdkecpsig {
72         unsigned long   magic;
73         unsigned short  romver;
74         unsigned short  cputype;
75         unsigned char   panelid[8];
76 } cdkecpsig_t;
77
78 #define ECP_MAGIC       0x21504345
79
80 /*
81  *      On hardware power up the ROMs located on the ONboard, Stallion and
82  *      Brumbys will fill out the following signature information into shared
83  *      memory. This way the host system can quickly determine that the board
84  *      is present and is operational.
85  */
86 typedef struct cdkonbsig {
87         unsigned short  magic0;
88         unsigned short  magic1;
89         unsigned short  magic2;
90         unsigned short  magic3;
91         unsigned short  romver;
92         unsigned short  memoff;
93         unsigned short  memseg;
94         unsigned short  amask0;
95         unsigned short  pic;
96         unsigned short  status;
97         unsigned short  btype;
98         unsigned short  clkticks;
99         unsigned short  clkspeed;
100         unsigned short  amask1;
101         unsigned short  amask2;
102 } cdkonbsig_t;
103
104 #define ONB_MAGIC0      0xf2a7
105 #define ONB_MAGIC1      0xa149
106 #define ONB_MAGIC2      0x6352
107 #define ONB_MAGIC3      0xf121
108
109 /*
110  *      Define the feature area structure. The feature area is the set of
111  *      startup parameters used by the slave image when it starts executing.
112  *      They allow for the specification of buffer sizes, debug trace, etc.
113  */
114 typedef struct cdkfeature {
115         unsigned long   debug;
116         unsigned long   banner;
117         unsigned long   etype;
118         unsigned long   nrdevs;
119         unsigned long   brdspec;
120         unsigned long   txrqsize;
121         unsigned long   rxrqsize;
122         unsigned long   flags;
123 } cdkfeature_t;
124
125 #define ETYP_DDK        0
126 #define ETYP_CDK        1
127
128 /*
129  *      Define the CDK header structure. This is the info that the slave
130  *      environment sets up after it has been downloaded and started. It
131  *      essentially provides a memory map for the shared memory interface.
132  */
133 typedef struct cdkhdr {
134         unsigned short  command;
135         unsigned short  status;
136         unsigned short  port;
137         unsigned short  mode;
138         unsigned long   cmd_buf[14];
139         unsigned short  alive_cnt;
140         unsigned short  intrpt_mode;
141         unsigned char   intrpt_id[8];
142         unsigned char   ver_release;
143         unsigned char   ver_modification;
144         unsigned char   ver_fix;
145         unsigned char   deadman_restart;
146         unsigned short  deadman;
147         unsigned short  nrdevs;
148         unsigned long   memp;
149         unsigned long   hostp;
150         unsigned long   slavep;
151         unsigned char   hostreq;
152         unsigned char   slavereq;
153         unsigned char   cmd_reserved[30];
154 } cdkhdr_t;
155
156 #define MODE_DDK        0
157 #define MODE_CDK        1
158
159 #define IMD_INTR        0x0
160 #define IMD_PPINTR      0x1
161 #define IMD_POLL        0xff
162
163 /*
164  *      Define the memory mapping structure. This structure is pointed to by
165  *      the memp field in the stlcdkhdr struct. As many as these structures
166  *      as required are layed out in shared memory to define how the rest of
167  *      shared memory is divided up. There will be one for each port.
168  */
169 typedef struct cdkmem {
170         unsigned short  dtype;
171         unsigned long   offset;
172 } cdkmem_t;
173
174 #define TYP_UNDEFINED   0x0
175 #define TYP_ASYNCTRL    0x1
176 #define TYP_ASYNC       0x20
177 #define TYP_PARALLEL    0x40
178 #define TYP_SYNCX21     0x60
179
180 /*****************************************************************************/
181
182 /*
183  *      Following is a set of defines and structures used to actually deal
184  *      with the serial ports on the board. Firstly is the set of commands
185  *      that can be applied to ports.
186  */
187 #define ASYCMD          (((unsigned long) 'a') << 8)
188
189 #define A_NULL          (ASYCMD | 0)
190 #define A_FLUSH         (ASYCMD | 1)
191 #define A_BREAK         (ASYCMD | 2)
192 #define A_GETPORT       (ASYCMD | 3)
193 #define A_SETPORT       (ASYCMD | 4)
194 #define A_SETPORTF      (ASYCMD | 5)
195 #define A_SETPORTFTX    (ASYCMD | 6)
196 #define A_SETPORTFRX    (ASYCMD | 7)
197 #define A_GETSIGNALS    (ASYCMD | 8)
198 #define A_SETSIGNALS    (ASYCMD | 9)
199 #define A_SETSIGNALSF   (ASYCMD | 10)
200 #define A_SETSIGNALSFTX (ASYCMD | 11)
201 #define A_SETSIGNALSFRX (ASYCMD | 12)
202 #define A_GETNOTIFY     (ASYCMD | 13)
203 #define A_SETNOTIFY     (ASYCMD | 14)
204 #define A_NOTIFY        (ASYCMD | 15)
205 #define A_PORTCTRL      (ASYCMD | 16)
206 #define A_GETSTATS      (ASYCMD | 17)
207 #define A_RQSTATE       (ASYCMD | 18)
208 #define A_FLOWSTATE     (ASYCMD | 19)
209 #define A_CLEARSTATS    (ASYCMD | 20)
210
211 /*
212  *      Define those arguments used for simple commands.
213  */
214 #define FLUSHRX         0x1
215 #define FLUSHTX         0x2
216
217 #define BREAKON         -1
218 #define BREAKOFF        -2
219
220 /*
221  *      Define the port setting structure, and all those defines that go along
222  *      with it. Basically this structure defines the charcateristics of this
223  *      port: baud rate, chars, parity, input/output char cooking etc.
224  */
225 typedef struct asyport {
226         unsigned long   baudout;
227         unsigned long   baudin;
228         unsigned long   iflag;
229         unsigned long   oflag;
230         unsigned long   lflag;
231         unsigned long   pflag;
232         unsigned long   flow;
233         unsigned long   spare1;
234         unsigned short  vtime;
235         unsigned short  vmin;
236         unsigned short  txlo;
237         unsigned short  txhi;
238         unsigned short  rxlo;
239         unsigned short  rxhi;
240         unsigned short  rxhog;
241         unsigned short  spare2;
242         unsigned char   csize;
243         unsigned char   stopbs;
244         unsigned char   parity;
245         unsigned char   stopin;
246         unsigned char   startin;
247         unsigned char   stopout;
248         unsigned char   startout;
249         unsigned char   parmark;
250         unsigned char   brkmark;
251         unsigned char   cc[11];
252 } asyport_t;
253
254 #define PT_STOP1        0x0
255 #define PT_STOP15       0x1
256 #define PT_STOP2        0x2
257
258 #define PT_NOPARITY     0x0
259 #define PT_ODDPARITY    0x1
260 #define PT_EVENPARITY   0x2
261 #define PT_MARKPARITY   0x3
262 #define PT_SPACEPARITY  0x4
263
264 #define F_NONE          0x0
265 #define F_IXON          0x1
266 #define F_IXOFF         0x2
267 #define F_IXANY         0x4
268 #define F_IOXANY        0x8
269 #define F_RTSFLOW       0x10
270 #define F_CTSFLOW       0x20
271 #define F_DTRFLOW       0x40
272 #define F_DCDFLOW       0x80
273 #define F_DSROFLOW      0x100
274 #define F_DSRIFLOW      0x200
275
276 #define FI_NORX         0x1
277 #define FI_RAW          0x2
278 #define FI_ISTRIP       0x4
279 #define FI_UCLC         0x8
280 #define FI_INLCR        0x10
281 #define FI_ICRNL        0x20
282 #define FI_IGNCR        0x40
283 #define FI_IGNBREAK     0x80
284 #define FI_DSCRDBREAK   0x100
285 #define FI_1MARKBREAK   0x200
286 #define FI_2MARKBREAK   0x400
287 #define FI_XCHNGBREAK   0x800
288 #define FI_IGNRXERRS    0x1000
289 #define FI_DSCDRXERRS   0x2000
290 #define FI_1MARKRXERRS  0x4000
291 #define FI_2MARKRXERRS  0x8000
292 #define FI_XCHNGRXERRS  0x10000
293 #define FI_DSCRDNULL    0x20000
294
295 #define FO_OLCUC        0x1
296 #define FO_ONLCR        0x2
297 #define FO_OOCRNL       0x4
298 #define FO_ONOCR        0x8
299 #define FO_ONLRET       0x10
300 #define FO_ONL          0x20
301 #define FO_OBS          0x40
302 #define FO_OVT          0x80
303 #define FO_OFF          0x100
304 #define FO_OTAB1        0x200
305 #define FO_OTAB2        0x400
306 #define FO_OTAB3        0x800
307 #define FO_OCR1         0x1000
308 #define FO_OCR2         0x2000
309 #define FO_OCR3         0x4000
310 #define FO_OFILL        0x8000
311 #define FO_ODELL        0x10000
312
313 #define P_RTSLOCK       0x1
314 #define P_CTSLOCK       0x2
315 #define P_MAPRTS        0x4
316 #define P_MAPCTS        0x8
317 #define P_LOOPBACK      0x10
318 #define P_DTRFOLLOW     0x20
319 #define P_FAKEDCD       0x40
320
321 #define P_RXIMIN        0x10000
322 #define P_RXITIME       0x20000
323 #define P_RXTHOLD       0x40000
324
325 /*
326  *      Define a structure to communicate serial port signal and data state
327  *      information.
328  */
329 typedef struct asysigs {
330         unsigned long   data;
331         unsigned long   signal;
332         unsigned long   sigvalue;
333 } asysigs_t;
334
335 #define DT_TXBUSY       0x1
336 #define DT_TXEMPTY      0x2
337 #define DT_TXLOW        0x4
338 #define DT_TXHIGH       0x8
339 #define DT_TXFULL       0x10
340 #define DT_TXHOG        0x20
341 #define DT_TXFLOWED     0x40
342 #define DT_TXBREAK      0x80
343
344 #define DT_RXBUSY       0x100
345 #define DT_RXEMPTY      0x200
346 #define DT_RXLOW        0x400
347 #define DT_RXHIGH       0x800
348 #define DT_RXFULL       0x1000
349 #define DT_RXHOG        0x2000
350 #define DT_RXFLOWED     0x4000
351 #define DT_RXBREAK      0x8000
352
353 #define SG_DTR          0x1
354 #define SG_DCD          0x2
355 #define SG_RTS          0x4
356 #define SG_CTS          0x8
357 #define SG_DSR          0x10
358 #define SG_RI           0x20
359
360 /*
361  *      Define the notification setting structure. This is used to tell the
362  *      port what events we want to be informed about. Fields here use the
363  *      same defines as for the asysigs structure above.
364  */
365 typedef struct asynotify {
366         unsigned long   ctrl;
367         unsigned long   data;
368         unsigned long   signal;
369         unsigned long   sigvalue;
370 } asynotify_t;
371
372 /*
373  *      Define the port control structure. It is used to do fine grain
374  *      control operations on the port.
375  */
376 typedef struct {
377         unsigned long   rxctrl;
378         unsigned long   txctrl;
379         char            rximdch;
380         char            tximdch;
381         char            spare1;
382         char            spare2;
383 } asyctrl_t;
384
385 #define CT_ENABLE       0x1
386 #define CT_DISABLE      0x2
387 #define CT_STOP         0x4
388 #define CT_START        0x8
389 #define CT_STARTFLOW    0x10
390 #define CT_STOPFLOW     0x20
391 #define CT_SENDCHR      0x40
392
393 /*
394  *      Define the stats structure kept for each port. This is a useful set
395  *      of data collected for each port on the slave. The A_GETSTATS command
396  *      is used to retrive this data from the slave.
397  */
398 typedef struct asystats {
399         unsigned long   opens;
400         unsigned long   txchars;
401         unsigned long   rxchars;
402         unsigned long   txringq;
403         unsigned long   rxringq;
404         unsigned long   txmsgs;
405         unsigned long   rxmsgs;
406         unsigned long   txflushes;
407         unsigned long   rxflushes;
408         unsigned long   overruns;
409         unsigned long   framing;
410         unsigned long   parity;
411         unsigned long   ringover;
412         unsigned long   lost;
413         unsigned long   rxstart;
414         unsigned long   rxstop;
415         unsigned long   txstart;
416         unsigned long   txstop;
417         unsigned long   dcdcnt;
418         unsigned long   dtrcnt;
419         unsigned long   ctscnt;
420         unsigned long   rtscnt;
421         unsigned long   dsrcnt;
422         unsigned long   ricnt;
423         unsigned long   txbreaks;
424         unsigned long   rxbreaks;
425         unsigned long   signals;
426         unsigned long   state;
427         unsigned long   hwid;
428 } asystats_t;
429
430 /*****************************************************************************/
431
432 /*
433  *      All command and control communication with a device on the slave is
434  *      via a control block in shared memory. Each device has its own control
435  *      block, defined by the following structure. The control block allows
436  *      the host to open, close and control the device on the slave.
437  */
438 typedef struct cdkctrl {
439         unsigned char   open;
440         unsigned char   close;
441         unsigned long   openarg;
442         unsigned long   closearg;
443         unsigned long   cmd;
444         unsigned long   status;
445         unsigned long   args[32];
446 } cdkctrl_t;
447
448 /*
449  *      Each device on the slave passes data to and from the host via a ring
450  *      queue in shared memory. Define a ring queue structure to hold the
451  *      vital information about each ring queue. Two ring queues will be
452  *      allocated for each port, one for reveice data and one for transmit
453  *      data.
454  */
455 typedef struct cdkasyrq {
456         unsigned long   offset;
457         unsigned short  size;
458         unsigned short  head;
459         unsigned short  tail;
460 } cdkasyrq_t;
461
462 /*
463  *      Each asynchronous port is defined in shared memory by the following
464  *      structure. It contains a control block to command a device, and also
465  *      the neccessary data channel information as well.
466  */
467 typedef struct cdkasy {
468         cdkctrl_t       ctrl;
469         unsigned short  notify;
470         asynotify_t     changed;
471         unsigned short  receive;
472         cdkasyrq_t      rxq;
473         unsigned short  transmit;
474         cdkasyrq_t      txq;
475 } cdkasy_t;
476
477 #pragma pack()
478
479 /*****************************************************************************/
480
481 /*
482  *      Define the set of ioctls used by the driver to do special things
483  *      to the board. These include interrupting it, and initializeing
484  *      the driver after board startup and shutdown.
485  */
486 #define STL_BINTR       _IO('s', 20)
487 #define STL_BSTART      _IO('s', 21)
488 #define STL_BSTOP       _IO('s', 22)
489 #define STL_BRESET      _IO('s', 23)
490
491 /*
492  *      Define a set of ioctl extensions, used to get at special stuff.
493  */
494 #define STL_GETPFLAG    _IOR('s', 80, unsigned long)
495 #define STL_SETPFLAG    _IOW('s', 81, unsigned long)
496
497 /*****************************************************************************/
498
499 #endif