summaryrefslogtreecommitdiff
path: root/emu/port/deveia-bsd.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /emu/port/deveia-bsd.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'emu/port/deveia-bsd.c')
-rw-r--r--emu/port/deveia-bsd.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/emu/port/deveia-bsd.c b/emu/port/deveia-bsd.c
new file mode 100644
index 00000000..3640837d
--- /dev/null
+++ b/emu/port/deveia-bsd.c
@@ -0,0 +1,95 @@
+/*
+ * BSD serial port control features not found in POSIX
+ * including modem line control and hardware flow control
+ */
+
+static struct flagmap lines[] = {
+ {"cts", TIOCM_CTS},
+ {"dsr", TIOCM_DSR},
+ {"ring", TIOCM_RI},
+ {"dcd", TIOCM_CD},
+ {"dtr", TIOCM_DTR},
+ {"rts", TIOCM_RTS},
+ {0, -1}
+};
+
+static void
+resxtra(int port, struct termios *ts)
+{
+ int fd = eia[port].fd;
+
+ USED(ts);
+
+ if(eia[port].dtr)
+ ioctl(fd, TIOCM_DTR, eia[port].dtr);
+ if(eia[port].rts)
+ ioctl(fd, TIOCM_RTS, eia[port].rts);
+ if(eia[port].cts)
+ ioctl(fd, TIOCM_CTS, eia[port].cts);
+}
+
+static char *
+rdxtra(int port, struct termios *ts, char *str)
+{
+ int fd = eia[port].fd;
+ int line;
+// struct flagmap *lp;
+ char *s = str;
+
+ USED(ts);
+
+ if(ioctl(fd, TIOCMGET, &line) < 0)
+ oserror();
+
+// for(lp = lines; lp->str; lp++)
+// if(line&lp->flag)
+// s += sprint(s, " %s", lp->str);
+
+ return s;
+}
+
+static char *
+wrxtra(int port, struct termios *ts, char *cmd)
+{
+ int fd = eia[port].fd;
+ int n, r, flag, iocmd, *l;
+
+ USED(ts);
+
+ switch(*cmd) {
+ case 'D':
+ case 'd':
+ flag = TIOCM_DTR;
+ l = &eia[port].dtr;
+ break;
+ case 'R':
+ case 'r':
+ flag = TIOCM_RTS;
+ l = &eia[port].rts;
+ break;
+ case 'M':
+ case 'm':
+ flag = TIOCM_CTS;
+ l = &eia[port].cts;
+ break;
+ default:
+ return nil;
+ }
+
+ n = atoi(cmd+1);
+ if(n)
+ iocmd = TIOCMBIS;
+ else
+ iocmd = TIOCMBIC;
+
+ osenter();
+ r = ioctl(fd, iocmd, &flag);
+ osleave();
+ if(r < 0)
+ oserror();
+
+ eia[port].restore = 1;
+ *l = iocmd;
+
+ return nil;
+}