Merge branch 'vendor/GREP'
[dragonfly.git] / usr.bin / doscmd / com.h
1 /*
2  * Copyright (c) 1992, 1993, 1996
3  *      Berkeley Software Design, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
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 provided 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 Berkeley Software
16  *      Design, Inc.
17  *
18  * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      BSDI com.h,v 2.2 1996/04/08 19:32:21 bostic Exp
31  *
32  * $FreeBSD: src/usr.bin/doscmd/com.h,v 1.2.2.1 2002/04/25 11:04:50 tg Exp $
33  * $DragonFly: src/usr.bin/doscmd/com.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
34  */
35
36 /* com.h for doscmd int14.c */
37
38 /* NS16550A register definitions */
39
40 /* interrupt enable register */
41
42 #define IE_NOP          0xF0    /* Not used */
43 #define IE_MODEM_STAT   0x08    /* modem status int. */
44 #define IE_LINE_STAT    0x04    /* receiver-line status int. */
45 #define IE_TRANS_HLD    0x02    /* transmitter holding register empty int. */
46 #define IE_RCV_DATA     0x01    /* received data available int. */
47
48 /* interrupt identification register */
49
50 #define II_FIFOS_EN     0xC0    /* if FIFOs are enabled */
51 #define II_NOP          0x30    /* not used */
52 #define II_INT_ID       0x0E    /* mask: bits see below */
53 #define II_PEND_INT     0x01    /* 1=no interrupt pending */
54
55 /* bit masks for II_INT_ID */
56
57 #define II_TO           0x0C
58 #define II_LINE_STAT    0x06
59 #define II_RCV_DATA     0x04
60 #define II_TRANS_HLD    0x02
61 #define II_MODEM_STAT   0x00
62
63 /* FIFO control reg */
64
65 #define FC_FIFO_SZ_MASK 0xC0
66 #define FC_FIFO_1B      0x80
67 #define FC_FIFO_4B      0x40
68 #define FC_FIFO_8B      0x80
69 #define FC_FIFO_14B     0xC0
70 #define FC_FIFO_CTR     0x04
71 #define FC_FIFO_CRV     0x02
72 #define FC_FIFO_EN      0x01
73
74 /* line control register */
75
76 #define LC_DIV_ACC      0x80    /* divisor latch access bit */
77 #define LC_BRK_CTRL     0x40    /* set break control */
78 #define LC_S_PAR        0x20    /* stick parity */
79 #define LC_EVEN_P       0x10    /* even parity select */
80 #define LC_PAR_E        0x08    /* parity enable */
81 #define LC_STOP_B       0x04    /* number of stop bits (0 - 1 bit) */
82 #define LC_W_LEN        0x03    /* unsigned short length (00 - 5, 01 - 6 etc.) */
83
84 /* line status register */
85
86 #define LS_NOP          0x80    /* not used */
87 #define LS_X_DATA_E     0x40    /* 1=empty */
88 #define LS_X_HOLD_E     0x20    /* 1=empty */
89 #define LS_BREAK        0x10    /* break received */
90 #define LS_FRM_ERR      0x08    /* framing error */
91 #define LS_PAR_ERR      0x04    /* parity error */
92 #define LS_OVRN_ERR     0x02    /* overrun error */
93 #define LS_RCV_DATA_RD  0x01    /* data received */
94
95 /* modem status register */
96
97 #define MS_DCD          0x80    /* Data Carrier Detect in */
98 #define MS_RI           0x40    /* Ring Indicator in */
99 #define MS_DSR          0x20    /* Data Set Ready in */
100 #define MS_CTS          0x10    /* Clear To Send in */
101 #define MS_DELTA_DCD    0x08    /* Data Carrier Detect changed state */
102 #define MS_DELTA_RI     0x04    /* Ring Indicator changed state */
103 #define MS_DELTA_DSR    0x02    /* Data Set Ready changed state */
104 #define MS_DELTA_CTS    0x01    /* Clear To Send changed state */
105
106 /* DOS definitions -- parameters */
107
108 #define BITRATE_110     0x00
109 #define BITRATE_150     0x20
110 #define BITRATE_300     0x40
111 #define BITRATE_600     0x60
112 #define BITRATE_1200    0x80
113 #define BITRATE_2400    0xA0
114 #define BITRATE_4800    0xC0
115 #define BITRATE_9600    0xE0
116 #define PARITY_NONE     0x00
117 #define PARITY_ODD      0x08
118 #define PARITY_EVEN     0x18
119 #define STOPBIT_1       0x00
120 #define STOPBIT_2       0x04
121 #define TXLEN_7BITS     0x02
122 #define TXLEN_8BITS     0x03
123
124 #define N_OF_COM_REGS   8
125
126 /* DOS definitions -- return codes */
127
128 #define LS_SW_TIME_OUT  LS_NOP  /* return value used by DOS */
129
130 /* routine declarations */
131
132 void    int14(regcontext_t *REGS);
133 void    init_com(int, char *, int, unsigned char);
134
135 /* end of file com.h */