source: rtems/c/src/libchip/serial/ns16550_p.h @ 48bfd992

4.104.114.84.95
Last change on this file since 48bfd992 was 8739322, checked in by Joel Sherrill <joel.sherrill@…>, on 07/25/98 at 17:17:46

Added ns16550_set_attributes.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1998 by Radstone Technology
3 *
4 *
5 * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
6 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
7 * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
8 * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
9 *
10 * You are hereby granted permission to use, copy, modify, and distribute
11 * this file, provided that this notice, plus the above copyright notice
12 * and disclaimer, appears in all copies. Radstone Technology will provide
13 * no support for this code.
14 *
15 *  $Id$
16 */
17
18#ifndef _NS16550_P_H_
19#define _NS16550_P_H_
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*
26 *  Define NS16550_STATIC to nothing while debugging so the entry points
27 *  will show up in the symbol table.
28 */
29
30#define NS16550_STATIC
31
32/* #define NS16550_STATIC static */
33
34/*
35 * Define serial port read registers structure.
36 */
37
38typedef volatile struct _SP_READ_REGISTERS {
39    unsigned char ReceiveBuffer;
40    unsigned char InterruptEnable;
41    unsigned char InterruptId;
42    unsigned char LineControl;
43    unsigned char ModemControl;
44    unsigned char LineStatus;
45    unsigned char ModemStatus;
46    unsigned char ScratchPad;
47} SP_READ_REGISTERS, *PSP_READ_REGISTERS;
48
49#define NS16550_RECEIVE_BUFFER   0
50#define NS16550_INTERRUPT_ENABLE 1
51#define NS16550_INTERRUPT_ID     2
52#define NS16550_LINE_CONTROL     3
53#define NS16550_MODEM_CONTROL    4
54#define NS16550_LINE_STATUS      5
55#define NS16550_MODEM_STATUS     6
56#define NS16550_SCRATCH_PAD      7
57
58/*
59 * Define serial port write registers structure.
60 */
61
62typedef volatile struct _SP_WRITE_REGISTERS {
63    unsigned char TransmitBuffer;
64    unsigned char InterruptEnable;
65    unsigned char FifoControl;
66    unsigned char LineControl;
67    unsigned char ModemControl;
68    unsigned char Reserved1;
69    unsigned char ModemStatus;
70    unsigned char ScratchPad;
71} SP_WRITE_REGISTERS, *PSP_WRITE_REGISTERS;
72
73#define NS16550_TRANSMIT_BUFFER  0
74#define NS16550_FIFO_CONTROL     2
75
76/*
77 * Define serial port interrupt enable register structure.
78 */
79
80#define SP_INT_RX_ENABLE  0x01
81#define SP_INT_TX_ENABLE  0x02
82#define SP_INT_LS_ENABLE  0x04
83#define SP_INT_MS_ENABLE  0x08
84
85#define NS16550_ENABLE_ALL_INTR           (SP_INT_RX_ENABLE | SP_INT_TX_ENABLE)
86#define NS16550_DISABLE_ALL_INTR          0x00
87#define NS16550_ENABLE_ALL_INTR_EXCEPT_TX (SP_INT_RX_ENABLE)
88
89/*
90 * Define serial port interrupt id register structure.
91 */
92
93typedef struct _SP_INTERRUPT_ID {
94    unsigned char InterruptPending : 1;
95    unsigned char Identification : 3;
96    unsigned char Reserved1 : 2;
97    unsigned char FifoEnabled : 2;
98} SP_INTERRUPT_ID, *PSP_INTERRUPT_ID;
99
100/*
101 * Define serial port fifo control register structure.
102 */
103
104#define SP_FIFO_ENABLE  0x01
105#define SP_FIFO_RXRST 0x02
106#define SP_FIFO_TXRST 0x04
107#define SP_FIFO_DMA   0x08
108#define SP_FIFO_RXLEVEL 0xc0
109
110/*
111 * Define serial port line control register structure.
112 */
113
114#define SP_LINE_SIZE  0x03
115#define SP_LINE_STOP  0x04
116#define SP_LINE_PAR   0x08
117#define SP_LINE_ODD   0x10
118#define SP_LINE_STICK 0x20
119#define SP_LINE_BREAK 0x40
120#define SP_LINE_DLAB  0x80
121
122/*
123 * Line status register character size definitions.
124 */
125
126#define FIVE_BITS 0x0                   /* five bits per character */
127#define SIX_BITS 0x1                    /* six bits per character */
128#define SEVEN_BITS 0x2                  /* seven bits per character */
129#define EIGHT_BITS 0x3                  /* eight bits per character */
130
131/*
132 * Line speed divisor definition.
133 */
134
135#define NS16550_Baud(baud_rate) (115200/baud_rate)
136
137/*
138 * Define serial port modem control register structure.
139 */
140
141#define SP_MODEM_DTR  0x01
142#define SP_MODEM_RTS  0x02
143#define SP_MODEM_IRQ  0x08
144#define SP_MODEM_LOOP 0x10
145#define SP_MODEM_DIV4 0x80
146
147/*
148 * Define serial port line status register structure.
149 */
150
151#define SP_LSR_RDY    0x01
152#define SP_LSR_EOVRUN 0x02
153#define SP_LSR_EPAR   0x04
154#define SP_LSR_EFRAME 0x08
155#define SP_LSR_BREAK  0x10
156#define SP_LSR_THOLD  0x20
157#define SP_LSR_TX   0x40
158#define SP_LSR_EFIFO  0x80
159
160typedef struct _ns16550_context
161{
162        unsigned8       ucModemCtrl;
163} ns16550_context;
164
165/*
166 * Driver functions
167 */
168
169NS16550_STATIC boolean ns16550_probe(int minor);
170
171NS16550_STATIC void ns16550_init(int minor);
172
173NS16550_STATIC int ns16550_open(
174  int major,
175  int minor,
176  void  * arg
177);
178
179NS16550_STATIC int ns16550_close(
180  int major,
181  int minor,
182  void  * arg
183);
184
185NS16550_STATIC void ns16550_write_polled(
186  int   minor,
187  char  cChar
188);
189
190NS16550_STATIC int ns16550_assert_RTS(
191  int minor
192);
193
194NS16550_STATIC int ns16550_negate_RTS(
195  int minor
196);
197
198NS16550_STATIC int ns16550_assert_DTR(
199  int minor
200);
201
202NS16550_STATIC int ns16550_negate_DTR(
203  int minor
204);
205
206NS16550_STATIC void ns16550_initialize_interrupts(int minor);
207
208NS16550_STATIC int ns16550_write_support_int(
209  int   minor,
210  const char *buf,
211  int   len
212);
213
214NS16550_STATIC int ns16550_write_support_polled(
215  int   minor,
216  const char *buf,
217  int   len
218  );
219
220NS16550_STATIC int ns16550_inbyte_nonblocking_polled(
221  int minor
222);
223
224NS16550_STATIC void ns16550_enable_interrupts(
225  int minor,
226  int mask
227);
228
229NS16550_STATIC int ns16550_set_attributes(
230  int                   minor,
231  const struct termios *t
232);
233
234#ifdef __cplusplus
235}
236#endif
237
238#endif /* _NS16550_P_H_ */
Note: See TracBrowser for help on using the repository browser.