summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_conf.c
diff options
context:
space:
mode:
authordufault <dufault@FreeBSD.org>1995-03-21 11:24:05 +0000
committerdufault <dufault@FreeBSD.org>1995-03-21 11:24:05 +0000
commit0d7a7de4477ab79130ffa5843d2637f588db0415 (patch)
tree35c2fac1677fc3b5c6b768c17bba08d61ecf43be /sys/kern/tty_conf.c
parent0015f4c42bcc7da928de9f828fdbd46603010eca (diff)
downloadFreeBSD-src-0d7a7de4477ab79130ffa5843d2637f588db0415.zip
FreeBSD-src-0d7a7de4477ab79130ffa5843d2637f588db0415.tar.gz
Set it so you can add and remove line disciplines without replicating
code for looking for open slots in table (and you could hide the table if you wanted to).
Diffstat (limited to 'sys/kern/tty_conf.c')
-rw-r--r--sys/kern/tty_conf.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/sys/kern/tty_conf.c b/sys/kern/tty_conf.c
index 6b9bf4f..e565c61 100644
--- a/sys/kern/tty_conf.c
+++ b/sys/kern/tty_conf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
- * $Id: tty_conf.c,v 1.3 1994/08/02 07:42:50 davidg Exp $
+ * $Id: tty_conf.c,v 1.4 1994/10/05 21:22:24 wollman Exp $
*/
#include <sys/param.h>
@@ -89,6 +89,67 @@ struct linesw linesw[MAXLDISC] =
int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
+static struct linesw nodisc =
+{
+ ttynodisc,
+ ttyerrclose,
+ ttyerrio,
+ ttyerrio,
+ nullioctl,
+ ttyerrinput,
+ ttyerrstart,
+ nullmodem
+};
+
+#define LOADABLE_LDISC 6
+/*
+ * ldisc_register: Register a line discipline.
+ *
+ * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
+ * linesw_p: Pointer to linesw_p.
+ *
+ * Returns: Index used or -1 on failure.
+ */
+int
+ldisc_register(discipline, linesw_p)
+ int discipline;
+ struct linesw *linesw_p;
+{
+ int slot = -1;
+
+ if (discipline == LDISC_LOAD) {
+ int i;
+ for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
+ if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
+ slot = i;
+ }
+ }
+ else if (discipline >= 0 && discipline < MAXLDISC) {
+ slot = discipline;
+ }
+
+ if (slot != -1 && linesw_p)
+ linesw[slot] = *linesw_p;
+
+ return slot;
+}
+
+/*
+ * ldisc_deregister: Deregister a line discipline obtained with
+ * ldisc_register. Can only deregister "loadable" ones now.
+ *
+ * discipline: Index for discipline to unload.
+ */
+void
+ldisc_deregister(discipline)
+ int discipline;
+{
+ if (discipline >= LOADABLE_LDISC && discipline < MAXLDISC) {
+ linesw[discipline] = nodisc;
+ }
+}
+
+
/*
* Do nothing specific version of line
* discipline specific ioctl command.
OpenPOWER on IntegriCloud