OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [tty.h] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _LINUX_TTY_H
2
#define _LINUX_TTY_H
3
 
4
/*
5
 * 'tty.h' defines some structures used by tty_io.c and some defines.
6
 */
7
 
8
/*
9
 * These constants are also useful for user-level apps (e.g., VC
10
 * resizing).
11
 */
12
#define MIN_NR_CONSOLES 1       /* must be at least 1 */
13
#define MAX_NR_CONSOLES 63      /* serial lines start at 64 */
14
#define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */
15
                /* Note: the ioctl VT_GETSTATE does not work for
16
                   consoles 16 and higher (since it returns a short) */
17
 
18
#ifdef __KERNEL__
19
#include <linux/fs.h>
20
#include <linux/termios.h>
21
#include <linux/tqueue.h>
22
#include <linux/tty_driver.h>
23
#include <linux/tty_ldisc.h>
24
 
25
#include <asm/system.h>
26
 
27
 
28
/*
29
 * Note: don't mess with NR_PTYS until you understand the tty minor
30
 * number allocation game...
31
 * (Note: the *_driver.minor_start values 1, 64, 128, 192 are
32
 * hardcoded at present.)
33
 */
34
#define NR_PTYS         256
35
#define NR_LDISCS       16
36
 
37
/*
38
 * These are set up by the setup-routine at boot-time:
39
 */
40
 
41
struct screen_info {
42
        unsigned char  orig_x;
43
        unsigned char  orig_y;
44
        unsigned char  unused1[2];
45
        unsigned short orig_video_page;
46
        unsigned char  orig_video_mode;
47
        unsigned char  orig_video_cols;
48
        unsigned short unused2;
49
        unsigned short orig_video_ega_bx;
50
        unsigned short unused3;
51
        unsigned char  orig_video_lines;
52
        unsigned char  orig_video_isVGA;
53
        unsigned short orig_video_points;
54
};
55
 
56
extern struct screen_info screen_info;
57
 
58
#define ORIG_X                  (screen_info.orig_x)
59
#define ORIG_Y                  (screen_info.orig_y)
60
#define ORIG_VIDEO_MODE         (screen_info.orig_video_mode)
61
#define ORIG_VIDEO_COLS         (screen_info.orig_video_cols)
62
#define ORIG_VIDEO_EGA_BX       (screen_info.orig_video_ega_bx)
63
#define ORIG_VIDEO_LINES        (screen_info.orig_video_lines)
64
#define ORIG_VIDEO_ISVGA        (screen_info.orig_video_isVGA)
65
#define ORIG_VIDEO_POINTS       (screen_info.orig_video_points)
66
 
67
#define VIDEO_TYPE_MDA          0x10    /* Monochrome Text Display      */
68
#define VIDEO_TYPE_CGA          0x11    /* CGA Display                  */
69
#define VIDEO_TYPE_EGAM         0x20    /* EGA/VGA in Monochrome Mode   */
70
#define VIDEO_TYPE_EGAC         0x21    /* EGA in Color Mode            */
71
#define VIDEO_TYPE_VGAC         0x22    /* VGA+ in Color Mode           */
72
 
73
#define VIDEO_TYPE_TGAC         0x40    /* DEC TGA */
74
 
75
#define VIDEO_TYPE_SUN          0x50    /* Sun frame buffer. */
76
 
77
/*
78
 * This character is the same as _POSIX_VDISABLE: it cannot be used as
79
 * a c_cc[] character, but indicates that a particular special character
80
 * isn't in use (eg VINTR has no character etc)
81
 */
82
#define __DISABLED_CHAR '\0'
83
 
84
/*
85
 * This is the flip buffer used for the tty driver.  The buffer is
86
 * located in the tty structure, and is used as a high speed interface
87
 * between the tty driver and the tty line discipline.
88
 */
89
#define TTY_FLIPBUF_SIZE 512
90
 
