From 2e6ee3cfe6192bdd5a7470d89b662e2e6c4eba17 Mon Sep 17 00:00:00 2001 From: Jim Date: Sat, 31 Mar 2007 00:00:00 -0400 Subject: [PATCH] telnet server updates, RPH segment tracing specific RPH segment tracing simple telnet server option handling put telnet connection in binary mode --- em.c | 16 ++++++--- emdev.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/em.c b/em.c index a5e5cd6..63bca87 100644 --- a/em.c +++ b/em.c @@ -295,11 +295,13 @@ char gen0nam[][5] = { traceuser is the user number to trace, 0 meaning any user + traceseg is the procedure segment number to trace, 0 meaning any + savetraceflags hold the real traceflags, while "traceflags" switches on and off for each instruction - traceprocs is an array of procedure names we're tracing, with flags - and associated data + traceprocs is an array of (operating system) procedure names we're + tracing, with flags and associated data numtraceprocs is the number of entries in traceprocs, 0=none @@ -309,6 +311,7 @@ char gen0nam[][5] = { int traceflags=0; /* each bit is a trace flag */ int savetraceflags=0; int traceuser=0; /* OWNERL to trace */ +int traceseg=0; /* RPH segment # to trace */ int numtraceprocs=0; #define MAXTRACEPROCS 2 struct { @@ -741,7 +744,10 @@ unsigned short get16t(ea_t ea, ea_t rpring) { fatal(NULL); } -inline unsigned short get16r(ea_t ea, ea_t rpring) { +/* NOTE: when get16r was inlined, Magsav worked but Magrst failed, + and the tape files created by Magsav were garbage */ + +unsigned short get16r(ea_t ea, ea_t rpring) { unsigned short access; /* sign bit is set for live register access */ @@ -3000,6 +3006,8 @@ main (int argc, char **argv) { traceuser = 0100000 | (templ<<6); /* form OWNERL for user # */ else if (strlen(argv[i]) == 6 && sscanf(argv[i],"%o", &templ) == 1) traceuser = templ; /* specify OWNERL directly */ + else if (strlen(argv[i]) == 4 && sscanf(argv[i],"%o", &templ) == 1) + traceseg = templ; /* specify RPH segno */ else if (strlen(argv[i]) <= 8 && argv[i][0] != '-') { if (numtraceprocs >= MAXTRACEPROCS) fprintf(stderr,"Only %d trace procs are allowed\n", MAXTRACEPROCS); @@ -3249,7 +3257,7 @@ For disk boots, the last 3 digits can be:\n\ /* is this user being traced? */ - if (TRACEUSER) + if (TRACEUSER && ((traceseg == 0) || (traceseg == (RPH & 0xFFF)))) traceflags = savetraceflags; else traceflags = 0; diff --git a/emdev.h b/emdev.h index 16905d0..c0fa11c 100644 --- a/emdev.h +++ b/emdev.h @@ -1976,7 +1976,7 @@ int devamlc (int class, int func, int device) { #define MAXFD MAXLINES+20 #define MAXBOARDS 8 /* AMLC poll rate in milliseconds */ -#define AMLCPOLL 50 +#define AMLCPOLL 75 #if 1 #define QAMLC 020000 /* this is to enable QAMLC/DMQ functionality */ @@ -1984,6 +1984,13 @@ int devamlc (int class, int func, int device) { #define QAMLC 0 #endif + /* terminal states needed to process telnet connections */ + +#define TS_DATA 0 /* data state, looking for IAC */ +#define TS_IAC 1 /* have seen initial IAC */ +#define TS_SUBOPT 2 /* inside a suboption */ +#define TS_OPTION 3 /* inside an option */ + static short inited = 0; static short devices[MAXBOARDS]; /* list of AMLC devices initialized */ static int tsfd; /* socket fd for terminal server */ @@ -1998,13 +2005,14 @@ int devamlc (int class, int func, int device) { unsigned short dmcchan; /* DMC channel (for input) */ unsigned short baseaddr; /* DMT/Q base address (for output) */ unsigned short intvector; /* interrupt vector */ - char intenable; /* interrupts enabled? */ - char interrupting; /* am I interrupting? */ + unsigned short intenable; /* interrupts enabled? */ + unsigned short interrupting; /* am I interrupting? */ unsigned short xmitenabled; /* 1 bit per line */ unsigned short recvenabled; /* 1 bit per line */ unsigned short ctinterrupt; /* 1 bit per line */ unsigned short dss; /* 1 bit per line */ unsigned short sockfd[16]; /* Unix socket fd, 1 per line */ + unsigned short tstate[16]; /* terminal state (telnet) */ } dc[64]; int lx; @@ -2022,6 +2030,8 @@ int devamlc (int class, int func, int device) { int i, n, nw, newdevice; fd_set fds; struct timeval timeout; + unsigned char ch; + int state; switch (class) { @@ -2055,7 +2065,7 @@ int devamlc (int class, int func, int device) { perror("listen failed for AMLC"); fatal(NULL); } - if (fcntl(tsfd, F_GETFL, tsflags) == -1) { + if ((tsflags = fcntl(tsfd, F_GETFL)) == -1) { perror("unable to get ts flags for AMLC"); fatal(NULL); } @@ -2146,7 +2156,7 @@ int devamlc (int class, int func, int device) { IOSKIP; } else if (func == 07) { /* input AMLC status */ - crs[A] = 040000 | (dc[device].bufnum<<8) | (dc[device].intenable<<5) || (dc[device].dmqmode<<4); + crs[A] = 040000 | (dc[device].bufnum<<8) | (dc[device].intenable<<5) | (dc[device].dmqmode<<4); if (dc[device].eor) { crs[A] |= 0100000; dc[device].eor = 0; @@ -2245,20 +2255,43 @@ int devamlc (int class, int func, int device) { fatal("New connection fd is too big"); newdevice = 0; for (i=0; devices[i] && !newdevice && i 0) { + state = dc[device].tstate[lx]; for (i=0; i dmcbufendea) + fatal("AMLC tumble table overflowed?"); put16r0(dmcbufbegea, dmcea); if (dmcbufbegea > dmcbufendea) { /* end of range has occurred */ dc[device].bufnum = 1-dc[device].bufnum;