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:
Oliver Lehmann 2008-05-03 22:10:19 +00:00
parent 6c214e73e5
commit 84e28c465d
1 changed files with 504 additions and 487 deletions

View File

@ -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,30 +20,40 @@
#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();
mode = tp->t_iflag; mode = tp->t_iflag;
if (count){ if( count) {
if (count == 1) if(count == 1)
goto L214; goto L214;
putcb(c, tp); putcb(c, tp);
sysinfo.rawch += count; sysinfo.rawch += count;
@ -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; if (tp->t_state&OEXTPROC)
register char *cp; flg &= ~OPOST;
char *colp; if (ncode == 0) {
int pch, vch; if (tp->t_outq.c_cc >= TTYHOG)
struct cblock *cbp; return;
ncode++;
mode = tp->t_oflag; if (!(flg&OPOST)) {
if (tp->t_state & OEXTPROC)
mode &= ~OPOST;
if (!(count)) {
if (tp->t_outq.c_cc >= TTYHOG) return;
count++;
if (!(mode & 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(count--){ while (ncode--) {
ch = (unsigned char) (*cp++); c = *cp++;
if (ch >= DELAYDEL){ /* b7 */ if (c >= DELAYDEL){
if (ch == DELAYDEL) if (c == 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;
} }
if (tp->t_lflag & XCASE){ /*
for ( colp = "({)}!|^~'`\\"; (*colp++); ) * Generate escapes for upper-case-only terminals.
if (ch == *colp++){ */
if (tp->t_lflag&XCASE) {
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);
}
} }
else goto cr;
goto nldly;
} }
goto crdly; nl:
case 4: if (flg&NLDLY)
ch = 8 - (*colp & 7); c = 5;
*colp += ch; break;
pch = mode & TABDLY; case 4: /* tab */
if (pch == 0){ c = 8 - ((*colp)&07);
ch = 0; *colp += c;
break; ctype = flg&TABDLY;
} if (ctype == TAB0) {
if (pch == TAB1){ c = 0;
if (ch < 5) } else if (ctype == TAB1) {
ch = 0; if (c < 5)
break; c = 0;
} } else if (ctype == TAB2) {
if (pch == TAB2){ c = 2;
ch = 2; } else if (ctype == TAB3) {
break; sysinfo.outch += c;
}
if (pch == TAB3){
sysinfo.outch += ch;
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)
c = 0177;
break; break;
case 6:
if (mode & OCRNL){ case 6: /* carriage return */
vch = '\n'; if (flg&OCRNL) {
nldly: cs = '\n';
if (mode & NLDLY) goto nl;
ch = 5;
break;
} }
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)
if (tp->t_state & RTO){ /* timeout waiting on rawq */ return; /* time out */
tp->t_delct = 1; if (( tp->t_rawq.c_cc == 0) && (tp->t_cc[VMIN]))
if (!(tp->t_state & IASLP)) return; /* wakeup when input done */
tp->t_state &= ~IASLP;
wakeup(tp);
return; return;
if (tp->t_state&RTO) { /* timeout waiting on rawq */
tp->t_delct = 1;
if (tp->t_state&IASLP) {/* wakeup when input done */
tp->t_state &= ~IASLP;
wakeup(tp);
}
} else {
tp->t_state |= RTO|TACT;
timeout(tttimeo, tp, tp->t_cc[VTIME]*(HZ/10));
} }
tp->t_state |= (RTO | TACT);
timeout(tttimeout, tp, tp->t_cc[VTIME] * 6);
} }
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;
} }