From 4061b6adc9f6ed7fac36e88688f269e7c7f10bd9 Mon Sep 17 00:00:00 2001 From: Jim Date: Wed, 25 Sep 2019 10:56:48 -0400 Subject: [PATCH] Changes to allow emulator to run on Linux for hosting at Linode --- devamlc.h | 11 +++++++---- devpnc.h | 8 ++++++-- em.c | 3 ++- emdev.h | 2 ++ makefile | 4 ++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/devamlc.h b/devamlc.h index 4c688e4..2088c09 100644 --- a/devamlc.h +++ b/devamlc.h @@ -174,7 +174,7 @@ int devamlc (int class, int func, int device) { #ifdef DEMO #define AMLCLINESPERBOARD 1 - #define MAXLINES 1 + #define MAXLINES 2 #define MAXBOARDS 1 #else #define AMLCLINESPERBOARD 16 @@ -405,9 +405,9 @@ int devamlc (int class, int func, int device) { //printf("devamlc: lc=%d, line '%o (%d) set to device %s\n", lc, i, i, devname); dx = i/16; lx = i & 0xF; - if (devname[0] == '/') { /* USB serial port */ + if (devname[0] == '/') { /* USB serial port (not tested on Linux) */ int fd; - if ((fd = open(devname, O_RDWR | O_NONBLOCK | O_EXLOCK)) == -1) { + if ((fd = open(devname, O_RDWR | O_NONBLOCK)) == -1 || flock(fd, LOCK_EX) == -1) { printf("em: error connecting AMLC line '%o (%d) to device %s: %s\n", i, i, devname, strerror(errno)); continue; } @@ -562,6 +562,7 @@ int devamlc (int class, int func, int device) { #define TIOCM_CD 0x0100 if (func == 00) { /* input Data Set Sense (carrier) */ +#ifdef __APPLE__ if (dc[dx].serial) { /* any serial connections? */ if (--dc[dx].dsstime == 0) { dc[dx].dsstime = DSSCOUNTDOWN; @@ -585,7 +586,7 @@ int devamlc (int class, int func, int device) { //printf("devamlc: dss for device '%o = 0x%x\n", device, dc[dx].dss); putcrs16(A, ~dc[dx].dss); /* to the outside world, 1 = no carrier */ IOSKIP; - +#endif } else if (func == 07) { /* input AMLC status */ dc[dx].interrupting = 0; putcrs16(A, 040000 | (dc[dx].bufnum<<8) | (dc[dx].intenable<<5) | (1<<4)); @@ -750,6 +751,7 @@ int devamlc (int class, int func, int device) { /* set DTR high (02000) or low if it has changed */ +#ifdef __APPLE__ if ((getcrs16(A) ^ dc[dx].lconf[lx]) & 02000) { int modemstate; //printf("devamlc: DTR state changed\n"); @@ -762,6 +764,7 @@ int devamlc (int class, int func, int device) { } ioctl(fd, TIOCMSET, &modemstate); } +#endif break; } diff --git a/devpnc.h b/devpnc.h index 2e85642..9fbcb0c 100644 --- a/devpnc.h +++ b/devpnc.h @@ -259,7 +259,7 @@ #define MAXPNCBYTES MAXPNCWORDS*2 /* same in bytes */ #define MAXPKTBYTES (MAXPNCBYTES+4) /* adds 16-bit length word to each end */ -#ifdef DEMO +#ifdef DEMOXXX #define MAXNODEID 3 /* 0 is a dummy, 255 is broadcast */ #else #define MAXNODEID 254 /* 0 is a dummy, 255 is broadcast */ @@ -402,10 +402,12 @@ pncinitfd(int fd) { perror("setsockopt 2 failed for PNC"); fatal(NULL); } +#ifdef __APPLE__ if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) { perror("setsockopt 3 failed for PNC"); fatal(NULL); } +#endif #ifndef NOREGS fdflags |= O_NONBLOCK; #else @@ -943,7 +945,7 @@ int devpnc (int class, int func, int device) { fatal(NULL); } fclose(ringfile); -#ifdef DEMO +#ifdef DEMOXXX i = 0; for (tempid=1; tempid<=MAXNODEID; tempid++) if (ni[tempid].cstate != PNCCSNONE) @@ -974,10 +976,12 @@ int devpnc (int class, int func, int device) { perror("setsockopt failed for PNC listen"); fatal(NULL); } +#ifdef __APPLE__ if (setsockopt(pncfd, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) { perror("setsockopt 1 failed for PNC"); fatal(NULL); } +#endif addr.sin_family = AF_INET; addr.sin_port = htons(nport); addr.sin_addr.s_addr = INADDR_ANY; diff --git a/em.c b/em.c index 5c79cfe..e1a186e 100644 --- a/em.c +++ b/em.c @@ -1803,7 +1803,7 @@ static int (*devmap[64])(int, int, int) = { #elif 0 -/* this is the "full system" configuration supported by the emulator */ +/* this is the "full system" configuration supported by the emulator '04 = devasr: system console '07 = devpnc: Primenet Node Controller aka PNC (Ringnet) @@ -1825,6 +1825,7 @@ static int (*devmap[64])(int, int, int) = { '52 = devamlc: 3rd AMLC (16 lines) '53 = devamlc: 2nd AMLC (16 lines) '54 = devamlc: 1st AMLC (16 lines) +*/ static int (*devmap[64])(int, int, int) = { /* '0x */ devnone,devnone,devnone,devnone,devasr,devnone,devnone,devpnc, diff --git a/emdev.h b/emdev.h index 6fc7ccc..323a02d 100644 --- a/emdev.h +++ b/emdev.h @@ -365,7 +365,9 @@ int devasr (int class, int func, int device) { terminfo.c_lflag &= ~(ECHOCTL | ICANON); terminfo.c_oflag &= ~(TOSTOP); terminfo.c_cc[VINTR] = _POSIX_VDISABLE; /* disable ^C interrupt; use ^\ */ +#ifdef __APPLE__ terminfo.c_cc[VDSUSP] = _POSIX_VDISABLE; /* disable ^Y dsuspend */ +#endif terminfo.c_cc[VLNEXT] = _POSIX_VDISABLE; /* disable ^V lnext */ terminfo.c_cc[VDISCARD] = _POSIX_VDISABLE; /* disable ^O discard */ #if 0 diff --git a/makefile b/makefile index b86b7bf..8d69bc6 100644 --- a/makefile +++ b/makefile @@ -85,10 +85,10 @@ fixedp: # fixed clock rate, gdb (PowerPC) rm em.o -demo: # demo (limited: 1-2 amlc, 1 disk drive up to 160MB, one PNC node) (Intel) +demo: # demo (limited: 1-2 amlc, 2 disk drive up to 160MB) (Intel) rm -rf em.o - cc -DREV=\"${REV}\" -DNOREGS -DDEMO -DNOTRACE -DFAST -O em.c -fobey-inline -mdynamic-no-pic -o em + cc -DREV=\"${REV}\" -DNOREGS -DDEMO -DNOTRACE -DFAST -D__LITTLE_ENDIAN__ -O em.c -o em strip em rm -rf em.o