91
struct tty_flip_buffer {
92
        struct tq_struct tqueue;
93
        unsigned char   char_buf[2*TTY_FLIPBUF_SIZE];
94
        char            flag_buf[2*TTY_FLIPBUF_SIZE];
95
        char            *char_buf_ptr;
96
        unsigned char   *flag_buf_ptr;
97
        int             count;
98
        int             buf_num;
99
};
100
 
101
/*
102
 * When a break, frame error, or parity error happens, these codes are
103
 * stuffed into the flags buffer.
104
 */
105
#define TTY_NORMAL      0
106
#define TTY_BREAK       1
107
#define TTY_FRAME       2
108
#define TTY_PARITY      3
109
#define TTY_OVERRUN     4
110
 
111
#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR])
112
#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT])
113
#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE])
114
#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL])
115
#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF])
116
#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME])
117
#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN])
118
#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC])
119
#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART])
120
#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP])
121
#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP])
122
#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL])
123
#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT])
124
#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD])
125
#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE])
126
#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT])
127
#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2])
128
 
129
#define _I_FLAG(tty,f)  ((tty)->termios->c_iflag & (f))
130
#define _O_FLAG(tty,f)  ((tty)->termios->c_oflag & (f))
131
#define _C_FLAG(tty,f)  ((tty)->termios->c_cflag & (f))
132
#define _L_FLAG(tty,f)  ((tty)->termios->c_lflag & (f))
133
 
134
#define I_IGNBRK(tty)   _I_FLAG((tty),IGNBRK)
135
#define I_BRKINT(tty)   _I_FLAG((tty),BRKINT)
136
#define I_IGNPAR(tty)   _I_FLAG((tty),IGNPAR)
137
#define I_PARMRK(tty)   _I_FLAG((tty),PARMRK)
138
#define I_INPCK(tty)    _I_FLAG((tty),INPCK)
139
#define I_ISTRIP(tty)   _I_FLAG((tty),ISTRIP)
140
#define I_INLCR(tty)    _I_FLAG((tty),INLCR)
141
#define I_IGNCR(tty)    _I_FLAG((tty),IGNCR)
142
#define I_ICRNL(tty)    _I_FLAG((tty),ICRNL)
143
#define I_IUCLC(tty)    _I_FLAG((tty),IUCLC)
144
#define I_IXON(tty)     _I_FLAG((tty),IXON)
145
#define I_IXANY(tty)    _I_FLAG((tty),IXANY)
146
#define I_IXOFF(tty)    _I_FLAG((tty),IXOFF)
147
#define I_IMAXBEL(tty)  _I_FLAG((tty),IMAXBEL)
148
 
149
#define O_OPOST(tty)    _O_FLAG((tty),OPOST)
150
#define O_OLCUC(tty)    _O_FLAG((tty),OLCUC)
151
#define O_ONLCR(tty)    _O_FLAG((tty),ONLCR)
152
#define O_OCRNL(tty)    _O_FLAG((tty),OCRNL)
153
#define O_ONOCR(tty)    _O_FLAG((tty),ONOCR)
154
#define O_ONLRET(tty)   _O_FLAG((tty),ONLRET)
155
#define O_OFILL(tty)    _O_FLAG((tty),OFILL)
156
#define O_OFDEL(tty)    _O_FLAG((tty),OFDEL)
157
#define O_NLDLY(tty)    _O_FLAG((tty),NLDLY)
158
#define O_CRDLY(tty)    _O_FLAG((tty),CRDLY)
159
#define O_TABDLY(tty)   _O_FLAG((tty),TABDLY)
160
#define O_BSDLY(tty)    _O_FLAG((tty),BSDLY)
161
#define O_VTDLY(tty)    _O_FLAG((tty),VTDLY)
162
#define O_FFDLY(tty)    _O_FLAG((tty),FFDLY)
163
 
