Module Name: src Committed By: riastradh Date: Mon Oct 3 19:12:29 UTC 2022
Modified Files: src/sys/dev: cons.c cons.h Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/cons.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/cons.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/dev/cons.c diff -u src/sys/dev/cons.c:1.79 src/sys/dev/cons.c:1.80 --- src/sys/dev/cons.c:1.79 Mon Aug 22 00:20:56 2022 +++ src/sys/dev/cons.c Mon Oct 3 19:12:29 2022 @@ -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 c 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) { Index: src/sys/dev/cons.h diff -u src/sys/dev/cons.h:1.28 src/sys/dev/cons.h:1.29 --- src/sys/dev/cons.h:1.28 Sun Aug 28 09:52:43 2022 +++ src/sys/dev/cons.h Mon Oct 3 19:12:29 2022 @@ -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 @@ struct consdev { 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);