source: rtems/c/src/libchip/serial/serial.h @ 229bcca8

4.115
Last change on this file since 229bcca8 was 229bcca8, checked in by Jennifer Averett <Jennifer.Averett@…>, on Oct 18, 2011 at 6:40:27 PM

2011-10-18 Jennifer Averett <Jennifer.Averett@…>

PR 1917/bsps

  • libchip/serial/mc68681.c, libchip/serial/ns16550.c, libchip/serial/serial.h, libchip/serial/z85c30.c: Modifications to add dynamic tables for libchip serial drivers.
  • Property mode set to 100644
File size: 6.9 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.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#ifndef __LIBCHIP_SERIAL_h
24#define __LIBCHIP_SERIAL_h
25
26#include <stdint.h>
27#include <stdbool.h>
28#include <termios.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/*
35 *  Types for get and set register routines
36 */
37
38/**
39 *  @typedef getRegister_f
40 *
41 *  This type function provides a hook for the bsp specific method
42 *  that gets register data from the given port and register.
43 */
44typedef uint8_t   (*getRegister_f)(uintptr_t port, uint8_t reg);
45
46/**
47 *  @typedef setData_f
48 *
49 *  This type function provides a hook for the bsp specific method
50 *  that sets register data from the given port and register to the
51 *  given value.
52 */
53typedef void      (*setRegister_f)(uintptr_t port, uint8_t reg, uint8_t  value);
54
55/**
56 *  @typedef getData_f
57 *
58 *  This type function provides a hook for the bsp specific method
59 *  that gets data from the specified port.
60 */
61typedef uint8_t   (*getData_f)(uintptr_t port);
62
63/**
64 *  @typedef setData_f
65 *
66 *  This type function provides a hook for the bsp specific method
67 *  that writes value to the specified port.
68 */
69typedef void      (*setData_f)(uintptr_t port, uint8_t value);
70
71/**
72 *  @typedef _console_fns
73 *
74 *  This type definition provides a structure of functions each
75 *  methood provides an interfce to the serial por to do a specific
76 *  function.
77 */
78typedef struct _console_fns {
79  bool    (*deviceProbe)(int minor);
80  int     (*deviceFirstOpen)(int major, int minor, void *arg);
81  int     (*deviceLastClose)(int major, int minor, void *arg);
82  int     (*deviceRead)(int minor);
83  ssize_t (*deviceWrite)(int minor, const char *buf, size_t len);
84  void    (*deviceInitialize)(int minor);
85  void    (*deviceWritePolled)(int minor, char cChar);
86  int     (*deviceSetAttributes)(int minor, const struct termios *t);
87  bool      deviceOutputUsesInterrupts;
88} console_fns;
89
90/**
91 *  @typedef _console_flow
92 *
93 *  This type definition provides a structure of functions
94 *  that provide flow control for the transmit buffer.
95 */
96typedef struct _console_flow {
97  int (*deviceStopRemoteTx)(int minor);
98  int (*deviceStartRemoteTx)(int minor);
99} console_flow;
100
101
102/**
103 * This type defination provides an enumerated type of all
104 * supported libchip console drivers.
105 */
106typedef enum {
107  SERIAL_MC68681,              /* Motorola MC68681 or Exar 88681 */
108  SERIAL_NS16550,              /* National Semiconductor NS16550 */
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  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  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  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
222#ifdef __cplusplus
223}
224#endif
225
226#endif
Note: See TracBrowser for help on using the repository browser.