source: rtems/c/src/libchip/serial/serial.h @ 7e72d51

4.104.115
Last change on this file since 7e72d51 was 7e72d51, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/10/10 at 02:19:02

Add extern "C".

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 *  This file contains the TTY driver table definition
3 *
4 *  This driver uses the termios pseudo driver.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef __LIBCHIP_SERIAL_h
17#define __LIBCHIP_SERIAL_h
18
19#include <stdint.h>
20#include <stdbool.h>
21#include <termios.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 *  Types for get and set register routines
29 */
30
31typedef uint8_t   (*getRegister_f)(uint32_t   port, uint8_t   register);
32typedef void      (*setRegister_f)(
33                            uint32_t   port, uint8_t   reg, uint8_t   value);
34typedef uint8_t   (*getData_f)(uint32_t   port);
35typedef void      (*setData_f)(uint32_t   port, uint8_t   value);
36
37typedef struct _console_fns {
38  bool    (*deviceProbe)(int minor);
39  int     (*deviceFirstOpen)(int major, int minor, void *arg);
40  int     (*deviceLastClose)(int major, int minor, void *arg);
41  int     (*deviceRead)(int minor);
42  ssize_t (*deviceWrite)(int minor, const char *buf, size_t len);
43  void    (*deviceInitialize)(int minor);
44  void    (*deviceWritePolled)(int minor, char cChar);
45  int     (*deviceSetAttributes)(int minor, const struct termios *t);
46  bool      deviceOutputUsesInterrupts;
47} console_fns;
48
49typedef struct _console_flow {
50  int (*deviceStopRemoteTx)(int minor);
51  int (*deviceStartRemoteTx)(int minor);
52} console_flow;
53
54typedef enum {
55  SERIAL_MC68681,              /* Motorola MC68681 or Exar 88681 */
56  SERIAL_NS16550,              /* National Semiconductor NS16550 */
57  SERIAL_Z85C30,               /* Zilog Z85C30 */
58  SERIAL_CUSTOM                /* BSP specific driver */
59} console_devs;
60
61/*
62 * Each field is interpreted thus:
63 *
64 * sDeviceName  This is the name of the device.
65 *
66 * deviceType   This indicates the chip type.  It is especially important when
67 *              multiple devices share the same interrupt vector and must be
68 *              distinguished.
69 *
70 * pDeviceFns   This is a pointer to the set of driver routines to use.
71 *
72 * pDeviceFlow  This is a pointer to the set of flow control routines to
73 *              use. Serial device drivers will typically supply RTSCTS
74 *              and DTRCTS handshake routines for DCE to DCE communication,
75 *              however for DCE to DTE communication, no such routines
76 *              should be necessary as RTS will be driven automatically
77 *              when the transmitter is active.
78 *
79 * ulMargin     The high water mark in the input buffer is set to the buffer
80 *              size less ulMargin. Once this level is reached, the driver's
81 *              flow control routine used to stop the remote transmitter will
82 *              be called. This figure should be greater than or equal to
83 *              the number of stages of FIFO between the transmitter and
84 *              receiver.
85 *
86 *              NOTE: At the current time, this parameter is hard coded
87 *                    in termios and this number is ignored.
88 *
89 * ulHysteresis After the high water mark specified by ulMargin has been
90 *              reached, the driver's routine to re-start the remote
91 *              transmitter will be called once the level in the input
92 *              buffer has fallen by ulHysteresis bytes.
93 *
94 *              NOTE: At the current time, this parameter is hard coded
95 *                    in termios and this number is ignored.
96 *
97 * pDeviceParams This contains either device specific data or a pointer to a
98 *              device specific structure containing additional information
99 *              not provided in this table.
100 *
101 * ulCtrlPort1  This is the primary control port number for the device. This
102 *              may be used to specify different instances of the same device
103 *              type.
104 *
105 * ulCtrlPort2  This is the secondary control port number, of use when a given
106 *              device has more than one available channel.
107 *
108 * ulDataPort   This is the port number for the data port of the device
109 *
110 * getRegister  This is the routine used to read register values.
111 *
112 * setRegister  This is the routine used to write register values.
113 *
114 * getData      This is the routine used to read the data register (RX).
115 *
116 * setData      This is the routine used to write the data register (TX).
117 *
118 * ulClock      This is the baud rate clock speed.
119 *
120 * ulIntVector  This encodes the interrupt vector of the device.
121 */
122
123typedef struct _console_tbl {
124  char          *sDeviceName;
125  console_devs   deviceType;
126  console_fns   *pDeviceFns;
127  bool         (*deviceProbe)(int minor);
128  console_flow  *pDeviceFlow;
129  uint32_t       ulMargin;
130  uint32_t       ulHysteresis;
131  void          *pDeviceParams;
132  uint32_t       ulCtrlPort1;
133  uint32_t       ulCtrlPort2;
134  uint32_t       ulDataPort;
135  getRegister_f  getRegister;
136  setRegister_f  setRegister;
137  getData_f      getData;
138  setData_f      setData;
139  uint32_t       ulClock;
140  unsigned int   ulIntVector;
141} console_tbl;
142
143typedef struct _console_data {
144  void                   *termios_data;
145  volatile bool           bActive;
146  /*
147   * This field may be used for any purpose required by the driver
148   */
149  void                   *pDeviceContext;
150} console_data;
151
152extern console_tbl  Console_Port_Tbl[];
153extern console_data Console_Port_Data[];
154extern unsigned long  Console_Port_Count;
155
156#ifdef __cplusplus
157}
158#endif
159
160#endif
Note: See TracBrowser for help on using the repository browser.