summaryrefslogtreecommitdiff
path: root/sys/dev/cons.c
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-10-03 19:12:29 +0000
committerriastradh <riastradh@NetBSD.org>2022-10-03 19:12:29 +0000
commit2d9449bb49d2b63993e56d3c3cf4ad92fd41a329 (patch)
treedb28adcac3b265cab4acd1eccfe8bc85d4f8173e /sys/dev/cons.c
parent02bddf7da46380295c0a2a92dd7f8194b75e41c4 (diff)
cons(9): New function cn_set_tab.
Increment of progress toward eliminating bare access to cn_tab so we can make more things MP-safe without the kernel lock (and maybe some day better formalize console detection and switching).
Diffstat (limited to 'sys/dev/cons.c')
-rw-r--r--sys/dev/cons.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/dev/cons.c b/sys/dev/cons.c
index eef38cbbc51..5763736654b 100644
--- a/sys/dev/cons.c
+++ b/sys/dev/cons.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cons.c,v 1.79 2022/08/22 00:20:56 riastradh Exp $ */
+/* $NetBSD: cons.c,v 1.80 2022/10/03 19:12:29 riastradh Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.79 2022/08/22 00:20:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.80 2022/10/03 19:12:29 riastradh Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -87,6 +87,22 @@ struct tty *constty = NULL; /* virtual console output device */
struct consdev *cn_tab; /* physical console device info */
struct vnode *cn_devvp[2]; /* vnode for underlying device. */
+void
+cn_set_tab(struct consdev *tab)
+{
+
+ /*
+ * This is a point that we should have KASSERT(cold) or add
+ * synchronization in case this can happen after cold boot.
+ * However, cn_tab initialization is so critical to any
+ * diagnostics or debugging that we need to tread carefully
+ * about introducing new ways to crash. So let's put the
+ * assertion in only after we've audited most or all of the
+ * cn_tab updates.
+ */
+ cn_tab = tab;
+}
+
int
cnopen(dev_t dev, int flag, int mode, struct lwp *l)
{