Increase the default TCP maximum segment size from 512 to 1460.
[dragonfly.git] / sys / dev / serial / rp2 / rpreg.h
1 /* 
2  * Copyright (c) Comtrol Corporation <support@comtrol.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted prodived that the follwoing conditions
7  * are met.
8  * 1. Redistributions of source code must retain the above copyright 
9  *    notive, this list of conditions and the following disclainer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials prodided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *       This product includes software developed by Comtrol Corporation.
16  * 4. The name of Comtrol Corporation may not be used to endorse or 
17  *    promote products derived from this software without specific 
18  *    prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY COMTROL CORPORATION ``AS IS'' AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL COMTROL CORPORATION BE LIABLE FOR
24  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  * $FreeBSD: src/sys/i386/isa/rpreg.h,v 1.2.6.1 2000/08/03 01:01:20 peter Exp $
33  * $DragonFly: src/sys/dev/serial/rp2/Attic/rpreg.h,v 1.2 2003/06/17 04:28:37 dillon Exp $
34  */
35
36 /*
37  * Begin OS-specific defines -  rpreg.h - for RocketPort FreeBSD
38  */
39
40 typedef unsigned char Byte_t;
41 typedef unsigned int ByteIO_t;
42
43 typedef unsigned int Word_t;
44 typedef unsigned int WordIO_t;
45
46 typedef unsigned long DWord_t;
47 typedef unsigned int DWordIO_t;
48
49 #define sOutB(a, b) outb(a, b)
50 #define sOutW(a, b) outw(a, b)
51 #define sOutDW(a, b) outl(a, b)
52 #define sInB(a) (inb(a))
53 #define sInW(a) (inw(a))
54 #define sOutStrW(port, addr, count) outsw(port, addr, count)
55 #define sInStrW(port, addr, count) insw(port, addr, count)
56
57 /*
58  * End of OS-specific defines
59  */
60
61 #define ROCKET_H
62
63 #define CTL_SIZE 4
64 #define AIOP_CTL_SIZE 4
65 #define CHAN_AIOP_SIZE 8
66 #define MAX_PORTS_PER_AIOP 8
67 #define MAX_AIOPS_PER_BOARD 4
68 #define MAX_PORTS_PER_BOARD 32
69
70 /* Bus Type ID */
71 #define isISA   0
72 #define isPCI   1
73 #define isMC    2
74
75 /* Controller ID numbers */
76 #define CTLID_NULL  -1              /* no controller exists */
77 #define CTLID_0001  0x0001          /* controller release 1 */
78
79 /* PCI IDs  */
80 #define RP_VENDOR_ID            0x11FE
81 #define RP_DEVICE_ID_8OCTA      0x0001
82 #define RP_DEVICE_ID_8INTF      0x0002
83 #define RP_DEVICE_ID_16INTF     0x0003
84 #define RP_DEVICE_ID_32INTF     0x0004
85
86 /* AIOP ID numbers, identifies AIOP type implementing channel */
87 #define AIOPID_NULL -1              /* no AIOP or channel exists */
88 #define AIOPID_0001 0x0001          /* AIOP release 1 */
89
90 #define NULLDEV -1                  /* identifies non-existant device */
91 #define NULLCTL -1                  /* identifies non-existant controller */
92 #define NULLCTLPTR (CONTROLLER_T *)0 /* identifies non-existant controller */
93 #define NULLAIOP -1                 /* identifies non-existant AIOP */
94 #define NULLCHAN -1                 /* identifies non-existant channel */
95
96 /************************************************************************
97  Global Register Offsets - Direct Access - Fixed values
98 ************************************************************************/
99
100 #define _CMD_REG   0x38   /* Command Register            8    Write */
101 #define _INT_CHAN  0x39   /* Interrupt Channel Register  8    Read */
102 #define _INT_MASK  0x3A   /* Interrupt Mask Register     8    Read / Write */
103 #define _UNUSED    0x3B   /* Unused                      8 */
104 #define _INDX_ADDR 0x3C   /* Index Register Address      16   Write */
105 #define _INDX_DATA 0x3E   /* Index Register Data         8/16 Read / Write */
106
107 /************************************************************************
108  Channel Register Offsets for 1st channel in AIOP - Direct Access
109 ************************************************************************/
110 #define _TD0       0x00  /* Transmit Data               16   Write */
111 #define _RD0       0x00  /* Receive Data                16   Read */
112 #define _CHN_STAT0 0x20  /* Channel Status              8/16 Read / Write */
113 #define _FIFO_CNT0 0x10  /* Transmit/Receive FIFO Count 16   Read */
114 #define _INT_ID0   0x30  /* Interrupt Identification    8    Read */
115
116 /************************************************************************
117  Tx Control Register Offsets - Indexed - External - Fixed
118 ************************************************************************/
119 #define _TX_ENBLS  0x980    /* Tx Processor Enables Register 8 Read / Write */
120 #define _TXCMP1    0x988    /* Transmit Compare Value #1     8 Read / Write */
121 #define _TXCMP2    0x989    /* Transmit Compare Value #2     8 Read / Write */
122 #define _TXREP1B1  0x98A    /* Tx Replace Value #1 - Byte 1  8 Read / Write */
123 #define _TXREP1B2  0x98B    /* Tx Replace Value #1 - Byte 2  8 Read / Write */
124 #define _TXREP2    0x98C    /* Transmit Replace Value #2     8 Read / Write */
125
126 /************************************************************************
127  Receive FIFO
128 ************************************************************************/
129 #define RXFIFO_DATA     0x5f
130 #define RXFIFO_OUT      0x5c
131 #define RXFIFO_EN       0x08
132 #define RXFIFO_DIS      0xa7
133
134 /************************************************************************
135 Memory Controller Register Offsets - Indexed - External - Fixed
136 ************************************************************************/
137 #define _RX_FIFO    0x000    /* Rx FIFO */
138 #define _TX_FIFO    0x800    /* Tx FIFO */
139 #define _RXF_OUTP   0x990    /* Rx FIFO OUT pointer        16 Read / Write */
140 #define _RXF_INP    0x992    /* Rx FIFO IN pointer         16 Read / Write */
141 #define _TXF_OUTP   0x994    /* Tx FIFO OUT pointer        8  Read / Write */
142 #define _TXF_INP    0x995    /* Tx FIFO IN pointer         8  Read / Write */
143 #define _TXP_CNT    0x996    /* Tx Priority Count          8  Read / Write */
144 #define _TXP_PNTR   0x997    /* Tx Priority Pointer        8  Read / Write */
145
146 #define PRI_PEND    0x80     /* Priority data pending (bit7, Tx pri cnt) */
147 #define TXFIFO_SIZE 255      /* size of Tx FIFO */
148 #define RXFIFO_SIZE 1023     /* size of Rx FIFO */
149
150 /************************************************************************
151 Tx Priority Buffer - Indexed - External - Fixed
152 ************************************************************************/
153 #define _TXP_BUF    0x9C0    /* Tx Priority Buffer  32  Bytes   Read / Write */
154 #define TXP_SIZE    0x20     /* 32 bytes */
155
156 /************************************************************************
157 Channel Register Offsets - Indexed - Internal - Fixed
158 ************************************************************************/
159
160 #define _TX_CTRL    0xFF0    /* Transmit Control               16  Write */
161 #define _RX_CTRL    0xFF2    /* Receive Control                 8  Write */
162 #define _BAUD       0xFF4    /* Baud Rate                      16  Write */
163 #define _CLK_PRE    0xFF6    /* Clock Prescaler                 8  Write */
164
165 #define CLOCK_PRESC 0x19          /* mod 9 (divide by 10) prescale */
166
167 #define BRD50             4607
168 #define BRD75             3071
169 #define BRD110            2094
170 #define BRD134            1712
171 #define BRD150            1535
172 #define BRD200            1151
173 #define BRD300            767
174 #define BRD600            383
175 #define BRD1200           191
176 #define BRD1800           127
177 #define BRD2000           114
178 #define BRD2400           95
179 #define BRD3600           64
180 #define BRD4800           47
181 #define BRD7200           31
182 #define BRD9600           23
183 #define BRD14400          15
184 #define BRD19200          11
185 #define BRD38400          5
186 #define BRD57600          3
187 #define BRD76800          2
188 #define BRD115200         1
189 #define BRD230400         0
190
191 #define STMBREAK   0x08        /* BREAK */
192 #define STMFRAME   0x04        /* framing error */
193 #define STMRCVROVR 0x02        /* receiver over run error */
194 #define STMPARITY  0x01        /* parity error */
195 #define STMERROR   (STMBREAK | STMFRAME | STMPARITY)
196 #define STMBREAKH   0x800      /* BREAK */
197 #define STMFRAMEH   0x400      /* framing error */
198 #define STMRCVROVRH 0x200      /* receiver over run error */
199 #define STMPARITYH  0x100      /* parity error */
200 #define STMERRORH   (STMBREAKH | STMFRAMEH | STMPARITYH)
201
202 #define CTS_ACT   0x20        /* CTS input asserted */
203 #define DSR_ACT   0x10        /* DSR input asserted */
204 #define CD_ACT    0x08        /* CD input asserted */
205 #define TXFIFOMT  0x04        /* Tx FIFO is empty */
206 #define TXSHRMT   0x02        /* Tx shift register is empty */
207 #define RDA       0x01        /* Rx data available */
208 #define DRAINED (TXFIFOMT | TXSHRMT)  /* indicates Tx is drained */
209
210 #define STATMODE  0x8000      /* status mode enable bit */
211 #define RXFOVERFL 0x2000      /* receive FIFO overflow */
212 #define RX2MATCH  0x1000      /* receive compare byte 2 match */
213 #define RX1MATCH  0x0800      /* receive compare byte 1 match */
214 #define RXBREAK   0x0400      /* received BREAK */
215 #define RXFRAME   0x0200      /* received framing error */
216 #define RXPARITY  0x0100      /* received parity error */
217 #define STATERROR (RXBREAK | RXFRAME | RXPARITY)
218
219 #define CTSFC_EN  0x80        /* CTS flow control enable bit */
220 #define RTSTOG_EN 0x40        /* RTS toggle enable bit */
221 #define TXINT_EN  0x10        /* transmit interrupt enable */
222 #define STOP2     0x08        /* enable 2 stop bits (0 = 1 stop) */
223 #define PARITY_EN 0x04        /* enable parity (0 = no parity) */
224 #define EVEN_PAR  0x02        /* even parity (0 = odd parity) */
225 #define DATA8BIT  0x01        /* 8 bit data (0 = 7 bit data) */
226
227 #define SETBREAK  0x10        /* send break condition (must clear) */
228 #define LOCALLOOP 0x08        /* local loopback set for test */
229 #define SET_DTR   0x04        /* assert DTR */
230 #define SET_RTS   0x02        /* assert RTS */
231 #define TX_ENABLE 0x01        /* enable transmitter */
232
233 #define RTSFC_EN  0x40        /* RTS flow control enable */
234 #define RXPROC_EN 0x20        /* receive processor enable */
235 #define TRIG_NO   0x00        /* Rx FIFO trigger level 0 (no trigger) */
236 #define TRIG_1    0x08        /* trigger level 1 char */
237 #define TRIG_1_2  0x10        /* trigger level 1/2 */
238 #define TRIG_7_8  0x18        /* trigger level 7/8 */
239 #define TRIG_MASK 0x18        /* trigger level mask */
240 #define SRCINT_EN 0x04        /* special Rx condition interrupt enable */
241 #define RXINT_EN  0x02        /* Rx interrupt enable */
242 #define MCINT_EN  0x01        /* modem change interrupt enable */
243
244 #define RXF_TRIG  0x20        /* Rx FIFO trigger level interrupt */
245 #define TXFIFO_MT 0x10        /* Tx FIFO empty interrupt */
246 #define SRC_INT   0x08        /* special receive condition interrupt */
247 #define DELTA_CD  0x04        /* CD change interrupt */
248 #define DELTA_CTS 0x02        /* CTS change interrupt */
249 #define DELTA_DSR 0x01        /* DSR change interrupt */
250
251 #define REP1W2_EN 0x10        /* replace byte 1 with 2 bytes enable */
252 #define IGN2_EN   0x08        /* ignore byte 2 enable */
253 #define IGN1_EN   0x04        /* ignore byte 1 enable */
254 #define COMP2_EN  0x02        /* compare byte 2 enable */
255 #define COMP1_EN  0x01        /* compare byte 1 enable */
256
257 #define RESET_ALL 0x80        /* reset AIOP (all channels) */
258 #define TXOVERIDE 0x40        /* Transmit software off override */
259 #define RESETUART 0x20        /* reset channel's UART */
260 #define RESTXFCNT 0x10        /* reset channel's Tx FIFO count register */
261 #define RESRXFCNT 0x08        /* reset channel's Rx FIFO count register */
262
263 #define INTSTAT0  0x01        /* AIOP 0 interrupt status */
264 #define INTSTAT1  0x02        /* AIOP 1 interrupt status */
265 #define INTSTAT2  0x04        /* AIOP 2 interrupt status */
266 #define INTSTAT3  0x08        /* AIOP 3 interrupt status */
267
268 #define INTR_EN   0x08        /* allow interrupts to host */
269 #define INT_STROB 0x04        /* strobe and clear interrupt line (EOI) */
270
271 /**************************************************************************
272   MUDBAC remapped for PCI
273 **************************************************************************/
274
275 #define _CFG_INT_PCI    0x40
276 #define _PCI_INT_FUNC   0x3A
277
278 #define PCI_STROB       0x2000
279 #define INTR_EN_PCI     0x0010
280
281 #define CHAN3_EN  0x08        /* enable AIOP 3 */
282 #define CHAN2_EN  0x04        /* enable AIOP 2 */
283 #define CHAN1_EN  0x02        /* enable AIOP 1 */
284 #define CHAN0_EN  0x01        /* enable AIOP 0 */
285 #define FREQ_DIS  0x00
286 #define FREQ_274HZ 0x60
287 #define FREQ_137HZ 0x50
288 #define FREQ_69HZ  0x40
289 #define FREQ_34HZ  0x30
290 #define FREQ_17HZ  0x20
291 #define FREQ_9HZ   0x10
292 #define PERIODIC_ONLY 0x80    /* only PERIODIC interrupt */
293
294 #define CHANINT_EN 0x0100           /* flags to enable/disable channel ints */
295
296 #define RDATASIZE 72
297 #define RREGDATASIZE 52
298
299 /* Controller level information structure */
300 typedef struct
301 {
302         int             CtlID;
303         int             CtlNum;
304         int             BusType;
305         WordIO_t        PCIIO;
306         ByteIO_t        MBaseIO;
307         ByteIO_t        MReg1IO;
308         ByteIO_t        MReg2IO;
309         ByteIO_t        MReg3IO;
310         Byte_t          MReg2;
311         Byte_t          MReg3;
312         int             NumAiop;
313         WordIO_t        AiopIO[AIOP_CTL_SIZE];
314         ByteIO_t        AiopIntChanIO[AIOP_CTL_SIZE];
315         int             AiopID[AIOP_CTL_SIZE];
316         int             AiopNumChan[AIOP_CTL_SIZE];
317 } CONTROLLER_T;
318
319 typedef CONTROLLER_T CONTROLLER_t;
320
321 /* Channel level information structure */
322 typedef struct
323 {
324         CONTROLLER_T    *CtlP;
325         int             AiopNum;
326         int             ChanID;
327         int             ChanNum;
328
329         ByteIO_t        Cmd;
330         ByteIO_t        IntChan;
331         ByteIO_t        IntMask;
332         DWordIO_t       IndexAddr;
333         WordIO_t        IndexData;
334
335         WordIO_t        TxRxData;
336         WordIO_t        ChanStat;
337         WordIO_t        TxRxCount;
338         ByteIO_t        IntID;
339
340         Word_t          TxFIFO;
341         Word_t          TxFIFOPtrs;
342         Word_t          RxFIFO;
343         Word_t          RxFIFOPtrs;
344         Word_t          TxPrioCnt;
345         Word_t          TxPrioPtr;
346         Word_t          TxPrioBuf;
347
348         Byte_t          R[RREGDATASIZE];
349
350         Byte_t          BaudDiv[4];
351         Byte_t          TxControl[4];
352         Byte_t          RxControl[4];
353         Byte_t          TxEnables[4];
354         Byte_t          TxCompare[4];
355         Byte_t          TxReplace1[4];
356         Byte_t          TxReplace2[4];
357 } CHANNEL_T;
358
359 typedef CHANNEL_T CHANNEL_t;
360 typedef CHANNEL_T * CHANPTR_T;
361
362 /***************************************************************************
363 Function: sClrBreak
364 Purpose:  Stop sending a transmit BREAK signal
365 Call:     sClrBreak(ChP)
366           CHANNEL_T *ChP; Ptr to channel structure
367 */
368 #define sClrBreak(ChP) \
369 { \
370    (ChP)->TxControl[3] &= ~SETBREAK; \
371    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
372 }
373
374 /***************************************************************************
375 Function: sClrDTR
376 Purpose:  Clr the DTR output
377 Call:     sClrDTR(ChP)
378           CHANNEL_T *ChP; Ptr to channel structure
379 */
380 #define sClrDTR(ChP) \
381 { \
382    (ChP)->TxControl[3] &= ~SET_DTR; \
383    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
384 }
385
386 /***************************************************************************
387 Function: sClrRTS
388 Purpose:  Clr the RTS output
389 Call:     sClrRTS(ChP)
390           CHANNEL_T *ChP; Ptr to channel structure
391 */
392 #define sClrRTS(ChP) \
393 { \
394    (ChP)->TxControl[3] &= ~SET_RTS; \
395    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
396 }
397
398 /***************************************************************************
399 Function: sClrTxXOFF
400 Purpose:  Clear any existing transmit software flow control off condition
401 Call:     sClrTxXOFF(ChP)
402           CHANNEL_T *ChP; Ptr to channel structure
403 */
404 #define sClrTxXOFF(ChP) \
405 { \
406    sOutB((ChP)->Cmd,TXOVERIDE | (Byte_t)(ChP)->ChanNum); \
407    sOutB((ChP)->Cmd,(Byte_t)(ChP)->ChanNum); \
408 }
409
410 /***************************************************************************
411 Function: sCtlNumToCtlPtr
412 Purpose:  Convert a controller number to controller structure pointer
413 Call:     sCtlNumToCtlPtr(CtlNum)
414           int CtlNum; Controller number
415 Return:   CONTROLLER_T *: Ptr to controller structure
416 */
417 #define sCtlNumToCtlPtr(CTLNUM) &sController[CTLNUM]
418
419 /***************************************************************************
420 Function: sControllerEOI
421 Purpose:  Strobe the MUDBAC's End Of Interrupt bit.
422 Call:     sControllerEOI(CtlP)
423           CONTROLLER_T *CtlP; Ptr to controller structure
424 */
425 #define sControllerEOI(CTLP) sOutB((CTLP)->MReg2IO,(CTLP)->MReg2 | INT_STROB)
426
427
428 /***************************************************************************
429 Function: sPCIControllerEOI
430 Purpose:  Strobe the MUDBAC's End Of Interrupt bit.
431 Call:     sPCIControllerEOI(CtlP)
432           CONTROLLER_T *CtlP; Ptr to controller structure
433 */
434 #define sPCIControllerEOI(CTLP) sOutW((CTLP)->PCIIO, PCI_STROB)
435
436 /***************************************************************************
437 Function: sDisAiop
438 Purpose:  Disable I/O access to an AIOP
439 Call:     sDisAiop(CltP)
440           CONTROLLER_T *CtlP; Ptr to controller structure
441           int AiopNum; Number of AIOP on controller
442 */
443 #define sDisAiop(CTLP,AIOPNUM) \
444 { \
445    (CTLP)->MReg3 &= sBitMapClrTbl[AIOPNUM]; \
446    sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
447 }
448
449 /***************************************************************************
450 Function: sDisCTSFlowCtl
451 Purpose:  Disable output flow control using CTS
452 Call:     sDisCTSFlowCtl(ChP)
453           CHANNEL_T *ChP; Ptr to channel structure
454 */
455 #define sDisCTSFlowCtl(ChP) \
456 { \
457    (ChP)->TxControl[2] &= ~CTSFC_EN; \
458    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
459 }
460
461 /***************************************************************************
462 Function: DisParity
463 Purpose:  Disable parity
464 Call:     sDisParity(ChP)
465           CHANNEL_T *ChP; Ptr to channel structure
466 Comments: Function sSetParity() can be used in place of functions sEnParity(),
467           sDisParity(), sSetOddParity(), and sSetEvenParity().
468 */
469 #define sDisParity(ChP) \
470 { \
471    (ChP)->TxControl[2] &= ~PARITY_EN; \
472    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
473 }
474
475 /***************************************************************************
476 Function: sDisRxFIFO
477 Purpose:  Disable Rx FIFO
478 Call:     sDisRxFIFO(ChP)
479           CHANNEL_T *ChP; Ptr to channel structure
480 */
481 #define sDisRxFIFO(ChP) \
482 { \
483    (ChP)->R[0x32] = 0x0a; \
484    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
485 }
486
487 /***************************************************************************
488 Function: sDisRxStatusMode
489 Purpose:  Disable the Rx status mode
490 Call:     sDisRxStatusMode(ChP)
491           CHANNEL_T *ChP; Ptr to channel structure
492 Comments: This takes the channel out of the receive status mode.  All
493           subsequent reads of receive data using sReadRxWord() will return
494           two data bytes.
495 */
496 #define sDisRxStatusMode(ChP) sOutW((ChP)->ChanStat,0)
497
498 /***************************************************************************
499 Function: sDisTransmit
500 Purpose:  Disable transmit
501 Call:     sDisTransmit(ChP)
502           CHANNEL_T *ChP; Ptr to channel structure
503           This disables movement of Tx data from the Tx FIFO into the 1 byte
504           Tx buffer.  Therefore there could be up to a 2 byte latency
505           between the time sDisTransmit() is called and the transmit buffer
506           and transmit shift register going completely empty.
507 */
508 #define sDisTransmit(ChP) \
509 { \
510    (ChP)->TxControl[3] &= ~TX_ENABLE; \
511    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
512 }
513
514 /***************************************************************************
515 Function: sDisTxSoftFlowCtl
516 Purpose:  Disable Tx Software Flow Control
517 Call:     sDisTxSoftFlowCtl(ChP)
518           CHANNEL_T *ChP; Ptr to channel structure
519 */
520 #define sDisTxSoftFlowCtl(ChP) \
521 { \
522    (ChP)->R[0x06] = 0x8a; \
523    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
524 }
525
526 /***************************************************************************
527 Function: sEnAiop
528 Purpose:  Enable I/O access to an AIOP
529 Call:     sEnAiop(CltP)
530           CONTROLLER_T *CtlP; Ptr to controller structure
531           int AiopNum; Number of AIOP on controller
532 */
533 #define sEnAiop(CTLP,AIOPNUM) \
534 { \
535    (CTLP)->MReg3 |= sBitMapSetTbl[AIOPNUM]; \
536    sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
537 }
538
539 /***************************************************************************
540 Function: sEnCTSFlowCtl
541 Purpose:  Enable output flow control using CTS
542 Call:     sEnCTSFlowCtl(ChP)
543           CHANNEL_T *ChP; Ptr to channel structure
544 */
545 #define sEnCTSFlowCtl(ChP) \
546 { \
547    (ChP)->TxControl[2] |= CTSFC_EN; \
548    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
549 }
550
551 /***************************************************************************
552 Function: EnParity
553 Purpose:  Enable parity
554 Call:     sEnParity(ChP)
555           CHANNEL_T *ChP; Ptr to channel structure
556 Comments: Function sSetParity() can be used in place of functions sEnParity(),
557           sDisParity(), sSetOddParity(), and sSetEvenParity().
558
559 Warnings: Before enabling parity odd or even parity should be chosen using
560           functions sSetOddParity() or sSetEvenParity().
561 */
562 #define sEnParity(ChP) \
563 { \
564    (ChP)->TxControl[2] |= PARITY_EN; \
565    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
566 }
567
568 /***************************************************************************
569 Function: sEnRTSFlowCtl
570 Return: void
571 */
572 #define sEnRTSFlowCtl(ChP) \
573 { \
574         (ChP)->TxControl[2] &= ~RTSTOG_EN; \
575         (ChP)->TxControl[3] &= ~SET_RTS; \
576    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
577         (ChP)->RxControl[2] |= RTSFC_EN; \
578    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
579 }
580
581 /***************************************************************************
582 Function: sDisRTSFlowCtl
583 Return: void
584 */
585 #define sDisRTSFlowCtl(ChP) \
586 { \
587         (ChP)->RxControl[2] &= ~RTSFC_EN; \
588    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
589 }
590
591 /***************************************************************************
592 Function: sEnRxFIFO
593 Purpose:  Enable Rx FIFO
594 Call:     sEnRxFIFO(ChP)
595           CHANNEL_T *ChP; Ptr to channel structure
596 */
597 #define sEnRxFIFO(ChP) \
598 { \
599    (ChP)->R[0x32] = 0x08; \
600    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
601 }
602
603 /***************************************************************************
604 Function: sEnRxProcessor
605 Purpose:  Enable the receive processor
606 Call:     sEnRxProcessor(ChP)
607           CHANNEL_T *ChP; Ptr to channel structure
608 Comments: This function is used to start the receive processor.  When
609           the channel is in the reset state the receive processor is not
610           running.  This is done to prevent the receive processor from
611           executing invalid microcode instructions prior to the
612           downloading of the microcode.
613
614 Warnings: This function must be called after valid microcode has been
615           downloaded to the AIOP, and it must not be called before the
616           microcode has been downloaded.
617 */
618 #define sEnRxProcessor(ChP) \
619 { \
620    (ChP)->RxControl[2] |= RXPROC_EN; \
621    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
622 }
623
624 /***************************************************************************
625 Function: sEnRxStatusMode
626 Purpose:  Enable the Rx status mode
627 Call:     sEnRxStatusMode(ChP)
628           CHANNEL_T *ChP; Ptr to channel structure
629 Comments: This places the channel in the receive status mode.  All subsequent
630           reads of receive data using sReadRxWord() will return a data byte
631           in the low word and a status byte in the high word.
632
633 */
634 #define sEnRxStatusMode(ChP) sOutW((ChP)->ChanStat,STATMODE)
635
636 /***************************************************************************
637 Function: sEnTransmit
638 Purpose:  Enable transmit
639 Call:     sEnTransmit(ChP)
640           CHANNEL_T *ChP; Ptr to channel structure
641 */
642 #define sEnTransmit(ChP) \
643 { \
644    (ChP)->TxControl[3] |= TX_ENABLE; \
645    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
646 }
647
648 /***************************************************************************
649 Function: sGetAiopIntStatus
650 Purpose:  Get the AIOP interrupt status
651 Call:     sGetAiopIntStatus(CtlP,AiopNum)
652           CONTROLLER_T *CtlP; Ptr to controller structure
653           int AiopNum; AIOP number
654 Return:   Byte_t: The AIOP interrupt status.  Bits 0 through 7
655                          represent channels 0 through 7 respectively.  If a
656                          bit is set that channel is interrupting.
657 */
658 #define sGetAiopIntStatus(CTLP,AIOPNUM) sInB((CTLP)->AiopIntChanIO[AIOPNUM])
659
660 /***************************************************************************
661 Function: sGetAiopNumChan
662 Purpose:  Get the number of channels supported by an AIOP
663 Call:     sGetAiopNumChan(CtlP,AiopNum)
664           CONTROLLER_T *CtlP; Ptr to controller structure
665           int AiopNum; AIOP number
666 Return:   int: The number of channels supported by the AIOP
667 */
668 #define sGetAiopNumChan(CTLP,AIOPNUM) (CTLP)->AiopNumChan[AIOPNUM]
669
670 /***************************************************************************
671 Function: sGetChanIntID
672 Purpose:  Get a channel's interrupt identification byte
673 Call:     sGetChanIntID(ChP)
674           CHANNEL_T *ChP; Ptr to channel structure
675 Return:   Byte_t: The channel interrupt ID.  Can be any
676              combination of the following flags:
677                 RXF_TRIG:     Rx FIFO trigger level interrupt
678                 TXFIFO_MT:    Tx FIFO empty interrupt
679                 SRC_INT:      Special receive condition interrupt
680                 DELTA_CD:     CD change interrupt
681                 DELTA_CTS:    CTS change interrupt
682                 DELTA_DSR:    DSR change interrupt
683 */
684 #define sGetChanIntID(ChP) (sInB((ChP)->IntID) & (RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR))
685
686 /***************************************************************************
687 Function: sGetChanNum
688 Purpose:  Get the number of a channel within an AIOP
689 Call:     sGetChanNum(ChP)
690           CHANNEL_T *ChP; Ptr to channel structure
691 Return:   int: Channel number within AIOP, or NULLCHAN if channel does
692                not exist.
693 */
694 #define sGetChanNum(ChP) (ChP)->ChanNum
695
696 /***************************************************************************
697 Function: sGetChanStatus
698 Purpose:  Get the channel status
699 Call:     sGetChanStatus(ChP)
700           CHANNEL_T *ChP; Ptr to channel structure
701 Return:   Word_t: The channel status.  Can be any combination of
702              the following flags:
703                 LOW BYTE FLAGS
704                 CTS_ACT:      CTS input asserted
705                 DSR_ACT:      DSR input asserted
706                 CD_ACT:       CD input asserted
707                 TXFIFOMT:     Tx FIFO is empty
708                 TXSHRMT:      Tx shift register is empty
709                 RDA:          Rx data available
710
711                 HIGH BYTE FLAGS
712                 STATMODE:     status mode enable bit
713                 RXFOVERFL:    receive FIFO overflow
714                 RX2MATCH:     receive compare byte 2 match
715                 RX1MATCH:     receive compare byte 1 match
716                 RXBREAK:      received BREAK
717                 RXFRAME:      received framing error
718                 RXPARITY:     received parity error
719 Warnings: This function will clear the high byte flags in the Channel
720           Status Register.
721 */
722 #define sGetChanStatus(ChP) sInW((ChP)->ChanStat)
723
724 /***************************************************************************
725 Function: sGetChanStatusLo
726 Purpose:  Get the low byte only of the channel status
727 Call:     sGetChanStatusLo(ChP)
728           CHANNEL_T *ChP; Ptr to channel structure
729 Return:   Byte_t: The channel status low byte.  Can be any combination
730              of the following flags:
731                 CTS_ACT:      CTS input asserted
732                 DSR_ACT:      DSR input asserted
733                 CD_ACT:       CD input asserted
734                 TXFIFOMT:     Tx FIFO is empty
735                 TXSHRMT:      Tx shift register is empty
736                 RDA:          Rx data available
737 */
738 #define sGetChanStatusLo(ChP) sInB((ByteIO_t)(ChP)->ChanStat)
739
740 /***************************************************************************
741 Function: sGetControllerIntStatus
742 Purpose:  Get the controller interrupt status
743 Call:     sGetControllerIntStatus(CtlP)
744           CONTROLLER_T *CtlP; Ptr to controller structure
745 Return:   Byte_t: The controller interrupt status in the lower 4
746                          bits.  Bits 0 through 3 represent AIOP's 0
747                          through 3 respectively.  If a bit is set that
748                          AIOP is interrupting.  Bits 4 through 7 will
749                          always be cleared.
750 */
751 #define sGetControllerIntStatus(CTLP) (sInB((CTLP)->MReg1IO) & 0x0f)
752
753 /***************************************************************************
754 Function: sPCIGetControllerIntStatus
755 Purpose:  Get the controller interrupt status
756 Call:     sPCIGetControllerIntStatus(CtlP)
757           CONTROLLER_T *CtlP; Ptr to controller structure
758 Return:   Byte_t: The controller interrupt status in the lower 4
759                          bits.  Bits 0 through 3 represent AIOP's 0
760                          through 3 respectively.  If a bit is set that
761                          AIOP is interrupting.  Bits 4 through 7 will
762                          always be cleared.
763 */
764 #define sPCIGetControllerIntStatus(CTLP) ((sInW((CTLP)->PCIIO) >> 8) & 0x1f)
765
766 /***************************************************************************
767 Function: sGetRxCnt
768 Purpose:  Get the number of data bytes in the Rx FIFO
769 Call:     sGetRxCnt(ChP)
770           CHANNEL_T *ChP; Ptr to channel structure
771 Return:   int: The number of data bytes in the Rx FIFO.
772 Comments: Byte read of count register is required to obtain Rx count.
773
774 */
775 #define sGetRxCnt(ChP) sInW((ChP)->TxRxCount)
776
777 /***************************************************************************
778 Function: sGetTxCnt
779 Purpose:  Get the number of data bytes in the Tx FIFO
780 Call:     sGetTxCnt(ChP)
781           CHANNEL_T *ChP; Ptr to channel structure
782 Return:   Byte_t: The number of data bytes in the Tx FIFO.
783 Comments: Byte read of count register is required to obtain Tx count.
784
785 */
786 #define sGetTxCnt(ChP) sInB((ByteIO_t)(ChP)->TxRxCount)
787
788 /*****************************************************************************
789 Function: sGetTxRxDataIO
790 Purpose:  Get the I/O address of a channel's TxRx Data register
791 Call:     sGetTxRxDataIO(ChP)
792           CHANNEL_T *ChP; Ptr to channel structure
793 Return:   WordIO_t: I/O address of a channel's TxRx Data register
794 */
795 #define sGetTxRxDataIO(ChP) (ChP)->TxRxData
796
797 /***************************************************************************
798 Function: sInitChanDefaults
799 Purpose:  Initialize a channel structure to its default state.
800 Call:     sInitChanDefaults(ChP)
801           CHANNEL_T *ChP; Ptr to the channel structure
802 Comments: This function must be called once for every channel structure
803           that exists before any other SSCI calls can be made.
804
805 */
806 #define sInitChanDefaults(ChP) \
807 { \
808    (ChP)->CtlP = NULLCTLPTR; \
809    (ChP)->AiopNum = NULLAIOP; \
810    (ChP)->ChanID = AIOPID_NULL; \
811    (ChP)->ChanNum = NULLCHAN; \
812 }
813
814 /***************************************************************************
815 Function: sResetAiopByNum
816 Purpose:  Reset the AIOP by number
817 Call:     sResetAiopByNum(CTLP,AIOPNUM)
818         CONTROLLER_T CTLP; Ptr to controller structure
819         AIOPNUM; AIOP index
820 */
821 #define sResetAiopByNum(CTLP,AIOPNUM) \
822 { \
823    sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,RESET_ALL); \
824    sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,0x0); \
825 }
826
827 /***************************************************************************
828 Function: sSendBreak
829 Purpose:  Send a transmit BREAK signal
830 Call:     sSendBreak(ChP)
831           CHANNEL_T *ChP; Ptr to channel structure
832 */
833 #define sSendBreak(ChP) \
834 { \
835    (ChP)->TxControl[3] |= SETBREAK; \
836    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
837 }
838
839 /***************************************************************************
840 Function: sSetBaud
841 Purpose:  Set baud rate
842 Call:     sSetBaud(ChP,Divisor)
843           CHANNEL_T *ChP; Ptr to channel structure
844           Word_t Divisor; 16 bit baud rate divisor for channel
845 */
846 #define sSetBaud(ChP,DIVISOR) \
847 { \
848    (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
849    (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
850    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->BaudDiv[0]); \
851 }
852
853 /***************************************************************************
854 Function: sSetData7
855 Purpose:  Set data bits to 7
856 Call:     sSetData7(ChP)
857           CHANNEL_T *ChP; Ptr to channel structure
858 */
859 #define sSetData7(ChP) \
860 { \
861    (ChP)->TxControl[2] &= ~DATA8BIT; \
862    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
863 }
864
865 /***************************************************************************
866 Function: sSetData8
867 Purpose:  Set data bits to 8
868 Call:     sSetData8(ChP)
869           CHANNEL_T *ChP; Ptr to channel structure
870 */
871 #define sSetData8(ChP) \
872 { \
873    (ChP)->TxControl[2] |= DATA8BIT; \
874    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
875 }
876
877 /***************************************************************************
878 Function: sSetDTR
879 Purpose:  Set the DTR output
880 Call:     sSetDTR(ChP)
881           CHANNEL_T *ChP; Ptr to channel structure
882 */
883 #define sSetDTR(ChP) \
884 { \
885    (ChP)->TxControl[3] |= SET_DTR; \
886    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
887 }
888
889 /***************************************************************************
890 Function: sSetEvenParity
891 Purpose:  Set even parity
892 Call:     sSetEvenParity(ChP)
893           CHANNEL_T *ChP; Ptr to channel structure
894 Comments: Function sSetParity() can be used in place of functions sEnParity(),
895           sDisParity(), sSetOddParity(), and sSetEvenParity().
896
897 Warnings: This function has no effect unless parity is enabled with function
898           sEnParity().
899 */
900 #define sSetEvenParity(ChP) \
901 { \
902    (ChP)->TxControl[2] |= EVEN_PAR; \
903    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
904 }
905
906 /***************************************************************************
907 Function: sSetOddParity
908 Purpose:  Set odd parity
909 Call:     sSetOddParity(ChP)
910           CHANNEL_T *ChP; Ptr to channel structure
911 Comments: Function sSetParity() can be used in place of functions sEnParity(),
912           sDisParity(), sSetOddParity(), and sSetEvenParity().
913
914 Warnings: This function has no effect unless parity is enabled with function
915           sEnParity().
916 */
917 #define sSetOddParity(ChP) \
918 { \
919    (ChP)->TxControl[2] &= ~EVEN_PAR; \
920    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
921 }
922
923 /***************************************************************************
924 Function: sSetRTS
925 Purpose:  Set the RTS output
926 Call:     sSetRTS(ChP)
927           CHANNEL_T *ChP; Ptr to channel structure
928 */
929 #define sSetRTS(ChP) \
930 { \
931    (ChP)->TxControl[3] |= SET_RTS; \
932    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
933 }
934
935 /***************************************************************************
936 Function: sSetRxTrigger
937 Purpose:  Set the Rx FIFO trigger level
938 Call:     sSetRxProcessor(ChP,Level)
939           CHANNEL_T *ChP; Ptr to channel structure
940           Byte_t Level; Number of characters in Rx FIFO at which the
941              interrupt will be generated.  Can be any of the following flags:
942
943              TRIG_NO:   no trigger
944              TRIG_1:    1 character in FIFO
945              TRIG_1_2:  FIFO 1/2 full
946              TRIG_7_8:  FIFO 7/8 full
947 Comments: An interrupt will be generated when the trigger level is reached
948           only if function sEnInterrupt() has been called with flag
949           RXINT_EN set.  The RXF_TRIG flag in the Interrupt Idenfification
950           register will be set whenever the trigger level is reached
951           regardless of the setting of RXINT_EN.
952
953 */
954 #define sSetRxTrigger(ChP,LEVEL) \
955 { \
956    (ChP)->RxControl[2] &= ~TRIG_MASK; \
957    (ChP)->RxControl[2] |= LEVEL; \
958    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
959 }
960
961 /***************************************************************************
962 Function: sSetStop1
963 Purpose:  Set stop bits to 1
964 Call:     sSetStop1(ChP)
965           CHANNEL_T *ChP; Ptr to channel structure
966 */
967 #define sSetStop1(ChP) \
968 { \
969    (ChP)->TxControl[2] &= ~STOP2; \
970    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
971 }
972
973 /***************************************************************************
974 Function: sSetStop2
975 Purpose:  Set stop bits to 2
976 Call:     sSetStop2(ChP)
977           CHANNEL_T *ChP; Ptr to channel structure
978 */
979 #define sSetStop2(ChP) \
980 { \
981    (ChP)->TxControl[2] |= STOP2; \
982    sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
983 }
984
985 /***************************************************************************
986 Function: sStartRxProcessor
987 Purpose:  Start a channel's receive processor
988 Call:     sStartRxProcessor(ChP)
989           CHANNEL_T *ChP; Ptr to channel structure
990 Comments: This function is used to start a Rx processor after it was
991           stopped with sStopRxProcessor() or sStopSWInFlowCtl().  It
992           will restart both the Rx processor and software input flow control.
993
994 */
995 #define sStartRxProcessor(ChP) sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0])
996
997 /***************************************************************************
998 Function: sWriteTxByte
999 Purpose:  Write a transmit data byte to a channel.
1000           ByteIO_t io: Channel transmit register I/O address.  This can
1001                            be obtained with sGetTxRxDataIO().
1002           Byte_t Data; The transmit data byte.
1003 Warnings: This function writes the data byte without checking to see if
1004           sMaxTxSize is exceeded in the Tx FIFO.
1005 */
1006 #define sWriteTxByte(IO,DATA) sOutB(IO,DATA)
1007
1008 int sInitController(    CONTROLLER_T *CtlP,
1009                         int CtlNum,
1010                         ByteIO_t MudbacIO,
1011                         ByteIO_t *AiopIOList,
1012                         int AiopIOListSize,
1013                         int IRQNum,
1014                         Byte_t Frequency,
1015                         int PeriodicOnly);
1016
1017 int sPCIInitController( CONTROLLER_T *CtlP,
1018                         int CtlNum,
1019                         ByteIO_t *AiopIOList,
1020                         int AiopIOListSize,
1021                         int IRQNum,
1022                         Byte_t Frequency,
1023                         int PeriodicOnly);
1024
1025 int sReadAiopID(ByteIO_t io);
1026 int sReadAiopNumChan(WordIO_t io);
1027 int sInitChan(  CONTROLLER_T *CtlP,
1028                 CHANNEL_T *ChP,
1029                 int AiopNum,
1030                 int ChanNum);
1031 Byte_t sGetRxErrStatus(CHANNEL_T *ChP);
1032 void sStopRxProcessor(CHANNEL_T *ChP);
1033 void sStopSWInFlowCtl(CHANNEL_T *ChP);
1034 void sFlushRxFIFO(CHANNEL_T *ChP);
1035 void sFlushTxFIFO(CHANNEL_T *ChP);
1036 int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data);
1037 void sEnInterrupts(CHANNEL_T *ChP,Word_t Flags);
1038 void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags);
1039
1040 #ifndef ROCKET_C
1041 extern Byte_t R[RDATASIZE];
1042 extern CONTROLLER_T sController[CTL_SIZE];
1043 extern Byte_t sIRQMap[16];
1044 extern Byte_t sBitMapClrTbl[8];
1045 extern Byte_t sBitMapSetTbl[8];
1046 #endif