164
#define C_BAUD(tty)     _C_FLAG((tty),CBAUD)
165
#define C_CSIZE(tty)    _C_FLAG((tty),CSIZE)
166
#define C_CSTOPB(tty)   _C_FLAG((tty),CSTOPB)
167
#define C_CREAD(tty)    _C_FLAG((tty),CREAD)
168
#define C_PARENB(tty)   _C_FLAG((tty),PARENB)
169
#define C_PARODD(tty)   _C_FLAG((tty),PARODD)
170
#define C_HUPCL(tty)    _C_FLAG((tty),HUPCL)
171
#define C_CLOCAL(tty)   _C_FLAG((tty),CLOCAL)
172
#define C_CIBAUD(tty)   _C_FLAG((tty),CIBAUD)
173
#define C_CRTSCTS(tty)  _C_FLAG((tty),CRTSCTS)
174
 
175
#define L_ISIG(tty)     _L_FLAG((tty),ISIG)
176
#define L_ICANON(tty)   _L_FLAG((tty),ICANON)
177
#define L_XCASE(tty)    _L_FLAG((tty),XCASE)
178
#define L_ECHO(tty)     _L_FLAG((tty),ECHO)
179
#define L_ECHOE(tty)    _L_FLAG((tty),ECHOE)
180
#define L_ECHOK(tty)    _L_FLAG((tty),ECHOK)
181
#define L_ECHONL(tty)   _L_FLAG((tty),ECHONL)
182
#define L_NOFLSH(tty)   _L_FLAG((tty),NOFLSH)
183
#define L_TOSTOP(tty)   _L_FLAG((tty),TOSTOP)
184
#define L_ECHOCTL(tty)  _L_FLAG((tty),ECHOCTL)
185
#define L_ECHOPRT(tty)  _L_FLAG((tty),ECHOPRT)
186
#define L_ECHOKE(tty)   _L_FLAG((tty),ECHOKE)
187
#define L_FLUSHO(tty)   _L_FLAG((tty),FLUSHO)
188
#define L_PENDIN(tty)   _L_FLAG((tty),PENDIN)
189
#define L_IEXTEN(tty)   _L_FLAG((tty),IEXTEN)
190
 
191
/*
192
 * Where all of the state associated with a tty is kept while the tty
193
 * is open.  Since the termios state should be kept even if the tty
194
 * has been closed --- for things like the baud rate, etc --- it is
195
 * not stored here, but rather a pointer to the real state is stored
196
 * here.  Possible the winsize structure should have the same
197
 * treatment, but (1) the default 80x24 is usually right and (2) it's
198
 * most often used by a windowing system, which will set the correct
199
 * size each time the window is created or resized anyway.
200
 * IMPORTANT: since this structure is dynamically allocated, it must
201
 * be no larger than 4096 bytes.  Changing TTY_BUF_SIZE will change
202
 * the size of this structure, and it needs to be done with care.
203
 *                                              - TYT, 9/14/92
204
 */
205
struct tty_struct {
206
        int     magic;
207
        struct tty_driver driver;
208
        struct tty_ldisc ldisc;
209
        struct termios *termios, *termios_locked;
210
        int pgrp;
211
        int session;
212
        kdev_t  device;
213
        unsigned long flags;
214
        int count;
215
        struct winsize winsize;
216
        unsigned char stopped:1, hw_stopped:1, packet:1;
217
        unsigned char ctrl_status;
218
 
219
        struct tty_struct *link;
220
        struct fasync_struct *fasync;
221
        struct tty_flip_buffer flip;
222
        int max_flip_cnt;
223
        struct wait_queue *write_wait;
224
        struct wait_queue *read_wait;
225
        void *disc_data;
226
        void *driver_data;
227
 
228
#define N_TTY_BUF_SIZE 4096
229
 
230
        /*
231
         * The following is data for the N_TTY line discipline.  For
232
         * historical reasons, this is included in the tty structure.
233
         */
234
        unsigned int column;
235
        unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
236
        unsigned char closing:1;
237
        unsigned short minimum_to_wake;
238
        unsigned overrun_time;
239
        int num_overrun;
240
        unsigned long process_char_map[256/(8*sizeof(unsigned long))];
241
        char *read_buf;
242
        int read_head;
243
        int read_tail;
244
        int read_cnt;
245
        unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];
246
        int canon_data;
247
        unsigned long canon_head;
248
        unsigned int canon_column;
249
};
250
 
