TODO: still not 100% equal
changed much code to get it more equal. changed also code to make the diff to the plexis sources I have as small as possible while getting the same object code
This commit is contained in:
parent
6c214e73e5
commit
84e28c465d
|
|
@ -1,3 +1,16 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle
|
||||||
|
KERN 3.2 Modul : tt0.c
|
||||||
|
|
||||||
|
Bearbeiter : O. Lehmann
|
||||||
|
Datum : 03.05.08
|
||||||
|
Version : 1.0
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/state.h>
|
#include <sys/state.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
|
@ -7,24 +20,34 @@
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
#include <sys/ttold.h>
|
#include <sys/ttold.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/inode.h>
|
#include <sys/inode.h>
|
||||||
#include <sys/mmu.h>
|
#include <sys/mmu.h>
|
||||||
#include <sys/s.out.h>
|
#include <sys/s.out.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
extern putcb();
|
/*
|
||||||
|
* Line discipline 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
char tt0wstr[] = "@[$]tt0.c Rev : 4.1 09/29/83 01:02:58";
|
||||||
|
|
||||||
|
|
||||||
|
extern putcb();
|
||||||
|
extern char partab[];
|
||||||
|
|
||||||
|
#ifdef 0
|
||||||
ttin(tp, c, count)
|
ttin(tp, c, count)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
long c;
|
long c;
|
||||||
int count;
|
int count;
|
||||||
{
|
{
|
||||||
|
|
||||||
register ushort ch;
|
register ushort ch;
|
||||||
register ushort mode;
|
register ushort mode;
|
||||||
register char *cp;
|
register char *cp;
|
||||||
char *csp;
|
char *csp;
|
||||||
|
char *foo;
|
||||||
|
|
||||||
extern tttimeo();
|
extern tttimeo();
|
||||||
|
|
||||||
|
|
@ -216,22 +239,25 @@ L494:
|
||||||
if (mode & IUCLC) /* 35 */
|
if (mode & IUCLC) /* 35 */
|
||||||
c = toupper(c);
|
c = toupper(c);
|
||||||
L214:
|
L214:
|
||||||
if (putc(c, tp)){/* 38 */
|
if (putc(c, tp))
|
||||||
|
return;
|
||||||
sysinfo.rawch++;
|
sysinfo.rawch++;
|
||||||
cp = &lobyte(c.half.right);
|
cp = &lobyte(c.half.right);
|
||||||
goto L5a;
|
goto L5a;
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put character(s) on TTY output queue, adding delays,
|
||||||
|
* expanding tabs, and handling the CR/NL bit.
|
||||||
extern char partab[];
|
* It is called both from the top half for output, and from
|
||||||
ttxput(tp, arg, count)
|
* interrupt level for echoing.
|
||||||
|
*/
|
||||||
|
ttxput(tp, ucp, ncode)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
union {
|
union {
|
||||||
long c;
|
long ch;
|
||||||
struct cblock *cb;
|
struct cblock *ptr;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char l_l;
|
char l_l;
|
||||||
|
|
@ -240,240 +266,230 @@ union {
|
||||||
char r_r;
|
char r_r;
|
||||||
}
|
}
|
||||||
byte;
|
byte;
|
||||||
}
|
} ucp;
|
||||||
arg;
|
int ncode;
|
||||||
int count;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
register c;
|
||||||
|
register flg;
|
||||||
|
register unsigned char *cp;
|
||||||
|
register char *colp;
|
||||||
|
int ctype;
|
||||||
|
register int cs;
|
||||||
|
struct cblock *scf;
|
||||||
|
|
||||||
register ch;
|
flg = tp->t_oflag;
|
||||||
register ushort mode;
|
|
||||||
register char *cp;
|
|
||||||
char *colp;
|
|
||||||
int pch, vch;
|
|
||||||
struct cblock *cbp;
|
|
||||||
|
|
||||||
mode = tp->t_oflag;
|
|
||||||
if (tp->t_state&OEXTPROC)
|
if (tp->t_state&OEXTPROC)
|
||||||
mode &= ~OPOST;
|
flg &= ~OPOST;
|
||||||
if (!(count)) {
|
if (ncode == 0) {
|
||||||
if (tp->t_outq.c_cc >= TTYHOG) return;
|
if (tp->t_outq.c_cc >= TTYHOG)
|
||||||
count++;
|
return;
|
||||||
if (!(mode & OPOST)){
|
ncode++;
|
||||||
|
if (!(flg&OPOST)) {
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(arg.r_r, &tp->t_outq);
|
putc(ucp.r_r, &tp->t_outq);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
cp = (unsigned char *)&ucp.r_r;
|
||||||
cp = &arg.r_r;
|
scf = NULL;
|
||||||
cbp = 0;
|
} else {
|
||||||
}
|
if (!(flg&OPOST)) {
|
||||||
}
|
sysinfo.outch += ncode;
|
||||||
else {
|
putcb(ucp.ch, &tp->t_outq);
|
||||||
if (!(mode & OPOST)){
|
|
||||||
sysinfo.outch += count;
|
|
||||||
putcb(arg.c, &tp->t_outq);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
cp = (unsigned char *)&ucp.ptr->c_data[ucp.ptr->c_first];
|
||||||
cp = &arg.cb->c_data[arg.cb->c_first];
|
scf = ucp.ptr;
|
||||||
cbp = arg.cb;
|
|
||||||
}
|
}
|
||||||
}
|
while (ncode--) {
|
||||||
while(count--){
|
c = *cp++;
|
||||||
ch = (unsigned char) (*cp++);
|
if (c >= DELAYDEL){
|
||||||
if (ch >= DELAYDEL){ /* b7 */
|
if (c == DELAYDEL)
|
||||||
if (ch == DELAYDEL)
|
|
||||||
putc(DELAYDEL, &tp->t_outq);
|
putc(DELAYDEL, &tp->t_outq);
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(ch, &tp->t_outq);
|
putc(c, &tp->t_outq);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Generate escapes for upper-case-only terminals.
|
||||||
|
*/
|
||||||
if (tp->t_lflag&XCASE) {
|
if (tp->t_lflag&XCASE) {
|
||||||
for ( colp = "({)}!|^~'`\\"; (*colp++); )
|
colp = "({)}!|^~'`\\";
|
||||||
if (ch == *colp++){
|
while(*colp++)
|
||||||
|
if (c == *colp++) {
|
||||||
tp->t_lflag &= ~XCASE;
|
tp->t_lflag &= ~XCASE;
|
||||||
ttxput(tp, (long)'\\', 0);
|
ttxput(tp, (long)'\\', 0);
|
||||||
tp->t_lflag |= XCASE;
|
tp->t_lflag |= XCASE;
|
||||||
ch = *(colp - 2);
|
c = colp[-2];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((ch >= 'A') && (ch <= 'Z')){
|
if ('A' <= c && c <= 'Z'){
|
||||||
tp->t_lflag &= ~XCASE;
|
tp->t_lflag &= ~XCASE;
|
||||||
ttxput(tp, (long)'\\', 0);
|
ttxput(tp, (long)'\\', 0);
|
||||||
tp->t_lflag |= XCASE;
|
tp->t_lflag |= XCASE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode & OLCUC)
|
if (flg&OLCUC && 'a' <= c && c <= 'z')
|
||||||
if ((ch >= 'a') &&
|
c += 'A' - 'a';
|
||||||
(ch <= 'z'))
|
cs = c;
|
||||||
ch += 'A'-'a';
|
/*
|
||||||
vch = ch;
|
* Calculate delays.
|
||||||
pch = partab[ch];
|
* The numbers here represent clock ticks
|
||||||
|
* and are not necessarily optimal for all terminals.
|
||||||
|
* The delays are indicated by characters above 0200.
|
||||||
|
*/
|
||||||
|
ctype = partab[c];
|
||||||
colp = &tp->t_col;
|
colp = &tp->t_col;
|
||||||
ch = 0;
|
c = 0;
|
||||||
switch (pch & 077){
|
switch (ctype&077) {
|
||||||
case 0:
|
case 0: /* ordinary */
|
||||||
(*colp)++;
|
(*colp)++;
|
||||||
|
|
||||||
|
case 1: /* non-printing */
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
if (mode & BS1)
|
case 2: /* backspace */
|
||||||
ch = 2;
|
if (flg&BSDLY)
|
||||||
|
c = 2;
|
||||||
if (*colp)
|
if (*colp)
|
||||||
(*colp)--;
|
(*colp)--;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3: /* line feed */
|
||||||
if (!(mode & ONLRET)){
|
if (flg&ONLRET)
|
||||||
if (mode & ONLCR){
|
goto cr;
|
||||||
if ((!(mode & ONOCR)) ||
|
if (flg&ONLCR) {
|
||||||
(*colp)){
|
if (!(flg&ONOCR && *colp==0)) {
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc('\r', &tp->t_outq);
|
putc('\r', &tp->t_outq);
|
||||||
}
|
}
|
||||||
|
goto cr;
|
||||||
}
|
}
|
||||||
else
|
nl:
|
||||||
goto nldly;
|
if (flg&NLDLY)
|
||||||
}
|
c = 5;
|
||||||
goto crdly;
|
|
||||||
case 4:
|
|
||||||
ch = 8 - (*colp & 7);
|
|
||||||
*colp += ch;
|
|
||||||
pch = mode & TABDLY;
|
|
||||||
if (pch == 0){
|
|
||||||
ch = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
case 4: /* tab */
|
||||||
if (pch == TAB1){
|
c = 8 - ((*colp)&07);
|
||||||
if (ch < 5)
|
*colp += c;
|
||||||
ch = 0;
|
ctype = flg&TABDLY;
|
||||||
break;
|
if (ctype == TAB0) {
|
||||||
}
|
c = 0;
|
||||||
if (pch == TAB2){
|
} else if (ctype == TAB1) {
|
||||||
ch = 2;
|
if (c < 5)
|
||||||
break;
|
c = 0;
|
||||||
}
|
} else if (ctype == TAB2) {
|
||||||
if (pch == TAB3){
|
c = 2;
|
||||||
sysinfo.outch += ch;
|
} else if (ctype == TAB3) {
|
||||||
|
sysinfo.outch += c;
|
||||||
do
|
do
|
||||||
putc(' ', &tp->t_outq);
|
putc(' ', &tp->t_outq);
|
||||||
while (--ch);
|
while (--c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
|
||||||
if (mode & VTDLY)
|
case 5: /* vertical tab */
|
||||||
ch = 0x7f;
|
if (flg&VTDLY)
|
||||||
break;
|
c = 0177;
|
||||||
case 6:
|
|
||||||
if (mode & OCRNL){
|
|
||||||
vch = '\n';
|
|
||||||
nldly:
|
|
||||||
if (mode & NLDLY)
|
|
||||||
ch = 5;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 6: /* carriage return */
|
||||||
|
if (flg&OCRNL) {
|
||||||
|
cs = '\n';
|
||||||
|
goto nl;
|
||||||
}
|
}
|
||||||
if ((mode & ONOCR) &&
|
if (flg&ONOCR && *colp == 0)
|
||||||
(*colp == 0))
|
|
||||||
continue;
|
continue;
|
||||||
crdly:
|
cr:
|
||||||
pch = mode & CRDLY;
|
ctype = flg&CRDLY;
|
||||||
if (pch == CR1){
|
if (ctype == CR1) {
|
||||||
if (*colp)
|
if (*colp)
|
||||||
ch = max((*colp>>4)+3, 6);
|
c = max((*colp>>4) + 3, 6);
|
||||||
|
} else if (ctype == CR2) {
|
||||||
|
c = 5;
|
||||||
|
} else if (ctype == CR3) {
|
||||||
|
c = 9;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (pch == CR2)
|
|
||||||
ch = 5;
|
|
||||||
else
|
|
||||||
if (pch == CR3)
|
|
||||||
ch = 9;
|
|
||||||
*colp = 0;
|
*colp = 0;
|
||||||
case 1:
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7: /* form feed */
|
||||||
if (mode & FFDLY)
|
if (flg&FFDLY)
|
||||||
ch = 0x7f;
|
c = 0177;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(vch, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
if (ch){
|
if (c) {
|
||||||
if ((ch < ' ') &&
|
if ((c < 32) && flg&OFILL) {
|
||||||
(mode & OFILL)){
|
if (flg&OFDEL)
|
||||||
if (mode & OFDEL)
|
cs = 0177;
|
||||||
vch = 0x7f;
|
|
||||||
else
|
else
|
||||||
vch = 0;
|
cs = 0;
|
||||||
putc(vch, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
if (ch > 3)
|
if (c > 3)
|
||||||
putc(vch, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
putc(DELAYDEL, &tp->t_outq);
|
putc(DELAYDEL, &tp->t_outq);
|
||||||
putc(ch | DELAYDEL, &tp->t_outq);
|
putc(c|DELAYDEL, &tp->t_outq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }
|
}
|
||||||
else {
|
if (scf != NULL)
|
||||||
putc(DELAYDEL, &tp->t_outq);
|
putcf(scf);
|
||||||
sysinfo.outch++;
|
|
||||||
putc(ch, &tp->t_outq);
|
|
||||||
continue;
|
|
||||||
} */
|
|
||||||
} /* von while */
|
|
||||||
if (cbp)
|
|
||||||
putcf(cbp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get next function from output queue.
|
||||||
|
* Called from xmit interrupt complete.
|
||||||
|
*/
|
||||||
ttout(tp)
|
ttout(tp)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern timeout();
|
extern timeout();
|
||||||
tttimeout(tp)
|
tttimeo(tp)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
{
|
{
|
||||||
|
|
||||||
tp->t_state &= ~TACT; /* timeout waiting on rawq */
|
tp->t_state &= ~TACT; /* timeout waiting on rawq */
|
||||||
if (tp->t_lflag & ICANON) return; /* enable canonicalization */
|
if (tp->t_lflag&ICANON)
|
||||||
if (tp->t_cc[VTIME] == 0) return; /* time out */
|
return; /* enable canonicalization */
|
||||||
if (( tp->t_rawq.c_cc == 0) && (tp->t_cc[VMIN])) return;
|
if (tp->t_cc[VTIME] == 0)
|
||||||
|
return; /* time out */
|
||||||
|
if (( tp->t_rawq.c_cc == 0) && (tp->t_cc[VMIN]))
|
||||||
|
return;
|
||||||
if (tp->t_state&RTO) { /* timeout waiting on rawq */
|
if (tp->t_state&RTO) { /* timeout waiting on rawq */
|
||||||
tp->t_delct = 1;
|
tp->t_delct = 1;
|
||||||
if (!(tp->t_state & IASLP)) return; /* wakeup when input done */
|
if (tp->t_state&IASLP) {/* wakeup when input done */
|
||||||
tp->t_state &= ~IASLP;
|
tp->t_state &= ~IASLP;
|
||||||
wakeup(tp);
|
wakeup(tp);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
tp->t_state |= (RTO | TACT);
|
} else {
|
||||||
timeout(tttimeout, tp, tp->t_cc[VTIME] * 6);
|
tp->t_state |= RTO|TACT;
|
||||||
|
timeout(tttimeo, tp, tp->t_cc[VTIME]*(HZ/10));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern putcb();
|
ttioctl(tp, cmd, arg)
|
||||||
|
|
||||||
ttioctl(tp, com, arg)
|
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
int com;
|
int cmd;
|
||||||
long arg;
|
long arg;
|
||||||
{
|
{
|
||||||
|
ushort chg;
|
||||||
|
|
||||||
ushort ldmode;
|
switch(cmd) {
|
||||||
|
|
||||||
switch(com) {
|
|
||||||
case LDCHG:
|
case LDCHG:
|
||||||
ldmode = tp->t_lflag ^ arg;
|
chg = tp->t_lflag^arg;
|
||||||
if (!(ldmode & ICANON))
|
if (!(chg&ICANON))
|
||||||
break;
|
break;
|
||||||
dvi();
|
dvi();
|
||||||
if (tp->t_canq.c_cc) {
|
if (tp->t_canq.c_cc) {
|
||||||
if (tp->t_rawq.c_cc) {
|
if (tp->t_rawq.c_cc) {
|
||||||
tp->t_canq.c_cc += tp->t_rawq.c_cc;
|
tp->t_canq.c_cc += tp->t_rawq.c_cc;
|
||||||
tp->t_canq.c_cl->c_next = tp->t_rawq.c_cf;
|
tp->t_canq.c_cl->c_next = tp->t_rawq.c_cf;
|
||||||
tp->t_outq.c_cf = tp->t_rawq.c_cl;
|
tp->t_canq.c_cl = tp->t_rawq.c_cl;
|
||||||
}
|
}
|
||||||
tp->t_rawq = tp->t_canq;
|
tp->t_rawq = tp->t_canq;
|
||||||
tp->t_canq = ttnulq;
|
tp->t_canq = ttnulq;
|
||||||
|
|
@ -481,6 +497,7 @@ long arg;
|
||||||
tp->t_delct = tp->t_rawq.c_cc;
|
tp->t_delct = tp->t_rawq.c_cc;
|
||||||
evi();
|
evi();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue