2 * Copyright (c) Comtrol Corporation <support@comtrol.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted prodived that the follwoing conditions
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.
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
34 * Begin OS-specific defines - rpreg.h - for RocketPort FreeBSD
37 typedef unsigned char Byte_t;
38 typedef unsigned int ByteIO_t;
40 typedef unsigned int Word_t;
41 typedef unsigned int WordIO_t;
43 typedef unsigned long DWord_t;
44 typedef unsigned int DWordIO_t;
46 #define sOutB(a, b) outb(a, b)
47 #define sOutW(a, b) outw(a, b)
48 #define sOutDW(a, b) outl(a, b)
49 #define sInB(a) (inb(a))
50 #define sInW(a) (inw(a))
51 #define sOutStrW(port, addr, count) outsw(port, addr, count)
52 #define sInStrW(port, addr, count) insw(port, addr, count)
55 * End of OS-specific defines
61 #define AIOP_CTL_SIZE 4
62 #define CHAN_AIOP_SIZE 8
63 #define MAX_PORTS_PER_AIOP 8
64 #define MAX_AIOPS_PER_BOARD 4
65 #define MAX_PORTS_PER_BOARD 32
72 /* Controller ID numbers */
73 #define CTLID_NULL -1 /* no controller exists */
74 #define CTLID_0001 0x0001 /* controller release 1 */
77 #define RP_VENDOR_ID 0x11FE
78 #define RP_DEVICE_ID_8OCTA 0x0001
79 #define RP_DEVICE_ID_8INTF 0x0002
80 #define RP_DEVICE_ID_16INTF 0x0003
81 #define RP_DEVICE_ID_32INTF 0x0004
83 /* AIOP ID numbers, identifies AIOP type implementing channel */
84 #define AIOPID_NULL -1 /* no AIOP or channel exists */
85 #define AIOPID_0001 0x0001 /* AIOP release 1 */
87 #define NULLDEV -1 /* identifies non-existant device */
88 #define NULLCTL -1 /* identifies non-existant controller */
89 #define NULLCTLPTR (CONTROLLER_T *)0 /* identifies non-existant controller */
90 #define NULLAIOP -1 /* identifies non-existant AIOP */
91 #define NULLCHAN -1 /* identifies non-existant channel */
93 /************************************************************************
94 Global Register Offsets - Direct Access - Fixed values
95 ************************************************************************/
97 #define _CMD_REG 0x38 /* Command Register 8 Write */
98 #define _INT_CHAN 0x39 /* Interrupt Channel Register 8 Read */
99 #define _INT_MASK 0x3A /* Interrupt Mask Register 8 Read / Write */
100 #define _UNUSED 0x3B /* Unused 8 */
101 #define _INDX_ADDR 0x3C /* Index Register Address 16 Write */
102 #define _INDX_DATA 0x3E /* Index Register Data 8/16 Read / Write */
104 /************************************************************************
105 Channel Register Offsets for 1st channel in AIOP - Direct Access
106 ************************************************************************/
107 #define _TD0 0x00 /* Transmit Data 16 Write */
108 #define _RD0 0x00 /* Receive Data 16 Read */
109 #define _CHN_STAT0 0x20 /* Channel Status 8/16 Read / Write */
110 #define _FIFO_CNT0 0x10 /* Transmit/Receive FIFO Count 16 Read */
111 #define _INT_ID0 0x30 /* Interrupt Identification 8 Read */
113 /************************************************************************
114 Tx Control Register Offsets - Indexed - External - Fixed
115 ************************************************************************/
116 #define _TX_ENBLS 0x980 /* Tx Processor Enables Register 8 Read / Write */
117 #define _TXCMP1 0x988 /* Transmit Compare Value #1 8 Read / Write */
118 #define _TXCMP2 0x989 /* Transmit Compare Value #2 8 Read / Write */
119 #define _TXREP1B1 0x98A /* Tx Replace Value #1 - Byte 1 8 Read / Write */
120 #define _TXREP1B2 0x98B /* Tx Replace Value #1 - Byte 2 8 Read / Write */
121 #define _TXREP2 0x98C /* Transmit Replace Value #2 8 Read / Write */
123 /************************************************************************
125 ************************************************************************/
126 #define RXFIFO_DATA 0x5f
127 #define RXFIFO_OUT 0x5c
128 #define RXFIFO_EN 0x08
129 #define RXFIFO_DIS 0xa7
131 /************************************************************************
132 Memory Controller Register Offsets - Indexed - External - Fixed
133 ************************************************************************/
134 #define _RX_FIFO 0x000 /* Rx FIFO */
135 #define _TX_FIFO 0x800 /* Tx FIFO */
136 #define _RXF_OUTP 0x990 /* Rx FIFO OUT pointer 16 Read / Write */
137 #define _RXF_INP 0x992 /* Rx FIFO IN pointer 16 Read / Write */
138 #define _TXF_OUTP 0x994 /* Tx FIFO OUT pointer 8 Read / Write */
139 #define _TXF_INP 0x995 /* Tx FIFO IN pointer 8 Read / Write */
140 #define _TXP_CNT 0x996 /* Tx Priority Count 8 Read / Write */
141 #define _TXP_PNTR 0x997 /* Tx Priority Pointer 8 Read / Write */
143 #define PRI_PEND 0x80 /* Priority data pending (bit7, Tx pri cnt) */
144 #define TXFIFO_SIZE 255 /* size of Tx FIFO */
145 #define RXFIFO_SIZE 1023 /* size of Rx FIFO */
147 /************************************************************************
148 Tx Priority Buffer - Indexed - External - Fixed
149 ************************************************************************/
150 #define _TXP_BUF 0x9C0 /* Tx Priority Buffer 32 Bytes Read / Write */
151 #define TXP_SIZE 0x20 /* 32 bytes */
153 /************************************************************************
154 Channel Register Offsets - Indexed - Internal - Fixed
155 ************************************************************************/
157 #define _TX_CTRL 0xFF0 /* Transmit Control 16 Write */
158 #define _RX_CTRL 0xFF2 /* Receive Control 8 Write */
159 #define _BAUD 0xFF4 /* Baud Rate 16 Write */
160 #define _CLK_PRE 0xFF6 /* Clock Prescaler 8 Write */
162 #define CLOCK_PRESC 0x19 /* mod 9 (divide by 10) prescale */
188 #define STMBREAK 0x08 /* BREAK */
189 #define STMFRAME 0x04 /* framing error */
190 #define STMRCVROVR 0x02 /* receiver over run error */
191 #define STMPARITY 0x01 /* parity error */
192 #define STMERROR (STMBREAK | STMFRAME | STMPARITY)
193 #define STMBREAKH 0x800 /* BREAK */
194 #define STMFRAMEH 0x400 /* framing error */
195 #define STMRCVROVRH 0x200 /* receiver over run error */
196 #define STMPARITYH 0x100 /* parity error */
197 #define STMERRORH (STMBREAKH | STMFRAMEH | STMPARITYH)
199 #define CTS_ACT 0x20 /* CTS input asserted */
200 #define DSR_ACT 0x10 /* DSR input asserted */
201 #define CD_ACT 0x08 /* CD input asserted */
202 #define TXFIFOMT 0x04 /* Tx FIFO is empty */
203 #define TXSHRMT 0x02 /* Tx shift register is empty */
204 #define RDA 0x01 /* Rx data available */
205 #define DRAINED (TXFIFOMT | TXSHRMT) /* indicates Tx is drained */
207 #define STATMODE 0x8000 /* status mode enable bit */
208 #define RXFOVERFL 0x2000 /* receive FIFO overflow */
209 #define RX2MATCH 0x1000 /* receive compare byte 2 match */
210 #define RX1MATCH 0x0800 /* receive compare byte 1 match */
211 #define RXBREAK 0x0400 /* received BREAK */
212 #define RXFRAME 0x0200 /* received framing error */
213 #define RXPARITY 0x0100 /* received parity error */
214 #define STATERROR (RXBREAK | RXFRAME | RXPARITY)
216 #define CTSFC_EN 0x80 /* CTS flow control enable bit */
217 #define RTSTOG_EN 0x40 /* RTS toggle enable bit */
218 #define TXINT_EN 0x10 /* transmit interrupt enable */
219 #define STOP2 0x08 /* enable 2 stop bits (0 = 1 stop) */
220 #define PARITY_EN 0x04 /* enable parity (0 = no parity) */
221 #define EVEN_PAR 0x02 /* even parity (0 = odd parity) */
222 #define DATA8BIT 0x01 /* 8 bit data (0 = 7 bit data) */
224 #define SETBREAK 0x10 /* send break condition (must clear) */
225 #define LOCALLOOP 0x08 /* local loopback set for test */
226 #define SET_DTR 0x04 /* assert DTR */
227 #define SET_RTS 0x02 /* assert RTS */
228 #define TX_ENABLE 0x01 /* enable transmitter */
230 #define RTSFC_EN 0x40 /* RTS flow control enable */
231 #define RXPROC_EN 0x20 /* receive processor enable */
232 #define TRIG_NO 0x00 /* Rx FIFO trigger level 0 (no trigger) */
233 #define TRIG_1 0x08 /* trigger level 1 char */
234 #define TRIG_1_2 0x10 /* trigger level 1/2 */
235 #define TRIG_7_8 0x18 /* trigger level 7/8 */
236 #define TRIG_MASK 0x18 /* trigger level mask */
237 #define SRCINT_EN 0x04 /* special Rx condition interrupt enable */
238 #define RXINT_EN 0x02 /* Rx interrupt enable */
239 #define MCINT_EN 0x01 /* modem change interrupt enable */
241 #define RXF_TRIG 0x20 /* Rx FIFO trigger level interrupt */
242 #define TXFIFO_MT 0x10 /* Tx FIFO empty interrupt */
243 #define SRC_INT 0x08 /* special receive condition interrupt */
244 #define DELTA_CD 0x04 /* CD change interrupt */
245 #define DELTA_CTS 0x02 /* CTS change interrupt */
246 #define DELTA_DSR 0x01 /* DSR change interrupt */
248 #define REP1W2_EN 0x10 /* replace byte 1 with 2 bytes enable */
249 #define IGN2_EN 0x08 /* ignore byte 2 enable */
250 #define IGN1_EN 0x04 /* ignore byte 1 enable */
251 #define COMP2_EN 0x02 /* compare byte 2 enable */
252 #define COMP1_EN 0x01 /* compare byte 1 enable */
254 #define RESET_ALL 0x80 /* reset AIOP (all channels) */
255 #define TXOVERIDE 0x40 /* Transmit software off override */
256 #define RESETUART 0x20 /* reset channel's UART */
257 #define RESTXFCNT 0x10 /* reset channel's Tx FIFO count register */
258 #define RESRXFCNT 0x08 /* reset channel's Rx FIFO count register */
260 #define INTSTAT0 0x01 /* AIOP 0 interrupt status */
261 #define INTSTAT1 0x02 /* AIOP 1 interrupt status */
262 #define INTSTAT2 0x04 /* AIOP 2 interrupt status */
263 #define INTSTAT3 0x08 /* AIOP 3 interrupt status */
265 #define INTR_EN 0x08 /* allow interrupts to host */
266 #define INT_STROB 0x04 /* strobe and clear interrupt line (EOI) */
268 /**************************************************************************
269 MUDBAC remapped for PCI
270 **************************************************************************/
272 #define _CFG_INT_PCI 0x40
273 #define _PCI_INT_FUNC 0x3A
275 #define PCI_STROB 0x2000
276 #define INTR_EN_PCI 0x0010
278 #define CHAN3_EN 0x08 /* enable AIOP 3 */
279 #define CHAN2_EN 0x04 /* enable AIOP 2 */
280 #define CHAN1_EN 0x02 /* enable AIOP 1 */
281 #define CHAN0_EN 0x01 /* enable AIOP 0 */
282 #define FREQ_DIS 0x00
283 #define FREQ_274HZ 0x60
284 #define FREQ_137HZ 0x50
285 #define FREQ_69HZ 0x40
286 #define FREQ_34HZ 0x30
287 #define FREQ_17HZ 0x20
288 #define FREQ_9HZ 0x10
289 #define PERIODIC_ONLY 0x80 /* only PERIODIC interrupt */
291 #define CHANINT_EN 0x0100 /* flags to enable/disable channel ints */
294 #define RREGDATASIZE 52
296 /* Controller level information structure */
310 WordIO_t AiopIO[AIOP_CTL_SIZE];
311 ByteIO_t AiopIntChanIO[AIOP_CTL_SIZE];
312 int AiopID[AIOP_CTL_SIZE];
313 int AiopNumChan[AIOP_CTL_SIZE];
316 typedef CONTROLLER_T CONTROLLER_t;
318 /* Channel level information structure */
345 Byte_t R[RREGDATASIZE];
352 Byte_t TxReplace1[4];
353 Byte_t TxReplace2[4];
356 typedef CHANNEL_T CHANNEL_t;
357 typedef CHANNEL_T * CHANPTR_T;
359 /***************************************************************************
361 Purpose: Stop sending a transmit BREAK signal
363 CHANNEL_T *ChP; Ptr to channel structure
365 #define sClrBreak(ChP) \
367 (ChP)->TxControl[3] &= ~SETBREAK; \
368 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
371 /***************************************************************************
373 Purpose: Clr the DTR output
375 CHANNEL_T *ChP; Ptr to channel structure
377 #define sClrDTR(ChP) \
379 (ChP)->TxControl[3] &= ~SET_DTR; \
380 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
383 /***************************************************************************
385 Purpose: Clr the RTS output
387 CHANNEL_T *ChP; Ptr to channel structure
389 #define sClrRTS(ChP) \
391 (ChP)->TxControl[3] &= ~SET_RTS; \
392 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
395 /***************************************************************************
397 Purpose: Clear any existing transmit software flow control off condition
398 Call: sClrTxXOFF(ChP)
399 CHANNEL_T *ChP; Ptr to channel structure
401 #define sClrTxXOFF(ChP) \
403 sOutB((ChP)->Cmd,TXOVERIDE | (Byte_t)(ChP)->ChanNum); \
404 sOutB((ChP)->Cmd,(Byte_t)(ChP)->ChanNum); \
407 /***************************************************************************
408 Function: sCtlNumToCtlPtr
409 Purpose: Convert a controller number to controller structure pointer
410 Call: sCtlNumToCtlPtr(CtlNum)
411 int CtlNum; Controller number
412 Return: CONTROLLER_T *: Ptr to controller structure
414 #define sCtlNumToCtlPtr(CTLNUM) &sController[CTLNUM]
416 /***************************************************************************
417 Function: sControllerEOI
418 Purpose: Strobe the MUDBAC's End Of Interrupt bit.
419 Call: sControllerEOI(CtlP)
420 CONTROLLER_T *CtlP; Ptr to controller structure
422 #define sControllerEOI(CTLP) sOutB((CTLP)->MReg2IO,(CTLP)->MReg2 | INT_STROB)
425 /***************************************************************************
426 Function: sPCIControllerEOI
427 Purpose: Strobe the MUDBAC's End Of Interrupt bit.
428 Call: sPCIControllerEOI(CtlP)
429 CONTROLLER_T *CtlP; Ptr to controller structure
431 #define sPCIControllerEOI(CTLP) sOutW((CTLP)->PCIIO, PCI_STROB)
433 /***************************************************************************
435 Purpose: Disable I/O access to an AIOP
437 CONTROLLER_T *CtlP; Ptr to controller structure
438 int AiopNum; Number of AIOP on controller
440 #define sDisAiop(CTLP,AIOPNUM) \
442 (CTLP)->MReg3 &= sBitMapClrTbl[AIOPNUM]; \
443 sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
446 /***************************************************************************
447 Function: sDisCTSFlowCtl
448 Purpose: Disable output flow control using CTS
449 Call: sDisCTSFlowCtl(ChP)
450 CHANNEL_T *ChP; Ptr to channel structure
452 #define sDisCTSFlowCtl(ChP) \
454 (ChP)->TxControl[2] &= ~CTSFC_EN; \
455 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
458 /***************************************************************************
460 Purpose: Disable parity
461 Call: sDisParity(ChP)
462 CHANNEL_T *ChP; Ptr to channel structure
463 Comments: Function sSetParity() can be used in place of functions sEnParity(),
464 sDisParity(), sSetOddParity(), and sSetEvenParity().
466 #define sDisParity(ChP) \
468 (ChP)->TxControl[2] &= ~PARITY_EN; \
469 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
472 /***************************************************************************
474 Purpose: Disable Rx FIFO
475 Call: sDisRxFIFO(ChP)
476 CHANNEL_T *ChP; Ptr to channel structure
478 #define sDisRxFIFO(ChP) \
480 (ChP)->R[0x32] = 0x0a; \
481 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
484 /***************************************************************************
485 Function: sDisRxStatusMode
486 Purpose: Disable the Rx status mode
487 Call: sDisRxStatusMode(ChP)
488 CHANNEL_T *ChP; Ptr to channel structure
489 Comments: This takes the channel out of the receive status mode. All
490 subsequent reads of receive data using sReadRxWord() will return
493 #define sDisRxStatusMode(ChP) sOutW((ChP)->ChanStat,0)
495 /***************************************************************************
496 Function: sDisTransmit
497 Purpose: Disable transmit
498 Call: sDisTransmit(ChP)
499 CHANNEL_T *ChP; Ptr to channel structure
500 This disables movement of Tx data from the Tx FIFO into the 1 byte
501 Tx buffer. Therefore there could be up to a 2 byte latency
502 between the time sDisTransmit() is called and the transmit buffer
503 and transmit shift register going completely empty.
505 #define sDisTransmit(ChP) \
507 (ChP)->TxControl[3] &= ~TX_ENABLE; \
508 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
511 /***************************************************************************
512 Function: sDisTxSoftFlowCtl
513 Purpose: Disable Tx Software Flow Control
514 Call: sDisTxSoftFlowCtl(ChP)
515 CHANNEL_T *ChP; Ptr to channel structure
517 #define sDisTxSoftFlowCtl(ChP) \
519 (ChP)->R[0x06] = 0x8a; \
520 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
523 /***************************************************************************
525 Purpose: Enable I/O access to an AIOP
527 CONTROLLER_T *CtlP; Ptr to controller structure
528 int AiopNum; Number of AIOP on controller
530 #define sEnAiop(CTLP,AIOPNUM) \
532 (CTLP)->MReg3 |= sBitMapSetTbl[AIOPNUM]; \
533 sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
536 /***************************************************************************
537 Function: sEnCTSFlowCtl
538 Purpose: Enable output flow control using CTS
539 Call: sEnCTSFlowCtl(ChP)
540 CHANNEL_T *ChP; Ptr to channel structure
542 #define sEnCTSFlowCtl(ChP) \
544 (ChP)->TxControl[2] |= CTSFC_EN; \
545 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
548 /***************************************************************************
550 Purpose: Enable parity
552 CHANNEL_T *ChP; Ptr to channel structure
553 Comments: Function sSetParity() can be used in place of functions sEnParity(),
554 sDisParity(), sSetOddParity(), and sSetEvenParity().
556 Warnings: Before enabling parity odd or even parity should be chosen using
557 functions sSetOddParity() or sSetEvenParity().
559 #define sEnParity(ChP) \
561 (ChP)->TxControl[2] |= PARITY_EN; \
562 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
565 /***************************************************************************
566 Function: sEnRTSFlowCtl
569 #define sEnRTSFlowCtl(ChP) \
571 (ChP)->TxControl[2] &= ~RTSTOG_EN; \
572 (ChP)->TxControl[3] &= ~SET_RTS; \
573 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
574 (ChP)->RxControl[2] |= RTSFC_EN; \
575 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
578 /***************************************************************************
579 Function: sDisRTSFlowCtl
582 #define sDisRTSFlowCtl(ChP) \
584 (ChP)->RxControl[2] &= ~RTSFC_EN; \
585 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
588 /***************************************************************************
590 Purpose: Enable Rx FIFO
592 CHANNEL_T *ChP; Ptr to channel structure
594 #define sEnRxFIFO(ChP) \
596 (ChP)->R[0x32] = 0x08; \
597 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
600 /***************************************************************************
601 Function: sEnRxProcessor
602 Purpose: Enable the receive processor
603 Call: sEnRxProcessor(ChP)
604 CHANNEL_T *ChP; Ptr to channel structure
605 Comments: This function is used to start the receive processor. When
606 the channel is in the reset state the receive processor is not
607 running. This is done to prevent the receive processor from
608 executing invalid microcode instructions prior to the
609 downloading of the microcode.
611 Warnings: This function must be called after valid microcode has been
612 downloaded to the AIOP, and it must not be called before the
613 microcode has been downloaded.
615 #define sEnRxProcessor(ChP) \
617 (ChP)->RxControl[2] |= RXPROC_EN; \
618 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
621 /***************************************************************************
622 Function: sEnRxStatusMode
623 Purpose: Enable the Rx status mode
624 Call: sEnRxStatusMode(ChP)
625 CHANNEL_T *ChP; Ptr to channel structure
626 Comments: This places the channel in the receive status mode. All subsequent
627 reads of receive data using sReadRxWord() will return a data byte
628 in the low word and a status byte in the high word.
631 #define sEnRxStatusMode(ChP) sOutW((ChP)->ChanStat,STATMODE)
633 /***************************************************************************
634 Function: sEnTransmit
635 Purpose: Enable transmit
636 Call: sEnTransmit(ChP)
637 CHANNEL_T *ChP; Ptr to channel structure
639 #define sEnTransmit(ChP) \
641 (ChP)->TxControl[3] |= TX_ENABLE; \
642 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
645 /***************************************************************************
646 Function: sGetAiopIntStatus
647 Purpose: Get the AIOP interrupt status
648 Call: sGetAiopIntStatus(CtlP,AiopNum)
649 CONTROLLER_T *CtlP; Ptr to controller structure
650 int AiopNum; AIOP number
651 Return: Byte_t: The AIOP interrupt status. Bits 0 through 7
652 represent channels 0 through 7 respectively. If a
653 bit is set that channel is interrupting.
655 #define sGetAiopIntStatus(CTLP,AIOPNUM) sInB((CTLP)->AiopIntChanIO[AIOPNUM])
657 /***************************************************************************
658 Function: sGetAiopNumChan
659 Purpose: Get the number of channels supported by an AIOP
660 Call: sGetAiopNumChan(CtlP,AiopNum)
661 CONTROLLER_T *CtlP; Ptr to controller structure
662 int AiopNum; AIOP number
663 Return: int: The number of channels supported by the AIOP
665 #define sGetAiopNumChan(CTLP,AIOPNUM) (CTLP)->AiopNumChan[AIOPNUM]
667 /***************************************************************************
668 Function: sGetChanIntID
669 Purpose: Get a channel's interrupt identification byte
670 Call: sGetChanIntID(ChP)
671 CHANNEL_T *ChP; Ptr to channel structure
672 Return: Byte_t: The channel interrupt ID. Can be any
673 combination of the following flags:
674 RXF_TRIG: Rx FIFO trigger level interrupt
675 TXFIFO_MT: Tx FIFO empty interrupt
676 SRC_INT: Special receive condition interrupt
677 DELTA_CD: CD change interrupt
678 DELTA_CTS: CTS change interrupt
679 DELTA_DSR: DSR change interrupt
681 #define sGetChanIntID(ChP) (sInB((ChP)->IntID) & (RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR))
683 /***************************************************************************
684 Function: sGetChanNum
685 Purpose: Get the number of a channel within an AIOP
686 Call: sGetChanNum(ChP)
687 CHANNEL_T *ChP; Ptr to channel structure
688 Return: int: Channel number within AIOP, or NULLCHAN if channel does
691 #define sGetChanNum(ChP) (ChP)->ChanNum
693 /***************************************************************************
694 Function: sGetChanStatus
695 Purpose: Get the channel status
696 Call: sGetChanStatus(ChP)
697 CHANNEL_T *ChP; Ptr to channel structure
698 Return: Word_t: The channel status. Can be any combination of
701 CTS_ACT: CTS input asserted
702 DSR_ACT: DSR input asserted
703 CD_ACT: CD input asserted
704 TXFIFOMT: Tx FIFO is empty
705 TXSHRMT: Tx shift register is empty
706 RDA: Rx data available
709 STATMODE: status mode enable bit
710 RXFOVERFL: receive FIFO overflow
711 RX2MATCH: receive compare byte 2 match
712 RX1MATCH: receive compare byte 1 match
713 RXBREAK: received BREAK
714 RXFRAME: received framing error
715 RXPARITY: received parity error
716 Warnings: This function will clear the high byte flags in the Channel
719 #define sGetChanStatus(ChP) sInW((ChP)->ChanStat)
721 /***************************************************************************
722 Function: sGetChanStatusLo
723 Purpose: Get the low byte only of the channel status
724 Call: sGetChanStatusLo(ChP)
725 CHANNEL_T *ChP; Ptr to channel structure
726 Return: Byte_t: The channel status low byte. Can be any combination
727 of the following flags:
728 CTS_ACT: CTS input asserted
729 DSR_ACT: DSR input asserted
730 CD_ACT: CD input asserted
731 TXFIFOMT: Tx FIFO is empty
732 TXSHRMT: Tx shift register is empty
733 RDA: Rx data available
735 #define sGetChanStatusLo(ChP) sInB((ByteIO_t)(ChP)->ChanStat)
737 /***************************************************************************
738 Function: sGetControllerIntStatus
739 Purpose: Get the controller interrupt status
740 Call: sGetControllerIntStatus(CtlP)
741 CONTROLLER_T *CtlP; Ptr to controller structure
742 Return: Byte_t: The controller interrupt status in the lower 4
743 bits. Bits 0 through 3 represent AIOP's 0
744 through 3 respectively. If a bit is set that
745 AIOP is interrupting. Bits 4 through 7 will
748 #define sGetControllerIntStatus(CTLP) (sInB((CTLP)->MReg1IO) & 0x0f)
750 /***************************************************************************
751 Function: sPCIGetControllerIntStatus
752 Purpose: Get the controller interrupt status
753 Call: sPCIGetControllerIntStatus(CtlP)
754 CONTROLLER_T *CtlP; Ptr to controller structure
755 Return: Byte_t: The controller interrupt status in the lower 4
756 bits. Bits 0 through 3 represent AIOP's 0
757 through 3 respectively. If a bit is set that
758 AIOP is interrupting. Bits 4 through 7 will
761 #define sPCIGetControllerIntStatus(CTLP) ((sInW((CTLP)->PCIIO) >> 8) & 0x1f)
763 /***************************************************************************
765 Purpose: Get the number of data bytes in the Rx FIFO
767 CHANNEL_T *ChP; Ptr to channel structure
768 Return: int: The number of data bytes in the Rx FIFO.
769 Comments: Byte read of count register is required to obtain Rx count.
772 #define sGetRxCnt(ChP) sInW((ChP)->TxRxCount)
774 /***************************************************************************
776 Purpose: Get the number of data bytes in the Tx FIFO
778 CHANNEL_T *ChP; Ptr to channel structure
779 Return: Byte_t: The number of data bytes in the Tx FIFO.
780 Comments: Byte read of count register is required to obtain Tx count.
783 #define sGetTxCnt(ChP) sInB((ByteIO_t)(ChP)->TxRxCount)
785 /*****************************************************************************
786 Function: sGetTxRxDataIO
787 Purpose: Get the I/O address of a channel's TxRx Data register
788 Call: sGetTxRxDataIO(ChP)
789 CHANNEL_T *ChP; Ptr to channel structure
790 Return: WordIO_t: I/O address of a channel's TxRx Data register
792 #define sGetTxRxDataIO(ChP) (ChP)->TxRxData
794 /***************************************************************************
795 Function: sInitChanDefaults
796 Purpose: Initialize a channel structure to its default state.
797 Call: sInitChanDefaults(ChP)
798 CHANNEL_T *ChP; Ptr to the channel structure
799 Comments: This function must be called once for every channel structure
800 that exists before any other SSCI calls can be made.
803 #define sInitChanDefaults(ChP) \
805 (ChP)->CtlP = NULLCTLPTR; \
806 (ChP)->AiopNum = NULLAIOP; \
807 (ChP)->ChanID = AIOPID_NULL; \
808 (ChP)->ChanNum = NULLCHAN; \
811 /***************************************************************************
812 Function: sResetAiopByNum
813 Purpose: Reset the AIOP by number
814 Call: sResetAiopByNum(CTLP,AIOPNUM)
815 CONTROLLER_T CTLP; Ptr to controller structure
818 #define sResetAiopByNum(CTLP,AIOPNUM) \
820 sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,RESET_ALL); \
821 sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,0x0); \
824 /***************************************************************************
826 Purpose: Send a transmit BREAK signal
827 Call: sSendBreak(ChP)
828 CHANNEL_T *ChP; Ptr to channel structure
830 #define sSendBreak(ChP) \
832 (ChP)->TxControl[3] |= SETBREAK; \
833 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
836 /***************************************************************************
838 Purpose: Set baud rate
839 Call: sSetBaud(ChP,Divisor)
840 CHANNEL_T *ChP; Ptr to channel structure
841 Word_t Divisor; 16 bit baud rate divisor for channel
843 #define sSetBaud(ChP,DIVISOR) \
845 (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
846 (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
847 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->BaudDiv[0]); \
850 /***************************************************************************
852 Purpose: Set data bits to 7
854 CHANNEL_T *ChP; Ptr to channel structure
856 #define sSetData7(ChP) \
858 (ChP)->TxControl[2] &= ~DATA8BIT; \
859 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
862 /***************************************************************************
864 Purpose: Set data bits to 8
866 CHANNEL_T *ChP; Ptr to channel structure
868 #define sSetData8(ChP) \
870 (ChP)->TxControl[2] |= DATA8BIT; \
871 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
874 /***************************************************************************
876 Purpose: Set the DTR output
878 CHANNEL_T *ChP; Ptr to channel structure
880 #define sSetDTR(ChP) \
882 (ChP)->TxControl[3] |= SET_DTR; \
883 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
886 /***************************************************************************
887 Function: sSetEvenParity
888 Purpose: Set even parity
889 Call: sSetEvenParity(ChP)
890 CHANNEL_T *ChP; Ptr to channel structure
891 Comments: Function sSetParity() can be used in place of functions sEnParity(),
892 sDisParity(), sSetOddParity(), and sSetEvenParity().
894 Warnings: This function has no effect unless parity is enabled with function
897 #define sSetEvenParity(ChP) \
899 (ChP)->TxControl[2] |= EVEN_PAR; \
900 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
903 /***************************************************************************
904 Function: sSetOddParity
905 Purpose: Set odd parity
906 Call: sSetOddParity(ChP)
907 CHANNEL_T *ChP; Ptr to channel structure
908 Comments: Function sSetParity() can be used in place of functions sEnParity(),
909 sDisParity(), sSetOddParity(), and sSetEvenParity().
911 Warnings: This function has no effect unless parity is enabled with function
914 #define sSetOddParity(ChP) \
916 (ChP)->TxControl[2] &= ~EVEN_PAR; \
917 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
920 /***************************************************************************
922 Purpose: Set the RTS output
924 CHANNEL_T *ChP; Ptr to channel structure
926 #define sSetRTS(ChP) \
928 (ChP)->TxControl[3] |= SET_RTS; \
929 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
932 /***************************************************************************
933 Function: sSetRxTrigger
934 Purpose: Set the Rx FIFO trigger level
935 Call: sSetRxProcessor(ChP,Level)
936 CHANNEL_T *ChP; Ptr to channel structure
937 Byte_t Level; Number of characters in Rx FIFO at which the
938 interrupt will be generated. Can be any of the following flags:
941 TRIG_1: 1 character in FIFO
942 TRIG_1_2: FIFO 1/2 full
943 TRIG_7_8: FIFO 7/8 full
944 Comments: An interrupt will be generated when the trigger level is reached
945 only if function sEnInterrupt() has been called with flag
946 RXINT_EN set. The RXF_TRIG flag in the Interrupt Idenfification
947 register will be set whenever the trigger level is reached
948 regardless of the setting of RXINT_EN.
951 #define sSetRxTrigger(ChP,LEVEL) \
953 (ChP)->RxControl[2] &= ~TRIG_MASK; \
954 (ChP)->RxControl[2] |= LEVEL; \
955 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
958 /***************************************************************************
960 Purpose: Set stop bits to 1
962 CHANNEL_T *ChP; Ptr to channel structure
964 #define sSetStop1(ChP) \
966 (ChP)->TxControl[2] &= ~STOP2; \
967 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
970 /***************************************************************************
972 Purpose: Set stop bits to 2
974 CHANNEL_T *ChP; Ptr to channel structure
976 #define sSetStop2(ChP) \
978 (ChP)->TxControl[2] |= STOP2; \
979 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
982 /***************************************************************************
983 Function: sStartRxProcessor
984 Purpose: Start a channel's receive processor
985 Call: sStartRxProcessor(ChP)
986 CHANNEL_T *ChP; Ptr to channel structure
987 Comments: This function is used to start a Rx processor after it was
988 stopped with sStopRxProcessor() or sStopSWInFlowCtl(). It
989 will restart both the Rx processor and software input flow control.
992 #define sStartRxProcessor(ChP) sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0])
994 /***************************************************************************
995 Function: sWriteTxByte
996 Purpose: Write a transmit data byte to a channel.
997 ByteIO_t io: Channel transmit register I/O address. This can
998 be obtained with sGetTxRxDataIO().
999 Byte_t Data; The transmit data byte.
1000 Warnings: This function writes the data byte without checking to see if
1001 sMaxTxSize is exceeded in the Tx FIFO.
1003 #define sWriteTxByte(IO,DATA) sOutB(IO,DATA)
1005 int sInitController( CONTROLLER_T *CtlP,
1008 ByteIO_t *AiopIOList,
1014 int sPCIInitController( CONTROLLER_T *CtlP,
1016 ByteIO_t *AiopIOList,
1022 int sReadAiopID(ByteIO_t io);
1023 int sReadAiopNumChan(WordIO_t io);
1024 int sInitChan( CONTROLLER_T *CtlP,
1028 Byte_t sGetRxErrStatus(CHANNEL_T *ChP);
1029 void sStopRxProcessor(CHANNEL_T *ChP);
1030 void sStopSWInFlowCtl(CHANNEL_T *ChP);
1031 void sFlushRxFIFO(CHANNEL_T *ChP);
1032 void sFlushTxFIFO(CHANNEL_T *ChP);
1033 int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data);
1034 void sEnInterrupts(CHANNEL_T *ChP,Word_t Flags);
1035 void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags);
1038 extern Byte_t R[RDATASIZE];
1039 extern CONTROLLER_T sController[CTL_SIZE];
1040 extern Byte_t sIRQMap[16];
1041 extern Byte_t sBitMapClrTbl[8];
1042 extern Byte_t sBitMapSetTbl[8];