source: branches/minix3-book/drivers/tty/tty.h@ 4

Last change on this file since 4 was 4, checked in by Mattia Monga, 13 years ago

Importazione sorgenti libro

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