home *** CD-ROM | disk | FTP | other *** search
- /* This file contains various defines for the FAS async driver.
- If you change anything here you have to recompile the driver module.
- */
-
- #ident "@(#)fas.h 2.06"
-
- #include <sys/param.h>
- #include <sys/types.h>
- #include <sys/signal.h>
- #include <sys/buf.h>
- #include <sys/iobuf.h>
- #include <sys/dir.h>
- #include <sys/user.h>
- #include <sys/errno.h>
- #include <sys/tty.h>
- #include <sys/conf.h>
- #include <sys/sysinfo.h>
- #include <sys/file.h>
- #include <sys/termio.h>
- #include <sys/ioctl.h>
- #include <macros.h>
-
- #if defined (TRUE)
- #undef TRUE
- #endif
- #define TRUE (1)
-
- #if defined (FALSE)
- #undef FALSE
- #endif
- #define FALSE (0)
-
- /* Uncomment the following line if you need init8250. DosMerge needs
- this function, but only if you link the kernel without the original
- asy driver.
- */
- /* #define NEED_INIT8250 /* */
-
- /* Uncomment the following line if you need asyputchar and asygetchar.
- Bell Tech needs these. uPort has them burried in the kd device.
- */
- /* #define NEED_PUT_GETCHAR /* */
-
- /* Initial line control register. Value will only be meaningful for
- asyputchar and asygetchar and they are only meaningful if
- NEED_PUT_GETCHAR is defined.
- */
- #define INITIAL_LINE_CONTROL LC_WORDLEN_8
-
- /* Initial baud rate. Value will only be meaningful for
- asyputchar and asygetchar and they are only meaningful if
- NEED_PUT_GETCHAR is defined.
- */
- #define INITIAL_BAUD_RATE (BAUD_BASE/9600)
-
- /* Initial modem control register. This should probably not have to
- be touched. It is here because some terminals used as the console
- require one or more of the modem signals set. It is only meaningful
- for asyputchar and asygetchar and they are only meaningful if
- NEED_PUT_GETCHAR is defined.
- */
- #define INITIAL_MDM_CONTROL 0
-
- /****************************************************/
- /* Nothing past this line should have to be changed */
- /****************************************************/
-
- #define NUM_INT_VECTORS 16 /* sixteen vectors possible but only
- the first eight are normally used
- */
-
- #define MAX_UNITS 16 /* we will only use that many units */
-
- /* Miscellaneous Constants */
-
- #define BAUD_BASE (1843200 / 16) /* 115200 bps */
- #define HANGUP_DELAY ((HZ) / 4) /* 250 msec */
- #define HANGUP_TIME (HZ) /* 1 sec */
- #define BREAK_TIME ((HZ) / 4) /* 250 msec */
- #define ADAPT_TIME ((HZ) * 2) /* 2 sec */
- #define RECV_BUFF_SIZE 5000 /* receiver ring buffer size (MAX) */
- #define SW_LOW_WATER 2500 /* 50% MAX sw flow control */
- #define SW_HIGH_WATER 4000 /* 80% MAX trigger levels */
- #define HW_LOW_WATER 4500 /* MAX - 500 hw flow control */
- #define HW_HIGH_WATER 4900 /* MAX - 100 trigger levels */
- #define XMIT_BUFF_SIZE 2500 /* transmitter ring buffer size */
-
-
- /* Here are the modem control flags for the fas_modem array in space.c.
- They are arranged in three 8-bit masks which are combined to a 32-bit
- word. Each of these 32-bit words represents one entry in the fas_modem
- array.
-
- The lowest byte is used as a mask to manipulate the modem control
- register for modem enable. Use the MC_* macros to build the mask.
-
- The second lowest byte is used to mask signals from the modem status
- register that will be used as the carrier detect signal. Use the MS_*
- macros to build the mask and shift them 8 bits to the left. If you use
- more than one signal, carrier is considered on only when all signals
- are on.
-
- The second highes byte is used to mask signals from the modem status
- register that will be used as the unblock signal. Use the MS_* macros
- to build the mask and shift them 16 bits to the left. If you use more
- than one signal, unblock occurs only when all signals are on.
-
- The highest byte is reserved for future use.
-
- Here are some useful macros for the space.c file. You may create your
- own macros if you have some special requirements not met by the
- predefined ones.
- */
-
- /* modem enable (chose one) */
- #define EN_RTS MC_SET_RTS /* RTS enables modem */
- #define EN_DTR MC_SET_DTR /* DTR enables modem */
- #define EN_RTS_AND_DTR (MC_SET_RTS | MC_SET_DTR)
-
- /* carrier detect signal (chose one) */
- #define CA_DCD (MS_DCD_PRESENT << 8) /* DCD is carr. detect */
- #define CA_CTS (MS_CTS_PRESENT << 8) /* CTS is carr. detect */
- #define CA_DSR (MS_DSR_PRESENT << 8) /* DSR is carr. detect */
-
- /* unblock signal (chose one) */
- #define UB_DCD (MS_DCD_PRESENT << 16) /* DCD is unblock */
- #define UB_RING (MS_RING_PRESENT << 16) /* RING is unblock */
-
-
- /* Here are the hardware handshake flags for the fas_flow array in space.c.
- They are arranged in three 8-bit masks which are combined to a 32-bit
- word. Each of these 32-bit words represents one entry in the fas_flow
- array.
-
- The lowest byte is used as a mask to manipulate the modem control
- register for input flow control. Use the MC_* macros to build the mask.
-
- The second lowest byte is used to mask signals from the modem status
- register that will be used for output flow control. Use the MS_* macros
- to build the mask and shift them 8 bits to the left. If you use more
- than one signal, output is allowed only when all signals are on.
-
- The second highest byte is used to mask signals from the modem status
- register that will be used to enable the output flow control selected
- by the second lowest byte. Use the MS_* macros to build the mask and
- shift them 16 bits to the left. If you use more than one signal, output
- flow control is enabled only when all signals are on.
-
- The highest byte is reserved for future use.
-
- Here are some useful macros for the space.c file. You may create your
- own macros if you have some special requirements not met by the
- predefined ones.
- */
-
- /* input flow control (chose one) */
- #define HI_RTS MC_SET_RTS /* RTS input flow ctrl */
- #define HI_DTR MC_SET_DTR /* DTR input flow ctrl */
- #define HI_RTS_AND_DTR (MC_SET_RTS | MC_SET_DTR)
-
- /* output flow control (chose one) */
- #define HO_CTS (MS_CTS_PRESENT << 8) /* CTS output flow ctrl */
- #define HO_DSR (MS_DSR_PRESENT << 8) /* DSR output flow ctrl */
- #define HO_CTS_AND_DSR ((MS_CTS_PRESENT | MS_DSR_PRESENT) << 8)
- #define HO_CTS_ON_DSR ((MS_CTS_PRESENT << 8) | (MS_DSR_PRESENT << 16))
- #define HO_CTS_ON_DSR_AND_DCD ((MS_CTS_PRESENT << 8) \
- | ((MS_DSR_PRESENT | MS_DCD_PRESENT) << 16))
-
-
- /* define the local open flags */
-
- #define OS_DEVICE_CLOSED 0x0000
- #define OS_OPEN_FOR_DIALOUT 0x0001
- #define OS_OPEN_FOR_GETTY 0x0002
- #define OS_WAIT_OPEN 0x0004
- #define OS_NO_DIALOUT 0x0008
- #define OS_CHECK_CARR_ON_OPEN 0x0010
- #define OS_FAKE_CARR_ON 0x0020
- #define OS_UNBLOCK_ENABLE 0x0040
- #define OS_CLOCAL 0x0080
- #define OS_HW_HANDSHAKE 0x0100
- #define OS_EXCLUSIVE_OPEN 0x0200 /* SYSV 3.2 Xenix compatibility */
-
- #define OS_OPEN_STATES (OS_OPEN_FOR_DIALOUT | OS_OPEN_FOR_GETTY)
- #define OS_TEST_MASK (OS_OPEN_FOR_DIALOUT | OS_NO_DIALOUT \
- | OS_CHECK_CARR_ON_OPEN | OS_FAKE_CARR_ON \
- | OS_UNBLOCK_ENABLE | OS_CLOCAL \
- | OS_HW_HANDSHAKE | OS_EXCLUSIVE_OPEN)
-
- /* define the device status flags */
-
- #define DF_DEVICE_CONFIGURED 0x0001 /* device is configured */
- #define DF_DEVICE_HAS_FIFO 0x0002 /* it's an NS16550 */
- #define DF_DEVICE_OPEN 0x0004 /* physical device is open */
- #define DF_DEVICE_LOCKED 0x0008 /* physical device locked */
- #define DF_MODEM_ENABLED 0x0010 /* modem enabled */
- #define DF_SWO_STOPPED 0x0020 /* output stopped by sw flow control */
- #define DF_SWI_STOPPED 0x0040 /* input stopped by sw flow control */
- #define DF_SW_FC_REQ 0x0080 /* sw input flow control request */
- #define DF_HWO_STOPPED 0x0100 /* output stopped by hw handshake */
- #define DF_HWI_STOPPED 0x0200 /* input stopped by hw handshake */
- #define DF_XMIT_DISABLED 0x0400 /* transmitter is disabled */
- #define DF_XMIT_BUSY 0x0800 /* transmitter is busy */
- #define DF_DO_HANGUP 0x1000 /* delayed hangup request */
- #define DF_DO_BREAK 0x2000 /* delayed break request */
- #define DF_GUARD_TIMEOUT 0x4000 /* protect last char from corruption */
- #define DF_ADAPT_TIMEOUT 0x8000 /* transmitter was used recently */
-
- /* define an easy way to refenence the absolute port addresses */
-
- #define RCV_DATA_PORT (fip->uart_port_0)
- #define XMT_DATA_PORT (fip->uart_port_0)
- #define INT_ENABLE_PORT (fip->uart_port_1)
- #define INT_ID_PORT (fip->uart_port_2)
- #define FIFO_CTL_PORT (fip->uart_port_2)
- #define LINE_CTL_PORT (fip->uart_port_3)
- #define MDM_CTL_PORT (fip->uart_port_4)
- #define LINE_STATUS_PORT (fip->uart_port_5)
- #define MDM_STATUS_PORT (fip->uart_port_6)
- #define DIVISOR_LSB_PORT (fip->uart_port_0)
- #define DIVISOR_MSB_PORT (fip->uart_port_1)
- #define INT_ACK_PORT (fip->int_ack_port)
-
- /* modem control port */
-
- #define MC_SET_DTR 0x01
- #define MC_SET_RTS 0x02
- #define MC_SET_OUT1 0x04
- #define MC_SET_OUT2 0x08 /* tristates int line when false */
- #define MC_SET_LOOPBACK 0x10
-
- /* modem status port */
-
- #define MS_CTS_PRESENT 0x10
- #define MS_DSR_PRESENT 0x20
- #define MS_RING_PRESENT 0x40
- #define MS_DCD_PRESENT 0x80
-
- #define MS_ANY_PRESENT (MS_CTS_PRESENT | MS_DSR_PRESENT | MS_RING_PRESENT \
- | MS_DCD_PRESENT)
-
- /* interrupt enable port */
-
- #define IE_NONE 0x00
- #define IE_RECV_DATA_AVAILABLE 0x01
- #define IE_XMIT_HOLDING_BUFFER_EMPTY 0x02
- #define IE_LINE_STATUS 0x04
- #define IE_MODEM_STATUS 0x08
-
- #define IE_INIT_MODE (IE_RECV_DATA_AVAILABLE | IE_XMIT_HOLDING_BUFFER_EMPTY \
- | IE_LINE_STATUS | IE_MODEM_STATUS)
-
- /* interrupt id port */
-
- #define II_NO_INTS_PENDING 0x01
- #define II_CODE_MASK 0x07
- #define II_MODEM_STATE 0x00
- #define II_XMTD_CHAR 0x02
- #define II_RCVD_CHAR 0x04
- #define II_RCV_ERROR 0x06
- #define II_FIFO_TIMEOUT 0x08
- #define II_FIFO_ENABLED 0xC0
-
- /* line control port */
-
- #define LC_WORDLEN_MASK 0x03
- #define LC_WORDLEN_5 0x00
- #define LC_WORDLEN_6 0x01
- #define LC_WORDLEN_7 0x02
- #define LC_WORDLEN_8 0x03
- #define LC_STOPBITS_LONG 0x04
- #define LC_ENABLE_PARITY 0x08
- #define LC_EVEN_PARITY 0x10
- #define LC_STICK_PARITY 0x20
- #define LC_SET_BREAK_LEVEL 0x40
- #define LC_ENABLE_DIVISOR 0x80
-
- /* line status port */
-
- #define LS_RCV_AVAIL 0x01
- #define LS_OVERRUN 0x02
- #define LS_PARITY_ERROR 0x04
- #define LS_FRAMING_ERROR 0x08
- #define LS_BREAK_DETECTED 0x10
- #define LS_XMIT_AVAIL 0x20
- #define LS_XMIT_COMPLETE 0x40
- #define LS_ERROR_IN_FIFO 0x80 /* NS16550 only */
-
- #define LS_RCV_INT (LS_RCV_AVAIL | LS_OVERRUN | LS_PARITY_ERROR \
- | LS_FRAMING_ERROR | LS_BREAK_DETECTED)
-
- /* fifo control port (NS16550 only) */
-
- #define FIFO_ENABLE 0x01
- #define FIFO_CLR_RECV 0x02
- #define FIFO_CLR_XMIT 0x04
- #define FIFO_START_DMA 0x08
- #define FIFO_SIZE_1 0x00
- #define FIFO_SIZE_4 0x40
- #define FIFO_SIZE_8 0x80
- #define FIFO_SIZE_14 0xC0
- #define FIFO_SIZE_MASK 0xC0
-
- #define STANDARD_FIFO_CLEAR 0
- #define STANDARD_FIFO_SETUP (FIFO_SIZE_8 | FIFO_ENABLE)
- #define STANDARD_FIFO_INIT (STANDARD_FIFO_SETUP | FIFO_CLR_RECV \
- | FIFO_CLR_XMIT)
-
- #define INPUT_FIFO_SIZE 16
- #define OUTPUT_FIFO_SIZE 16
-
-
- /* This structure contains everything one would like to know about
- an open device. There is one of these for each physical unit.
-
- We use several unions to eliminate most integer type conversions
- at run-time. The standard UNIX V 3.X/386 C compiler forces all
- operands in expressions and all function parameters to type int.
- To save some time, with the means of unions we deliver type int
- at the proper locations while dealing with the original type
- wherever int would be slower.
-
- This is highly compiler implementation specific. But for the sake
- of speed the end justifies the means.
- */
-
- struct fas_info
- {
- struct tty *tty; /* the tty structure */
- struct fas_info *prev_int_user;/* link to previous fas_info struct */
- struct fas_info *next_int_user;/* link to next fas_info struct */
- uint vec; /* interrupt vector for this struct */
- uint iflag; /* current terminal input flags */
- uint cflag; /* current terminal hardware control flags */
- union { /* flags about the device */
- ushort s;
- uint i;
- } device_flags;
- uint o_state; /* current open state */
- uint po_state; /* previous open state */
- union { /* modem control masks */
- struct {
- unchar en; /* mask for modem enable */
- unchar ca; /* mask for carrier detect */
- unchar ub; /* mask for unblock signal */
- } m;
- uint i;
- } modem;
- union { /* hardware flow control masks */
- struct {
- unchar ic; /* control mask for inp. flow ctrl */
- unchar oc; /* control mask for outp. flow ctrl */
- unchar oe; /* enable mask for outp. flow ctrl */
- } m;
- uint i;
- } flow;
- uint msr; /* modem status register value */
- union { /* modem control register value */
- unchar c;
- uint i;
- } mcr;
- union { /* line control register value */
- unchar c;
- uint i;
- } lcr;
- union { /* interrupt enable register value */
- unchar c;
- uint i;
- } ier;
- uint timeout_idx; /* timeout index for untimeout () */
- uint uart_port_0; /* uart port 0 address */
- uint uart_port_1; /* uart port 1 address */
- uint uart_port_2; /* uart port 2 address */
- uint uart_port_3; /* uart port 3 address */
- uint uart_port_4; /* uart port 4 address */
- uint uart_port_5; /* uart port 5 address */
- uint uart_port_6; /* uart port 6 address */
- uint int_ack_port; /* int ack port address */
- uint int_ack; /* int ack value */
- uint recv_ring_cnt; /* receiver ring buffer counter */
- unchar *recv_ring_put_ptr; /* recv ring buf put ptr */
- unchar *recv_ring_take_ptr; /* recv ring buf take ptr */
- uint xmit_ring_size; /* transmitter ring buffer size */
- uint xmit_ring_cnt; /* transmitter ring buffer counter */
- unchar *xmit_ring_put_ptr; /* xmit ring buf put ptr */
- unchar *xmit_ring_take_ptr; /* xmit ring buf take ptr */
- unchar recv_buffer [RECV_BUFF_SIZE]; /* recv ring buf */
- unchar xmit_buffer [XMIT_BUFF_SIZE]; /* xmit ring buf */
- };
-