source: rtems/c/src/libchip/serial/serial.h @ 74172b7d

5
Last change on this file since 74172b7d was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 7.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief  The generic libchip serial driver interface
5 */
6
7
8/*
9 *  This file contains the TTY driver table definition
10 *
11 *  This driver uses the termios pseudo driver.
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef __LIBCHIP_SERIAL_h
22#define __LIBCHIP_SERIAL_h
23
24#include <termios.h>
25
26#include <rtems.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*
33 *  Types for get and set register routines
34 */
35
36/**
37 *  @typedef getRegister_f
38 *
39 *  This type function provides a hook for the bsp specific method
40 *  that gets register data from the given port and register.
41 */
42typedef uint8_t   (*getRegister_f)(uintptr_t port, uint8_t reg);
43
44/**
45 *  @typedef setData_f
46 *
47 *  This type function provides a hook for the bsp specific method
48 *  that sets register data from the given port and register to the
49 *  given value.
50 */
51typedef void      (*setRegister_f)(uintptr_t port, uint8_t reg, uint8_t  value);
52
53/**
54 *  @typedef getData_f
55 *
56 *  This type function provides a hook for the bsp specific method
57 *  that gets data from the specified port.
58 */
59typedef uint8_t   (*getData_f)(uintptr_t port);
60
61/**
62 *  @typedef setData_f
63 *
64 *  This type function provides a hook for the bsp specific method
65 *  that writes value to the specified port.
66 */
67typedef void      (*setData_f)(uintptr_t port, uint8_t value);
68
69/**
70 *  @typedef _console_fns
71 *
72 *  This type definition provides a structure of functions each
73 *  methood provides an interfce to the serial por to do a specific
74 *  function.
75 */
76typedef struct _console_fns {
77  bool    (*deviceProbe)(int minor);
78  int     (*deviceFirstOpen)(int major, int minor, void *arg);
79  int     (*deviceLastClose)(int major, int minor, void *arg);
80  int     (*deviceRead)(int minor);
81  ssize_t (*deviceWrite)(int minor, const char *buf, size_t len);
82  void    (*deviceInitialize)(int minor);
83  void    (*deviceWritePolled)(int minor, char cChar);
84  int     (*deviceSetAttributes)(int minor, const struct termios *t);
85  bool      deviceOutputUsesInterrupts;
86} console_fns;
87
88/**
89 *  @typedef _console_flow
90 *
91 *  This type definition provides a structure of functions
92 *  that provide flow control for the transmit buffer.
93 */
94typedef struct _console_flow {
95  int (*deviceStopRemoteTx)(int minor);
96  int (*deviceStartRemoteTx)(int minor);
97} console_flow;
98
99
100/**
101 * This type defination provides an enumerated type of all
102 * supported libchip console drivers.
103 */
104typedef enum {
105  SERIAL_MC68681,              /* Motorola MC68681 or Exar 88681 */
106  SERIAL_NS16550,              /* National Semiconductor NS16550 */
107  SERIAL_NS16550_WITH_FDR,     /* National Semiconductor NS16550
108                                  with Fractional Divider Register (FDR) */
109  SERIAL_Z85C30,               /* Zilog Z85C30 */
110  SERIAL_CUSTOM                /* BSP specific driver */
111} console_devs;
112
113/**
114 * This type defination provides an structure that is used to
115 * uniquely identify a specific serial port.
116 */
117typedef struct _console_tbl {
118  /**  This is the name of the device. */
119  const char    *sDeviceName;
120  /** This indicates the chip type.  It is especially important when
121   *   multiple devices share the same interrupt vector and must be
122   *   distinguished.
123   */
124  console_devs   deviceType;
125  /** pDeviceFns   This is a pointer to the set of driver routines to use. */
126  const console_fns *pDeviceFns;
127  /** This value is passed to the serial device driver for use.  In termios
128   *  itself the number is ignored.
129   */
130  bool         (*deviceProbe)(int minor);
131  /** This is a pointer to the set of flow control routines to
132   *  use. Serial device drivers will typically supply RTSCTS
133   *  and DTRCTS handshake routines for DCE to DCE communication,
134   *  however for DCE to DTE communication, no such routines
135   *  should be necessary as RTS will be driven automatically
136   *  when the transmitter is active.
137   */
138  const console_flow *pDeviceFlow;
139  /** The high water mark in the input buffer is set to the buffer
140   *  size less ulMargin. Once this level is reached, the driver's
141   *  flow control routine used to stop the remote transmitter will
142   *  be called. This figure should be greater than or equal to
143   *  the number of stages of FIFO between the transmitter and
144   *  receiver.
145   *
146   *  @note At the current time, this parameter is hard coded
147   *        in termios and this number is ignored.
148   */
149  uint32_t       ulMargin;
150  /** After the high water mark specified by ulMargin has been
151   *  reached, the driver's routine to re-start the remote
152   *  transmitter will be called once the level in the input
153   *  buffer has fallen by ulHysteresis bytes.
154   *
155   *  @note At the current time, this parameter is hard coded in termios.
156   */
157  uint32_t       ulHysteresis;
158  /** This contains either device specific data or a pointer to a
159   *  device specific structure containing additional information
160   *  not provided in this table.
161   */
162  void          *pDeviceParams;
163  /** This is the primary control port number for the device. This
164   *  may be used to specify different instances of the same device type.
165   */
166  uint32_t       ulCtrlPort1;
167  /** This is the secondary control port number, of use when a given
168   *  device has more than one available channel.
169   */
170  uint32_t       ulCtrlPort2;
171  /** This is the port number for the data port of the device */
172  uint32_t       ulDataPort;
173  /** This is the routine used to read register values. */
174  getRegister_f  getRegister;
175  /** This is the routine used to write register values. */
176  setRegister_f  setRegister;
177  /** This is the routine used to read the data register (RX). */
178  getData_f      getData;
179  /* This is the routine used to write the data register (TX). */
180  setData_f      setData;
181  /** This is the baud rate clock speed.*/
182  uint32_t       ulClock;
183  /** This encodes the interrupt vector of the device. */
184  unsigned int   ulIntVector;
185} console_tbl;
186
187/**
188 * This type defination provides data for the console port.
189 */
190typedef struct _console_data {
191  void                   *termios_data;
192  volatile bool           bActive;
193  /** This field may be used for any purpose required by the driver  */
194  void                   *pDeviceContext;
195} console_data;
196
197/**
198 *  This is a dynamically sized set of tables containing the serial
199 *  port information.
200 */
201extern console_tbl   **Console_Port_Tbl;
202/**
203 * This is the number of serial ports defined in the Console_Port_Tbl.
204 */
205extern unsigned long   Console_Port_Count;
206
207/**
208 *  The statically configured serial port information tables which
209 *  are used to initially populate the dynamic tables.
210 */
211extern console_tbl    Console_Configuration_Ports[];
212/**
213 * The number of serial ports defined in Console_Configuration_Ports
214 * */
215extern unsigned long  Console_Configuration_Count;
216
217/**
218 *  This is an array of per port information.
219 */
220extern console_data  *Console_Port_Data;
221
222extern rtems_device_minor_number Console_Port_Minor;
223
224/**
225 * @brief Selects the minor number of the console device.
226 *
227 * @see Console_Port_Minor.
228 */
229void bsp_console_select(void);
230
231#ifdef __cplusplus
232}
233#endif
234
235#endif
Note: See TracBrowser for help on using the repository browser.