FreeBSD/Linux Kernel Cross Reference
sys/drivers/tty/tty.h
1 /* tty.h - Terminals */
2
3 #include <timers.h>
4 #include "../../kernel/const.h"
5 #include "../../kernel/type.h"
6
7 #undef lock
8 #undef unlock
9
10 /* First minor numbers for the various classes of TTY devices. */
11 #define CONS_MINOR 0
12 #define LOG_MINOR 15
13 #define RS232_MINOR 16
14 #define TTYPX_MINOR 128
15 #define PTYPX_MINOR 192
16
17 #define LINEWRAP 1 /* console.c - wrap lines at column 80 */
18
19 #define TTY_IN_BYTES 256 /* tty input queue size */
20 #define TAB_SIZE 8 /* distance between tab stops */
21 #define TAB_MASK 7 /* mask to compute a tab stop position */
22
23 #define ESC '\33' /* escape */
24
25 #define O_NOCTTY 00400 /* from <fcntl.h>, or cc will choke */
26 #define O_NONBLOCK 04000
27
28 struct tty;
29 typedef _PROTOTYPE( int (*devfun_t), (struct tty *tp, int try_only) );
30 typedef _PROTOTYPE( void (*devfunarg_t), (struct tty *tp, int c) );
31
32 typedef struct tty {
33 int tty_events; /* set when TTY should inspect this line */
34 int tty_index; /* index into TTY table */
35 int tty_minor; /* device minor number */
36
37 /* Input queue. Typed characters are stored here until read by a program. */
38 u16_t *tty_inhead; /* pointer to place where next char goes */
39 u16_t *tty_intail; /* pointer to next char to be given to prog */
40 int tty_incount; /* # chars in the input queue */
41 int tty_eotct; /* number of "line breaks" in input queue */
42 devfun_t tty_devread; /* routine to read from low level buffers */
43 devfun_t tty_icancel; /* cancel any device input */
44 int tty_min; /* minimum requested #chars in input queue */
45 timer_t tty_tmr; /* the timer for this tty */
46
47 /* Output section. */
48 devfun_t tty_devwrite; /* routine to start actual device output */
49 devfunarg_t tty_echo; /* routine to echo characters input */
50 devfun_t tty_ocancel; /* cancel any ongoing device output */
51 devfun_t tty_break; /* let the device send a break */
52
53 /* Terminal parameters and status. */
54 int tty_position; /* current position on the screen for echoing */
55 char tty_reprint; /* 1 when echoed input messed up, else 0 */
56 char tty_escaped; /* 1 when LNEXT (^V) just seen, else 0 */
57 char tty_inhibited; /* 1 when STOP (^S) just seen (stops output) */
58 char tty_pgrp; /* slot number of controlling process */
59 char tty_openct; /* count of number of opens of this tty */
60
61 /* Information about incomplete I/O requests is stored here. */
62 char tty_inrepcode; /* reply code, TASK_REPLY or REVIVE */
63 char tty_inrevived; /* set to 1 if revive callback is pending */
64 char tty_incaller; /* process that made the call (usually FS) */
65 char tty_inproc; /* process that wants to read from tty */
66 vir_bytes tty_in_vir; /* virtual address where data is to go */
67 int tty_inleft; /* how many chars are still needed */
68 int tty_incum; /* # chars input so far */
69 char tty_outrepcode; /* reply code, TASK_REPLY or REVIVE */
70 char tty_outrevived; /* set to 1 if revive callback is pending */
71 char tty_outcaller; /* process that made the call (usually FS) */
72 char tty_outproc; /* process that wants to write to tty */
73 vir_bytes tty_out_vir; /* virtual address where data comes from */
74 int tty_outleft; /* # chars yet to be output */
75 int tty_outcum; /* # chars output so far */
76 char tty_iocaller; /* process that made the call (usually FS) */
77 char tty_ioproc; /* process that wants to do an ioctl */
78 int tty_ioreq; /* ioctl request code */
79 vir_bytes tty_iovir; /* virtual address of ioctl buffer */
80
81 /* select() data */
82 int tty_select_ops; /* which operations are interesting */
83 int tty_select_proc; /* which process wants notification */
84
85 /* Miscellaneous. */
86 devfun_t tty_ioctl; /* set line speed, etc. at the device level */
87 devfun_t tty_close; /* tell the device that the tty is closed */
88 void *tty_priv; /* pointer to per device private data */
89 struct termios tty_termios; /* terminal attributes */
90 struct winsize tty_winsize; /* window size (#lines and #columns) */
91
92 u16_t tty_inbuf[TTY_IN_BYTES];/* tty input buffer */
93
94 } tty_t;
95
96 /* Memory allocated in tty.c, so extern here. */
97 extern tty_t tty_table[NR_CONS+NR_RS_LINES+NR_PTYS];
98 extern int ccurrent; /* currently visible console */
99 extern int irq_hook_id; /* hook id for keyboard irq */
100
101 extern unsigned long kbd_irq_set;
102 extern unsigned long rs_irq_set;
103
104 /* Values for the fields. */
105 #define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */
106 #define ESCAPED 1 /* previous character was LNEXT (^V) */
107 #define RUNNING 0 /* no STOP (^S) has been typed to stop output */
108 #define STOPPED 1 /* STOP (^S) has been typed to stop output */
109
110 /* Fields and flags on characters in the input queue. */
111 #define IN_CHAR 0x00FF /* low 8 bits are the character itself */
112 #define IN_LEN 0x0F00 /* length of char if it has been echoed */
113 #define IN_LSHIFT 8 /* length = (c & IN_LEN) >> IN_LSHIFT */
114 #define IN_EOT 0x1000 /* char is a line break (^D, LF) */
115 #define IN_EOF 0x2000 /* char is EOF (^D), do not return to user */
116 #define IN_ESC 0x4000 /* escaped by LNEXT (^V), no interpretation */
117
118 /* Times and timeouts. */
119 #define force_timeout() ((void) (0))
120
121 /* Memory allocated in tty.c, so extern here. */
122 extern timer_t *tty_timers; /* queue of TTY timers */
123 extern clock_t tty_next_timeout; /* next TTY timeout */
124
125 /* Number of elements and limit of a buffer. */
126 #define buflen(buf) (sizeof(buf) / sizeof((buf)[0]))
127 #define bufend(buf) ((buf) + buflen(buf))
128
129 /* Memory allocated in tty.c, so extern here. */
130 extern struct machine machine; /* machine information (a.o.: pc_at, ega) */
131
132 /* The tty outputs diagnostic messages in a circular buffer. */
133 extern struct kmessages kmess;
134
135 /* Function prototypes for TTY driver. */
136 /* tty.c */
137 _PROTOTYPE( void handle_events, (struct tty *tp) );
138 _PROTOTYPE( void sigchar, (struct tty *tp, int sig) );
139 _PROTOTYPE( void tty_task, (void) );
140 _PROTOTYPE( int in_process, (struct tty *tp, char *buf, int count) );
141 _PROTOTYPE( void out_process, (struct tty *tp, char *bstart, char *bpos,
142 char *bend, int *icount, int *ocount) );
143 _PROTOTYPE( void tty_wakeup, (clock_t now) );
144 _PROTOTYPE( void tty_reply, (int code, int replyee, int proc_nr,
145 int status) );
146 _PROTOTYPE( int tty_devnop, (struct tty *tp, int try) );
147 _PROTOTYPE( int select_try, (struct tty *tp, int ops) );
148 _PROTOTYPE( int select_retry, (struct tty *tp) );
149
150 /* rs232.c */
151 _PROTOTYPE( void rs_init, (struct tty *tp) );
152 _PROTOTYPE( void rs_interrupt, (message *m) );
153
154 #if (CHIP == INTEL)
155 /* console.c */
156 _PROTOTYPE( void kputc, (int c) );
157 _PROTOTYPE( void cons_stop, (void) );
158 _PROTOTYPE( void do_new_kmess, (message *m) );
159 _PROTOTYPE( void do_diagnostics, (message *m) );
160 _PROTOTYPE( void do_get_kmess, (message *m) );
161 _PROTOTYPE( void scr_init, (struct tty *tp) );
162 _PROTOTYPE( void toggle_scroll, (void) );
163 _PROTOTYPE( int con_loadfont, (message *m) );
164 _PROTOTYPE( void select_console, (int cons_line) );
165
166 /* keyboard.c */
167 _PROTOTYPE( void kb_init, (struct tty *tp) );
168 _PROTOTYPE( void kb_init_once, (void) );
169 _PROTOTYPE( int kbd_loadmap, (message *m) );
170 _PROTOTYPE( void do_panic_dumps, (message *m) );
171 _PROTOTYPE( void do_fkey_ctl, (message *m) );
172 _PROTOTYPE( void kbd_interrupt, (message *m) );
173
174 /* pty.c */
175 _PROTOTYPE( void do_pty, (struct tty *tp, message *m_ptr) );
176 _PROTOTYPE( void pty_init, (struct tty *tp) );
177 _PROTOTYPE( void select_retry_pty, (struct tty *tp) );
178 _PROTOTYPE( int pty_status, (message *m_ptr) );
179
180 /* vidcopy.s */
181 _PROTOTYPE( void vid_vid_copy, (unsigned src, unsigned dst, unsigned count));
182 _PROTOTYPE( void mem_vid_copy, (u16_t *src, unsigned dst, unsigned count));
183
184 #endif /* (CHIP == INTEL) */
185
Cache object: d5bae1e6f26db615f5962000923f4df1
|