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