source: rtems/c/src/libchip/serial/serial.h @ 3ed964f9

4.104.115
Last change on this file since 3ed964f9 was 3ed964f9, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 04/09/10 at 22:44:05

adapt _write_ functions to new prototype

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