More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / include / linux / tty_driver.h
blob325e7f64df7f1898f39afedec16f679670483265
1 #ifndef _LINUX_TTY_DRIVER_H
2 #define _LINUX_TTY_DRIVER_H
4 /*
5 * This structure defines the interface between the low-level tty
6 * driver and the tty routines. The following routines can be
7 * defined; unless noted otherwise, they are optional, and can be
8 * filled in with a null pointer.
10 * int (*open)(struct tty_struct * tty, struct file * filp);
12 * This routine is called when a particular tty device is opened.
13 * This routine is mandatory; if this routine is not filled in,
14 * the attempted open will fail with ENODEV.
16 * void (*close)(struct tty_struct * tty, struct file * filp);
18 * This routine is called when a particular tty device is closed.
20 * int (*write)(struct tty_struct * tty, int from_user,
21 * const unsigned char *buf, int count);
23 * This routine is called by the kernel to write a series of
24 * characters to the tty device. The characters may come from
25 * user space or kernel space. This routine will return the
26 * number of characters actually accepted for writing. This
27 * routine is mandatory.
29 * void (*put_char)(struct tty_struct *tty, unsigned char ch);
31 * This routine is called by the kernel to write a single
32 * character to the tty device. If the kernel uses this routine,
33 * it must call the flush_chars() routine (if defined) when it is
34 * done stuffing characters into the driver. If there is no room
35 * in the queue, the character is ignored.
37 * void (*flush_chars)(struct tty_struct *tty);
39 * This routine is called by the kernel after it has written a
40 * series of characters to the tty device using put_char().
42 * int (*write_room)(struct tty_struct *tty);
44 * This routine returns the numbers of characters the tty driver
45 * will accept for queuing to be written. This number is subject
46 * to change as output buffers get emptied, or if the output flow
47 * control is acted.
49 * int (*ioctl)(struct tty_struct *tty, struct file * file,
50 * unsigned int cmd, unsigned long arg);
52 * This routine allows the tty driver to implement
53 * device-specific ioctl's. If the ioctl number passed in cmd
54 * is not recognized by the driver, it should return ENOIOCTLCMD.
56 * void (*set_termios)(struct tty_struct *tty, struct termios * old);
58 * This routine allows the tty driver to be notified when
59 * device's termios settings have changed. Note that a
60 * well-designed tty driver should be prepared to accept the case
61 * where old == NULL, and try to do something rational.
63 * void (*set_ldisc)(struct tty_struct *tty);
65 * This routine allows the tty driver to be notified when the
66 * device's termios settings have changed.
68 * void (*throttle)(struct tty_struct * tty);
70 * This routine notifies the tty driver that input buffers for
71 * the line discipline are close to full, and it should somehow
72 * signal that no more characters should be sent to the tty.
74 * void (*unthrottle)(struct tty_struct * tty);
76 * This routine notifies the tty drivers that it should signals
77 * that characters can now be sent to the tty without fear of
78 * overrunning the input buffers of the line disciplines.
80 * void (*stop)(struct tty_struct *tty);
82 * This routine notifies the tty driver that it should stop
83 * outputting characters to the tty device.
85 * void (*start)(struct tty_struct *tty);
87 * This routine notifies the tty driver that it resume sending
88 * characters to the tty device.
90 * void (*hangup)(struct tty_struct *tty);
92 * This routine notifies the tty driver that it should hangup the
93 * tty device.
95 * void (*break_ctl)(struct tty_stuct *tty, int state);
97 * This optional routine requests the tty driver to turn on or
98 * off BREAK status on the RS-232 port. If state is -1,
99 * then the BREAK status should be turned on; if state is 0, then
100 * BREAK should be turned off.
102 * If this routine is implemented, the high-level tty driver will
103 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
104 * TIOCCBRK. Otherwise, these ioctls will be passed down to the
105 * driver to handle.
107 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
109 * This routine waits until the device has written out all of the
110 * characters in its transmitter FIFO.
112 * void (*send_xchar)(struct tty_struct *tty, char ch);
114 * This routine is used to send a high-priority XON/XOFF
115 * character to the device.
118 #include <linux/fs.h>
120 struct tty_driver {
121 int magic; /* magic number for this structure */
122 const char *driver_name;
123 const char *name;
124 int name_base; /* offset of printed name */
125 short major; /* major device number */
126 short minor_start; /* start of minor device number*/
127 short num; /* number of devices */
128 short type; /* type of tty driver */
129 short subtype; /* subtype of tty driver */
130 struct termios init_termios; /* Initial termios */
131 int flags; /* tty driver flags */
132 int *refcount; /* for loadable tty drivers */
133 struct proc_dir_entry *proc_entry; /* /proc fs entry */
134 struct tty_driver *other; /* only used for the PTY driver */
137 * Pointer to the tty data structures
139 struct tty_struct **table;
140 struct termios **termios;
141 struct termios **termios_locked;
142 void *driver_state; /* only used for the PTY driver */
145 * Interface routines from the upper tty layer to the tty
146 * driver.
148 int (*open)(struct tty_struct * tty, struct file * filp);
149 void (*close)(struct tty_struct * tty, struct file * filp);
150 int (*write)(struct tty_struct * tty, int from_user,
151 const unsigned char *buf, int count);
152 void (*put_char)(struct tty_struct *tty, unsigned char ch);
153 void (*flush_chars)(struct tty_struct *tty);
154 int (*write_room)(struct tty_struct *tty);
155 int (*chars_in_buffer)(struct tty_struct *tty);
156 int (*ioctl)(struct tty_struct *tty, struct file * file,
157 unsigned int cmd, unsigned long arg);
158 void (*set_termios)(struct tty_struct *tty, struct termios * old);
159 void (*throttle)(struct tty_struct * tty);
160 void (*unthrottle)(struct tty_struct * tty);
161 void (*stop)(struct tty_struct *tty);
162 void (*start)(struct tty_struct *tty);
163 void (*hangup)(struct tty_struct *tty);
164 void (*break_ctl)(struct tty_struct *tty, int state);
165 void (*flush_buffer)(struct tty_struct *tty);
166 void (*set_ldisc)(struct tty_struct *tty);
167 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
168 void (*send_xchar)(struct tty_struct *tty, char ch);
169 int (*read_proc)(char *page, char **start, off_t off,
170 int count, int *eof, void *data);
171 int (*write_proc)(struct file *file, const char *buffer,
172 unsigned long count, void *data);
175 * linked list pointers
177 struct tty_driver *next;
178 struct tty_driver *prev;
181 /* tty driver magic number */
182 #define TTY_DRIVER_MAGIC 0x5402
185 * tty driver flags
187 * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
188 * termios setting when the last process has closed the device.
189 * Used for PTY's, in particular.
191 * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
192 * guarantee never not to set any special character handling
193 * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
194 * !INPCK)). That is, if there is no reason for the driver to
195 * send notifications of parity and break characters up to the
196 * line driver, it won't do so. This allows the line driver to
197 * optimize for this case if this flag is set. (Note that there
198 * is also a promise, if the above case is true, not to signal
199 * overruns, either.)
201 * TTY_DRIVER_NO_DEVFS --- if set, do not create devfs entries. This
202 * is only used by tty_register_driver().
205 #define TTY_DRIVER_INSTALLED 0x0001
206 #define TTY_DRIVER_RESET_TERMIOS 0x0002
207 #define TTY_DRIVER_REAL_RAW 0x0004
208 #define TTY_DRIVER_NO_DEVFS 0x0008
210 /* tty driver types */
211 #define TTY_DRIVER_TYPE_SYSTEM 0x0001
212 #define TTY_DRIVER_TYPE_CONSOLE 0x0002
213 #define TTY_DRIVER_TYPE_SERIAL 0x0003
214 #define TTY_DRIVER_TYPE_PTY 0x0004
215 #define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */
216 #define TTY_DRIVER_TYPE_SYSCONS 0x0006
218 /* system subtypes (magic, used by tty_io.c) */
219 #define SYSTEM_TYPE_TTY 0x0001
220 #define SYSTEM_TYPE_CONSOLE 0x0002
221 #define SYSTEM_TYPE_SYSCONS 0x0003
222 #define SYSTEM_TYPE_SYSPTMX 0x0004
224 /* pty subtypes (magic, used by tty_io.c) */
225 #define PTY_TYPE_MASTER 0x0001
226 #define PTY_TYPE_SLAVE 0x0002
228 /* serial subtype definitions */
229 #define SERIAL_TYPE_NORMAL 1
230 #define SERIAL_TYPE_CALLOUT 2
232 #endif /* #ifdef _LINUX_TTY_DRIVER_H */