/* ttyold.c 4.1 11/9/80 */
* general TTY subroutines
* When running dz's using only SAE (silo alarm) on input
* it is necessary to call dzrint() at clock interrupt time.
* This is unsafe unless spl5()s in tty code are changed to
* spl6()s to block clock interrupts. Note that the dh driver
* currently in use works the same way as the dz, even though
* we could try to more intelligently manage its silo.
* Thus don't take this out if you have no dz's unless you
* change clock.c and dhtimer().
* Input mapping table-- if an entry is non-zero, when the
* corresponding character is typed preceded by "\" the escape
* sequence is replaced by the table value. Mostly used for
* upper-case only terminals.
* routine called on first teletype open.
* establishes a process group for distribution
* of quits and interrupts from the tty.
register struct proc
*pp
;
tp
->t_line
= 0; /* conservative */
* transfer raw input list to canonical list,
* doing erase-kill processing and handling escapes.
* It waits until a full line has been typed in cooked mode,
* or until any character has been typed in raw mode.
if ((tp
->t_flags
&(RAW
|CBREAK
))==0 && tp
->t_delct
==0
|| (tp
->t_flags
&(RAW
|CBREAK
))!=0 && tp
->t_rawq
.c_cc
==0) {
while ((c
=getc(&tp
->t_rawq
)) >= 0) {
if ((tp
->t_flags
&(RAW
|CBREAK
))==0) {
if (c
==tp
->t_erase
|| c
==tp
->t_kill
)
if (mc
&& (mc
==c
|| (tp
->t_flags
&LCASE
))) {
(void) b_to_q(bp1
, bp
-bp1
, &tp
->t_canq
);
if (tp
->t_state
&TBLOCK
&& tp
->t_rawq
.c_cc
< TTYHOG
/5) {
if (putc(tun
.t_startc
, &tp
->t_outq
)==0) {
* block transfer input handler.
tandem
= tp
->t_flags
&TANDEM
;
(void) b_to_q(pb
, pe
-pb
, &tp
->t_rawq
);
(void) sdata(tp
->t_chan
); else
wakeup((caddr_t
)&tp
->t_rawq
);
* Place a character on raw TTY input queue, putting in delimiters
* and waking up top half as needed.
* The arguments are the character and the appropriate
register struct chan
*cp
;
if (tp
->t_state
&TTSTOP
) {
(*cdevsw
[major(tp
->t_dev
)].d_stop
)(tp
);
if (c
==tun
.t_quitc
|| c
==tun
.t_intrc
) {
flushtty(tp
, FREAD
|FWRITE
);
c
= (c
==tun
.t_intrc
) ? SIGINT
:SIGQUIT
;
scontrol(tp
->t_chan
, M_SIG
, c
);
if (c
=='\r' && t_flags
&CRMOD
)
if (tp
->t_rawq
.c_cc
>TTYHOG
) {
flushtty(tp
, FREAD
|FWRITE
);
if (t_flags
&LCASE
&& c
>='A' && c
<='Z')
(void) putc(c
, &tp
->t_rawq
);
if (t_flags
&(RAW
|CBREAK
)||(c
=='\n'||c
==tun
.t_eofc
||c
==tun
.t_brkc
)) {
if ((t_flags
&(RAW
|CBREAK
))==0 && putc(0377, &tp
->t_rawq
)==0)
if ((cp
=tp
->t_chan
)!=NULL
)
wakeup((caddr_t
)&tp
->t_rawq
);
if (c
==tp
->t_kill
&& (t_flags
&(RAW
|CBREAK
))==0)
* put character on TTY output queue, adding delays,
* expanding tabs, and handling the CR/NL bit.
* It is called both from the top half for output, and from
* interrupt level for echoing.
* The arguments are the character and the tty structure.
* Ignore EOT in normal mode to avoid hanging up
* In raw mode dump the char unchanged.
if ((tp
->t_flags
&RAW
)==0) {
if ((tp
->t_flags
&CBREAK
)==0 && c
==CEOT
)
(void) putc(c
, &tp
->t_outq
);
* Turn tabs to spaces as required
if (c
=='\t' && (tp
->t_flags
&TBDELAY
)==XTABS
) {
(void) b_to_q(" ", c
, &tp
->t_outq
);
* for upper-case-only terminals,
* turn <nl> to <cr><lf> if desired.
if (c
=='\n' && tp
->t_flags
&CRMOD
)
(void) putc(c
, &tp
->t_outq
);
* The numbers here represent clock ticks
* and are not necessarily optimal for all terminals.
* The delays are indicated by characters above 0200.
* In raw mode there are no delays and the
* transmission path is 8 bits wide.
ctype
= (tp
->t_flags
>> 8) & 03;
if(ctype
== 1) { /* tty 37 */
c
= max(((unsigned)*colp
>>4) + 3, (unsigned)6);
if(ctype
== 2) { /* vt05 */
ctype
= (tp
->t_flags
>> 10) & 03;
if(ctype
== 1) { /* tty 37 */
if(tp
->t_flags
& VTDELAY
) /* tty 37 */
ctype
= (tp
->t_flags
>> 12) & 03;
if(ctype
== 1) { /* tn 300 */
} else if(ctype
== 2) { /* ti 700 */
} else if(ctype
== 3) { /* concept 100 */
(void) putc(0177, &tp
->t_outq
);
(void) putc(c
|0200, &tp
->t_outq
);
* Called from device's read routine after it has
* calculated the tty-structure given as argument.
if ((tp
->t_state
&CARR_ON
)==0)
sleep((caddr_t
)&tp
->t_rawq
, TTIPRI
);
while (tp
->t_canq
.c_cc
&& passc(getc(&tp
->t_canq
))>=0)
return(tp
->t_rawq
.c_cc
+tp
->t_canq
.c_cc
);
* Called from the device's write routine after it has
* calculated the tty-structure given as argument.
* THE POSITIONING OF CP, CC, AND CE ARE CRITICAL
* AND MUST NOT BE CHANGED WITHOUT PATCHING
* THE 'ASM' INLINES BELOW. WATCH OUT.
if ((tp
->t_state
&CARR_ON
)==0)
cc
= MIN(u
.u_count
, OBUFSIZ
);
iomove(cp
, (unsigned)cc
, B_WRITE
);
while (tp
->t_outq
.c_cc
> hiwat
) {
return((caddr_t
)&tp
->t_outq
);
sleep((caddr_t
)&tp
->t_outq
, TTOPRI
);
asm(" scanc r9,(r10),_partab,$077");
while(((partab
[*(unsigned char *)(cp
+ce
)]&077)==0)&&(ce
<cc
))
i
=b_to_q(cp
,ce
,&tp
->t_outq
);
if (tp
->t_outq
.c_cc
> hiwat
) {
while (tp
->t_outq
.c_cc
> hiwat
) {
sleep((caddr_t
)&tp
->t_outq
, TTOPRI
);