Project

General

Profile

Statistics
| Branch: | Revision:

root / prex-0.9.0 / bsp / drv / include / tty.h @ 03e9c04a

History | View | Annotate | Download (3.76 KB)

1 03e9c04a Brad Neuman
/*-
2
 * Copyright (c) 1982, 1986, 1993
3
 *        The Regents of the University of California.  All rights reserved.
4
 * (c) UNIX System Laboratories, Inc.
5
 * All or some portions of this file are derived from material licensed
6
 * to the University of California by American Telephone and Telegraph
7
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8
 * the permission of UNIX System Laboratories, Inc.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in the
17
 *    documentation and/or other materials provided with the distribution.
18
 * 3. Neither the name of the University nor the names of its contributors
19
 *    may be used to endorse or promote products derived from this software
20
 *    without specific prior written permission.
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32
 * SUCH DAMAGE.
33
 *
34
 *        @(#)tty.h        8.7 (Berkeley) 1/9/95
35
 */
36
37
#ifndef _SYS_TTY_H_
38
#define _SYS_TTY_H_
39
40
#include <sys/cdefs.h>
41
#include <sys/termios.h>
42
#include <sys/syslimits.h>
43
44
#define TTYQ_SIZE        MAX_INPUT
45
#define TTYQ_HIWAT        (TTYQ_SIZE - 10)
46
47
struct tty_queue {
48
        char        tq_buf[TTYQ_SIZE];
49
        int        tq_head;
50
        int        tq_tail;
51
        int        tq_count;
52
};
53
54
/*
55
 * Per-tty structure.
56
 */
57
struct tty {
58
        struct tty_queue t_rawq;        /* raw input queue */
59
        struct tty_queue t_canq;        /* canonical queue */
60
        struct tty_queue t_outq;        /* ouput queue */
61
        struct termios        t_termios;        /* termios state */
62
        struct winsize        t_winsize;        /* window size */
63
        struct event        t_input;        /* event for input data ready */
64
        struct event        t_output;        /* event for output completion */
65
        void (*t_oproc)(struct tty *);        /* routine to start output */
66
        device_t        t_dev;                /* device */
67
        int                t_state;        /* driver state */
68
        int                t_column;        /* tty output column */
69
        pid_t                t_pgid;                /* foreground process group. */
70
        task_t                t_sigtask;        /* task to dispatch the tty signal */
71
        int                t_signo;        /* pending signal# */
72
        struct dpc        t_dpc;                /* dpc for tty */
73
};
74
75
#define        t_iflag                t_termios.c_iflag
76
#define        t_oflag                t_termios.c_oflag
77
#define        t_cflag                t_termios.c_cflag
78
#define        t_lflag                t_termios.c_lflag
79
#define        t_cc                t_termios.c_cc
80
#define        t_ispeed        t_termios.c_ispeed
81
#define        t_ospeed        t_termios.c_ospeed
82
83
/* These flags are kept in t_state. */
84
#define        TS_ASLEEP        0x00001                /* Process waiting for tty. */
85
#define        TS_BUSY                0x00004                /* Draining output. */
86
#define        TS_TIMEOUT        0x00100                /* Wait for output char processing. */
87
#define        TS_TTSTOP        0x00200                /* Output paused. */
88
#define        TS_ISIG                0x00400                /* Input is interrupted by signal. */
89
90
__BEGIN_DECLS
91
int         tty_read(struct tty *, char *, size_t *);
92
int         tty_write(struct tty *, char *, size_t *);
93
int         tty_ioctl(struct tty *, u_long, void *);
94
void         tty_input(int, struct tty *);
95
int         tty_getc(struct tty_queue *);
96
void         tty_done(struct tty *);
97
void         tty_attach(struct tty *);
98
__END_DECLS
99
100
#endif /* !_SYS_TTY_H_ */