251
/* tty magic number */
252
#define TTY_MAGIC               0x5401
253
 
254
/*
255
 * These bits are used in the flags field of the tty structure.
256
 *
257
 * So that interrupts won't be able to mess up the queues,
258
 * copy_to_cooked must be atomic with respect to itself, as must
259
 * tty->write.  Thus, you must use the inline functions set_bit() and
260
 * clear_bit() to make things atomic.
261
 */
262
#define TTY_THROTTLED 0
263
#define TTY_IO_ERROR 1
264
#define TTY_OTHER_CLOSED 2
265
#define TTY_EXCLUSIVE 3
266
#define TTY_DEBUG 4
267
#define TTY_DO_WRITE_WAKEUP 5
268
#define TTY_PUSH 6
269
#define TTY_CLOSING 7
270
 
271
#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
272
 
273
extern void tty_write_flush(struct tty_struct *);
274
 
275
extern struct termios tty_std_termios;
276
extern struct tty_struct * redirect;
277
extern struct tty_ldisc ldiscs[];
278
extern int fg_console, last_console, want_console;
279
 
280
extern int kmsg_redirect;
281
extern struct wait_queue * keypress_wait;
282
 
283
extern unsigned long con_init(unsigned long);
284
 
285
extern int fbmem_init(void);
286
extern int rs_init(void);
287
extern int lp_init(void);
288
extern int pty_init(void);
289
extern int tty_init(void);
290
extern int pcxe_init(void);
291
extern int vcs_init(void);
292
extern int cy_init(void);
293
extern int stl_init(void);
294
extern int stli_init(void);
295
extern int riscom8_init(void);
296
extern int specialix_init(void);
297
extern int baycom_init(void);
298
extern int rs68328_init(void);
299
extern int rs68332_init(void);
300
 
301
extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
302
                              const char *routine);
303
extern char *_tty_name(struct tty_struct *tty, char *buf);
304
extern char *tty_name(struct tty_struct *tty);
305
extern void tty_wait_until_sent(struct tty_struct * tty, int timeout);
306
extern int tty_check_change(struct tty_struct * tty);
307
extern void stop_tty(struct tty_struct * tty);
308
extern void start_tty(struct tty_struct * tty);
309
extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
310
extern int tty_register_driver(struct tty_driver *driver);
311
extern int tty_unregister_driver(struct tty_driver *driver);
312
extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
313
                             int buflen);
314
extern void tty_write_message(struct tty_struct *tty, char *msg);
315
 
316
extern int is_orphaned_pgrp(int pgrp);
317
extern int is_ignored(int sig);
318
extern int tty_signal(int sig, struct tty_struct *tty);
319
extern void tty_hangup(struct tty_struct * tty);
320
extern void tty_vhangup(struct tty_struct * tty);
321
extern void tty_unhangup(struct file *filp);
322
extern int tty_hung_up_p(struct file * filp);
323
extern void do_SAK(struct tty_struct *tty);
324
extern void disassociate_ctty(int priv);
325
 
326
/* n_tty.c */
327
extern struct tty_ldisc tty_ldisc_N_TTY;
328
 
329
/* tty_ioctl.c */
330
extern int n_tty_ioctl(struct tty_struct * tty, struct file * file,
331
                       unsigned int cmd, unsigned long arg);
332
 
333
/* serial.c */
334
 
335
extern int  rs_open(struct tty_struct * tty, struct file * filp);
336
 
337
/* pty.c */
338
 
339
extern int  pty_open(struct tty_struct * tty, struct file * filp);
340
extern int pcxe_open(struct tty_struct *tty, struct file *filp);
341
 
342
/* console.c */
343
 
344
extern int con_open(struct tty_struct * tty, struct file * filp);
345
extern void update_screen(int new_console);
346
extern void console_print(const char *);
347
 
348
/* vt.c */
349
 
350
extern int vt_ioctl(struct tty_struct *tty, struct file * file,
351
                    unsigned int cmd, unsigned long arg);
352
 
353
#endif /* __KERNEL__ */
354
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.