]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/doscmd/com.h
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.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$
33  */
34
35 /* com.h for doscmd int14.c */
36
37 #define BUFSIZE 1024
38
39 /* NS16550A register definitions */
40
41 /* interrupt enable register */
42
43 #define IE_NOP          0xF0    /* not used */
44 #define IE_MODEM_STAT   0x08    /* modem status int. */
45 #define IE_LINE_STAT    0x04    /* receiver-line status int. */
46 #define IE_TRANS_HLD    0x02    /* transmitter holding register empty int. */
47 #define IE_RCV_DATA     0x01    /* received data available int. */
48
49 /* interrupt identification register */
50
51 #define II_FIFOS_EN     0xC0    /* if FIFOs are enabled */
52 #define II_NOP          0x38    /* not used */
53 #define II_INT_ID       0x06    /* mask: bits see below */
54 #define II_PEND_INT     0x01    /* 1=no interrupt pending */
55
56 /* bit masks for II_INT_ID */
57
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_EN      0x01
66
67 /* line control register */
68
69 #define LC_DIV_ACC      0x80    /* divisor latch access bit */
70 #define LC_BRK_CTRL     0x40    /* set break control */
71 #define LC_S_PAR        0x20    /* stick parity */
72 #define LC_EVEN_P       0x10    /* even parity select */
73 #define LC_PAR_E        0x08    /* parity enable */
74 #define LC_STOP_B       0x04    /* number of stop bits (0 - 1 bit) */
75 #define LC_W_LEN        0x03    /* unsigned short length (00 - 5, 01 - 6 etc.) */
76
77 /* line status register */
78
79 #define LS_NOP          0x80    /* not used */
80 #define LS_X_SHFT_E     0x40    /* 0=data transfer, 1=transmitter idle */
81 #define LS_X_HOLD_E     0x20    /* 0=ready, 1=transferring character */
82 #define LS_BREAK        0x10    /* break received */
83 #define LS_FRM_ERR      0x08    /* framing error */
84 #define LS_PAR_ERR      0x04    /* parity error */
85 #define LS_OVRN_ERR     0x02    /* overrun error */
86 #define LS_RCV_DATA_RD  0x01    /* data received */
87
88 /* modem status register */
89
90 #define MS_DCD          0x80    /* Data Carrier Detect in */
91 #define MS_RI           0x40    /* Ring Indicator in */
92 #define MS_DSR          0x20    /* Data Set Ready in */
93 #define MS_CTS          0x10    /* Clear To Send in */
94 #define MS_DELTA_DCD    0x08    /* Data Carrier Detect changed state */
95 #define MS_DELTA_RI     0x04    /* Ring Indicator changed state */
96 #define MS_DELTA_DSR    0x02    /* Data Set Ready changed state */
97 #define MS_DELTA_CTS    0x01    /* Clear To Send changed state */
98
99 /* data structure definitions */
100
101 #define N_OF_COM_REGS   8
102
103 struct com_data_struct {
104         int             fd;             /* BSD/386 file descriptor */
105         char            *path;          /* BSD/386 pathname */
106         int             addr;           /* ISA I/O address */
107         unsigned char   irq;            /* ISA IRQ */
108         unsigned char   flags;          /* some general software flags */
109
110         struct queue    *com_queue;     /* XXX DEBUG obsolete MCL? */
111
112         unsigned char   div_latch[2];   /* mirror of 16550 R0':R1' read/write */
113         unsigned char   last_char_read; /* mirror of 16550 R0 read only */
114         unsigned char   int_enable;     /* mirror of 16550 R1 read/write */
115         unsigned char   int_id;         /* mirror of 16550 R2 read only */
116         unsigned char   fifo_ctrl;      /* mirror of 16550 R2 write only */
117         unsigned char   line_ctrl;      /* mirror of 16550 R3 read/write */
118         unsigned char   modem_ctrl;     /* mirror of 16550 R4 read/write */
119         unsigned char   line_stat;      /* mirror of 16550 R5 read/write */
120         unsigned char   modem_stat;     /* mirror of 16550 R6 read/write */
121         unsigned char   uart_spare;     /* mirror of 16550 R7 read/write */
122 };
123
124 /* DOS definitions -- parameters */
125
126 #define BITRATE_110     0x00
127 #define BITRATE_150     0x20
128 #define BITRATE_300     0x40
129 #define BITRATE_600     0x60
130 #define BITRATE_1200    0x80
131 #define BITRATE_2400    0xA0
132 #define BITRATE_4800    0xC0
133 #define BITRATE_9600    0xE0
134 #define PARITY_NONE     0x00
135 #define PARITY_ODD      0x08
136 #define PARITY_EVEN     0x18
137 #define STOPBIT_1       0x00
138 #define STOPBIT_2       0x04
139 #define TXLEN_7BITS     0x02
140 #define TXLEN_8BITS     0x03
141
142 /* DOS definitions -- return codes */
143
144 #define LS_SW_TIME_OUT  LS_NOP  /* return value used by DOS */
145
146 /* miscellaneous definitions */
147
148 #define DIV_LATCH_LOW   0
149 #define DIV_LATCH_HIGH  1
150
151 #define DIV_LATCH_LOW_WRITTEN   0x01
152 #define DIV_LATCH_HIGH_WRITTEN  0x02
153 #define DIV_LATCH_BOTH_WRITTEN  0x03
154
155 /* variable declarations */
156
157 extern int errno;
158
159 /* routine declarations */
160
161 extern void     int14(regcontext_t *REGS);
162 extern void     com_set_line(struct com_data_struct *, unsigned char, unsigned char);
163 extern void     init_com(int, char *, int, unsigned char);
164 extern u_char   com_port_in(int);
165 extern void     com_port_out(int, unsigned char);
166
167 /* end of file com.h */