1
0
mirror of https://github.com/prirun/p50em.git synced 2026-04-04 20:27:59 +00:00

Changes to allow emulator to run on Linux for hosting at Linode

This commit is contained in:
Jim
2019-09-25 10:56:48 -04:00
parent a5d156c679
commit 4061b6adc9
5 changed files with 19 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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;

3
em.c
View File

@@ -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,

View File

@@ -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

View File

@@ -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