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 10/18/11 at 18:40:27

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
RevLine 
[229bcca8]1/**
2 * @file
3 *
4 * @brief  The generic libchip serial driver interface
5 */
6
7
[ee3b242b]8/*
9 *  This file contains the TTY driver table definition
10 *
11 *  This driver uses the termios pseudo driver.
12 *
[08311cc3]13 *  COPYRIGHT (c) 1989-1999.
[009c235]14 *  On-Line Applications Research Corporation (OAR).
[ee3b242b]15 *
[009c235]16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
[94365d9]18 *  http://www.rtems.com/license/LICENSE.
[ee3b242b]19 *
20 *  $Id$
21 */
22
23#ifndef __LIBCHIP_SERIAL_h
24#define __LIBCHIP_SERIAL_h
25
[e97e0e0]26#include <stdint.h>
27#include <stdbool.h>
[5ae415b]28#include <termios.h>
[ee3b242b]29
[7e72d51]30#ifdef __cplusplus
31extern "C" {
32#endif
33
[36152b0e]34/*
35 *  Types for get and set register routines
36 */
37
[229bcca8]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 */
[642c500]44typedef uint8_t   (*getRegister_f)(uintptr_t port, uint8_t reg);
[229bcca8]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 */
[642c500]53typedef void      (*setRegister_f)(uintptr_t port, uint8_t reg, uint8_t  value);
[229bcca8]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 */
[642c500]61typedef uint8_t   (*getData_f)(uintptr_t port);
[229bcca8]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 */
[642c500]69typedef void      (*setData_f)(uintptr_t port, uint8_t value);
[36152b0e]70
[229bcca8]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 */
[ee3b242b]78typedef struct _console_fns {
[6640459d]79  bool    (*deviceProbe)(int minor);
[58b1e95]80  int     (*deviceFirstOpen)(int major, int minor, void *arg);
81  int     (*deviceLastClose)(int major, int minor, void *arg);
82  int     (*deviceRead)(int minor);
[3ed964f9]83  ssize_t (*deviceWrite)(int minor, const char *buf, size_t len);
[58b1e95]84  void    (*deviceInitialize)(int minor);
85  void    (*deviceWritePolled)(int minor, char cChar);
[8a2d4f2b]86  int     (*deviceSetAttributes)(int minor, const struct termios *t);
[6640459d]87  bool      deviceOutputUsesInterrupts;
[ee3b242b]88} console_fns;
89
[229bcca8]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 */
[ee3b242b]96typedef struct _console_flow {
[424e23ee]97  int (*deviceStopRemoteTx)(int minor);
98  int (*deviceStartRemoteTx)(int minor);
[ee3b242b]99} console_flow;
100
[229bcca8]101
102/**
103 * This type defination provides an enumerated type of all
104 * supported libchip console drivers.
105 */
[c0573d7]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
[229bcca8]113/**
114 * This type defination provides an structure that is used to
115 * uniquely identify a specific serial port.
[5ae415b]116 */
[ee3b242b]117typedef struct _console_tbl {
[229bcca8]118  /**  This is the name of the device. */
[58b1e95]119  char          *sDeviceName;
[229bcca8]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   */
[c0573d7]124  console_devs   deviceType;
[229bcca8]125  /** pDeviceFns   This is a pointer to the set of driver routines to use. */
[58b1e95]126  console_fns   *pDeviceFns;
[229bcca8]127  /** This value is passed to the serial device driver for use.  In termios
128   *  itself the number is ignored.
129   */
[6640459d]130  bool         (*deviceProbe)(int minor);
[229bcca8]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   */
[424e23ee]138  console_flow  *pDeviceFlow;
[229bcca8]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   */
[ee4f57d]149  uint32_t       ulMargin;
[229bcca8]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   */
[ee4f57d]157  uint32_t       ulHysteresis;
[229bcca8]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   */
[58b1e95]162  void          *pDeviceParams;
[229bcca8]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   */
[ee4f57d]166  uint32_t       ulCtrlPort1;
[229bcca8]167  /** This is the secondary control port number, of use when a given
168   *  device has more than one available channel.
169   */
[ee4f57d]170  uint32_t       ulCtrlPort2;
[229bcca8]171  /** This is the port number for the data port of the device */
[ee4f57d]172  uint32_t       ulDataPort;
[229bcca8]173  /** This is the routine used to read register values. */
[36152b0e]174  getRegister_f  getRegister;
[229bcca8]175  /** This is the routine used to write register values. */
[36152b0e]176  setRegister_f  setRegister;
[229bcca8]177  /** This is the routine used to read the data register (RX). */
[36152b0e]178  getData_f      getData;
[229bcca8]179  /* This is the routine used to write the data register (TX). */
[36152b0e]180  setData_f      setData;
[229bcca8]181  /** This is the baud rate clock speed.*/
[ee4f57d]182  uint32_t       ulClock;
[229bcca8]183  /** This encodes the interrupt vector of the device. */
[58b1e95]184  unsigned int   ulIntVector;
[ee3b242b]185} console_tbl;
186
[229bcca8]187/**
188 * This type defination provides data for the console port.
189 */
[ee3b242b]190typedef struct _console_data {
[58b1e95]191  void                   *termios_data;
[6640459d]192  volatile bool           bActive;
[229bcca8]193  /** This field may be used for any purpose required by the driver  */
[58b1e95]194  void                   *pDeviceContext;
[ee3b242b]195} console_data;
196
[229bcca8]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;
[ee3b242b]221
[7e72d51]222#ifdef __cplusplus
223}
224#endif
225
[ee3b242b]226#endif
Note: See TracBrowser for help on using the repository browser.