Module Name:    src
Committed By:   pgoyette
Date:           Sun Mar 18 12:07:00 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: compat_60_mod.c compat_mod.c
            tty_60.c
        src/sys/kern [pgoyette-compat]: tty.c
        src/sys/sys [pgoyette-compat]: tty.h

Log Message:
Initial pass at getting the tty stuff properly modularized.  Subject
to review and revision.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/compat/common/compat_60_mod.c
cvs rdiff -u -r1.24.14.15 -r1.24.14.16 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.4.16.1 -r1.4.16.2 src/sys/compat/common/tty_60.c
cvs rdiff -u -r1.275 -r1.275.2.1 src/sys/kern/tty.c
cvs rdiff -u -r1.94 -r1.94.2.1 src/sys/sys/tty.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/compat_60_mod.c
diff -u src/sys/compat/common/compat_60_mod.c:1.1.2.7 src/sys/compat/common/compat_60_mod.c:1.1.2.8
--- src/sys/compat/common/compat_60_mod.c:1.1.2.7	Sun Mar 18 09:00:55 2018
+++ src/sys/compat/common/compat_60_mod.c	Sun Mar 18 12:06:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_60_mod.c,v 1.1.2.7 2018/03/18 09:00:55 pgoyette Exp $	*/
+/*	$NetBSD: compat_60_mod.c,v 1.1.2.8 2018/03/18 12:06:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_60_mod.c,v 1.1.2.7 2018/03/18 09:00:55 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_60_mod.c,v 1.1.2.8 2018/03/18 12:06:59 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -71,9 +71,18 @@ compat_60_init(void)
 		return 0;
 	}
 
+	error = kern_tty_60_init();
+	if (error != 0) {
+		kern_sa_60_fini();
+		kern_time_60_fini();
+		return 0;
+	}
+
 #ifdef CPU_UCODE
 	error = kern_cpu_60_init();
 	if (error != 0) {
+		kern_tty_60_fini();
+		kern_sa_60_fini();
 		kern_time_60_fini();
 		return 0;
 	}
@@ -93,8 +102,17 @@ compat_60_fini(void)
 		return error;
 #endif
 
+	error = kern_tty_60_fini();
+	if (error != 0) {
+#ifdef CPU_UCODE
+		kern_cpu_60_init();
+#endif
+		return error;
+	}
+
 	error = kern_sa_60_fini();
 	if (error != 0) {
+		kern_tty_60_init();
 #ifdef CPU_UCODE
 		kern_cpu_60_init();
 #endif
@@ -103,6 +121,7 @@ compat_60_fini(void)
 
 	error = kern_time_60_fini();
 	if (error != 0) {
+		kern_tty_60_init();
 		kern_sa_60_init();
 #ifdef CPU_UCODE
 		kern_cpu_60_init();
@@ -110,7 +129,6 @@ compat_60_fini(void)
 		return error;
 	}
 
-
 	return error;
 }
 

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.15 src/sys/compat/common/compat_mod.c:1.24.14.16
--- src/sys/compat/common/compat_mod.c:1.24.14.15	Sun Mar 18 02:05:21 2018
+++ src/sys/compat/common/compat_mod.c	Sun Mar 18 12:06:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24.14.15 2018/03/18 02:05:21 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.16 2018/03/18 12:06:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.15 2018/03/18 02:05:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.16 2018/03/18 12:06:59 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -92,7 +92,6 @@ static const char * const compat_include
 
 MODULE_WITH_ALIASES(MODULE_CLASS_EXEC, compat, NULL, &compat_includes);
 
-int	ttcompat(struct tty *, u_long, void *, int, struct lwp *);
 
 #ifdef _MODULE
 #ifdef COMPAT_16
@@ -255,11 +254,21 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		if (error != 0) {
 			return error;
 		}
+#ifdef NOTYET /* XXX */
 #ifdef COMPAT_43
+/* XXX
+ * XXX This would mean that compat_43 and compat_60 are mutually
+ * XXX exclusive.  Rather we should save the original vector
+ * XXX value, and retore it if we unload.  Note that compat_43
+ * XXX should "require" compat_60 to provide a definitive order
+ * XXX of initialization (ie, compat_60 first, then compat_43).
+ * XXX
 		KASSERT(ttcompatvec == NULL);
 		ttcompatvec = ttcompat;
 		if_43_init();
+ * XXX */
 #endif
+#endif /* XXX NOTYET */
 #ifdef COMPAT_40
 		if_40_init();
 #endif
@@ -333,6 +342,7 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		if (error != 0) {
 			return error;
 		}
+#ifdef NOTYET /* XXX */
 #ifdef COMPAT_43
 		/* Unlink ttcompatvec. */
 		if (rw_tryenter(&ttcompat_lock, RW_WRITER)) {
@@ -344,6 +354,7 @@ compat_modcmd(modcmd_t cmd, void *arg)
 			return EBUSY;
 		}
 #endif
