mirror of
https://github.com/prirun/p50em.git
synced 2026-01-11 23:42:56 +00:00
Additional #ifdef __APPLE__ sections removed
Some DTR handling was still inside of such #ifdefs, and thus I was unable to make a modem work on a serial port. I believe this code is portable to OSX, Linux, FreeBSD, and Solaris.
This commit is contained in:
parent
0466b4b603
commit
c6c0344004
40
devamlc.h
40
devamlc.h
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Implements the AMLC subsystem for Primos. In earlier versions
|
||||
(r186), a more hardware-centric implementation was used that closely
|
||||
followed the design of Prime's real AMLC board. For example, every
|
||||
@ -52,9 +52,9 @@
|
||||
NOTE: varying the AMLC poll rates dynamically is the default, but
|
||||
this can lead to unpredictable performance. If consistent,
|
||||
predictable performance is more important than absolute
|
||||
performance, MAXAMLCSPEEDUP can be set to 1. Then this
|
||||
performance, MAXAMLCSPEEDUP can be set to 1. Then this
|
||||
implementation will function more or less like a real Prime.
|
||||
|
||||
|
||||
|
||||
AMLC I/O operations:
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
AMLC status word (from AMLCT5):
|
||||
|
||||
BITS DESCRIPTION
|
||||
|
||||
|
||||
1 END OF RANGE INTERRUPT
|
||||
2 CLOCK RUNNING
|
||||
3-6 LINE # OF LINE WHOSE DATA SET STATUS HAS CHANGED
|
||||
@ -150,6 +150,8 @@ AMLC status word (from AMLCT5):
|
||||
|
||||
*/
|
||||
|
||||
#include <termio.h>
|
||||
|
||||
/* this macro closes an AMLC connection - used in several places
|
||||
|
||||
NOTE: don't print disconnect message on dedicated lines */
|
||||
@ -202,11 +204,11 @@ int devamlc (int class, int func, int device) {
|
||||
#define DSSCOUNTDOWN 25
|
||||
|
||||
/* connection types for each line. This _doesn't_ imply the line is
|
||||
actually connected, ie, an AMLC line may be tied to a specific
|
||||
actually connected, ie, an AMLC line may be tied to a specific
|
||||
serial device (like a USB->serial gizmo), but the USB device may
|
||||
not be plugged in. The connection type would be CT_SERIAL but
|
||||
the line's fd would be -1 and the "connected" bit would be 0 */
|
||||
|
||||
|
||||
#define CT_SOCKET 1
|
||||
#define CT_SERIAL 2
|
||||
#define CT_DEDIP 3
|
||||
@ -324,7 +326,7 @@ int devamlc (int class, int func, int device) {
|
||||
int tempport;
|
||||
struct hostent* host;
|
||||
char *p;
|
||||
|
||||
|
||||
/* initially, we don't know about any AMLC boards */
|
||||
|
||||
for (dx=0; dx<MAXBOARDS; dx++) {
|
||||
@ -346,7 +348,7 @@ int devamlc (int class, int func, int device) {
|
||||
/* read the amlc.cfg file. This file has 3 uses:
|
||||
|
||||
1. maps Prime async lines to real serial devices, like host
|
||||
serial ports or USB serial boxes.
|
||||
serial ports or USB serial boxes.
|
||||
|
||||
Format: <line #> /dev/<Unix usb device name>
|
||||
|
||||
@ -418,7 +420,7 @@ int devamlc (int class, int func, int device) {
|
||||
fprintf(stderr,"Line %d of amlc.cfg ignored: IP address too long\n", lc);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* break out host and port number; no port means this is
|
||||
an incoming dedicated line: no connects out. With a
|
||||
port means we need to connect to it. */
|
||||
@ -553,13 +555,13 @@ int devamlc (int class, int func, int device) {
|
||||
/* XXX: this constant is redefined because of a bug in the
|
||||
OSX Prolific USB serial driver at version 1.2.1r2. They should be
|
||||
turning on bit 0100, but are turning on 0x0100. */
|
||||
#define TIOCM_CD 0x0100
|
||||
#define TIOCM_CD 0x0100
|
||||
|
||||
if (func == 00) { /* input Data Set Sense (carrier) */
|
||||
if (dc[dx].serial) { /* any serial connections? */
|
||||
if (--dc[dx].dsstime == 0) {
|
||||
dc[dx].dsstime = DSSCOUNTDOWN;
|
||||
#ifdef __APPLE__
|
||||
/* #ifdef __APPLE__ */
|
||||
for (lx = 0; lx < 16; lx++) { /* yes, poll them */
|
||||
if (dc[dx].ctype[lx] == CT_SERIAL) {
|
||||
int modemstate;
|
||||
@ -575,7 +577,7 @@ int devamlc (int class, int func, int device) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* #endif */
|
||||
}
|
||||
}
|
||||
//printf("devamlc: dss for device '%o = 0x%x\n", device, dc[dx].dss);
|
||||
@ -634,10 +636,10 @@ int devamlc (int class, int func, int device) {
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case CT_SERIAL: {
|
||||
int fd;
|
||||
|
||||
|
||||
/* setup line characteristics if they have changed (check for
|
||||
something other than DTR changing) */
|
||||
|
||||
@ -707,7 +709,7 @@ int devamlc (int class, int func, int device) {
|
||||
1_0 - cts/rts flow control (2413 becomes 6413)
|
||||
1_1 - dsr/dtr flow control (2413 becomes 7413)
|
||||
|
||||
NOTE: bit 11 also appears to be free, but Primos doesn't
|
||||
NOTE: bit 11 also appears to be free, but Primos doesn't
|
||||
let it flow through to the AMLC controller. :(
|
||||
*/
|
||||
|
||||
@ -758,7 +760,6 @@ 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");
|
||||
@ -771,7 +772,6 @@ int devamlc (int class, int func, int device) {
|
||||
}
|
||||
ioctl(fd, TIOCMSET, &modemstate);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ int devamlc (int class, int func, int device) {
|
||||
double ts;
|
||||
int neweor, activelines;
|
||||
//printf("poll device '%o, speedup=%5.2f, cti=%x, xmit=%x, recv=%x, dss=%x\n", device, pollspeedup, dc[dx].ctinterrupt, dc[dx].xmitenabled, dc[dx].recvenabled, dc[dx].dss);
|
||||
|
||||
|
||||
/* check for 1 new telnet connection every AMLCACCEPTSECS seconds
|
||||
(10 times per second) */
|
||||
|
||||
@ -1036,7 +1036,7 @@ int devamlc (int class, int func, int device) {
|
||||
|
||||
int fd, sockflags;
|
||||
struct sockaddr_in raddr;
|
||||
|
||||
|
||||
dc[dx].obtimer[lx] = tv.tv_sec + AMLCCONNECT;
|
||||
//printf("em: trying to connect to 0x%08x:%d\n", dc[dx].obhost[lx], dc[dx].obport[lx]); /***/
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@ -1121,7 +1121,7 @@ int devamlc (int class, int func, int device) {
|
||||
}
|
||||
|
||||
/* process input, but only as much as will fit into the DMC
|
||||
buffer.
|
||||
buffer.
|
||||
|
||||
Because the size of the AMLC tumble tables is limited, this
|
||||
could pose a denial of service issue. Input is processed in a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user