source: trunk/minix/drivers/tty/tty.h@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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