Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev cons(9): New function cn_set_tab.
details: https://anonhg.NetBSD.org/src/rev/f2e6d45c5a12
branches: trunk
changeset: 371715:f2e6d45c5a12
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Oct 03 19:12:29 2022 +0000
description:
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:
sys/dev/cons.c | 20 ++++++++++++++++++--
sys/dev/cons.h | 4 +++-
2 files changed, 21 insertions(+), 3 deletions(-)
diffs (59 lines):
diff -r 02e77497e6d1 -r f2e6d45c5a12 sys/dev/cons.c
--- a/sys/dev/cons.c Mon Oct 03 17:42:35 2022 +0000
+++ b/sys/dev/cons.c Mon Oct 03 19:12:29 2022 +0000
@@ -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 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)
{
diff -r 02e77497e6d1 -r f2e6d45c5a12 sys/dev/cons.h
--- a/sys/dev/cons.h Mon Oct 03 17:42:35 2022 +0000
+++ b/sys/dev/cons.h Mon Oct 03 19:12:29 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cons.h,v 1.28 2022/08/28 09:52:43 riastradh Exp $ */
+/* $NetBSD: cons.h,v 1.29 2022/10/03 19:12:29 riastradh Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -76,6 +76,8 @@
extern struct consdev constab[];
extern struct consdev *cn_tab;
+void cn_set_tab(struct consdev *);
+
void cninit(void);
int cngetc(void);
int cngetsn(char *, int);
Home |
Main Index |
Thread Index |
Old Index