+#endif /* NOTYET XXX */
 #ifdef COMPAT_16
 #if defined(COMPAT_SIGCONTEXT)
 		/*

Index: src/sys/compat/common/tty_60.c
diff -u src/sys/compat/common/tty_60.c:1.4.16.1 src/sys/compat/common/tty_60.c:1.4.16.2
--- src/sys/compat/common/tty_60.c:1.4.16.1	Thu Mar  8 08:55:52 2018
+++ src/sys/compat/common/tty_60.c	Sun Mar 18 12:06:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_60.c,v 1.4.16.1 2018/03/08 08:55:52 pgoyette Exp $	*/
+/*	$NetBSD: tty_60.c,v 1.4.16.2 2018/03/18 12:06:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.4.16.1 2018/03/08 08:55:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.4.16.2 2018/03/18 12:06:59 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -43,6 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1
 #include <sys/systm.h>
 
 #include <sys/tty.h>
+
+#include <compat/common/compat_mod.h>
 #include <compat/sys/ttycom.h>
 
 /* convert struct ptmget to struct compat_60_ptmget */
@@ -114,3 +116,21 @@ compat_60_ptmioctl(dev_t dev, u_long cmd
 		return EPASSTHROUGH;
 	}
 }
+
+int
+kern_tty_60_init(void)
+{
+
+	vec_compat_ttioctl_60 = compat_60_ttioctl;
+/*	vec_compat_ptmioctl_60 = compat_60_ptmioctl;	XXX NOT-YET */
+	return 0;
+}
+
+int
+kern_tty_60_fini(void)
+{
+	vec_compat_ttioctl_60 = NULL;
+/*	vec_compat_ptmioctl_60 = NULL;			XXX NOT-YET */
+
+	return 0;
+}

Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.275 src/sys/kern/tty.c:1.275.2.1
--- src/sys/kern/tty.c:1.275	Wed Oct 25 08:12:39 2017
+++ src/sys/kern/tty.c	Sun Mar 18 12:06:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.275 2017/10/25 08:12:39 maya Exp $	*/
+/*	$NetBSD: tty.c,v 1.275.2.1 2018/03/18 12:06:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.275 2017/10/25 08:12:39 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.275.2.1 2018/03/18 12:06:59 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -209,7 +209,7 @@ struct ttylist_head ttylist = TAILQ_HEAD
 int tty_count;
 kmutex_t tty_lock;
 krwlock_t ttcompat_lock;
-int (*ttcompatvec)(struct tty *, u_long, void *, int, struct lwp *);
+int (*vec_compat_ttioctl_60)(struct tty *, u_long, void *, int, struct lwp *);
 
 uint64_t tk_cancc;
 uint64_t tk_nin;
@@ -1408,24 +1408,19 @@ ttioctl(struct tty *tp, u_long cmd, void
 		default:
 			break;
 		}
-#ifdef COMPAT_60
-		error = compat_60_ttioctl(tp, cmd, data, flag, l);
-		if (error != EPASSTHROUGH)
-			return error;
-#endif /* COMPAT_60 */
 		/* We may have to load the compat module for this. */
 		for (;;) {
 			rw_enter(&ttcompat_lock, RW_READER);
-			if (ttcompatvec != NULL) {
+			if (vec_compat_ttioctl_60 != NULL) {
 				break;
 			}
 			rw_exit(&ttcompat_lock);
-			(void)module_autoload("compat", MODULE_CLASS_ANY);
-			if (ttcompatvec == NULL) {
+			(void)module_autoload("compat", MODULE_CLASS_EXEC);
+			if (vec_compat_ttioctl_60 == NULL) {
 				return EPASSTHROUGH;
 			}
 		}
-		error = (*ttcompatvec)(tp, cmd, data, flag, l);
+		error = (*vec_compat_ttioctl_60)(tp, cmd, data, flag, l);
 		rw_exit(&ttcompat_lock);
 		return error;
 	}

Index: src/sys/sys/tty.h
diff -u src/sys/sys/tty.h:1.94 src/sys/sys/tty.h:1.94.2.1
--- src/sys/sys/tty.h:1.94	Tue Oct 31 10:45:19 2017
+++ src/sys/sys/tty.h	Sun Mar 18 12:07:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.h,v 1.94 2017/10/31 10:45:19 martin Exp $	*/
+/*	$NetBSD: tty.h,v 1.94.2.1 2018/03/18 12:07:00 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -313,7 +313,8 @@ bool	 ttypull(struct tty *);
 int	clalloc(struct clist *, int, int);
 void	clfree(struct clist *);
 
-extern int (*ttcompatvec)(struct tty *, u_long, void *, int, struct lwp *);
+extern int (*vec_compat_ttioctl_60)(struct tty *, u_long, void *, int,
+    struct lwp *);
 
 unsigned char tty_getctrlchar(struct tty *, unsigned /*which*/);
 void tty_setctrlchar(struct tty *, unsigned /*which*/, unsigned char /*val*/);

Reply via email to