source: rtems/cpukit/libcsupport/include/rtems/termiostypes.h @ 2733f945

4.9
Last change on this file since 2733f945 was b6be4217, checked in by Joel Sherrill <joel.sherrill@…>, on 05/22/08 at 20:16:08

2008-05-22 Joel Sherrill <joel.sherrill@…>

  • libcsupport/Makefile.am, libcsupport/preinstall.am, libcsupport/include/rtems/termiostypes.h: Move termios helper routines from libchip to libcsupport. Add routine which makes it easy for a termios device driver to inform termios of its default baud rate. This avoids inconsistencies in later termios settings changes.
  • Property mode set to 100644
File size: 4.8 KB
Line 
1/**
2 * @file rtems/termiostypes.h
3 */
4
5/*
6 *  RTEMS termios device support internal data structures
7 *
8 *  COPYRIGHT (c) 1989-2008.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#ifndef  __TERMIOSTYPES_H
19#define  __TERMIOSTYPES_H
20
21#include <rtems.h>
22#include <rtems/libio.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*
29 * Wakeup callback data structure
30 */
31struct ttywakeup {
32  void      (*sw_pfn)(struct termios *tty, void *arg);
33  void      *sw_arg;
34};
35
36/*
37 * Variables associated with the character buffer
38 */
39struct rtems_termios_rawbuf {
40  char *theBuf;
41  volatile unsigned int  Head;
42  volatile unsigned int  Tail;
43  volatile unsigned int  Size;
44  rtems_id    Semaphore;
45};
46/*
47 * Variables associated with each termios instance.
48 * One structure for each hardware I/O device.
49 */
50struct rtems_termios_tty {
51  /*
52   * Linked-list of active TERMIOS devices
53   */
54  struct rtems_termios_tty  *forw;
55  struct rtems_termios_tty  *back;
56
57  /*
58   * How many times has this device been opened
59   */
60  int    refcount;
61
62  /*
63   * This device
64   */
65  rtems_device_major_number  major;
66  rtems_device_major_number  minor;
67
68  /*
69   * Mutual-exclusion semaphores
70   */
71  rtems_id  isem;
72  rtems_id  osem;
73
74  /*
75   * The canonical (cooked) character buffer
76   */
77  char    *cbuf;
78  int    ccount;
79  int    cindex;
80
81  /*
82   * Keep track of cursor (printhead) position
83   */
84  int    column;
85  int    read_start_column;
86
87  /*
88   * The ioctl settings
89   */
90  struct termios  termios;
91  rtems_interval  vtimeTicks;
92
93  /*
94   * Raw input character buffer
95   */
96  struct rtems_termios_rawbuf rawInBuf;
97  uint32_t                    rawInBufSemaphoreOptions;
98  rtems_interval              rawInBufSemaphoreTimeout;
99  rtems_interval              rawInBufSemaphoreFirstTimeout;
100  unsigned int                rawInBufDropped;  /* Statistics */
101
102  /*
103   * Raw output character buffer
104   */
105  struct rtems_termios_rawbuf rawOutBuf;
106  int  t_dqlen; /* count of characters dequeued from device */
107  enum {rob_idle, rob_busy, rob_wait }  rawOutBufState;
108
109  /*
110   * Callbacks to device-specific routines
111   */
112  rtems_termios_callbacks  device;
113  volatile unsigned int    flow_ctrl;
114  unsigned int             lowwater,highwater;
115
116  /*
117   * I/O task IDs (for task-driven drivers)
118   */
119  rtems_id                rxTaskId;
120  rtems_id                txTaskId;
121
122  /*
123   * line discipline related stuff
124   */
125  int t_line;   /* id of line discipline                       */
126  void *t_sc;   /* hook for discipline-specific data structure */
127
128  /*
129   * Wakeup callback variables
130   */
131  struct ttywakeup tty_snd;
132  struct ttywakeup tty_rcv;
133  int              tty_rcvwakeup;
134};
135
136struct rtems_termios_linesw {
137  int (*l_open) (struct rtems_termios_tty *tp);
138  int (*l_close)(struct rtems_termios_tty *tp);
139  int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
140  int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args);
141  int (*l_rint )(int c,struct rtems_termios_tty *tp);
142  int (*l_start)(struct rtems_termios_tty *tp);
143  int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args);
144  int (*l_modem)(struct rtems_termios_tty *tp,int flags);
145};
146
147/*
148 * FIXME: this should move to libio.h!
149 * values for rtems_termios_callbacks.outputUsesInterrupts
150 */
151#define TERMIOS_POLLED      0
152#define TERMIOS_IRQ_DRIVEN  1
153#define TERMIOS_TASK_DRIVEN 2
154
155/*
156 * FIXME: this should move to termios.h!
157 */
158void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty);
159
160/*
161 * FIXME: this should move to termios.h!
162 * put a string to output ring buffer
163 */
164void rtems_termios_puts (
165  const void               *buf,
166  int                       len,
167  struct rtems_termios_tty *tty
168);
169
170/*
171 * global hooks for line disciplines
172 */
173extern struct rtems_termios_linesw rtems_termios_linesw[];
174extern int   rtems_termios_nlinesw;
175
176#define TTYDISC   0    /* termios tty line discipline */
177#define TABLDISC  3    /* tablet discipline */
178#define SLIPDISC  4    /* serial IP discipline */
179#define PPPDISC   5    /* PPP discipline */
180#define MAXLDISC  8
181
182/* convert xxx integer to equivalent Bxxx constant */
183int  termios_number_to_baud(int baud);
184/* convert Bxxx constant to xxx integer */
185int  termios_baud_to_number(int termios_baud);
186/* convert Bxxx constant to index */
187int  termios_baud_to_index(int termios_baud);
188
189/*
190 *  This method is used by a driver to tell termios its
191 *  initial baud rate.  This is especially important when
192 *  the device driver does not set the baud to the default
193 *  of B9600.
194 */
195int  rtems_termios_set_initial_baud(
196  struct rtems_termios_tty *ttyp,
197  int                       baud
198);
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif  /* TERMIOSTYPES_H */
Note: See TracBrowser for help on using the repository browser.