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

4.11
Last change on this file since 2698728 was 4f1173bc, checked in by Jennifer Averett <jennifer.averett@…>, on Feb 23, 2012 at 4:40:33 PM

Avoid NULL dereference in printk() before libchip console initialized

With the addition of dynamically registered libchip serial devices,
there is the need to be able to use printk() before the console driver
has initialized the indirect pointer table. This lets printk() support
routines call pass a control structure directly without a lookup through
the uninitialized indirect one.

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